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