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