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