void cbmem_add_lb_mem(struct lb_memory *mem) { unsigned long base; unsigned long top; base = (unsigned long)cbmem_base(); top = (unsigned long)get_top_aligned(); lb_add_memory_range(mem, LB_MEM_TABLE, base, top - base); }
void cbmem_add_bootmem(void) { uintptr_t base; uintptr_t top; base = cbmem_base(); top = get_top_aligned(); bootmem_add_range(base, top - base, LB_MEM_TABLE); }
const struct cbmem_entry *cbmem_entry_add(u32 id, u64 size64) { struct cbmem_root *root; const struct cbmem_entry *entry; unsigned long base; u32 size; u32 aligned_size; entry = cbmem_entry_find(id); if (entry != NULL) return entry; /* Only handle sizes <= UINT_MAX internally. */ if (size64 > (u64)UINT_MAX) return NULL; size = size64; root = get_root(); if (root == NULL) return NULL; /* Nothing can be added once it is locked down. */ if (root->locked) return NULL; if (root->max_entries == root->num_entries) return NULL; aligned_size = ALIGN(size, DYN_CBMEM_ALIGN_SIZE); base = (unsigned long)cbmem_base(); base -= aligned_size; return cbmem_entry_append(root, id, base, aligned_size); }