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 STATIC EFI_STATUS_CODE_PROTOCOL
*gStatusCode
= NULL
;
29 EfiLibReportStatusCode (
30 IN EFI_STATUS_CODE_TYPE Type
,
31 IN EFI_STATUS_CODE_VALUE Value
,
33 IN EFI_GUID
*CallerId OPTIONAL
,
34 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
40 Report device path through status code.
46 Instance - Instance number
47 CallerId - Caller name
48 DevicePath - Device path that to be reported
54 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
60 Status
= EFI_UNSUPPORTED
;
62 if (gRT
->Hdr
.Revision
>= 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
);
75 return EFI_UNSUPPORTED
;
78 // Check whether EFI_RUNTIME_SERVICES has Tiano Extension
80 Status
= EFI_UNSUPPORTED
;
81 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
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
);
93 ReportStatusCodeWithDevicePath (
94 IN EFI_STATUS_CODE_TYPE Type
,
95 IN EFI_STATUS_CODE_VALUE Value
,
97 IN EFI_GUID
* CallerId OPTIONAL
,
98 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
104 Report device path through status code.
110 Instance - Instance number
111 CallerId - Caller name
112 DevicePath - Device path that to be reported
118 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
123 UINT16 DevicePathSize
;
124 EFI_STATUS_CODE_DATA
*ExtendedData
;
125 EFI_DEVICE_PATH_PROTOCOL
*ExtendedDevicePath
;
128 DevicePathSize
= (UINT16
) EfiDevicePathSize (DevicePath
);
129 Size
= (UINT16
) (DevicePathSize
+ sizeof (EFI_STATUS_CODE_DATA
));
130 ExtendedData
= (EFI_STATUS_CODE_DATA
*) EfiLibAllocatePool (Size
);
131 if (ExtendedData
== NULL
) {
132 return EFI_OUT_OF_RESOURCES
;
135 ExtendedDevicePath
= EfiConstructStatusCodeData (Size
, &gEfiStatusCodeSpecificDataGuid
, ExtendedData
);
136 EfiCopyMem (ExtendedDevicePath
, DevicePath
, DevicePathSize
);
138 Status
= EfiLibReportStatusCode (Type
, Value
, Instance
, CallerId
, (EFI_STATUS_CODE_DATA
*) ExtendedData
);
140 gBS
->FreePool (ExtendedData
);