Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 3 | #include <stdint.h> |
| 4 | |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 5 | /** |
| 6 | * @brief TI special attention handler |
| 7 | * |
| 8 | * Handle special attention due to a terminate immediately (TI) condition. |
| 9 | */ |
| 10 | namespace attn |
| 11 | { |
| 12 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 13 | // TI data area definition |
| 14 | #pragma pack(push) |
| 15 | #pragma pack(1) |
| 16 | struct TiDataArea |
| 17 | { |
| 18 | uint8_t tiAreaValid; // 0x00, common (non-zero == valid) |
| 19 | uint8_t command; // 0x01, phyp/opal = 0xA1 |
| 20 | uint16_t numDataBytes; // 0x02, phyp/opal |
| 21 | uint8_t reserved1; // 0x04, reserved |
| 22 | uint8_t hbTerminateType; // 0x05, hostboot only |
| 23 | uint16_t hardwareDumpType; // 0x06, phyp/opal |
| 24 | uint8_t srcFormat; // 0x08, phyp/opal = 0x02 |
| 25 | uint8_t srcFlags; // 0x09, phyp/opal |
| 26 | uint8_t numAsciiWords; // 0x0a, phyp/opal |
| 27 | uint8_t numHexWords; // 0x0b, phyp/opal |
| 28 | uint8_t hbDumpFlag; // 0x0c, hostboot only |
| 29 | uint8_t source; // 0x0d, hostboot only |
| 30 | uint16_t lenSrc; // 0x0e, phyp/opal |
| 31 | uint32_t srcWord12HbWord0; // 0x10, common |
| 32 | uint32_t srcWord13HbWord2; // 0x14, common (Word1 intentionally skipped) |
| 33 | uint32_t srcWord14HbWord3; // 0x18, common |
| 34 | uint32_t srcWord15HbWord4; // 0x1c, common |
| 35 | uint32_t srcWord16HbWord5; // 0x20, common |
| 36 | uint32_t srcWord17HbWord6; // 0x24, common |
| 37 | uint32_t srcWord18HbWord7; // 0x28, common |
| 38 | uint32_t srcWord19HbWord8; // 0x2c, common |
| 39 | uint32_t asciiData0; // 0x30, phyp/opal, hostboot error_data |
| 40 | uint32_t asciiData1; // 0x34, phyp/opal, hostboot EID |
| 41 | uint32_t asciiData2; // 0x38, phyp/opal |
| 42 | uint32_t asciiData3; // 0x3c, phyp/opal |
| 43 | uint32_t asciiData4; // 0x40, phyp/opal |
| 44 | uint32_t asciiData5; // 0x44, phyp/opal |
| 45 | uint32_t asciiData6; // 0x48, phyp/opal |
| 46 | uint32_t asciiData7; // 0x4c, phyp/opal |
| 47 | uint8_t location; // 0x50, phyp/opal |
| 48 | uint8_t codeSection; // 0x51, phyp/opal |
| 49 | uint8_t additionalSize; // 0x52, phyp/opal |
| 50 | uint8_t andData; // 0x53, phyp/opal |
| 51 | }; |
| 52 | #pragma pack(pop) |
| 53 | |
Ben Tyner | 8c5e4f4 | 2020-10-28 11:11:55 -0500 | [diff] [blame] | 54 | // miscellaneous defines |
| 55 | constexpr uint8_t TI_WITH_PLID = 0x01; |
| 56 | constexpr uint8_t TI_WITH_SRC = 0x02; |
| 57 | constexpr uint8_t TI_WITH_EID = 0x03; |
| 58 | |
| 59 | // component ID's |
| 60 | constexpr uint16_t INITSVC_COMP_ID = 0x0500; |
| 61 | constexpr uint16_t PNOR_COMP_ID = 0x0600; |
| 62 | constexpr uint16_t HWAS_COMP_ID = 0x0C00; |
| 63 | constexpr uint16_t SECURE_COMP_ID = 0x1E00; |
| 64 | constexpr uint16_t TRBOOT_COMP_ID = 0x2B00; |
| 65 | |
| 66 | // HBFW::INITSERVICE::SHUTDOWNPREQUESTED_BY_FSP |
| 67 | constexpr uint16_t HB_SRC_SHUTDOWN_REQUEST = INITSVC_COMP_ID | 0x0b; |
| 68 | |
| 69 | // SHUTDOWN_KEY_TRANSITION |
| 70 | constexpr uint16_t HB_SRC_KEY_TRANSITION = INITSVC_COMP_ID | 0x15; |
| 71 | |
| 72 | // HBFW::HWAS::RC_SYSAVAIL_INSUFFICIENT_HW |
| 73 | constexpr uint16_t HB_SRC_INSUFFICIENT_HW = HWAS_COMP_ID | 0x04; |
| 74 | |
| 75 | // HBFW::TRUSTDBOOT::RC_TPM_NOFUNCTIONALTPM_FAIL |
| 76 | constexpr uint16_t HB_SRC_TPM_FAIL = TRBOOT_COMP_ID | 0xAD; |
| 77 | |
| 78 | // HBFW::SECUREBOOT::RC_ROM_VERIFY |
| 79 | constexpr uint16_t HB_SRC_ROM_VERIFY = SECURE_COMP_ID | 0x07; |
| 80 | |
| 81 | // HBFW::PNOR::RC_BASE_EXT_MISMATCH |
| 82 | constexpr uint16_t HB_SRC_EXT_MISMATCH = PNOR_COMP_ID | 0x2F; |
| 83 | |
| 84 | // HBFW::PNOR:RC_ECC_UE |
| 85 | constexpr uint16_t HB_SRC_ECC_UE = PNOR_COMP_ID | 0x0F; |
| 86 | |
| 87 | // HBFW::PNOR:RC_UNSUPPORTED_MODE |
| 88 | constexpr uint16_t HB_SRC_UNSUPPORTED_MODE = PNOR_COMP_ID | 0x0D; |
| 89 | |
| 90 | // HBFW::PNOR:RC_UNSUPPORTED_SFCRANGE |
| 91 | constexpr uint16_t HB_SRC_UNSUPPORTED_SFCRANGE = PNOR_COMP_ID | 0x0E; |
| 92 | |
| 93 | // HBFW::PNOR:RC_PARTITION_TABLE_INVALID |
| 94 | constexpr uint16_t HB_SRC_PARTITION_TABLE = PNOR_COMP_ID | 0x0C; |
| 95 | |
| 96 | // HBFW::PNOR:RC_UNSUPPORTED_HARDWARE |
| 97 | constexpr uint16_t HB_SRC_UNSUPPORTED_HARDWARE = PNOR_COMP_ID | 0x0A; |
| 98 | |
| 99 | // HBFW::PNOR:RC_PNOR_CORRUPTION |
| 100 | constexpr uint16_t HB_SRC_PNOR_CORRUPTION = PNOR_COMP_ID | 0x99; |
| 101 | |
| 102 | /** @brief Handle terminate immediate special attentions */ |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 103 | int tiHandler(TiDataArea* i_tiDataArea); |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 104 | |
Ben Tyner | 8c5e4f4 | 2020-10-28 11:11:55 -0500 | [diff] [blame] | 105 | /** @brief Handle phyp terminate immediately special attention */ |
| 106 | void handlePhypTi(TiDataArea* i_tiDataArea); |
| 107 | |
| 108 | /** @brief Handle hostboot terminate immediately special attention */ |
| 109 | void handleHbTi(TiDataArea* i_tiDataArea); |
| 110 | |
Ben Tyner | ff17f96 | 2020-09-23 08:21:19 -0500 | [diff] [blame] | 111 | /** |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 112 | * @brief Parse TI info data as PHYP/OPAL data |
| 113 | * |
| 114 | * Read the TI data, parse as PHYP/OPAL data and place into map. |
| 115 | */ |
| 116 | void parsePhypOpalTiInfo(std::map<std::string, std::string>& i_map, |
| 117 | TiDataArea* i_tiDataArea); |
| 118 | |
| 119 | /** |
| 120 | * @brief Parse TI info data as hostboot data |
| 121 | * |
| 122 | * Read the TI data, parse as hostboot data and place into map. |
| 123 | */ |
| 124 | void parseHbTiInfo(std::map<std::string, std::string>& i_map, |
| 125 | TiDataArea* i_tiDataArea); |
| 126 | |
Ben Tyner | a16758b | 2021-12-07 10:38:05 -0600 | [diff] [blame] | 127 | constexpr uint8_t defaultPhypTiInfo[0x58] = { |
| 128 | 0x01, 0xa1, 0x02, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, |
| 129 | 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 130 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 131 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 132 | 0x00, 0x00, 0x00, 0x00, 0x42, 0x37, 0x30, 0x30, 0x46, 0x46, 0x46, |
| 133 | 0x46, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 134 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 135 | 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 136 | |
| 137 | constexpr uint8_t defaultHbTiInfo[0x58] = { |
| 138 | 0x01, 0xa1, 0x02, 0xa8, 0x00, TI_WITH_SRC, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 139 | 0x09, 0x01, 0x00, 0x00, 0x00, 0xbc, 0x80, 0x1b, 0x99, 0x00, 0x00, |
| 140 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 141 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 142 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 143 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 145 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 146 | |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 147 | } // namespace attn |