Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 1 | #ifndef __HOST_IPMI_SEN_HANDLER_H__ |
| 2 | #define __HOST_IPMI_SEN_HANDLER_H__ |
| 3 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 4 | #include <stdint.h> |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 5 | #include "types.hpp" |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 6 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 7 | // IPMI commands for net functions. |
| 8 | enum ipmi_netfn_sen_cmds |
| 9 | { |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame] | 10 | IPMI_CMD_GET_SDR_INFO = 0x20, |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 11 | IPMI_CMD_GET_SDR = 0x21, |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 12 | IPMI_CMD_RESERVE_SDR_REPO = 0x22, |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 13 | IPMI_CMD_GET_SENSOR_READING = 0x2D, |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame] | 14 | IPMI_CMD_GET_SENSOR_TYPE = 0x2F, |
| 15 | IPMI_CMD_SET_SENSOR = 0x30, |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 16 | }; |
| 17 | |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 18 | // Discrete sensor types. |
| 19 | enum ipmi_sensor_types |
| 20 | { |
| 21 | IPMI_SENSOR_TEMP = 0x01, |
| 22 | IPMI_SENSOR_VOLTAGE = 0x02, |
| 23 | IPMI_SENSOR_CURRENT = 0x03, |
| 24 | IPMI_SENSOR_FAN = 0x04, |
Tom Joseph | 60cac72 | 2017-08-18 12:06:07 +0530 | [diff] [blame] | 25 | IPMI_SENSOR_TPM = 0xCC, |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 28 | #define MAX_DBUS_PATH 128 |
| 29 | struct dbus_interface_t { |
| 30 | uint8_t sensornumber; |
| 31 | uint8_t sensortype; |
| 32 | |
| 33 | char bus[MAX_DBUS_PATH]; |
| 34 | char path[MAX_DBUS_PATH]; |
| 35 | char interface[MAX_DBUS_PATH]; |
| 36 | }; |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 37 | |
| 38 | int set_sensor_dbus_state_s(uint8_t , const char *, const char *); |
| 39 | int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t); |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 40 | int find_openbmc_path(uint8_t , dbus_interface_t *); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 41 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 42 | /** |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame] | 43 | * Get SDR Info |
| 44 | */ |
| 45 | |
| 46 | namespace get_sdr_info |
| 47 | { |
| 48 | namespace request |
| 49 | { |
| 50 | // Note: for some reason the ipmi_request_t appears to be the |
| 51 | // raw value for this call. |
| 52 | inline bool get_count(void* req) |
| 53 | { |
| 54 | return (bool)((uint64_t)(req) & 1); |
| 55 | } |
| 56 | } // namespace request |
| 57 | |
| 58 | namespace response |
| 59 | { |
| 60 | #define SDR_INFO_RESP_SIZE 2 |
| 61 | inline void set_lun_present(int lun, uint8_t* resp) |
| 62 | { |
| 63 | *resp |= 1 << lun; |
| 64 | } |
| 65 | inline void set_lun_not_present(int lun, uint8_t* resp) |
| 66 | { |
| 67 | *resp &= ~(1 << lun); |
| 68 | } |
| 69 | inline void set_dynamic_population(uint8_t* resp) |
| 70 | { |
| 71 | *resp |= 1 << 7; |
| 72 | } |
| 73 | inline void set_static_population(uint8_t* resp) |
| 74 | { |
| 75 | *resp &= ~(1 << 7); |
| 76 | } |
| 77 | } // namespace response |
| 78 | |
| 79 | struct GetSdrInfoResp |
| 80 | { |
| 81 | uint8_t count; |
| 82 | uint8_t luns_and_dynamic_population; |
| 83 | }; |
| 84 | |
| 85 | } // namespace get_sdr_info |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Get SDR |
| 89 | */ |
| 90 | namespace get_sdr |
| 91 | { |
| 92 | |
| 93 | struct GetSdrReq |
| 94 | { |
| 95 | uint8_t reservation_id_lsb; |
| 96 | uint8_t reservation_id_msb; |
| 97 | uint8_t record_id_lsb; |
| 98 | uint8_t record_id_msb; |
| 99 | uint8_t offset; |
| 100 | uint8_t bytes_to_read; |
| 101 | } __attribute__((packed)); |
| 102 | |
| 103 | namespace request |
| 104 | { |
| 105 | |
| 106 | inline uint8_t get_reservation_id(GetSdrReq* req) |
| 107 | { |
| 108 | return (req->reservation_id_lsb + (req->reservation_id_msb << 8)); |
| 109 | }; |
| 110 | |
| 111 | inline uint8_t get_record_id(GetSdrReq* req) |
| 112 | { |
| 113 | return (req->record_id_lsb + (req->record_id_msb << 8)); |
| 114 | }; |
| 115 | |
| 116 | } // namespace request |
| 117 | |
| 118 | // Response |
| 119 | struct GetSdrResp |
| 120 | { |
| 121 | uint8_t next_record_id_lsb; |
| 122 | uint8_t next_record_id_msb; |
| 123 | uint8_t record_data[64]; |
| 124 | } __attribute__((packed)); |
| 125 | |
| 126 | namespace response |
| 127 | { |
| 128 | |
| 129 | inline void set_next_record_id(int next, GetSdrResp* resp) |
| 130 | { |
| 131 | resp->next_record_id_lsb = next & 0xff; |
| 132 | resp->next_record_id_msb = (next >> 8) & 0xff; |
| 133 | }; |
| 134 | |
| 135 | } // namespace response |
| 136 | |
| 137 | // Record header |
| 138 | struct SensorDataRecordHeader |
| 139 | { |
| 140 | uint8_t record_id_lsb; |
| 141 | uint8_t record_id_msb; |
| 142 | uint8_t sdr_version; |
| 143 | uint8_t record_type; |
| 144 | uint8_t record_length; // Length not counting the header |
| 145 | } __attribute__((packed)); |
| 146 | |
| 147 | namespace header |
| 148 | { |
| 149 | |
| 150 | inline void set_record_id(int id, SensorDataRecordHeader* hdr) |
| 151 | { |
| 152 | hdr->record_id_lsb = (id & 0xFF); |
| 153 | hdr->record_id_msb = (id >> 8) & 0xFF; |
| 154 | }; |
| 155 | |
| 156 | } // namespace header |
| 157 | |
| 158 | enum SensorDataRecordType |
| 159 | { |
| 160 | SENSOR_DATA_FULL_RECORD = 1, |
| 161 | }; |
| 162 | |
| 163 | // Record key |
| 164 | struct SensorDataRecordKey |
| 165 | { |
| 166 | uint8_t owner_id; |
| 167 | uint8_t owner_lun; |
| 168 | uint8_t sensor_number; |
| 169 | } __attribute__((packed)); |
| 170 | |
| 171 | namespace key |
| 172 | { |
| 173 | |
| 174 | inline void set_owner_id_ipmb(SensorDataRecordKey* key) |
| 175 | { |
| 176 | key->owner_id &= ~0x01; |
| 177 | }; |
| 178 | |
| 179 | inline void set_owner_id_system_sw(SensorDataRecordKey* key) |
| 180 | { |
| 181 | key->owner_id |= 0x01; |
| 182 | }; |
| 183 | |
| 184 | inline void set_owner_id_address(uint8_t addr, SensorDataRecordKey* key) |
| 185 | { |
| 186 | key->owner_id &= 0x01; |
| 187 | key->owner_id |= addr<<1; |
| 188 | }; |
| 189 | |
| 190 | inline void set_owner_lun(uint8_t lun, SensorDataRecordKey* key) |
| 191 | { |
| 192 | key->owner_lun &= ~0x03; |
| 193 | key->owner_lun |= (lun&0x03); |
| 194 | }; |
| 195 | |
| 196 | inline void set_owner_lun_channel(uint8_t channel, SensorDataRecordKey* key) |
| 197 | { |
| 198 | key->owner_lun &= 0x0f; |
| 199 | key->owner_lun |= ((channel & 0xf)<<4); |
| 200 | }; |
| 201 | |
| 202 | } // namespace key |
| 203 | |
| 204 | // Body - full record |
| 205 | #define FULL_RECORD_ID_STR_MAX_LENGTH 16 |
| 206 | struct SensorDataFullRecordBody |
| 207 | { |
| 208 | uint8_t entity_id; |
| 209 | uint8_t entity_instance; |
| 210 | uint8_t sensor_initialization; |
| 211 | uint8_t sensor_capabilities; // no macro support |
| 212 | uint8_t sensor_type; |
| 213 | uint8_t event_reading_type; |
| 214 | uint8_t supported_assertions[2]; // no macro support |
| 215 | uint8_t supported_deassertions[2]; // no macro support |
| 216 | uint8_t discrete_reading_setting_mask[2]; // no macro support |
| 217 | uint8_t sensor_units_1; |
| 218 | uint8_t sensor_units_2_base; |
| 219 | uint8_t sensor_units_3_modifier; |
| 220 | uint8_t linearization; |
| 221 | uint8_t m_lsb; |
| 222 | uint8_t m_msb_and_tolerance; |
| 223 | uint8_t b_lsb; |
| 224 | uint8_t b_msb_and_accuracy_lsb; |
| 225 | uint8_t accuracy_and_sensor_direction; |
| 226 | uint8_t r_b_exponents; |
| 227 | uint8_t analog_characteristic_flags; //no macro support |
| 228 | uint8_t nominal_reading; |
| 229 | uint8_t normal_max; |
| 230 | uint8_t normal_min; |
| 231 | uint8_t sensor_max; |
| 232 | uint8_t sensor_min; |
| 233 | uint8_t upper_nonrecoverable_threshold; |
| 234 | uint8_t upper_critical_threshold; |
| 235 | uint8_t upper_noncritical_threshold; |
| 236 | uint8_t lower_nonrecoverable_threshold; |
| 237 | uint8_t lower_critical_threshold; |
| 238 | uint8_t lower_noncritical_threshold; |
| 239 | uint8_t positive_threshold_hysteresis; |
| 240 | uint8_t negative_threshold_hysteresis; |
| 241 | uint16_t reserved; |
| 242 | uint8_t oem_reserved; |
| 243 | uint8_t id_string_info; |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 244 | char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 245 | } __attribute__((packed)); |
| 246 | |
| 247 | namespace body |
| 248 | { |
| 249 | |
| 250 | inline void set_entity_instance_number(uint8_t n, |
| 251 | SensorDataFullRecordBody* body) |
| 252 | { |
| 253 | body->entity_instance &= 1<<7; |
| 254 | body->entity_instance |= (n & ~(1<<7)); |
| 255 | }; |
| 256 | inline void set_entity_physical_entity(SensorDataFullRecordBody* body) |
| 257 | { |
| 258 | body->entity_instance &= ~(1<<7); |
| 259 | }; |
| 260 | inline void set_entity_logical_container(SensorDataFullRecordBody* body) |
| 261 | { |
| 262 | body->entity_instance |= 1<<7; |
| 263 | }; |
| 264 | |
| 265 | inline void sensor_scanning_state(bool enabled, |
| 266 | SensorDataFullRecordBody* body) |
| 267 | { |
| 268 | if (enabled) |
| 269 | { |
| 270 | body->sensor_initialization |= 1<<0; |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | body->sensor_initialization &= ~(1<<0); |
| 275 | }; |
| 276 | }; |
| 277 | inline void event_generation_state(bool enabled, |
| 278 | SensorDataFullRecordBody* body) |
| 279 | { |
| 280 | if (enabled) |
| 281 | { |
| 282 | body->sensor_initialization |= 1<<1; |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | body->sensor_initialization &= ~(1<<1); |
| 287 | } |
| 288 | }; |
| 289 | inline void init_types_state(bool enabled, |
| 290 | SensorDataFullRecordBody* body) |
| 291 | { |
| 292 | if (enabled) |
| 293 | { |
| 294 | body->sensor_initialization |= 1<<2; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | body->sensor_initialization &= ~(1<<2); |
| 299 | } |
| 300 | }; |
| 301 | inline void init_hyst_state(bool enabled, |
| 302 | SensorDataFullRecordBody* body) |
| 303 | { |
| 304 | if (enabled) |
| 305 | { |
| 306 | body->sensor_initialization |= 1<<3; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | body->sensor_initialization &= ~(1<<3); |
| 311 | } |
| 312 | }; |
| 313 | inline void init_thresh_state(bool enabled, |
| 314 | SensorDataFullRecordBody* body) |
| 315 | { |
| 316 | if (enabled) |
| 317 | { |
| 318 | body->sensor_initialization |= 1<<4; |
| 319 | } |
| 320 | else |
| 321 | { |
| 322 | body->sensor_initialization &= ~(1<<4); |
| 323 | } |
| 324 | }; |
| 325 | inline void init_events_state(bool enabled, |
| 326 | SensorDataFullRecordBody* body) |
| 327 | { |
| 328 | if (enabled) |
| 329 | { |
| 330 | body->sensor_initialization |= 1<<5; |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | body->sensor_initialization &= ~(1<<5); |
| 335 | } |
| 336 | }; |
| 337 | inline void init_scanning_state(bool enabled, |
| 338 | SensorDataFullRecordBody* body) |
| 339 | { |
| 340 | if (enabled) |
| 341 | { |
| 342 | body->sensor_initialization |= 1<<6; |
| 343 | } |
| 344 | else |
| 345 | { |
| 346 | body->sensor_initialization &= ~(1<<6); |
| 347 | } |
| 348 | }; |
| 349 | inline void init_settable_state(bool enabled, |
| 350 | SensorDataFullRecordBody* body) |
| 351 | { |
| 352 | if (enabled) |
| 353 | { |
| 354 | body->sensor_initialization |= 1<<7; |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | body->sensor_initialization &= ~(1<<7); |
| 359 | } |
| 360 | }; |
| 361 | |
| 362 | inline void set_percentage(SensorDataFullRecordBody* body) |
| 363 | { |
| 364 | body->sensor_units_1 |= 1<<0; |
| 365 | }; |
| 366 | inline void unset_percentage(SensorDataFullRecordBody* body) |
| 367 | { |
| 368 | body->sensor_units_1 &= ~(1<<0); |
| 369 | }; |
| 370 | inline void set_modifier_operation(uint8_t op, SensorDataFullRecordBody* body) |
| 371 | { |
| 372 | body->sensor_units_1 &= ~(3<<1); |
| 373 | body->sensor_units_1 |= (op & 0x3)<<1; |
| 374 | }; |
| 375 | inline void set_rate_unit(uint8_t unit, SensorDataFullRecordBody* body) |
| 376 | { |
| 377 | body->sensor_units_1 &= ~(7<<3); |
| 378 | body->sensor_units_1 |= (unit & 0x7)<<3; |
| 379 | }; |
| 380 | inline void set_analog_data_format(uint8_t format, |
| 381 | SensorDataFullRecordBody* body) |
| 382 | { |
| 383 | body->sensor_units_1 &= ~(3<<6); |
| 384 | body->sensor_units_1 |= (format & 0x3)<<6; |
| 385 | }; |
| 386 | |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 387 | inline void set_m(uint16_t m, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 388 | { |
| 389 | body->m_lsb = m & 0xff; |
| 390 | body->m_msb_and_tolerance &= ~(3<<6); |
| 391 | body->m_msb_and_tolerance |= ((m & (3<<8)) >> 2); |
| 392 | }; |
| 393 | inline void set_tolerance(uint8_t tol, SensorDataFullRecordBody* body) |
| 394 | { |
| 395 | body->m_msb_and_tolerance &= ~0x3f; |
| 396 | body->m_msb_and_tolerance |= tol & 0x3f; |
| 397 | }; |
| 398 | |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 399 | inline void set_b(uint16_t b, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 400 | { |
| 401 | body->b_lsb = b & 0xff; |
| 402 | body->b_msb_and_accuracy_lsb &= ~(3<<6); |
| 403 | body->b_msb_and_accuracy_lsb |= ((b & (3<<8)) >> 2); |
| 404 | }; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 405 | inline void set_accuracy(uint16_t acc, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 406 | { |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 407 | // bottom 6 bits |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 408 | body->b_msb_and_accuracy_lsb &= ~0x3f; |
| 409 | body->b_msb_and_accuracy_lsb |= acc & 0x3f; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 410 | // top 4 bits |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 411 | body->accuracy_and_sensor_direction &= 0x0f; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 412 | body->accuracy_and_sensor_direction |= ((acc >> 6) & 0xf) << 4; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 413 | }; |
| 414 | inline void set_accuracy_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 415 | { |
| 416 | body->accuracy_and_sensor_direction &= ~(3<<2); |
| 417 | body->accuracy_and_sensor_direction |= (exp & 3)<<2; |
| 418 | }; |
| 419 | inline void set_sensor_dir(uint8_t dir, SensorDataFullRecordBody* body) |
| 420 | { |
| 421 | body->accuracy_and_sensor_direction &= ~(3<<0); |
| 422 | body->accuracy_and_sensor_direction |= (dir & 3); |
| 423 | }; |
| 424 | |
| 425 | inline void set_b_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 426 | { |
| 427 | body->r_b_exponents &= 0xf0; |
| 428 | body->r_b_exponents |= exp & 0x0f; |
| 429 | }; |
| 430 | inline void set_r_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 431 | { |
| 432 | body->r_b_exponents &= 0x0f; |
| 433 | body->r_b_exponents |= (exp & 0x0f)<<4; |
| 434 | }; |
| 435 | |
| 436 | inline void set_id_strlen(uint8_t len, SensorDataFullRecordBody* body) |
| 437 | { |
| 438 | body->id_string_info &= ~(0x1f); |
| 439 | body->id_string_info |= len & 0x1f; |
| 440 | }; |
| 441 | inline uint8_t get_id_strlen( SensorDataFullRecordBody* body) |
| 442 | { |
| 443 | return body->id_string_info & 0x1f; |
| 444 | }; |
| 445 | inline void set_id_type(uint8_t type, SensorDataFullRecordBody* body) |
| 446 | { |
| 447 | body->id_string_info &= ~(3<<6); |
| 448 | body->id_string_info |= (type & 0x3)<<6; |
| 449 | }; |
| 450 | |
| 451 | } // namespace body |
| 452 | |
| 453 | // More types contained in section 43.17 Sensor Unit Type Codes, |
| 454 | // IPMI spec v2 rev 1.1 |
| 455 | enum SensorUnitTypeCodes |
| 456 | { |
| 457 | SENSOR_UNIT_UNSPECIFIED = 0, |
| 458 | SENSOR_UNIT_DEGREES_C = 1, |
| 459 | SENSOR_UNIT_VOLTS = 4, |
| 460 | SENSOR_UNIT_AMPERES = 5, |
| 461 | SENSOR_UNIT_JOULES = 7, |
| 462 | SENSOR_UNIT_METERS = 34, |
| 463 | SENSOR_UNIT_REVOLUTIONS = 41, |
| 464 | }; |
| 465 | |
| 466 | struct SensorDataFullRecord |
| 467 | { |
| 468 | SensorDataRecordHeader header; |
| 469 | SensorDataRecordKey key; |
| 470 | SensorDataFullRecordBody body; |
| 471 | } __attribute__((packed)); |
| 472 | |
| 473 | } // get_sdr |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 474 | |
| 475 | namespace ipmi |
| 476 | { |
| 477 | |
| 478 | namespace sensor |
| 479 | { |
| 480 | |
| 481 | /** |
| 482 | * @brief Map offset to the corresponding bit in the assertion byte. |
| 483 | * |
| 484 | * The discrete sensors support upto 14 states. 0-7 offsets are stored in one |
| 485 | * byte and offsets 8-14 in the second byte. |
| 486 | * |
| 487 | * @param[in] offset - offset number. |
| 488 | * @param[in/out] resp - get sensor reading response. |
| 489 | */ |
| 490 | inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp) |
| 491 | { |
| 492 | if (offset > 7) |
| 493 | { |
| 494 | resp->assertOffset8_14 |= 1 << (offset - 8); |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | resp->assertOffset0_7 |= 1 << offset; |
| 499 | } |
| 500 | } |
| 501 | |
Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 502 | /** |
| 503 | * @brief Set the reading field in the response. |
| 504 | * |
| 505 | * @param[in] offset - offset number. |
| 506 | * @param[in/out] resp - get sensor reading response. |
| 507 | */ |
| 508 | inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp) |
| 509 | { |
| 510 | resp->reading = value; |
| 511 | } |
| 512 | |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 513 | /** |
| 514 | * @brief Map the value to the assertion bytes. The assertion states are stored |
| 515 | * in 2 bytes. |
| 516 | * |
| 517 | * @param[in] value - value to mapped to the assertion byte. |
| 518 | * @param[in/out] resp - get sensor reading response. |
| 519 | */ |
| 520 | inline void setAssertionBytes(uint16_t value, |
| 521 | ipmi::sensor::GetReadingResponse* resp) |
| 522 | { |
| 523 | resp->assertOffset0_7 = static_cast<uint8_t>(value & 0x00FF); |
| 524 | resp->assertOffset8_14 = static_cast<uint8_t>(value >> 8); |
| 525 | } |
| 526 | |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 527 | /** |
| 528 | * @brief Set the scanning enabled bit in the response. |
| 529 | * |
| 530 | * @param[in/out] resp - get sensor reading response. |
| 531 | */ |
| 532 | inline void enableScanning(ipmi::sensor::GetReadingResponse* resp) |
| 533 | { |
| 534 | resp->operation = 1 << 6; |
| 535 | } |
| 536 | |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 537 | } // namespace sensor |
| 538 | |
| 539 | } // namespace ipmi |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 540 | #endif |