2 Report Status Code Library for DXE Phase.
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "ReportStatusCodeLibInternal.h"
18 Locatet he report status code service.
20 @return EFI_REPORT_STATUS_CODE function point to
23 EFI_REPORT_STATUS_CODE
24 InternalGetReportStatusCode (
28 EFI_STATUS_CODE_PROTOCOL
*StatusCodeProtocol
;
31 if (gRT
->Hdr
.Revision
< 0x20000) {
32 return ((FRAMEWORK_EFI_RUNTIME_SERVICES
*)gRT
)->ReportStatusCode
;
33 } else if (gBS
!= NULL
) {
34 Status
= gBS
->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid
, NULL
, (VOID
**)&StatusCodeProtocol
);
35 if (!EFI_ERROR (Status
) && StatusCodeProtocol
!= NULL
) {
36 return StatusCodeProtocol
->ReportStatusCode
;
46 InternalReportStatusCodeEx (
47 IN EFI_STATUS_CODE_TYPE Type
,
48 IN EFI_STATUS_CODE_VALUE Value
,
50 IN CONST EFI_GUID
*CallerId OPTIONAL
,
51 IN CONST EFI_GUID
*ExtendedDataGuid OPTIONAL
,
52 IN CONST VOID
*ExtendedData OPTIONAL
,
53 IN UINTN ExtendedDataSize
57 EFI_STATUS_CODE_DATA
*StatusCodeData
;
59 ASSERT (!((ExtendedData
== NULL
) && (ExtendedDataSize
!= 0)));
60 ASSERT (!((ExtendedData
!= NULL
) && (ExtendedDataSize
== 0)));
63 return EFI_UNSUPPORTED
;
67 // Allocate space for the Status Code Header and its buffer
69 StatusCodeData
= NULL
;
70 gBS
->AllocatePool (EfiBootServicesData
, sizeof (EFI_STATUS_CODE_DATA
) + ExtendedDataSize
, (VOID
**)&StatusCodeData
);
71 if (StatusCodeData
== NULL
) {
72 return EFI_OUT_OF_RESOURCES
;
76 // Fill in the extended data header
78 StatusCodeData
->HeaderSize
= sizeof (EFI_STATUS_CODE_DATA
);
79 StatusCodeData
->Size
= (UINT16
)ExtendedDataSize
;
80 if (ExtendedDataGuid
== NULL
) {
81 ExtendedDataGuid
= &gEfiStatusCodeSpecificDataGuid
;
83 CopyGuid (&StatusCodeData
->Type
, ExtendedDataGuid
);
86 // Fill in the extended data buffer
88 CopyMem (StatusCodeData
+ 1, ExtendedData
, ExtendedDataSize
);
91 // Report the status code
93 if (CallerId
== NULL
) {
94 CallerId
= &gEfiCallerIdGuid
;
96 Status
= InternalReportStatusCode (Type
, Value
, Instance
, CallerId
, StatusCodeData
);
99 // Free the allocated buffer
101 gBS
->FreePool (StatusCodeData
);