]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeSupport.c
Fixed a typo in variable name
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / DxeReportStatusCodeLibFramework / DxeSupport.c
1 /** @file
2 Report Status Code Library for DXE Phase.
3
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
9
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.
12
13 **/
14
15 #include "ReportStatusCodeLibInternal.h"
16
17 /**
18 Locatet he report status code service.
19
20 @return EFI_REPORT_STATUS_CODE function point to
21 ReportStatusCode.
22 **/
23 EFI_REPORT_STATUS_CODE
24 InternalGetReportStatusCode (
25 VOID
26 )
27 {
28 EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;
29 EFI_STATUS Status;
30
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;
37 }
38 }
39
40 return NULL;
41 }
42
43
44 EFI_STATUS
45 EFIAPI
46 InternalReportStatusCodeEx (
47 IN EFI_STATUS_CODE_TYPE Type,
48 IN EFI_STATUS_CODE_VALUE Value,
49 IN UINT32 Instance,
50 IN CONST EFI_GUID *CallerId OPTIONAL,
51 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
52 IN CONST VOID *ExtendedData OPTIONAL,
53 IN UINTN ExtendedDataSize
54 )
55 {
56 EFI_STATUS Status;
57 EFI_STATUS_CODE_DATA *StatusCodeData;
58
59 ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
60 ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
61
62 if (gBS == NULL) {
63 return EFI_UNSUPPORTED;
64 }
65
66 //
67 // Allocate space for the Status Code Header and its buffer
68 //
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;
73 }
74
75 //
76 // Fill in the extended data header
77 //
78 StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
79 StatusCodeData->Size = (UINT16)ExtendedDataSize;
80 if (ExtendedDataGuid == NULL) {
81 ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
82 }
83 CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
84
85 //
86 // Fill in the extended data buffer
87 //
88 CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);
89
90 //
91 // Report the status code
92 //
93 if (CallerId == NULL) {
94 CallerId = &gEfiCallerIdGuid;
95 }
96 Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
97
98 //
99 // Free the allocated buffer
100 //
101 gBS->FreePool (StatusCodeData);
102
103 return Status;
104 }
105