Updated MSA by putting Specification element at the end of the header section
[mirror_edk2.git] / EdkNt32Pkg / Pei / MonoStatusCode / MonoStatusCode.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 MonoStatusCode.c
15
16 Abstract:
17
18 PEIM to provide the status code functionality, to aid in system debug.
19 It includes output to 0x80 port and/or to serial port.
20 This PEIM is monolithic. Different platform should provide different library.
21
22 --*/
23
24 #include "MonoStatusCode.h"
25
26 //
27 // Module globals
28 //
29 //
30 EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi = { PlatformReportStatusCode };
31
32 EFI_PEI_PPI_DESCRIPTOR mPpiListStatusCode = {
33 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
34 &gEfiPeiStatusCodePpiGuid,
35 &mStatusCodePpi
36 };
37
38 //
39 // Function implemenations
40 //
41 EFI_STATUS
42 EFIAPI
43 TranslateDxeStatusCodeToPeiStatusCode (
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 Translate from a DXE status code interface into a PEI-callable
55 interface, making the PEI the least common denominator..
56
57 Arguments:
58
59 Same as DXE ReportStatusCode RT service
60
61 Returns:
62
63 None
64
65 --*/
66 {
67 return PlatformReportStatusCode (NULL, CodeType, Value, Instance, CallerId, Data);
68 }
69
70 EFI_STATUS
71 EFIAPI
72 InitializeDxeReportStatusCode (
73 IN EFI_PEI_SERVICES **PeiServices
74 )
75 /*++
76
77 Routine Description:
78
79 Build a hob describing the status code listener that has been installed.
80 This will be used by DXE code until a runtime status code listener is
81 installed.
82
83 Arguments:
84
85 PeiServices - General purpose services available to every PEIM.
86
87 Returns:
88
89 Status - EFI_SUCCESS if the interface could be successfully
90 installed
91
92 --*/
93 {
94 VOID *Instance;
95 VOID *HobData;
96
97 Instance = (VOID *) (UINTN) TranslateDxeStatusCodeToPeiStatusCode;
98
99 HobData = BuildGuidDataHob (
100 &gEfiStatusCodeRuntimeProtocolGuid,
101 &Instance,
102 sizeof (VOID *)
103 );
104
105 ASSERT (HobData != NULL);
106 return EFI_SUCCESS;
107 }
108
109 VOID
110 EFIAPI
111 InitializeMonoStatusCode (
112 IN EFI_FFS_FILE_HEADER *FfsHeader,
113 IN EFI_PEI_SERVICES **PeiServices
114 )
115 /*++
116
117 Routine Description:
118
119 Initialize the platform status codes and publish the platform status code
120 PPI.
121
122 Arguments:
123
124 FfsHeader - FV this PEIM was loaded from.
125 PeiServices - General purpose services available to every PEIM.
126
127 Returns:
128
129 Status - EFI_SUCCESS
130
131 --*/
132 {
133 EFI_STATUS Status;
134
135 //
136 // Initialize status code listeners.
137 //
138 PlatformInitializeStatusCode (FfsHeader, PeiServices);
139
140 //
141 // Publish the status code capability to other modules
142 //
143 Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStatusCode);
144
145 ASSERT_EFI_ERROR (Status);
146
147 DEBUG ((EFI_D_ERROR, "\nMono Status Code PEIM Loaded\n"));
148
149 return ;
150 }