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