blob: 74923005744dd4b559a95fb375d03f6d0047a3bf [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',
Brad Bishopf38b35e2020-11-08 10:42:34 -05007 'cpp_std=c++17',
8 'buildtype=debugoptimized',
9 'b_ndebug=if-release',
Brad Bishop919e4082020-10-27 18:55:19 -040010 ],
11 license: 'Apache-2.0',
12 version: '1.0',
13)
14add_project_arguments('-Wno-psabi', language: 'cpp')
15
Brad Bishopf38b35e2020-11-08 10:42:34 -050016if get_option('cpp_std') != 'c++17'
17 error('This project requires c++17')
18endif
19
20if(get_option('buildtype') == 'minsize')
21 add_project_arguments('-DNDEBUG', language : 'cpp')
22endif
23
Brad Bishop919e4082020-10-27 18:55:19 -040024cxx = meson.get_compiler('cpp')
25
26extra_sources = []
27extra_dependencies = []
28extra_unit_files = []
29
Jayanth Othayoth38405472021-07-26 06:16:44 -050030# Configuration header file(config.h) generation
31conf_data = configuration_data()
32
33conf_data.set_quoted('DEVTREE_EXPORT_FILTER_FILE', get_option('DEVTREE_EXPORT_FILTER_FILE'),
34 description : 'Path to the phal devtree export filter file'
35 )
36
37conf_data.set_quoted('DEVTREE_EXP_FILE', get_option('DEVTREE_EXP_FILE'),
38 description : 'Path to the devtree export copy file'
39 )
40
41configure_file(configuration : conf_data,
42 output : 'config.h'
43 )
44
Brad Bishop919e4082020-10-27 18:55:19 -040045unit_subs = configuration_data()
Brad Bishopa5b4b1b2020-11-08 12:14:03 -050046unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
47unit_subs.set('ENABLE_PHAL_TRUE', '#')
Brad Bishop919e4082020-10-27 18:55:19 -040048
49if get_option('phal').enabled() and get_option('p9').enabled()
50 error('phal and p9 cannot be selected at the same time')
51endif
52
53build_p9 = not get_option('p9').disabled()
54build_openfsi = not get_option('openfsi').disabled()
55build_phal = get_option('phal').enabled()
56
57if get_option('phal').enabled() and not get_option('p9').disabled()
58 build_p9 = false
59endif
60
61summary('building p9', build_p9)
62summary('building openfsi', build_openfsi)
63summary('building phal', build_phal)
64
65if build_p9
66 extra_sources += [
67 'procedures/p9/cleanup_pcie.cpp',
68 'procedures/p9/set_sync_fsi_clock_mode.cpp',
69 'procedures/p9/start_host.cpp',
70 'procedures/p9/start_host_mpreboot.cpp',
71 ]
72endif
73if build_openfsi
74 extra_sources += [
75 'procedures/openfsi/scan.cpp',
76 ]
77endif
78if build_phal
79 extra_sources += [
80 'procedures/phal/start_host.cpp',
81 'procedures/phal/set_SPI_mux.cpp',
Chirag Sharmaa2576932020-12-05 23:17:41 -060082 'procedures/phal/proc_pre_poweroff.cpp',
Jayanth Othayothcf2da1b2021-07-29 03:15:20 -050083 'procedures/phal/check_host_running.cpp',
84 'procedures/phal/import_devtree.cpp',
Jayanth Othayoth25e39c82021-07-12 01:00:17 -050085 'extensions/phal/common_utils.cpp',
Jayanth Othayothc3d6b872021-07-28 05:07:25 -050086 'extensions/phal/pdbg_utils.cpp',
Jayanth Othayoth6552de02021-07-12 00:55:57 -050087 'extensions/phal/create_pel.cpp',
88 'extensions/phal/phal_error.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -040089 ]
90 extra_dependencies += [
91 dependency('libdt-api'),
Brad Bishop919e4082020-10-27 18:55:19 -040092 cxx.find_library('ekb'),
93 cxx.find_library('ipl'),
94 ]
95 extra_unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -050096 'service_files/set-spi-mux.service',
97 'service_files/phal-reinit-devtree.service',
98 'service_files/proc-pre-poweroff@.service',
Andrew Geissler8e73da02021-06-23 15:43:21 -050099 'service_files/op-reset-host-check@.service',
Andrew Geissler3292c062021-06-23 21:11:10 -0500100 'service_files/op-reset-host-clear.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400101 ]
Brad Bishopa5b4b1b2020-11-08 12:14:03 -0500102 unit_subs.set('ENABLE_PHAL_TRUE', '')
Brad Bishop919e4082020-10-27 18:55:19 -0400103endif
104
105executable(
106 'openpower-proc-control',
107 [
108 'cfam_access.cpp',
109 'ext_interface.cpp',
110 'filedescriptor.cpp',
111 'proc_control.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400112 'targeting.cpp',
113 'procedures/common/cfam_overrides.cpp',
114 'procedures/common/cfam_reset.cpp',
115 'procedures/common/enter_mpreboot.cpp',
116 'procedures/common/collect_sbe_hb_data.cpp',
Jayanth Othayothc4831812021-06-08 01:33:40 -0500117 'util.cpp',
Brad Bishop919e4082020-10-27 18:55:19 -0400118 ] + extra_sources,
119 dependencies: [
120 dependency('libgpiodcxx'),
121 cxx.find_library('pdbg'),
122 dependency('phosphor-dbus-interfaces'),
123 dependency('phosphor-logging'),
124 dependency('sdbusplus'),
125 dependency('threads'),
Jayanth Othayothc4831812021-06-08 01:33:40 -0500126 dependency('fmt'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500127 ] + extra_dependencies,
128 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400129)
130
131executable(
132 'openpower-proc-nmi',
133 [
134 'nmi_main.cpp',
135 'nmi_interface.cpp',
136 ],
137 dependencies: [
138 cxx.find_library('pdbg'),
139 dependency('phosphor-dbus-interfaces'),
140 dependency('phosphor-logging'),
141 dependency('sdbusplus'),
Brad Bishopce08fb92020-11-08 09:50:48 -0500142 ],
143 install: true
Brad Bishop919e4082020-10-27 18:55:19 -0400144)
145
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500146if build_phal
147 executable(
148 'phal-export-devtree',
149 [
150 'extensions/phal/devtree_export.cpp',
151 'extensions/phal/fw_update_watch.cpp',
Jayanth Othayoth38405472021-07-26 06:16:44 -0500152 'extensions/phal/pdbg_utils.cpp',
153 'extensions/phal/create_pel.cpp',
154 'util.cpp',
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500155 ],
156 dependencies: [
157 dependency('phosphor-logging'),
158 dependency('sdbusplus'),
159 dependency('sdeventplus'),
160 dependency('fmt'),
Jayanth Othayoth38405472021-07-26 06:16:44 -0500161 dependency('phosphor-dbus-interfaces'),
162 cxx.find_library('pdbg'),
Jayanth Othayoth13c57ad2021-07-16 06:02:21 -0500163 ],
164 install: true
165 )
166endif
167
Brad Bishop919e4082020-10-27 18:55:19 -0400168unit_files = [
Andrew Geissler1dc08292021-06-22 17:14:54 -0500169 'service_files/pcie-poweroff@.service',
170 'service_files/xyz.openbmc_project.Control.Host.NMI.service',
171 'service_files/op-stop-instructions@.service',
172 'service_files/op-cfam-reset.service',
173 'service_files/op-continue-mpreboot@.service',
174 'service_files/op-enter-mpreboot@.service',
Brad Bishop919e4082020-10-27 18:55:19 -0400175] + extra_unit_files
176
177systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
178 'systemdsystemunitdir',
179 define_variable: ['prefix', get_option('prefix')])
180foreach u : unit_files
181 configure_file(
182 configuration: unit_subs,
183 input: u + '.in',
184 install: true,
185 install_dir: systemd_system_unit_dir,
Andrew Geissler1dc08292021-06-22 17:14:54 -0500186 output: '@BASENAME@'
Brad Bishop919e4082020-10-27 18:55:19 -0400187 )
188endforeach
189
190if not get_option('tests').disabled()
Brad Bishop919e4082020-10-27 18:55:19 -0400191 test(
192 'utest',
193 executable(
194 'utest',
195 'test/utest.cpp',
196 'targeting.cpp',
197 'filedescriptor.cpp',
198 dependencies: [
Brad Bishop5d482d92020-11-08 09:45:18 -0500199 dependency('gtest', main: true),
Brad Bishop919e4082020-10-27 18:55:19 -0400200 dependency('phosphor-logging'),
201 ],
202 implicit_include_directories: false,
203 include_directories: '.',
204 )
205 )
206endif