X-Git-Url: http://git.etherboot.org/people/balajirrao/gpxe.git/blobdiff_plain/3d6123e69ab879c72ff489afc5bf93ef0b7a94ce..604c934981618bb2125318b3aa9cbbbde7707fc5:/src/arch/i386/include/io.h diff --git a/src/arch/i386/include/io.h b/src/arch/i386/include/io.h index e351a0c1..c26fdf7e 100644 --- a/src/arch/i386/include/io.h +++ b/src/arch/i386/include/io.h @@ -1,22 +1,8 @@ #ifndef ETHERBOOT_IO_H #define ETHERBOOT_IO_H - -/* Amount of relocation etherboot is experiencing */ -extern unsigned long virt_offset; - -/* Don't require identity mapped physical memory, - * osloader.c is the only valid user at the moment. - */ -static inline unsigned long virt_to_phys(volatile const void *virt_addr) -{ - return ((unsigned long)virt_addr) + virt_offset; -} - -static inline void *phys_to_virt(unsigned long phys_addr) -{ - return (void *)(phys_addr - virt_offset); -} +#include +#include "virtaddr.h" /* virt_to_bus converts an addresss inside of etherboot [_start, _end] * into a memory access cards can use. @@ -86,13 +72,46 @@ static inline void iounmap(void *virt_addr __unused) * differently. On the x86 architecture, we just read/write the * memory location directly. */ -#define readb(addr) (*(volatile unsigned char *) (addr)) -#define readw(addr) (*(volatile unsigned short *) (addr)) -#define readl(addr) (*(volatile unsigned int *) (addr)) - -#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b)) -#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b)) -#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) +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))