1 #ifndef _IPXE_IOMAP_H 2 #define _IPXE_IOMAP_H 3 4 /** @file 5 * 6 * iPXE I/O mapping API 7 * 8 * The I/O mapping API provides methods for mapping and unmapping I/O 9 * devices. 10 */ 11 12 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 13 14 #include <stdint.h> 15 #include <ipxe/api.h> 16 #include <config/ioapi.h> 17 #include <ipxe/uaccess.h> 18 19 /** 20 * Calculate static inline I/O mapping API function name 21 * 22 * @v _prefix Subsystem prefix 23 * @v _api_func API function 24 * @ret _subsys_func Subsystem API function 25 */ 26 #define IOMAP_INLINE( _subsys, _api_func ) \ 27 SINGLE_API_INLINE ( IOMAP_PREFIX_ ## _subsys, _api_func ) 28 29 /** 30 * Provide an I/O mapping API implementation 31 * 32 * @v _prefix Subsystem prefix 33 * @v _api_func API function 34 * @v _func Implementing function 35 */ 36 #define PROVIDE_IOMAP( _subsys, _api_func, _func ) \ 37 PROVIDE_SINGLE_API ( IOMAP_PREFIX_ ## _subsys, _api_func, _func ) 38 39 /** 40 * Provide a static inline I/O mapping API implementation 41 * 42 * @v _prefix Subsystem prefix 43 * @v _api_func API function 44 */ 45 #define PROVIDE_IOMAP_INLINE( _subsys, _api_func ) \ 46 PROVIDE_SINGLE_API_INLINE ( IOMAP_PREFIX_ ## _subsys, _api_func ) 47 48 /* Include all architecture-independent I/O API headers */ 49 #include <ipxe/iomap_virt.h> 50 51 /* Include all architecture-dependent I/O API headers */ 52 #include <bits/iomap.h> 53 54 /** 55 * Map bus address as an I/O address 56 * 57 * @v bus_addr Bus address 58 * @v len Length of region 59 * @ret io_addr I/O address 60 */ 61 void * ioremap ( unsigned long bus_addr, size_t len ); 62 63 /** 64 * Unmap I/O address 65 * 66 * @v io_addr I/O address 67 */ 68 void iounmap ( volatile const void *io_addr ); 69 70 /** 71 * Convert I/O address to bus address (for debug only) 72 * 73 * @v io_addr I/O address 74 * @ret bus_addr Bus address 75 */ 76 unsigned long io_to_bus ( volatile const void *io_addr ); 77 78 #endif /* _IPXE_IOMAP_H */ 79