Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'openpower-proc-control', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Patrick Williams | 9e178b7 | 2021-10-06 15:33:36 -0500 | [diff] [blame] | 7 | 'cpp_std=c++20', |
Brad Bishop | f38b35e | 2020-11-08 10:42:34 -0500 | [diff] [blame] | 8 | 'buildtype=debugoptimized', |
| 9 | 'b_ndebug=if-release', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 10 | ], |
| 11 | license: 'Apache-2.0', |
| 12 | version: '1.0', |
Patrick Williams | 9e178b7 | 2021-10-06 15:33:36 -0500 | [diff] [blame] | 13 | meson_version: '>=0.57.0', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 14 | ) |
| 15 | add_project_arguments('-Wno-psabi', language: 'cpp') |
| 16 | |
Patrick Williams | 9e178b7 | 2021-10-06 15:33:36 -0500 | [diff] [blame] | 17 | if get_option('cpp_std') != 'c++20' |
| 18 | error('This project requires c++20') |
Brad Bishop | f38b35e | 2020-11-08 10:42:34 -0500 | [diff] [blame] | 19 | endif |
| 20 | |
| 21 | if(get_option('buildtype') == 'minsize') |
| 22 | add_project_arguments('-DNDEBUG', language : 'cpp') |
| 23 | endif |
| 24 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 25 | cxx = meson.get_compiler('cpp') |
| 26 | |
| 27 | extra_sources = [] |
| 28 | extra_dependencies = [] |
| 29 | extra_unit_files = [] |
| 30 | |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 31 | # Configuration header file(config.h) generation |
| 32 | conf_data = configuration_data() |
| 33 | |
| 34 | conf_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 | |
| 38 | conf_data.set_quoted('DEVTREE_EXP_FILE', get_option('DEVTREE_EXP_FILE'), |
| 39 | description : 'Path to the devtree export copy file' |
| 40 | ) |
| 41 | |
| 42 | configure_file(configuration : conf_data, |
| 43 | output : 'config.h' |
| 44 | ) |
| 45 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 46 | unit_subs = configuration_data() |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 47 | unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) |
| 48 | unit_subs.set('ENABLE_PHAL_TRUE', '#') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 49 | |
| 50 | if get_option('phal').enabled() and get_option('p9').enabled() |
| 51 | error('phal and p9 cannot be selected at the same time') |
| 52 | endif |
| 53 | |
| 54 | build_p9 = not get_option('p9').disabled() |
| 55 | build_openfsi = not get_option('openfsi').disabled() |
| 56 | build_phal = get_option('phal').enabled() |
| 57 | |
| 58 | if get_option('phal').enabled() and not get_option('p9').disabled() |
| 59 | build_p9 = false |
| 60 | endif |
| 61 | |
| 62 | summary('building p9', build_p9) |
| 63 | summary('building openfsi', build_openfsi) |
| 64 | summary('building phal', build_phal) |
| 65 | |
| 66 | if build_p9 |
| 67 | extra_sources += [ |
| 68 | 'procedures/p9/cleanup_pcie.cpp', |
| 69 | 'procedures/p9/set_sync_fsi_clock_mode.cpp', |
| 70 | 'procedures/p9/start_host.cpp', |
| 71 | 'procedures/p9/start_host_mpreboot.cpp', |
Jayanth Othayoth | db8d46c | 2021-10-09 02:19:57 -0500 | [diff] [blame^] | 72 | 'procedures/p9/enter_mpreboot.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 73 | ] |
| 74 | endif |
| 75 | if build_openfsi |
| 76 | extra_sources += [ |
| 77 | 'procedures/openfsi/scan.cpp', |
| 78 | ] |
| 79 | endif |
| 80 | if build_phal |
| 81 | extra_sources += [ |
| 82 | 'procedures/phal/start_host.cpp', |
| 83 | 'procedures/phal/set_SPI_mux.cpp', |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 84 | 'procedures/phal/proc_pre_poweroff.cpp', |
Jayanth Othayoth | cf2da1b | 2021-07-29 03:15:20 -0500 | [diff] [blame] | 85 | 'procedures/phal/check_host_running.cpp', |
| 86 | 'procedures/phal/import_devtree.cpp', |
Jayanth Othayoth | db8d46c | 2021-10-09 02:19:57 -0500 | [diff] [blame^] | 87 | 'procedures/phal/enter_mpreboot.cpp', |
Jayanth Othayoth | 25e39c8 | 2021-07-12 01:00:17 -0500 | [diff] [blame] | 88 | 'extensions/phal/common_utils.cpp', |
Jayanth Othayoth | c3d6b87 | 2021-07-28 05:07:25 -0500 | [diff] [blame] | 89 | 'extensions/phal/pdbg_utils.cpp', |
Jayanth Othayoth | 6552de0 | 2021-07-12 00:55:57 -0500 | [diff] [blame] | 90 | 'extensions/phal/create_pel.cpp', |
| 91 | 'extensions/phal/phal_error.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 92 | ] |
| 93 | extra_dependencies += [ |
| 94 | dependency('libdt-api'), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 95 | cxx.find_library('ekb'), |
| 96 | cxx.find_library('ipl'), |
Jayanth Othayoth | 4079f09 | 2021-09-20 07:36:54 -0500 | [diff] [blame] | 97 | cxx.find_library('phal'), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 98 | ] |
| 99 | extra_unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 100 | 'service_files/set-spi-mux.service', |
| 101 | 'service_files/phal-reinit-devtree.service', |
| 102 | 'service_files/proc-pre-poweroff@.service', |
Andrew Geissler | 8e73da0 | 2021-06-23 15:43:21 -0500 | [diff] [blame] | 103 | 'service_files/op-reset-host-check@.service', |
Andrew Geissler | 3292c06 | 2021-06-23 21:11:10 -0500 | [diff] [blame] | 104 | 'service_files/op-reset-host-clear.service', |
Jayanth Othayoth | a089bd2 | 2021-07-30 01:32:31 -0500 | [diff] [blame] | 105 | 'service_files/phal-import-devtree@.service', |
Jayanth Othayoth | 07e9a6a | 2021-07-30 03:52:13 -0500 | [diff] [blame] | 106 | 'service_files/phal-export-devtree@.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 107 | ] |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 108 | unit_subs.set('ENABLE_PHAL_TRUE', '') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 109 | endif |
| 110 | |
| 111 | executable( |
| 112 | 'openpower-proc-control', |
| 113 | [ |
| 114 | 'cfam_access.cpp', |
| 115 | 'ext_interface.cpp', |
| 116 | 'filedescriptor.cpp', |
| 117 | 'proc_control.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 118 | 'targeting.cpp', |
| 119 | 'procedures/common/cfam_overrides.cpp', |
| 120 | 'procedures/common/cfam_reset.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 121 | 'procedures/common/collect_sbe_hb_data.cpp', |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 122 | 'util.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 123 | ] + extra_sources, |
| 124 | dependencies: [ |
| 125 | dependency('libgpiodcxx'), |
| 126 | cxx.find_library('pdbg'), |
| 127 | dependency('phosphor-dbus-interfaces'), |
| 128 | dependency('phosphor-logging'), |
| 129 | dependency('sdbusplus'), |
| 130 | dependency('threads'), |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 131 | dependency('fmt'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 132 | ] + extra_dependencies, |
| 133 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 134 | ) |
| 135 | |
| 136 | executable( |
| 137 | 'openpower-proc-nmi', |
| 138 | [ |
| 139 | 'nmi_main.cpp', |
| 140 | 'nmi_interface.cpp', |
| 141 | ], |
| 142 | dependencies: [ |
| 143 | cxx.find_library('pdbg'), |
| 144 | dependency('phosphor-dbus-interfaces'), |
| 145 | dependency('phosphor-logging'), |
| 146 | dependency('sdbusplus'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 147 | ], |
| 148 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 149 | ) |
| 150 | |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 151 | if build_phal |
| 152 | executable( |
| 153 | 'phal-export-devtree', |
| 154 | [ |
| 155 | 'extensions/phal/devtree_export.cpp', |
| 156 | 'extensions/phal/fw_update_watch.cpp', |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 157 | 'extensions/phal/pdbg_utils.cpp', |
| 158 | 'extensions/phal/create_pel.cpp', |
| 159 | 'util.cpp', |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 160 | ], |
| 161 | dependencies: [ |
| 162 | dependency('phosphor-logging'), |
| 163 | dependency('sdbusplus'), |
| 164 | dependency('sdeventplus'), |
| 165 | dependency('fmt'), |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 166 | dependency('phosphor-dbus-interfaces'), |
| 167 | cxx.find_library('pdbg'), |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 168 | ], |
| 169 | install: true |
| 170 | ) |
| 171 | endif |
| 172 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 173 | unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 174 | 'service_files/pcie-poweroff@.service', |
| 175 | 'service_files/xyz.openbmc_project.Control.Host.NMI.service', |
| 176 | 'service_files/op-stop-instructions@.service', |
| 177 | 'service_files/op-cfam-reset.service', |
| 178 | 'service_files/op-continue-mpreboot@.service', |
| 179 | 'service_files/op-enter-mpreboot@.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 180 | ] + extra_unit_files |
| 181 | |
| 182 | systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( |
| 183 | 'systemdsystemunitdir', |
| 184 | define_variable: ['prefix', get_option('prefix')]) |
| 185 | foreach u : unit_files |
| 186 | configure_file( |
| 187 | configuration: unit_subs, |
| 188 | input: u + '.in', |
| 189 | install: true, |
| 190 | install_dir: systemd_system_unit_dir, |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 191 | output: '@BASENAME@' |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 192 | ) |
| 193 | endforeach |
| 194 | |
| 195 | if not get_option('tests').disabled() |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 196 | test( |
| 197 | 'utest', |
| 198 | executable( |
| 199 | 'utest', |
| 200 | 'test/utest.cpp', |
| 201 | 'targeting.cpp', |
| 202 | 'filedescriptor.cpp', |
| 203 | dependencies: [ |
Brad Bishop | 5d482d9 | 2020-11-08 09:45:18 -0500 | [diff] [blame] | 204 | dependency('gtest', main: true), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 205 | dependency('phosphor-logging'), |
| 206 | ], |
| 207 | implicit_include_directories: false, |
| 208 | include_directories: '.', |
| 209 | ) |
| 210 | ) |
| 211 | endif |