summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2008-10-12 01:52:30 +0200
committerMichael Brown2008-10-12 02:06:27 +0200
commitee2df1d6d6a83dbe0972835d4f9adfb46a121ef5 (patch)
treee13f3cade309302922cf0e95411b1ce1c70fa837
parent[ioapi] Formalise the I/O API as used in i386-pcbios (diff)
downloadipxe-ee2df1d6d6a83dbe0972835d4f9adfb46a121ef5.tar.gz
ipxe-ee2df1d6d6a83dbe0972835d4f9adfb46a121ef5.tar.xz
ipxe-ee2df1d6d6a83dbe0972835d4f9adfb46a121ef5.zip
[ioapi] Remove old io.h file and switch all users over to <gpxe/io.h>
-rw-r--r--src/arch/i386/core/i386_timer.c2
-rw-r--r--src/arch/i386/core/relocate.c2
-rw-r--r--src/arch/i386/core/video_subr.c2
-rw-r--r--src/arch/i386/drivers/timer_rdtsc.c2
-rw-r--r--src/arch/i386/firmware/pcbios/gateA20.c12
-rw-r--r--src/arch/i386/include/io.h265
-rw-r--r--src/arch/i386/include/pcidirect.h2
-rw-r--r--src/arch/i386/include/realmode.h2
-rw-r--r--src/core/debug.c2
-rw-r--r--src/core/malloc.c2
-rw-r--r--src/core/pc_kbd.c2
-rw-r--r--src/core/serial.c2
-rw-r--r--src/drivers/bus/eisa.c2
-rw-r--r--src/drivers/bus/isa.c2
-rw-r--r--src/drivers/bus/isapnp.c2
-rw-r--r--src/drivers/bus/mca.c2
-rw-r--r--src/drivers/net/3c509.c2
-rw-r--r--src/drivers/net/e1000/e1000.h2
-rw-r--r--src/drivers/net/e1000/e1000_osdep.h2
-rw-r--r--src/drivers/net/natsemi.c2
-rw-r--r--src/drivers/net/pnic.c2
-rw-r--r--src/drivers/net/rtl8139.c2
22 files changed, 26 insertions, 291 deletions
diff --git a/src/arch/i386/core/i386_timer.c b/src/arch/i386/core/i386_timer.c
index 8f90ae05..3325bb0b 100644
--- a/src/arch/i386/core/i386_timer.c
+++ b/src/arch/i386/core/i386_timer.c
@@ -14,7 +14,7 @@
#include <stddef.h>
#include <bits/timer2.h>
#include <gpxe/timer.h>
-#include <io.h>
+#include <gpxe/io.h>
/* Timers tick over at this rate */
#define TIMER2_TICK_RATE 1193180U
diff --git a/src/arch/i386/core/relocate.c b/src/arch/i386/core/relocate.c
index 53e190f5..fd8df087 100644
--- a/src/arch/i386/core/relocate.c
+++ b/src/arch/i386/core/relocate.c
@@ -1,4 +1,4 @@
-#include <io.h>
+#include <gpxe/io.h>
#include <registers.h>
#include <gpxe/memmap.h>
diff --git a/src/arch/i386/core/video_subr.c b/src/arch/i386/core/video_subr.c
index bf82cc61..c821cd02 100644
--- a/src/arch/i386/core/video_subr.c
+++ b/src/arch/i386/core/video_subr.c
@@ -7,7 +7,7 @@
#include "stddef.h"
#include "string.h"
-#include "io.h"
+#include <gpxe/io.h>
#include "console.h"
#include <gpxe/init.h>
#include "vga.h"
diff --git a/src/arch/i386/drivers/timer_rdtsc.c b/src/arch/i386/drivers/timer_rdtsc.c
index 09b7df2f..f4ede558 100644
--- a/src/arch/i386/drivers/timer_rdtsc.c
+++ b/src/arch/i386/drivers/timer_rdtsc.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <bits/cpu.h>
#include <bits/timer2.h>
-#include <io.h>
+#include <gpxe/io.h>
#define rdtsc(low,high) \
diff --git a/src/arch/i386/firmware/pcbios/gateA20.c b/src/arch/i386/firmware/pcbios/gateA20.c
index a14e3416..91135247 100644
--- a/src/arch/i386/firmware/pcbios/gateA20.c
+++ b/src/arch/i386/firmware/pcbios/gateA20.c
@@ -48,9 +48,9 @@ static void empty_8042 ( void ) {
time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
while ( ( inb ( K_CMD ) & ( K_IBUF_FUL | K_OBUF_FUL ) ) &&
currticks() < time ) {
- SLOW_DOWN_IO;
- ( void ) inb ( K_RDWR );
- SLOW_DOWN_IO;
+ iodelay();
+ ( void ) inb_p ( K_RDWR );
+ iodelay();
}
}
@@ -77,7 +77,7 @@ static int gateA20_is_set ( int retries ) {
/* Avoid false negatives */
test_pattern++;
- SLOW_DOWN_IO;
+ iodelay();
/* Always retry at least once, to avoid false negatives */
} while ( retries-- >= 0 );
@@ -145,9 +145,9 @@ void gateA20_set ( void ) {
scp_a = inb ( SCP_A );
scp_a &= ~0x01; /* Avoid triggering a reset */
scp_a |= 0x02; /* Enable A20 */
- SLOW_DOWN_IO;
+ iodelay();
outb ( scp_a, SCP_A );
- SLOW_DOWN_IO;
+ iodelay();
if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
DBG ( "Enabled gate A20 using "
"Fast Gate A20\n" );
diff --git a/src/arch/i386/include/io.h b/src/arch/i386/include/io.h
deleted file mode 100644
index c26fdf7e..00000000
--- a/src/arch/i386/include/io.h
+++ /dev/null
@@ -1,265 +0,0 @@
-#ifndef ETHERBOOT_IO_H
-#define ETHERBOOT_IO_H
-
-#include <stdint.h>
-#include "virtaddr.h"
-
-/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
- * into a memory access cards can use.
- */
-#define virt_to_bus virt_to_phys
-
-
-/* bus_to_virt reverses virt_to_bus, the address must be output
- * from virt_to_bus to be valid. This function does not work on
- * all bus addresses.
- */
-#define bus_to_virt phys_to_virt
-
-/* ioremap converts a random 32bit bus address into something
- * etherboot can access.
- */
-static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
-{
- return bus_to_virt(bus_addr);
-}
-
-/* iounmap cleans up anything ioremap had to setup */
-static inline void iounmap(void *virt_addr __unused)
-{
- return;
-}
-
-/*
- * This file contains the definitions for the x86 IO instructions
- * inb/inw/inl/outb/outw/outl and the "string versions" of the same
- * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
- * versions of the single-IO instructions (inb_p/inw_p/..).
- *
- * This file is not meant to be obfuscating: it's just complicated
- * to (a) handle it all in a way that makes gcc able to optimize it
- * as well as possible and (b) trying to avoid writing the same thing
- * over and over again with slight variations and possibly making a
- * mistake somewhere.
- */
-
-/*
- * Thanks to James van Artsdalen for a better timing-fix than
- * the two short jumps: using outb's to a nonexistent port seems
- * to guarantee better timings even on fast machines.
- *
- * On the other hand, I'd like to be sure of a non-existent port:
- * I feel a bit unsafe about using 0x80 (should be safe, though)
- *
- * Linus
- */
-
-#ifdef SLOW_IO_BY_JUMPING
-#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
-#else
-#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
-#endif
-
-#ifdef REALLY_SLOW_IO
-#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
-#else
-#define SLOW_DOWN_IO __SLOW_DOWN_IO
-#endif
-
-/*
- * readX/writeX() are used to access memory mapped devices. On some
- * architectures the memory mapped IO stuff needs to be accessed
- * differently. On the x86 architecture, we just read/write the
- * memory location directly.
- */
-static inline __attribute__ (( always_inline )) unsigned long
-_readb ( volatile uint8_t *addr ) {
- unsigned long data = *addr;
- DBGIO ( "[%08lx] => %02lx\n", virt_to_phys ( addr ), data );
- return data;
-}
-static inline __attribute__ (( always_inline )) unsigned long
-_readw ( volatile uint16_t *addr ) {
- unsigned long data = *addr;
- DBGIO ( "[%08lx] => %04lx\n", virt_to_phys ( addr ), data );
- return data;
-}
-static inline __attribute__ (( always_inline )) unsigned long
-_readl ( volatile uint32_t *addr ) {
- unsigned long data = *addr;
- DBGIO ( "[%08lx] => %08lx\n", virt_to_phys ( addr ), data );
- return data;
-}
-#define readb( addr ) _readb ( ( volatile uint8_t * ) (addr) )
-#define readw( addr ) _readw ( ( volatile uint16_t * ) (addr) )
-#define readl( addr ) _readl ( ( volatile uint32_t * ) (addr) )
-
-static inline __attribute__ (( always_inline )) void
-_writeb ( unsigned long data, volatile uint8_t *addr ) {
- DBGIO ( "[%08lx] <= %02lx\n", virt_to_phys ( addr ), data );
- *addr = data;
-}
-static inline __attribute__ (( always_inline )) void
-_writew ( unsigned long data, volatile uint16_t *addr ) {
- DBGIO ( "[%08lx] <= %04lx\n", virt_to_phys ( addr ), data );
- *addr = data;
-}
-static inline __attribute__ (( always_inline )) void
-_writel ( unsigned long data, volatile uint32_t *addr ) {
- DBGIO ( "[%08lx] <= %08lx\n", virt_to_phys ( addr ), data );
- *addr = data;
-}
-#define writeb( b, addr ) _writeb ( (b), ( volatile uint8_t * ) (addr) )
-#define writew( b, addr ) _writew ( (b), ( volatile uint16_t * ) (addr) )
-#define writel( b, addr ) _writel ( (b), ( volatile uint32_t * ) (addr) )
-
-#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
-#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
-
-/*
- * Force strict CPU ordering.
- * And yes, this is required on UP too when we're talking
- * to devices.
- *
- * For now, "wmb()" doesn't actually do anything, as all
- * Intel CPU's follow what Intel calls a *Processor Order*,
- * in which all writes are seen in the program order even
- * outside the CPU.
- *
- * I expect future Intel CPU's to have a weaker ordering,
- * but I'd also expect them to finally get their act together
- * and add some real memory barriers if so.
- *
- * Some non intel clones support out of order store. wmb() ceases to be a
- * nop for these.
- */
-
-#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
-#define rmb() mb()
-#define wmb() mb();
-
-
-/*
- * Talk about misusing macros..
- */
-
-#define __OUT1(s,x) \
-extern void __out##s(unsigned x value, unsigned short port); \
-extern inline void __out##s(unsigned x value, unsigned short port) {
-
-#define __OUT2(s,s1,s2) \
-__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
-
-#define __OUT(s,s1,x) \
-__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
-__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
-__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
-__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
-
-#define __IN1(s,x) \
-extern unsigned x __in##s(unsigned short port); \
-extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
-
-#define __IN2(s,s1,s2) \
-__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
-
-#define __IN(s,s1,x,i...) \
-__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
-__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
-__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
-__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
-
-#define __INS(s) \
-extern void ins##s(unsigned short port, void * addr, unsigned long count); \
-extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
-{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
-: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
-
-#define __OUTS(s) \
-extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
-extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
-{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
-: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
-
-__IN(b,"", char)
-__IN(w,"",short)
-__IN(l,"", long)
-
-__OUT(b,"b",char)
-__OUT(w,"w",short)
-__OUT(l,,int)
-
-__INS(b)
-__INS(w)
-__INS(l)
-
-__OUTS(b)
-__OUTS(w)
-__OUTS(l)
-
-/*
- * Note that due to the way __builtin_constant_p() works, you
- * - can't use it inside a inline function (it will never be true)
- * - you don't have to worry about side effects within the __builtin..
- */
-#define outb(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outbc((val),(port)) : \
- __outb((val),(port)))
-
-#define inb(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inbc(port) : \
- __inb(port))
-
-#define outb_p(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outbc_p((val),(port)) : \
- __outb_p((val),(port)))
-
-#define inb_p(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inbc_p(port) : \
- __inb_p(port))
-
-#define outw(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outwc((val),(port)) : \
- __outw((val),(port)))
-
-#define inw(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inwc(port) : \
- __inw(port))
-
-#define outw_p(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outwc_p((val),(port)) : \
- __outw_p((val),(port)))
-
-#define inw_p(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inwc_p(port) : \
- __inw_p(port))
-
-#define outl(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outlc((val),(port)) : \
- __outl((val),(port)))
-
-#define inl(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inlc(port) : \
- __inl(port))
-
-#define outl_p(val,port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __outlc_p((val),(port)) : \
- __outl_p((val),(port)))
-
-#define inl_p(port) \
-((__builtin_constant_p((port)) && (port) < 256) ? \
- __inlc_p(port) : \
- __inl_p(port))
-
-#endif /* ETHERBOOT_IO_H */
diff --git a/src/arch/i386/include/pcidirect.h b/src/arch/i386/include/pcidirect.h
index 4e2e9d12..c333424d 100644
--- a/src/arch/i386/include/pcidirect.h
+++ b/src/arch/i386/include/pcidirect.h
@@ -2,7 +2,7 @@
#define _PCIDIRECT_H
#include <stdint.h>
-#include <io.h>
+#include <gpxe/io.h>
/** @file
*
diff --git a/src/arch/i386/include/realmode.h b/src/arch/i386/include/realmode.h
index 5d3ddf50..ea4192ed 100644
--- a/src/arch/i386/include/realmode.h
+++ b/src/arch/i386/include/realmode.h
@@ -5,7 +5,7 @@
#include "stdint.h"
#include "registers.h"
-#include "io.h"
+#include <gpxe/io.h>
/*
* Data structures and type definitions
diff --git a/src/core/debug.c b/src/core/debug.c
index 09830420..3079cd4c 100644
--- a/src/core/debug.c
+++ b/src/core/debug.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <console.h>
void pause ( void ) {
diff --git a/src/core/malloc.c b/src/core/malloc.c
index 2d892f42..db7f1bed 100644
--- a/src/core/malloc.c
+++ b/src/core/malloc.c
@@ -20,7 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <strings.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <gpxe/list.h>
#include <gpxe/init.h>
#include <gpxe/malloc.h>
diff --git a/src/core/pc_kbd.c b/src/core/pc_kbd.c
index d43357fe..799c8beb 100644
--- a/src/core/pc_kbd.c
+++ b/src/core/pc_kbd.c
@@ -10,7 +10,7 @@
* yhlu@tyan.com
*/
-#include "io.h"
+#include <gpxe/io.h>
#include "console.h"
static char key_map[][128] = {
diff --git a/src/core/serial.c b/src/core/serial.c
index 97640f93..5b3be39c 100644
--- a/src/core/serial.c
+++ b/src/core/serial.c
@@ -13,7 +13,7 @@
#include "stddef.h"
#include <gpxe/init.h>
-#include "io.h"
+#include <gpxe/io.h>
#include <unistd.h>
#include <gpxe/serial.h>
#include "config/serial.h"
diff --git a/src/drivers/bus/eisa.c b/src/drivers/bus/eisa.c
index ee03df3a..d9e42359 100644
--- a/src/drivers/bus/eisa.c
+++ b/src/drivers/bus/eisa.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <unistd.h>
#include <gpxe/eisa.h>
diff --git a/src/drivers/bus/isa.c b/src/drivers/bus/isa.c
index a4105fd0..4147a9bc 100644
--- a/src/drivers/bus/isa.c
+++ b/src/drivers/bus/isa.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <gpxe/isa.h>
/*
diff --git a/src/drivers/bus/isapnp.c b/src/drivers/bus/isapnp.c
index f4968eb1..0915a92b 100644
--- a/src/drivers/bus/isapnp.c
+++ b/src/drivers/bus/isapnp.c
@@ -60,7 +60,7 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <unistd.h>
#include <gpxe/isapnp.h>
diff --git a/src/drivers/bus/mca.c b/src/drivers/bus/mca.c
index eb7b7e39..e9233813 100644
--- a/src/drivers/bus/mca.c
+++ b/src/drivers/bus/mca.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <gpxe/mca.h>
static struct mca_driver mca_drivers[0]
diff --git a/src/drivers/net/3c509.c b/src/drivers/net/3c509.c
index 8a15aff2..ecfdec55 100644
--- a/src/drivers/net/3c509.c
+++ b/src/drivers/net/3c509.c
@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <unistd.h>
#include <gpxe/device.h>
#include <gpxe/isa.h>
diff --git a/src/drivers/net/e1000/e1000.h b/src/drivers/net/e1000/e1000.h
index 4ae41451..e0664e38 100644
--- a/src/drivers/net/e1000/e1000.h
+++ b/src/drivers/net/e1000/e1000.h
@@ -34,7 +34,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <errno.h>
#include <byteswap.h>
#include <gpxe/pci.h>
diff --git a/src/drivers/net/e1000/e1000_osdep.h b/src/drivers/net/e1000/e1000_osdep.h
index eb57fb54..c2d9eb9c 100644
--- a/src/drivers/net/e1000/e1000_osdep.h
+++ b/src/drivers/net/e1000/e1000_osdep.h
@@ -37,7 +37,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <errno.h>
#include <unistd.h>
#include <byteswap.h>
diff --git a/src/drivers/net/natsemi.c b/src/drivers/net/natsemi.c
index 028b905c..bfe1452b 100644
--- a/src/drivers/net/natsemi.c
+++ b/src/drivers/net/natsemi.c
@@ -61,7 +61,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <errno.h>
#include <byteswap.h>
#include <unistd.h>
diff --git a/src/drivers/net/pnic.c b/src/drivers/net/pnic.c
index c7f08670..3a4af967 100644
--- a/src/drivers/net/pnic.c
+++ b/src/drivers/net/pnic.c
@@ -14,7 +14,7 @@ Bochs Pseudo NIC driver for Etherboot
#include <stdint.h>
#include <stdio.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <errno.h>
#include <gpxe/pci.h>
#include <gpxe/if_ether.h>
diff --git a/src/drivers/net/rtl8139.c b/src/drivers/net/rtl8139.c
index 509047a9..ff7de5c6 100644
--- a/src/drivers/net/rtl8139.c
+++ b/src/drivers/net/rtl8139.c
@@ -69,7 +69,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
-#include <io.h>
+#include <gpxe/io.h>
#include <errno.h>
#include <unistd.h>
#include <byteswap.h>