blob: 38e7abd729a4be63b91ca2b5a6e10119d28d7518 [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',
72 ]
73endif
74if build_openfsi
75 extra_sources += [
76 'procedures/openfsi/scan.cpp',
77 ]
78endif
79if build_phal
80 extra_sources += [
81 'procedures/phal/start_host.cpp',
82 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -060083 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -050084 'procedures/phal/check_host_running.cpp',
85 'procedures/phal/import_devtree.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -050086 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -050087 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -050088 'extensions/phal/create_pel.cpp',
89 'extensions/phal/phal_error.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040090 ]
91 extra_dependencies += [
92 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -040093 cxx.find_library('ekb'),
94 cxx.find_library('ipl'),
Jayanth Othayoth4079f092021-09-20 07:36:54 -050095 cxx.find_library('phal'),
Brad Bishop919e4082020-10-27 18:55:19 -040096 ]
97 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -050098 'service_files/set-spi-mux.service',
99 'service_files/phal-reinit-devtree.service',
100 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -0500101 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500102 'service_files/op-reset-host-clear.service',
Jayanth Othayotha089bd22021-07-30 01:32:31 -0500103 'service_files/phal-import-devtree@.service',
Jayanth Othayoth07e9a6a2021-07-30 03:52:13 -0500104 'service_files/phal-export-devtree@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400105 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500106 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400107endif
108
109executable(
110 'openpower-proc-control',
111 [
112 'cfam_access.cpp',
113 'ext_interface.cpp',
114 'filedescriptor.cpp',
115 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400116 'targeting.cpp',
117 'procedures/common/cfam_overrides.cpp',
118 'procedures/common/cfam_reset.cpp',
119 'procedures/common/enter_mpreboot.cpp',
120 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500121 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400122 ] + extra_sources,
123 dependencies: [
124 dependency('libgpiodcxx'),
125 cxx.find_library('pdbg'),
126 dependency('phosphor-dbus-interfaces'),
127 dependency('phosphor-logging'),
128 dependency('sdbusplus'),
129 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500130 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500131 ] + extra_dependencies,
132 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400133)
134
135executable(
136 'openpower-proc-nmi',
137 [
138 'nmi_main.cpp',
139 'nmi_interface.cpp',
140 ],
141 dependencies: [
142 cxx.find_library('pdbg'),
143 dependency('phosphor-dbus-interfaces'),
144 dependency('phosphor-logging'),
145 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500146 ],
147 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400148)
149
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500150if build_phal
151 executable(
152 'phal-export-devtree',
153 [
154 'extensions/phal/devtree_export.cpp',
155 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500156 'extensions/phal/pdbg_utils.cpp',
157 'extensions/phal/create_pel.cpp',
158 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500159 ],
160 dependencies: [
161 dependency('phosphor-logging'),
162 dependency('sdbusplus'),
163 dependency('sdeventplus'),
164 dependency('fmt'),
Jayanth Othayoth38405472021-07-26 06:16:44 -0500165 dependency('phosphor-dbus-interfaces'),
166 cxx.find_library('pdbg'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500167 ],
168 install: true
169 )
170endif
171
Brad Bishop919e4082020-10-27 18:55:19 -0400172unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500173 'service_files/pcie-poweroff@.service',
174 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
175 'service_files/op-stop-instructions@.service',
176 'service_files/op-cfam-reset.service',
177 'service_files/op-continue-mpreboot@.service',
178 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400179] + extra_unit_files
180
181systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
182 'systemdsystemunitdir',
183 define_variable: ['prefix', get_option('prefix')])
184foreach u : unit_files
185 configure_file(
186 configuration: unit_subs,
187 input: u + '.in',
188 install: true,
189 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500190 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400191 )
192endforeach
193
194if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400195 test(
196 'utest',
197 executable(
198 'utest',
199 'test/utest.cpp',
200 'targeting.cpp',
201 'filedescriptor.cpp',
202 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500203 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400204 dependency('phosphor-logging'),
205 ],
206 implicit_include_directories: false,
207 include_directories: '.',
208 )
209 )
210endif