]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BasePostCodeLibPort80/PostCode.c
MdePkg: Clean up source files
[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
LG
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 9\r
9095d37b
LG
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
e1f414b6 12\r
13**/\r
14\r
c7d265a9 15#include <Base.h>\r
c892d846 16\r
c7d265a9 17#include <Library/PostCodeLib.h>\r
18#include <Library/PcdLib.h>\r
19#include <Library/IoLib.h>\r
661c306c 20#include <Library/DebugLib.h>\r
e1f414b6 21\r
22/**\r
23 Sends an 32-bit value to a POST card.\r
24\r
9095d37b
LG
25 Sends the 32-bit value specified by Value to a POST card, and returns Value.\r
26 Some implementations of this library function may perform I/O operations\r
27 directly to a POST card device. Other implementations may send Value to\r
28 ReportStatusCode(), and the status code reporting mechanism will eventually\r
e1f414b6 29 display the 32-bit value on the status reporting device.\r
9095d37b
LG
30\r
31 PostCode() must actively prevent recursion. If PostCode() is called while\r
32 processing another any other Post Code Library function, then\r
e1f414b6 33 PostCode() must return Value immediately.\r
34\r
35 @param Value The 32-bit value to write to the POST card.\r
36\r
afa22326 37 @return The 32-bit value to write to the POST card.\r
e1f414b6 38\r
39**/\r
40UINT32\r
41EFIAPI\r
42PostCode (\r
43 IN UINT32 Value\r
44 )\r
45{\r
661c306c
LG
46 switch (PcdGet8 (PcdPort80DataWidth)) {\r
47 case 8:\r
48 IoWrite8 (0x80, (UINT8)(Value));\r
49 break;\r
50 case 16:\r
51 IoWrite16 (0x80, (UINT16)(Value));\r
52 break;\r
53 case 32:\r
54 IoWrite32 (0x80, Value);\r
55 break;\r
56 default:\r
57 //\r
58 // Assert on the invalid data width\r
59 //\r
60 ASSERT (FALSE);\r
61 break;\r
62 }\r
9095d37b 63\r
e1f414b6 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
9095d37b
LG
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
e1f414b6 82 immediately.\r
83\r
84 @param Value The 32-bit value to write to the POST card.\r
9095d37b
LG
85 @param Description The pointer to an ASCII string that is a description of the\r
86 POST code value. This is an optional parameter that may\r
efb23117 87 be NULL.\r
e1f414b6 88\r
afa22326 89 @return The 32-bit value to write to the POST card.\r
e1f414b6 90\r
91**/\r
92UINT32\r
93EFIAPI\r
94PostCodeWithDescription (\r
95 IN UINT32 Value,\r
96 IN CONST CHAR8 *Description OPTIONAL\r
97 )\r
98{\r
661c306c 99 PostCode (Value);\r
e1f414b6 100 return Value;\r
101}\r
102\r
103\r
104/**\r
105 Returns TRUE if POST Codes are enabled.\r
106\r
9095d37b 107 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED\r
e1f414b6 108 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
109\r
9095d37b 110 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
e1f414b6 111 PcdPostCodeProperyMask is set.\r
9095d37b 112 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
e1f414b6 113 PcdPostCodeProperyMask is clear.\r
114\r
115**/\r
116BOOLEAN\r
117EFIAPI\r
118PostCodeEnabled (\r
119 VOID\r
120 )\r
121{\r
122 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
123}\r
124\r
125\r
126/**\r
127 Returns TRUE if POST code descriptions are enabled.\r
128\r
eceb3a4c
LG
129 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED\r
130 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
e1f414b6 131\r
eceb3a4c
LG
132 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r
133 PcdPostCodeProperyMask is set.\r
134 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of\r
135 PcdPostCodeProperyMask is clear.\r
e1f414b6 136\r
137**/\r
138BOOLEAN\r
139EFIAPI\r
140PostCodeDescriptionEnabled (\r
141 VOID\r
142 )\r
143{\r
eceb3a4c 144 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);\r
e1f414b6 145}\r