Add inf files for PeiSmbusLibSmbus2, PeiDxePostCodeLibReportStatusCode, PeiMemoryLib...
[mirror_edk2.git] / MdePkg / Library / PeiDxePostCodeLibReportStatusCode / PostCode.c
1 /** @file
2 Report Status Code Library Post Code functions for DXE Phase.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 //
16 // The package level header files this module uses
17 //
18 #include <PiPei.h>
19 //
20 // The Library classes this module consumes
21 //
22 #include <Library/PostCodeLib.h>
23 #include <Library/ReportStatusCodeLib.h>
24 #include <Library/PcdLib.h>
25 #include <Library/BaseLib.h>
26
27 /**
28 Converts POST code value to status code value.
29
30 This macro converts the post code to status code value. Bits 0..4 of PostCode
31 are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits
32 24..26 of status code value.
33
34 @param PostCode POST code value.
35
36 @return The converted status code value.
37
38 **/
39 #define POST_CODE_TO_STATUS_CODE_VALUE(PostCode) \
40 ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19)))
41
42 /**
43 Sends an 32-bit value to a POST card.
44
45 Sends the 32-bit value specified by Value to a POST card, and returns Value.
46 Some implementations of this library function may perform I/O operations
47 directly to a POST card device. Other implementations may send Value to
48 ReportStatusCode(), and the status code reporting mechanism will eventually
49 display the 32-bit value on the status reporting device.
50
51 PostCode() must actively prevent recursion. If PostCode() is called while
52 processing another any other Report Status Code Library function, then
53 PostCode() must return Value immediately.
54
55 @param Value The 32-bit value to write to the POST card.
56
57 @return Value
58
59 **/
60 UINT32
61 EFIAPI
62 PostCode (
63 IN UINT32 Value
64 )
65 {
66 REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value));
67 return Value;
68 }
69
70
71 /**
72 Sends an 32-bit value to a POST and associated ASCII string.
73
74 Sends the 32-bit value specified by Value to a POST card, and returns Value.
75 If Description is not NULL, then the ASCII string specified by Description is
76 also passed to the handler that displays the POST card value. Some
77 implementations of this library function may perform I/O operations directly
78 to a POST card device. Other implementations may send Value to ReportStatusCode(),
79 and the status code reporting mechanism will eventually display the 32-bit
80 value on the status reporting device.
81
82 PostCodeWithDescription()must actively prevent recursion. If
83 PostCodeWithDescription() is called while processing another any other Report
84 Status Code Library function, then PostCodeWithDescription() must return Value
85 immediately.
86
87 @param Value The 32-bit value to write to the POST card.
88 @param Description Pointer to an ASCII string that is a description of the
89 POST code value. This is an optional parameter that may
90 be NULL.
91
92 @return Value
93
94 **/
95 UINT32
96 EFIAPI
97 PostCodeWithDescription (
98 IN UINT32 Value,
99 IN CONST CHAR8 *Description OPTIONAL
100 )
101 {
102 if (Description == NULL) {
103 REPORT_STATUS_CODE (
104 EFI_PROGRESS_CODE,
105 POST_CODE_TO_STATUS_CODE_VALUE (Value)
106 );
107 } else {
108 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
109 EFI_PROGRESS_CODE,
110 POST_CODE_TO_STATUS_CODE_VALUE (Value),
111 Description,
112 AsciiStrSize (Description)
113 );
114 }
115
116 return Value;
117 }
118
119
120 /**
121 Returns TRUE if POST Codes are enabled.
122
123 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
124 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
125
126 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
127 PcdPostCodeProperyMask is set.
128 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
129 PcdPostCodeProperyMask is clear.
130
131 **/
132 BOOLEAN
133 EFIAPI
134 PostCodeEnabled (
135 VOID
136 )
137 {
138 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
139 }
140
141
142 /**
143 Returns TRUE if POST code descriptions are enabled.
144
145 This function returns TRUE if the
146 POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
147 PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
148
149 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED
150 bit of PcdPostCodeProperyMask is set.
151 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED
152 bit of PcdPostCodeProperyMask is clear.
153
154 **/
155 BOOLEAN
156 EFIAPI
157 PostCodeDescriptionEnabled (
158 VOID
159 )
160 {
161 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
162 }