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 ] 90endif 91if build_openfsi 92 extra_sources += [ 93 'procedures/openfsi/scan.cpp', 94 ] 95endif 96if build_phal 97 extra_sources += [ 98 'procedures/phal/start_host.cpp', 99 'procedures/phal/set_SPI_mux.cpp', 100 'procedures/phal/proc_pre_poweroff.cpp', 101 'procedures/phal/check_host_running.cpp', 102 'procedures/phal/import_devtree.cpp', 103 'procedures/phal/enter_mpreboot.cpp', 104 'procedures/phal/reinit_devtree.cpp', 105 'procedures/phal/thread_stopall.cpp', 106 'extensions/phal/common_utils.cpp', 107 'extensions/phal/pdbg_utils.cpp', 108 'extensions/phal/create_pel.cpp', 109 'extensions/phal/phal_error.cpp', 110 'extensions/phal/dump_utils.cpp', 111 'temporary_file.cpp', 112 ] 113 extra_dependencies += [ 114 dependency('libdt-api'), 115 cxx.find_library('ekb'), 116 cxx.find_library('ipl'), 117 cxx.find_library('phal'), 118 cxx.find_library('dtree'), 119 ] 120 extra_unit_files = [ 121 'service_files/set-spi-mux.service', 122 'service_files/phal-reinit-devtree.service', 123 'service_files/proc-pre-poweroff@.service', 124 'service_files/op-reset-host-check@.service', 125 'service_files/op-reset-host-clear.service', 126 'service_files/phal-import-devtree@.service', 127 'service_files/phal-export-devtree@.service', 128 ] 129 unit_subs.set('ENABLE_PHAL_TRUE', '') 130endif 131 132executable( 133 'openpower-proc-control', 134 [ 135 'cfam_access.cpp', 136 'ext_interface.cpp', 137 'filedescriptor.cpp', 138 'proc_control.cpp', 139 'targeting.cpp', 140 'procedures/common/cfam_overrides.cpp', 141 'procedures/common/cfam_reset.cpp', 142 'procedures/common/collect_sbe_hb_data.cpp', 143 'util.cpp', 144 ] + extra_sources, 145 dependencies: [ 146 dependency('libgpiodcxx'), 147 cxx.find_library('pdbg'), 148 dependency('phosphor-dbus-interfaces'), 149 dependency('phosphor-logging'), 150 dependency('sdbusplus'), 151 dependency('threads'), 152 dependency('fmt'), 153 ] + extra_dependencies, 154 install: true 155) 156 157executable( 158 'openpower-proc-nmi', 159 [ 160 'nmi_main.cpp', 161 'nmi_interface.cpp', 162 ], 163 dependencies: [ 164 cxx.find_library('pdbg'), 165 dependency('phosphor-dbus-interfaces'), 166 dependency('phosphor-logging'), 167 dependency('sdbusplus'), 168 ], 169 install: true 170) 171 172if build_phal 173 executable( 174 'phal-export-devtree', 175 [ 176 'extensions/phal/devtree_export.cpp', 177 'extensions/phal/fw_update_watch.cpp', 178 'extensions/phal/pdbg_utils.cpp', 179 'extensions/phal/create_pel.cpp', 180 'util.cpp', 181 ], 182 dependencies: [ 183 dependency('phosphor-logging'), 184 dependency('sdbusplus'), 185 dependency('sdeventplus'), 186 dependency('fmt'), 187 dependency('phosphor-dbus-interfaces'), 188 cxx.find_library('pdbg'), 189 ], 190 install: true 191 ) 192endif 193 194unit_files = [ 195 'service_files/pcie-poweroff@.service', 196 'service_files/xyz.openbmc_project.Control.Host.NMI.service', 197 'service_files/op-stop-instructions@.service', 198 'service_files/op-cfam-reset.service', 199 'service_files/op-continue-mpreboot@.service', 200 'service_files/op-enter-mpreboot@.service', 201] + extra_unit_files 202 203systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( 204 'systemdsystemunitdir', 205 define_variable: ['prefix', get_option('prefix')]) 206foreach u : unit_files 207 configure_file( 208 configuration: unit_subs, 209 input: u + '.in', 210 install: true, 211 install_dir: systemd_system_unit_dir, 212 output: '@BASENAME@' 213 ) 214endforeach 215 216if not get_option('tests').disabled() 217 test( 218 'utest', 219 executable( 220 'utest', 221 'test/utest.cpp', 222 'targeting.cpp', 223 'filedescriptor.cpp', 224 dependencies: [ 225 dependency('gtest', main: true), 226 dependency('phosphor-logging'), 227 ], 228 implicit_include_directories: false, 229 include_directories: '.', 230 ) 231 ) 232endif 233