28 #define PAGE_SIZE ( 1 << PAGE_SHIFT ) 31 #define PAGE_MASK ( PAGE_SIZE - 1 ) 40 #define IOAPI_INLINE( _subsys, _api_func ) \ 41 SINGLE_API_INLINE ( IOAPI_PREFIX_ ## _subsys, _api_func ) 50 #define PROVIDE_IOAPI( _subsys, _api_func, _func ) \ 51 PROVIDE_SINGLE_API ( IOAPI_PREFIX_ ## _subsys, _api_func, _func ) 59 #define PROVIDE_IOAPI_INLINE( _subsys, _api_func ) \ 60 PROVIDE_SINGLE_API_INLINE ( IOAPI_PREFIX_ ## _subsys, _api_func ) 76 #define IOAPI_READ( _func, _type, io_addr, _prefix, _ndigits ) ( { \ 77 volatile _type *_io_addr = \ 78 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 79 _type _data = _func ( _io_addr ); \ 80 DBGIO ( "[" _prefix " %08lx] => %0" #_ndigits "llx\n", \ 81 io_to_bus ( _io_addr ), ( unsigned long long ) _data ); \ 94 #define IOAPI_WRITE( _func, _type, data, io_addr, _prefix, _ndigits ) do { \ 95 volatile _type *_io_addr = \ 96 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 97 _type _data = (data); \ 98 DBGIO ( "[" _prefix " %08lx] <= %0" #_ndigits "llx\n", \ 99 io_to_bus ( _io_addr ), ( unsigned long long ) _data ); \ 100 _func ( _data, _io_addr ); \ 114 #define IOAPI_READS( _func, _type, io_addr, data, count, _prefix, _ndigits ) \ 116 volatile _type *_io_addr = \ 117 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 118 void *_data_void = (data); \ 119 _type * _data = ( ( _type * ) _data_void ); \ 120 const _type * _dbg_data = _data; \ 121 unsigned int _count = (count); \ 122 unsigned int _dbg_count = _count; \ 123 _func ( _io_addr, _data, _count ); \ 124 DBGIO ( "[" _prefix " %08lx] =>", io_to_bus ( _io_addr ) ); \ 125 while ( _dbg_count-- ) { \ 126 DBGIO ( " %0" #_ndigits "llx", \ 127 ( ( unsigned long long ) *(_dbg_data++) ) ); \ 143 #define IOAPI_WRITES( _func, _type, io_addr, data, count, _prefix, _ndigits ) \ 145 volatile _type *_io_addr = \ 146 ( ( volatile _type * ) ( intptr_t ) (io_addr) ); \ 147 const void *_data_void = (data); \ 148 const _type * _data = ( ( const _type * ) _data_void ); \ 149 const _type * _dbg_data = _data; \ 150 unsigned int _count = (count); \ 151 unsigned int _dbg_count = _count; \ 152 DBGIO ( "[" _prefix " %08lx] <=", io_to_bus ( _io_addr ) ); \ 153 while ( _dbg_count-- ) { \ 154 DBGIO ( " %0" #_ndigits "llx", \ 155 ( ( unsigned long long ) *(_dbg_data++) ) ); \ 158 _func ( _io_addr, _data, _count ); \ 167 unsigned long phys_to_bus (
unsigned long phys_addr );
207 #define readb( io_addr ) IOAPI_READ ( readb, uint8_t, io_addr, "MEM", 2 ) 216 #define readw( io_addr ) IOAPI_READ ( readw, uint16_t, io_addr, "MEM", 4 ) 225 #define readl( io_addr ) IOAPI_READ ( readl, uint32_t, io_addr, "MEM", 8 ) 234 #define readq( io_addr ) IOAPI_READ ( readq, uint64_t, io_addr, "MEM", 16 ) 243 #define writeb( data, io_addr ) \ 244 IOAPI_WRITE ( writeb, uint8_t, data, io_addr, "MEM", 2 ) 253 #define writew( data, io_addr ) \ 254 IOAPI_WRITE ( writew, uint16_t, data, io_addr, "MEM", 4 ) 263 #define writel( data, io_addr ) \ 264 IOAPI_WRITE ( writel, uint32_t, data, io_addr, "MEM", 8 ) 273 #define writeq( data, io_addr ) \ 274 IOAPI_WRITE ( writeq, uint64_t, data, io_addr, "MEM", 16 ) 283 #define inb( io_addr ) IOAPI_READ ( inb, uint8_t, io_addr, "IO", 2 ) 292 #define inw( io_addr ) IOAPI_READ ( inw, uint16_t, io_addr, "IO", 4 ) 301 #define inl( io_addr ) IOAPI_READ ( inl, uint32_t, io_addr, "IO", 8 ) 310 #define outb( data, io_addr ) \ 311 IOAPI_WRITE ( outb, uint8_t, data, io_addr, "IO", 2 ) 320 #define outw( data, io_addr ) \ 321 IOAPI_WRITE ( outw, uint16_t, data, io_addr, "IO", 4 ) 330 #define outl( data, io_addr ) \ 331 IOAPI_WRITE ( outl, uint32_t, data, io_addr, "IO", 8 ) 340 #define ioread8( io_addr ) \ 341 IOAPI_READ ( ioread8, uint8_t, io_addr, "IO/MEM", 2 ) 350 #define ioread16( io_addr ) \ 351 IOAPI_READ ( ioread16, uint16_t, io_addr, "IO/MEM", 4 ) 360 #define ioread32( io_addr ) \ 361 IOAPI_READ ( ioread32, uint32_t, io_addr, "IO/MEM", 8 ) 370 #define iowrite8( data, io_addr ) \ 371 IOAPI_WRITE ( iowrite8, uint8_t, data, io_addr, "IO/MEM", 2 ) 380 #define iowrite16( data, io_addr ) \ 381 IOAPI_WRITE ( iowrite16, uint16_t, data, io_addr, "IO/MEM", 4 ) 390 #define iowrite32( data, io_addr ) \ 391 IOAPI_WRITE ( iowrite32, uint32_t, data, io_addr, "IO/MEM", 8 ) 401 #define insb( io_addr, data, count ) \ 402 IOAPI_READS ( insb, uint8_t, io_addr, data, count, "IO", 2 ) 412 #define insw( io_addr, data, count ) \ 413 IOAPI_READS ( insw, uint16_t, io_addr, data, count, "IO", 4 ) 423 #define insl( io_addr, data, count ) \ 424 IOAPI_READS ( insl, uint32_t, io_addr, data, count, "IO", 8 ) 434 unsigned int count );
435 #define outsb( io_addr, data, count ) \ 436 IOAPI_WRITES ( outsb, uint8_t, io_addr, data, count, "IO", 2 ) 446 unsigned int count );
447 #define outsw( io_addr, data, count ) \ 448 IOAPI_WRITES ( outsw, uint16_t, io_addr, data, count, "IO", 4 ) 458 unsigned int count );
459 #define outsl( io_addr, data, count ) \ 460 IOAPI_WRITES ( outsl, uint32_t, io_addr, data, count, "IO", 8 ) 475 #define INX_P( _func, _type, io_addr ) ( { \ 476 _type _data = _func ( (io_addr) ); \ 486 #define inb_p( io_addr ) INX_P ( inb, uint8_t, io_addr ) 494 #define inw_p( io_addr ) INX_P ( inw, uint16_t, io_addr ) 502 #define inl_p( io_addr ) INX_P ( inl, uint32_t, io_addr ) 511 #define OUTX_P( _func, data, io_addr ) do { \ 512 _func ( (data), (io_addr) ); \ 522 #define outb_p( data, io_addr ) OUTX_P ( outb, data, io_addr ) 530 #define outw_p( data, io_addr ) OUTX_P ( outw, data, io_addr ) 538 #define outl_p( data, io_addr ) OUTX_P ( outl, data, io_addr ) x86-specific I/O API implementations
#define outsl(io_addr, data, count)
#define writel(data, io_addr)
#define outw(data, io_addr)
#define iowrite16(data, io_addr)
#define ioread32(io_addr)
unsigned long long uint64_t
#define writeq(data, io_addr)
#define insw(io_addr, data, count)
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.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static unsigned int 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.
uint32_t addr
Buffer address.
#define iowrite32(data, io_addr)
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)
#define iowrite8(data, io_addr)
#define ioread16(io_addr)
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.
unsigned long bus_to_phys(unsigned long bus_addr)
Convert bus address to a physical address.
#define outsb(io_addr, data, count)