blob: d39f9f520be657082afa70e5f161d3a86cd2b657 [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
42configure_file(configuration : conf_data,
43 output : 'config.h'
44 )
45
Brad Bishop919e4082020-10-27 18:55:19 -040046unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050047unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
48unit_subs.set('ENABLE_PHAL_TRUE', '#')
Brad Bishop919e4082020-10-27 18:55:19 -040049
50if get_option('phal').enabled() and get_option('p9').enabled()
51 error('phal and p9 cannot be selected at the same time')
52endif
53
54build_p9 = not get_option('p9').disabled()
55build_openfsi = not get_option('openfsi').disabled()
56build_phal = get_option('phal').enabled()
57
58if get_option('phal').enabled() and not get_option('p9').disabled()
59 build_p9 = false
60endif
61
62summary('building p9', build_p9)
63summary('building openfsi', build_openfsi)
64summary('building phal', build_phal)
65
66if build_p9
67 extra_sources += [
68 'procedures/p9/cleanup_pcie.cpp',
69 'procedures/p9/set_sync_fsi_clock_mode.cpp',
70 'procedures/p9/start_host.cpp',
71 'procedures/p9/start_host_mpreboot.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -050072 'procedures/p9/enter_mpreboot.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040073 ]
74endif
75if build_openfsi
76 extra_sources += [
77 'procedures/openfsi/scan.cpp',
78 ]
79endif
80if build_phal
81 extra_sources += [
82 'procedures/phal/start_host.cpp',
83 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -060084 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -050085 'procedures/phal/check_host_running.cpp',
86 'procedures/phal/import_devtree.cpp',
Jayanth Othayothdb8d46c2021-10-09 02:19:57 -050087 'procedures/phal/enter_mpreboot.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -050088 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -050089 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -050090 'extensions/phal/create_pel.cpp',
91 'extensions/phal/phal_error.cpp',
Jayanth Othayoth21a889f2021-10-07 06:53:40 -050092 'extensions/phal/dump_utils.cpp',
Jayanth Othayoth4f7b9bd2021-11-25 08:11:12 -060093 'temporary_file.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040094 ]
95 extra_dependencies += [
96 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -040097 cxx.find_library('ekb'),
98 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -050099 cxx.find_library('phal'),
Brad Bishop919e4082020-10-27 18:55:19 -0400100 ]
101 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500102 'service_files/set-spi-mux.service',
103 'service_files/phal-reinit-devtree.service',
104 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500105 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500106 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500107 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500108 'service_files/phal-export-devtree@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400109 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500110 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400111endif
112
113executable(
114 'openpower-proc-control',
115 [
116 'cfam_access.cpp',
117 'ext_interface.cpp',
118 'filedescriptor.cpp',
119 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400120 'targeting.cpp',
121 'procedures/common/cfam_overrides.cpp',
122 'procedures/common/cfam_reset.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400123 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500124 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400125 ] + extra_sources,
126 dependencies: [
127 dependency('libgpiodcxx'),
128 cxx.find_library('pdbg'),
129 dependency('phosphor-dbus-interfaces'),
130 dependency('phosphor-logging'),
131 dependency('sdbusplus'),
132 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500133 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500134 ] + extra_dependencies,
135 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400136)
137
138executable(
139 'openpower-proc-nmi',
140 [
141 'nmi_main.cpp',
142 'nmi_interface.cpp',
143 ],
144 dependencies: [
145 cxx.find_library('pdbg'),
146 dependency('phosphor-dbus-interfaces'),
147 dependency('phosphor-logging'),
148 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500149 ],
150 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400151)
152
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500153if build_phal
154 executable(
155 'phal-export-devtree',
156 [
157 'extensions/phal/devtree_export.cpp',
158 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500159 'extensions/phal/pdbg_utils.cpp',
160 'extensions/phal/create_pel.cpp',
161 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500162 ],
163 dependencies: [
164 dependency('phosphor-logging'),
165 dependency('sdbusplus'),
166 dependency('sdeventplus'),
167 dependency('fmt'),
Jayanth Othayoth38405472021-07-26 06:16:44 -0500168 dependency('phosphor-dbus-interfaces'),
169 cxx.find_library('pdbg'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500170 ],
171 install: true
172 )
173endif
174
Brad Bishop919e4082020-10-27 18:55:19 -0400175unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500176 'service_files/pcie-poweroff@.service',
177 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
178 'service_files/op-stop-instructions@.service',
179 'service_files/op-cfam-reset.service',
180 'service_files/op-continue-mpreboot@.service',
181 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400182] + extra_unit_files
183
184systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
185 'systemdsystemunitdir',
186 define_variable: ['prefix', get_option('prefix')])
187foreach u : unit_files
188 configure_file(
189 configuration: unit_subs,
190 input: u + '.in',
191 install: true,
192 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500193 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400194 )
195endforeach
196
197if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400198 test(
199 'utest',
200 executable(
201 'utest',
202 'test/utest.cpp',
203 'targeting.cpp',
204 'filedescriptor.cpp',
205 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500206 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400207 dependency('phosphor-logging'),
208 ],
209 implicit_include_directories: false,
210 include_directories: '.',
211 )
212 )
213endif