]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIcc.c
2 I/O Library. This file has compiler specifics for ICC as there
3 is no ANSI C standard for doing IO.
5 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are
7 licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "BaseIoLibIntrinsicInternal.h"
18 Reads an 8-bit MMIO register.
20 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
21 returned. This function must guarantee that all MMIO read and write
22 operations are serialized.
24 If 8-bit MMIO register operations are not supported, then ASSERT().
26 @param Address The MMIO register to read.
28 @return The value read.
37 return *(volatile UINT8
*)Address
;
41 Writes an 8-bit MMIO register.
43 Writes the 8-bit MMIO register specified by Address with the value specified
44 by Value and returns Value. This function must guarantee that all MMIO read
45 and write operations are serialized.
47 If 8-bit MMIO register operations are not supported, then ASSERT().
49 @param Address The MMIO register to write.
50 @param Value The value to write to the MMIO register.
60 return *(volatile UINT8
*)Address
= Value
;
64 Reads a 16-bit MMIO register.
66 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
67 returned. This function must guarantee that all MMIO read and write
68 operations are serialized.
70 If 16-bit MMIO register operations are not supported, then ASSERT().
72 @param Address The MMIO register to read.
74 @return The value read.
83 ASSERT ((Address
& 1) == 0);
84 return *(volatile UINT16
*)Address
;
88 Writes a 16-bit MMIO register.
90 Writes the 16-bit MMIO register specified by Address with the value specified
91 by Value and returns Value. This function must guarantee that all MMIO read
92 and write operations are serialized.
94 If 16-bit MMIO register operations are not supported, then ASSERT().
96 @param Address The MMIO register to write.
97 @param Value The value to write to the MMIO register.
107 ASSERT ((Address
& 1) == 0);
108 return *(volatile UINT16
*)Address
= Value
;
112 Reads a 32-bit MMIO register.
114 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
115 returned. This function must guarantee that all MMIO read and write
116 operations are serialized.
118 If 32-bit MMIO register operations are not supported, then ASSERT().
120 @param Address The MMIO register to read.
122 @return The value read.
131 ASSERT ((Address
& 3) == 0);
132 return *(volatile UINT32
*)Address
;
136 Writes a 32-bit MMIO register.
138 Writes the 32-bit MMIO register specified by Address with the value specified
139 by Value and returns Value. This function must guarantee that all MMIO read
140 and write operations are serialized.
142 If 32-bit MMIO register operations are not supported, then ASSERT().
144 @param Address The MMIO register to write.
145 @param Value The value to write to the MMIO register.
155 ASSERT ((Address
& 3) == 0);
156 return *(volatile UINT32
*)Address
= Value
;
160 Reads a 64-bit MMIO register.
162 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
163 returned. This function must guarantee that all MMIO read and write
164 operations are serialized.
166 If 64-bit MMIO register operations are not supported, then ASSERT().
168 @param Address The MMIO register to read.
170 @return The value read.
179 ASSERT ((Address
& 7) == 0);
180 return *(volatile UINT64
*)Address
;
184 Writes a 64-bit MMIO register.
186 Writes the 64-bit MMIO register specified by Address with the value specified
187 by Value and returns Value. This function must guarantee that all MMIO read
188 and write operations are serialized.
190 If 64-bit MMIO register operations are not supported, then ASSERT().
192 @param Address The MMIO register to write.
193 @param Value The value to write to the MMIO register.
203 ASSERT ((Address
& 7) == 0);
204 return *(volatile UINT64
*)Address
= Value
;
210 Reads an 8-bit I/O port.
212 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
213 This function must guarantee that all I/O read and write operations are
216 If 8-bit I/O port operations are not supported, then ASSERT().
218 @param Port The I/O port to read.
220 @return The value read.
232 mov dx
, word ptr
[Port
]
241 Writes an 8-bit I/O port.
243 Writes the 8-bit I/O port specified by Port with the value specified by Value
244 and returns Value. This function must guarantee that all I/O read and write
245 operations are serialized.
247 If 8-bit I/O port operations are not supported, then ASSERT().
249 @param Port The I/O port to write.
250 @param Value The value to write to the I/O port.
252 @return The value written the I/O port.
263 mov al
, byte ptr
[Value
]
264 mov dx
, word ptr
[Port
]
271 Reads a 16-bit I/O port.
273 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
274 This function must guarantee that all I/O read and write operations are
277 If 16-bit I/O port operations are not supported, then ASSERT().
279 @param Port The I/O port to read.
281 @return The value read.
292 ASSERT ((Port
& 1) == 0);
295 mov dx
, word ptr
[Port
]
297 mov word ptr
[Data
], ax
304 Writes a 16-bit I/O port.
306 Writes the 16-bit I/O port specified by Port with the value specified by Value
307 and returns Value. This function must guarantee that all I/O read and write
308 operations are serialized.
310 If 16-bit I/O port operations are not supported, then ASSERT().
312 @param Port The I/O port to write.
313 @param Value The value to write to the I/O port.
315 @return The value written the I/O port.
325 ASSERT ((Port
& 1) == 0);
328 mov ax
, word ptr
[Value
]
329 mov dx
, word ptr
[Port
]
334 // Never reached return statement.
340 Reads a 32-bit I/O port.
342 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
343 This function must guarantee that all I/O read and write operations are
346 If 32-bit I/O port operations are not supported, then ASSERT().
348 @param Port The I/O port to read.
350 @return The value read.
361 ASSERT ((Port
& 3) == 0);
364 mov dx
, word ptr
[Port
]
366 mov dword ptr
[Data
], eax
373 Writes a 32-bit I/O port.
375 Writes the 32-bit I/O port specified by Port with the value specified by Value
376 and returns Value. This function must guarantee that all I/O read and write
377 operations are serialized.
379 If 32-bit I/O port operations are not supported, then ASSERT().
381 @param Port The I/O port to write.
382 @param Value The value to write to the I/O port.
384 @return The value written the I/O port.
394 ASSERT ((Port
& 3) == 0);
397 mov eax
, dword ptr
[Value
]
398 mov dx
, word ptr
[Port
]