Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 1 | /** |
| 2 | * @file hei_types.hpp |
| 3 | * |
| 4 | * This file contains simple types/enums used throughout all of the isolator |
| 5 | * code. |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <stdint.h> |
| 11 | |
Zane Shelley | 6b1fe16 | 2022-11-18 13:37:42 -0600 | [diff] [blame] | 12 | #include <limits> |
| 13 | |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 14 | namespace libhei |
| 15 | { |
| 16 | |
| 17 | /** |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 18 | * A value representing the type of chip that is being accessed. A unique value |
| 19 | * will exist for each Chip Data File. During isolation, the user application |
| 20 | * will pass these values to the isolator along with pointers to the user |
| 21 | * application's chip objects. This tells the isolator which Chip Data File to |
| 22 | * reference for each chip. |
| 23 | * |
| 24 | * Values: |
| 25 | * The values are determined by the chip manufacturer. The isolator does not |
| 26 | * need to know the possible values because the user application controls |
| 27 | * both the Chip Data Files and the input into the isolation function. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 28 | * |
| 29 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 30 | * This is defined as a 4-byte field in the Chip Data Files. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 31 | */ |
Zane Shelley | 8c093d8 | 2020-05-04 22:06:52 -0500 | [diff] [blame] | 32 | using ChipType_t = uint32_t; |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 33 | |
| 34 | /** |
Zane Shelley | 6722b5b | 2020-05-12 22:09:04 -0500 | [diff] [blame] | 35 | * Each isolation node within a chip must have a unique ID. These IDs (combined |
| 36 | * with other information) will be passed back to the user application to |
| 37 | * identify all of the active errors reported by this chip. Note that some |
| 38 | * isolation nodes will have multiple instances within a chip. An ID will be |
| 39 | * used for all instances of a node. See enum Instance_t for details on the |
| 40 | * instance value. |
| 41 | * |
| 42 | * Values: |
| 43 | * The isolator does not need to know the possible values because the values |
| 44 | * are passed from the Chip Data Files to the user application. |
| 45 | * |
| 46 | * Range: |
| 47 | * This is a 2-byte field, which should be sufficient to support all the |
| 48 | * isolation nodes on a typical chip. |
| 49 | */ |
| 50 | using NodeId_t = uint16_t; |
| 51 | |
| 52 | /** |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 53 | * Different chips will contain different types of registers. Also, a single |
| 54 | * chip may also support multiple types of registers. These enum values are |
| 55 | * used to communicate to the user application which type of register access is |
| 56 | * needed. |
| 57 | * |
| 58 | * Values: |
| 59 | * The supported register types are listed in this enum. |
| 60 | * |
| 61 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 62 | * This is defined as the minimum 1-byte field in the Chip Data Files. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 63 | */ |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 64 | enum RegisterType_t : uint8_t |
| 65 | { |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 66 | REG_TYPE_SCOM = 0x01, ///< Power Systems SCOM register. |
| 67 | REG_TYPE_ID_SCOM = 0x02, ///< Power Systems Indirect SCOM register. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /** |
| 71 | * Each register within a chip must have a unique ID. These IDs (combined with |
| 72 | * other information) will be passed back to the user application to identify |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 73 | * register contents captured for debugging purposes. Note that some registers |
| 74 | * will have multiple instances within a chip. An ID will be used for all |
| 75 | * instances of a register. See Instance_t for details on the register instance |
| 76 | * value. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 77 | * |
| 78 | * Values: |
| 79 | * The isolator does not need to know the possible values because the values |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 80 | * are passed from the Chip Data Files to the user application. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 81 | * |
| 82 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 83 | * This is defined as a 3-byte field in the Chip Data Files, which should be |
| 84 | * sufficient to support all the registers on a typical chip. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 85 | */ |
Zane Shelley | b9a8e76 | 2020-05-11 21:41:32 -0500 | [diff] [blame] | 86 | // IMPORTANT: typedef or using only creates an alias which is not a new type. |
| 87 | // Need to defined this as an enum so that template specialization will detect a |
| 88 | // new variable type. See note aboved for details. |
| 89 | enum RegisterId_t : uint32_t; |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 90 | |
| 91 | /** |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 92 | * A chip could contain more than one instance of a register or node. For |
| 93 | * example, a register could exist for each instance of a core on a processor |
| 94 | * chip. This field will be used to differeniate multiple instances of a |
| 95 | * register in order to avoid repeating common information for every instance. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 96 | * |
| 97 | * Values: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 98 | * Not all registers or nodes will have multiple instances. So the default |
| 99 | * instance value is 0, which always indicates the first (or only) logical |
| 100 | * instance. Then a value of 1-255 can be used for each subsequent instance. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 101 | * |
| 102 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 103 | * This is defined as a 1-byte field in the Chip Data Files. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 104 | */ |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 105 | using Instance_t = uint8_t; |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 106 | |
| 107 | /** |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 108 | * This is used to defined a bit field for a register or node. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 109 | * |
| 110 | * Values: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 111 | * The widest supported register type is only 64-bits (value 0-63). |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 112 | * |
| 113 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 114 | * This is defined as a 1-byte field in the Chip Data Files. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 115 | */ |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 116 | using BitPosition_t = uint8_t; |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 117 | |
| 118 | /** |
Zane Shelley | 6b1fe16 | 2022-11-18 13:37:42 -0600 | [diff] [blame] | 119 | * The maximum bit position supported by the BitPosition_t type. Note that this |
| 120 | * value does not represent the maximum bit position for a specific register |
| 121 | * type. That will need to be calculated seperately. |
| 122 | */ |
| 123 | constexpr auto MAX_BIT_POSITION = std::numeric_limits<BitPosition_t>::max(); |
| 124 | |
| 125 | /** |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 126 | * The hardware address of a register (right justified). |
| 127 | * |
| 128 | * Values: |
| 129 | * Currently only supporting 1, 2, 4, or 8 byte addresses. |
| 130 | * |
| 131 | * Range: |
| 132 | * The maximum supported address requires an 8-byte field. |
| 133 | */ |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 134 | using RegisterAddress_t = uint64_t; |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 135 | |
| 136 | /** |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 137 | * The hardware register attribute flags. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 138 | * |
| 139 | * Values: |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 140 | * Each bit within this field represents an attribute flag. If the bit is 0, |
| 141 | * the flag is disabled. If the bit is 1, the flag is enabled. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 142 | * |
| 143 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 144 | * This is defined as a 1-byte field in the Chip Data Files. |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 145 | */ |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 146 | enum RegisterAttributeFlags_t : uint8_t |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 147 | { |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 148 | REG_ATTR_ACCESS_READ = 0x80, ///< Register read access access |
| 149 | REG_ATTR_ACCESS_WRITE = 0x40, ///< Register write access access |
| 150 | REG_ATTR_RESERVED = 0x3f, ///< Reserved/unused bits |
Zane Shelley | 0d4f562 | 2019-10-14 13:02:30 -0500 | [diff] [blame] | 151 | }; |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 152 | |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 153 | /** |
| 154 | * The Chip Data Files will contain action, rules, etc. based on the supported |
| 155 | * attention types listed in this enum. The user application must use the |
| 156 | * values defined in this enum in order to maintain consistency across all |
| 157 | * chips. |
| 158 | * |
| 159 | * Values: |
| 160 | * The supported attention types are listed in this enum. |
| 161 | * |
| 162 | * Range: |
Zane Shelley | 13b182b | 2020-05-07 20:23:45 -0500 | [diff] [blame] | 163 | * This is defined as a 1-byte field in the Chip Data Files. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 164 | */ |
| 165 | enum AttentionType_t : uint8_t |
| 166 | { |
Zane Shelley | 7c8faa1 | 2019-10-28 22:26:28 -0500 | [diff] [blame] | 167 | // clang-format off |
| 168 | |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 169 | /** System checkstop hardware attention. Unrecoverable, fatal error. */ |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame^] | 170 | // TODO: This is deprecated and will be removed. Use CHIP_CS instead. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 171 | ATTN_TYPE_CHECKSTOP = 1, |
| 172 | |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame^] | 173 | /** |
| 174 | * Hardware error event indicating that an entire chip has checkstopped and |
| 175 | * is no longer usable. |
| 176 | */ |
| 177 | ATTN_TYPE_CHIP_CS = 1, |
| 178 | |
| 179 | /** |
| 180 | * Hardware error event indicating that a unit within a chip has |
| 181 | * checkstopped and is no longer usable. Other units within the chip should |
| 182 | * continue uninterrupted. Possible degraded functionality. |
| 183 | */ |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 184 | ATTN_TYPE_UNIT_CS = 2, |
| 185 | |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame^] | 186 | /** |
| 187 | * Hardware error event in which the hardware recovered. The system should |
| 188 | * be able to continue uninterrupted. Possible degraded functionality. |
| 189 | */ |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 190 | ATTN_TYPE_RECOVERABLE = 3, |
| 191 | |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame^] | 192 | /** |
| 193 | * Software or hardware event requiring action by the service processor |
| 194 | * firmware. |
| 195 | */ |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 196 | ATTN_TYPE_SP_ATTN = 4, |
| 197 | |
Zane Shelley | b7005ca | 2023-03-24 15:23:59 -0500 | [diff] [blame^] | 198 | /** |
| 199 | * Software or hardware event requiring action by the host firmware. |
| 200 | */ |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 201 | ATTN_TYPE_HOST_ATTN = 5, |
Zane Shelley | 7c8faa1 | 2019-10-28 22:26:28 -0500 | [diff] [blame] | 202 | |
| 203 | // clang-format on |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 204 | }; |
| 205 | |
Zane Shelley | 2e38ae5 | 2020-11-05 22:21:30 -0600 | [diff] [blame] | 206 | /** |
| 207 | * Each Chip Data File will begin with a keyword signafying it is a Chip Data |
| 208 | * File. |
| 209 | */ |
| 210 | using FileKeyword_t = uint64_t; |
| 211 | |
| 212 | constexpr FileKeyword_t KW_CHIPDATA = 0x4348495044415441; // "CHIPDATA" ASCII |
| 213 | |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 214 | } // end namespace libhei |