david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[ioapi] Generalise i386 raw I/O API to x86

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2012-07-17 20:53:25 +01:00
parent 73ba154124
commit 4dc3f8141f
4 changed files with 22 additions and 21 deletions

View File

@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
* This routine uses MMX instructions.
*/
static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
static __unused uint64_t i386_readq ( volatile uint64_t *io_addr ) {
uint64_t data;
__asm__ __volatile__ ( "pushl %%edx\n\t"
"pushl %%eax\n\t"
@ -56,7 +56,7 @@ static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
*
* This routine uses MMX instructions.
*/
static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
static __unused void i386_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
__asm__ __volatile__ ( "pushl %%edx\n\t"
"pushl %%eax\n\t"
"movq (%%esp), %%mm0\n\t"
@ -75,11 +75,9 @@ PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
PROVIDE_IOAPI_INLINE ( x86, readb );
PROVIDE_IOAPI_INLINE ( x86, readw );
PROVIDE_IOAPI_INLINE ( x86, readl );
PROVIDE_IOAPI ( x86, readq, x86_readq );
PROVIDE_IOAPI_INLINE ( x86, writeb );
PROVIDE_IOAPI_INLINE ( x86, writew );
PROVIDE_IOAPI_INLINE ( x86, writel );
PROVIDE_IOAPI ( x86, writeq, x86_writeq );
PROVIDE_IOAPI_INLINE ( x86, inb );
PROVIDE_IOAPI_INLINE ( x86, inw );
PROVIDE_IOAPI_INLINE ( x86, inl );
@ -94,3 +92,10 @@ PROVIDE_IOAPI_INLINE ( x86, outsw );
PROVIDE_IOAPI_INLINE ( x86, outsl );
PROVIDE_IOAPI_INLINE ( x86, iodelay );
PROVIDE_IOAPI_INLINE ( x86, mb );
#ifdef __x86_64__
PROVIDE_IOAPI_INLINE ( x86, readq );
PROVIDE_IOAPI_INLINE ( x86, writeq );
#else
PROVIDE_IOAPI ( x86, readq, i386_readq );
PROVIDE_IOAPI ( x86, writeq, i386_writeq );
#endif

View File

@ -3,7 +3,7 @@
/** @file
*
* i386-specific I/O API implementations
* x86-specific I/O API implementations
*
*/

View File

@ -5,14 +5,14 @@
*
* iPXE I/O API for x86
*
* i386 uses direct pointer dereferences for accesses to memory-mapped
* x86 uses direct pointer dereferences for accesses to memory-mapped
* I/O space, and the inX/outX instructions for accesses to
* port-mapped I/O space.
*
* 64-bit atomic accesses (readq() and writeq()) use MMX instructions,
* and will crash original Pentium and earlier CPUs. Fortunately, no
* hardware that requires atomic 64-bit accesses will physically fit
* into a machine with such an old CPU anyway.
* 64-bit atomic accesses (readq() and writeq()) use MMX instructions
* under i386, and will crash original Pentium and earlier CPUs.
* Fortunately, no hardware that requires atomic 64-bit accesses will
* physically fit into a machine with such an old CPU anyway.
*/
FILE_LICENCE ( GPL2_OR_LATER );
@ -59,7 +59,7 @@ IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
}
/*
* MMIO reads and writes up to 32 bits
* MMIO reads and writes up to native word size
*
*/
@ -71,6 +71,9 @@ IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \
X86_READX ( readb, uint8_t );
X86_READX ( readw, uint16_t );
X86_READX ( readl, uint32_t );
#ifdef __x86_64__
X86_READX ( readq, uint64_t );
#endif
#define X86_WRITEX( _api_func, _type ) \
static inline __always_inline void \
@ -81,6 +84,9 @@ IOAPI_INLINE ( x86, _api_func ) ( _type data, \
X86_WRITEX ( writeb, uint8_t );
X86_WRITEX ( writew, uint16_t );
X86_WRITEX ( writel, uint32_t );
#ifdef __x86_64__
X86_WRITEX ( writeq, uint64_t );
#endif
/*
* PIO reads and writes up to 32 bits

View File

@ -1,10 +0,0 @@
#ifndef _BITS_IO_H
#define _BITS_IO_H
/** @file
*
* x86_64-specific I/O API implementations
*
*/
#endif /* _BITS_IO_H */