]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/Library/DuetDxeReportStatusCodeLib/DxeSupport.c
Update Unix platform to use dynamic HII pcd to save console output mode.
[mirror_edk2.git] / DuetPkg / Library / DuetDxeReportStatusCodeLib / DxeSupport.c
CommitLineData
cf0206ee 1/** @file\r
2 Report Status Code Library for DXE Phase.\r
3\r
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "ReportStatusCodeLibInternal.h"\r
16\r
17/**\r
18 Locate he report status code service.\r
19\r
20 @return EFI_REPORT_STATUS_CODE function point to\r
21 ReportStatusCode.\r
22**/\r
23EFI_REPORT_STATUS_CODE\r
24InternalGetReportStatusCode (\r
25 VOID\r
26 )\r
27{\r
28 EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;\r
29 EFI_STATUS Status;\r
30 EFI_PEI_HOB_POINTERS GuidHob;\r
31 \r
32 if (gRT->Hdr.Revision < 0x20000) {\r
33 return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)gRT)->ReportStatusCode;\r
34 } else if (gBS != NULL) {\r
35 Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);\r
36 if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
37 return StatusCodeProtocol->ReportStatusCode;\r
38 } else {\r
39 GuidHob.Raw = GetFirstGuidHob(&gEfiStatusCodeRuntimeProtocolGuid);\r
40 if (GuidHob.Raw != NULL) {\r
41 return (EFI_REPORT_STATUS_CODE) (*(UINTN *) GET_GUID_HOB_DATA (GuidHob.Guid));\r
42 }\r
43 }\r
44 }\r
45\r
46 return NULL;\r
47}\r
48\r
49/**\r
50 Reports a status code with full parameters.\r
51\r
52 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize\r
53 is 0, then an extended data buffer is not reported. If ExtendedData is not\r
54 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
55 ExtendedData is assumed not have the standard status code header, so this function\r
56 is responsible for allocating a buffer large enough for the standard header and\r
57 the extended data passed into this function. The standard header is filled in\r
58 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a\r
59 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with\r
60 an instance specified by Instance and a caller ID specified by CallerId. If\r
61 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
62\r
63 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()\r
64 is called while processing another any other Report Status Code Library function,\r
65 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
66\r
67 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
68 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
69\r
70 @param Type Status code type.\r
71 @param Value Status code value.\r
72 @param Instance Status code instance number.\r
73 @param CallerId Pointer to a GUID that identifies the caller of this\r
74 function. If this parameter is NULL, then a caller\r
75 ID of gEfiCallerIdGuid is used.\r
76 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.\r
77 If this parameter is NULL, then a the status code\r
78 standard header is filled in with\r
79 gEfiStatusCodeSpecificDataGuid.\r
80 @param ExtendedData Pointer to the extended data buffer. This is an\r
81 optional parameter that may be NULL.\r
82 @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r
83\r
84 @retval EFI_SUCCESS The status code was reported.\r
85 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate\r
86 the extended data section if it was specified.\r
87 @retval EFI_UNSUPPORTED Report status code is not supported\r
88\r
89**/\r
90EFI_STATUS\r
91EFIAPI\r
92InternalReportStatusCodeEx (\r
93 IN EFI_STATUS_CODE_TYPE Type,\r
94 IN EFI_STATUS_CODE_VALUE Value,\r
95 IN UINT32 Instance,\r
96 IN CONST EFI_GUID *CallerId OPTIONAL,\r
97 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r
98 IN CONST VOID *ExtendedData OPTIONAL,\r
99 IN UINTN ExtendedDataSize\r
100 )\r
101{\r
102 EFI_STATUS Status;\r
103 EFI_STATUS_CODE_DATA *StatusCodeData;\r
104\r
105 ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
106 ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
107\r
108 if (gBS == NULL) {\r
109 return EFI_UNSUPPORTED;\r
110 }\r
111\r
112 //\r
113 // Allocate space for the Status Code Header and its buffer\r
114 //\r
115 StatusCodeData = NULL;\r
116 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
117 if (StatusCodeData == NULL) {\r
118 return EFI_OUT_OF_RESOURCES;\r
119 }\r
120\r
121 //\r
122 // Fill in the extended data header\r
123 //\r
124 StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
125 StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
126 if (ExtendedDataGuid == NULL) {\r
127 ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
128 }\r
129 CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
130\r
131 //\r
132 // Fill in the extended data buffer\r
133 //\r
134 CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
135\r
136 //\r
137 // Report the status code\r
138 //\r
139 if (CallerId == NULL) {\r
140 CallerId = &gEfiCallerIdGuid;\r
141 }\r
142 Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
143\r
144 //\r
145 // Free the allocated buffer\r
146 //\r
147 gBS->FreePool (StatusCodeData);\r
148\r
149 return Status;\r
150}\r
151\r