MCPcopy Create free account
hub / github.com/coreboot/coreboot / memalign

Function memalign

src/lib/malloc.c:22–56  ·  view source on GitHub ↗

We don't restrict the boundary. This is firmware, * you are supposed to know what you are doing. */

Source from the content-addressed store, hash-verified

20 * you are supposed to know what you are doing.
21 */
22void *memalign(size_t boundary, size_t size)
23{
24 void *p;
25
26 MALLOCDBG("%s Enter, boundary %zu, size %zu, free_mem_ptr %p\n",
27 __func__, boundary, size, free_mem_ptr);
28
29 free_mem_ptr = (void *)ALIGN_UP((unsigned long)free_mem_ptr, boundary);
30
31 p = free_mem_ptr;
32 free_mem_ptr += size;
33 /*
34 * Store last allocation pointer after ALIGN, as malloc() will
35 * return it. This may cause n bytes of gap between allocations
36 * where n < boundary.
37 */
38 free_last_alloc_ptr = p;
39
40 if (free_mem_ptr >= free_mem_end_ptr) {
41 printk(BIOS_ERR, "%s(boundary=%zu, size=%zu): failed: ",
42 __func__, boundary, size);
43 printk(BIOS_ERR, "Tried to round up free_mem_ptr %p to %p\n",
44 p, free_mem_ptr);
45 printk(BIOS_ERR, "but free_mem_end_ptr is %p\n",
46 free_mem_end_ptr);
47 printk(BIOS_ERR, "Error! %s: Out of memory "
48 "(free_mem_ptr >= free_mem_end_ptr)",
49 __func__);
50 return NULL;
51 }
52
53 MALLOCDBG("%s %p\n", __func__, p);
54
55 return p;
56}
57
58void *malloc(size_t size)
59{

Callers 8

mallocFunction · 0.70
bdk_sata_initializeFunction · 0.50
vnic_setup_cqFunction · 0.50
vnic_setup_rbdrFunction · 0.50
bdk_nic_port_initFunction · 0.50
xmemalign_workFunction · 0.50
bounce_buffer_startFunction · 0.50
allocate_hsphy_bufFunction · 0.50

Calls 1

printkFunction · 0.50

Tested by

no test coverage detected