blob: bb60f736c2eeadb0a856b98748c9f662f0839106 [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 Williams6529d782023-07-12 11:27:39 -05007 'cpp_std=c++23',
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 Williams6529d782023-07-12 11:27:39 -050013 meson_version: '>=1.1.1',
Brad Bishop919e4082020-10-27 18:55:19 -040014)
15add_project_arguments('-Wno-psabi', language: 'cpp')
16
Patrick Williams6529d782023-07-12 11:27:39 -050017if get_option('cpp_std') != 'c++23'
18 error('This project requires c++23')
Brad Bishopf38b35e2020-11-08 10:42:34 -050019endif
20
Patrick Williams81cf0652025-02-01 08:36:55 -050021if (get_option('buildtype') == 'minsize')
22 add_project_arguments('-DNDEBUG', language: 'cpp')
Brad Bishopf38b35e2020-11-08 10:42:34 -050023endif
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
Patrick Williams81cf0652025-02-01 08:36:55 -050034conf_data.set_quoted(
35 'DEVTREE_EXPORT_FILTER_FILE',
36 get_option('DEVTREE_EXPORT_FILTER_FILE'),
37 description: 'Path to the phal devtree export filter file',
38)
Jayanth Othayoth38405472021-07-26 06:16:44 -050039
Patrick Williams81cf0652025-02-01 08:36:55 -050040conf_data.set_quoted(
41 'DEVTREE_EXP_FILE',
42 get_option('DEVTREE_EXP_FILE'),
43 description: 'Path to the devtree export copy file',
44)
Jayanth Othayoth38405472021-07-26 06:16:44 -050045
Patrick Williams81cf0652025-02-01 08:36:55 -050046conf_data.set_quoted(
47 'CEC_DEVTREE_RW_PATH',
48 get_option('CEC_DEVTREE_RW_PATH'),
49 description: 'Path to the devtree file r/w version',
50)
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060051
Patrick Williams81cf0652025-02-01 08:36:55 -050052conf_data.set_quoted(
53 'CEC_DEVTREE_RO_BASE_PATH',
54 get_option('CEC_DEVTREE_RO_BASE_PATH'),
55 description: 'Base path to the devtree file read only version',
56)
57conf_data.set_quoted(
58 'CEC_INFODB_PATH',
59 get_option('CEC_INFODB_PATH'),
60 description: 'Path to the devtree attributes based database path',
61)
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060062
Patrick Williams81cf0652025-02-01 08:36:55 -050063conf_data.set_quoted(
64 'DEVTREE_REINIT_ATTRS_LIST',
65 get_option('DEVTREE_REINIT_ATTRS_LIST'),
66 description: 'Path to the phal devtree reinit attribute list file',
67)
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -060068
Patrick Williams81cf0652025-02-01 08:36:55 -050069conf_data.set_quoted(
70 'OP_DUMP_OBJ_PATH',
71 get_option('op_dump_obj_path'),
72 description: 'Object path requesting OpenPOWER dumps',
73)
Dhruvaraj Subhashchandran5235dba2024-06-01 11:01:49 -050074
Patrick Williams81cf0652025-02-01 08:36:55 -050075configure_file(configuration: conf_data, output: 'config.h')
Jayanth Othayoth38405472021-07-26 06:16:44 -050076
Brad Bishop919e4082020-10-27 18:55:19 -040077unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050078unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
79unit_subs.set('ENABLE_PHAL_TRUE', '#')
Patrick Williams81cf0652025-02-01 08:36:55 -050080unit_subs.set(
81 'CEC_DEVTREE_RW_PATH',
82 get_option('CEC_DEVTREE_RW_PATH'),
83 description: 'Path to the devtree file r/w version',
84)
Brad Bishop919e4082020-10-27 18:55:19 -040085
86if get_option('phal').enabled() and get_option('p9').enabled()
87 error('phal and p9 cannot be selected at the same time')
88endif
89
90build_p9 = not get_option('p9').disabled()
91build_openfsi = not get_option('openfsi').disabled()
92build_phal = get_option('phal').enabled()
93
94if get_option('phal').enabled() and not get_option('p9').disabled()
95 build_p9 = false
96endif
97
98summary('building p9', build_p9)
99summary('building openfsi', build_openfsi)
100summary('building phal', build_phal)
101
102if build_p9
103 extra_sources += [
104 'procedures/p9/cleanup_pcie.cpp',
105 'procedures/p9/set_sync_fsi_clock_mode.cpp',
106 'procedures/p9/start_host.cpp',
107 'procedures/p9/start_host_mpreboot.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -0500108 'procedures/p9/enter_mpreboot.cpp',
Jayanth Othayothee10ead2021-12-05 22:54:06 -0600109 'procedures/p9/thread_stopall.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400110 ]
111endif
112if build_openfsi
Patrick Williams81cf0652025-02-01 08:36:55 -0500113 extra_sources += ['procedures/openfsi/scan.cpp']
Brad Bishop919e4082020-10-27 18:55:19 -0400114endif
115if build_phal
116 extra_sources += [
117 'procedures/phal/start_host.cpp',
118 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -0600119 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -0500120 'procedures/phal/check_host_running.cpp',
121 'procedures/phal/import_devtree.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -0500122 'procedures/phal/enter_mpreboot.cpp',
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600123 'procedures/phal/reinit_devtree.cpp',
Jayanth Othayoth5f2eaf12021-11-30 11:08:51 -0600124 'procedures/phal/thread_stopall.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -0500125 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -0500126 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -0500127 'extensions/phal/create_pel.cpp',
128 'extensions/phal/phal_error.cpp',
Jayanth Othayoth21a889f2021-10-07 06:53:40 -0500129 'extensions/phal/dump_utils.cpp',
Jayanth Othayoth4f7b9bd2021-11-25 08:11:12 -0600130 'temporary_file.cpp',
Marri Devender Rao4d5b5bf2022-05-23 09:23:31 -0500131 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400132 ]
133 extra_dependencies += [
134 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -0400135 cxx.find_library('ekb'),
136 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -0500137 cxx.find_library('phal'),
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600138 cxx.find_library('dtree'),
Brad Bishop919e4082020-10-27 18:55:19 -0400139 ]
140 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500141 'service_files/set-spi-mux.service',
142 'service_files/phal-reinit-devtree.service',
143 'service_files/proc-pre-poweroff@.service',
Andrew Geissler9ca8a112022-04-07 16:18:47 -0500144 'service_files/op-clear-sys-dump-active@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500145 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500146 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500147 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500148 'service_files/phal-export-devtree@.service',
Ramesh Iyyar482a8872022-02-24 01:42:52 -0600149 'service_files/phal-create-boottime-guard-indicator.service',
Jayanth Othayoth1af14432022-09-12 01:19:10 -0500150 'service_files/op-clock-data-logger@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400151 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500152 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400153endif
154
Matt Spinler81cae312024-08-02 10:35:36 -0500155libgpiodcxx_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
156sdbusplus_dep = dependency('sdbusplus')
157sdeventplus_dep = dependency('sdeventplus')
158pdi_dep = dependency('phosphor-dbus-interfaces')
159phosphor_logging_dep = dependency('phosphor-logging')
160
Patrick Williams81cf0652025-02-01 08:36:55 -0500161gtest = dependency(
162 'gtest',
163 main: true,
164 disabler: true,
165 required: false,
166 include_type: 'system',
167)
Matt Spinler81cae312024-08-02 10:35:36 -0500168if get_option('tests').allowed()
169 if not gtest.found()
170 gtest_proj = import('cmake').subproject('gtest', required: false)
171 if gtest_proj.found()
172 gtest = declare_dependency(
173 dependencies: [
174 dependency('threads'),
175 gtest_proj.dependency('gtest'),
176 gtest_proj.dependency('gtest_main'),
Patrick Williams81cf0652025-02-01 08:36:55 -0500177 ],
Matt Spinler81cae312024-08-02 10:35:36 -0500178 )
179 else
180 assert(
181 not get_option('tests').enabled(),
Patrick Williams81cf0652025-02-01 08:36:55 -0500182 'Googletest is required if tests are enabled',
Matt Spinler81cae312024-08-02 10:35:36 -0500183 )
184 endif
185 endif
186endif
187
Brad Bishop919e4082020-10-27 18:55:19 -0400188executable(
189 'openpower-proc-control',
190 [
191 'cfam_access.cpp',
192 'ext_interface.cpp',
193 'filedescriptor.cpp',
194 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400195 'targeting.cpp',
196 'procedures/common/cfam_overrides.cpp',
197 'procedures/common/cfam_reset.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400198 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500199 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400200 ] + extra_sources,
201 dependencies: [
Matt Spinler81cae312024-08-02 10:35:36 -0500202 libgpiodcxx_dep,
Brad Bishop919e4082020-10-27 18:55:19 -0400203 cxx.find_library('pdbg'),
Matt Spinler81cae312024-08-02 10:35:36 -0500204 pdi_dep,
205 phosphor_logging_dep,
206 sdbusplus_dep,
Brad Bishop919e4082020-10-27 18:55:19 -0400207 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500208 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500209 ] + extra_dependencies,
Patrick Williams81cf0652025-02-01 08:36:55 -0500210 install: true,
Brad Bishop919e4082020-10-27 18:55:19 -0400211)
212
213executable(
214 'openpower-proc-nmi',
Patrick Williams81cf0652025-02-01 08:36:55 -0500215 ['nmi_main.cpp', 'nmi_interface.cpp'],
Brad Bishop919e4082020-10-27 18:55:19 -0400216 dependencies: [
217 cxx.find_library('pdbg'),
Matt Spinler81cae312024-08-02 10:35:36 -0500218 pdi_dep,
219 phosphor_logging_dep,
220 sdbusplus_dep,
Patrick Williams81cf0652025-02-01 08:36:55 -0500221 ],
222 install: true,
Brad Bishop919e4082020-10-27 18:55:19 -0400223)
224
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500225if build_phal
226 executable(
227 'phal-export-devtree',
228 [
229 'extensions/phal/devtree_export.cpp',
230 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500231 'extensions/phal/pdbg_utils.cpp',
232 'extensions/phal/create_pel.cpp',
233 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500234 ],
235 dependencies: [
Matt Spinler81cae312024-08-02 10:35:36 -0500236 phosphor_logging_dep,
237 sdbusplus_dep,
238 sdeventplus_dep,
239 pdi_dep,
Jayanth Othayoth38405472021-07-26 06:16:44 -0500240 cxx.find_library('pdbg'),
Jayanth Othayothe5ba5fd2022-01-27 09:29:01 -0600241 cxx.find_library('phal'),
Patrick Williams81cf0652025-02-01 08:36:55 -0500242 ],
243 install: true,
244 )
Jayanth Othayothed7fb7a2022-09-09 00:07:41 -0500245
Patrick Williams81cf0652025-02-01 08:36:55 -0500246 executable(
247 'openpower-clock-data-logger',
248 [
Jayanth Othayothed7fb7a2022-09-09 00:07:41 -0500249 'extensions/phal/clock_logger_main.cpp',
250 'extensions/phal/clock_logger.cpp',
251 'extensions/phal/create_pel.cpp',
252 'util.cpp',
Patrick Williams81cf0652025-02-01 08:36:55 -0500253 ],
254 dependencies: [
255 cxx.find_library('dtree'),
256 cxx.find_library('pdbg'),
257 cxx.find_library('phal'),
258 dependency('libdt-api'),
259 phosphor_logging_dep,
260 sdbusplus_dep,
261 sdeventplus_dep,
262 ],
263 install: true,
264 )
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500265endif
266
Brad Bishop919e4082020-10-27 18:55:19 -0400267unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500268 'service_files/pcie-poweroff@.service',
269 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
270 'service_files/op-stop-instructions@.service',
271 'service_files/op-cfam-reset.service',
272 'service_files/op-continue-mpreboot@.service',
273 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400274] + extra_unit_files
275
Patrick Williams00299872023-04-12 08:05:17 -0500276systemd_system_unit_dir = dependency('systemd').get_variable(
Brad Bishop919e4082020-10-27 18:55:19 -0400277 'systemdsystemunitdir',
Patrick Williams81cf0652025-02-01 08:36:55 -0500278 pkgconfig_define: ['prefix', get_option('prefix')],
279)
Brad Bishop919e4082020-10-27 18:55:19 -0400280foreach u : unit_files
281 configure_file(
282 configuration: unit_subs,
283 input: u + '.in',
284 install: true,
285 install_dir: systemd_system_unit_dir,
Patrick Williams81cf0652025-02-01 08:36:55 -0500286 output: '@BASENAME@',
Brad Bishop919e4082020-10-27 18:55:19 -0400287 )
288endforeach
289
290if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400291 test(
292 'utest',
293 executable(
294 'utest',
295 'test/utest.cpp',
296 'targeting.cpp',
297 'filedescriptor.cpp',
Patrick Williams81cf0652025-02-01 08:36:55 -0500298 dependencies: [gtest, dependency('phosphor-logging')],
Brad Bishop919e4082020-10-27 18:55:19 -0400299 implicit_include_directories: false,
300 include_directories: '.',
Patrick Williams81cf0652025-02-01 08:36:55 -0500301 ),
Brad Bishop919e4082020-10-27 18:55:19 -0400302 )
303endif