blob: ef6feed04d4bb54f1e18f45545d20533a85585b3 [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
Patrick Williams601cea42025-02-01 08:36:51 -05002 'openpower-occ-control',
3 'cpp',
4 version: '1.0.0',
Patrick Williams50cfb702023-07-12 11:15:24 -05005 meson_version: '>=1.1.1',
George Liubddcf852021-09-08 08:46:22 +08006 default_options: [
7 'warning_level=3',
8 'werror=true',
Patrick Williams50cfb702023-07-12 11:15:24 -05009 'cpp_std=c++23',
Patrick Williams601cea42025-02-01 08:36:51 -050010 'buildtype=debugoptimized',
11 ],
George Liubddcf852021-09-08 08:46:22 +080012)
13
Eddie Jamescbad2192021-10-07 09:39:39 -050014cxx = meson.get_compiler('cpp')
15
George Liubddcf852021-09-08 08:46:22 +080016conf_data = configuration_data()
17conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control')
18conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control')
19conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors')
20conf_data.set_quoted('CPU_NAME', 'cpu')
21conf_data.set_quoted('OCC_NAME', 'occ')
22conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1')
23conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ')
Patrick Williams601cea42025-02-01 08:36:51 -050024conf_data.set_quoted(
25 'CPU_SUBPATH',
26 '/xyz/openbmc_project/inventory/system/chassis/motherboard',
27)
28conf_data.set_quoted(
29 'OCC_CONTROL_PERSIST_PATH',
30 '/var/lib/openpower-occ-control',
31)
Dhruvaraj Subhashchandran1173b2b2024-06-01 11:12:13 -050032conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path'))
George Liubddcf852021-09-08 08:46:22 +080033
34conf_data.set('MAX_CPUS', get_option('max-cpus'))
35conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0)
36conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0)
Eddie James3f710bd2021-10-20 13:40:52 -050037conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor'))
George Liubddcf852021-09-08 08:46:22 +080038
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060039if get_option('i2c-occ').allowed()
George Liubddcf852021-09-08 08:46:22 +080040 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/')
41 conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices')
42 conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon')
43else
Patrick Williams601cea42025-02-01 08:36:51 -050044 conf_data.set_quoted(
45 'OCC_HWMON_PATH',
46 '/sys/bus/platform/drivers/occ-hwmon/',
47 )
George Liubddcf852021-09-08 08:46:22 +080048 conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/')
49endif
50
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060051conf_data.set('I2C_OCC', get_option('i2c-occ').allowed())
52conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').allowed())
Patrick Williams601cea42025-02-01 08:36:51 -050053conf_data.set('PLDM', get_option('with-host-communication-protocol') == 'pldm')
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -060054conf_data.set('POWER10', get_option('power10-support').allowed())
Chris Cain720a3842025-01-09 10:23:36 -060055conf_data.set('PHAL_SUPPORT', get_option('phal-support').allowed())
George Liubddcf852021-09-08 08:46:22 +080056
Eddie James88811ad2024-08-27 13:39:05 -050057if get_option('transport-implementation') == 'mctp-demux'
58 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1)
59elif get_option('transport-implementation') == 'af-mctp'
60 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1)
61endif
62
Rashmica Gupta52328cb2023-02-15 10:38:16 +110063if cxx.has_header('poll.h')
64 conf_data.set('PLDM_HAS_POLL', 1)
65endif
66
Patrick Williams601cea42025-02-01 08:36:51 -050067configure_file(output: 'config.h', configuration: conf_data)
George Liubddcf852021-09-08 08:46:22 +080068
Patrick Williams601cea42025-02-01 08:36:51 -050069install_data(
70 'occ-active.sh',
Chris Cain7bd6d142023-01-11 13:41:09 -060071 install_mode: 'rwxr-xr-x',
Patrick Williams601cea42025-02-01 08:36:51 -050072 install_dir: get_option('bindir'),
Chris Cain7bd6d142023-01-11 13:41:09 -060073)
74
75systemd = dependency('systemd')
Patrick Williams601cea42025-02-01 08:36:51 -050076systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
Chris Cain7bd6d142023-01-11 13:41:09 -060077subdir('service_files')
78
Patrick Williamse2a58512022-09-13 11:26:57 -050079sdbusplus_dep = dependency('sdbusplus')
Patrick Williamse2a58512022-09-13 11:26:57 -050080
George Liubddcf852021-09-08 08:46:22 +080081python_prog = find_program('python3', required: true)
George Liubddcf852021-09-08 08:46:22 +080082
83deps = []
84sources = []
Patrick Williams9bec8af2023-09-07 14:02:27 -050085
Patrick Williamsf6992a42024-02-28 11:12:24 -060086cereal_dep = dependency('cereal', required: false)
87has_cereal = cxx.has_header_symbol(
88 'cereal/cereal.hpp',
89 'cereal::specialize',
90 dependencies: cereal_dep,
Patrick Williams601cea42025-02-01 08:36:51 -050091 required: false,
92)
Patrick Williamsf6992a42024-02-28 11:12:24 -060093if not has_cereal
94 cereal_opts = import('cmake').subproject_options()
95 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
96 cereal_proj = import('cmake').subproject(
97 'cereal',
98 options: cereal_opts,
Patrick Williams601cea42025-02-01 08:36:51 -050099 required: false,
100 )
Patrick Williamsf6992a42024-02-28 11:12:24 -0600101 assert(cereal_proj.found(), 'cereal is required')
102 cereal_dep = cereal_proj.dependency('cereal')
103endif
104
Patrick Williamsa9374912023-12-07 17:22:45 -0600105nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams447c1832024-02-28 11:15:33 -0600106phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
107phosphor_logging_dep = dependency('phosphor-logging')
108sdeventplus_dep = dependency('sdeventplus')
Patrick Williams9bec8af2023-09-07 14:02:27 -0500109
Patrick Williams9bec8af2023-09-07 14:02:27 -0500110deps += [
Patrick Williamsf6992a42024-02-28 11:12:24 -0600111 cereal_dep,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500112 nlohmann_json_dep,
113 phosphor_dbus_interfaces_dep,
114 phosphor_logging_dep,
115 sdbusplus_dep,
116 sdeventplus_dep,
117]
Patrick Williamsd86651f2023-02-08 09:31:48 -0600118
Patrick Williams9bec8af2023-09-07 14:02:27 -0500119sources += [
120 'app.cpp',
121 'occ_pass_through.cpp',
122 'occ_manager.cpp',
123 'occ_status.cpp',
124 'occ_device.cpp',
125 'occ_errors.cpp',
126 'occ_ffdc.cpp',
127 'occ_presence.cpp',
128 'occ_command.cpp',
129 'occ_dbus.cpp',
130 'powercap.cpp',
131 'i2c_occ.cpp',
132 'utils.cpp',
133]
134
Patrick Williams601cea42025-02-01 08:36:51 -0500135if get_option('with-host-communication-protocol') == 'pldm'
Patrick Williams6506e0d2024-02-28 11:23:11 -0600136 libpldm_dep = dependency('libpldm')
Patrick Williams601cea42025-02-01 08:36:51 -0500137 deps += [libpldm_dep]
138 sources += ['pldm.cpp']
Patrick Williams9bec8af2023-09-07 14:02:27 -0500139endif
George Liubddcf852021-09-08 08:46:22 +0800140
Patrick Williamsa8ebb1d2023-11-29 06:44:15 -0600141if get_option('power10-support').allowed()
Chris Cain720a3842025-01-09 10:23:36 -0600142 libpldm_dep = dependency('libpldm')
Patrick Williams601cea42025-02-01 08:36:51 -0500143 deps += [libpldm_dep]
144 sources += ['pldm.cpp', 'powermode.cpp']
Patrick Williams9bec8af2023-09-07 14:02:27 -0500145endif
George Liubddcf852021-09-08 08:46:22 +0800146
Chris Cain720a3842025-01-09 10:23:36 -0600147if get_option('phal-support').allowed()
Patrick Williams601cea42025-02-01 08:36:51 -0500148 deps += [cxx.find_library('pdbg'), cxx.find_library('phal')]
Chris Cain720a3842025-01-09 10:23:36 -0600149endif
150
Patrick Williams9bec8af2023-09-07 14:02:27 -0500151yamldir = get_option('yamldir')
152if yamldir == ''
153 yamldir = meson.project_source_root() / 'example'
154endif
George Liubddcf852021-09-08 08:46:22 +0800155
Patrick Williams9bec8af2023-09-07 14:02:27 -0500156# Generate occ-sensor.hpp.
157occ_sensor_hpp = custom_target(
158 'occ-sensor.hpp',
Patrick Williams601cea42025-02-01 08:36:51 -0500159 command: [
Patrick Williams9bec8af2023-09-07 14:02:27 -0500160 python_prog,
161 meson.project_source_root() + '/sensor_gen.py',
Patrick Williams601cea42025-02-01 08:36:51 -0500162 '-i',
163 yamldir,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500164 ],
Patrick Williams601cea42025-02-01 08:36:51 -0500165 output: 'occ-sensor.hpp',
166)
167sources += [occ_sensor_hpp]
George Liubddcf852021-09-08 08:46:22 +0800168
Patrick Williams601cea42025-02-01 08:36:51 -0500169executable(
170 'openpower-occ-control',
171 sources,
172 include_directories: '.',
173 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
Patrick Williamseb888052025-01-30 17:47:34 -0500179if get_option('tests').allowed()
Patrick Williams601cea42025-02-01 08:36:51 -0500180 subdir('test')
George Liubddcf852021-09-08 08:46:22 +0800181endif