]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / EsrtFmpDxe / EsrtFmpDebugPrint.c
CommitLineData
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
29EFI_STATUS\r
30EFIAPI\r
31PrintOutEsrtEntry (\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
1436aea4
MK
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
4184aabd
MK
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
1436aea4
MK
74 DEBUG ((\r
75 DEBUG_INFO,\r
4184aabd
MK
76 " 0x%8X | 0x%8X | 0x%8X | 0x%8X | 0x%8X |\n",\r
77 Entry->FwVersion,\r
78 Entry->LowestSupportedFwVersion,\r
79 Entry->CapsuleFlags,\r
80 Entry->LastAttemptVersion,\r
81 Entry->LastAttemptStatus\r
82 ));\r
83\r
84 return EFI_SUCCESS;\r
85}\r
86\r
87/**\r
ae38c976 88 Function to print the ESRT table to the debug console.\r
4184aabd
MK
89\r
90 @param[in] Table - Pointer to the ESRT table\r
91**/\r
92VOID\r
93EFIAPI\r
94PrintTable (\r
95 IN EFI_SYSTEM_RESOURCE_TABLE *Table\r
96 )\r
97{\r
98 EFI_SYSTEM_RESOURCE_ENTRY *Entry;\r
99 UINTN Index;\r
100\r
101 Entry = (EFI_SYSTEM_RESOURCE_ENTRY *)(((UINT8 *)Table) + sizeof (EFI_SYSTEM_RESOURCE_TABLE));\r
102\r
103 //\r
104 // Print ESRT table information\r
105 //\r
106 DEBUG ((DEBUG_INFO, "ESRT Table Information:\n"));\r
107 if (Table == NULL) {\r
108 DEBUG ((DEBUG_INFO, "ERROR: Invalid table pointer\n"));\r
109 return;\r
110 }\r
111\r
112 DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r
1436aea4
MK
113 DEBUG ((DEBUG_INFO, "| Firmware Resource Count : 0x%08x |\n", Table->FwResourceCount));\r
114 DEBUG ((DEBUG_INFO, "| Firmware Resource Count Max : 0x%08x |\n", Table->FwResourceCountMax));\r
115 DEBUG ((DEBUG_INFO, "| Firmware Resource Entry Version : 0x%016x |\n", Table->FwResourceVersion));\r
4184aabd
MK
116 DEBUG ((DEBUG_INFO, "+--------------------------------------------------------+\n"));\r
117\r
118 //\r
119 // Print table entry information\r
120 //\r
121 DEBUG ((DEBUG_INFO, "ESRT Table Entries:\n"));\r
122 if (Table->FwResourceVersion != EFI_SYSTEM_RESOURCE_TABLE_FIRMWARE_RESOURCE_VERSION) {\r
123 DEBUG ((DEBUG_INFO, "ERROR: Unsupported Resource Entry Version\n"));\r
124 return;\r
125 }\r
126\r
127 DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r
128 DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r
129 DEBUG ((DEBUG_INFO, "| | | "));\r
130 DEBUG ((DEBUG_INFO, "| Lowest | | Last | Last |\n"));\r
131 DEBUG ((DEBUG_INFO, "| | Firmware | "));\r
132 DEBUG ((DEBUG_INFO, "| Supported | Capsule | Attempted | Attempted |\n"));\r
133 DEBUG ((DEBUG_INFO, "| CLASS GUID | Type | Version "));\r
134 DEBUG ((DEBUG_INFO, "| Version | Flags | Version | Status |\n"));\r
135 DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r
136 DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r
137\r
138 for (Index = 0; Index < Table->FwResourceCount; Index++) {\r
139 PrintOutEsrtEntry (&(Entry[Index]));\r
140 }\r
141\r
142 DEBUG ((DEBUG_INFO, "+--------------------------------------+--------------+------------"));\r
143 DEBUG ((DEBUG_INFO, "+------------+------------+------------+------------+\n"));\r
144}\r