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
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.
18 Status Code Architectural Protocol implementation as defined in Tiano
19 Architecture Specification.
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).
25 This driver has limited functionality at runtime and will not log to Data Hub
29 This driver assumes the following ReportStatusCode strategy:
30 PEI -> uses PeiReportStatusCode
31 DXE IPL -> uses PeiReportStatusCode
32 early DXE -> uses PeiReportStatusCode via HOB
38 #include "StatusCode.h"
40 EFI_LOCK mStatusCodeLock
;
41 BOOLEAN mStatusCodeFlag
= FALSE
;
44 // Function implemenations
50 StatusCodeReportStatusCode (
51 IN EFI_STATUS_CODE_TYPE CodeType
,
52 IN EFI_STATUS_CODE_VALUE Value
,
54 IN EFI_GUID
*CallerId
,
55 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
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.
68 (See Tiano Runtime Specification)
79 // Acquire the lock required to update mStatusCodeFlag
81 Status
= EfiAcquireLockOrFail (&mStatusCodeLock
);
82 if (EFI_ERROR (Status
)) {
84 // Check for reentrancy of the lock
86 return EFI_DEVICE_ERROR
;
89 // Check to see if we are already in the middle of a ReportStatusCode()
91 if (mStatusCodeFlag
) {
92 EfiReleaseLock (&mStatusCodeLock
);
93 return EFI_DEVICE_ERROR
;
96 // Set the flag to show we are in the middle of a ReportStatusCode()
98 mStatusCodeFlag
= TRUE
;
101 // Release the lock for updating mStatusCodeFlag
103 EfiReleaseLock (&mStatusCodeLock
);
106 // Go do the work required to report a status code
108 RtPlatformReportStatusCode (CodeType
, Value
, Instance
, CallerId
, Data
);
111 // Acquire the lock required to update mStatusCodeFlag
113 Status
= EfiAcquireLockOrFail (&mStatusCodeLock
);
114 if (EFI_ERROR (Status
)) {
116 // Check for reentrancy of the lock
118 return EFI_DEVICE_ERROR
;
121 // Clear the flag to show we are no longer in the middle of a ReportStatusCode()
123 mStatusCodeFlag
= FALSE
;
126 // Release the lock for updating mStatusCodeFlag
128 EfiReleaseLock (&mStatusCodeLock
);
133 // Protocol instance, there can be only one.
136 InitializeStatusCode (
137 IN EFI_HANDLE ImageHandle
,
138 IN EFI_SYSTEM_TABLE
*SystemTable
144 Install Driver to produce Report Status Code Arch Protocol
148 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
152 EFI_SUCCESS - Logging Hub protocol installed
153 Other - No protocol installed, unload driver.
158 EfiInitializeLock (&mStatusCodeLock
, EFI_TPL_HIGH_LEVEL
);
161 // Call the platform hook to initialize the different listeners.
163 RtPlatformStatusCodeInitialize ();
166 // Register a protocol that EfiUtilityLib can use to implement DEBUG () and ASSERT ()
169 InstallStatusCodeDebugAssert ();