]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BasePostCodeLibPort80/PostCode.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BasePostCodeLibPort80 / PostCode.c
CommitLineData
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
34UINT32\r
35EFIAPI\r
36PostCode (\r
37 IN UINT32 Value\r
38 )\r
39{\r
661c306c
LG
40 switch (PcdGet8 (PcdPort80DataWidth)) {\r
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
56 }\r
9095d37b 57\r
e1f414b6 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
e1f414b6 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
efb23117 81 be NULL.\r
e1f414b6 82\r
afa22326 83 @return The 32-bit value to write to the POST card.\r
e1f414b6 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
661c306c 93 PostCode (Value);\r
e1f414b6 94 return Value;\r
95}\r
96\r
97\r
98/**\r
99 Returns TRUE if POST Codes are enabled.\r
100\r
9095d37b 101 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED\r
e1f414b6 102 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
103\r
9095d37b 104 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
e1f414b6 105 PcdPostCodeProperyMask is set.\r
9095d37b 106 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
e1f414b6 107 PcdPostCodeProperyMask is clear.\r
108\r
109**/\r
110BOOLEAN\r
111EFIAPI\r
112PostCodeEnabled (\r
113 VOID\r
114 )\r
115{\r
116 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
117}\r
118\r
119\r
120/**\r
121 Returns TRUE if POST code descriptions are enabled.\r
122\r
eceb3a4c
LG
123 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED\r
124 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
e1f414b6 125\r
eceb3a4c
LG
126 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r
127 PcdPostCodeProperyMask is set.\r
128 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r
129 PcdPostCodeProperyMask is clear.\r
e1f414b6 130\r
131**/\r
132BOOLEAN\r
133EFIAPI\r
134PostCodeDescriptionEnabled (\r
135 VOID\r
136 )\r
137{\r
eceb3a4c 138 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);\r
e1f414b6 139}\r