1project( 2 'openpower-proc-control', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++23', 8 'buildtype=debugoptimized', 9 'b_ndebug=if-release', 10 ], 11 license: 'Apache-2.0', 12 version: '1.0', 13 meson_version: '>=1.1.1', 14) 15add_project_arguments('-Wno-psabi', language: 'cpp') 16 17if get_option('cpp_std') != 'c++23' 18 error('This project requires c++23') 19endif 20 21if (get_option('buildtype') == 'minsize') 22 add_project_arguments('-DNDEBUG', language: 'cpp') 23endif 24 25cxx = meson.get_compiler('cpp') 26 27extra_sources = [] 28extra_dependencies = [] 29extra_unit_files = [] 30 31# Configuration header file(config.h) generation 32conf_data = configuration_data() 33 34conf_data.set_quoted( 35 'DEVTREE_EXPORT_FILTER_FILE', 36 get_option('DEVTREE_EXPORT_FILTER_FILE'), 37 description: 'Path to the phal devtree export filter file', 38) 39 40conf_data.set_quoted( 41 'DEVTREE_EXP_FILE', 42 get_option('DEVTREE_EXP_FILE'), 43 description: 'Path to the devtree export copy file', 44) 45 46conf_data.set_quoted( 47 'CEC_DEVTREE_RW_PATH', 48 get_option('CEC_DEVTREE_RW_PATH'), 49 description: 'Path to the devtree file r/w version', 50) 51 52conf_data.set_quoted( 53 'CEC_DEVTREE_RO_BASE_PATH', 54 get_option('CEC_DEVTREE_RO_BASE_PATH'), 55 description: 'Base path to the devtree file read only version', 56) 57conf_data.set_quoted( 58 'CEC_INFODB_PATH', 59 get_option('CEC_INFODB_PATH'), 60 description: 'Path to the devtree attributes based database path', 61) 62 63conf_data.set_quoted( 64 'DEVTREE_REINIT_ATTRS_LIST', 65 get_option('DEVTREE_REINIT_ATTRS_LIST'), 66 description: 'Path to the phal devtree reinit attribute list file', 67) 68 69conf_data.set_quoted( 70 'OP_DUMP_OBJ_PATH', 71 get_option('op_dump_obj_path'), 72 description: 'Object path requesting OpenPOWER dumps', 73) 74 75configure_file(configuration: conf_data, output: 'config.h') 76 77unit_subs = configuration_data() 78unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 79unit_subs.set('ENABLE_PHAL_TRUE', '#') 80unit_subs.set( 81 'CEC_DEVTREE_RW_PATH', 82 get_option('CEC_DEVTREE_RW_PATH'), 83 description: 'Path to the devtree file r/w version', 84) 85 86if get_option('phal').enabled() and get_option('p9').enabled() 87 error('phal and p9 cannot be selected at the same time') 88endif 89 90build_p9 = not get_option('p9').disabled() 91build_openfsi = not get_option('openfsi').disabled() 92build_phal = get_option('phal').enabled() 93 94if get_option('phal').enabled() and not get_option('p9').disabled() 95 build_p9 = false 96endif 97 98summary('building p9', build_p9) 99summary('building openfsi', build_openfsi) 100summary('building phal', build_phal) 101 102if build_p9 103 extra_sources += [ 104 'procedures/p9/cleanup_pcie.cpp', 105 'procedures/p9/set_sync_fsi_clock_mode.cpp', 106 'procedures/p9/start_host.cpp', 107 'procedures/p9/start_host_mpreboot.cpp', 108 'procedures/p9/enter_mpreboot.cpp', 109 'procedures/p9/thread_stopall.cpp', 110 ] 111endif 112if build_openfsi 113 extra_sources += ['procedures/openfsi/scan.cpp'] 114endif 115if build_phal 116 extra_sources += [ 117 'procedures/phal/start_host.cpp', 118 'procedures/phal/set_SPI_mux.cpp', 119 'procedures/phal/proc_pre_poweroff.cpp', 120 'procedures/phal/check_host_running.cpp', 121 'procedures/phal/import_devtree.cpp', 122 'procedures/phal/enter_mpreboot.cpp', 123 'procedures/phal/reinit_devtree.cpp', 124 'procedures/phal/thread_stopall.cpp', 125 'extensions/phal/common_utils.cpp', 126 'extensions/phal/pdbg_utils.cpp', 127 'extensions/phal/create_pel.cpp', 128 'extensions/phal/phal_error.cpp', 129 'extensions/phal/dump_utils.cpp', 130 'temporary_file.cpp', 131 'util.cpp', 132 ] 133 extra_dependencies += [ 134 dependency('libdt-api'), 135 cxx.find_library('ekb'), 136 cxx.find_library('ipl'), 137 cxx.find_library('phal'), 138 cxx.find_library('dtree'), 139 ] 140 extra_unit_files = [ 141 'service_files/set-spi-mux.service', 142 'service_files/phal-reinit-devtree.service', 143 'service_files/proc-pre-poweroff@.service', 144 'service_files/op-clear-sys-dump-active@.service', 145 'service_files/op-reset-host-check@.service', 146 'service_files/op-reset-host-clear.service', 147 'service_files/phal-import-devtree@.service', 148 'service_files/phal-export-devtree@.service', 149 'service_files/phal-create-boottime-guard-indicator.service', 150 'service_files/op-clock-data-logger@.service', 151 ] 152 unit_subs.set('ENABLE_PHAL_TRUE', '') 153endif 154 155libgpiodcxx_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx']) 156sdbusplus_dep = dependency('sdbusplus') 157sdeventplus_dep = dependency('sdeventplus') 158pdi_dep = dependency('phosphor-dbus-interfaces') 159phosphor_logging_dep = dependency('phosphor-logging') 160 161gtest = dependency( 162 'gtest', 163 main: true, 164 disabler: true, 165 required: false, 166 include_type: 'system', 167) 168if get_option('tests').allowed() 169 if not gtest.found() 170 gtest_proj = import('cmake').subproject('gtest', required: false) 171 if gtest_proj.found() 172 gtest = declare_dependency( 173 dependencies: [ 174 dependency('threads'), 175 gtest_proj.dependency('gtest'), 176 gtest_proj.dependency('gtest_main'), 177 ], 178 ) 179 else 180 assert( 181 not get_option('tests').enabled(), 182 'Googletest is required if tests are enabled', 183 ) 184 endif 185 endif 186endif 187 188executable( 189 'openpower-proc-control', 190 [ 191 'cfam_access.cpp', 192 'ext_interface.cpp', 193 'filedescriptor.cpp', 194 'proc_control.cpp', 195 'targeting.cpp', 196 'procedures/common/cfam_overrides.cpp', 197 'procedures/common/cfam_reset.cpp', 198 'procedures/common/collect_sbe_hb_data.cpp', 199 'util.cpp', 200 ] + extra_sources, 201 dependencies: [ 202 libgpiodcxx_dep, 203 cxx.find_library('pdbg'), 204 pdi_dep, 205 phosphor_logging_dep, 206 sdbusplus_dep, 207 dependency('threads'), 208 dependency('fmt'), 209 ] + extra_dependencies, 210 install: true, 211) 212 213executable( 214 'openpower-proc-nmi', 215 ['nmi_main.cpp', 'nmi_interface.cpp'], 216 dependencies: [ 217 cxx.find_library('pdbg'), 218 pdi_dep, 219 phosphor_logging_dep, 220 sdbusplus_dep, 221 ], 222 install: true, 223) 224 225if build_phal 226 executable( 227 'phal-export-devtree', 228 [ 229 'extensions/phal/devtree_export.cpp', 230 'extensions/phal/fw_update_watch.cpp', 231 'extensions/phal/pdbg_utils.cpp', 232 'extensions/phal/create_pel.cpp', 233 'util.cpp', 234 ], 235 dependencies: [ 236 phosphor_logging_dep, 237 sdbusplus_dep, 238 sdeventplus_dep, 239 pdi_dep, 240 cxx.find_library('pdbg'), 241 cxx.find_library('phal'), 242 ], 243 install: true, 244 ) 245 246 executable( 247 'openpower-clock-data-logger', 248 [ 249 'extensions/phal/clock_logger_main.cpp', 250 'extensions/phal/clock_logger.cpp', 251 'extensions/phal/create_pel.cpp', 252 'util.cpp', 253 ], 254 dependencies: [ 255 cxx.find_library('dtree'), 256 cxx.find_library('pdbg'), 257 cxx.find_library('phal'), 258 dependency('libdt-api'), 259 phosphor_logging_dep, 260 sdbusplus_dep, 261 sdeventplus_dep, 262 ], 263 install: true, 264 ) 265endif 266 267unit_files = [ 268 'service_files/pcie-poweroff@.service', 269 'service_files/xyz.openbmc_project.Control.Host.NMI.service', 270 'service_files/op-stop-instructions@.service', 271 'service_files/op-cfam-reset.service', 272 'service_files/op-continue-mpreboot@.service', 273 'service_files/op-enter-mpreboot@.service', 274] + extra_unit_files 275 276systemd_system_unit_dir = dependency('systemd').get_variable( 277 'systemdsystemunitdir', 278 pkgconfig_define: ['prefix', get_option('prefix')], 279) 280foreach u : unit_files 281 configure_file( 282 configuration: unit_subs, 283 input: u + '.in', 284 install: true, 285 install_dir: systemd_system_unit_dir, 286 output: '@BASENAME@', 287 ) 288endforeach 289 290if not get_option('tests').disabled() 291 test( 292 'utest', 293 executable( 294 'utest', 295 'test/utest.cpp', 296 'targeting.cpp', 297 'filedescriptor.cpp', 298 dependencies: [gtest, dependency('phosphor-logging')], 299 implicit_include_directories: false, 300 include_directories: '.', 301 ), 302 ) 303endif 304