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