]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / PeiDxePostCodeLibReportStatusCode / PostCode.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 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
13 Module Name:
14
15 PostCode.c
16
17 Abstract:
18
19 Post Code Lib
20
21 --*/
22
23 #include "EdkIIGlueDxe.h"
24
25 /**
26 Converts POST code value to status code value.
27
28 This macro converts the post code to status code value. Bits 0..4 of PostCode
29 are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits
30 24..26 of status code value.
31
32 @param PostCode POST code value.
33
34 @return The converted status code value.
35
36 **/
37 #define POST_CODE_TO_STATUS_CODE_VALUE(PostCode) \
38 ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19)))
39
40 /**
41 Sends an 32-bit value to a POST card.
42
43 Sends the 32-bit value specified by Value to a POST card, and returns Value.
44 Some implementations of this library function may perform I/O operations
45 directly to a POST card device. Other implementations may send Value to
46 ReportStatusCode(), and the status code reporting mechanism will eventually
47 display the 32-bit value on the status reporting device.
48
49 PostCode() must actively prevent recursion. If PostCode() is called while
50 processing another any other Report Status Code Library function, then
51 PostCode() must return Value immediately.
52
53 @param Value The 32-bit value to write to the POST card.
54
55 @return Value
56
57 **/
58 UINT32
59 EFIAPI
60 GluePostCode (
61 IN UINT32 Value
62 )
63 {
64 REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value));
65 return Value;
66 }
67
68
69 /**
70 Sends an 32-bit value to a POST and associated ASCII string.
71
72 Sends the 32-bit value specified by Value to a POST card, and returns Value.
73 If Description is not NULL, then the ASCII string specified by Description is
74 also passed to the handler that displays the POST card value. Some
75 implementations of this library function may perform I/O operations directly
76 to a POST card device. Other implementations may send Value to ReportStatusCode(),
77 and the status code reporting mechanism will eventually display the 32-bit
78 value on the status reporting device.
79
80 PostCodeWithDescription()must actively prevent recursion. If
81 PostCodeWithDescription() is called while processing another any other Report
82 Status Code Library function, then PostCodeWithDescription() must return Value
83 immediately.
84
85 @param Value The 32-bit value to write to the POST card.
86 @param Description Pointer to an ASCII string that is a description of the
87 POST code value. This is an optional parameter that may
88 be NULL.
89
90 @return Value
91
92 **/
93 UINT32
94 EFIAPI
95 GluePostCodeWithDescription (
96 IN UINT32 Value,
97 IN CONST CHAR8 *Description OPTIONAL
98 )
99 {
100 if (Description == NULL) {
101 REPORT_STATUS_CODE (
102 EFI_PROGRESS_CODE,
103 POST_CODE_TO_STATUS_CODE_VALUE (Value)
104 );
105 } else {
106 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
107 EFI_PROGRESS_CODE,
108 POST_CODE_TO_STATUS_CODE_VALUE (Value),
109 Description,
110 AsciiStrSize (Description)
111 );
112 }
113
114 return Value;
115 }
116
117
118 /**
119 Returns TRUE if POST Codes are enabled.
120
121 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
122 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
123
124 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
125 PcdPostCodeProperyMask is set.
126 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
127 PcdPostCodeProperyMask is clear.
128
129 **/
130 BOOLEAN
131 EFIAPI
132 GluePostCodeEnabled (
133 VOID
134 )
135 {
136 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
137 }
138
139
140 /**
141 Returns TRUE if POST code descriptions are enabled.
142
143 This function returns TRUE if the
144 POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
145 PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
146
147 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED
148 bit of PcdPostCodeProperyMask is set.
149 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED
150 bit of PcdPostCodeProperyMask is clear.
151
152 **/
153 BOOLEAN
154 EFIAPI
155 GluePostCodeDescriptionEnabled (
156 VOID
157 )
158 {
159 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
160 }