]>
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"
12 Reads a 64-bit I/O port.
14 Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
15 This function must guarantee that all I/O read and write operations are
18 If 64-bit I/O port operations are not supported, then ASSERT().
19 If Port is not aligned on a 64-bit boundary, then ASSERT().
21 @param Port The I/O port to read.
23 @return The value read.
37 Writes a 64-bit I/O port.
39 Writes the 64-bit I/O port specified by Port with the value specified by Value
40 and returns Value. This function must guarantee that all I/O read and write
41 operations are serialized.
43 If 64-bit I/O port operations are not supported, then ASSERT().
44 If Port is not aligned on a 64-bit boundary, then ASSERT().
46 @param Port The I/O port to write.
47 @param Value The value to write to the I/O port.
49 @return The value written the I/O port.
64 Reads an 8-bit MMIO register.
66 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
67 returned. This function must guarantee that all MMIO read and write
68 operations are serialized.
70 If 8-bit MMIO register operations are not supported, then ASSERT().
72 @param Address The MMIO register to read.
74 @return The value read.
86 Flag
= FilterBeforeMmIoRead (FilterWidth8
, Address
, &Value
);
89 Value
= *(volatile UINT8
*)Address
;
93 FilterAfterMmIoRead (FilterWidth8
, Address
, &Value
);
99 Writes an 8-bit MMIO register.
101 Writes the 8-bit MMIO register specified by Address with the value specified
102 by Value and returns Value. This function must guarantee that all MMIO read
103 and write operations are serialized.
105 If 8-bit MMIO register operations are not supported, then ASSERT().
107 @param Address The MMIO register to write.
108 @param Value The value to write to the MMIO register.
122 Flag
= FilterBeforeMmIoWrite (FilterWidth8
, Address
, &Value
);
125 *(volatile UINT8
*)Address
= Value
;
129 FilterAfterMmIoWrite (FilterWidth8
, Address
, &Value
);
135 Reads a 16-bit MMIO register.
137 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
138 returned. This function must guarantee that all MMIO read and write
139 operations are serialized.
141 If 16-bit MMIO register operations are not supported, then ASSERT().
142 If Address is not aligned on a 16-bit boundary, then ASSERT().
144 @param Address The MMIO register to read.
146 @return The value read.
158 ASSERT ((Address
& 1) == 0);
159 Flag
= FilterBeforeMmIoRead (FilterWidth16
, Address
, &Value
);
162 Value
= *(volatile UINT16
*)Address
;
166 FilterAfterMmIoRead (FilterWidth16
, Address
, &Value
);
172 Writes a 16-bit MMIO register.
174 Writes the 16-bit MMIO register specified by Address with the value specified
175 by Value and returns Value. This function must guarantee that all MMIO read
176 and write operations are serialized.
178 If 16-bit MMIO register operations are not supported, then ASSERT().
179 If Address is not aligned on a 16-bit boundary, then ASSERT().
181 @param Address The MMIO register to write.
182 @param Value The value to write to the MMIO register.
196 ASSERT ((Address
& 1) == 0);
198 Flag
= FilterBeforeMmIoWrite (FilterWidth16
, Address
, &Value
);
201 *(volatile UINT16
*)Address
= Value
;
205 FilterAfterMmIoWrite (FilterWidth16
, Address
, &Value
);
211 Reads a 32-bit MMIO register.
213 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
214 returned. This function must guarantee that all MMIO read and write
215 operations are serialized.
217 If 32-bit MMIO register operations are not supported, then ASSERT().
218 If Address is not aligned on a 32-bit boundary, then ASSERT().
220 @param Address The MMIO register to read.
222 @return The value read.
234 ASSERT ((Address
& 3) == 0);
236 Flag
= FilterBeforeMmIoRead (FilterWidth32
, Address
, &Value
);
239 Value
= *(volatile UINT32
*)Address
;
243 FilterAfterMmIoRead (FilterWidth32
, Address
, &Value
);
249 Writes a 32-bit MMIO register.
251 Writes the 32-bit MMIO register specified by Address with the value specified
252 by Value and returns Value. This function must guarantee that all MMIO read
253 and write operations are serialized.
255 If 32-bit MMIO register operations are not supported, then ASSERT().
256 If Address is not aligned on a 32-bit boundary, then ASSERT().
258 @param Address The MMIO register to write.
259 @param Value The value to write to the MMIO register.
273 ASSERT ((Address
& 3) == 0);
275 Flag
= FilterBeforeMmIoWrite (FilterWidth32
, Address
, &Value
);
278 *(volatile UINT32
*)Address
= Value
;
282 FilterAfterMmIoWrite (FilterWidth32
, Address
, &Value
);
288 Reads a 64-bit MMIO register.
290 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
291 returned. This function must guarantee that all MMIO read and write
292 operations are serialized.
294 If 64-bit MMIO register operations are not supported, then ASSERT().
295 If Address is not aligned on a 64-bit boundary, then ASSERT().
297 @param Address The MMIO register to read.
299 @return The value read.
311 ASSERT ((Address
& 7) == 0);
313 Flag
= FilterBeforeMmIoRead (FilterWidth64
, Address
, &Value
);
316 Value
= *(volatile UINT64
*)Address
;
320 FilterAfterMmIoRead (FilterWidth64
, Address
, &Value
);
326 Writes a 64-bit MMIO register.
328 Writes the 64-bit MMIO register specified by Address with the value specified
329 by Value and returns Value. This function must guarantee that all MMIO read
330 and write operations are serialized.
332 If 64-bit MMIO register operations are not supported, then ASSERT().
333 If Address is not aligned on a 64-bit boundary, then ASSERT().
335 @param Address The MMIO register to write.
336 @param Value The value to write to the MMIO register.
348 ASSERT ((Address
& 7) == 0);
350 Flag
= FilterBeforeMmIoWrite (FilterWidth64
, Address
, &Value
);
353 *(volatile UINT64
*)Address
= Value
;
357 FilterAfterMmIoWrite (FilterWidth64
, Address
, &Value
);