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