iPXE
Macros | Functions
umalloc.h File Reference

User memory allocation. More...

#include <ipxe/api.h>
#include <config/umalloc.h>
#include <ipxe/uaccess.h>
#include <ipxe/efi/efi_umalloc.h>
#include <ipxe/linux/linux_umalloc.h>
#include <bits/umalloc.h>

Go to the source code of this file.

Macros

#define PROVIDE_UMALLOC(_subsys, _api_func, _func)   PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func )
 Provide a user memory allocation API implementation. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
userptr_t urealloc (userptr_t userptr, size_t new_size)
 Reallocate external memory. More...
 
static __always_inline userptr_t umalloc (size_t size)
 Allocate external memory. More...
 
static __always_inline void ufree (userptr_t userptr)
 Free external memory. More...
 

Detailed Description

User memory allocation.

Definition in file umalloc.h.

Macro Definition Documentation

◆ PROVIDE_UMALLOC

#define PROVIDE_UMALLOC (   _subsys,
  _api_func,
  _func 
)    PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func )

Provide a user memory allocation API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 24 of file umalloc.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ urealloc()

userptr_t urealloc ( userptr_t  userptr,
size_t  new_size 
)

Reallocate external memory.

Parameters
userptrMemory previously allocated by umalloc(), or UNULL
new_sizeRequested size
Return values
userptrAllocated memory, or UNULL

Calling realloc() with a new size of zero is a valid way to free a memory block.

Referenced by ufree(), umalloc(), umalloc_test(), and xferbuf_umalloc_realloc().

◆ umalloc()

static __always_inline userptr_t umalloc ( size_t  size)
inlinestatic

Allocate external memory.

Parameters
sizeRequested size
Return values
userptrMemory, or UNULL

Memory is guaranteed to be aligned to a page boundary.

Definition at line 54 of file umalloc.h.

54  {
55  return urealloc ( UNULL, size );
56 }
userptr_t urealloc(userptr_t userptr, size_t new_size)
Reallocate external memory.
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16

References size, UNULL, and urealloc().

Referenced by alloc_pixbuf(), arbel_alloc_icm(), arbel_start_firmware(), efifb_glyphs(), exanic_probe_port(), fbcon_init(), fbcon_picture_init(), golan_provide_pages(), hermon_map_icm(), hermon_start_firmware(), initrd_init(), netvsc_create_buffer(), nii_initialise_flags(), png_image_header(), txnic_alloc(), umalloc_test(), and xhci_scratchpad_alloc().

◆ ufree()

static __always_inline void ufree ( userptr_t  userptr)
inlinestatic

Free external memory.

Parameters
userptrMemory allocated by umalloc(), or UNULL

If ptr is UNULL, no action is taken.

Definition at line 65 of file umalloc.h.

65  {
66  urealloc ( userptr, 0 );
67 }
userptr_t urealloc(userptr_t userptr, size_t new_size)
Reallocate external memory.

References urealloc().

Referenced by arbel_free(), efifb_fini(), efifb_glyphs(), efifb_init(), exanic_probe_port(), exanic_remove_port(), fbcon_fini(), fbcon_init(), fbcon_picture_init(), free_image(), free_pixbuf(), golan_free_fw_areas(), hermon_free(), netvsc_create_buffer(), netvsc_destroy_buffer(), nii_initialise_flags(), nii_shutdown(), png_pixbuf(), txnic_alloc(), txnic_free(), umalloc_test(), xhci_scratchpad_alloc(), and xhci_scratchpad_free().