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