Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 1 | #include "sensorhandler.hpp" |
| 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include <malloc.h> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 4 | |
George Liu | 5e72ce9 | 2024-07-19 09:26:40 +0800 | [diff] [blame] | 5 | #include <phosphor-logging/lg2.hpp> |
| 6 | |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 7 | extern uint8_t find_type_for_sensor_number(uint8_t); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 8 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 9 | struct sensorRES_t |
| 10 | { |
| 11 | uint8_t sensor_number; |
| 12 | uint8_t operation; |
| 13 | uint8_t sensor_reading; |
| 14 | uint8_t assert_state7_0; |
| 15 | uint8_t assert_state14_8; |
| 16 | uint8_t deassert_state7_0; |
| 17 | uint8_t deassert_state14_8; |
| 18 | uint8_t event_data1; |
| 19 | uint8_t event_data2; |
| 20 | uint8_t event_data3; |
| 21 | } __attribute__((packed)); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 22 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 23 | #define ISBITSET(x, y) (((x) >> (y)) & 0x01) |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 24 | #define ASSERTINDEX 0 |
| 25 | #define DEASSERTINDEX 1 |
| 26 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 27 | // Sensor Type, Offset, function handler, Dbus Method, Assert value, Deassert |
| 28 | // value |
| 29 | struct lookup_t |
| 30 | { |
| 31 | uint8_t sensor_type; |
| 32 | uint8_t offset; |
| 33 | int (*func)(const sensorRES_t*, const lookup_t*, const char*); |
| 34 | char member[16]; |
| 35 | char assertion[64]; |
| 36 | char deassertion[64]; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 37 | }; |
| 38 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 39 | extern int updateDbusInterface(uint8_t, const char*, const char*); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 40 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 41 | int set_sensor_dbus_state_simple(const sensorRES_t* pRec, |
| 42 | const lookup_t* pTable, const char* value) |
| 43 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 44 | return set_sensor_dbus_state_s(pRec->sensor_number, pTable->member, value); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 45 | } |
| 46 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 47 | struct event_data_t |
| 48 | { |
| 49 | uint8_t data; |
| 50 | char text[64]; |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 53 | event_data_t g_fwprogress02h[] = {{0x00, "Unspecified"}, |
| 54 | {0x01, "Memory Init"}, |
| 55 | {0x02, "HD Init"}, |
| 56 | {0x03, "Secondary Proc Init"}, |
| 57 | {0x04, "User Authentication"}, |
| 58 | {0x05, "User init system setup"}, |
| 59 | {0x06, "USB configuration"}, |
| 60 | {0x07, "PCI configuration"}, |
| 61 | {0x08, "Option ROM Init"}, |
| 62 | {0x09, "Video Init"}, |
| 63 | {0x0A, "Cache Init"}, |
| 64 | {0x0B, "SM Bus init"}, |
| 65 | {0x0C, "Keyboard Init"}, |
| 66 | {0x0D, "Embedded ctrl init"}, |
| 67 | {0x0E, "Docking station attachment"}, |
| 68 | {0x0F, "Enable docking station"}, |
| 69 | {0x10, "Docking station ejection"}, |
| 70 | {0x11, "Disabling docking station"}, |
| 71 | {0x12, "Calling OS Wakeup"}, |
| 72 | {0x13, "Starting OS"}, |
| 73 | {0x14, "Baseboard Init"}, |
| 74 | {0x15, ""}, |
| 75 | {0x16, "Floppy Init"}, |
| 76 | {0x17, "Keyboard Test"}, |
| 77 | {0x18, "Pointing Device Test"}, |
| 78 | {0x19, "Primary Proc Init"}, |
| 79 | {0xFF, "Unknown"}}; |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 80 | |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 81 | event_data_t g_fwprogress00h[] = { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 82 | {0x00, "Unspecified."}, |
| 83 | {0x01, "No system memory detected"}, |
| 84 | {0x02, "No usable system memory"}, |
| 85 | {0x03, "Unrecoverable hard-disk/ATAPI/IDE"}, |
| 86 | {0x04, "Unrecoverable system-board"}, |
| 87 | {0x05, "Unrecoverable diskette"}, |
| 88 | {0x06, "Unrecoverable hard-disk controller"}, |
| 89 | {0x07, "Unrecoverable PS/2 or USB keyboard"}, |
| 90 | {0x08, "Removable boot media not found"}, |
| 91 | {0x09, "Unrecoverable video controller"}, |
| 92 | {0x0A, "No video device detected"}, |
| 93 | {0x0B, "Firmware ROM corruption detected"}, |
| 94 | {0x0C, "CPU voltage mismatch"}, |
| 95 | {0x0D, "CPU speed matching"}, |
| 96 | {0xFF, "unknown"}, |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 97 | }; |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 98 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 99 | char* event_data_lookup(event_data_t* p, uint8_t b) |
| 100 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 101 | while (p->data != 0xFF) |
| 102 | { |
| 103 | if (p->data == b) |
| 104 | { |
| 105 | break; |
| 106 | } |
| 107 | p++; |
| 108 | } |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 109 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 110 | return p->text; |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 111 | } |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 112 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 113 | // The fw progress sensor contains some additional information that needs to be |
| 114 | // processed prior to calling the dbus code. |
| 115 | int set_sensor_dbus_state_fwprogress(const sensorRES_t* pRec, |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 116 | const lookup_t* pTable, const char*) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 117 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 118 | char valuestring[128]; |
| 119 | char* p = valuestring; |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 120 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 121 | switch (pTable->offset) |
| 122 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 123 | case 0x00: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 124 | std::snprintf( |
| 125 | p, sizeof(valuestring), "POST Error, %s", |
| 126 | event_data_lookup(g_fwprogress00h, pRec->event_data2)); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 127 | break; |
| 128 | case 0x01: /* Using g_fwprogress02h for 0x01 because that's what the |
| 129 | ipmi spec says to do */ |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 130 | std::snprintf( |
| 131 | p, sizeof(valuestring), "FW Hang, %s", |
| 132 | event_data_lookup(g_fwprogress02h, pRec->event_data2)); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 133 | break; |
| 134 | case 0x02: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 135 | std::snprintf( |
| 136 | p, sizeof(valuestring), "FW Progress, %s", |
| 137 | event_data_lookup(g_fwprogress02h, pRec->event_data2)); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 138 | break; |
| 139 | default: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 140 | std::snprintf( |
| 141 | p, sizeof(valuestring), |
| 142 | "Internal warning, fw_progres offset unknown (0x%02x)", |
| 143 | pTable->offset); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 144 | break; |
| 145 | } |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 146 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 147 | return set_sensor_dbus_state_s(pRec->sensor_number, pTable->member, p); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 148 | } |
| 149 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 150 | // Handling this special OEM sensor by coping what is in byte 4. I also think |
| 151 | // that is odd considering byte 3 is for sensor reading. This seems like a |
| 152 | // misuse of the IPMI spec |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 153 | int set_sensor_dbus_state_osbootcount(const sensorRES_t* pRec, const lookup_t*, |
| 154 | const char*) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 155 | { |
| 156 | return set_sensor_dbus_state_y(pRec->sensor_number, "setValue", |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 157 | pRec->assert_state7_0); |
Chris Austen | 0a4e247 | 2015-10-18 12:19:40 -0500 | [diff] [blame] | 158 | } |
| 159 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 160 | int set_sensor_dbus_state_system_event(const sensorRES_t* pRec, |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 161 | const lookup_t* pTable, const char*) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 162 | { |
| 163 | char valuestring[128]; |
| 164 | char* p = valuestring; |
Chris Austen | 800ba71 | 2015-12-03 15:31:00 -0600 | [diff] [blame] | 165 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 166 | switch (pTable->offset) |
| 167 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 168 | case 0x00: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 169 | std::snprintf(p, sizeof(valuestring), "System Reconfigured"); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 170 | break; |
| 171 | case 0x01: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 172 | std::snprintf(p, sizeof(valuestring), "OEM Boot Event"); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 173 | break; |
| 174 | case 0x02: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 175 | std::snprintf(p, sizeof(valuestring), |
| 176 | "Undetermined System Hardware Failure"); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 177 | break; |
| 178 | case 0x03: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 179 | std::snprintf( |
| 180 | p, sizeof(valuestring), |
| 181 | "System Failure see error log for more details (0x%02x)", |
| 182 | pRec->event_data2); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 183 | break; |
| 184 | case 0x04: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 185 | std::snprintf( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 186 | p, sizeof(valuestring), |
| 187 | "System Failure see PEF error log for more details (0x%02x)", |
| 188 | pRec->event_data2); |
| 189 | break; |
| 190 | default: |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 191 | std::snprintf( |
| 192 | p, sizeof(valuestring), |
| 193 | "Internal warning, system_event offset unknown (0x%02x)", |
| 194 | pTable->offset); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 195 | break; |
| 196 | } |
Chris Austen | 800ba71 | 2015-12-03 15:31:00 -0600 | [diff] [blame] | 197 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 198 | return set_sensor_dbus_state_s(pRec->sensor_number, pTable->member, p); |
Chris Austen | 800ba71 | 2015-12-03 15:31:00 -0600 | [diff] [blame] | 199 | } |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 200 | |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 201 | // This table lists only senors we care about telling dbus about. |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 202 | // Offset definition cab be found in section 42.2 of the IPMI 2.0 |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 203 | // spec. Add more if/when there are more items of interest. |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 204 | lookup_t g_ipmidbuslookup[] = { |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 205 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 206 | {0xe9, 0x00, set_sensor_dbus_state_simple, "setValue", "Disabled", |
| 207 | ""}, // OCC Inactive 0 |
| 208 | {0xe9, 0x01, set_sensor_dbus_state_simple, "setValue", "Enabled", |
| 209 | ""}, // OCC Active 1 |
| 210 | // Turbo Allowed |
| 211 | {0xda, 0x00, set_sensor_dbus_state_simple, "setValue", "True", "False"}, |
| 212 | // Power Supply Derating |
| 213 | {0xb4, 0x00, set_sensor_dbus_state_simple, "setValue", "", ""}, |
| 214 | // Power Cap |
| 215 | {0xC2, 0x00, set_sensor_dbus_state_simple, "setValue", "", ""}, |
| 216 | {0x07, 0x07, set_sensor_dbus_state_simple, "setPresent", "True", "False"}, |
| 217 | {0x07, 0x08, set_sensor_dbus_state_simple, "setFault", "True", "False"}, |
| 218 | {0x0C, 0x06, set_sensor_dbus_state_simple, "setPresent", "True", "False"}, |
| 219 | {0x0C, 0x04, set_sensor_dbus_state_simple, "setFault", "True", "False"}, |
| 220 | {0x0F, 0x02, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"}, |
| 221 | {0x0F, 0x01, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"}, |
| 222 | {0x0F, 0x00, set_sensor_dbus_state_fwprogress, "setValue", "True", "False"}, |
| 223 | {0xC7, 0x01, set_sensor_dbus_state_simple, "setFault", "True", "False"}, |
| 224 | {0xc3, 0x00, set_sensor_dbus_state_osbootcount, "setValue", "", ""}, |
| 225 | {0x1F, 0x00, set_sensor_dbus_state_simple, "setValue", |
| 226 | "Boot completed (00)", ""}, |
| 227 | {0x1F, 0x01, set_sensor_dbus_state_simple, "setValue", |
| 228 | "Boot completed (01)", ""}, |
| 229 | {0x1F, 0x02, set_sensor_dbus_state_simple, "setValue", "PXE boot completed", |
| 230 | ""}, |
| 231 | {0x1F, 0x03, set_sensor_dbus_state_simple, "setValue", |
| 232 | "Diagnostic boot completed", ""}, |
| 233 | {0x1F, 0x04, set_sensor_dbus_state_simple, "setValue", |
| 234 | "CD-ROM boot completed", ""}, |
| 235 | {0x1F, 0x05, set_sensor_dbus_state_simple, "setValue", "ROM boot completed", |
| 236 | ""}, |
| 237 | {0x1F, 0x06, set_sensor_dbus_state_simple, "setValue", |
| 238 | "Boot completed (06)", ""}, |
| 239 | {0x12, 0x00, set_sensor_dbus_state_system_event, "setValue", "", ""}, |
| 240 | {0x12, 0x01, set_sensor_dbus_state_system_event, "setValue", "", ""}, |
| 241 | {0x12, 0x02, set_sensor_dbus_state_system_event, "setValue", "", ""}, |
| 242 | {0x12, 0x03, set_sensor_dbus_state_system_event, "setValue", "", ""}, |
| 243 | {0x12, 0x04, set_sensor_dbus_state_system_event, "setValue", "", ""}, |
| 244 | {0xCA, 0x00, set_sensor_dbus_state_simple, "setValue", "Disabled", ""}, |
| 245 | {0xCA, 0x01, set_sensor_dbus_state_simple, "setValue", "Enabled", ""}, |
| 246 | {0xFF, 0xFF, NULL, "", "", ""}}; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 247 | |
Patrick Venture | d99148b | 2018-10-13 10:06:13 -0700 | [diff] [blame] | 248 | void reportSensorEventAssert(const sensorRES_t* pRec, int index) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 249 | { |
| 250 | lookup_t* pTable = &g_ipmidbuslookup[index]; |
| 251 | (*pTable->func)(pRec, pTable, pTable->assertion); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 252 | } |
Patrick Venture | d99148b | 2018-10-13 10:06:13 -0700 | [diff] [blame] | 253 | void reportSensorEventDeassert(const sensorRES_t* pRec, int index) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 254 | { |
| 255 | lookup_t* pTable = &g_ipmidbuslookup[index]; |
| 256 | (*pTable->func)(pRec, pTable, pTable->deassertion); |
Chris Austen | 0130d6e | 2015-10-15 22:32:36 -0500 | [diff] [blame] | 257 | } |
| 258 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 259 | int findindex(const uint8_t sensor_type, int offset, int* index) |
| 260 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 261 | int i = 0, rc = 0; |
| 262 | lookup_t* pTable = g_ipmidbuslookup; |
Gunnar Mills | d8249ee | 2018-04-12 16:33:53 -0500 | [diff] [blame] | 263 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 264 | do |
| 265 | { |
| 266 | if (((pTable + i)->sensor_type == sensor_type) && |
| 267 | ((pTable + i)->offset == offset)) |
| 268 | { |
| 269 | rc = 1; |
| 270 | *index = i; |
| 271 | break; |
| 272 | } |
| 273 | i++; |
| 274 | } while ((pTable + i)->sensor_type != 0xFF); |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 275 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 276 | return rc; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 277 | } |
| 278 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 279 | bool shouldReport(uint8_t sensorType, int offset, int* index) |
| 280 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 281 | bool rc = false; |
Chris Austen | 0a4e247 | 2015-10-18 12:19:40 -0500 | [diff] [blame] | 282 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 283 | if (findindex(sensorType, offset, index)) |
| 284 | { |
| 285 | rc = true; |
| 286 | } |
| 287 | if (rc == false) |
| 288 | { |
Aditya Saripalli | 5fb1460 | 2017-11-09 14:46:27 +0530 | [diff] [blame] | 289 | #ifdef __IPMI_DEBUG__ |
George Liu | 5e72ce9 | 2024-07-19 09:26:40 +0800 | [diff] [blame] | 290 | lg2::debug("LOOKATME: Sensor should not be reported, " |
| 291 | "sensor type: {SENSORTYPE}, offset: {OFFSET}", |
| 292 | SENSORTYPE, lg2::hex, sensorType, "OFFSET", lg2::hex, |
| 293 | offset); |
Aditya Saripalli | 5fb1460 | 2017-11-09 14:46:27 +0530 | [diff] [blame] | 294 | #endif |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 295 | } |
Chris Austen | 0a4e247 | 2015-10-18 12:19:40 -0500 | [diff] [blame] | 296 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 297 | return rc; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 298 | } |
| 299 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 300 | int updateSensorRecordFromSSRAESC(const void* record) |
| 301 | { |
Patrick Venture | d99148b | 2018-10-13 10:06:13 -0700 | [diff] [blame] | 302 | auto pRec = static_cast<const sensorRES_t*>(record); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 303 | uint8_t stype; |
Patrick Venture | 4491a46 | 2018-10-13 13:00:42 -0700 | [diff] [blame] | 304 | int index; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 305 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 306 | stype = find_type_for_sensor_number(pRec->sensor_number); |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 307 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 308 | // 0xC3 types use the assertion7_0 for the value to be set |
| 309 | // so skip the reseach and call the correct event reporting |
| 310 | // function |
| 311 | if (stype == 0xC3) |
| 312 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 313 | shouldReport(stype, 0x00, &index); |
| 314 | reportSensorEventAssert(pRec, index); |
| 315 | } |
| 316 | else |
| 317 | { |
| 318 | // Scroll through each bit position . Determine |
| 319 | // if any bit is either asserted or Deasserted. |
Patrick Venture | 4491a46 | 2018-10-13 13:00:42 -0700 | [diff] [blame] | 320 | for (int i = 0; i < 8; i++) |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 321 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 322 | if ((ISBITSET(pRec->assert_state7_0, i)) && |
| 323 | (shouldReport(stype, i, &index))) |
| 324 | { |
| 325 | reportSensorEventAssert(pRec, index); |
| 326 | } |
| 327 | if ((ISBITSET(pRec->assert_state14_8, i)) && |
| 328 | (shouldReport(stype, i + 8, &index))) |
| 329 | { |
| 330 | reportSensorEventAssert(pRec, index); |
| 331 | } |
| 332 | if ((ISBITSET(pRec->deassert_state7_0, i)) && |
| 333 | (shouldReport(stype, i, &index))) |
| 334 | { |
| 335 | reportSensorEventDeassert(pRec, index); |
| 336 | } |
| 337 | if ((ISBITSET(pRec->deassert_state14_8, i)) && |
| 338 | (shouldReport(stype, i + 8, &index))) |
| 339 | { |
| 340 | reportSensorEventDeassert(pRec, index); |
| 341 | } |
| 342 | } |
| 343 | } |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 344 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 345 | return 0; |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 346 | } |