lib: sysmem: add sysmem_alloc() interface

Change-Id: I3ae1fe618ba1bb9c7924bb9816884eb26927dc1e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-05-07 17:34:04 +08:00
parent d92ffd1e48
commit dcb404a677
2 changed files with 22 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#define _SYSMEM_H
#include <memblk.h>
#include <malloc.h>
/*
* CONFIG_SYS_FDT_PAD default value is sync with bootm framework in:
@ -121,6 +122,12 @@ static inline int sysmem_initr(void) { return 0; }
static inline int sysmem_free(phys_addr_t base) { return 0; }
static inline void sysmem_dump(void) {}
__weak int board_sysmem_reserve(struct sysmem *sysmem) { return 0; }
static inline void *sysmem_alloc(enum memblk_id id, phys_size_t size)
{
return malloc(size);
}
static inline void *sysmem_alloc_base(enum memblk_id id,
phys_addr_t base, phys_size_t size)
{

View File

@ -364,6 +364,21 @@ out:
return (attr.flags & M_ATTR_PEEK) ? (void *)base : NULL;
}
void *sysmem_alloc(enum memblk_id id, phys_size_t size)
{
void *paddr;
paddr = sysmem_alloc_align_base(id,
NULL,
SYSMEM_ALLOC_ANYWHERE,
size,
SYSMEM_ALLOC_NO_ALIGN);
if (!paddr)
sysmem_dump();
return paddr;
}
void *sysmem_alloc_base(enum memblk_id id, phys_addr_t base, phys_size_t size)
{
void *paddr;