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