]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeSupport.c
Add some function/header comments.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / DxeReportStatusCodeLibFramework / DxeSupport.c
CommitLineData
e5516b49 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
ed7752ec 18 Locate he report status code service.\r
e5516b49 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\r
31 if (gRT->Hdr.Revision < 0x20000) {\r
32 return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)gRT)->ReportStatusCode;\r
33 } else if (gBS != NULL) {\r
34 Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);\r
35 if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
36 return StatusCodeProtocol->ReportStatusCode;\r
37 }\r
38 }\r
39\r
40 return NULL;\r
41}\r
42\r
ed7752ec 43/**\r
44 Reports a status code with full parameters.\r
45\r
46 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize\r
47 is 0, then an extended data buffer is not reported. If ExtendedData is not\r
48 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
49 ExtendedData is assumed not have the standard status code header, so this function\r
50 is responsible for allocating a buffer large enough for the standard header and\r
51 the extended data passed into this function. The standard header is filled in\r
52 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a\r
53 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with\r
54 an instance specified by Instance and a caller ID specified by CallerId. If\r
55 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
56\r
57 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()\r
58 is called while processing another any other Report Status Code Library function,\r
59 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
60\r
61 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
62 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
e5516b49 63\r
ed7752ec 64 @param Type Status code type.\r
65 @param Value Status code value.\r
66 @param Instance Status code instance number.\r
67 @param CallerId Pointer to a GUID that identifies the caller of this\r
68 function. If this parameter is NULL, then a caller\r
69 ID of gEfiCallerIdGuid is used.\r
70 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.\r
71 If this parameter is NULL, then a the status code\r
72 standard header is filled in with\r
73 gEfiStatusCodeSpecificDataGuid.\r
74 @param ExtendedData Pointer to the extended data buffer. This is an\r
75 optional parameter that may be NULL.\r
76 @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r
77\r
78 @retval EFI_SUCCESS The status code was reported.\r
79 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate\r
80 the extended data section if it was specified.\r
81 @retval EFI_UNSUPPORTED Report status code is not supported\r
82\r
83**/\r
e5516b49 84EFI_STATUS\r
85EFIAPI\r
86InternalReportStatusCodeEx (\r
87 IN EFI_STATUS_CODE_TYPE Type,\r
88 IN EFI_STATUS_CODE_VALUE Value,\r
89 IN UINT32 Instance,\r
90 IN CONST EFI_GUID *CallerId OPTIONAL,\r
91 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r
92 IN CONST VOID *ExtendedData OPTIONAL,\r
93 IN UINTN ExtendedDataSize\r
94 )\r
95{\r
96 EFI_STATUS Status;\r
97 EFI_STATUS_CODE_DATA *StatusCodeData;\r
98\r
99 ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
100 ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
101\r
102 if (gBS == NULL) {\r
103 return EFI_UNSUPPORTED;\r
104 }\r
105\r
106 //\r
107 // Allocate space for the Status Code Header and its buffer\r
108 //\r
109 StatusCodeData = NULL;\r
110 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
111 if (StatusCodeData == NULL) {\r
112 return EFI_OUT_OF_RESOURCES;\r
113 }\r
114\r
115 //\r
116 // Fill in the extended data header\r
117 //\r
118 StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
119 StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
120 if (ExtendedDataGuid == NULL) {\r
121 ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
122 }\r
123 CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
124\r
125 //\r
126 // Fill in the extended data buffer\r
127 //\r
128 CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
129\r
130 //\r
131 // Report the status code\r
132 //\r
133 if (CallerId == NULL) {\r
134 CallerId = &gEfiCallerIdGuid;\r
135 }\r
136 Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
137\r
138 //\r
139 // Free the allocated buffer\r
140 //\r
141 gBS->FreePool (StatusCodeData);\r
142\r
143 return Status;\r
144}\r
145\r