]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/BasePostCodeLibPort80/PostCode.c
MdePkg/BaseSafeIntLib: fix undefined behavior in SafeInt64Mult()
[mirror_edk2.git] / MdePkg / Library / BasePostCodeLibPort80 / PostCode.c
... / ...
CommitLineData
1/** @file\r
2 Post Code Library instance that writes post code values to I/O port 0x80.\r
3\r
4 Copyright (c) 2006 - 2015, 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
9\r
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
12\r
13**/\r
14\r
15#include <Base.h>\r
16\r
17#include <Library/PostCodeLib.h>\r
18#include <Library/PcdLib.h>\r
19#include <Library/IoLib.h>\r
20#include <Library/DebugLib.h>\r
21\r
22/**\r
23 Sends an 32-bit value to a POST card.\r
24\r
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
29 display the 32-bit value on the status reporting device.\r
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
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
37 @return The 32-bit value to write to the POST card.\r
38\r
39**/\r
40UINT32\r
41EFIAPI\r
42PostCode (\r
43 IN UINT32 Value\r
44 )\r
45{\r
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
63 \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
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
82 immediately.\r
83\r
84 @param Value The 32-bit value to write to the POST card.\r
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
87 be NULL.\r
88\r
89 @return The 32-bit value to write to the POST card.\r
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
99 PostCode (Value);\r
100 return Value;\r
101}\r
102\r
103\r
104/**\r
105 Returns TRUE if POST Codes are enabled.\r
106\r
107 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED \r
108 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.\r
109\r
110 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
111 PcdPostCodeProperyMask is set.\r
112 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
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
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
131\r
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
136\r
137**/\r
138BOOLEAN\r
139EFIAPI\r
140PostCodeDescriptionEnabled (\r
141 VOID\r
142 )\r
143{\r
144 return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);\r
145}\r