mirror of
https://github.com/xcat2/xNBA.git
synced 2025-04-18 19:18:56 +00:00
[ioapi] Remove old io.h file and switch all users over to <gpxe/io.h>
This commit is contained in:
parent
8956a36be5
commit
ee2df1d6d6
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <io.h>
|
||||
#include <gpxe/io.h>
|
||||
#include <registers.h>
|
||||
#include <gpxe/memmap.h>
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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) \
|
||||
|
@ -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" );
|
||||
|
@ -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 */
|
@ -2,7 +2,7 @@
|
||||
#define _PCIDIRECT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <io.h>
|
||||
#include <gpxe/io.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "stdint.h"
|
||||
#include "registers.h"
|
||||
#include "io.h"
|
||||
#include <gpxe/io.h>
|
||||
|
||||
/*
|
||||
* Data structures and type definitions
|
||||
|
@ -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 ) {
|
||||
|
@ -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>
|
||||
|
@ -10,7 +10,7 @@
|
||||
* yhlu@tyan.com
|
||||
*/
|
||||
|
||||
#include "io.h"
|
||||
#include <gpxe/io.h>
|
||||
#include "console.h"
|
||||
|
||||
static char key_map[][128] = {
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <gpxe/io.h>
|
||||
#include <gpxe/isa.h>
|
||||
|
||||
/*
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user