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