]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / ReportStatusCode.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ReportStatusCode.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
20#include "Tiano.h"\r
21#include "EfiDriverLib.h"\r
22#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
23#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
24#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
25\r
ce7a12fb 26#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
3eb9473e 27STATIC EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;\r
ce7a12fb 28#endif\r
3eb9473e 29\r
30EFI_STATUS\r
31EfiLibReportStatusCode (\r
32 IN EFI_STATUS_CODE_TYPE Type,\r
33 IN EFI_STATUS_CODE_VALUE Value,\r
34 IN UINT32 Instance,\r
35 IN EFI_GUID *CallerId OPTIONAL,\r
36 IN EFI_STATUS_CODE_DATA *Data OPTIONAL \r
37 )\r
38/*++\r
39\r
40Routine Description:\r
41\r
42 Report device path through status code.\r
43\r
44Arguments:\r
45\r
46 Type - Code type\r
47 Value - Code value\r
48 Instance - Instance number\r
49 CallerId - Caller name\r
50 DevicePath - Device path that to be reported\r
51\r
52Returns:\r
53\r
54 Status code.\r
55\r
56 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
57\r
58--*/\r
59{\r
60 EFI_STATUS Status;\r
bdabfae7 61\r
ce7a12fb 62#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
63 if (gStatusCode == NULL) {\r
64 if (gBS == NULL) {\r
65 return EFI_UNSUPPORTED;\r
66 }\r
67 Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
68 if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
69 return EFI_UNSUPPORTED;\r
70 }\r
71 }\r
72 Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
bdabfae7 73 return Status;\r
ce7a12fb 74#else\r
75 if (gRT == NULL) {\r
76 return EFI_UNSUPPORTED;\r
77 }\r
78 //\r
79 // Check whether EFI_RUNTIME_SERVICES has Tiano Extension\r
80 //\r
81 Status = EFI_UNSUPPORTED;\r
82 if (gRT->Hdr.Revision == EFI_SPECIFICATION_VERSION &&\r
83 gRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) &&\r
84 gRT->ReportStatusCode != NULL) {\r
85 Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
86 }\r
87 return Status;\r
88#endif\r
3eb9473e 89}\r
90\r
91EFI_STATUS\r
92ReportStatusCodeWithDevicePath (\r
93 IN EFI_STATUS_CODE_TYPE Type,\r
94 IN EFI_STATUS_CODE_VALUE Value,\r
95 IN UINT32 Instance,\r
96 IN EFI_GUID * CallerId OPTIONAL,\r
97 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath\r
98 )\r
99/*++\r
100\r
101Routine Description:\r
102\r
103 Report device path through status code.\r
104\r
105Arguments:\r
106\r
107 Type - Code type\r
108 Value - Code value\r
109 Instance - Instance number\r
110 CallerId - Caller name\r
111 DevicePath - Device path that to be reported\r
112\r
113Returns:\r
114\r
115 Status code.\r
116\r
117 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
118\r
119--*/\r
120{\r
121 UINT16 Size;\r
122 UINT16 DevicePathSize;\r
123 EFI_STATUS_CODE_DATA *ExtendedData;\r
124 EFI_DEVICE_PATH_PROTOCOL *ExtendedDevicePath;\r
125 EFI_STATUS Status;\r
126\r
127 DevicePathSize = (UINT16) EfiDevicePathSize (DevicePath);\r
8e986445 128 Size = (UINT16) (DevicePathSize + sizeof (EFI_STATUS_CODE_DATA));\r
3eb9473e 129 ExtendedData = (EFI_STATUS_CODE_DATA *) EfiLibAllocatePool (Size);\r
130 if (ExtendedData == NULL) {\r
131 return EFI_OUT_OF_RESOURCES;\r
132 }\r
133\r
134 ExtendedDevicePath = EfiConstructStatusCodeData (Size, &gEfiStatusCodeSpecificDataGuid, ExtendedData);\r
135 EfiCopyMem (ExtendedDevicePath, DevicePath, DevicePathSize);\r
136\r
137 Status = EfiLibReportStatusCode (Type, Value, Instance, CallerId, (EFI_STATUS_CODE_DATA *) ExtendedData);\r
138\r
139 gBS->FreePool (ExtendedData);\r
140 return Status;\r
141}\r