]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/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 - 2008, Intel Corporation<BR> All rights
6 reserved. 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.
16 #include "BaseIoLibIntrinsicInternal.h"
19 Reads an 8-bit MMIO register.
21 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
22 returned. This function must guarantee that all MMIO read and write
23 operations are serialized.
25 If 8-bit MMIO register operations are not supported, then ASSERT().
27 @param Address The MMIO register to read.
29 @return The value read from Address.
38 return *(volatile UINT8
*)Address
;
42 Writes an 8-bit MMIO register.
44 Writes the 8-bit MMIO register specified by Address with the value specified
45 by Value and returns Value. This function must guarantee that all MMIO read
46 and write operations are serialized.
48 If 8-bit MMIO register operations are not supported, then ASSERT().
50 @param Address The MMIO register to write.
51 @param Value The value to write to the MMIO register.
53 @return The value written to the Mmio. It equals to the input
54 Value instead of the actual value read back from the
65 return *(volatile UINT8
*)Address
= Value
;
69 Reads a 16-bit MMIO register.
71 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
72 returned. This function must guarantee that all MMIO read and write
73 operations are serialized.
75 If 16-bit MMIO register operations are not supported, then ASSERT().
77 @param Address The MMIO register to read.
79 @return The value read from Address.
88 ASSERT ((Address
& 1) == 0);
89 return *(volatile UINT16
*)Address
;
93 Writes a 16-bit MMIO register.
95 Writes the 16-bit MMIO register specified by Address with the value specified
96 by Value and returns Value. This function must guarantee that all MMIO read
97 and write operations are serialized.
99 If 16-bit MMIO register operations are not supported, then ASSERT().
101 @param Address The MMIO register to write.
102 @param Value The value to write to the MMIO register.
104 @return The value written to the Mmio. It equals to the input
105 Value instead of the actual value read back from the
116 ASSERT ((Address
& 1) == 0);
117 return *(volatile UINT16
*)Address
= Value
;
121 Reads a 32-bit MMIO register.
123 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
124 returned. This function must guarantee that all MMIO read and write
125 operations are serialized.
127 If 32-bit MMIO register operations are not supported, then ASSERT().
129 @param Address The MMIO register to read.
131 @return The value read from Address.
140 ASSERT ((Address
& 3) == 0);
141 return *(volatile UINT32
*)Address
;
145 Writes a 32-bit MMIO register.
147 Writes the 32-bit MMIO register specified by Address with the value specified
148 by Value and returns Value. This function must guarantee that all MMIO read
149 and write operations are serialized.
151 If 32-bit MMIO register operations are not supported, then ASSERT().
153 @param Address The MMIO register to write.
154 @param Value The value to write to the MMIO register.
156 @return The value written to the Mmio. It equals to the input
157 Value instead of the actual value read back from the
168 ASSERT ((Address
& 3) == 0);
169 return *(volatile UINT32
*)Address
= Value
;
173 Reads a 64-bit MMIO register.
175 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
176 returned. This function must guarantee that all MMIO read and write
177 operations are serialized.
179 If 64-bit MMIO register operations are not supported, then ASSERT().
181 @param Address The MMIO register to read.
183 @return The value read from Address.
192 ASSERT ((Address
& 7) == 0);
193 return *(volatile UINT64
*)Address
;
197 Writes a 64-bit MMIO register.
199 Writes the 64-bit MMIO register specified by Address with the value specified
200 by Value and returns Value. This function must guarantee that all MMIO read
201 and write operations are serialized.
203 If 64-bit MMIO register operations are not supported, then ASSERT().
205 @param Address The MMIO register to write.
206 @param Value The value to write to the MMIO register.
208 @return The value written to the Mmio. It equals to the input
209 Value instead of the actual value read back from the
219 ASSERT ((Address
& 7) == 0);
220 return *(volatile UINT64
*)Address
= Value
;
226 Reads an 8-bit I/O port.
228 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
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.
236 @return The value read from Port.
248 mov dx
, word ptr
[Port
]
257 Writes an 8-bit I/O port.
259 Writes the 8-bit I/O port specified by Port with the value specified by Value
260 and returns Value. This function must guarantee that all I/O read and write
261 operations are serialized.
263 If 8-bit I/O port operations are not supported, then ASSERT().
265 @param Port The I/O port to write.
266 @param Value The value to write to the I/O port.
268 @return The value written to the I/O port. It equals to the input
269 Value instead of the actual value read back from the
281 mov al
, byte ptr
[Value
]
282 mov dx
, word ptr
[Port
]
289 Reads a 16-bit I/O port.
291 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
292 This function must guarantee that all I/O read and write operations are
295 If 16-bit I/O port operations are not supported, then ASSERT().
297 @param Port The I/O port to read.
299 @return The value read from Port.
310 ASSERT ((Port
& 1) == 0);
313 mov dx
, word ptr
[Port
]
315 mov word ptr
[Data
], ax
322 Writes a 16-bit I/O port.
324 Writes the 16-bit I/O port specified by Port with the value specified by Value
325 and returns Value. This function must guarantee that all I/O read and write
326 operations are serialized.
328 If 16-bit I/O port operations are not supported, then ASSERT().
330 @param Port The I/O port to write.
331 @param Value The value to write to the I/O port.
333 @return The value written to the I/O port. It equals to the input
334 Value instead of the actual value read back from the
345 ASSERT ((Port
& 1) == 0);
348 mov ax
, word ptr
[Value
]
349 mov dx
, word ptr
[Port
]
357 Reads a 32-bit I/O port.
359 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
360 This function must guarantee that all I/O read and write operations are
363 If 32-bit I/O port operations are not supported, then ASSERT().
365 @param Port The I/O port to read.
367 @return The value read from Port.
378 ASSERT ((Port
& 3) == 0);
381 mov dx
, word ptr
[Port
]
383 mov dword ptr
[Data
], eax
390 Writes a 32-bit I/O port.
392 Writes the 32-bit I/O port specified by Port with the value specified by Value
393 and returns Value. This function must guarantee that all I/O read and write
394 operations are serialized.
396 If 32-bit I/O port operations are not supported, then ASSERT().
398 @param Port The I/O port to write.
399 @param Value The value to write to the I/O port.
401 @return The value written to the I/O port. It equals to the input
402 Value instead of the actual value read back from the
413 ASSERT ((Port
& 3) == 0);
416 mov eax
, dword ptr
[Value
]
417 mov dx
, word ptr
[Port
]