]>
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.
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.
63 return *(volatile UINT8
*)Address
= Value
;
67 Reads a 16-bit MMIO register.
69 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
70 returned. This function must guarantee that all MMIO read and write
71 operations are serialized.
73 If 16-bit MMIO register operations are not supported, then ASSERT().
74 If Address is not aligned on a 16-bit boundary, then ASSERT().
76 @param Address The MMIO register to read.
78 @return The value read.
87 ASSERT ((Address
& 1) == 0);
88 return *(volatile UINT16
*)Address
;
92 Writes a 16-bit MMIO register.
94 Writes the 16-bit MMIO register specified by Address with the value specified
95 by Value and returns Value. This function must guarantee that all MMIO read
96 and write operations are serialized.
98 If 16-bit MMIO register operations are not supported, then ASSERT().
99 If Address is not aligned on a 16-bit boundary, then ASSERT().
101 @param Address The MMIO register to write.
102 @param Value The value to write to the MMIO register.
114 ASSERT ((Address
& 1) == 0);
115 return *(volatile UINT16
*)Address
= Value
;
119 Reads a 32-bit MMIO register.
121 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
122 returned. This function must guarantee that all MMIO read and write
123 operations are serialized.
125 If 32-bit MMIO register operations are not supported, then ASSERT().
126 If Address is not aligned on a 32-bit boundary, then ASSERT().
128 @param Address The MMIO register to read.
130 @return The value read.
139 ASSERT ((Address
& 3) == 0);
140 return *(volatile UINT32
*)Address
;
144 Writes a 32-bit MMIO register.
146 Writes the 32-bit MMIO register specified by Address with the value specified
147 by Value and returns Value. This function must guarantee that all MMIO read
148 and write operations are serialized.
150 If 32-bit MMIO register operations are not supported, then ASSERT().
151 If Address is not aligned on a 32-bit boundary, then ASSERT().
153 @param Address The MMIO register to write.
154 @param Value The value to write to the MMIO register.
166 ASSERT ((Address
& 3) == 0);
167 return *(volatile UINT32
*)Address
= Value
;
171 Reads a 64-bit MMIO register.
173 Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
174 returned. This function must guarantee that all MMIO read and write
175 operations are serialized.
177 If 64-bit MMIO register operations are not supported, then ASSERT().
178 If Address is not aligned on a 64-bit boundary, then ASSERT().
180 @param Address The MMIO register to read.
182 @return The value read.
191 ASSERT ((Address
& 7) == 0);
192 return *(volatile UINT64
*)Address
;
196 Writes a 64-bit MMIO register.
198 Writes the 64-bit MMIO register specified by Address with the value specified
199 by Value and returns Value. This function must guarantee that all MMIO read
200 and write operations are serialized.
202 If 64-bit MMIO register operations are not supported, then ASSERT().
203 If Address is not aligned on a 64-bit boundary, then ASSERT().
205 @param Address The MMIO register to write.
206 @param Value The value to write to the MMIO register.
216 ASSERT ((Address
& 7) == 0);
217 return *(volatile UINT64
*)Address
= Value
;
223 Reads an 8-bit I/O port.
225 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
226 This function must guarantee that all I/O read and write operations are
229 If 8-bit I/O port operations are not supported, then ASSERT().
231 @param Port The I/O port to read.
233 @return The value read.
245 mov dx
, word ptr
[Port
]
254 Writes an 8-bit I/O port.
256 Writes the 8-bit I/O port specified by Port with the value specified by Value
257 and returns Value. This function must guarantee that all I/O read and write
258 operations are serialized.
260 If 8-bit I/O port operations are not supported, then ASSERT().
262 @param Port The I/O port to write.
263 @param Value The value to write to the I/O port.
265 @return The value written the I/O port.
276 mov al
, byte ptr
[Value
]
277 mov dx
, word ptr
[Port
]
284 Reads a 16-bit I/O port.
286 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
287 This function must guarantee that all I/O read and write operations are
290 If 16-bit I/O port operations are not supported, then ASSERT().
291 If Port is not aligned on a 16-bit boundary, then ASSERT().
293 @param Port The I/O port to read.
295 @return The value read.
306 ASSERT ((Port
& 1) == 0);
309 mov dx
, word ptr
[Port
]
311 mov word ptr
[Data
], ax
318 Writes a 16-bit I/O port.
320 Writes the 16-bit I/O port specified by Port with the value specified by Value
321 and returns Value. This function must guarantee that all I/O read and write
322 operations are serialized.
324 If 16-bit I/O port operations are not supported, then ASSERT().
325 If Port is not aligned on a 16-bit boundary, then ASSERT().
327 @param Port The I/O port to write.
328 @param Value The value to write to the I/O port.
330 @return The value written the I/O port.
340 ASSERT ((Port
& 1) == 0);
343 mov ax
, word ptr
[Value
]
344 mov dx
, word ptr
[Port
]
352 Reads a 32-bit I/O port.
354 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
355 This function must guarantee that all I/O read and write operations are
358 If 32-bit I/O port operations are not supported, then ASSERT().
359 If Port is not aligned on a 32-bit boundary, then ASSERT().
361 @param Port The I/O port to read.
363 @return The value read.
374 ASSERT ((Port
& 3) == 0);
377 mov dx
, word ptr
[Port
]
379 mov dword ptr
[Data
], eax
386 Writes a 32-bit I/O port.
388 Writes the 32-bit I/O port specified by Port with the value specified by Value
389 and returns Value. This function must guarantee that all I/O read and write
390 operations are serialized.
392 If 32-bit I/O port operations are not supported, then ASSERT().
393 If Port is not aligned on a 32-bit boundary, then ASSERT().
395 @param Port The I/O port to write.
396 @param Value The value to write to the I/O port.
398 @return The value written the I/O port.
408 ASSERT ((Port
& 3) == 0);
411 mov eax
, dword ptr
[Value
]
412 mov dx
, word ptr
[Port
]