3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include "EfiDriverLib.h"
22 #include EFI_PROTOCOL_DEFINITION (DevicePath)
23 #include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
24 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
26 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
27 STATIC EFI_STATUS_CODE_PROTOCOL
*gStatusCode
= NULL
;
31 EfiLibReportStatusCode (
32 IN EFI_STATUS_CODE_TYPE Type
,
33 IN EFI_STATUS_CODE_VALUE Value
,
35 IN EFI_GUID
*CallerId OPTIONAL
,
36 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
42 Report device path through status code.
48 Instance - Instance number
49 CallerId - Caller name
50 DevicePath - Device path that to be reported
56 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
62 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
63 if (gStatusCode
== NULL
) {
65 return EFI_UNSUPPORTED
;
67 Status
= gBS
->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid
, NULL
, (VOID
**)&gStatusCode
);
68 if (EFI_ERROR (Status
) || gStatusCode
== NULL
) {
69 return EFI_UNSUPPORTED
;
72 Status
= gStatusCode
->ReportStatusCode (Type
, Value
, Instance
, CallerId
, Data
);
76 return EFI_UNSUPPORTED
;
79 // Check whether EFI_RUNTIME_SERVICES has Tiano Extension
81 Status
= EFI_UNSUPPORTED
;
82 if (gRT
->Hdr
.Revision
== EFI_SPECIFICATION_VERSION
&&
83 gRT
->Hdr
.HeaderSize
== sizeof (EFI_RUNTIME_SERVICES
) &&
84 gRT
->ReportStatusCode
!= NULL
) {
85 Status
= gRT
->ReportStatusCode (Type
, Value
, Instance
, CallerId
, Data
);
92 ReportStatusCodeWithDevicePath (
93 IN EFI_STATUS_CODE_TYPE Type
,
94 IN EFI_STATUS_CODE_VALUE Value
,
96 IN EFI_GUID
* CallerId OPTIONAL
,
97 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
103 Report device path through status code.
109 Instance - Instance number
110 CallerId - Caller name
111 DevicePath - Device path that to be reported
117 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
122 UINT16 DevicePathSize
;
123 EFI_STATUS_CODE_DATA
*ExtendedData
;
124 EFI_DEVICE_PATH_PROTOCOL
*ExtendedDevicePath
;
127 DevicePathSize
= (UINT16
) EfiDevicePathSize (DevicePath
);
128 Size
= (UINT16
) (DevicePathSize
+ sizeof (EFI_STATUS_CODE_DATA
));
129 ExtendedData
= (EFI_STATUS_CODE_DATA
*) EfiLibAllocatePool (Size
);
130 if (ExtendedData
== NULL
) {
131 return EFI_OUT_OF_RESOURCES
;
134 ExtendedDevicePath
= EfiConstructStatusCodeData (Size
, &gEfiStatusCodeSpecificDataGuid
, ExtendedData
);
135 EfiCopyMem (ExtendedDevicePath
, DevicePath
, DevicePathSize
);
137 Status
= EfiLibReportStatusCode (Type
, Value
, Instance
, CallerId
, (EFI_STATUS_CODE_DATA
*) ExtendedData
);
139 gBS
->FreePool (ExtendedData
);