iPXE I/O API for x86
More...
#include <ipxe/io.h>
#include <ipxe/x86_io.h>
Go to the source code of this file.
|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| |
| | X86_IOREADX (ioread8, b, uint8_t) |
| |
| | X86_IOREADX (ioread16, w, uint16_t) |
| |
| | X86_IOREADX (ioread32, l, uint32_t) |
| |
| | X86_IOWRITEX (iowrite8, b, uint8_t) |
| |
| | X86_IOWRITEX (iowrite16, w, uint16_t) |
| |
| | X86_IOWRITEX (iowrite32, l, uint32_t) |
| |
| static __unused uint64_t | i386_readq (volatile uint64_t *io_addr) |
| | Read 64-bit qword from memory-mapped device. More...
|
| |
| static __unused void | i386_writeq (uint64_t data, volatile uint64_t *io_addr) |
| | Write 64-bit qword to memory-mapped device. More...
|
| |
| | PROVIDE_IOAPI_INLINE (x86, phys_to_bus) |
| |
| | PROVIDE_IOAPI_INLINE (x86, bus_to_phys) |
| |
| | PROVIDE_IOAPI_INLINE (x86, readb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, readw) |
| |
| | PROVIDE_IOAPI_INLINE (x86, readl) |
| |
| | PROVIDE_IOAPI_INLINE (x86, writeb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, writew) |
| |
| | PROVIDE_IOAPI_INLINE (x86, writel) |
| |
| | PROVIDE_IOAPI_INLINE (x86, inb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, inw) |
| |
| | PROVIDE_IOAPI_INLINE (x86, inl) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outw) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outl) |
| |
| | PROVIDE_IOAPI_INLINE (x86, insb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, insw) |
| |
| | PROVIDE_IOAPI_INLINE (x86, insl) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outsb) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outsw) |
| |
| | PROVIDE_IOAPI_INLINE (x86, outsl) |
| |
| | PROVIDE_IOAPI_INLINE (x86, iodelay) |
| |
| | PROVIDE_IOAPI_INLINE (x86, mb) |
| |
| | PROVIDE_IOAPI (x86, readq, i386_readq) |
| |
| | PROVIDE_IOAPI (x86, writeq, i386_writeq) |
| |
| | PROVIDE_IOAPI (x86, ioread8, x86_ioread8) |
| |
| | PROVIDE_IOAPI (x86, ioread16, x86_ioread16) |
| |
| | PROVIDE_IOAPI (x86, ioread32, x86_ioread32) |
| |
| | PROVIDE_IOAPI (x86, iowrite8, x86_iowrite8) |
| |
| | PROVIDE_IOAPI (x86, iowrite16, x86_iowrite16) |
| |
| | PROVIDE_IOAPI (x86, iowrite32, x86_iowrite32) |
| |
iPXE I/O API for x86
Definition in file x86_io.c.
◆ PIO_THRESHOLD
| #define PIO_THRESHOLD 0x10000 |
Threshold for port I/O-mapped addresses.
On x86, port I/O instructions (inb/outb/etc) can take only an 8-bit or 16-bit address (in dx). All I/O ports must therefore have a value in the first 64kB of the address space.
Virtual addresses below 64kB can never be MMIO addresses:
- In the UEFI memory model and x86_64 BIOS memory model, virtual addresses below 64kB are identity-mapped to the corresponding physical address. Since the first 64kB of address space is always RAM, no MMIO device can exist within this region.
- In the i386 BIOS memory model, virtual addresses below 64kB cover the iPXE binary itself (which starts at address zero). Since the size of .textdata can never realistically be below 64kB (not least since the heap alone is 512kB), and since iPXE is placed into RAM as a contiguous block, no MMIO device can exist within this region.
We therefore know that any (virtual) address returned by ioremap() must be outside the first 64kB of the address space. We can therefore use this as a threshold to determine whether a given address is a port I/O address or an MMIO address.
Definition at line 60 of file x86_io.c.
◆ X86_IOREADX
| #define X86_IOREADX |
( |
|
_api_func, |
|
|
|
_suffix, |
|
|
|
_type |
|
) |
| |
Value:static _type x86_ ## _api_func ( volatile _type *io_addr ) { \
return
in ## _suffix ( io_addr ); \
} else { \
return
read ## _suffix ( io_addr ); \
} \
}
struct option_descriptor read[1]
#define PIO_THRESHOLD
Threshold for port I/O-mapped addresses.
Read from I/O-mapped or memory-mapped device.
- Parameters
-
- Return values
-
Definition at line 68 of file x86_io.c.
◆ X86_IOWRITEX
| #define X86_IOWRITEX |
( |
|
_api_func, |
|
|
|
_suffix, |
|
|
|
_type |
|
) |
| |
Value:static void x86_ ## _api_func ( _type
data,
volatile _type *io_addr ) { \
out ## _suffix (
data, io_addr ); \
} else { \
write ## _suffix (
data, io_addr ); \
} \
}
uint8_t data[48]
Additional event data.
#define PIO_THRESHOLD
Threshold for port I/O-mapped addresses.
Write to I/O-mapped or memory-mapped device.
- Parameters
-
| data | Value to write |
| io_addr | I/O address |
Definition at line 86 of file x86_io.c.
◆ FILE_LICENCE()
| FILE_LICENCE |
( |
GPL2_OR_LATER_OR_UBDL |
| ) |
|
◆ X86_IOREADX() [1/3]
◆ X86_IOREADX() [2/3]
◆ X86_IOREADX() [3/3]
◆ X86_IOWRITEX() [1/3]
◆ X86_IOWRITEX() [2/3]
◆ X86_IOWRITEX() [3/3]
◆ i386_readq()
Read 64-bit qword from memory-mapped device.
- Parameters
-
- Return values
-
This routine uses MMX instructions.
Definition at line 106 of file x86_io.c.
110 "movq (%1), %%mm0\n\t" 111 "movq %%mm0, (%%esp)\n\t" 115 :
"=A" (
data ) :
"r" ( io_addr ) );
unsigned long long uint64_t
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
__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")
uint8_t data[48]
Additional event data.
References __asm__(), __volatile__(), and data.
◆ i386_writeq()
Write 64-bit qword to memory-mapped device.
- Parameters
-
| data | Value to write |
| io_addr | I/O address |
This routine uses MMX instructions.
Definition at line 127 of file x86_io.c.
130 "movq (%%esp), %%mm0\n\t" 131 "movq %%mm0, (%1)\n\t" 135 : :
"A" (
data ),
"r" ( io_addr ) );
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
__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")
uint8_t data[48]
Additional event data.
References __asm__(), __volatile__(), and data.
◆ PROVIDE_IOAPI_INLINE() [1/22]
◆ PROVIDE_IOAPI_INLINE() [2/22]
◆ PROVIDE_IOAPI_INLINE() [3/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
readb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [4/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
readw |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [5/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
readl |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [6/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
writeb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [7/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
writew |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [8/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
writel |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [9/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
inb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [10/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
inw |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [11/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
inl |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [12/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [13/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outw |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [14/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outl |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [15/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
insb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [16/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
insw |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [17/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
insl |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [18/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outsb |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [19/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outsw |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [20/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
outsl |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [21/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
iodelay |
|
|
) |
| |
◆ PROVIDE_IOAPI_INLINE() [22/22]
| PROVIDE_IOAPI_INLINE |
( |
x86 |
, |
|
|
mb |
|
|
) |
| |
◆ PROVIDE_IOAPI() [1/8]
◆ PROVIDE_IOAPI() [2/8]
◆ PROVIDE_IOAPI() [3/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
ioread8 |
, |
|
|
x86_ioread8 |
|
|
) |
| |
◆ PROVIDE_IOAPI() [4/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
ioread16 |
, |
|
|
x86_ioread16 |
|
|
) |
| |
◆ PROVIDE_IOAPI() [5/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
ioread32 |
, |
|
|
x86_ioread32 |
|
|
) |
| |
◆ PROVIDE_IOAPI() [6/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
iowrite8 |
, |
|
|
x86_iowrite8 |
|
|
) |
| |
◆ PROVIDE_IOAPI() [7/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
iowrite16 |
, |
|
|
x86_iowrite16 |
|
|
) |
| |
◆ PROVIDE_IOAPI() [8/8]
| PROVIDE_IOAPI |
( |
x86 |
, |
|
|
iowrite32 |
, |
|
|
x86_iowrite32 |
|
|
) |
| |