]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoLib.c
d0d7044f0901fd95e30a7b2e766d371f437dc1ab
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.
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 @param Address The MMIO register to read.
75 @return The value read.
87 Flag
= FilterBeforeMmIoRead (FilterWidth8
, Address
, &Value
);
90 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
;
128 FilterAfterMmIoWrite (FilterWidth8
, Address
, &Value
);
134 Reads a 16-bit MMIO register.
136 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
137 returned. This function must guarantee that all MMIO read and write
138 operations are serialized.
140 If 16-bit MMIO register operations are not supported, then ASSERT().
141 If Address is not aligned on a 16-bit boundary, then ASSERT().
143 @param Address The MMIO register to read.
145 @return The value read.
157 ASSERT ((Address
& 1) == 0);
158 Flag
= FilterBeforeMmIoRead (FilterWidth16
, Address
, &Value
);
161 Value
= *(volatile UINT16
*)Address
;
164 FilterAfterMmIoRead (FilterWidth16
, Address
, &Value
);
170 Writes a 16-bit MMIO register.
172 Writes the 16-bit MMIO register specified by Address with the value specified
173 by Value and returns Value. This function must guarantee that all MMIO read
174 and write operations are serialized.
176 If 16-bit MMIO register operations are not supported, then ASSERT().
177 If Address is not aligned on a 16-bit boundary, then ASSERT().
179 @param Address The MMIO register to write.
180 @param Value The value to write to the MMIO register.
194 ASSERT ((Address
& 1) == 0);
196 Flag
= FilterBeforeMmIoWrite (FilterWidth16
, Address
, &Value
);
199 *(volatile UINT16
*)Address
= Value
;
202 FilterAfterMmIoWrite (FilterWidth16
, Address
, &Value
);
208 Reads a 32-bit MMIO register.
210 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
211 returned. This function must guarantee that all MMIO read and write
212 operations are serialized.
214 If 32-bit MMIO register operations are not supported, then ASSERT().
215 If Address is not aligned on a 32-bit boundary, then ASSERT().
217 @param Address The MMIO register to read.
219 @return The value read.
231 ASSERT ((Address
& 3) == 0);
233 Flag
= FilterBeforeMmIoRead (FilterWidth32
, Address
, &Value
);
236 Value
= *(volatile UINT32
*)Address
;
239 FilterAfterMmIoRead (FilterWidth32
, Address
, &Value
);
245 Writes a 32-bit MMIO register.
247 Writes the 32-bit MMIO register specified by Address with the value specified
248 by Value and returns Value. This function must guarantee that all MMIO read
249 and write operations are serialized.
251 If 32-bit MMIO register operations are not supported, then ASSERT().
252 If Address is not aligned on a 32-bit boundary, then ASSERT().
254 @param Address The MMIO register to write.
255 @param Value The value to write to the MMIO register.
269 ASSERT ((Address
& 3) == 0);
271 Flag
= FilterBeforeMmIoWrite (FilterWidth32
, Address
, &Value
);
274 *(volatile UINT32
*)Address
= Value
;
277 FilterAfterMmIoWrite (FilterWidth32
, Address
, &Value
);
283 Reads a 64-bit MMIO register.
285 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
286 returned. This function must guarantee that all MMIO read and write
287 operations are serialized.
289 If 64-bit MMIO register operations are not supported, then ASSERT().
290 If Address is not aligned on a 64-bit boundary, then ASSERT().
292 @param Address The MMIO register to read.
294 @return The value read.
306 ASSERT ((Address
& 7) == 0);
308 Flag
= FilterBeforeMmIoRead (FilterWidth64
, Address
, &Value
);
311 Value
= *(volatile UINT64
*)Address
;
314 FilterAfterMmIoRead (FilterWidth64
, Address
, &Value
);
320 Writes a 64-bit MMIO register.
322 Writes the 64-bit MMIO register specified by Address with the value specified
323 by Value and returns Value. This function must guarantee that all MMIO read
324 and write operations are serialized.
326 If 64-bit MMIO register operations are not supported, then ASSERT().
327 If Address is not aligned on a 64-bit boundary, then ASSERT().
329 @param Address The MMIO register to write.
330 @param Value The value to write to the MMIO register.
342 ASSERT ((Address
& 7) == 0);
344 Flag
= FilterBeforeMmIoWrite (FilterWidth64
, Address
, &Value
);
347 *(volatile UINT64
*)Address
= Value
;
350 FilterAfterMmIoWrite (FilterWidth64
, Address
, &Value
);