TianoCore EDK2 master
Loading...
Searching...
No Matches
IoLibGcc.c
Go to the documentation of this file.
1
19#include "IoLibTdx.h"
20
37UINT8
38EFIAPI
40 IN UINTN Port
41 )
42{
43 UINT8 Data;
44 BOOLEAN Flag;
45
46 Flag = FilterBeforeIoRead (FilterWidth8, Port, &Data);
47 if (Flag) {
48 if (IsTdxGuest ()) {
49 Data = TdIoRead8 (Port);
50 } else {
51 __asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port));
52 }
53 }
54
55 FilterAfterIoRead (FilterWidth8, Port, &Data);
56
57 return Data;
58}
59
77UINT8
78EFIAPI
80 IN UINTN Port,
81 IN UINT8 Value
82 )
83{
84 BOOLEAN Flag;
85
86 Flag = FilterBeforeIoWrite (FilterWidth8, Port, &Value);
87 if (Flag) {
88 if (IsTdxGuest ()) {
89 TdIoWrite8 (Port, Value);
90 } else {
91 __asm__ __volatile__ ("outb %b0,%w1" : : "a" (Value), "d" ((UINT16)Port));
92 }
93 }
94
95 FilterAfterIoWrite (FilterWidth8, Port, &Value);
96
97 return Value;
98}
99
117UINT16
118EFIAPI
120 IN UINTN Port
121 )
122{
123 UINT16 Data;
124 BOOLEAN Flag;
125
126 ASSERT ((Port & 1) == 0);
127
128 Flag = FilterBeforeIoRead (FilterWidth16, Port, &Data);
129 if (Flag) {
130 if (IsTdxGuest ()) {
131 Data = TdIoRead16 (Port);
132 } else {
133 __asm__ __volatile__ ("inw %w1,%w0" : "=a" (Data) : "d" ((UINT16)Port));
134 }
135 }
136
137 FilterAfterIoRead (FilterWidth16, Port, &Data);
138
139 return Data;
140}
141
160UINT16
161EFIAPI
163 IN UINTN Port,
164 IN UINT16 Value
165 )
166{
167 BOOLEAN Flag;
168
169 ASSERT ((Port & 1) == 0);
170
171 Flag = FilterBeforeIoWrite (FilterWidth16, Port, &Value);
172 if (Flag) {
173 if (IsTdxGuest ()) {
174 TdIoWrite16 (Port, Value);
175 } else {
176 __asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port));
177 }
178 }
179
180 FilterAfterIoWrite (FilterWidth16, Port, &Value);
181
182 return Value;
183}
184
202UINT32
203EFIAPI
205 IN UINTN Port
206 )
207{
208 UINT32 Data;
209 BOOLEAN Flag;
210
211 ASSERT ((Port & 3) == 0);
212
213 Flag = FilterBeforeIoRead (FilterWidth32, Port, &Data);
214 if (Flag) {
215 if (IsTdxGuest ()) {
216 Data = TdIoRead32 (Port);
217 } else {
218 __asm__ __volatile__ ("inl %w1,%0" : "=a" (Data) : "d" ((UINT16)Port));
219 }
220 }
221
222 FilterAfterIoRead (FilterWidth32, Port, &Data);
223
224 return Data;
225}
226
245UINT32
246EFIAPI
248 IN UINTN Port,
249 IN UINT32 Value
250 )
251{
252 BOOLEAN Flag;
253
254 ASSERT ((Port & 3) == 0);
255
256 Flag = FilterBeforeIoWrite (FilterWidth32, Port, &Value);
257 if (Flag) {
258 if (IsTdxGuest ()) {
259 TdIoWrite32 (Port, Value);
260 } else {
261 __asm__ __volatile__ ("outl %0,%w1" : : "a" (Value), "d" ((UINT16)Port));
262 }
263 }
264
265 FilterAfterIoWrite (FilterWidth32, Port, &Value);
266
267 return Value;
268}
UINT64 UINTN
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
Definition: IoLibGcc.c:79
UINT8 EFIAPI IoRead8(IN UINTN Port)
Definition: IoLibGcc.c:39
UINT16 EFIAPI IoRead16(IN UINTN Port)
Definition: IoLibGcc.c:119
UINT32 EFIAPI IoRead32(IN UINTN Port)
Definition: IoLibGcc.c:204
UINT32 EFIAPI IoWrite32(IN UINTN Port, IN UINT32 Value)
Definition: IoLibGcc.c:247
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value)
Definition: IoLibGcc.c:162
UINT16 EFIAPI TdIoRead16(IN UINTN Port)
UINT32 EFIAPI TdIoWrite32(IN UINTN Port, IN UINT32 Value)
UINT16 EFIAPI TdIoWrite16(IN UINTN Port, IN UINT16 Value)
UINT32 EFIAPI TdIoRead32(IN UINTN Port)
BOOLEAN EFIAPI IsTdxGuest(VOID)
UINT8 EFIAPI TdIoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI TdIoRead8(IN UINTN Port)
#define IN
Definition: Base.h:279
VOID EFIAPI FilterAfterIoRead(IN FILTER_IO_WIDTH Width, IN UINTN Address, IN VOID *Buffer)
BOOLEAN EFIAPI FilterBeforeIoWrite(IN FILTER_IO_WIDTH Width, IN UINTN Address, IN VOID *Buffer)
VOID EFIAPI FilterAfterIoWrite(IN FILTER_IO_WIDTH Width, IN UINTN Address, IN VOID *Buffer)
BOOLEAN EFIAPI FilterBeforeIoRead(IN FILTER_IO_WIDTH Width, IN UINTN Address, IN OUT VOID *Buffer)