blob: a1ec942572daec8ad72f21437e1b9bc380145408 [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
46conf_data.set_quoted('CEC_DEVTREE_RO_PATH', get_option('CEC_DEVTREE_RO_PATH'),
47 description : 'Path to the devtree file read only version'
48 )
49
50conf_data.set_quoted('CEC_INFODB_PATH', get_option('CEC_INFODB_PATH'),
51 description : 'Path to the devtree attributes based database path'
52 )
53
54conf_data.set_quoted('DEVTREE_REINIT_ATTRS_LIST', get_option('DEVTREE_REINIT_ATTRS_LIST'),
55 description : 'Path to the phal devtree reinit attribute list file'
56 )
57
Jayanth Othayoth38405472021-07-26 06:16:44 -050058configure_file(configuration : conf_data,
59 output : 'config.h'
60 )
61
Brad Bishop919e4082020-10-27 18:55:19 -040062unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050063unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
64unit_subs.set('ENABLE_PHAL_TRUE', '#')
Brad Bishop919e4082020-10-27 18:55:19 -040065
66if get_option('phal').enabled() and get_option('p9').enabled()
67 error('phal and p9 cannot be selected at the same time')
68endif
69
70build_p9 = not get_option('p9').disabled()
71build_openfsi = not get_option('openfsi').disabled()
72build_phal = get_option('phal').enabled()
73
74if get_option('phal').enabled() and not get_option('p9').disabled()
75 build_p9 = false
76endif
77
78summary('building p9', build_p9)
79summary('building openfsi', build_openfsi)
80summary('building phal', build_phal)
81
82if build_p9
83 extra_sources += [
84 'procedures/p9/cleanup_pcie.cpp',
85 'procedures/p9/set_sync_fsi_clock_mode.cpp',
86 'procedures/p9/start_host.cpp',
87 'procedures/p9/start_host_mpreboot.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -050088 'procedures/p9/enter_mpreboot.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040089 ]
90endif
91if build_openfsi
92 extra_sources += [
93 'procedures/openfsi/scan.cpp',
94 ]
95endif
96if build_phal
97 extra_sources += [
98 'procedures/phal/start_host.cpp',
99 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -0600100 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -0500101 'procedures/phal/check_host_running.cpp',
102 'procedures/phal/import_devtree.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -0500103 'procedures/phal/enter_mpreboot.cpp',
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600104 'procedures/phal/reinit_devtree.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -0500105 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -0500106 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -0500107 'extensions/phal/create_pel.cpp',
108 'extensions/phal/phal_error.cpp',
Jayanth Othayoth21a889f2021-10-07 06:53:40 -0500109 'extensions/phal/dump_utils.cpp',
Jayanth Othayoth4f7b9bd2021-11-25 08:11:12 -0600110 'temporary_file.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400111 ]
112 extra_dependencies += [
113 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -0400114 cxx.find_library('ekb'),
115 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -0500116 cxx.find_library('phal'),
Jayanth Othayoth94fc70c2021-11-25 08:18:03 -0600117 cxx.find_library('dtree'),
Brad Bishop919e4082020-10-27 18:55:19 -0400118 ]
119 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500120 'service_files/set-spi-mux.service',
121 'service_files/phal-reinit-devtree.service',
122 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500123 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500124 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500125 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500126 'service_files/phal-export-devtree@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400127 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500128 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400129endif
130
131executable(
132 'openpower-proc-control',
133 [
134 'cfam_access.cpp',
135 'ext_interface.cpp',
136 'filedescriptor.cpp',
137 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400138 'targeting.cpp',
139 'procedures/common/cfam_overrides.cpp',
140 'procedures/common/cfam_reset.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400141 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500142 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400143 ] + extra_sources,
144 dependencies: [
145 dependency('libgpiodcxx'),
146 cxx.find_library('pdbg'),
147 dependency('phosphor-dbus-interfaces'),
148 dependency('phosphor-logging'),
149 dependency('sdbusplus'),
150 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500151 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500152 ] + extra_dependencies,
153 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400154)
155
156executable(
157 'openpower-proc-nmi',
158 [
159 'nmi_main.cpp',
160 'nmi_interface.cpp',
161 ],
162 dependencies: [
163 cxx.find_library('pdbg'),
164 dependency('phosphor-dbus-interfaces'),
165 dependency('phosphor-logging'),
166 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500167 ],
168 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400169)
170
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500171if build_phal
172 executable(
173 'phal-export-devtree',
174 [
175 'extensions/phal/devtree_export.cpp',
176 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500177 'extensions/phal/pdbg_utils.cpp',
178 'extensions/phal/create_pel.cpp',
179 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500180 ],
181 dependencies: [
182 dependency('phosphor-logging'),
183 dependency('sdbusplus'),
184 dependency('sdeventplus'),
185 dependency('fmt'),
Jayanth Othayoth38405472021-07-26 06:16:44 -0500186 dependency('phosphor-dbus-interfaces'),
187 cxx.find_library('pdbg'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500188 ],
189 install: true
190 )
191endif
192
Brad Bishop919e4082020-10-27 18:55:19 -0400193unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500194 'service_files/pcie-poweroff@.service',
195 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
196 'service_files/op-stop-instructions@.service',
197 'service_files/op-cfam-reset.service',
198 'service_files/op-continue-mpreboot@.service',
199 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400200] + extra_unit_files
201
202systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
203 'systemdsystemunitdir',
204 define_variable: ['prefix', get_option('prefix')])
205foreach u : unit_files
206 configure_file(
207 configuration: unit_subs,
208 input: u + '.in',
209 install: true,
210 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500211 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400212 )
213endforeach
214
215if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400216 test(
217 'utest',
218 executable(
219 'utest',
220 'test/utest.cpp',
221 'targeting.cpp',
222 'filedescriptor.cpp',
223 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500224 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400225 dependency('phosphor-logging'),
226 ],
227 implicit_include_directories: false,
228 include_directories: '.',
229 )
230 )
231endif