iPXE
Defines | Functions
x86_io.h File Reference

iPXE I/O API for x86 More...

Go to the source code of this file.

Defines

#define IOAPI_PREFIX_x86   __x86_
#define PAGE_SHIFT   12
 Page shift.
#define X86_READX(_api_func, _type)
#define X86_WRITEX(_api_func, _type)
#define X86_INX(_insn_suffix, _type, _reg_prefix)
#define X86_OUTX(_insn_suffix, _type, _reg_prefix)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static __always_inline
unsigned long 
IOAPI_INLINE (x86, phys_to_bus)(unsigned long phys_addr)
static __always_inline
unsigned long 
IOAPI_INLINE (x86, bus_to_phys)(unsigned long bus_addr)
 X86_READX (readb, uint8_t)
 X86_READX (readw, uint16_t)
 X86_READX (readl, uint32_t)
 X86_WRITEX (writeb, uint8_t)
 X86_WRITEX (writew, uint16_t)
 X86_WRITEX (writel, uint32_t)
 X86_INX (b, uint8_t,"b")
 X86_INX (w, uint16_t,"w")
 X86_INX (l, uint32_t,"k")
 X86_OUTX (b, uint8_t,"b")
 X86_OUTX (w, uint16_t,"w")
 X86_OUTX (l, uint32_t,"k")
static __always_inline void IOAPI_INLINE (x86, iodelay)(void)
static __always_inline void IOAPI_INLINE (x86, mb)(void)

Detailed Description

iPXE I/O API for x86

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 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.

Definition in file x86_io.h.


Define Documentation

#define IOAPI_PREFIX_x86   __x86_

Definition at line 23 of file x86_io.h.

#define PAGE_SHIFT   12

Page shift.

Definition at line 32 of file x86_io.h.

Referenced by vp_find_vq().

#define X86_READX (   _api_func,
  _type 
)
Value:
static inline __always_inline _type					      \
IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) {                 \
        return *io_addr;                                                      \
}

Definition at line 54 of file x86_io.h.

#define X86_WRITEX (   _api_func,
  _type 
)
Value:
static inline __always_inline void					      \
IOAPI_INLINE ( x86, _api_func ) ( _type data,                                 \
                                  volatile _type *io_addr ) {                 \
        *io_addr = data;                                                      \
}

Definition at line 66 of file x86_io.h.

#define X86_INX (   _insn_suffix,
  _type,
  _reg_prefix 
)
Value:
static inline __always_inline _type					      \
IOAPI_INLINE ( x86, in ## _insn_suffix ) ( volatile _type *io_addr ) {        \
        _type data;                                                           \
        __asm__ __volatile__ ( "in" #_insn_suffix " %w1, %" _reg_prefix "0"   \
                               : "=a" ( data ) : "Nd" ( io_addr ) );          \
        return data;                                                          \
}                                                                             \
static inline __always_inline void					      \
IOAPI_INLINE ( x86, ins ## _insn_suffix ) ( volatile _type *io_addr,          \
                                            _type *data,                      \
                                            unsigned int count ) {            \
        unsigned int discard_D;                                               \
        __asm__ __volatile__ ( "rep ins" #_insn_suffix                        \
                               : "=D" ( discard_D )                           \
                               : "d" ( io_addr ), "c" ( count ),              \
                                 "0" ( data ) );                              \
}

Definition at line 84 of file x86_io.h.

#define X86_OUTX (   _insn_suffix,
  _type,
  _reg_prefix 
)
Value:
static inline __always_inline void					      \
IOAPI_INLINE ( x86, out ## _insn_suffix ) ( _type data,                       \
                                            volatile _type *io_addr ) {       \
        __asm__ __volatile__ ( "out" #_insn_suffix " %" _reg_prefix "0, %w1"  \
                               : : "a" ( data ), "Nd" ( io_addr ) );          \
}                                                                             \
static inline __always_inline void					      \
IOAPI_INLINE ( x86, outs ## _insn_suffix ) ( volatile _type *io_addr,         \
                                             const _type *data,               \
                                             unsigned int count ) {           \
        unsigned int discard_S;                                               \
        __asm__ __volatile__ ( "rep outs" #_insn_suffix                       \
                               : "=S" ( discard_S )                           \
                               : "d" ( io_addr ), "c" ( count ),              \
                                 "0" ( data ) );                              \
}

Definition at line 106 of file x86_io.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static __always_inline unsigned long IOAPI_INLINE ( x86  ,
phys_to_bus   
) [inline, static]

Definition at line 40 of file x86_io.h.

                                                              {
        return phys_addr;
}
static __always_inline unsigned long IOAPI_INLINE ( x86  ,
bus_to_phys   
) [inline, static]

Definition at line 45 of file x86_io.h.

                                                             {
        return bus_addr;
}
X86_READX ( readb  ,
uint8_t   
)
X86_READX ( readw  ,
uint16_t   
)
X86_READX ( readl  ,
uint32_t   
)
X86_WRITEX ( writeb  ,
uint8_t   
)
X86_WRITEX ( writew  ,
uint16_t   
)
X86_WRITEX ( writel  ,
uint32_t   
)
X86_INX ( ,
uint8_t  ,
"b"   
)
X86_INX ( ,
uint16_t  ,
"w"   
)
X86_INX ( l  ,
uint32_t  ,
"k"   
)
X86_OUTX ( ,
uint8_t  ,
"b"   
)
X86_OUTX ( ,
uint16_t  ,
"w"   
)
X86_OUTX ( l  ,
uint32_t  ,
"k"   
)
static __always_inline void IOAPI_INLINE ( x86  ,
iodelay   
) [inline, static]

Definition at line 133 of file x86_io.h.

References __asm__().

                                       {
        __asm__ __volatile__ ( "outb %al, $0x80" );
}
static __always_inline void IOAPI_INLINE ( x86  ,
mb   
) [inline, static]

Definition at line 143 of file x86_io.h.

References __asm__().

                                  {
        __asm__ __volatile__ ( "lock; addl $0, 0(%%esp)" : : : "memory" );
}