]>
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 and RISC-V 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>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
15 // Include common header file for this module.
17 #include "BaseIoLibIntrinsicInternal.h"
20 Reads an 8-bit I/O port.
22 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
23 This function must guarantee that all I/O read and write operations are
26 If 8-bit I/O port operations are not supported, then ASSERT().
28 @param Port The I/O port to read.
30 @return The value read.
44 Writes an 8-bit I/O port.
46 Writes the 8-bit I/O port specified by Port with the value specified by Value
47 and returns Value. This function must guarantee that all I/O read and write
48 operations are serialized.
50 If 8-bit I/O port operations are not supported, then ASSERT().
52 @param Port The I/O port to write.
53 @param Value The value to write to the I/O port.
55 @return The value written the I/O port.
70 Reads a 16-bit I/O port.
72 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
73 This function must guarantee that all I/O read and write operations are
76 If 16-bit I/O port operations are not supported, then ASSERT().
78 @param Port The I/O port to read.
80 @return The value read.
94 Writes a 16-bit I/O port.
96 Writes the 16-bit I/O port specified by Port with the value specified by Value
97 and returns Value. This function must guarantee that all I/O read and write
98 operations are serialized.
100 If 16-bit I/O port operations are not supported, then ASSERT().
102 @param Port The I/O port to write.
103 @param Value The value to write to the I/O port.
105 @return The value written the I/O port.
120 Reads a 32-bit I/O port.
122 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
123 This function must guarantee that all I/O read and write operations are
126 If 32-bit I/O port operations are not supported, then ASSERT().
128 @param Port The I/O port to read.
130 @return The value read.
144 Writes a 32-bit I/O port.
146 Writes the 32-bit I/O port specified by Port with the value specified by Value
147 and returns Value. This function must guarantee that all I/O read and write
148 operations are serialized.
150 If 32-bit I/O port operations are not supported, then ASSERT().
152 @param Port The I/O port to write.
153 @param Value The value to write to the I/O port.
155 @return The value written the I/O port.
170 Reads a 64-bit I/O port.
172 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
173 This function must guarantee that all I/O read and write operations are
176 If 64-bit I/O port operations are not supported, then ASSERT().
177 If Port is not aligned on a 64-bit boundary, then ASSERT().
179 @param Port The I/O port to read.
181 @return The value read.
195 Writes a 64-bit I/O port.
197 Writes the 64-bit I/O port specified by Port with the value specified by Value
198 and returns Value. This function must guarantee that all I/O read and write
199 operations are serialized.
201 If 64-bit I/O port operations are not supported, then ASSERT().
202 If Port is not aligned on a 64-bit boundary, then ASSERT().
204 @param Port The I/O port to write.
205 @param Value The value to write to the I/O port.
207 @return The value written to the I/O port.
222 Reads an 8-bit I/O port fifo into a block of memory.
224 Reads the 8-bit I/O fifo port specified by Port.
225 The port is read Count times, and the read data is
226 stored in the provided Buffer.
228 This function must guarantee that all I/O read and write operations are
231 If 8-bit I/O port operations are not supported, then ASSERT().
233 @param Port The I/O port to read.
234 @param Count The number of times to read I/O port.
235 @param Buffer The buffer to store the read data into.
250 Writes a block of memory into an 8-bit I/O port fifo.
252 Writes the 8-bit I/O fifo port specified by Port.
253 The port is written Count times, and the write data is
254 retrieved from the provided Buffer.
256 This function must guarantee that all I/O write and write operations are
259 If 8-bit I/O port operations are not supported, then ASSERT().
261 @param Port The I/O port to write.
262 @param Count The number of times to write I/O port.
263 @param Buffer The buffer to retrieve the write data from.
278 Reads a 16-bit I/O port fifo into a block of memory.
280 Reads the 16-bit I/O fifo port specified by Port.
281 The port is read Count times, and the read data is
282 stored in the provided Buffer.
284 This function must guarantee that all I/O read and write operations are
287 If 16-bit I/O port operations are not supported, then ASSERT().
289 @param Port The I/O port to read.
290 @param Count The number of times to read I/O port.
291 @param Buffer The buffer to store the read data into.
306 Writes a block of memory into a 16-bit I/O port fifo.
308 Writes the 16-bit I/O fifo port specified by Port.
309 The port is written Count times, and the write data is
310 retrieved from the provided Buffer.
312 This function must guarantee that all I/O write and write operations are
315 If 16-bit I/O port operations are not supported, then ASSERT().
317 @param Port The I/O port to write.
318 @param Count The number of times to write I/O port.
319 @param Buffer The buffer to retrieve the write data from.
334 Reads a 32-bit I/O port fifo into a block of memory.
336 Reads the 32-bit I/O fifo port specified by Port.
337 The port is read Count times, and the read data is
338 stored in the provided Buffer.
340 This function must guarantee that all I/O read and write operations are
343 If 32-bit I/O port operations are not supported, then ASSERT().
345 @param Port The I/O port to read.
346 @param Count The number of times to read I/O port.
347 @param Buffer The buffer to store the read data into.
362 Writes a block of memory into a 32-bit I/O port fifo.
364 Writes the 32-bit I/O fifo port specified by Port.
365 The port is written Count times, and the write data is
366 retrieved from the provided Buffer.
368 This function must guarantee that all I/O write and write operations are
371 If 32-bit I/O port operations are not supported, then ASSERT().
373 @param Port The I/O port to write.
374 @param Count The number of times to write I/O port.
375 @param Buffer The buffer to retrieve the write data from.
390 Reads an 8-bit MMIO register.
392 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
393 returned. This function must guarantee that all MMIO read and write
394 operations are serialized.
396 If 8-bit MMIO register operations are not supported, then ASSERT().
398 @param Address The MMIO register to read.
400 @return The value read.
412 Flag
= FilterBeforeMmIoRead (FilterWidth8
, Address
, &Value
);
414 Value
= *(volatile UINT8
*)Address
;
417 FilterAfterMmIoRead (FilterWidth8
, Address
, &Value
);
423 Writes an 8-bit MMIO register.
425 Writes the 8-bit MMIO register specified by Address with the value specified
426 by Value and returns Value. This function must guarantee that all MMIO read
427 and write operations are serialized.
429 If 8-bit MMIO register operations are not supported, then ASSERT().
431 @param Address The MMIO register to write.
432 @param Value The value to write to the MMIO register.
444 Flag
= FilterBeforeMmIoWrite (FilterWidth8
, Address
, &Value
);
446 *(volatile UINT8
*)Address
= Value
;
449 FilterAfterMmIoWrite (FilterWidth8
, Address
, &Value
);
455 Reads a 16-bit MMIO register.
457 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
458 returned. This function must guarantee that all MMIO read and write
459 operations are serialized.
461 If 16-bit MMIO register operations are not supported, then ASSERT().
463 @param Address The MMIO register to read.
465 @return The value read.
477 ASSERT ((Address
& 1) == 0);
479 Flag
= FilterBeforeMmIoRead (FilterWidth16
, Address
, &Value
);
481 Value
= *(volatile UINT16
*)Address
;
484 FilterAfterMmIoRead (FilterWidth16
, Address
, &Value
);
490 Writes a 16-bit MMIO register.
492 Writes the 16-bit MMIO register specified by Address with the value specified
493 by Value and returns Value. This function must guarantee that all MMIO read
494 and write operations are serialized.
496 If 16-bit MMIO register operations are not supported, then ASSERT().
498 @param Address The MMIO register to write.
499 @param Value The value to write to the MMIO register.
511 ASSERT ((Address
& 1) == 0);
513 Flag
= FilterBeforeMmIoWrite (FilterWidth16
, Address
, &Value
);
515 *(volatile UINT16
*)Address
= Value
;
518 FilterAfterMmIoWrite (FilterWidth16
, Address
, &Value
);
524 Reads a 32-bit MMIO register.
526 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
527 returned. This function must guarantee that all MMIO read and write
528 operations are serialized.
530 If 32-bit MMIO register operations are not supported, then ASSERT().
532 @param Address The MMIO register to read.
534 @return The value read.
546 ASSERT ((Address
& 3) == 0);
548 Flag
= FilterBeforeMmIoRead (FilterWidth32
, Address
, &Value
);
550 Value
= *(volatile UINT32
*)Address
;
553 FilterAfterMmIoRead (FilterWidth32
, Address
, &Value
);
559 Writes a 32-bit MMIO register.
561 Writes the 32-bit MMIO register specified by Address with the value specified
562 by Value and returns Value. This function must guarantee that all MMIO read
563 and write operations are serialized.
565 If 32-bit MMIO register operations are not supported, then ASSERT().
567 @param Address The MMIO register to write.
568 @param Value The value to write to the MMIO register.
580 ASSERT ((Address
& 3) == 0);
582 Flag
= FilterBeforeMmIoWrite (FilterWidth32
, Address
, &Value
);
584 *(volatile UINT32
*)Address
= Value
;
587 FilterAfterMmIoWrite (FilterWidth32
, Address
, &Value
);
593 Reads a 64-bit MMIO register.
595 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
596 returned. This function must guarantee that all MMIO read and write
597 operations are serialized.
599 If 64-bit MMIO register operations are not supported, then ASSERT().
601 @param Address The MMIO register to read.
603 @return The value read.
615 ASSERT ((Address
& 7) == 0);
617 Flag
= FilterBeforeMmIoRead (FilterWidth64
, Address
, &Value
);
619 Value
= *(volatile UINT64
*)Address
;
622 FilterAfterMmIoRead (FilterWidth64
, Address
, &Value
);
628 Writes a 64-bit MMIO register.
630 Writes the 64-bit MMIO register specified by Address with the value specified
631 by Value and returns Value. This function must guarantee that all MMIO read
632 and write operations are serialized.
634 If 64-bit MMIO register operations are not supported, then ASSERT().
636 @param Address The MMIO register to write.
637 @param Value The value to write to the MMIO register.
649 ASSERT ((Address
& 7) == 0);
651 Flag
= FilterBeforeMmIoWrite (FilterWidth64
, Address
, &Value
);
653 *(volatile UINT64
*)Address
= Value
;
656 FilterAfterMmIoWrite (FilterWidth64
, Address
, &Value
);