blob: 1be93b4e0bd3034ec92972fe8b2b6943dfce841d [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
2 'openpower-occ-control', 'cpp',
3 version : '1.0.0',
Patrick Williams50cfb702023-07-12 11:15:24 -05004 meson_version: '>=1.1.1',
George Liubddcf852021-09-08 08:46:22 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
Patrick Williams50cfb702023-07-12 11:15:24 -05008 'cpp_std=c++23',
George Liubddcf852021-09-08 08:46:22 +08009 'buildtype=debugoptimized'
10 ]
11)
12
Eddie Jamescbad2192021-10-07 09:39:39 -050013cxx = meson.get_compiler('cpp')
14
George Liubddcf852021-09-08 08:46:22 +080015conf_data = configuration_data()
16conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control')
17conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control')
18conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors')
19conf_data.set_quoted('CPU_NAME', 'cpu')
20conf_data.set_quoted('OCC_NAME', 'occ')
21conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1')
22conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ')
Chris Cain36f9cde2021-11-22 11:18:21 -060023conf_data.set_quoted('CPU_SUBPATH', '/xyz/openbmc_project/inventory/system/chassis/motherboard')
24conf_data.set_quoted('OCC_CONTROL_PERSIST_PATH', '/var/lib/openpower-occ-control')
Dhruvaraj Subhashchandran1173b2b2024-06-01 11:12:13 -050025conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path'))
George Liubddcf852021-09-08 08:46:22 +080026
27conf_data.set('MAX_CPUS', get_option('max-cpus'))
28conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0)
29conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0)
Eddie James3f710bd2021-10-20 13:40:52 -050030conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor'))
George Liubddcf852021-09-08 08:46:22 +080031
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060032if get_option('i2c-occ').allowed()
George Liubddcf852021-09-08 08:46:22 +080033 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/')
34 conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices')
35 conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon')
36else
37 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/')
38 conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/')
39endif
40
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060041conf_data.set('I2C_OCC', get_option('i2c-occ').allowed())
42conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').allowed())
Patrick Williams9bec8af2023-09-07 14:02:27 -050043conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm')
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060044conf_data.set('POWER10', get_option('power10-support').allowed())
Chris Cain720a3842025-01-09 10:23:36 -060045conf_data.set('PHAL_SUPPORT', get_option('phal-support').allowed())
George Liubddcf852021-09-08 08:46:22 +080046
Eddie James88811ad2024-08-27 13:39:05 -050047if get_option('transport-implementation') == 'mctp-demux'
48 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1)
49elif get_option('transport-implementation') == 'af-mctp'
50 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1)
51endif
52
Rashmica Gupta52328cb2023-02-15 10:38:16 +110053if cxx.has_header('poll.h')
54 conf_data.set('PLDM_HAS_POLL', 1)
55endif
56
George Liubddcf852021-09-08 08:46:22 +080057configure_file(output: 'config.h',
58 configuration: conf_data
59)
60
Chris Cain7bd6d142023-01-11 13:41:09 -060061install_data('occ-active.sh',
62 install_mode: 'rwxr-xr-x',
63 install_dir: get_option('bindir')
64)
65
66systemd = dependency('systemd')
67systemd_system_unit_dir = systemd.get_variable(
Patrick Williams47831f52023-04-12 08:01:05 -050068 'systemdsystemunitdir')
Chris Cain7bd6d142023-01-11 13:41:09 -060069subdir('service_files')
70
Patrick Williamse2a58512022-09-13 11:26:57 -050071sdbusplus_dep = dependency('sdbusplus')
Patrick Williamse2a58512022-09-13 11:26:57 -050072
George Liubddcf852021-09-08 08:46:22 +080073python_prog = find_program('python3', required: true)
George Liubddcf852021-09-08 08:46:22 +080074
75deps = []
76sources = []
Patrick Williams9bec8af2023-09-07 14:02:27 -050077
Patrick Williamsf6992a42024-02-28 11:12:24 -060078cereal_dep = dependency('cereal', required: false)
79has_cereal = cxx.has_header_symbol(
80 'cereal/cereal.hpp',
81 'cereal::specialize',
82 dependencies: cereal_dep,
83 required: false)
84if not has_cereal
85 cereal_opts = import('cmake').subproject_options()
86 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
87 cereal_proj = import('cmake').subproject(
88 'cereal',
89 options: cereal_opts,
90 required: false)
91 assert(cereal_proj.found(), 'cereal is required')
92 cereal_dep = cereal_proj.dependency('cereal')
93endif
94
Patrick Williamsa9374912023-12-07 17:22:45 -060095nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams447c1832024-02-28 11:15:33 -060096phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
97phosphor_logging_dep = dependency('phosphor-logging')
98sdeventplus_dep = dependency('sdeventplus')
Patrick Williams9bec8af2023-09-07 14:02:27 -050099
Patrick Williams9bec8af2023-09-07 14:02:27 -0500100deps += [
Patrick Williamsf6992a42024-02-28 11:12:24 -0600101 cereal_dep,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500102 nlohmann_json_dep,
103 phosphor_dbus_interfaces_dep,
104 phosphor_logging_dep,
105 sdbusplus_dep,
106 sdeventplus_dep,
107]
Patrick Williamsd86651f2023-02-08 09:31:48 -0600108
Patrick Williams9bec8af2023-09-07 14:02:27 -0500109sources += [
110 'app.cpp',
111 'occ_pass_through.cpp',
112 'occ_manager.cpp',
113 'occ_status.cpp',
114 'occ_device.cpp',
115 'occ_errors.cpp',
116 'occ_ffdc.cpp',
117 'occ_presence.cpp',
118 'occ_command.cpp',
119 'occ_dbus.cpp',
120 'powercap.cpp',
121 'i2c_occ.cpp',
122 'utils.cpp',
123]
124
125if get_option('with-host-communication-protocol')=='pldm'
Patrick Williams6506e0d2024-02-28 11:23:11 -0600126 libpldm_dep = dependency('libpldm')
George Liubddcf852021-09-08 08:46:22 +0800127 deps += [
Chris Cain720a3842025-01-09 10:23:36 -0600128 libpldm_dep
George Liubddcf852021-09-08 08:46:22 +0800129 ]
George Liubddcf852021-09-08 08:46:22 +0800130 sources += [
Chris Cain720a3842025-01-09 10:23:36 -0600131 'pldm.cpp'
George Liubddcf852021-09-08 08:46:22 +0800132 ]
Patrick Williams9bec8af2023-09-07 14:02:27 -0500133endif
George Liubddcf852021-09-08 08:46:22 +0800134
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -0600135if get_option('power10-support').allowed()
Chris Cain720a3842025-01-09 10:23:36 -0600136 libpldm_dep = dependency('libpldm')
137 deps += [
138 libpldm_dep
139 ]
Patrick Williams9bec8af2023-09-07 14:02:27 -0500140 sources += [
Chris Cain720a3842025-01-09 10:23:36 -0600141 'pldm.cpp',
Patrick Williams9bec8af2023-09-07 14:02:27 -0500142 'powermode.cpp',
143 ]
144endif
George Liubddcf852021-09-08 08:46:22 +0800145
Chris Cain720a3842025-01-09 10:23:36 -0600146if get_option('phal-support').allowed()
147 deps += [
148 cxx.find_library('pdbg'),
149 cxx.find_library('phal')
150 ]
151endif
152
Patrick Williams9bec8af2023-09-07 14:02:27 -0500153yamldir = get_option('yamldir')
154if yamldir == ''
155 yamldir = meson.project_source_root() / 'example'
156endif
George Liubddcf852021-09-08 08:46:22 +0800157
Patrick Williams9bec8af2023-09-07 14:02:27 -0500158# Generate occ-sensor.hpp.
159occ_sensor_hpp = custom_target(
160 'occ-sensor.hpp',
161 command : [
162 python_prog,
163 meson.project_source_root() + '/sensor_gen.py',
164 '-i', yamldir,
165 ],
166 output : 'occ-sensor.hpp')
George Liubddcf852021-09-08 08:46:22 +0800167 sources += [occ_sensor_hpp]
168
169 executable(
170 'openpower-occ-control',
171 sources,
Patrick Williamsd8aab2a2023-04-21 11:15:54 -0500172 include_directories: '.',
George Liubddcf852021-09-08 08:46:22 +0800173 implicit_include_directories: true,
174 dependencies: deps,
175 install: true,
176 install_dir: get_option('bindir')
177 )
George Liubddcf852021-09-08 08:46:22 +0800178
179if not get_option('tests').disabled()
180 subdir('test')
181endif