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