#include <stdint.h>
#include <string.h>
#include <gpxe/api.h>
#include <config/ioapi.h>
#include <gpxe/efi/efi_uaccess.h>
#include <bits/uaccess.h>
Go to the source code of this file.
Defines | |
| #define | UNULL ( ( userptr_t ) 0 ) |
| Equivalent of NULL for user pointers. | |
| #define | UACCESS_INLINE(_subsys, _api_func) SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) |
| Calculate static inline user access API function name. | |
| #define | PROVIDE_UACCESS(_subsys, _api_func, _func) PROVIDE_SINGLE_API ( UACCESS_PREFIX_ ## _subsys, _api_func, _func ) |
| Provide an user access API implementation. | |
| #define | PROVIDE_UACCESS_INLINE(_subsys, _api_func) PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) |
| Provide a static inline user access API implementation. | |
Typedefs | |
| typedef unsigned long | userptr_t |
| A pointer to a user buffer. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static __always_inline userptr_t | trivial_virt_to_user (volatile const void *addr) |
| Convert virtual address to user pointer. | |
| static __always_inline void * | trivial_user_to_virt (userptr_t userptr, off_t offset) |
| Convert user pointer to virtual address. | |
| static __always_inline userptr_t | trivial_userptr_add (userptr_t userptr, off_t offset) |
| Add offset to user pointer. | |
| static __always_inline void | trivial_memcpy_user (userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len) |
| Copy data between user buffers. | |
| static __always_inline void | trivial_memmove_user (userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len) |
| Copy data between user buffers, allowing for overlap. | |
| static __always_inline void | trivial_memset_user (userptr_t buffer, off_t offset, int c, size_t len) |
| Fill user buffer with a constant byte. | |
| static __always_inline size_t | trivial_strlen_user (userptr_t buffer, off_t offset) |
| Find length of NUL-terminated string in user buffer. | |
| static __always_inline off_t | trivial_memchr_user (userptr_t buffer, off_t offset, int c, size_t len) |
| Find character in user buffer. | |
| userptr_t | phys_to_user (unsigned long phys_addr) |
| Convert physical address to user pointer. | |
| unsigned long | user_to_phys (userptr_t userptr, off_t offset) |
| Convert user pointer to physical address. | |
| userptr_t | virt_to_user (volatile const void *addr) |
| Convert virtual address to user pointer. | |
| void * | user_to_virt (userptr_t userptr, off_t offset) |
| Convert user pointer to virtual address. | |
| userptr_t | userptr_add (userptr_t userptr, off_t offset) |
| Add offset to user pointer. | |
| static __always_inline unsigned long | virt_to_phys (volatile const void *addr) |
| Convert virtual address to a physical address. | |
| static __always_inline void * | phys_to_virt (unsigned long phys_addr) |
| Convert physical address to a virtual address. | |
| void | memcpy_user (userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len) |
| Copy data between user buffers. | |
| static __always_inline void | copy_to_user (userptr_t dest, off_t dest_off, const void *src, size_t len) |
| Copy data to user buffer. | |
| static __always_inline void | copy_from_user (void *dest, userptr_t src, off_t src_off, size_t len) |
| Copy data from user buffer. | |
| void | memmove_user (userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len) |
| Copy data between user buffers, allowing for overlap. | |
| void | memset_user (userptr_t userptr, off_t offset, int c, size_t len) |
| Fill user buffer with a constant byte. | |
| size_t | strlen_user (userptr_t userptr, off_t offset) |
| Find length of NUL-terminated string in user buffer. | |
| off_t | memchr_user (userptr_t userptr, off_t offset, int c, size_t len) |
| Find character in user buffer. | |
gPXE often needs to transfer data between internal and external buffers. On i386, the external buffers may require access via a different segment, and the buffer address cannot be encoded into a simple void * pointer. The userptr_t type encapsulates the information needed to identify an external buffer, and the copy_to_user() and copy_from_user() functions provide methods for transferring data between internal and external buffers.
Note that userptr_t is an opaque type; in particular, performing arithmetic upon a userptr_t is not allowed.
Definition in file uaccess.h.
| #define UNULL ( ( userptr_t ) 0 ) |
Equivalent of NULL for user pointers.
Definition at line 36 of file uaccess.h.
Referenced by arbel_alloc_icm(), arbel_free_icm(), arbel_start_firmware(), arbel_stop_firmware(), bzimage_load_initrds(), efi_urealloc(), find_smbios_structure(), hermon_alloc_icm(), hermon_free_icm(), hermon_start_firmware(), hermon_stop_firmware(), memtop_urealloc(), pxenv_tftp_read(), pxenv_tftp_read_file(), read_smbios_string(), read_smbios_structure(), and umalloc().
| #define UACCESS_INLINE | ( | _subsys, | |||
| _api_func | ) | SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) |
| #define PROVIDE_UACCESS | ( | _subsys, | |||
| _api_func, | |||||
| _func | ) | PROVIDE_SINGLE_API ( UACCESS_PREFIX_ ## _subsys, _api_func, _func ) |
| #define PROVIDE_UACCESS_INLINE | ( | _subsys, | |||
| _api_func | ) | PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func ) |
| typedef unsigned long userptr_t |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| userptr_t phys_to_user | ( | unsigned long | phys_addr | ) |
Convert physical address to user pointer.
| phys_addr | Physical address |
| userptr | User pointer |
Referenced by bios_find_smbios(), bzimage_load_initrds(), bzimage_parse_header(), com32_cfarcall(), com32_farcall(), com32_intcall(), comboot_load_image(), efi_find_smbios(), efi_urealloc(), elf_load_segment(), gateA20_is_set(), init_eheap(), multiboot_load_raw(), nbi_process_segments(), phys_to_virt(), pxenv_tftp_read_file(), real_to_user(), and shuffle().
Convert user pointer to physical address.
| userptr | User pointer | |
| offset | Offset from user pointer |
| phys_addr | Physical address |
Referenced by arbel_alloc_icm(), arbel_start_firmware(), bzimage_load_initrd(), bzimage_load_initrds(), bzimage_parse_header(), bzimage_update_header(), ecollect_free(), efi_urealloc(), hermon_alloc_icm(), hermon_start_firmware(), init_eheap(), memtop_urealloc(), multiboot_build_module_list(), prep_segment(), register_image(), srp_cmd(), and virt_to_phys().
| userptr_t virt_to_user | ( | volatile const void * | addr | ) |
Convert virtual address to user pointer.
| addr | Virtual address |
| userptr | User pointer |
Referenced by ata_identify(), com32_farcall(), com32_intcall(), copy_from_user(), copy_to_user(), embedded_init(), guess_int13_geometry(), scsi_read_capacity_10(), scsi_read_capacity_16(), and virt_to_phys().
Convert user pointer to virtual address.
| userptr | User pointer | |
| offset | Offset from user pointer |
| addr | Virtual address |
Referenced by efi_image_exec(), efi_image_load(), and phys_to_virt().
Add offset to user pointer.
| userptr | User pointer | |
| offset | Offset |
| userptr | New pointer value |
Referenced by ecollect_free(), memtop_urealloc(), and nbi_process_segments().
| static __always_inline unsigned long virt_to_phys | ( | volatile const void * | addr | ) | [inline, static] |
Convert virtual address to a physical address.
| addr | Virtual address |
| phys_addr | Physical address |
Definition at line 248 of file uaccess.h.
References user_to_phys(), and virt_to_user().
Referenced by alloc_memblock(), arbel_create_eq(), arbel_poll_eq(), arbel_ring_doorbell(), check_region(), com32_exec(), gateA20_is_set(), hermon_alloc_mtt(), hermon_cmd(), hermon_create_cq(), hermon_create_qp(), hermon_poll_eq(), hermon_post_send(), hide_etherboot(), hide_textdata(), hide_umalloc(), jump_2ep(), linda_readq(), linda_writeq(), multiboot_add_cmdline(), multiboot_exec(), nbi_boot32(), pxe_start_nbp(), relocate(), virt_to_bus(), vp_find_vq(), vring_add_buf(), and vring_init().
00248 { 00249 return user_to_phys ( virt_to_user ( addr ), 0 ); 00250 }
| static __always_inline void* phys_to_virt | ( | unsigned long | phys_addr | ) | [inline, static] |
Convert physical address to a virtual address.
| addr | Virtual address |
| phys_addr | Physical address |
Definition at line 260 of file uaccess.h.
References phys_to_user(), and user_to_virt().
Referenced by aout_download(), arbel_alloc_icm(), bus_to_virt(), ce_loader(), com32_exec(), fnrec_init(), jump_2ep(), myri10ge_net_open(), video_init(), and vring_init().
00260 { 00261 return user_to_virt ( phys_to_user ( phys_addr ), 0 ); 00262 }
Copy data between user buffers.
| dest | Destination | |
| dest_off | Destination offset | |
| src | Source | |
| src_off | Source offset | |
| len | Length |
Referenced by bzimage_load(), bzimage_load_initrd(), com32_farcall(), com32_intcall(), comboot_load_image(), comboot_prepare_segment(), copy_from_user(), copy_to_user(), copy_user_to_rm_stack(), efi_urealloc(), elf_load_segment(), eltorito_load_disk(), int22(), multiboot_load_raw(), nbi_load_segment(), pxe_load(), ramdisk_read(), ramdisk_write(), and remove_user_from_rm_stack().
| static __always_inline void copy_to_user | ( | userptr_t | dest, | |
| off_t | dest_off, | |||
| const void * | src, | |||
| size_t | len | |||
| ) | [inline, static] |
Copy data to user buffer.
| dest | Destination | |
| dest_off | Destination offset | |
| src | Source | |
| len | Length |
Definition at line 285 of file uaccess.h.
References memcpy_user(), and virt_to_user().
Referenced by aoe_rx_ata(), bzimage_load_initrd(), bzimage_set_cmdline(), bzimage_update_header(), comboot_copy_cmdline(), comboot_init_psp(), copy_to_real(), downloader_xfer_deliver_iob(), efi_urealloc(), iscsi_rx_data_in(), memtop_urealloc(), pxe_api_call(), pxe_loader_call(), pxe_tftp_xfer_deliver_iob(), pxe_udp_deliver_iob(), pxenv_get_cached_info(), and read_user().
00285 { 00286 memcpy_user ( dest, dest_off, virt_to_user ( src ), 0, len ); 00287 }
| static __always_inline void copy_from_user | ( | void * | dest, | |
| userptr_t | src, | |||
| off_t | src_off, | |||
| size_t | len | |||
| ) | [inline, static] |
Copy data from user buffer.
| dest | Destination | |
| src | Source | |
| src_off | Source offset | |
| len | Length |
Definition at line 298 of file uaccess.h.
References memcpy_user(), and virt_to_user().
Referenced by aoe_send_command(), bzimage_parse_header(), com32_identify(), copy_from_real(), digest_exec(), ecollect_free(), efi_urealloc(), elf_load(), elfboot_load(), eltorito_read_catalog(), eltorito_read_voldesc(), find_smbios_structure(), find_strings_terminator(), gateA20_is_set(), int22(), iscsi_tx_data_out(), memtop_urealloc(), multiboot_find_header(), nbi_exec(), nbi_load(), nbi_process_segments(), print_user_string(), pxe_api_call(), pxe_loader_call(), pxenv_file_exec(), pxenv_file_open(), pxenv_udp_write(), read_smbios_string(), read_smbios_structure(), script_exec(), script_load(), shuffle(), and store_cached_dhcpack().
00298 { 00299 memcpy_user ( virt_to_user ( dest ), 0, src, src_off, len ); 00300 }
Copy data between user buffers, allowing for overlap.
| dest | Destination | |
| dest_off | Destination offset | |
| src | Source | |
| src_off | Source offset | |
| len | Length |
Referenced by memtop_urealloc(), and shuffle().
Fill user buffer with a constant byte.
| userptr | User buffer | |
| offset | Offset within buffer | |
| c | Constant byte with which to fill | |
| len | Length |
Referenced by comboot_prepare_segment(), prep_segment(), and shuffle().
Find length of NUL-terminated string in user buffer.
| userptr | User buffer | |
| offset | Offset within buffer |
| len | Length of string (excluding NUL) |
Referenced by int22(), pxenv_file_exec(), pxenv_file_open(), and read_smbios_string().
Find character in user buffer.
| userptr | User buffer | |
| offset | Starting offset within buffer | |
| c | Character to search for | |
| len | Length of user buffer |
| offset | Offset of character, or <0 if not found |
Referenced by script_exec().
1.5.7.1