]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePostCodeLibPort80/PostCode.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 Sends an 32-bit value to a POST and associated ASCII string.
63
64 Sends the 32-bit value specified by Value to a POST card, and returns Value.
65 If Description is not NULL, then the ASCII string specified by Description is
66 also passed to the handler that displays the POST card value. Some
67 implementations of this library function may perform I/O operations directly
68 to a POST card device. Other implementations may send Value to ReportStatusCode(),
69 and the status code reporting mechanism will eventually display the 32-bit
70 value on the status reporting device.
71
72 PostCodeWithDescription()must actively prevent recursion. If
73 PostCodeWithDescription() is called while processing another any other Post
74 Code Library function, then PostCodeWithDescription() must return Value
75 immediately.
76
77 @param Value The 32-bit value to write to the POST card.
78 @param Description The pointer to an ASCII string that is a description of the
79 POST code value. This is an optional parameter that may
80 be NULL.
81
82 @return The 32-bit value to write to the POST card.
83
84 **/
85 UINT32
86 EFIAPI
87 PostCodeWithDescription (
88 IN UINT32 Value,
89 IN CONST CHAR8 *Description OPTIONAL
90 )
91 {
92 PostCode (Value);
93 return Value;
94 }
95
96 /**
97 Returns TRUE if POST Codes are enabled.
98
99 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
100 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
101
102 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
103 PcdPostCodeProperyMask is set.
104 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
105 PcdPostCodeProperyMask is clear.
106
107 **/
108 BOOLEAN
109 EFIAPI
110 PostCodeEnabled (
111 VOID
112 )
113 {
114 return (BOOLEAN)((PcdGet8 (PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
115 }
116
117 /**
118 Returns TRUE if POST code descriptions are enabled.
119
120 This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED
121 bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
122
123 @retval TRUE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of
124 PcdPostCodeProperyMask is set.
125 @retval FALSE The POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED bit of
126 PcdPostCodeProperyMask is clear.
127
128 **/
129 BOOLEAN
130 EFIAPI
131 PostCodeDescriptionEnabled (
132 VOID
133 )
134 {
135 return (BOOLEAN)((PcdGet8 (PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED) != 0);
136 }