]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
2 I/O library for non I/O read and write access (memory map I/O read and
3 write only) architecture, such as ARM, RISC-V and LoongArch processor.
5 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
8 Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
9 Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
16 // Include common header file for this module.
18 #include "BaseIoLibIntrinsicInternal.h"
21 Reads an 8-bit I/O port.
23 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
24 This function must guarantee that all I/O read and write operations are
27 If 8-bit I/O port operations are not supported, then ASSERT().
29 @param Port The I/O port to read.
31 @return The value read.
45 Writes an 8-bit I/O port.
47 Writes the 8-bit I/O port specified by Port with the value specified by Value
48 and returns Value. This function must guarantee that all I/O read and write
49 operations are serialized.
51 If 8-bit I/O port operations are not supported, then ASSERT().
53 @param Port The I/O port to write.
54 @param Value The value to write to the I/O port.
56 @return The value written the I/O port.
71 Reads a 16-bit I/O port.
73 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
74 This function must guarantee that all I/O read and write operations are
77 If 16-bit I/O port operations are not supported, then ASSERT().
79 @param Port The I/O port to read.
81 @return The value read.
95 Writes a 16-bit I/O port.
97 Writes the 16-bit I/O port specified by Port with the value specified by Value
98 and returns Value. This function must guarantee that all I/O read and write
99 operations are serialized.
101 If 16-bit I/O port operations are not supported, then ASSERT().
103 @param Port The I/O port to write.
104 @param Value The value to write to the I/O port.
106 @return The value written the I/O port.
121 Reads a 32-bit I/O port.
123 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
124 This function must guarantee that all I/O read and write operations are
127 If 32-bit I/O port operations are not supported, then ASSERT().
129 @param Port The I/O port to read.
131 @return The value read.
145 Writes a 32-bit I/O port.
147 Writes the 32-bit I/O port specified by Port with the value specified by Value
148 and returns Value. This function must guarantee that all I/O read and write
149 operations are serialized.
151 If 32-bit I/O port operations are not supported, then ASSERT().
153 @param Port The I/O port to write.
154 @param Value The value to write to the I/O port.
156 @return The value written the I/O port.
171 Reads a 64-bit I/O port.
173 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
174 This function must guarantee that all I/O read and write operations are
177 If 64-bit I/O port operations are not supported, then ASSERT().
178 If Port is not aligned on a 64-bit boundary, then ASSERT().
180 @param Port The I/O port to read.
182 @return The value read.
196 Writes a 64-bit I/O port.
198 Writes the 64-bit I/O port specified by Port with the value specified by Value
199 and returns Value. This function must guarantee that all I/O read and write
200 operations are serialized.
202 If 64-bit I/O port operations are not supported, then ASSERT().
203 If Port is not aligned on a 64-bit boundary, then ASSERT().
205 @param Port The I/O port to write.
206 @param Value The value to write to the I/O port.
208 @return The value written to the I/O port.
223 Reads an 8-bit I/O port fifo into a block of memory.
225 Reads the 8-bit I/O fifo port specified by Port.
226 The port is read Count times, and the read data is
227 stored in the provided Buffer.
229 This function must guarantee that all I/O read and write operations are
232 If 8-bit I/O port operations are not supported, then ASSERT().
234 @param Port The I/O port to read.
235 @param Count The number of times to read I/O port.
236 @param Buffer The buffer to store the read data into.
251 Writes a block of memory into an 8-bit I/O port fifo.
253 Writes the 8-bit I/O fifo port specified by Port.
254 The port is written Count times, and the write data is
255 retrieved from the provided Buffer.
257 This function must guarantee that all I/O write and write operations are
260 If 8-bit I/O port operations are not supported, then ASSERT().
262 @param Port The I/O port to write.
263 @param Count The number of times to write I/O port.
264 @param Buffer The buffer to retrieve the write data from.
279 Reads a 16-bit I/O port fifo into a block of memory.
281 Reads the 16-bit I/O fifo port specified by Port.
282 The port is read Count times, and the read data is
283 stored in the provided Buffer.
285 This function must guarantee that all I/O read and write operations are
288 If 16-bit I/O port operations are not supported, then ASSERT().
290 @param Port The I/O port to read.
291 @param Count The number of times to read I/O port.
292 @param Buffer The buffer to store the read data into.
307 Writes a block of memory into a 16-bit I/O port fifo.
309 Writes the 16-bit I/O fifo port specified by Port.
310 The port is written Count times, and the write data is
311 retrieved from the provided Buffer.
313 This function must guarantee that all I/O write and write operations are
316 If 16-bit I/O port operations are not supported, then ASSERT().
318 @param Port The I/O port to write.
319 @param Count The number of times to write I/O port.
320 @param Buffer The buffer to retrieve the write data from.
335 Reads a 32-bit I/O port fifo into a block of memory.
337 Reads the 32-bit I/O fifo port specified by Port.
338 The port is read Count times, and the read data is
339 stored in the provided Buffer.
341 This function must guarantee that all I/O read and write operations are
344 If 32-bit I/O port operations are not supported, then ASSERT().
346 @param Port The I/O port to read.
347 @param Count The number of times to read I/O port.
348 @param Buffer The buffer to store the read data into.
363 Writes a block of memory into a 32-bit I/O port fifo.
365 Writes the 32-bit I/O fifo port specified by Port.
366 The port is written Count times, and the write data is
367 retrieved from the provided Buffer.
369 This function must guarantee that all I/O write and write operations are
372 If 32-bit I/O port operations are not supported, then ASSERT().
374 @param Port The I/O port to write.
375 @param Count The number of times to write I/O port.
376 @param Buffer The buffer to retrieve the write data from.
391 Reads an 8-bit MMIO register.
393 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
394 returned. This function must guarantee that all MMIO read and write
395 operations are serialized.
397 If 8-bit MMIO register operations are not supported, then ASSERT().
399 @param Address The MMIO register to read.
401 @return The value read.
413 Flag
= FilterBeforeMmIoRead (FilterWidth8
, Address
, &Value
);
415 Value
= *(volatile UINT8
*)Address
;
418 FilterAfterMmIoRead (FilterWidth8
, Address
, &Value
);
424 Writes an 8-bit MMIO register.
426 Writes the 8-bit MMIO register specified by Address with the value specified
427 by Value and returns Value. This function must guarantee that all MMIO read
428 and write operations are serialized.
430 If 8-bit MMIO register operations are not supported, then ASSERT().
432 @param Address The MMIO register to write.
433 @param Value The value to write to the MMIO register.
445 Flag
= FilterBeforeMmIoWrite (FilterWidth8
, Address
, &Value
);
447 *(volatile UINT8
*)Address
= Value
;
450 FilterAfterMmIoWrite (FilterWidth8
, Address
, &Value
);
456 Reads a 16-bit MMIO register.
458 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
459 returned. This function must guarantee that all MMIO read and write
460 operations are serialized.
462 If 16-bit MMIO register operations are not supported, then ASSERT().
464 @param Address The MMIO register to read.
466 @return The value read.
478 ASSERT ((Address
& 1) == 0);
480 Flag
= FilterBeforeMmIoRead (FilterWidth16
, Address
, &Value
);
482 Value
= *(volatile UINT16
*)Address
;
485 FilterAfterMmIoRead (FilterWidth16
, Address
, &Value
);
491 Writes a 16-bit MMIO register.
493 Writes the 16-bit MMIO register specified by Address with the value specified
494 by Value and returns Value. This function must guarantee that all MMIO read
495 and write operations are serialized.
497 If 16-bit MMIO register operations are not supported, then ASSERT().
499 @param Address The MMIO register to write.
500 @param Value The value to write to the MMIO register.
512 ASSERT ((Address
& 1) == 0);
514 Flag
= FilterBeforeMmIoWrite (FilterWidth16
, Address
, &Value
);
516 *(volatile UINT16
*)Address
= Value
;
519 FilterAfterMmIoWrite (FilterWidth16
, Address
, &Value
);
525 Reads a 32-bit MMIO register.
527 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
528 returned. This function must guarantee that all MMIO read and write
529 operations are serialized.
531 If 32-bit MMIO register operations are not supported, then ASSERT().
533 @param Address The MMIO register to read.
535 @return The value read.
547 ASSERT ((Address
& 3) == 0);
549 Flag
= FilterBeforeMmIoRead (FilterWidth32
, Address
, &Value
);
551 Value
= *(volatile UINT32
*)Address
;
554 FilterAfterMmIoRead (FilterWidth32
, Address
, &Value
);
560 Writes a 32-bit MMIO register.
562 Writes the 32-bit MMIO register specified by Address with the value specified
563 by Value and returns Value. This function must guarantee that all MMIO read
564 and write operations are serialized.
566 If 32-bit MMIO register operations are not supported, then ASSERT().
568 @param Address The MMIO register to write.
569 @param Value The value to write to the MMIO register.
581 ASSERT ((Address
& 3) == 0);
583 Flag
= FilterBeforeMmIoWrite (FilterWidth32
, Address
, &Value
);
585 *(volatile UINT32
*)Address
= Value
;
588 FilterAfterMmIoWrite (FilterWidth32
, Address
, &Value
);
594 Reads a 64-bit MMIO register.
596 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
597 returned. This function must guarantee that all MMIO read and write
598 operations are serialized.
600 If 64-bit MMIO register operations are not supported, then ASSERT().
602 @param Address The MMIO register to read.
604 @return The value read.
616 ASSERT ((Address
& 7) == 0);
618 Flag
= FilterBeforeMmIoRead (FilterWidth64
, Address
, &Value
);
620 Value
= *(volatile UINT64
*)Address
;
623 FilterAfterMmIoRead (FilterWidth64
, Address
, &Value
);
629 Writes a 64-bit MMIO register.
631 Writes the 64-bit MMIO register specified by Address with the value specified
632 by Value and returns Value. This function must guarantee that all MMIO read
633 and write operations are serialized.
635 If 64-bit MMIO register operations are not supported, then ASSERT().
637 @param Address The MMIO register to write.
638 @param Value The value to write to the MMIO register.
650 ASSERT ((Address
& 7) == 0);
652 Flag
= FilterBeforeMmIoWrite (FilterWidth64
, Address
, &Value
);
654 *(volatile UINT64
*)Address
= Value
;
657 FilterAfterMmIoWrite (FilterWidth64
, Address
, &Value
);