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_record 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 /* Please do not change the size of this struct */ 48 #define EVENT_RECORD_SIZE 64 49 struct event_record { 50 uint64_t reset_count; /* zeroed by Citadel power cycle */ 51 uint64_t uptime_usecs; /* since last Citadel reset */ 52 uint32_t id; 53 union { 54 /* id-specific information goes here */ 55 struct { 56 uint32_t intr_sts[3]; 57 } alert; 58 struct { 59 uint32_t bad_thing; 60 } citadel; 61 struct { 62 uint32_t okay_thing; 63 } info; 64 65 /* uninterpreted */ 66 union { 67 uint32_t w[11]; 68 uint16_t h[22]; 69 uint8_t b[44]; 70 } raw; 71 } u; 72 } __packed; 73 /* Please do not change the size of this struct */ 74 static_assert(sizeof(struct event_record) == EVENT_RECORD_SIZE, 75 "Muting the Immutable"); 76 77 /* 78 * Event ID values live forever. 79 * Add to the list, but NEVER change or delete existing entries. 80 */ 81 enum event_id { 82 EVENT_NONE = 0, /* No valid event exists with this ID */ 83 EVENT_ALERT = 1, /* Security alert reported */ 84 EVENT_CITADEL = 2, /* Bad: panic, stack overflow, etc. */ 85 EVENT_INFO = 3, /* FYI: normal reboot, etc. */ 86 }; 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 #endif /* __CROS_EC_INCLUDE_CITADEL_EVENTS_H */ 93