2 I/O Library. This file has compiler specifics for GCC as there is no
3 ANSI C standard for doing IO.
5 GCC - uses EFIAPI assembler. __asm__ calls GAS. __volatile__ makes sure the
6 compiler puts the assembler in this exact location. The complex GNUC
7 operations are not optimzed. It would be possible to also write these
10 We don't advocate putting compiler specifics in libraries or drivers but there
11 is no other way to make this work.
13 Copyright (c) 2006, Intel Corporation<BR>
14 All rights reserved. This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 Module Name: IoLibGcc.c
29 Reads an 8-bit I/O port.
31 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
32 This function must guarantee that all I/O read and write operations are
35 If 8-bit I/O port operations are not supported, then ASSERT().
37 @param Port The I/O port to read.
39 @return The value read.
51 __asm__
__volatile__ ("inb %w1,%b0" : "=a" (Data
) : "d" ((UINT16
)Port
));
56 Writes an 8-bit I/O port.
58 Writes the 8-bit I/O port specified by Port with the value specified by Value
59 and returns Value. This function must guarantee that all I/O read and write
60 operations are serialized.
62 If 8-bit I/O port operations are not supported, then ASSERT().
64 @param Port The I/O port to write.
65 @param Value The value to write to the I/O port.
67 @return The value written the I/O port.
78 __asm__
__volatile__ ("outb %b0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));
83 Reads a 16-bit I/O port.
85 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
86 This function must guarantee that all I/O read and write operations are
89 If 16-bit I/O port operations are not supported, then ASSERT().
91 @param Port The I/O port to read.
93 @return The value read.
105 ASSERT ((Port
& 1) == 0);
106 __asm__
__volatile__ ("inw %w1,%w0" : "=a" (Data
) : "d" ((UINT16
)Port
));
111 Writes a 16-bit I/O port.
113 Writes the 16-bit I/O port specified by Port with the value specified by Value
114 and returns Value. This function must guarantee that all I/O read and write
115 operations are serialized.
117 If 16-bit I/O port operations are not supported, then ASSERT().
119 @param Port The I/O port to write.
120 @param Value The value to write to the I/O port.
122 @return The value written the I/O port.
133 ASSERT ((Port
& 1) == 0);
134 __asm__
__volatile__ ("outw %w0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));
139 Reads a 32-bit I/O port.
141 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
142 This function must guarantee that all I/O read and write operations are
145 If 32-bit I/O port operations are not supported, then ASSERT().
147 @param Port The I/O port to read.
149 @return The value read.
161 ASSERT ((Port
& 3) == 0);
162 __asm__
__volatile__ ("inl %w1,%0" : "=a" (Data
) : "d" ((UINT16
)Port
));
167 Writes a 32-bit I/O port.
169 Writes the 32-bit I/O port specified by Port with the value specified by Value
170 and returns Value. This function must guarantee that all I/O read and write
171 operations are serialized.
173 If 32-bit I/O port operations are not supported, then ASSERT().
175 @param Port The I/O port to write.
176 @param Value The value to write to the I/O port.
178 @return The value written the I/O port.
189 ASSERT ((Port
& 3) == 0);
190 __asm__
__volatile__ ("outl %0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));