]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / PeiDxePostCodeLibReportStatusCode / PostCode.c
CommitLineData
cdffda11 1/** @file\r
eceb3a4c
LG
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
cdffda11 4\r
9095d37b 5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
cdffda11 7\r
8**/\r
9\r
c892d846 10\r
bad46384 11#include <PiPei.h>\r
c892d846 12\r
bad46384 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
cdffda11 18/**\r
19 Converts POST code value to status code value.\r
20\r
bad46384 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
cdffda11 24\r
bad46384 25 @param PostCode POST code value.\r
cdffda11 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
9095d37b
LG
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
cdffda11 40 display the 32-bit value on the status reporting device.\r
9095d37b
LG
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
cdffda11 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
122e2191 48 @return The 32-bit value to write to the POST card.\r
cdffda11 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
9095d37b
LG
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
cdffda11 76 immediately.\r
77\r
78 @param Value The 32-bit value to write to the POST card.\r
9095d37b
LG
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
cdffda11 81 be NULL.\r
82\r
122e2191 83 @return The 32-bit value to write to the POST card.\r
cdffda11 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
bad46384 93 if (Description == NULL) {\r
cdffda11 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
9095d37b 114 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED\r
cdffda11 115 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
116\r
9095d37b 117 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
cdffda11 118 PcdPostCodeProperyMask is set.\r
9095d37b 119 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
cdffda11 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
eceb3a4c
LG
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
cdffda11 138\r
eceb3a4c
LG
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
cdffda11 143\r
144**/\r
145BOOLEAN\r
146EFIAPI\r
147PostCodeDescriptionEnabled (\r
148 VOID\r
149 )\r
150{\r
eceb3a4c 151 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);\r
cdffda11 152}\r
eceb3a4c 153\r