iPXE
iomap.h
Go to the documentation of this file.
00001 #ifndef _IPXE_IOMAP_H
00002 #define _IPXE_IOMAP_H
00003 
00004 /** @file
00005  *
00006  * iPXE I/O mapping API
00007  *
00008  * The I/O mapping API provides methods for mapping and unmapping I/O
00009  * devices.
00010  */
00011 
00012 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00013 
00014 #include <stdint.h>
00015 #include <ipxe/api.h>
00016 #include <config/ioapi.h>
00017 #include <ipxe/uaccess.h>
00018 
00019 /**
00020  * Calculate static inline I/O mapping API function name
00021  *
00022  * @v _prefix           Subsystem prefix
00023  * @v _api_func         API function
00024  * @ret _subsys_func    Subsystem API function
00025  */
00026 #define IOMAP_INLINE( _subsys, _api_func ) \
00027         SINGLE_API_INLINE ( IOMAP_PREFIX_ ## _subsys, _api_func )
00028 
00029 /**
00030  * Provide an I/O mapping API implementation
00031  *
00032  * @v _prefix           Subsystem prefix
00033  * @v _api_func         API function
00034  * @v _func             Implementing function
00035  */
00036 #define PROVIDE_IOMAP( _subsys, _api_func, _func ) \
00037         PROVIDE_SINGLE_API ( IOMAP_PREFIX_ ## _subsys, _api_func, _func )
00038 
00039 /**
00040  * Provide a static inline I/O mapping API implementation
00041  *
00042  * @v _prefix           Subsystem prefix
00043  * @v _api_func         API function
00044  */
00045 #define PROVIDE_IOMAP_INLINE( _subsys, _api_func ) \
00046         PROVIDE_SINGLE_API_INLINE ( IOMAP_PREFIX_ ## _subsys, _api_func )
00047 
00048 /* Include all architecture-independent I/O API headers */
00049 #include <ipxe/iomap_virt.h>
00050 
00051 /* Include all architecture-dependent I/O API headers */
00052 #include <bits/iomap.h>
00053 
00054 /**
00055  * Map bus address as an I/O address
00056  *
00057  * @v bus_addr          Bus address
00058  * @v len               Length of region
00059  * @ret io_addr         I/O address
00060  */
00061 void * ioremap ( unsigned long bus_addr, size_t len );
00062 
00063 /**
00064  * Unmap I/O address
00065  *
00066  * @v io_addr           I/O address
00067  */
00068 void iounmap ( volatile const void *io_addr );
00069 
00070 /**
00071  * Convert I/O address to bus address (for debug only)
00072  *
00073  * @v io_addr           I/O address
00074  * @ret bus_addr        Bus address
00075  */
00076 unsigned long io_to_bus ( volatile const void *io_addr );
00077 
00078 #endif /* _IPXE_IOMAP_H */