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