]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCode.c
Initial import.
[mirror_edk2.git] / EdkModulePkg / Universal / StatusCode / RuntimeDxe / StatusCode.c
CommitLineData
878ddf1f 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 StatusCode.c\r
15\r
16Abstract:\r
17\r
18 Status Code Architectural Protocol implementation as defined in Tiano\r
19 Architecture Specification.\r
20\r
21 This driver also depends on the DataHub, and will log all status code info \r
22 to the DataHub. Fatal Errors are Printed to Standard Error (StdErr) and not \r
23 logged to the data hub (If you crash what good is the data in the data hub).\r
24\r
25 This driver has limited functionality at runtime and will not log to Data Hub\r
26 at runtime.\r
27\r
28 Notes:\r
29 This driver assumes the following ReportStatusCode strategy:\r
30 PEI -> uses PeiReportStatusCode\r
31 DXE IPL -> uses PeiReportStatusCode\r
32 early DXE -> uses PeiReportStatusCode via HOB\r
33 DXE -> This driver\r
34 RT -> This driver\r
35\r
36--*/\r
37\r
38#include "StatusCode.h"\r
39\r
40EFI_LOCK mStatusCodeLock;\r
41BOOLEAN mStatusCodeFlag = FALSE;\r
42\r
43//\r
44// Function implemenations\r
45//\r
46\r
47\r
48EFI_STATUS\r
49EFIAPI\r
50StatusCodeReportStatusCode (\r
51 IN EFI_STATUS_CODE_TYPE CodeType,\r
52 IN EFI_STATUS_CODE_VALUE Value,\r
53 IN UINT32 Instance,\r
54 IN EFI_GUID *CallerId,\r
55 IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
56 )\r
57/*++\r
58\r
59Routine Description:\r
60\r
61 Calls into the platform library which dispatches the platform specific\r
62 listeners. For NT environments we still call back into PEI because the \r
63 ReportStatusCode functionality requires Win32 services and is built into\r
64 the SecMain.exe utility.\r
65\r
66Arguments:\r
67\r
68 (See Tiano Runtime Specification)\r
69\r
70Returns:\r
71\r
72 None\r
73\r
74--*/\r
75{\r
76 EFI_STATUS Status;\r
77\r
78 //\r
79 // Acquire the lock required to update mStatusCodeFlag\r
80 //\r
81 Status = EfiAcquireLockOrFail (&mStatusCodeLock);\r
82 if (EFI_ERROR (Status)) {\r
83 //\r
84 // Check for reentrancy of the lock\r
85 //\r
86 return EFI_DEVICE_ERROR;\r
87 }\r
88 //\r
89 // Check to see if we are already in the middle of a ReportStatusCode()\r
90 //\r
91 if (mStatusCodeFlag) {\r
92 EfiReleaseLock (&mStatusCodeLock);\r
93 return EFI_DEVICE_ERROR;\r
94 }\r
95 //\r
96 // Set the flag to show we are in the middle of a ReportStatusCode()\r
97 //\r
98 mStatusCodeFlag = TRUE;\r
99\r
100 //\r
101 // Release the lock for updating mStatusCodeFlag\r
102 //\r
103 EfiReleaseLock (&mStatusCodeLock);\r
104\r
105 //\r
106 // Go do the work required to report a status code\r
107 //\r
108 RtPlatformReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
109\r
110 //\r
111 // Acquire the lock required to update mStatusCodeFlag\r
112 //\r
113 Status = EfiAcquireLockOrFail (&mStatusCodeLock);\r
114 if (EFI_ERROR (Status)) {\r
115 //\r
116 // Check for reentrancy of the lock\r
117 //\r
118 return EFI_DEVICE_ERROR;\r
119 }\r
120 //\r
121 // Clear the flag to show we are no longer in the middle of a ReportStatusCode()\r
122 //\r
123 mStatusCodeFlag = FALSE;\r
124\r
125 //\r
126 // Release the lock for updating mStatusCodeFlag\r
127 //\r
128 EfiReleaseLock (&mStatusCodeLock);\r
129\r
130 return EFI_SUCCESS;\r
131}\r
132//\r
133// Protocol instance, there can be only one.\r
134//\r
135EFI_STATUS\r
136InitializeStatusCode (\r
137 IN EFI_HANDLE ImageHandle,\r
138 IN EFI_SYSTEM_TABLE *SystemTable\r
139 )\r
140/*++\r
141\r
142Routine Description:\r
143\r
144 Install Driver to produce Report Status Code Arch Protocol\r
145\r
146Arguments:\r
147\r
148 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
149\r
150Returns:\r
151\r
152 EFI_SUCCESS - Logging Hub protocol installed\r
153 Other - No protocol installed, unload driver.\r
154\r
155--*/\r
156{\r
157\r
158 EfiInitializeLock (&mStatusCodeLock, EFI_TPL_HIGH_LEVEL);\r
159\r
160 //\r
161 // Call the platform hook to initialize the different listeners.\r
162 //\r
163 RtPlatformStatusCodeInitialize ();\r
164\r
165 //\r
166 // Register a protocol that EfiUtilityLib can use to implement DEBUG () and ASSERT ()\r
167 // Macros.\r
168 //\r
169 InstallStatusCodeDebugAssert ();\r
170\r
171 return EFI_SUCCESS;\r
172}\r