1project( 2 'openpower-proc-control', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++20', 8 'buildtype=debugoptimized', 9 'b_ndebug=if-release', 10 ], 11 license: 'Apache-2.0', 12 version: '1.0', 13 meson_version: '>=0.57.0', 14) 15add_project_arguments('-Wno-psabi', language: 'cpp') 16 17if get_option('cpp_std') != 'c++20' 18 error('This project requires c++20') 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('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 42conf_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_BASE_PATH', get_option('CEC_DEVTREE_RO_BASE_PATH'), 47 description : 'Base path to the devtree file read only version' 48 ) 49conf_data.set_quoted('CEC_INFODB_PATH', get_option('CEC_INFODB_PATH'), 50 description : 'Path to the devtree attributes based database path' 51 ) 52 53conf_data.set_quoted('DEVTREE_REINIT_ATTRS_LIST', get_option('DEVTREE_REINIT_ATTRS_LIST'), 54 description : 'Path to the phal devtree reinit attribute list file' 55 ) 56 57configure_file(configuration : conf_data, 58 output : 'config.h' 59 ) 60 61unit_subs = configuration_data() 62unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 63unit_subs.set('ENABLE_PHAL_TRUE', '#') 64unit_subs.set('CEC_DEVTREE_RW_PATH', get_option('CEC_DEVTREE_RW_PATH'), 65 description : 'Path to the devtree file r/w version' 66 ) 67 68if get_option('phal').enabled() and get_option('p9').enabled() 69 error('phal and p9 cannot be selected at the same time') 70endif 71 72build_p9 = not get_option('p9').disabled() 73build_openfsi = not get_option('openfsi').disabled() 74build_phal = get_option('phal').enabled() 75 76if get_option('phal').enabled() and not get_option('p9').disabled() 77 build_p9 = false 78endif 79 80summary('building p9', build_p9) 81summary('building openfsi', build_openfsi) 82summary('building phal', build_phal) 83 84if build_p9 85 extra_sources += [ 86 'procedures/p9/cleanup_pcie.cpp', 87 'procedures/p9/set_sync_fsi_clock_mode.cpp', 88 'procedures/p9/start_host.cpp', 89 'procedures/p9/start_host_mpreboot.cpp', 90 'procedures/p9/enter_mpreboot.cpp', 91 'procedures/p9/thread_stopall.cpp', 92 ] 93endif 94if build_openfsi 95 extra_sources += [ 96 'procedures/openfsi/scan.cpp', 97 ] 98endif 99if build_phal 100 extra_sources += [ 101 'procedures/phal/start_host.cpp', 102 'procedures/phal/set_SPI_mux.cpp', 103 'procedures/phal/proc_pre_poweroff.cpp', 104 'procedures/phal/check_host_running.cpp', 105 'procedures/phal/import_devtree.cpp', 106 'procedures/phal/enter_mpreboot.cpp', 107 'procedures/phal/reinit_devtree.cpp', 108 'procedures/phal/thread_stopall.cpp', 109 'extensions/phal/common_utils.cpp', 110 'extensions/phal/pdbg_utils.cpp', 111 'extensions/phal/create_pel.cpp', 112 'extensions/phal/phal_error.cpp', 113 'extensions/phal/dump_utils.cpp', 114 'temporary_file.cpp', 115 'util.cpp', 116 ] 117 extra_dependencies += [ 118 dependency('libdt-api'), 119 cxx.find_library('ekb'), 120 cxx.find_library('ipl'), 121 cxx.find_library('phal'), 122 cxx.find_library('dtree'), 123 ] 124 extra_unit_files = [ 125 'service_files/set-spi-mux.service', 126 'service_files/phal-reinit-devtree.service', 127 'service_files/proc-pre-poweroff@.service', 128 'service_files/op-clear-sys-dump-active@.service', 129 'service_files/op-reset-host-check@.service', 130 'service_files/op-reset-host-clear.service', 131 'service_files/phal-import-devtree@.service', 132 'service_files/phal-export-devtree@.service', 133 'service_files/phal-create-boottime-guard-indicator.service', 134 ] 135 unit_subs.set('ENABLE_PHAL_TRUE', '') 136endif 137 138executable( 139 'openpower-proc-control', 140 [ 141 'cfam_access.cpp', 142 'ext_interface.cpp', 143 'filedescriptor.cpp', 144 'proc_control.cpp', 145 'targeting.cpp', 146 'procedures/common/cfam_overrides.cpp', 147 'procedures/common/cfam_reset.cpp', 148 'procedures/common/collect_sbe_hb_data.cpp', 149 'util.cpp', 150 ] + extra_sources, 151 dependencies: [ 152 dependency('libgpiodcxx'), 153 cxx.find_library('pdbg'), 154 dependency('phosphor-dbus-interfaces'), 155 dependency('phosphor-logging'), 156 dependency('sdbusplus'), 157 dependency('threads'), 158 dependency('fmt'), 159 ] + extra_dependencies, 160 install: true 161) 162 163executable( 164 'openpower-proc-nmi', 165 [ 166 'nmi_main.cpp', 167 'nmi_interface.cpp', 168 ], 169 dependencies: [ 170 cxx.find_library('pdbg'), 171 dependency('phosphor-dbus-interfaces'), 172 dependency('phosphor-logging'), 173 dependency('sdbusplus'), 174 ], 175 install: true 176) 177 178if build_phal 179 executable( 180 'phal-export-devtree', 181 [ 182 'extensions/phal/devtree_export.cpp', 183 'extensions/phal/fw_update_watch.cpp', 184 'extensions/phal/pdbg_utils.cpp', 185 'extensions/phal/create_pel.cpp', 186 'util.cpp', 187 ], 188 dependencies: [ 189 dependency('phosphor-logging'), 190 dependency('sdbusplus'), 191 dependency('sdeventplus'), 192 dependency('fmt'), 193 dependency('phosphor-dbus-interfaces'), 194 cxx.find_library('pdbg'), 195 cxx.find_library('phal'), 196 ], 197 install: true 198 ) 199 200 executable( 201 'openpower-clock-data-logger', 202 [ 203 'extensions/phal/clock_logger_main.cpp', 204 'extensions/phal/clock_logger.cpp', 205 'extensions/phal/create_pel.cpp', 206 'util.cpp', 207 ], 208 dependencies: [ 209 cxx.find_library('dtree'), 210 cxx.find_library('pdbg'), 211 cxx.find_library('phal'), 212 dependency('libdt-api'), 213 dependency('phosphor-logging'), 214 dependency('sdbusplus'), 215 dependency('sdeventplus'), 216 ], 217 install: true 218) 219endif 220 221unit_files = [ 222 'service_files/pcie-poweroff@.service', 223 'service_files/xyz.openbmc_project.Control.Host.NMI.service', 224 'service_files/op-stop-instructions@.service', 225 'service_files/op-cfam-reset.service', 226 'service_files/op-continue-mpreboot@.service', 227 'service_files/op-enter-mpreboot@.service', 228] + extra_unit_files 229 230systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( 231 'systemdsystemunitdir', 232 define_variable: ['prefix', get_option('prefix')]) 233foreach u : unit_files 234 configure_file( 235 configuration: unit_subs, 236 input: u + '.in', 237 install: true, 238 install_dir: systemd_system_unit_dir, 239 output: '@BASENAME@' 240 ) 241endforeach 242 243if not get_option('tests').disabled() 244 test( 245 'utest', 246 executable( 247 'utest', 248 'test/utest.cpp', 249 'targeting.cpp', 250 'filedescriptor.cpp', 251 dependencies: [ 252 dependency('gtest', main: true), 253 dependency('phosphor-logging'), 254 ], 255 implicit_include_directories: false, 256 include_directories: '.', 257 ) 258 ) 259endif 260