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