]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c
47f7f9651151287585e58bf969d5217b1a977ef9
[mirror_edk2.git] / EdkModulePkg / Library / EdkRuntimeStatusCodeLib / 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 // Globals only work at BootService Time. NOT at Runtime!
24 //
25 //
26
27 typedef
28 EFI_STATUS
29 (EFIAPI *REPORT_STATUS_CODE_FUNCTION) (
30 IN EFI_STATUS_CODE_TYPE Type,
31 IN EFI_STATUS_CODE_VALUE Value,
32 IN UINT32 Instance,
33 IN EFI_GUID *CallerId OPTIONAL,
34 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
35 );
36
37 REPORT_STATUS_CODE_FUNCTION mPeiReportStatusCode;
38
39 //
40 // Function implementations
41 //
42 EFI_STATUS
43 RtPlatformReportStatusCode (
44 IN EFI_STATUS_CODE_TYPE CodeType,
45 IN EFI_STATUS_CODE_VALUE Value,
46 IN UINT32 Instance,
47 IN EFI_GUID * CallerId,
48 IN EFI_STATUS_CODE_DATA * Data OPTIONAL
49 )
50 /*++
51
52 Routine Description:
53
54 Call all status code listeners in the MonoStatusCode.
55
56 Arguments:
57
58 Same as ReportStatusCode service
59
60 Returns:
61
62 EFI_SUCCESS Always returns success.
63
64 --*/
65 {
66 RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);
67 if (EfiAtRuntime ()) {
68 //
69 // For now all we do is post code at runtime
70 //
71 return EFI_SUCCESS;
72 }
73
74 BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data);
75
76 //
77 // Call back into PEI to get status codes. This is because SecMain contains
78 // status code that reports to Win32.
79 //
80 if (mPeiReportStatusCode != NULL) {
81 return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data);
82 }
83
84 return EFI_SUCCESS;
85 }
86
87 VOID
88 RtPlatformStatusCodeInitialize (
89 VOID
90 )
91 /*++
92
93 Routine Description:
94
95 Initialize the status code listeners.
96
97 Arguments:
98
99 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
100
101 Returns:
102
103 None
104
105 --*/
106 {
107 EFI_HOB_GUID_TYPE *GuidHob;
108 void *Pointer;
109
110 RtMemoryStatusCodeInitialize ();
111 BsDataHubStatusCodeInitialize ();
112
113 //
114 // Play any prior status codes to the data hub.
115 //
116 PlaybackStatusCodes (BsDataHubReportStatusCode);
117
118 //
119 // If PEI has a ReportStatusCode callback find it and use it before StdErr
120 // is connected.
121 //
122 mPeiReportStatusCode = NULL;
123
124 GuidHob = GetFirstGuidHob (&gEfiStatusCodeRuntimeProtocolGuid);
125 if (NULL == GuidHob) {
126 return;
127 }
128 Pointer = GET_GUID_HOB_DATA (GuidHob);
129 mPeiReportStatusCode = (REPORT_STATUS_CODE_FUNCTION) (*(UINTN *) Pointer);
130 }