blob: d186f96511a63e2ef74f2ee2569a9f2c4ac5172c [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +01002
3#include <stdio.h>
4#include "me.h"
5
6#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
7
8/* HFS1[3:0] Current Working State Values */
9static const char *me_cws_values[] = {
10 [ME_HFS_CWS_RESET] = "Reset",
11 [ME_HFS_CWS_INIT] = "Initializing",
12 [ME_HFS_CWS_REC] = "Recovery",
Damien Zammit8e3b8422019-02-23 14:18:07 +110013 [ME_HFS_CWS_TEST] = "Test",
14 [ME_HFS_CWS_DISABLED] = "Disabled",
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010015 [ME_HFS_CWS_NORMAL] = "Normal",
16 [ME_HFS_CWS_WAIT] = "Platform Disable Wait",
17 [ME_HFS_CWS_TRANS] = "OP State Transition",
18 [ME_HFS_CWS_INVALID] = "Invalid CPU Plugged In"
19};
20
21/* HFS1[8:6] Current Operation State Values */
22static const char *me_opstate_values[] = {
23 [ME_HFS_STATE_PREBOOT] = "Preboot",
24 [ME_HFS_STATE_M0_UMA] = "M0 with UMA",
25 [ME_HFS_STATE_M3] = "M3 without UMA",
26 [ME_HFS_STATE_M0] = "M0 without UMA",
27 [ME_HFS_STATE_BRINGUP] = "Bring up",
28 [ME_HFS_STATE_ERROR] = "M0 without UMA but with error"
29};
30
31/* HFS[19:16] Current Operation Mode Values */
32static const char *me_opmode_values[] = {
33 [ME_HFS_MODE_NORMAL] = "Normal",
34 [ME_HFS_MODE_DEBUG] = "Debug",
35 [ME_HFS_MODE_DIS] = "Soft Temporary Disable",
36 [ME_HFS_MODE_OVER_JMPR] = "Security Override via Jumper",
37 [ME_HFS_MODE_OVER_MEI] = "Security Override via MEI Message"
38};
39
40/* HFS[15:12] Error Code Values */
41static const char *me_error_values[] = {
42 [ME_HFS_ERROR_NONE] = "No Error",
43 [ME_HFS_ERROR_UNCAT] = "Uncategorized Failure",
Damien Zammit8e3b8422019-02-23 14:18:07 +110044 [ME_HFS_ERROR_DISABLED] = "Disabled",
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010045 [ME_HFS_ERROR_IMAGE] = "Image Failure",
46 [ME_HFS_ERROR_DEBUG] = "Debug Failure"
47};
48
49/* GMES[31:28] ME Progress Code */
50static const char *me_progress_values[] = {
51 [ME_GMES_PHASE_ROM] = "ROM Phase",
52 [ME_GMES_PHASE_BUP] = "BUP Phase",
53 [ME_GMES_PHASE_UKERNEL] = "uKernel Phase",
54 [ME_GMES_PHASE_POLICY] = "Policy Module",
55 [ME_GMES_PHASE_MODULE] = "Module Loading",
56 [ME_GMES_PHASE_UNKNOWN] = "Unknown",
57 [ME_GMES_PHASE_HOST] = "Host Communication"
58};
59
60/* GMES[27:24] Power Management Event */
61static const char *me_pmevent_values[] = {
62 [0x00] = "Clean Moff->Mx wake",
63 [0x01] = "Moff->Mx wake after an error",
64 [0x02] = "Clean global reset",
65 [0x03] = "Global reset after an error",
66 [0x04] = "Clean Intel ME reset",
67 [0x05] = "Intel ME reset due to exception",
68 [0x06] = "Pseudo-global reset",
69 [0x07] = "S0/M0->Sx/M3",
70 [0x08] = "Sx/M3->S0/M0",
71 [0x09] = "Non-power cycle reset",
72 [0x0a] = "Power cycle reset through M3",
73 [0x0b] = "Power cycle reset through Moff",
74 [0x0c] = "Sx/Mx->Sx/Moff"
75};
76
77/* Progress Code 0 states */
78static const char *me_progress_rom_values[] = {
79 [0x00] = "BEGIN",
80 [0x06] = "DISABLE"
81};
82
83/* Progress Code 1 states */
84static const char *me_progress_bup_values[] = {
85 [0x00] = "Initialization starts",
86 [0x01] = "Disable the host wake event",
87 [0x04] = "Flow determination start process",
88 [0x08] = "Error reading/matching the VSCC table in the descriptor",
89 [0x0a] = "Check to see if straps say ME DISABLED",
90 [0x0b] = "Timeout waiting for PWROK",
91 [0x0d] = "Possibly handle BUP manufacturing override strap",
92 [0x11] = "Bringup in M3",
93 [0x12] = "Bringup in M0",
94 [0x13] = "Flow detection error",
95 [0x15] = "M3 clock switching error",
96 [0x18] = "M3 kernel load",
97 [0x1c] = "T34 missing - cannot program ICC",
98 [0x1f] = "Waiting for DID BIOS message",
99 [0x20] = "Waiting for DID BIOS message failure",
100 [0x21] = "DID reported an error",
101 [0x22] = "Enabling UMA",
102 [0x23] = "Enabling UMA error",
103 [0x24] = "Sending DID Ack to BIOS",
104 [0x25] = "Sending DID Ack to BIOS error",
105 [0x26] = "Switching clocks in M0",
106 [0x27] = "Switching clocks in M0 error",
107 [0x28] = "ME in temp disable",
108 [0x32] = "M0 kernel load",
109};
110
111/* Progress Code 3 states */
112static const char *me_progress_policy_values[] = {
113 [0x00] = "Entery into Policy Module",
114 [0x03] = "Received S3 entry",
115 [0x04] = "Received S4 entry",
116 [0x05] = "Received S5 entry",
117 [0x06] = "Received UPD entry",
118 [0x07] = "Received PCR entry",
119 [0x08] = "Received NPCR entry",
120 [0x09] = "Received host wake",
121 [0x0a] = "Received AC<>DC switch",
122 [0x0b] = "Received DRAM Init Done",
123 [0x0c] = "VSCC Data not found for flash device",
124 [0x0d] = "VSCC Table is not valid",
125 [0x0e] = "Flash Partition Boundary is outside address space",
126 [0x0f] = "ME cannot access the chipset descriptor region",
127 [0x10] = "Required VSCC values for flash parts do not match",
128};
129
130void intel_me_status(uint32_t hfs, uint32_t gmes)
131{
132 /* Check Current States */
133 printf("ME: FW Partition Table : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200134 ((hfs & 0x20) >> 5) ? "BAD" : "OK");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100135 printf("ME: Bringup Loader Failure : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200136 ((hfs & 0x400) >> 10) ? "YES" : "NO");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100137 printf("ME: Firmware Init Complete : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200138 ((hfs & 0x200) >> 9) ? "YES" : "NO");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100139 printf("ME: Manufacturing Mode : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200140 ((hfs & 0x10) >> 4) ? "YES" : "NO");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100141 printf("ME: Boot Options Present : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200142 ((hfs & 0x1000000) >> 24) ? "YES" : "NO");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100143 printf("ME: Update In Progress : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200144 ((hfs & 0x800) >> 11) ? "YES" : "NO");
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100145 printf("ME: Current Working State : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200146 me_cws_values[hfs & 0xf]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100147 printf("ME: Current Operation State : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200148 me_opstate_values[(hfs & 0x1c0) >> 6]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100149 printf("ME: Current Operation Mode : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200150 me_opmode_values[(hfs & 0xf0000) >> 16]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100151 printf("ME: Error Code : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200152 me_error_values[(hfs & 0xf000) >> 12]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100153 printf("ME: Progress Phase : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200154 me_progress_values[(gmes & 0xf0000000) >> 28]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100155 printf("ME: Power Management Event : %s\n",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200156 me_pmevent_values[(gmes & 0xf000000) >> 24]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100157
158 printf("ME: Progress Phase State : ");
159 switch ((gmes & 0xf0000000) >> 28) {
160 case ME_GMES_PHASE_ROM: /* ROM Phase */
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200161 printf("%s", me_progress_rom_values[(gmes & 0xff0000) >> 16]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100162 break;
163
164 case ME_GMES_PHASE_BUP: /* Bringup Phase */
165 if ((gmes & 0xff0000) >> 16 < ARRAY_SIZE(me_progress_bup_values)
166 && me_progress_bup_values[(gmes & 0xff0000) >> 16])
167 printf("%s",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200168 me_progress_bup_values[(gmes & 0xff0000) >> 16]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100169 else
170 printf("0x%02x", (gmes & 0xff0000) >> 16);
171 break;
172
173 case ME_GMES_PHASE_POLICY: /* Policy Module Phase */
174 if ((gmes & 0xff0000) >> 16 < ARRAY_SIZE(me_progress_policy_values)
175 && me_progress_policy_values[(gmes & 0xff0000) >> 16])
176 printf("%s",
Maximilian Schanderdf5b83f2017-10-28 18:33:07 +0200177 me_progress_policy_values[(gmes & 0xff0000) >> 16]);
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +0100178 else
179 printf("0x%02x", (gmes & 0xff0000) >> 16);
180 break;
181
182 case ME_GMES_PHASE_HOST: /* Host Communication Phase */
183 if (!((gmes & 0xff0000) >> 16))
184 printf("Host communication established");
185 else
186 printf("0x%02x", (gmes & 0xff0000) >> 16);
187 break;
188
189 default:
190 printf("Unknown 0x%02x", (gmes & 0xff0000) >> 16);
191 }
192 printf("\n");
193}