]>
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 | |
8 | Redistribution and use in source and binary forms, with or without\r | |
9 | modification, are permitted provided that the following conditions are met:\r | |
10 | 1. Redistributions of source code must retain the above copyright notice,\r | |
11 | this list of conditions and the following disclaimer.\r | |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,\r | |
13 | this list of conditions and the following disclaimer in the documentation\r | |
14 | and/or other materials provided with the distribution.\r | |
15 | \r | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r | |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r | |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r | |
19 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r | |
20 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r | |
21 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r | |
22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r | |
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r | |
24 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r | |
25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r | |
26 | \r | |
27 | **/\r | |
28 | \r | |
29 | #include <Uefi.h>\r | |
30 | #include <Library/BaseLib.h>\r | |
31 | #include <Library/BaseMemoryLib.h>\r | |
32 | #include <Library/DebugLib.h>\r | |
33 | #include <Protocol/FirmwareManagement.h>\r | |
34 | #include <Guid/SystemResourceTable.h>\r | |
35 | \r | |
36 | /**\r | |
ae38c976 | 37 | Function to print a single ESRT Entry (ESRE) to the debug console.\r |
4184aabd MK |
38 | \r |
39 | Print Format:\r | |
40 | | 00000000-0000-0000-0000-000000000000 | SSSSSSSSSSSS | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 | 0x00000000 |\r | |
41 | \r | |
42 | @param[in] Entry - Pointer to an ESRE entry\r | |
43 | @retval EFI_SUCCESS\r | |
44 | EFI_INVALID_PARAMETER\r | |
45 | **/\r | |
46 | EFI_STATUS\r | |
47 | EFIAPI\r | |
48 | PrintOutEsrtEntry (\r | |
49 | IN EFI_SYSTEM_RESOURCE_ENTRY *Entry\r | |
50 | )\r | |
51 | {\r | |
52 | if (Entry == NULL) {\r | |
53 | DEBUG ((DEBUG_INFO, "| ERROR: Invalid resource entry pointer "));\r | |
54 | DEBUG ((DEBUG_INFO, " |\n"));\r | |
55 | return EFI_INVALID_PARAMETER;\r | |
56 | }\r | |
57 | \r | |
58 | //\r | |
59 | // GUID FW Class (36 chars plus table formatting)\r | |
60 | //\r | |
61 | DEBUG ((DEBUG_INFO, "| %g |", &Entry->FwClass));\r | |
62 | \r | |
63 | //\r | |
64 | // Entry Type (12 chars plus table formatting)\r | |
65 | //\r | |
66 | switch (Entry->FwType) {\r | |
67 | case (ESRT_FW_TYPE_SYSTEMFIRMWARE) :\r | |
68 | DEBUG ((DEBUG_INFO, " System FW |"));\r | |
69 | break;\r | |
70 | case (ESRT_FW_TYPE_DEVICEFIRMWARE) :\r | |
71 | DEBUG ((DEBUG_INFO, " Device FW |"));\r | |
72 | break;\r | |
73 | case (ESRT_FW_TYPE_UEFIDRIVER) :\r | |
74 | DEBUG ((DEBUG_INFO, " Uefi Driver |"));\r | |
75 | break;\r | |
76 | case (ESRT_FW_TYPE_UNKNOWN) :\r | |
77 | DEBUG ((DEBUG_INFO, " Unknown Type |"));\r | |
78 | break;\r | |
79 | default:\r | |
80 | DEBUG ((DEBUG_INFO, " ? 0x%8X |", Entry->FwType));\r | |
81 | break;\r | |
82 | }\r | |
83 | \r | |
84 | //\r | |
85 | // FW Version (10 char UINT32 string plus table formatting)\r | |
86 | // Lowest Supported Version (10 char UINT32 string plus table formatting)\r | |
87 | // Capsule Flags (10 char UINT32 string plus table formatting)\r | |
88 | // Last Attempt Version (10 char UINT32 string plus table formatting)\r | |
89 | // Last Attempt Status (10 char UINT32 string plus table formatting)\r | |
90 | //\r | |
91 | DEBUG ((DEBUG_INFO,\r | |
92 | " 0x%8X | 0x%8X | 0x%8X | 0x%8X | 0x%8X |\n",\r | |
93 | Entry->FwVersion,\r | |
94 | Entry->LowestSupportedFwVersion,\r | |
95 | Entry->CapsuleFlags,\r | |
96 | Entry->LastAttemptVersion,\r | |
97 | Entry->LastAttemptStatus\r | |
98 | ));\r | |
99 | \r | |
100 | return EFI_SUCCESS;\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
ae38c976 | 104 | Function to print the ESRT table to the debug console.\r |
4184aabd MK |
105 | \r |
106 | @param[in] Table - Pointer to the ESRT table\r | |
107 | **/\r | |
108 | VOID\r | |
109 | EFIAPI\r | |
110 | PrintTable (\r | |
111 | IN EFI_SYSTEM_RESOURCE_TABLE *Table\r | |
112 | )\r | |
113 | {\r | |
114 | EFI_SYSTEM_RESOURCE_ENTRY *Entry;\r | |
115 | UINTN Index;\r | |
116 | \r | |
117 | Entry = (EFI_SYSTEM_RESOURCE_ENTRY *)(((UINT8 *)Table) + sizeof (EFI_SYSTEM_RESOURCE_TABLE));\r | |
118 | \r | |
119 | //\r | |
120 | // Print ESRT table information\r | |
121 | //\r | |
122 | DEBUG ((DEBUG_INFO, "ESRT Table Information:\n"));\r | |
123 | if (Table == NULL) {\r | |
124 | DEBUG ((DEBUG_INFO, "ERROR: Invalid table pointer\n"));\r | |
125 | return;\r | |
126 | }\r | |
127 | \r | |
128 | DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r | |
129 | DEBUG ((DEBUG_INFO, "| Firmware Resource Count : 0x%08x |\n", Table->FwResourceCount));\r | |
130 | DEBUG ((DEBUG_INFO, "| Firmware Resource Count Max : 0x%08x |\n", Table->FwResourceCountMax));\r | |
131 | DEBUG ((DEBUG_INFO, "| Firmware Resource Entry Version : 0x%016x |\n", Table->FwResourceVersion));\r | |
132 | DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r | |
133 | \r | |
134 | //\r | |
135 | // Print table entry information\r | |
136 | //\r | |
137 | DEBUG ((DEBUG_INFO, "ESRT Table Entries:\n"));\r | |
138 | if (Table->FwResourceVersion != EFI_SYSTEM_RESOURCE_TABLE_FIRMWARE_RESOURCE_VERSION) {\r | |
139 | DEBUG ((DEBUG_INFO, "ERROR: Unsupported Resource Entry Version\n"));\r | |
140 | return;\r | |
141 | }\r | |
142 | \r | |
143 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
144 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
145 | DEBUG ((DEBUG_INFO, "| | | "));\r | |
146 | DEBUG ((DEBUG_INFO, "| Lowest | | Last | Last |\n"));\r | |
147 | DEBUG ((DEBUG_INFO, "| | Firmware | "));\r | |
148 | DEBUG ((DEBUG_INFO, "| Supported | Capsule | Attempted | Attempted |\n"));\r | |
149 | DEBUG ((DEBUG_INFO, "| CLASS GUID | Type | Version "));\r | |
150 | DEBUG ((DEBUG_INFO, "| Version | Flags | Version | Status |\n"));\r | |
151 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
152 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
153 | \r | |
154 | for (Index = 0; Index < Table->FwResourceCount; Index++) {\r | |
155 | PrintOutEsrtEntry (&(Entry[Index]));\r | |
156 | }\r | |
157 | \r | |
158 | DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r | |
159 | DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r | |
160 | }\r | |
161 | \r |