1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef __CROS_EC_INCLUDE_CITADEL_EVENTS_H 17 #define __CROS_EC_INCLUDE_CITADEL_EVENTS_H 18 19 #include <assert.h> 20 #include <stdint.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #ifndef __packed 27 #define __packed __attribute__((packed)) 28 #endif 29 30 /* 31 * When Citadel needs to tell the AP something without waiting to be asked, the 32 * process is as follows: 33 * 34 * 1. Citadel adds an event_report to its internal queue, then asserts 35 * the CTDL_AP_IRQ signal to notify the AP. 36 * 37 * 2. The AP (citadeld) requests pending events from Citadel until they've 38 * all been retrieved. 39 * 40 * 3. Citadel deasserts CTDL_AP_IRQ. 41 * 42 * Because we may want to compare the history and evolution of events over a 43 * long time and for multiple releases, we should only APPEND to this file 44 * instead of changing things. 45 */ 46 47 /* 48 * Event priority. Stored events of lower priority will be evicted to store 49 * higher-priority events if the queue is full. 50 */ 51 enum event_priority { 52 EVENT_PRIORITY_LOW = 0, 53 EVENT_PRIORITY_MEDIUM = 1, 54 EVENT_PRIORITY_HIGH = 2, 55 }; 56 57 /* 58 * Event ID values live forever. 59 * Add to the list, but NEVER change or delete existing entries. 60 */ 61 enum event_id { 62 EVENT_NONE = 0, // Unused ID, used as empty marker. 63 EVENT_ALERT = 1, // Globalsec alert fired. 64 EVENT_REBOOTED = 2, // Device rebooted. 65 EVENT_UPGRADED = 3, // Device has upgraded. 66 EVENT_ALERT_V2 = 4, // Globalsec Alertv2 fired (Dauntless) 67 EVENT_SEC_CH_STATE = 5, // Update GSA-GSC secure channel state. 68 EVENT_V1_NO_SUPPORT = 69 6 // Report a VXX event that can't fit in struct event_report. 70 }; 71 72 /* 73 * Upgrade state definition. 74 */ 75 enum upgrade_state_def { 76 UPGRADE_SUCCESS = 0, 77 UPGRADE_PW_MISMATCH = 1, 78 UPGRADE_EN_FW_FAIL = 2, 79 /* Extended defines to distinguish RO upgrades from RW ones */ 80 UPGRADE_SUCCESS_RO = 3, 81 UPGRADE_PW_MISMATCH_RO = 4, 82 UPGRADE_EN_FW_FAIL_RO = 5, 83 }; 84 85 /* 86 * Big event header flags. 87 */ 88 enum hdr_flags { 89 HDR_FLAG_EMPTY_SLOT = 0, // Used to determine empty slot. 90 HDR_FLAG_OCCUPIED_SLOT = 1 // Used to indicate an occupied slot. 91 }; 92 93 /* Please do not change the size of this struct */ 94 #define EVENT_REPORT_SIZE 64 95 struct event_report { 96 uint64_t reset_count; /* zeroed by Citadel power cycle */ 97 uint64_t uptime_usecs; /* since last Citadel reset */ 98 uint32_t id; 99 uint32_t priority; 100 union { 101 /* id-specific information goes here */ 102 struct { 103 uint32_t intr_sts[3]; 104 } alert; 105 struct { 106 uint32_t rstsrc; 107 uint32_t exitpd; 108 uint32_t which0; 109 uint32_t which1; 110 } rebooted; 111 struct { 112 uint32_t upgrade_state; 113 } upgraded; 114 struct { 115 uint32_t alert_grp[4]; 116 uint16_t camo_breaches[2]; 117 uint16_t temp_min; 118 uint16_t temp_max; 119 uint32_t bus_err; 120 } alert_v2; 121 struct { 122 uint32_t state; 123 } sec_ch_state; 124 125 /* uninterpreted */ 126 union { 127 uint32_t w[10]; 128 uint16_t h[20]; 129 uint8_t b[40]; 130 } raw; 131 } event; 132 } __packed; 133 /* Please do not change the size of this struct */ 134 static_assert(sizeof(struct event_report) == EVENT_REPORT_SIZE, 135 "Muting the Immutable"); 136 137 struct big_event_report { 138 struct hdr { 139 /* Redundant w.r.t. to v1 event records */ 140 uint64_t reset_count; 141 uint64_t uptime_usecs; 142 uint32_t priority; 143 144 uint8_t version; 145 uint8_t flags; 146 uint16_t length; 147 } hdr; 148 uint8_t data[384]; 149 } __packed; 150 151 #ifdef __cplusplus 152 } 153 #endif 154 155 #endif /* __CROS_EC_INCLUDE_CITADEL_EVENTS_H */ 156