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