iPXE
efi_uaccess.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EFI_UACCESS_H
00002 #define _IPXE_EFI_UACCESS_H
00003 
00004 /** @file
00005  *
00006  * iPXE user access API for EFI
00007  *
00008  * EFI runs with flat physical addressing, so the various mappings
00009  * between virtual addresses, I/O addresses and bus addresses are all
00010  * no-ops.
00011  */
00012 
00013 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00014 
00015 #ifdef UACCESS_EFI
00016 #define UACCESS_PREFIX_efi
00017 #else
00018 #define UACCESS_PREFIX_efi __efi_
00019 #endif
00020 
00021 /**
00022  * Convert physical address to user pointer
00023  *
00024  * @v phys_addr         Physical address
00025  * @ret userptr         User pointer
00026  */
00027 static inline __always_inline userptr_t
00028 UACCESS_INLINE ( efi, phys_to_user ) ( unsigned long phys_addr ) {
00029         return phys_addr;
00030 }
00031 
00032 /**
00033  * Convert user buffer to physical address
00034  *
00035  * @v userptr           User pointer
00036  * @v offset            Offset from user pointer
00037  * @ret phys_addr       Physical address
00038  */
00039 static inline __always_inline unsigned long
00040 UACCESS_INLINE ( efi, user_to_phys ) ( userptr_t userptr, off_t offset ) {
00041         return ( userptr + offset );
00042 }
00043 
00044 static inline __always_inline userptr_t
00045 UACCESS_INLINE ( efi, virt_to_user ) ( volatile const void *addr ) {
00046         return trivial_virt_to_user ( addr );
00047 }
00048 
00049 static inline __always_inline void *
00050 UACCESS_INLINE ( efi, user_to_virt ) ( userptr_t userptr, off_t offset ) {
00051         return trivial_user_to_virt ( userptr, offset );
00052 }
00053 
00054 static inline __always_inline userptr_t
00055 UACCESS_INLINE ( efi, userptr_add ) ( userptr_t userptr, off_t offset ) {
00056         return trivial_userptr_add ( userptr, offset );
00057 }
00058 
00059 static inline __always_inline off_t
00060 UACCESS_INLINE ( efi, userptr_sub ) ( userptr_t userptr,
00061                                       userptr_t subtrahend ) {
00062         return trivial_userptr_sub ( userptr, subtrahend );
00063 }
00064 
00065 static inline __always_inline void
00066 UACCESS_INLINE ( efi, memcpy_user ) ( userptr_t dest, off_t dest_off,
00067                                         userptr_t src, off_t src_off,
00068                                         size_t len ) {
00069         trivial_memcpy_user ( dest, dest_off, src, src_off, len );
00070 }
00071 
00072 static inline __always_inline void
00073 UACCESS_INLINE ( efi, memmove_user ) ( userptr_t dest, off_t dest_off,
00074                                          userptr_t src, off_t src_off,
00075                                          size_t len ) {
00076         trivial_memmove_user ( dest, dest_off, src, src_off, len );
00077 }
00078 
00079 static inline __always_inline int
00080 UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off,
00081                                       userptr_t second, off_t second_off,
00082                                       size_t len ) {
00083         return trivial_memcmp_user ( first, first_off, second, second_off, len);
00084 }
00085 
00086 static inline __always_inline void
00087 UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset,
00088                                         int c, size_t len ) {
00089         trivial_memset_user ( buffer, offset, c, len );
00090 }
00091 
00092 static inline __always_inline size_t
00093 UACCESS_INLINE ( efi, strlen_user ) ( userptr_t buffer, off_t offset ) {
00094         return trivial_strlen_user ( buffer, offset );
00095 }
00096 
00097 static inline __always_inline off_t
00098 UACCESS_INLINE ( efi, memchr_user ) ( userptr_t buffer, off_t offset,
00099                                         int c, size_t len ) {
00100         return trivial_memchr_user ( buffer, offset, c, len );
00101 }
00102 
00103 #endif /* _IPXE_EFI_UACCESS_H */