]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/RtPlatformStatusCode/RtPlatformStatusCode.c
Porting Duet module from EDKI to EDKII
[mirror_edk2.git] / DuetPkg / RtPlatformStatusCode / RtPlatformStatusCode.c
CommitLineData
c69dd9df 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
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 RtPlatformStatusCode.c \r
15 \r
16Abstract:\r
17\r
18 Contains NT32 specific implementations required to use status codes.\r
19\r
20--*/\r
21\r
22//\r
23// Statements that include other files.\r
24//\r
25#include "Tiano.h"\r
26#include "EfiCommonLib.h"\r
27#include "EfiRuntimeLib.h"\r
28#include "EfiStatusCode.h"\r
29#include "EfiHobLib.h"\r
30#include "RtMemoryStatusCodeLib.h"\r
31#include "BsDataHubStatusCodeLib.h"\r
32\r
33//\r
34// Consumed protocols\r
35//\r
36#include EFI_ARCH_PROTOCOL_CONSUMER (StatusCode)\r
37\r
38//\r
39// GUID definitions\r
40//\r
41#include EFI_GUID_DEFINITION (Hob)\r
42\r
43//\r
44// Globals only work at BootService Time. NOT at Runtime!\r
45//\r
46EFI_REPORT_STATUS_CODE mPeiReportStatusCode;\r
47\r
48//\r
49// Function implementations\r
50//\r
51EFI_RUNTIMESERVICE\r
52EFI_STATUS\r
53EFIAPI\r
54RtPlatformReportStatusCode (\r
55 IN EFI_STATUS_CODE_TYPE CodeType,\r
56 IN EFI_STATUS_CODE_VALUE Value,\r
57 IN UINT32 Instance,\r
58 IN EFI_GUID * CallerId,\r
59 IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r
60 )\r
61/*++\r
62\r
63Routine Description:\r
64\r
65 Call all status code listeners in the MonoStatusCode.\r
66\r
67Arguments:\r
68\r
69 Same as ReportStatusCode service\r
70 \r
71Returns:\r
72\r
73 EFI_SUCCESS Always returns success.\r
74\r
75--*/\r
76{\r
77 RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
78 if (EfiAtRuntime ()) {\r
79 //\r
80 // For now all we do is post code at runtime\r
81 //\r
82 return EFI_SUCCESS;\r
83 }\r
84\r
85 BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
86\r
87 //\r
88 // Call back into PEI to get status codes. This is because SecMain contains\r
89 // status code that reports to Win32.\r
90 //\r
91 if (mPeiReportStatusCode != NULL) {\r
92 return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
93 }\r
94\r
95 return EFI_SUCCESS;\r
96}\r
97\r
98EFI_BOOTSERVICE\r
99VOID\r
100EFIAPI\r
101RtPlatformInitializeStatusCode (\r
102 IN EFI_HANDLE ImageHandle,\r
103 IN EFI_SYSTEM_TABLE *SystemTable\r
104 )\r
105/*++\r
106\r
107Routine Description:\r
108\r
109 Initialize the status code listeners.\r
110\r
111Arguments:\r
112\r
113 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
114\r
115Returns:\r
116\r
117 None\r
118\r
119--*/\r
120{\r
121 EFI_STATUS Status;\r
122 VOID *HobList;\r
123 VOID *Pointer;\r
124\r
125 RtMemoryInitializeStatusCode (ImageHandle, SystemTable);\r
126 BsDataHubInitializeStatusCode (ImageHandle, SystemTable);\r
127\r
128 //\r
129 // Play any prior status codes to the data hub.\r
130 //\r
131 PlaybackStatusCodes (BsDataHubReportStatusCode);\r
132\r
133 //\r
134 // If PEI has a ReportStatusCode callback find it and use it before StdErr\r
135 // is connected.\r
136 //\r
137 mPeiReportStatusCode = NULL;\r
138\r
139 Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
140 if (!EFI_ERROR (Status)) {\r
141 Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);\r
142 if (!EFI_ERROR (Status)) {\r
143 mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);\r
144 }\r
145 }\r
146}\r