]>
Commit | Line | Data |
---|---|---|
4184aabd MK |
1 | /** @file\r |
2 | Publishes ESRT table from Firmware Management Protocol instances\r | |
3 | \r | |
4 | Copyright (c) 2016, Microsoft Corporation\r | |
5 | Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r | |
6 | \r | |
7 | All rights reserved.\r | |
9d510e61 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
4184aabd MK |
9 | \r |
10 | **/\r | |
11 | \r | |
12 | #include <Uefi.h>\r | |
13 | #include <Library/BaseLib.h>\r | |
14 | #include <Library/BaseMemoryLib.h>\r | |
15 | #include <Library/DebugLib.h>\r | |
16 | #include <Protocol/FirmwareManagement.h>\r | |
17 | #include <Guid/SystemResourceTable.h>\r | |
18 | \r | |
19 | /**\r | |
ae38c976 | 20 | Function to print a single ESRT Entry (ESRE) to the debug console.\r |
4184aabd MK |
21 | \r |
22 | Print Format:\r | |
23 | | 00000000-0000-0000-0000-000000000000 | SSSSSSSSSSSS | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 |\r | |
24 | \r | |
25 | @param[in] Entry - Pointer to an ESRE entry\r | |
26 | @retval EFI_SUCCESS\r | |
27 | EFI_INVALID_PARAMETER\r | |
28 | **/\r | |
29 | EFI_STATUS\r | |
30 | EFIAPI\r | |
31 | PrintOutEsrtEntry (\r | |
32 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry\r | |
33 | )\r | |
34 | {\r | |
35 | if (Entry == NULL) {\r | |
36 | DEBUG ((DEBUG_INFO, "| ERROR: Invalid resource entry pointer "));\r | |
37 | DEBUG ((DEBUG_INFO, " |\n"));\r | |
38 | return EFI_INVALID_PARAMETER;\r | |
39 | }\r | |
40 | \r | |
41 | //\r | |
42 | // GUID FW Class (36 chars plus table formatting)\r | |
43 | //\r | |
44 | DEBUG ((DEBUG_INFO, "| %g |", &Entry->FwClass));\r | |
45 | \r | |
46 | //\r | |
47 | // Entry Type (12 chars plus table formatting)\r | |
48 | //\r | |
49 | switch (Entry->FwType) {\r | |
50 | case (ESRT_FW_TYPE_SYSTEMFIRMWARE) :\r | |
51 | DEBUG ((DEBUG_INFO, " System FW |"));\r | |
52 | break;\r | |
53 | case (ESRT_FW_TYPE_DEVICEFIRMWARE) :\r | |
54 | DEBUG ((DEBUG_INFO, " Device FW |"));\r | |
55 | break;\r | |
56 | case (ESRT_FW_TYPE_UEFIDRIVER) :\r | |
57 | DEBUG ((DEBUG_INFO, " Uefi Driver |"));\r | |
58 | break;\r | |
59 | case (ESRT_FW_TYPE_UNKNOWN) :\r | |
60 | DEBUG ((DEBUG_INFO, " Unknown Type |"));\r | |
61 | break;\r | |
62 | default:\r | |
63 | DEBUG ((DEBUG_INFO, " ? 0x%8X |", Entry->FwType));\r | |
64 | break;\r | |
65 | }\r | |
66 | \r | |
67 | //\r | |
68 | // FW Version (10 char UINT32 string plus table formatting)\r | |
69 | // Lowest Supported Version (10 char UINT32 string plus table formatting)\r | |
70 | // Capsule Flags (10 char UINT32 string plus table formatting)\r | |
71 | // Last Attempt Version (10 char UINT32 string plus table formatting)\r | |
72 | // Last Attempt Status (10 char UINT32 string plus table formatting)\r | |
73 | //\r | |
74 | DEBUG ((DEBUG_INFO,\r | |
75 | " 0x%8X | 0x%8X | 0x%8X | 0x%8X | 0x%8X |\n",\r | |
76 | Entry->FwVersion,\r | |
77 | Entry->LowestSupportedFwVersion,\r | |
78 | Entry->CapsuleFlags,\r | |
79 | Entry->LastAttemptVersion,\r | |
80 | Entry->LastAttemptStatus\r | |
81 | ));\r | |
82 | \r | |
83 | return EFI_SUCCESS;\r | |
84 | }\r | |
85 | \r | |
86 | /**\r | |
ae38c976 | 87 | Function to print the ESRT table to the debug console.\r |
4184aabd MK |
88 | \r |
89 | @param[in] Table - Pointer to the ESRT table\r | |
90 | **/\r | |
91 | VOID\r | |
92 | EFIAPI\r | |
93 | PrintTable (\r | |
94 | IN EFI_SYSTEM_RESOURCE_TABLE *Table\r | |
95 | )\r | |
96 | {\r | |
97 | EFI_SYSTEM_RESOURCE_ENTRY *Entry;\r | |
98 | UINTN Index;\r | |
99 | \r | |
100 | Entry = (EFI_SYSTEM_RESOURCE_ENTRY *)(((UINT8 *)Table) + sizeof (EFI_SYSTEM_RESOURCE_TABLE));\r | |
101 | \r | |
102 | //\r | |
103 | // Print ESRT table information\r | |
104 | //\r | |
105 | DEBUG ((DEBUG_INFO, "ESRT Table Information:\n"));\r | |
106 | if (Table == NULL) {\r | |
107 | DEBUG ((DEBUG_INFO, "ERROR: Invalid table pointer\n"));\r | |
108 | return;\r | |
109 | }\r | |
110 | \r | |
111 | DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r | |
112 | DEBUG ((DEBUG_INFO, "| Firmware Resource Count : 0x%08x |\n", Table->FwResourceCount));\r | |
113 | DEBUG ((DEBUG_INFO, "| Firmware Resource Count Max : 0x%08x |\n", Table->FwResourceCountMax));\r | |
114 | DEBUG ((DEBUG_INFO, "| Firmware Resource Entry Version : 0x%016x |\n", Table->FwResourceVersion));\r | |
115 | DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r | |
116 | \r | |
117 | //\r | |
118 | // Print table entry information\r | |
119 | //\r | |
120 | DEBUG ((DEBUG_INFO, "ESRT Table Entries:\n"));\r | |
121 | if (Table->FwResourceVersion != EFI_SYSTEM_RESOURCE_TABLE_FIRMWARE_RESOURCE_VERSION) {\r | |
122 | DEBUG ((DEBUG_INFO, "ERROR: Unsupported Resource Entry Version\n"));\r | |
123 | return;\r | |
124 | }\r | |
125 | \r | |
126 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
127 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
128 | DEBUG ((DEBUG_INFO, "| | | "));\r | |
129 | DEBUG ((DEBUG_INFO, "| Lowest | | Last | Last |\n"));\r | |
130 | DEBUG ((DEBUG_INFO, "| | Firmware | "));\r | |
131 | DEBUG ((DEBUG_INFO, "| Supported | Capsule | Attempted | Attempted |\n"));\r | |
132 | DEBUG ((DEBUG_INFO, "| CLASS GUID | Type | Version "));\r | |
133 | DEBUG ((DEBUG_INFO, "| Version | Flags | Version | Status |\n"));\r | |
134 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
135 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
136 | \r | |
137 | for (Index = 0; Index < Table->FwResourceCount; Index++) {\r | |
138 | PrintOutEsrtEntry (&(Entry[Index]));\r | |
139 | }\r | |
140 | \r | |
141 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
142 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
143 | }\r | |
144 | \r |