|
iPXE
|
Dynamic memory allocation. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include <ipxe/io.h>#include <ipxe/list.h>#include <ipxe/init.h>#include <ipxe/refcnt.h>#include <ipxe/malloc.h>#include <valgrind/memcheck.h>Go to the source code of this file.
Data Structures | |
| struct | memory_block |
| A free block of memory. More... | |
| struct | autosized_block |
| A block of allocated memory complete with size information. More... | |
Macros | |
| #define | MIN_MEMBLOCK_ALIGN ( 4 * sizeof ( void * ) ) |
| Physical address alignment maintained for free blocks of memory. | |
| #define | HEAP_SIZE ( 4096 * 1024 ) |
| Heap area size. | |
| #define | HEAP_ALIGN MIN_MEMBLOCK_ALIGN |
| Heap area alignment. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| static void | valgrind_make_blocks_defined (struct heap *heap) |
| Mark all blocks in free list as defined. | |
| static void | valgrind_make_blocks_noaccess (struct heap *heap) |
| Mark all blocks in free list as inaccessible. | |
| static void | check_blocks (struct heap *heap) |
| Check integrity of the blocks in the free list. | |
| static unsigned int | discard_cache (size_t size __unused) |
| Discard some cached data. | |
| static void | discard_all_cache (void) |
| Discard all cached data. | |
| static void * | heap_alloc_block (struct heap *heap, size_t size, size_t align, size_t offset) |
| Allocate a memory block. | |
| static void | heap_free_block (struct heap *heap, void *ptr, size_t size) |
| Free a memory block. | |
| void * | heap_realloc (struct heap *heap, void *old_ptr, size_t new_size) |
| Reallocate memory. | |
| void * | realloc (void *old_ptr, size_t new_size) |
| Reallocate memory. | |
| void * | malloc (size_t size) |
| Allocate memory. | |
| void | free (void *ptr) |
| Free memory. | |
| void * | zalloc (size_t size) |
| Allocate cleared memory. | |
| void | zfree (void *ptr) |
| Clear and free memory. | |
| void * | malloc_phys_offset (size_t size, size_t phys_align, size_t offset) |
| Allocate memory with specified physical alignment and offset. | |
| void * | malloc_phys (size_t size, size_t phys_align) |
| Allocate memory with specified physical alignment. | |
| void | free_phys (void *ptr, size_t size) |
| Free memory allocated with malloc_phys(). | |
| void | heap_populate (struct heap *heap, void *start, size_t len) |
| Add memory to allocation pool. | |
| static void | init_heap (void) |
| Initialise the heap. | |
| struct init_fn heap_init_fn | __init_fn (INIT_EARLY) |
| Memory allocator initialisation function. | |
| static void | shutdown_cache (int booting __unused) |
| Discard all cached data on shutdown. | |
| struct startup_fn heap_startup_fn | __startup_fn (STARTUP_EARLY) |
| Memory allocator shutdown function. | |
| void | heap_dump (struct heap *heap) |
| Dump free block list (for debugging). | |
Variables | |
| static char | heap_area [HEAP_SIZE] |
| The heap area. | |
| static struct heap | heap |
| The global heap. | |
Dynamic memory allocation.
Memory allocation via malloc() is provided using a simple free-block list in a fixed-size heap.
The standard C semantics are supported. Calling realloc() with a size of zero is a valid way to free a block. Calling malloc() or realloc() with a size of zero will return a non-NULL value that can safely be passed to free() (meaning that callers can always treat a NULL return value as an error, without having to special-case a zero-length allocation).
(The POSIX semantics of setting a global errno variable on allocation failure are not supported: callers should check for a NULL return value and then return -ENOMEM as per the usual iPXE error propagation conventions.)
Memory allocation assumes that all input parameters are untrusted and must be checked. In particular, buffer sizes are frequently derived from untrusted input obtained via the network (e.g. an HTTP Content-Length header).
In contrast, memory deallocation assumes that the caller is always passing in a valid pointer value.
The internal heap is relatively small. Allocation is expected to sometimes fail in normal operation, and all callers must be prepared to handle it cleanly. Device drivers attempting to allocate receive buffers to refill a receive ring can simply exit the refill loop and do nothing until the next refill opportunity. Other callers will generally have to treat allocation failure as fatal and cleanly terminate their operation (e.g. by closing a connection).
The same internal heap supports both size-tracked allocations (using malloc()/free()) and known-size allocations (using malloc_phys()/free_phys(), where the caller must pass the original size when freeing the block). The latter are typically used for I/O buffers, driver descriptor rings, and other hardware-facing structures.
Depending upon the build platform, the underlying heap implementation may also be used to support external ("user") allocations using umalloc() and ufree().
A cache discard mechanism exists to attempt to alleviate memory pressure by discarding cached information (such as packets held in a TCP out-of-order receive queue) when an allocation attempt would otherwise fail. Code that holds pointers to discardable objects must be careful not to call any allocation functions.
Definition in file malloc.c.
| #define MIN_MEMBLOCK_ALIGN ( 4 * sizeof ( void * ) ) |
Physical address alignment maintained for free blocks of memory.
We keep memory blocks aligned on a power of two that is at least large enough to hold a struct memory_block.
Definition at line 118 of file malloc.c.
Referenced by init_heap().
| #define HEAP_SIZE ( 4096 * 1024 ) |
| #define HEAP_ALIGN MIN_MEMBLOCK_ALIGN |
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
inlinestatic |
Mark all blocks in free list as defined.
| heap | Heap |
Definition at line 146 of file malloc.c.
References block, heap::blocks, memory_block::list, list_for_each_entry, list_head::next, list_head::prev, RUNNING_ON_VALGRIND, and VALGRIND_MAKE_MEM_DEFINED.
Referenced by heap_alloc_block(), and heap_free_block().
|
inlinestatic |
Mark all blocks in free list as inaccessible.
| heap | Heap |
Definition at line 188 of file malloc.c.
References block, heap::blocks, memory_block::list, list_for_each_entry, list_head::next, NULL, list_head::prev, RUNNING_ON_VALGRIND, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by heap_alloc_block(), and heap_free_block().
|
inlinestatic |
Check integrity of the blocks in the free list.
| heap | Heap |
Definition at line 237 of file malloc.c.
References heap::align, assert, ASSERTING, block, heap::blocks, memory_block::list, list_check, list_for_each_entry, and NULL.
Referenced by heap_alloc_block(), and heap_free_block().
Discard some cached data.
| size | Failed allocation size |
| discarded | Number of cached items discarded |
Definition at line 279 of file malloc.c.
References __unused, CACHE_DISCARDERS, cache_discarder::discard, for_each_table_entry, and size.
Referenced by discard_all_cache().
|
static |
Discard all cached data.
Definition at line 295 of file malloc.c.
References discard_cache().
Referenced by shutdown_cache().
Allocate a memory block.
| 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 317 of file malloc.c.
References heap::align, assert, block, heap::blocks, check_blocks(), DBGC, DBGC2, done, heap::freemem, heap::grow, memory_block::list, list_add, list_del, list_for_each_entry, heap::maxusedmem, NULL, offset, memory_block::size, size, heap::usedmem, valgrind_make_blocks_defined(), valgrind_make_blocks_noaccess(), VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by heap_realloc(), and malloc_phys_offset().
Free a memory block.
| heap | Heap |
| ptr | Memory allocated by heap_alloc_block(), or NULL |
| size | Size of the memory |
If ptr is NULL, no action is taken.
Definition at line 463 of file malloc.c.
References heap::align, assert, ASSERTING, block, heap::blocks, check_blocks(), DBGC, DBGC2, heap::freemem, memory_block::list, list_add_tail, list_del, list_for_each_entry, list_for_each_entry_safe, heap::shrink, memory_block::size, size, tmp, heap::usedmem, valgrind_make_blocks_defined(), valgrind_make_blocks_noaccess(), VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by free_phys(), heap_populate(), and heap_realloc().
Reallocate memory.
| heap | Heap |
| old_ptr | Memory previously allocated by heap_realloc(), or NULL |
| new_size | Requested size |
| new_ptr | Allocated memory, or NULL |
Allocates memory with no particular alignment requirement. new_ptr will be aligned to at least a multiple of sizeof(void*). If old_ptr is non-NULL, then the contents of the newly allocated memory will be the same as the contents of the previously allocated memory, up to the minimum of the old and new sizes. The old memory will be freed.
If allocation fails the previously allocated block is left untouched and NULL is returned.
Calling heap_realloc() with a new size of zero is a valid way to free a memory block.
Definition at line 593 of file malloc.c.
References assert, ASSERTED, container_of, autosized_block::data, data, DBGC, heap_alloc_block(), heap_free_block(), memcpy(), NOWHERE, NULL, offset, offsetof, heap::ptr_align, autosized_block::size, VALGRIND_FREELIKE_BLOCK, VALGRIND_MAKE_MEM_DEFINED, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MALLOCLIKE_BLOCK.
Referenced by realloc(), and uheap_realloc().
| void * realloc | ( | void * | old_ptr, |
| size_t | new_size ) |
Reallocate memory.
| old_ptr | Memory previously allocated by malloc(), or NULL |
| new_size | Requested size |
| new_ptr | Allocated memory, or NULL |
Definition at line 663 of file malloc.c.
References heap_realloc().
Referenced by __attribute__(), asn1_grow(), bitmap_resize(), cachedhcp_record(), dhcpopt_init(), efi_ifr_op(), efi_ifr_string(), efivars_find(), free(), ibft_alloc_string(), ibft_install(), line_buffer(), malloc(), nvo_realloc(), process_script(), and xferbuf_malloc_realloc().
| void * malloc | ( | size_t | size | ) |
Allocate memory.
| size | Requested size |
| ptr | Memory, or NULL |
Allocates memory with no particular alignment requirement. ptr will be aligned to at least a multiple of sizeof(void*).
Definition at line 677 of file malloc.c.
References ASSERTED, DBGC, NULL, realloc(), and size.
Referenced by add_tls(), aes_unwrap(), aes_wrap(), alloc_iob_raw(), apply_dns_search(), ath5k_hw_rfregs_init(), chap_init(), datauri_open(), deflate_test_exec(), der_asn1(), derwin(), dhcpv6_rx(), dupwin(), eap_rx_mschapv2_request(), eap_tx_response(), ecdsa_alloc(), efi_block_label(), efi_boot_path(), efi_cacert_all(), efi_download_start(), efi_load_path(), efi_local_check_volume_name(), efi_local_len(), efi_locate_device(), efi_vasprintf(), efivars_fetch(), eisabus_probe(), exchange_okx(), fc_ulp_login(), fetch_setting_copy(), ffdhe(), format_uri_alloc(), http_format_ntlm_auth(), icert_encode(), int13_hook(), ipair_rx_pubkey(), ipoib_map_remac(), ipv4_add_miniroute(), isabus_probe(), isapnpbus_probe(), iscsi_handle_chap_c_value(), iscsi_handle_chap_r_value(), iscsi_rx_buffered_data(), iscsi_scsi_command(), jme_alloc_rx_resources(), jme_alloc_tx_resources(), lldp_rx(), loopback_test(), mcabus_probe(), memcpy_test_speed(), mlx_memory_alloc_priv(), net80211_probe_start(), net80211_register(), newwin(), nfs_uri_symlink(), ntlm_authenticate_okx(), ocsp_response(), ocsp_uri_string(), parse_kv(), parse_net_args(), pci_vpd_resize(), pcibus_probe(), peerblk_decrypt(), peerblk_parse_header(), pem_asn1(), rsa_alloc(), sandev_parse_iso9660(), slirp_timer_new(), storef_setting(), storen_setting(), strndup(), t509bus_probe(), tls_new_session_ticket(), tls_send_client_key_exchange_dhe(), uhci_enqueue(), usb_config_descriptor(), usb_get_string_descriptor(), usbio_config(), usbio_path(), vasprintf(), vesafb_mode_list(), vmbus_open(), wpa_make_rsn_ie(), wpa_start(), and zalloc().
| void free | ( | void * | ptr | ) |
Free memory.
| ptr | Memory allocated by malloc(), or NULL |
Memory allocated with malloc_phys() cannot be freed with free(); it must be freed with free_phys() instead.
If ptr is NULL, no action is taken.
| void * zalloc | ( | size_t | size | ) |
Allocate cleared memory.
| size | Requested size |
| ptr | Allocated memory |
Allocate memory as per malloc(), and zero it.
This function name is non-standard, but pretty intuitive. zalloc(size) is always equivalent to calloc(1,size)
Definition at line 718 of file malloc.c.
References ASSERTED, data, DBGC, malloc(), memset(), and size.
Referenced by add_dynui_item(), add_parameter(), alloc_form(), alloc_gpios(), alloc_ibdev(), alloc_image(), alloc_netdev(), alloc_pixbuf(), alloc_sandev(), alloc_uart(), alloc_usb(), alloc_usb_bus(), alloc_usb_hub(), aoecmd_create(), aoedev_open(), ar9300_eeprom_restore_internal(), arbel_alloc(), arbel_create_cq(), arbel_create_qp(), ata_open(), atadev_command(), ath5k_hw_attach(), ath5k_probe(), ath9k_init_softc(), ath_descdma_setup(), atl1e_setup_ring_resources(), autovivify_child_settings(), blob_open(), block_translate(), cachedhcp_record(), calloc(), cms_message(), cms_parse_participants(), concat_args(), cpio_okx(), create_downloader(), create_dynui(), create_parameters(), create_pinger(), create_validator(), dhcp_deliver(), dhcpv6_register(), dns_resolv(), dt_probe_node(), dwgpio_group_probe(), dwusb_probe(), efi_block_exec(), efi_block_install(), efi_cmdline_init(), efi_fcp_path(), efi_file_open_image(), efi_ib_srp_path(), efi_image_filepath(), efi_image_uripath(), efi_iscsi_path(), efi_local_open(), efi_netdev_path(), efi_path_uri(), efi_paths(), efi_pxe_install(), efi_snp_hii_fetch(), efi_snp_hii_install(), efi_snp_hii_process(), efi_snp_hii_store(), efi_snp_probe(), efi_uri_path(), efi_usb_install(), efi_usb_open(), efi_usb_path(), efi_usb_probe(), efidev_alloc(), efipci_start(), efivars_find(), ehci_endpoint_open(), ehci_probe(), ehci_ring_alloc(), eoib_create_peer(), exanic_probe(), fc_els_create(), fc_ns_query(), fc_peer_create(), fc_port_open(), fc_ulp_create(), fc_xchg_create(), fcpdev_open(), fcpdev_scsi_command(), fetch_string_setting_copy_alloc(), fetchf_setting_copy(), flexboot_nodnic_create_cq(), flexboot_nodnic_create_qp(), flexboot_nodnic_eth_open(), flexboot_nodnic_probe(), fragment_reassemble(), ftp_open(), generic_settings_store(), golan_alloc(), golan_create_cq(), golan_create_qp_aux(), guestinfo_fetch_type(), hermon_alloc(), hermon_create_cq(), hermon_create_qp(), http_connect(), http_open(), http_open_uri(), hub_probe(), hv_probe(), hvm_probe(), ib_cmrc_open(), ib_create_conn(), ib_create_cq(), ib_create_madx(), ib_create_mi(), ib_create_path(), ib_create_qp(), ib_mcast_attach(), ib_srp_open(), ibft_install(), icert_certs(), imux_probe(), init_mlx_utils(), ipair_create(), ipv6_add_miniroute(), iscsi_open(), linda_create_send_wq(), mlx_memory_zalloc_priv(), ndp_register_settings(), neighbour_create(), net80211_handle_mgmt(), net80211_prepare_assoc(), net80211_probe_start(), net80211_probe_step(), net80211_step_associate(), nfs_open(), nii_map(), numeric_resolv(), ocsp_check(), ocsp_uri_string(), open(), parse_uri(), pcibridge_probe(), peerblk_open(), peerdisc_create(), peerdisc_discovered(), peermux_filter(), ping_open(), png_pixbuf(), pxe_menu_parse(), qib7322_create_send_bufs(), qib7322_create_send_wq(), qib7322_probe(), rc80211_init(), resolv(), resolv_setting(), rtl818x_probe(), scsi_open(), scsidev_command(), sec80211_install(), sis190_mii_probe(), skge_probe(), skge_ring_alloc(), sky2_probe(), sky2_up(), slam_open(), srp_open(), srpdev_scsi_command(), start_dhcp(), start_dhcpv6(), start_ipv6conf(), start_ntp(), start_pxebs(), tcp_open(), tftp_core_open(), tg3_alloc_consistent(), tls_agree_ephemeral(), tls_session(), tls_set_cipher(), tls_set_digest(), txnic_bgx_probe(), txnic_pf_probe(), ucode_exec(), udp_open_common(), uhci_endpoint_open(), uhci_probe(), undipci_probe(), undirom_probe(), uri_dup(), usb_probe_all(), usbblk_probe(), usbio_endpoint_open(), usbio_interfaces(), usbio_interrupt_open(), usbio_start(), usbkbd_probe(), validator_start_download(), vmbus_probe(), vmbus_probe_channels(), vxge_hw_device_initialize(), x509_alloc_chain(), x509_append(), x509_certificate(), xcm_create(), xenbus_probe_device(), xenstore_response(), xfer_open_named_socket(), xhci_bus_open(), xhci_device_open(), xhci_endpoint_open(), xhci_probe(), xhci_ring_alloc(), xsigo_ib_probe(), xve_create(), and zlib_deflate().
| void zfree | ( | void * | ptr | ) |
Clear and free memory.
| ptr | Memory allocated by malloc(), or NULL |
If ptr is NULL, no action is taken.
Definition at line 738 of file malloc.c.
References assert, ASSERTED, block, container_of, data, DBGC, free, memset(), NOWHERE, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by aes_unwrap(), aes_wrap(), asn1_grow(), chap_finish(), cms_cipher_key(), ecdsa_free(), ffdhe(), free_tls(), free_tls_session(), privkey_apply_settings(), privkey_free(), rsa_free(), tls_agree_ephemeral(), tls_clear_cipher(), tls_clear_digest(), tls_new_finished(), tls_new_session_ticket(), tls_send_certificate_verify(), tls_send_client_key_exchange_dhe(), and tls_send_client_key_exchange_pubkey().
Allocate memory with specified physical alignment and offset.
| ptr | Memory, or NULL |
align must be a power of two. size may not be zero.
Definition at line 767 of file malloc.c.
References assert, heap_alloc_block(), 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 789 of file malloc.c.
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(), 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(), legacy_probe(), 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(), uhci_bus_open(), uhci_enqueue(), uhci_ring_alloc(), velocity_alloc_rings(), vmbus_open(), and vmxnet3_open().
| void free_phys | ( | void * | ptr, |
| size_t | size ) |
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 805 of file malloc.c.
References heap_free_block(), 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(), 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(), legacy_probe(), legacy_remove(), 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(), 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().
Add memory to allocation pool.
Adds a block of memory to the allocation pool. The memory must be aligned to the heap's required free memory block alignment.
Definition at line 821 of file malloc.c.
References heap::align, assert, heap_free_block(), len, start, and heap::usedmem.
Referenced by init_heap(), and uheap_grow().
|
static |
Initialise the heap.
Definition at line 838 of file malloc.c.
References heap::blocks, build_assert, heap_area, heap_populate(), MIN_MEMBLOCK_ALIGN, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by __init_fn().
| struct init_fn heap_init_fn __init_fn | ( | INIT_EARLY | ) |
Memory allocator initialisation function.
References __init_fn, INIT_EARLY, and init_heap().
|
static |
Discard all cached data on shutdown.
Definition at line 859 of file malloc.c.
References __unused, DBGC, discard_all_cache(), and heap::maxusedmem.
Referenced by __startup_fn().
| struct startup_fn heap_startup_fn __startup_fn | ( | STARTUP_EARLY | ) |
Memory allocator shutdown function.
References __startup_fn, shutdown_cache(), and STARTUP_EARLY.
| void heap_dump | ( | struct heap * | heap | ) |
Dump free block list (for debugging).
Definition at line 875 of file malloc.c.
References block, heap::blocks, dbg_printf(), memory_block::list, and list_for_each_entry.
|
static |
|
static |
The global heap.
Definition at line 649 of file malloc.c.