]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c
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 - 2010, Intel Corporation. All rights reserved.<BR>
14 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.
25 #include "BaseIoLibIntrinsicInternal.h"
28 Reads an 8-bit I/O port.
30 Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
31 This function must guarantee that all I/O read and write operations are
34 If 8-bit I/O port operations are not supported, then ASSERT().
36 @param Port The I/O port to read.
38 @return The value read.
50 __asm__
__volatile__ ("inb %w1,%b0" : "=a" (Data
) : "d" ((UINT16
)Port
));
55 Writes an 8-bit I/O port.
57 Writes the 8-bit I/O port specified by Port with the value specified by Value
58 and returns Value. This function must guarantee that all I/O read and write
59 operations are serialized.
61 If 8-bit I/O port operations are not supported, then ASSERT().
63 @param Port The I/O port to write.
64 @param Value The value to write to the I/O port.
66 @return The value written the I/O port.
77 __asm__
__volatile__ ("outb %b0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));
82 Reads a 16-bit I/O port.
84 Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
85 This function must guarantee that all I/O read and write operations are
88 If 16-bit I/O port operations are not supported, then ASSERT().
89 If Port is not aligned on a 16-bit boundary, 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().
118 If Port is not aligned on a 16-bit boundary, then ASSERT().
120 @param Port The I/O port to write.
121 @param Value The value to write to the I/O port.
123 @return The value written the I/O port.
134 ASSERT ((Port
& 1) == 0);
135 __asm__
__volatile__ ("outw %w0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));
140 Reads a 32-bit I/O port.
142 Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
143 This function must guarantee that all I/O read and write operations are
146 If 32-bit I/O port operations are not supported, then ASSERT().
147 If Port is not aligned on a 32-bit boundary, then ASSERT().
149 @param Port The I/O port to read.
151 @return The value read.
163 ASSERT ((Port
& 3) == 0);
164 __asm__
__volatile__ ("inl %w1,%0" : "=a" (Data
) : "d" ((UINT16
)Port
));
169 Writes a 32-bit I/O port.
171 Writes the 32-bit I/O port specified by Port with the value specified by Value
172 and returns Value. This function must guarantee that all I/O read and write
173 operations are serialized.
175 If 32-bit I/O port operations are not supported, then ASSERT().
176 If Port is not aligned on a 32-bit boundary, then ASSERT().
178 @param Port The I/O port to write.
179 @param Value The value to write to the I/O port.
181 @return The value written the I/O port.
192 ASSERT ((Port
& 3) == 0);
193 __asm__
__volatile__ ("outl %0,%w1" : : "a" (Value
), "d" ((UINT16
)Port
));