iPXE
|
Dynamic memory allocation. More...
Go to the source code of this file.
Data Structures | |
struct | cache_discarder |
A cache discarder. More... | |
Macros | |
#define | CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" ) |
Cache discarder table. More... | |
#define | __cache_discarder(cost) __table_entry ( CACHE_DISCARDERS, cost ) |
Declare a cache discarder. More... | |
#define | CACHE_CHEAP 01 |
Items with a low replacement cost. More... | |
#define | CACHE_NORMAL 02 |
Items with a normal replacement cost. More... | |
#define | CACHE_EXPENSIVE 03 |
Items with a high replacement cost. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
void *__malloc | alloc_memblock (size_t size, size_t align, size_t offset) |
Allocate a memory block. More... | |
void | free_memblock (void *ptr, size_t size) |
Free a memory block. More... | |
void | mdumpfree (void) |
Dump free block list (for debugging) More... | |
static void *__malloc | malloc_phys_offset (size_t size, size_t phys_align, size_t offset) |
Allocate memory with specified physical alignment and offset. More... | |
static void *__malloc | malloc_phys (size_t size, size_t phys_align) |
Allocate memory with specified physical alignment. More... | |
static void | free_phys (void *ptr, size_t size) |
Free memory allocated with malloc_phys() More... | |
Variables | |
size_t | freemem |
Total amount of free memory. More... | |
size_t | usedmem |
Total amount of used memory. More... | |
size_t | maxusedmem |
Maximum amount of used memory. More... | |
struct cache_discarder | __attribute__ |
Dynamic memory allocation.
Definition in file malloc.h.
#define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" ) |
#define __cache_discarder | ( | cost | ) | __table_entry ( CACHE_DISCARDERS, cost ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Allocate a memory block.
size | Requested size |
align | Physical alignment |
offset | Offset from physical alignment |
ptr | Memory block, or NULL |
Allocates a memory block physically aligned as requested. No guarantees are provided for the alignment of the virtual address.
align
must be a power of two. size
may not be zero.
Definition at line 284 of file malloc.c.
References align, assert(), block, check_blocks(), DBGC, DBGC2, discard_cache(), done, freemem, heap, memory_block::list, list_add, list_del, list_for_each_entry, maxusedmem, MEMBLOCK_ALIGN, NULL, offset, size, memory_block::size, usedmem, valgrind_make_blocks_defined(), valgrind_make_blocks_noaccess(), VALGRIND_MAKE_MEM_NOACCESS, VALGRIND_MAKE_MEM_UNDEFINED, and virt_to_phys().
Referenced by malloc_phys_offset(), and realloc().
void free_memblock | ( | void * | ptr, |
size_t | size | ||
) |
Free a memory block.
ptr | Memory allocated by alloc_memblock(), or NULL |
size | Size of the memory |
If ptr
is NULL, no action is taken.
Definition at line 416 of file malloc.c.
References assert(), ASSERTING, block, check_blocks(), DBGC, DBGC2, freemem, heap, memory_block::list, list_add_tail, list_del, list_for_each_entry, list_for_each_entry_safe, MEMBLOCK_ALIGN, size, tmp, usedmem, valgrind_make_blocks_defined(), valgrind_make_blocks_noaccess(), VALGRIND_MAKE_MEM_NOACCESS, VALGRIND_MAKE_MEM_UNDEFINED, and virt_to_phys().
Referenced by free_phys(), mpopulate(), and realloc().
void mdumpfree | ( | void | ) |
Dump free block list (for debugging)
Definition at line 718 of file malloc.c.
References block, dbg_printf(), memory_block::list, and list_for_each_entry.
|
inlinestatic |
Allocate memory with specified physical alignment and offset.
size | Requested size |
align | Physical alignment |
offset | Offset from physical alignment |
ptr | Memory, or NULL |
align
must be a power of two. size
may not be zero.
Definition at line 43 of file malloc.h.
References alloc_memblock(), offset, size, and VALGRIND_MALLOCLIKE_BLOCK.
Referenced by alloc_iob_raw(), and malloc_phys().
Allocate memory with specified physical alignment.
size | Requested size |
align | Physical alignment |
ptr | Memory, or NULL |
align
must be a power of two. size
may not be zero.
Definition at line 61 of file malloc.h.
References malloc_phys_offset(), and size.
Referenced by __vxge_hw_fifo_create(), __vxge_hw_ring_create(), a3c90x_setup_rx_ring(), a3c90x_setup_tx_ring(), arbel_alloc(), arbel_alloc_icm(), arbel_create_cq(), arbel_create_eq(), arbel_create_recv_wq(), arbel_create_send_wq(), ath5k_desc_alloc(), ath_descdma_setup(), atl1e_setup_ring_resources(), b44_init_rx_ring(), b44_init_tx_ring(), bnxt_alloc_mem(), efx_hunt_alloc_special_buffer(), ehci_bus_open(), ehci_ring_alloc(), ena_create_admin(), ena_create_async(), ena_create_cq(), ena_create_sq(), ena_probe(), exanic_probe(), falcon_alloc_special_buffer(), golan_cmd_init(), golan_create_cq(), golan_create_eq(), golan_create_qp_aux(), hermon_alloc(), hermon_create_cq(), hermon_create_eq(), hermon_create_qp(), hv_alloc_message(), hv_alloc_pages(), hvm_map_hypercall(), icplus_create_ring(), ifec_net_open(), ifec_tx_setup(), igbvf_setup_rx_resources(), igbvf_setup_tx_resources(), jme_alloc_rx_resources(), jme_alloc_tx_resources(), linda_create_recv_wq(), linda_init_send(), mlx_memory_alloc_dma_priv(), myri10ge_net_open(), myson_create_ring(), natsemi_create_ring(), netfront_create_ring(), nv_init_rings(), pcnet32_setup_rx_resources(), pcnet32_setup_tx_resources(), phantom_create_rx_ctx(), phantom_create_tx_ctx(), phantom_open(), qib7322_create_recv_wq(), qib7322_init_send(), rhine_create_ring(), rtl818x_init_rx_ring(), rtl818x_init_tx_ring(), sis190_open(), skge_up(), sky2_probe(), sky2_up(), tg3_alloc_consistent(), tg3_test_dma(), uhci_bus_open(), uhci_enqueue(), uhci_ring_alloc(), velocity_alloc_rings(), vmbus_open(), and vmxnet3_open().
|
inlinestatic |
Free memory allocated with malloc_phys()
ptr | Memory allocated by malloc_phys(), or NULL |
size | Size of memory, as passed to malloc_phys() |
Memory allocated with malloc_phys() can only be freed with free_phys(); it cannot be freed with the standard free().
If ptr
is NULL, no action is taken.
Definition at line 76 of file malloc.h.
References free_memblock(), size, and VALGRIND_FREELIKE_BLOCK.
Referenced by __vxge_hw_fifo_delete(), __vxge_hw_ring_delete(), a3c90x_free_rx_ring(), a3c90x_free_tx_ring(), alloc_iob_raw(), arbel_alloc(), arbel_alloc_icm(), arbel_create_cq(), arbel_create_eq(), arbel_create_qp(), arbel_create_recv_wq(), arbel_destroy_cq(), arbel_destroy_eq(), arbel_destroy_qp(), arbel_free(), arbel_free_icm(), ath5k_desc_alloc(), ath5k_desc_free(), ath_descdma_cleanup(), ath_descdma_setup(), atl1e_free_ring_resources(), b44_free_rx_ring(), b44_free_tx_ring(), b44_init_rx_ring(), b44_init_tx_ring(), bnxt_free_mem(), efx_hunt_free_special_buffer(), ehci_bus_close(), ehci_bus_open(), ehci_ring_alloc(), ehci_ring_free(), ena_create_admin(), ena_create_async(), ena_create_cq(), ena_create_sq(), ena_destroy_admin(), ena_destroy_async(), ena_destroy_cq(), ena_destroy_sq(), ena_probe(), ena_remove(), exanic_probe(), exanic_remove(), falcon_free_special_buffer(), free_iob(), golan_cmd_init(), golan_cmd_uninit(), golan_create_cq(), golan_create_eq(), golan_create_qp_aux(), golan_destory_eq(), golan_destroy_cq(), golan_destroy_qp(), hermon_alloc(), hermon_create_cq(), hermon_create_eq(), hermon_create_qp(), hermon_destroy_cq(), hermon_destroy_eq(), hermon_destroy_qp(), hermon_free(), hv_alloc_pages(), hv_free_message(), hv_free_pages(), hvm_unmap_hypercall(), icplus_create_ring(), icplus_destroy_ring(), ifec_free(), ifec_net_open(), igbvf_free_rx_resources(), igbvf_free_tx_resources(), jme_free_rx_resources(), jme_free_tx_resources(), linda_create_recv_wq(), linda_destroy_recv_wq(), linda_fini_send(), linda_init_send(), mlx_memory_free_dma_priv(), myri10ge_net_close(), myri10ge_net_open(), myson_create_ring(), myson_destroy_ring(), natsemi_create_ring(), natsemi_destroy_ring(), netfront_create_ring(), netfront_destroy_ring(), nv_free_rxtx_resources(), pcnet32_free_rx_resources(), pcnet32_free_tx_resources(), phantom_close(), phantom_create_rx_ctx(), phantom_create_tx_ctx(), phantom_open(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_fini_send(), qib7322_init_send(), rhine_destroy_ring(), rtl818x_free_rx_ring(), rtl818x_free_tx_ring(), sis190_free(), skge_free(), sky2_free_rings(), sky2_probe(), sky2_remove(), tg3_free_consistent(), tg3_rx_prodring_fini(), tg3_test_dma(), uhci_bus_close(), uhci_bus_open(), uhci_dequeue(), uhci_enqueue(), uhci_ring_alloc(), uhci_ring_free(), velocity_alloc_rings(), velocity_close(), vmbus_close(), vmbus_open(), vmxnet3_close(), and vmxnet3_open().
size_t freemem |
Total amount of free memory.
Definition at line 95 of file malloc.c.
Referenced by alloc_memblock(), and free_memblock().
size_t usedmem |
Total amount of used memory.
Definition at line 98 of file malloc.c.
Referenced by alloc_memblock(), free_memblock(), and mpopulate().
size_t maxusedmem |
Maximum amount of used memory.
Definition at line 101 of file malloc.c.
Referenced by alloc_memblock(), and shutdown_cache().
struct cache_discarder __attribute__ |