]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
eceb3a4c | 2 | Post Code Library instance that writes post code values to I/O port 0x80.\r |
e1f414b6 | 3 | \r |
9095d37b | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
e1f414b6 | 6 | \r |
7 | **/\r | |
8 | \r | |
c7d265a9 | 9 | #include <Base.h>\r |
c892d846 | 10 | \r |
c7d265a9 | 11 | #include <Library/PostCodeLib.h>\r |
12 | #include <Library/PcdLib.h>\r | |
13 | #include <Library/IoLib.h>\r | |
661c306c | 14 | #include <Library/DebugLib.h>\r |
e1f414b6 | 15 | \r |
16 | /**\r | |
17 | Sends an 32-bit value to a POST card.\r | |
18 | \r | |
9095d37b LG |
19 | Sends the 32-bit value specified by Value to a POST card, and returns Value.\r |
20 | Some implementations of this library function may perform I/O operations\r | |
21 | directly to a POST card device. Other implementations may send Value to\r | |
22 | ReportStatusCode(), and the status code reporting mechanism will eventually\r | |
e1f414b6 | 23 | display the 32-bit value on the status reporting device.\r |
9095d37b LG |
24 | \r |
25 | PostCode() must actively prevent recursion. If PostCode() is called while\r | |
26 | processing another any other Post Code Library function, then\r | |
e1f414b6 | 27 | PostCode() must return Value immediately.\r |
28 | \r | |
29 | @param Value The 32-bit value to write to the POST card.\r | |
30 | \r | |
afa22326 | 31 | @return The 32-bit value to write to the POST card.\r |
e1f414b6 | 32 | \r |
33 | **/\r | |
34 | UINT32\r | |
35 | EFIAPI\r | |
36 | PostCode (\r | |
37 | IN UINT32 Value\r | |
38 | )\r | |
39 | {\r | |
661c306c | 40 | switch (PcdGet8 (PcdPort80DataWidth)) {\r |
2f88bd3a MK |
41 | case 8:\r |
42 | IoWrite8 (0x80, (UINT8)(Value));\r | |
43 | break;\r | |
44 | case 16:\r | |
45 | IoWrite16 (0x80, (UINT16)(Value));\r | |
46 | break;\r | |
47 | case 32:\r | |
48 | IoWrite32 (0x80, Value);\r | |
49 | break;\r | |
50 | default:\r | |
51 | //\r | |
52 | // Assert on the invalid data width\r | |
53 | //\r | |
54 | ASSERT (FALSE);\r | |
55 | break;\r | |
661c306c | 56 | }\r |
9095d37b | 57 | \r |
e1f414b6 | 58 | return Value;\r |
59 | }\r | |
60 | \r | |
e1f414b6 | 61 | /**\r |
62 | Sends an 32-bit value to a POST and associated ASCII string.\r | |
63 | \r | |
64 | Sends the 32-bit value specified by Value to a POST card, and returns Value.\r | |
9095d37b LG |
65 | If Description is not NULL, then the ASCII string specified by Description is\r |
66 | also passed to the handler that displays the POST card value. Some\r | |
67 | implementations of this library function may perform I/O operations directly\r | |
68 | to a POST card device. Other implementations may send Value to ReportStatusCode(),\r | |
69 | and the status code reporting mechanism will eventually display the 32-bit\r | |
70 | value on the status reporting device.\r | |
71 | \r | |
72 | PostCodeWithDescription()must actively prevent recursion. If\r | |
73 | PostCodeWithDescription() is called while processing another any other Post\r | |
74 | Code Library function, then PostCodeWithDescription() must return Value\r | |
e1f414b6 | 75 | immediately.\r |
76 | \r | |
77 | @param Value The 32-bit value to write to the POST card.\r | |
9095d37b LG |
78 | @param Description The pointer to an ASCII string that is a description of the\r |
79 | POST code value. This is an optional parameter that may\r | |
efb23117 | 80 | be NULL.\r |
e1f414b6 | 81 | \r |
afa22326 | 82 | @return The 32-bit value to write to the POST card.\r |
e1f414b6 | 83 | \r |
84 | **/\r | |
85 | UINT32\r | |
86 | EFIAPI\r | |
87 | PostCodeWithDescription (\r | |
88 | IN UINT32 Value,\r | |
89 | IN CONST CHAR8 *Description OPTIONAL\r | |
90 | )\r | |
91 | {\r | |
661c306c | 92 | PostCode (Value);\r |
e1f414b6 | 93 | return Value;\r |
94 | }\r | |
95 | \r | |
e1f414b6 | 96 | /**\r |
97 | Returns TRUE if POST Codes are enabled.\r | |
98 | \r | |
9095d37b | 99 | This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED\r |
e1f414b6 | 100 | bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r |
101 | \r | |
9095d37b | 102 | @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r |
e1f414b6 | 103 | PcdPostCodeProperyMask is set.\r |
9095d37b | 104 | @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r |
e1f414b6 | 105 | PcdPostCodeProperyMask is clear.\r |
106 | \r | |
107 | **/\r | |
108 | BOOLEAN\r | |
109 | EFIAPI\r | |
110 | PostCodeEnabled (\r | |
111 | VOID\r | |
112 | )\r | |
113 | {\r | |
2f88bd3a | 114 | return (BOOLEAN)((PcdGet8 (PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r |
e1f414b6 | 115 | }\r |
116 | \r | |
e1f414b6 | 117 | /**\r |
118 | Returns TRUE if POST code descriptions are enabled.\r | |
119 | \r | |
eceb3a4c LG |
120 | This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED\r |
121 | bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r | |
e1f414b6 | 122 | \r |
eceb3a4c LG |
123 | @retval TRUE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r |
124 | PcdPostCodeProperyMask is set.\r | |
125 | @retval FALSE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r | |
126 | PcdPostCodeProperyMask is clear.\r | |
e1f414b6 | 127 | \r |
128 | **/\r | |
129 | BOOLEAN\r | |
130 | EFIAPI\r | |
131 | PostCodeDescriptionEnabled (\r | |
132 | VOID\r | |
133 | )\r | |
134 | {\r | |
2f88bd3a | 135 | return (BOOLEAN)((PcdGet8 (PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);\r |
e1f414b6 | 136 | }\r |