blob: 3f69f8d20bf5c5f20d97131b18e828c0863ff3a1 [file] [log] [blame]
Brad Bishop919e4082020-10-27 18:55:19 -04001project(
2 'openpower-proc-control',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams9e178b72021-10-06 15:33:36 -05007 'cpp_std=c++20',
Brad Bishopf38b35e2020-11-08 10:42:34 -05008 'buildtype=debugoptimized',
9 'b_ndebug=if-release',
Brad Bishop919e4082020-10-27 18:55:19 -040010 ],
11 license: 'Apache-2.0',
12 version: '1.0',
Patrick Williams9e178b72021-10-06 15:33:36 -050013 meson_version: '>=0.57.0',
Brad Bishop919e4082020-10-27 18:55:19 -040014)
15add_project_arguments('-Wno-psabi', language: 'cpp')
16
Patrick Williams9e178b72021-10-06 15:33:36 -050017if get_option('cpp_std') != 'c++20'
18 error('This project requires c++20')
Brad Bishopf38b35e2020-11-08 10:42:34 -050019endif
20
21if(get_option('buildtype') == 'minsize')
22 add_project_arguments('-DNDEBUG', language : 'cpp')
23endif
24
Brad Bishop919e4082020-10-27 18:55:19 -040025cxx = meson.get_compiler('cpp')
26
27extra_sources = []
28extra_dependencies = []
29extra_unit_files = []
30
Jayanth Othayoth38405472021-07-26 06:16:44 -050031# Configuration header file(config.h) generation
32conf_data = configuration_data()
33
34conf_data.set_quoted('DEVTREE_EXPORT_FILTER_FILE', get_option('DEVTREE_EXPORT_FILTER_FILE'),
35 description : 'Path to the phal devtree export filter file'
36 )
37
38conf_data.set_quoted('DEVTREE_EXP_FILE', get_option('DEVTREE_EXP_FILE'),
39 description : 'Path to the devtree export copy file'
40 )
41
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060042conf_data.set_quoted('CEC_DEVTREE_RW_PATH', get_option('CEC_DEVTREE_RW_PATH'),
43 description : 'Path to the devtree file r/w version'
44 )
45
Marri Devender Rao90166c12022-01-07 02:22:53 -060046conf_data.set_quoted('CEC_DEVTREE_RO_BASE_PATH', get_option('CEC_DEVTREE_RO_BASE_PATH'),
47 description : 'Base path to the devtree file read only version'
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060048 )
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060049conf_data.set_quoted('CEC_INFODB_PATH', get_option('CEC_INFODB_PATH'),
50 description : 'Path to the devtree attributes based database path'
51 )
52
53conf_data.set_quoted('DEVTREE_REINIT_ATTRS_LIST', get_option('DEVTREE_REINIT_ATTRS_LIST'),
54 description : 'Path to the phal devtree reinit attribute list file'
55 )
56
Jayanth Othayoth38405472021-07-26 06:16:44 -050057configure_file(configuration : conf_data,
58 output : 'config.h'
59 )
60
Brad Bishop919e4082020-10-27 18:55:19 -040061unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050062unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
63unit_subs.set('ENABLE_PHAL_TRUE', '#')
Adriana Kobylakbbb53392022-02-14 21:15:48 +000064unit_subs.set('CEC_DEVTREE_RW_PATH', get_option('CEC_DEVTREE_RW_PATH'),
65 description : 'Path to the devtree file r/w version'
66 )
Brad Bishop919e4082020-10-27 18:55:19 -040067
68if get_option('phal').enabled() and get_option('p9').enabled()
69 error('phal and p9 cannot be selected at the same time')
70endif
71
72build_p9 = not get_option('p9').disabled()
73build_openfsi = not get_option('openfsi').disabled()
74build_phal = get_option('phal').enabled()
75
76if get_option('phal').enabled() and not get_option('p9').disabled()
77 build_p9 = false
78endif
79
80summary('building p9', build_p9)
81summary('building openfsi', build_openfsi)
82summary('building phal', build_phal)
83
84if build_p9
85 extra_sources += [
86 'procedures/p9/cleanup_pcie.cpp',
87 'procedures/p9/set_sync_fsi_clock_mode.cpp',
88 'procedures/p9/start_host.cpp',
89 'procedures/p9/start_host_mpreboot.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -050090 'procedures/p9/enter_mpreboot.cpp',
Jayanth Othayothee10ead2021-12-05 22:54:06 -060091 'procedures/p9/thread_stopall.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040092 ]
93endif
94if build_openfsi
95 extra_sources += [
96 'procedures/openfsi/scan.cpp',
97 ]
98endif
99if build_phal
100 extra_sources += [
101 'procedures/phal/start_host.cpp',
102 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -0600103 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -0500104 'procedures/phal/check_host_running.cpp',
105 'procedures/phal/import_devtree.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -0500106 'procedures/phal/enter_mpreboot.cpp',
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600107 'procedures/phal/reinit_devtree.cpp',
Jayanth Othayoth5f2eaf12021-11-30 11:08:51 -0600108 'procedures/phal/thread_stopall.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -0500109 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -0500110 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -0500111 'extensions/phal/create_pel.cpp',
112 'extensions/phal/phal_error.cpp',
Jayanth Othayoth21a889f2021-10-07 06:53:40 -0500113 'extensions/phal/dump_utils.cpp',
Jayanth Othayoth4f7b9bd2021-11-25 08:11:12 -0600114 'temporary_file.cpp',
Marri Devender Rao4d5b5bf2022-05-23 09:23:31 -0500115 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400116 ]
117 extra_dependencies += [
118 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -0400119 cxx.find_library('ekb'),
120 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -0500121 cxx.find_library('phal'),
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600122 cxx.find_library('dtree'),
Brad Bishop919e4082020-10-27 18:55:19 -0400123 ]
124 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500125 'service_files/set-spi-mux.service',
126 'service_files/phal-reinit-devtree.service',
127 'service_files/proc-pre-poweroff@.service',
Andrew Geissler9ca8a112022-04-07 16:18:47 -0500128 'service_files/op-clear-sys-dump-active@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500129 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500130 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500131 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500132 'service_files/phal-export-devtree@.service',
Ramesh Iyyar482a8872022-02-24 01:42:52 -0600133 'service_files/phal-create-boottime-guard-indicator.service',
Jayanth Othayoth1af14432022-09-12 01:19:10 -0500134 'service_files/op-clock-data-logger@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400135 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500136 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400137endif
138
139executable(
140 'openpower-proc-control',
141 [
142 'cfam_access.cpp',
143 'ext_interface.cpp',
144 'filedescriptor.cpp',
145 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400146 'targeting.cpp',
147 'procedures/common/cfam_overrides.cpp',
148 'procedures/common/cfam_reset.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400149 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500150 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400151 ] + extra_sources,
152 dependencies: [
153 dependency('libgpiodcxx'),
154 cxx.find_library('pdbg'),
155 dependency('phosphor-dbus-interfaces'),
156 dependency('phosphor-logging'),
157 dependency('sdbusplus'),
158 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500159 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500160 ] + extra_dependencies,
161 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400162)
163
164executable(
165 'openpower-proc-nmi',
166 [
167 'nmi_main.cpp',
168 'nmi_interface.cpp',
169 ],
170 dependencies: [
171 cxx.find_library('pdbg'),
172 dependency('phosphor-dbus-interfaces'),
173 dependency('phosphor-logging'),
174 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500175 ],
176 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400177)
178
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500179if build_phal
180 executable(
181 'phal-export-devtree',
182 [
183 'extensions/phal/devtree_export.cpp',
184 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500185 'extensions/phal/pdbg_utils.cpp',
186 'extensions/phal/create_pel.cpp',
187 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500188 ],
189 dependencies: [
190 dependency('phosphor-logging'),
191 dependency('sdbusplus'),
192 dependency('sdeventplus'),
193 dependency('fmt'),
Jayanth Othayoth38405472021-07-26 06:16:44 -0500194 dependency('phosphor-dbus-interfaces'),
195 cxx.find_library('pdbg'),
Jayanth Othayothe5ba5fd2022-01-27 09:29:01 -0600196 cxx.find_library('phal'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500197 ],
198 install: true
199 )
Jayanth Othayothed7fb7a2022-09-09 00:07:41 -0500200
201 executable(
202 'openpower-clock-data-logger',
203 [
204 'extensions/phal/clock_logger_main.cpp',
205 'extensions/phal/clock_logger.cpp',
206 'extensions/phal/create_pel.cpp',
207 'util.cpp',
208 ],
209 dependencies: [
210 cxx.find_library('dtree'),
211 cxx.find_library('pdbg'),
212 cxx.find_library('phal'),
213 dependency('libdt-api'),
214 dependency('phosphor-logging'),
215 dependency('sdbusplus'),
216 dependency('sdeventplus'),
217 ],
218 install: true
219)
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500220endif
221
Brad Bishop919e4082020-10-27 18:55:19 -0400222unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500223 'service_files/pcie-poweroff@.service',
224 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
225 'service_files/op-stop-instructions@.service',
226 'service_files/op-cfam-reset.service',
227 'service_files/op-continue-mpreboot@.service',
228 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400229] + extra_unit_files
230
231systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
232 'systemdsystemunitdir',
233 define_variable: ['prefix', get_option('prefix')])
234foreach u : unit_files
235 configure_file(
236 configuration: unit_subs,
237 input: u + '.in',
238 install: true,
239 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500240 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400241 )
242endforeach
243
244if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400245 test(
246 'utest',
247 executable(
248 'utest',
249 'test/utest.cpp',
250 'targeting.cpp',
251 'filedescriptor.cpp',
252 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500253 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400254 dependency('phosphor-logging'),
255 ],
256 implicit_include_directories: false,
257 include_directories: '.',
258 )
259 )
260endif