blob: 35aeae9322753a9abe8b2d82dc83e4d8ef22968d [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
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
Dhruvaraj Subhashchandran5235dba2024-06-01 11:01:49 -050057conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path'),
58 description : 'Object path requesting OpenPOWER dumps'
59 )
60
Jayanth Othayoth38405472021-07-26 06:16:44 -050061configure_file(configuration : conf_data,
62 output : 'config.h'
63 )
64
Brad Bishop919e4082020-10-27 18:55:19 -040065unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050066unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
67unit_subs.set('ENABLE_PHAL_TRUE', '#')
Adriana Kobylakbbb53392022-02-14 21:15:48 +000068unit_subs.set('CEC_DEVTREE_RW_PATH', get_option('CEC_DEVTREE_RW_PATH'),
69 description : 'Path to the devtree file r/w version'
70 )
Brad Bishop919e4082020-10-27 18:55:19 -040071
72if get_option('phal').enabled() and get_option('p9').enabled()
73 error('phal and p9 cannot be selected at the same time')
74endif
75
76build_p9 = not get_option('p9').disabled()
77build_openfsi = not get_option('openfsi').disabled()
78build_phal = get_option('phal').enabled()
79
80if get_option('phal').enabled() and not get_option('p9').disabled()
81 build_p9 = false
82endif
83
84summary('building p9', build_p9)
85summary('building openfsi', build_openfsi)
86summary('building phal', build_phal)
87
88if build_p9
89 extra_sources += [
90 'procedures/p9/cleanup_pcie.cpp',
91 'procedures/p9/set_sync_fsi_clock_mode.cpp',
92 'procedures/p9/start_host.cpp',
93 'procedures/p9/start_host_mpreboot.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -050094 'procedures/p9/enter_mpreboot.cpp',
Jayanth Othayothee10ead2021-12-05 22:54:06 -060095 'procedures/p9/thread_stopall.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040096 ]
97endif
98if build_openfsi
99 extra_sources += [
100 'procedures/openfsi/scan.cpp',
101 ]
102endif
103if build_phal
104 extra_sources += [
105 'procedures/phal/start_host.cpp',
106 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -0600107 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -0500108 'procedures/phal/check_host_running.cpp',
109 'procedures/phal/import_devtree.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -0500110 'procedures/phal/enter_mpreboot.cpp',
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600111 'procedures/phal/reinit_devtree.cpp',
Jayanth Othayoth5f2eaf12021-11-30 11:08:51 -0600112 'procedures/phal/thread_stopall.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -0500113 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -0500114 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -0500115 'extensions/phal/create_pel.cpp',
116 'extensions/phal/phal_error.cpp',
Jayanth Othayoth21a889f2021-10-07 06:53:40 -0500117 'extensions/phal/dump_utils.cpp',
Jayanth Othayoth4f7b9bd2021-11-25 08:11:12 -0600118 'temporary_file.cpp',
Marri Devender Rao4d5b5bf2022-05-23 09:23:31 -0500119 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400120 ]
121 extra_dependencies += [
122 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -0400123 cxx.find_library('ekb'),
124 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -0500125 cxx.find_library('phal'),
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600126 cxx.find_library('dtree'),
Brad Bishop919e4082020-10-27 18:55:19 -0400127 ]
128 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500129 'service_files/set-spi-mux.service',
130 'service_files/phal-reinit-devtree.service',
131 'service_files/proc-pre-poweroff@.service',
Andrew Geissler9ca8a112022-04-07 16:18:47 -0500132 'service_files/op-clear-sys-dump-active@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500133 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500134 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500135 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500136 'service_files/phal-export-devtree@.service',
Ramesh Iyyar482a8872022-02-24 01:42:52 -0600137 'service_files/phal-create-boottime-guard-indicator.service',
Jayanth Othayoth1af14432022-09-12 01:19:10 -0500138 'service_files/op-clock-data-logger@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400139 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500140 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400141endif
142
Matt Spinler81cae312024-08-02 10:35:36 -0500143libgpiodcxx_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
144sdbusplus_dep = dependency('sdbusplus')
145sdeventplus_dep = dependency('sdeventplus')
146pdi_dep = dependency('phosphor-dbus-interfaces')
147phosphor_logging_dep = dependency('phosphor-logging')
148
149gtest = dependency('gtest', main: true, disabler: true, required: false, include_type: 'system')
150if get_option('tests').allowed()
151 if not gtest.found()
152 gtest_proj = import('cmake').subproject('gtest', required: false)
153 if gtest_proj.found()
154 gtest = declare_dependency(
155 dependencies: [
156 dependency('threads'),
157 gtest_proj.dependency('gtest'),
158 gtest_proj.dependency('gtest_main'),
159 ]
160 )
161 else
162 assert(
163 not get_option('tests').enabled(),
164 'Googletest is required if tests are enabled'
165 )
166 endif
167 endif
168endif
169
Brad Bishop919e4082020-10-27 18:55:19 -0400170executable(
171 'openpower-proc-control',
172 [
173 'cfam_access.cpp',
174 'ext_interface.cpp',
175 'filedescriptor.cpp',
176 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400177 'targeting.cpp',
178 'procedures/common/cfam_overrides.cpp',
179 'procedures/common/cfam_reset.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400180 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500181 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400182 ] + extra_sources,
183 dependencies: [
Matt Spinler81cae312024-08-02 10:35:36 -0500184 libgpiodcxx_dep,
Brad Bishop919e4082020-10-27 18:55:19 -0400185 cxx.find_library('pdbg'),
Matt Spinler81cae312024-08-02 10:35:36 -0500186 pdi_dep,
187 phosphor_logging_dep,
188 sdbusplus_dep,
Brad Bishop919e4082020-10-27 18:55:19 -0400189 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500190 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500191 ] + extra_dependencies,
192 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400193)
194
195executable(
196 'openpower-proc-nmi',
197 [
198 'nmi_main.cpp',
199 'nmi_interface.cpp',
200 ],
201 dependencies: [
202 cxx.find_library('pdbg'),
Matt Spinler81cae312024-08-02 10:35:36 -0500203 pdi_dep,
204 phosphor_logging_dep,
205 sdbusplus_dep,
Brad Bishopce08fb92020-11-08 09:50:48 -0500206 ],
207 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400208)
209
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500210if build_phal
211 executable(
212 'phal-export-devtree',
213 [
214 'extensions/phal/devtree_export.cpp',
215 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500216 'extensions/phal/pdbg_utils.cpp',
217 'extensions/phal/create_pel.cpp',
218 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500219 ],
220 dependencies: [
Matt Spinler81cae312024-08-02 10:35:36 -0500221 phosphor_logging_dep,
222 sdbusplus_dep,
223 sdeventplus_dep,
224 pdi_dep,
Jayanth Othayoth38405472021-07-26 06:16:44 -0500225 cxx.find_library('pdbg'),
Jayanth Othayothe5ba5fd2022-01-27 09:29:01 -0600226 cxx.find_library('phal'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500227 ],
228 install: true
229 )
Jayanth Othayothed7fb7a2022-09-09 00:07:41 -0500230
231 executable(
232 'openpower-clock-data-logger',
233 [
234 'extensions/phal/clock_logger_main.cpp',
235 'extensions/phal/clock_logger.cpp',
236 'extensions/phal/create_pel.cpp',
237 'util.cpp',
238 ],
239 dependencies: [
240 cxx.find_library('dtree'),
241 cxx.find_library('pdbg'),
242 cxx.find_library('phal'),
243 dependency('libdt-api'),
Matt Spinler81cae312024-08-02 10:35:36 -0500244 phosphor_logging_dep,
245 sdbusplus_dep,
246 sdeventplus_dep,
Jayanth Othayothed7fb7a2022-09-09 00:07:41 -0500247 ],
248 install: true
249)
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500250endif
251
Brad Bishop919e4082020-10-27 18:55:19 -0400252unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500253 'service_files/pcie-poweroff@.service',
254 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
255 'service_files/op-stop-instructions@.service',
256 'service_files/op-cfam-reset.service',
257 'service_files/op-continue-mpreboot@.service',
258 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400259] + extra_unit_files
260
Patrick Williams00299872023-04-12 08:05:17 -0500261systemd_system_unit_dir = dependency('systemd').get_variable(
Brad Bishop919e4082020-10-27 18:55:19 -0400262 'systemdsystemunitdir',
Patrick Williams00299872023-04-12 08:05:17 -0500263 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop919e4082020-10-27 18:55:19 -0400264foreach u : unit_files
265 configure_file(
266 configuration: unit_subs,
267 input: u + '.in',
268 install: true,
269 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500270 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400271 )
272endforeach
273
274if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400275 test(
276 'utest',
277 executable(
278 'utest',
279 'test/utest.cpp',
280 'targeting.cpp',
281 'filedescriptor.cpp',
282 dependencies: [
Matt Spinler81cae312024-08-02 10:35:36 -0500283 gtest,
Brad Bishop919e4082020-10-27 18:55:19 -0400284 dependency('phosphor-logging'),
285 ],
286 implicit_include_directories: false,
287 include_directories: '.',
288 )
289 )
290endif