27 #define PAGE_SIZE ( 1 << PAGE_SHIFT ) 30 #define PAGE_MASK ( PAGE_SIZE - 1 ) 39 #define IOAPI_INLINE( _subsys, _api_func ) \ 40 SINGLE_API_INLINE ( IOAPI_PREFIX_ ## _subsys, _api_func ) 49 #define PROVIDE_IOAPI( _subsys, _api_func, _func ) \ 50 PROVIDE_SINGLE_API ( IOAPI_PREFIX_ ## _subsys, _api_func, _func ) 58 #define PROVIDE_IOAPI_INLINE( _subsys, _api_func ) \ 59 PROVIDE_SINGLE_API_INLINE ( IOAPI_PREFIX_ ## _subsys, _api_func ) 75 #define IOAPI_READ( _func, _type, io_addr, _prefix, _ndigits ) ( { \ 76 volatile _type *_io_addr = \ 77 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 78 _type _data = _func ( _io_addr ); \ 79 DBGIO ( "[" _prefix " %08lx] => %0" #_ndigits "llx\n", \ 80 io_to_bus ( _io_addr ), ( unsigned long long ) _data ); \ 93 #define IOAPI_WRITE( _func, _type, data, io_addr, _prefix, _ndigits ) do { \ 94 volatile _type *_io_addr = \ 95 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 96 _type _data = (data); \ 97 DBGIO ( "[" _prefix " %08lx] <= %0" #_ndigits "llx\n", \ 98 io_to_bus ( _io_addr ), ( unsigned long long ) _data ); \ 99 _func ( _data, _io_addr ); \ 113 #define IOAPI_READS( _func, _type, io_addr, data, count, _prefix, _ndigits ) \ 115 volatile _type *_io_addr = \ 116 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 117 void *_data_void = (data); \ 118 _type * _data = ( ( _type * ) _data_void ); \ 119 const _type * _dbg_data = _data; \ 120 unsigned int _count = (count); \ 121 unsigned int _dbg_count = _count; \ 122 _func ( _io_addr, _data, _count ); \ 123 DBGIO ( "[" _prefix " %08lx] =>", io_to_bus ( _io_addr ) ); \ 124 while ( _dbg_count-- ) { \ 125 DBGIO ( " %0" #_ndigits "llx", \ 126 ( ( unsigned long long ) *(_dbg_data++) ) ); \ 142 #define IOAPI_WRITES( _func, _type, io_addr, data, count, _prefix, _ndigits ) \ 144 volatile _type *_io_addr = \ 145 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 146 const void *_data_void = (data); \ 147 const _type * _data = ( ( const _type * ) _data_void ); \ 148 const _type * _dbg_data = _data; \ 149 unsigned int _count = (count); \ 150 unsigned int _dbg_count = _count; \ 151 DBGIO ( "[" _prefix " %08lx] <=", io_to_bus ( _io_addr ) ); \ 152 while ( _dbg_count-- ) { \ 153 DBGIO ( " %0" #_ndigits "llx", \ 154 ( ( unsigned long long ) *(_dbg_data++) ) ); \ 157 _func ( _io_addr, _data, _count ); \ 166 unsigned long phys_to_bus (
unsigned long phys_addr );
206 #define readb( io_addr ) IOAPI_READ ( readb, uint8_t, io_addr, "MEM", 2 ) 215 #define readw( io_addr ) IOAPI_READ ( readw, uint16_t, io_addr, "MEM", 4 ) 224 #define readl( io_addr ) IOAPI_READ ( readl, uint32_t, io_addr, "MEM", 8 ) 233 #define readq( io_addr ) IOAPI_READ ( readq, uint64_t, io_addr, "MEM", 16 ) 242 #define writeb( data, io_addr ) \ 243 IOAPI_WRITE ( writeb, uint8_t, data, io_addr, "MEM", 2 ) 252 #define writew( data, io_addr ) \ 253 IOAPI_WRITE ( writew, uint16_t, data, io_addr, "MEM", 4 ) 262 #define writel( data, io_addr ) \ 263 IOAPI_WRITE ( writel, uint32_t, data, io_addr, "MEM", 8 ) 272 #define writeq( data, io_addr ) \ 273 IOAPI_WRITE ( writeq, uint64_t, data, io_addr, "MEM", 16 ) 282 #define inb( io_addr ) IOAPI_READ ( inb, uint8_t, io_addr, "IO", 2 ) 291 #define inw( io_addr ) IOAPI_READ ( inw, uint16_t, io_addr, "IO", 4 ) 300 #define inl( io_addr ) IOAPI_READ ( inl, uint32_t, io_addr, "IO", 8 ) 309 #define outb( data, io_addr ) \ 310 IOAPI_WRITE ( outb, uint8_t, data, io_addr, "IO", 2 ) 319 #define outw( data, io_addr ) \ 320 IOAPI_WRITE ( outw, uint16_t, data, io_addr, "IO", 4 ) 329 #define outl( data, io_addr ) \ 330 IOAPI_WRITE ( outl, uint32_t, data, io_addr, "IO", 8 ) 340 #define insb( io_addr, data, count ) \ 341 IOAPI_READS ( insb, uint8_t, io_addr, data, count, "IO", 2 ) 351 #define insw( io_addr, data, count ) \ 352 IOAPI_READS ( insw, uint16_t, io_addr, data, count, "IO", 4 ) 362 #define insl( io_addr, data, count ) \ 363 IOAPI_READS ( insl, uint32_t, io_addr, data, count, "IO", 8 ) 373 unsigned int count );
374 #define outsb( io_addr, data, count ) \ 375 IOAPI_WRITES ( outsb, uint8_t, io_addr, data, count, "IO", 2 ) 385 unsigned int count );
386 #define outsw( io_addr, data, count ) \ 387 IOAPI_WRITES ( outsw, uint16_t, io_addr, data, count, "IO", 4 ) 397 unsigned int count );
398 #define outsl( io_addr, data, count ) \ 399 IOAPI_WRITES ( outsl, uint32_t, io_addr, data, count, "IO", 8 ) 414 #define INX_P( _func, _type, io_addr ) ( { \ 415 _type _data = _func ( (io_addr) ); \ 425 #define inb_p( io_addr ) INX_P ( inb, uint8_t, io_addr ) 433 #define inw_p( io_addr ) INX_P ( inw, uint16_t, io_addr ) 441 #define inl_p( io_addr ) INX_P ( inl, uint32_t, io_addr ) 450 #define OUTX_P( _func, data, io_addr ) do { \ 451 _func ( (data), (io_addr) ); \ 461 #define outb_p( data, io_addr ) OUTX_P ( outb, data, io_addr ) 469 #define outw_p( data, io_addr ) OUTX_P ( outw, data, io_addr ) 477 #define outl_p( data, io_addr ) OUTX_P ( outl, data, io_addr ) 496 #define MAX_MEMORY_REGIONS 8 x86-specific I/O API implementations
void get_memmap(struct memory_map *memmap)
Get memory map.
#define outsl(io_addr, data, count)
#define writel(data, io_addr)
#define outw(data, io_addr)
unsigned int count
Number of used regions.
unsigned long long uint64_t
#define writeq(data, io_addr)
#define insw(io_addr, data, count)
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
static __always_inline void unsigned long bus_addr
static __always_inline void * bus_to_virt(unsigned long bus_addr)
Convert bus address to a virtual address.
#define MAX_MEMORY_REGIONS
Maximum number of memory regions we expect to encounter.
struct memory_region regions[MAX_MEMORY_REGIONS]
Memory regions.
static __always_inline void * phys_to_virt(unsigned long phys_addr)
Convert physical address to a virtual address.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
uint16_t count
Number of entries.
#define writew(data, io_addr)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define outl(data, io_addr)
#define outsw(io_addr, data, count)
#define __always_inline
Declare a function to be always inline.
unsigned long phys_to_bus(unsigned long phys_addr)
Convert physical address to a bus address.
#define insb(io_addr, data, count)
#define outb(data, io_addr)
uint64_t start
Physical start address.
uint8_t data[48]
Additional event data.
#define insl(io_addr, data, count)
#define writeb(data, io_addr)
void mb(void)
Memory barrier.
void iodelay(void)
Slow down I/O.
uint64_t end
Physical end address.
unsigned long bus_to_phys(unsigned long bus_addr)
Convert bus address to a physical address.
#define outsb(io_addr, data, count)