iPXE
Macros | Functions
x86_io.h File Reference

iPXE I/O API for x86 More...

Go to the source code of this file.

Macros

#define IOAPI_PREFIX_x86   __x86_
 
#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.

Macro Definition Documentation

◆ IOAPI_PREFIX_x86

#define IOAPI_PREFIX_x86   __x86_

Definition at line 23 of file x86_io.h.

◆ X86_READX

#define X86_READX (   _api_func,
  _type 
)
Value:
static inline __always_inline _type \
IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \
return *io_addr; \
}
static __always_inline unsigned long IOAPI_INLINE(x86, phys_to_bus)(unsigned long phys_addr)
Definition: x86_io.h:37
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611

Definition at line 51 of file x86_io.h.

◆ X86_WRITEX

#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; \
}
static __always_inline unsigned long IOAPI_INLINE(x86, phys_to_bus)(unsigned long phys_addr)
Definition: x86_io.h:37
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
uint8_t data[48]
Additional event data.
Definition: ena.h:22

Definition at line 63 of file x86_io.h.

◆ X86_INX

#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 ) ); \
}
__be32 in[4]
Definition: CIB_PRM.h:35
static __always_inline unsigned long IOAPI_INLINE(x86, phys_to_bus)(unsigned long phys_addr)
Definition: x86_io.h:37
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
void * discard_D
Definition: bigint.h:31
uint16_t count
Number of entries.
Definition: ena.h:22
uint8_t data[48]
Additional event data.
Definition: ena.h:22

Definition at line 81 of file x86_io.h.

◆ X86_OUTX

#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 ) ); \
}
void * discard_S
Definition: bigint.h:62
__be32 out[4]
Definition: CIB_PRM.h:36
static __always_inline unsigned long IOAPI_INLINE(x86, phys_to_bus)(unsigned long phys_addr)
Definition: x86_io.h:37
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
uint16_t count
Number of entries.
Definition: ena.h:22
uint8_t data[48]
Additional event data.
Definition: ena.h:22

Definition at line 103 of file x86_io.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ IOAPI_INLINE() [1/4]

static __always_inline unsigned long IOAPI_INLINE ( x86  ,
phys_to_bus   
)
inlinestatic

Definition at line 37 of file x86_io.h.

37  {
38  return phys_addr;
39 }

◆ IOAPI_INLINE() [2/4]

static __always_inline unsigned long IOAPI_INLINE ( x86  ,
bus_to_phys   
)
inlinestatic

Definition at line 42 of file x86_io.h.

42  {
43  return bus_addr;
44 }
static __always_inline void unsigned long bus_addr
Definition: ecam_io.h:135

References bus_addr.

◆ X86_READX() [1/3]

X86_READX ( readb  ,
uint8_t   
)

◆ X86_READX() [2/3]

X86_READX ( readw  ,
uint16_t   
)

◆ X86_READX() [3/3]

X86_READX ( readl  ,
uint32_t   
)

◆ X86_WRITEX() [1/3]

X86_WRITEX ( writeb  ,
uint8_t   
)

◆ X86_WRITEX() [2/3]

X86_WRITEX ( writew  ,
uint16_t   
)

◆ X86_WRITEX() [3/3]

X86_WRITEX ( writel  ,
uint32_t   
)

◆ X86_INX() [1/3]

X86_INX ( b  ,
uint8_t  ,
"b"   
)

◆ X86_INX() [2/3]

X86_INX ( w  ,
uint16_t  ,
"w"   
)

◆ X86_INX() [3/3]

X86_INX ( l  ,
uint32_t  ,
"k"   
)

◆ X86_OUTX() [1/3]

X86_OUTX ( b  ,
uint8_t  ,
"b"   
)

◆ X86_OUTX() [2/3]

X86_OUTX ( w  ,
uint16_t  ,
"w"   
)

◆ X86_OUTX() [3/3]

X86_OUTX ( l  ,
uint32_t  ,
"k"   
)

◆ IOAPI_INLINE() [3/4]

static __always_inline void IOAPI_INLINE ( x86  ,
iodelay   
)
inlinestatic

Definition at line 130 of file x86_io.h.

130  {
131  __asm__ __volatile__ ( "outb %al, $0x80" );
132 }
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

References __asm__(), and __volatile__().

◆ IOAPI_INLINE() [4/4]

static __always_inline void IOAPI_INLINE ( x86  ,
mb   
)
inlinestatic

Definition at line 140 of file x86_io.h.

140  {
141  __asm__ __volatile__ ( "lock; addl $0, 0(%%esp)" : : : "memory" );
142 }
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

References __asm__(), and __volatile__().