]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c
Add more check to make sure code run safely.
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Platform / Generic / RuntimeDxe / StatusCode / Lib / RtPlatformStatusCode / Nt32 / RtPlatformStatusCode.c
CommitLineData
b38907a6 1/*++\r
2\r
4ac4deb7 3Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
4b1e1121 4This program and the accompanying materials \r
b38907a6 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_STATUS\r
52EFIAPI\r
53RtPlatformReportStatusCode (\r
54 IN EFI_STATUS_CODE_TYPE CodeType,\r
55 IN EFI_STATUS_CODE_VALUE Value,\r
56 IN UINT32 Instance,\r
57 IN EFI_GUID * CallerId,\r
58 IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r
59 )\r
60/*++\r
61\r
62Routine Description:\r
63\r
64 Call all status code listeners in the MonoStatusCode.\r
65\r
66Arguments:\r
67\r
68 Same as ReportStatusCode service\r
69 \r
70Returns:\r
71\r
72 EFI_SUCCESS Always returns success.\r
73\r
74--*/\r
75{\r
76 RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
77 if (EfiAtRuntime ()) {\r
78 //\r
79 // For now all we do is post code at runtime\r
80 //\r
81 return EFI_SUCCESS;\r
82 }\r
83\r
84 BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
85\r
86 //\r
87 // Call back into PEI to get status codes. This is because SecMain contains\r
88 // status code that reports to Win32.\r
89 //\r
90 if (mPeiReportStatusCode != NULL) {\r
91 return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
92 }\r
93\r
94 return EFI_SUCCESS;\r
95}\r
96\r
97VOID\r
98EFIAPI\r
99RtPlatformInitializeStatusCode (\r
100 IN EFI_HANDLE ImageHandle,\r
101 IN EFI_SYSTEM_TABLE *SystemTable\r
102 )\r
103/*++\r
104\r
105Routine Description:\r
106\r
107 Initialize the status code listeners.\r
108\r
109Arguments:\r
110\r
111 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
112\r
113Returns:\r
114\r
115 None\r
116\r
117--*/\r
118{\r
119 EFI_STATUS Status;\r
120 VOID *HobList;\r
121 VOID *Pointer;\r
122\r
123 RtMemoryInitializeStatusCode (ImageHandle, SystemTable);\r
124 BsDataHubInitializeStatusCode (ImageHandle, SystemTable);\r
125\r
126 //\r
127 // Play any prior status codes to the data hub.\r
128 //\r
129 PlaybackStatusCodes (BsDataHubReportStatusCode);\r
130\r
131 //\r
132 // If PEI has a ReportStatusCode callback find it and use it before StdErr\r
133 // is connected.\r
134 //\r
135 mPeiReportStatusCode = NULL;\r
4ac4deb7 136 Pointer = NULL;\r
b38907a6 137 Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
138 if (!EFI_ERROR (Status)) {\r
139 Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);\r
4ac4deb7 140 if (!EFI_ERROR (Status) && (Pointer != NULL)) {\r
b38907a6 141 mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);\r
142 }\r
143 }\r
144}\r