[ioapi] Absorb virt_to_phys() and phys_to_virt() into the I/O API
This commit is contained in:
parent
992bbf309c
commit
aef6d0df5c
|
@ -65,10 +65,13 @@ static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
||||||
: : "A" ( data ), "r" ( io_addr ) );
|
: : "A" ( data ), "r" ( io_addr ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
PROVIDE_IOAPI_INLINE ( x86, iounmap );
|
PROVIDE_IOAPI_INLINE ( x86, virt_to_phys );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
|
PROVIDE_IOAPI_INLINE ( x86, phys_to_virt );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, virt_to_bus );
|
PROVIDE_IOAPI_INLINE ( x86, virt_to_bus );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, bus_to_virt );
|
PROVIDE_IOAPI_INLINE ( x86, bus_to_virt );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, ioremap );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, iounmap );
|
||||||
|
PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, readb );
|
PROVIDE_IOAPI_INLINE ( x86, readb );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, readw );
|
PROVIDE_IOAPI_INLINE ( x86, readw );
|
||||||
PROVIDE_IOAPI_INLINE ( x86, readl );
|
PROVIDE_IOAPI_INLINE ( x86, readl );
|
||||||
|
|
|
@ -28,6 +28,26 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( x86, virt_to_phys ) ( volatile const void *addr ) {
|
||||||
|
return ( ( ( unsigned long ) addr ) + virt_offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void *
|
||||||
|
IOAPI_INLINE ( x86, phys_to_virt ) ( unsigned long phys_addr ) {
|
||||||
|
return ( ( void * ) ( phys_addr - virt_offset ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline unsigned long
|
||||||
|
IOAPI_INLINE ( x86, virt_to_bus ) ( volatile const void *addr ) {
|
||||||
|
return virt_to_phys ( addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __always_inline void *
|
||||||
|
IOAPI_INLINE ( x86, bus_to_virt ) ( unsigned long bus_addr ) {
|
||||||
|
return phys_to_virt ( bus_addr );
|
||||||
|
}
|
||||||
|
|
||||||
static inline __always_inline void *
|
static inline __always_inline void *
|
||||||
IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
|
IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
|
||||||
return phys_to_virt ( bus_addr );
|
return phys_to_virt ( bus_addr );
|
||||||
|
@ -43,16 +63,6 @@ IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
|
||||||
return virt_to_phys ( io_addr );
|
return virt_to_phys ( io_addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline unsigned long
|
|
||||||
IOAPI_INLINE ( x86, virt_to_bus ) ( volatile const void *addr ) {
|
|
||||||
return virt_to_phys ( addr );
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline __always_inline void *
|
|
||||||
IOAPI_INLINE ( x86, bus_to_virt ) ( unsigned long bus_addr ) {
|
|
||||||
return phys_to_virt ( bus_addr );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MMIO reads and writes up to 32 bits
|
* MMIO reads and writes up to 32 bits
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,18 +32,6 @@
|
||||||
/* Variables in virtaddr.S */
|
/* Variables in virtaddr.S */
|
||||||
extern unsigned long virt_offset;
|
extern unsigned long virt_offset;
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert between virtual and physical addresses
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
|
|
||||||
return ( ( unsigned long ) virt_addr ) + virt_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void * phys_to_virt ( unsigned long phys_addr ) {
|
|
||||||
return ( void * ) ( phys_addr - virt_offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* KEEP_IT_REAL */
|
#else /* KEEP_IT_REAL */
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -148,6 +148,46 @@
|
||||||
_func ( _io_addr, _data, _count ); \
|
_func ( _io_addr, _data, _count ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert virtual address to a physical address
|
||||||
|
*
|
||||||
|
* @v addr Virtual address
|
||||||
|
* @ret phys_addr Physical address
|
||||||
|
*/
|
||||||
|
unsigned long virt_to_phys ( volatile const void *addr );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert physical address to a virtual address
|
||||||
|
*
|
||||||
|
* @v addr Virtual address
|
||||||
|
* @ret phys_addr Physical address
|
||||||
|
*
|
||||||
|
* This operation isn't actually valid within our memory model, and is
|
||||||
|
* impossible to achieve under -DKEEP_IT_REAL. Some drivers haven't
|
||||||
|
* been updated to avoid it yet, though.
|
||||||
|
*/
|
||||||
|
void * phys_to_virt ( unsigned long phys_addr );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert virtual address to a bus address
|
||||||
|
*
|
||||||
|
* @v addr Virtual address
|
||||||
|
* @ret bus_addr Bus address
|
||||||
|
*/
|
||||||
|
unsigned long virt_to_bus ( volatile const void *addr );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert bus address to a virtual address
|
||||||
|
*
|
||||||
|
* @v bus_addr Bus address
|
||||||
|
* @ret addr Virtual address
|
||||||
|
*
|
||||||
|
* This operation isn't actually valid within our memory model, and is
|
||||||
|
* impossible to achieve under -DKEEP_IT_REAL. Some drivers haven't
|
||||||
|
* been updated to avoid it yet, though.
|
||||||
|
*/
|
||||||
|
void * bus_to_virt ( unsigned long bus_addr );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map bus address as an I/O address
|
* Map bus address as an I/O address
|
||||||
*
|
*
|
||||||
|
@ -172,26 +212,6 @@ void iounmap ( volatile const void *io_addr );
|
||||||
*/
|
*/
|
||||||
unsigned long io_to_bus ( volatile const void *io_addr );
|
unsigned long io_to_bus ( volatile const void *io_addr );
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert virtual address to a bus address
|
|
||||||
*
|
|
||||||
* @v addr Virtual address
|
|
||||||
* @ret bus_addr Bus address
|
|
||||||
*/
|
|
||||||
unsigned long virt_to_bus ( volatile const void *addr );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert bus address to a virtual address
|
|
||||||
*
|
|
||||||
* @v bus_addr Bus address
|
|
||||||
* @ret addr Virtual address
|
|
||||||
*
|
|
||||||
* This operation isn't actually valid within our memory model, and is
|
|
||||||
* impossible to achieve under -DKEEP_IT_REAL. Some drivers haven't
|
|
||||||
* been updated to avoid it yet, though.
|
|
||||||
*/
|
|
||||||
void * bus_to_virt ( unsigned long bus_addr );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read byte from memory-mapped device
|
* Read byte from memory-mapped device
|
||||||
*
|
*
|
||||||
|
|
Reference in New Issue