]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoLib.c
2 Common I/O Library routines.
4 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "BaseIoLibIntrinsicInternal.h"
13 Reads a 64-bit I/O port.
15 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
16 This function must guarantee that all I/O read and write operations are
19 If 64-bit I/O port operations are not supported, then ASSERT().
20 If Port is not aligned on a 64-bit boundary, then ASSERT().
22 @param Port The I/O port to read.
24 @return The value read.
38 Writes a 64-bit I/O port.
40 Writes the 64-bit I/O port specified by Port with the value specified by Value
41 and returns Value. This function must guarantee that all I/O read and write
42 operations are serialized.
44 If 64-bit I/O port operations are not supported, then ASSERT().
45 If Port is not aligned on a 64-bit boundary, then ASSERT().
47 @param Port The I/O port to write.
48 @param Value The value to write to the I/O port.
50 @return The value written the I/O port.
65 Reads an 8-bit MMIO register.
67 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
68 returned. This function must guarantee that all MMIO read and write
69 operations are serialized.
71 If 8-bit MMIO register operations are not supported, then ASSERT().
73 For Td guest TDVMCALL_MMIO is invoked to read MMIO registers.
75 @param Address The MMIO register to read.
77 @return The value read.
89 Flag
= FilterBeforeMmIoRead (FilterWidth8
, Address
, &Value
);
94 Value
= TdMmioRead8 (Address
);
96 Value
= *(volatile UINT8
*)Address
;
102 FilterAfterMmIoRead (FilterWidth8
, Address
, &Value
);
108 Writes an 8-bit MMIO register.
110 Writes the 8-bit MMIO register specified by Address with the value specified
111 by Value and returns Value. This function must guarantee that all MMIO read
112 and write operations are serialized.
114 If 8-bit MMIO register operations are not supported, then ASSERT().
116 For Td guest TDVMCALL_MMIO is invoked to write MMIO registers.
118 @param Address The MMIO register to write.
119 @param Value The value to write to the MMIO register.
133 Flag
= FilterBeforeMmIoWrite (FilterWidth8
, Address
, &Value
);
138 TdMmioWrite8 (Address
, Value
);
140 *(volatile UINT8
*)Address
= Value
;
146 FilterAfterMmIoWrite (FilterWidth8
, Address
, &Value
);
152 Reads a 16-bit MMIO register.
154 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
155 returned. This function must guarantee that all MMIO read and write
156 operations are serialized.
158 If 16-bit MMIO register operations are not supported, then ASSERT().
159 If Address is not aligned on a 16-bit boundary, then ASSERT().
161 For Td guest TDVMCALL_MMIO is invoked to read MMIO registers.
163 @param Address The MMIO register to read.
165 @return The value read.
177 ASSERT ((Address
& 1) == 0);
178 Flag
= FilterBeforeMmIoRead (FilterWidth16
, Address
, &Value
);
183 Value
= TdMmioRead16 (Address
);
185 Value
= *(volatile UINT16
*)Address
;
191 FilterAfterMmIoRead (FilterWidth16
, Address
, &Value
);
197 Writes a 16-bit MMIO register.
199 Writes the 16-bit MMIO register specified by Address with the value specified
200 by Value and returns Value. This function must guarantee that all MMIO read
201 and write operations are serialized.
203 If 16-bit MMIO register operations are not supported, then ASSERT().
204 If Address is not aligned on a 16-bit boundary, then ASSERT().
206 For Td guest TDVMCALL_MMIO is invoked to write MMIO registers.
208 @param Address The MMIO register to write.
209 @param Value The value to write to the MMIO register.
223 ASSERT ((Address
& 1) == 0);
225 Flag
= FilterBeforeMmIoWrite (FilterWidth16
, Address
, &Value
);
230 TdMmioWrite16 (Address
, Value
);
232 *(volatile UINT16
*)Address
= Value
;
238 FilterAfterMmIoWrite (FilterWidth16
, Address
, &Value
);
244 Reads a 32-bit MMIO register.
246 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
247 returned. This function must guarantee that all MMIO read and write
248 operations are serialized.
250 If 32-bit MMIO register operations are not supported, then ASSERT().
251 If Address is not aligned on a 32-bit boundary, then ASSERT().
253 For Td guest TDVMCALL_MMIO is invoked to read MMIO registers.
255 @param Address The MMIO register to read.
257 @return The value read.
269 ASSERT ((Address
& 3) == 0);
271 Flag
= FilterBeforeMmIoRead (FilterWidth32
, Address
, &Value
);
276 Value
= TdMmioRead32 (Address
);
278 Value
= *(volatile UINT32
*)Address
;
284 FilterAfterMmIoRead (FilterWidth32
, Address
, &Value
);
290 Writes a 32-bit MMIO register.
292 Writes the 32-bit MMIO register specified by Address with the value specified
293 by Value and returns Value. This function must guarantee that all MMIO read
294 and write operations are serialized.
296 If 32-bit MMIO register operations are not supported, then ASSERT().
297 If Address is not aligned on a 32-bit boundary, then ASSERT().
299 For Td guest TDVMCALL_MMIO is invoked to write MMIO registers.
301 @param Address The MMIO register to write.
302 @param Value The value to write to the MMIO register.
316 ASSERT ((Address
& 3) == 0);
318 Flag
= FilterBeforeMmIoWrite (FilterWidth32
, Address
, &Value
);
323 TdMmioWrite32 (Address
, Value
);
325 *(volatile UINT32
*)Address
= Value
;
331 FilterAfterMmIoWrite (FilterWidth32
, Address
, &Value
);
337 Reads a 64-bit MMIO register.
339 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
340 returned. This function must guarantee that all MMIO read and write
341 operations are serialized.
343 If 64-bit MMIO register operations are not supported, then ASSERT().
344 If Address is not aligned on a 64-bit boundary, then ASSERT().
346 For Td guest TDVMCALL_MMIO is invoked to read MMIO registers.
348 @param Address The MMIO register to read.
350 @return The value read.
362 ASSERT ((Address
& 7) == 0);
364 Flag
= FilterBeforeMmIoRead (FilterWidth64
, Address
, &Value
);
369 Value
= TdMmioRead64 (Address
);
371 Value
= *(volatile UINT64
*)Address
;
377 FilterAfterMmIoRead (FilterWidth64
, Address
, &Value
);
383 Writes a 64-bit MMIO register.
385 Writes the 64-bit MMIO register specified by Address with the value specified
386 by Value and returns Value. This function must guarantee that all MMIO read
387 and write operations are serialized.
389 If 64-bit MMIO register operations are not supported, then ASSERT().
390 If Address is not aligned on a 64-bit boundary, then ASSERT().
392 For Td guest TDVMCALL_MMIO is invoked to write MMIO registers.
394 @param Address The MMIO register to write.
395 @param Value The value to write to the MMIO register.
407 ASSERT ((Address
& 7) == 0);
409 Flag
= FilterBeforeMmIoWrite (FilterWidth64
, Address
, &Value
);
414 TdMmioWrite64 (Address
, Value
);
416 *(volatile UINT64
*)Address
= Value
;
422 FilterAfterMmIoWrite (FilterWidth64
, Address
, &Value
);