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