sysmem: simplify the memblk name
Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: Icfe908ade21d1d8f568db796298f67ba9f013da6
This commit is contained in:
parent
98de7945ac
commit
c01d448924
|
|
@ -772,19 +772,19 @@ int board_bidram_reserve(struct bidram *bidram)
|
|||
|
||||
/* ATF */
|
||||
mem = param_parse_atf_mem();
|
||||
ret = bidram_reserve(MEMBLK_ID_ATF, mem.base, mem.size);
|
||||
ret = bidram_reserve(MEM_ATF, mem.base, mem.size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* PSTORE/ATAGS/SHM */
|
||||
mem = param_parse_common_resv_mem();
|
||||
ret = bidram_reserve(MEMBLK_ID_SHM, mem.base, mem.size);
|
||||
ret = bidram_reserve(MEM_SHM, mem.base, mem.size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* OP-TEE */
|
||||
mem = param_parse_optee_mem();
|
||||
ret = bidram_reserve(MEMBLK_ID_OPTEE, mem.base, mem.size);
|
||||
ret = bidram_reserve(MEM_OPTEE, mem.base, mem.size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,84 +6,67 @@
|
|||
#include <common.h>
|
||||
#include <memblk.h>
|
||||
|
||||
const static struct memblk_attr plat_mem_attr[MEMBLK_ID_MAX] = {
|
||||
[MEMBLK_ID_ATF] = {
|
||||
.name = "ATF",
|
||||
.flags = M_ATTR_NONE,
|
||||
},
|
||||
[MEMBLK_ID_OPTEE] = {
|
||||
.name = "OP-TEE",
|
||||
.flags = M_ATTR_NONE,
|
||||
},
|
||||
[MEMBLK_ID_SHM] = {
|
||||
.name = "SHM",
|
||||
.flags = M_ATTR_NONE,
|
||||
.alias[0] = "ramoops",
|
||||
},
|
||||
[MEMBLK_ID_UBOOT] = {
|
||||
.name = "U-Boot",
|
||||
.flags = M_ATTR_KMEM_CAN_OVERLAP,
|
||||
},
|
||||
[MEMBLK_ID_FASTBOOT] = {
|
||||
.name = "FASTBOOT",
|
||||
.flags = M_ATTR_KMEM_CAN_OVERLAP,
|
||||
},
|
||||
[MEMBLK_ID_STACK] = {
|
||||
.name = "STACK",
|
||||
.flags = M_ATTR_HOFC | M_ATTR_KMEM_CAN_OVERLAP,
|
||||
},
|
||||
[MEMBLK_ID_FDT] = {
|
||||
.name = "FDT",
|
||||
.flags = M_ATTR_OFC,
|
||||
},
|
||||
[MEMBLK_ID_FDT_DTBO] = {
|
||||
.name = "FDT_DTBO",
|
||||
.flags = M_ATTR_OFC,
|
||||
},
|
||||
[MEMBLK_ID_FDT_AOSP] = {
|
||||
.name = "FDT_AOSP",
|
||||
.flags = M_ATTR_OFC,
|
||||
},
|
||||
[MEMBLK_ID_RAMDISK] = {
|
||||
.name = "RAMDISK",
|
||||
.alias[0] = "BOOT",
|
||||
.alias[1] = "RECOVERY",
|
||||
.flags = M_ATTR_OFC,
|
||||
},
|
||||
[MEMBLK_ID_KERNEL] = {
|
||||
.name = "KERNEL",
|
||||
/*
|
||||
* Here is a workarund:
|
||||
* ATF reserves 0~1MB when kernel is aarch32 mode(follow the ATF for
|
||||
* aarch64 kernel, but it actually occupies 0~192KB, so we allow kernel
|
||||
* to alloc the region within 0~1MB address.
|
||||
#define MEM_DEFINE(id, attr) \
|
||||
[MEM_##id] = { \
|
||||
.name = #id, \
|
||||
.flags = attr, \
|
||||
}
|
||||
|
||||
#define MEM_DEFINE_1(id, attr, alias0) \
|
||||
[MEM_##id] = { \
|
||||
.name = #id, \
|
||||
.flags = attr, \
|
||||
.alias[0] = alias0, \
|
||||
}
|
||||
|
||||
#define MEM_DEFINE_2(id, attr, alias0, alias1) \
|
||||
[MEM_##id] = { \
|
||||
.name = #id, \
|
||||
.flags = attr, \
|
||||
.alias[0] = alias0, \
|
||||
.alias[1] = alias1, \
|
||||
}
|
||||
|
||||
const static struct memblk_attr plat_mem_attr[MEM_MAX] = {
|
||||
/* Invisiable */
|
||||
MEM_DEFINE(ATF, F_NONE),
|
||||
MEM_DEFINE(OPTEE, F_NONE),
|
||||
|
||||
/* U-Boot */
|
||||
MEM_DEFINE(UBOOT, F_KMEM_CAN_OVERLAP),
|
||||
MEM_DEFINE(FASTBOOT, F_KMEM_CAN_OVERLAP),
|
||||
MEM_DEFINE(STACK, F_HOFC | F_KMEM_CAN_OVERLAP),
|
||||
|
||||
/* Images */
|
||||
MEM_DEFINE(ANDROID, F_HOFC | F_OFC | F_KMEM_CAN_OVERLAP),
|
||||
MEM_DEFINE(FDT, F_OFC),
|
||||
MEM_DEFINE(FDT_DTBO, F_OFC),
|
||||
MEM_DEFINE_1(SHM, F_NONE, "ramoops"),
|
||||
MEM_DEFINE_2(RAMDISK, F_OFC, "boot", "recovery"),
|
||||
MEM_DEFINE(UNCOMP_KERNEL,F_IGNORE_INVISIBLE),
|
||||
MEM_DEFINE(FIT_USER, F_OFC | F_KMEM_CAN_OVERLAP),
|
||||
MEM_DEFINE(UIMAGE_USER, F_OFC | F_KMEM_CAN_OVERLAP),
|
||||
MEM_DEFINE(AVB_ANDROID, F_OFC | F_CACHELINE_ALIGN |
|
||||
F_KMEM_CAN_OVERLAP | F_HIGHEST_MEM),
|
||||
MEM_DEFINE(FIT, F_OFC | F_CACHELINE_ALIGN |
|
||||
F_KMEM_CAN_OVERLAP | F_HIGHEST_MEM),
|
||||
MEM_DEFINE(UIMAGE, F_OFC | F_CACHELINE_ALIGN |
|
||||
F_KMEM_CAN_OVERLAP | F_HIGHEST_MEM),
|
||||
MEM_DEFINE(RESOURCE, F_OFC),
|
||||
MEM_DEFINE(SEARCH, F_OFC | F_CACHELINE_ALIGN | F_NO_FAIL_DUMP |
|
||||
F_KMEM_CAN_OVERLAP | F_HIGHEST_MEM),
|
||||
/*
|
||||
* Workarund:
|
||||
*
|
||||
* On aarch32 mode, ATF reserve 0~1MB memory that the same as aarch64
|
||||
* mode, but aarch32 mode actually occupies 0~192KB.
|
||||
* So that we allow kernel to alloc memory within 0~1MB.
|
||||
*/
|
||||
#if defined(CONFIG_ROCKCHIP_RK3308) && defined(CONFIG_ARM64_BOOT_AARCH32)
|
||||
.flags = M_ATTR_OFC | M_ATTR_IGNORE_INVISIBLE,
|
||||
MEM_DEFINE(KERNEL, F_OFC | F_IGNORE_INVISIBLE),
|
||||
#else
|
||||
.flags = M_ATTR_OFC,
|
||||
MEM_DEFINE(KERNEL, F_OFC),
|
||||
#endif
|
||||
},
|
||||
[MEMBLK_ID_UNCOMP_KERNEL] = {
|
||||
.name = "UNCOMPRESS-KERNEL",
|
||||
.flags = M_ATTR_IGNORE_INVISIBLE,
|
||||
},
|
||||
[MEMBLK_ID_ANDROID] = {
|
||||
.name = "ANDROID",
|
||||
.flags = M_ATTR_OFC | M_ATTR_KMEM_CAN_OVERLAP,
|
||||
},
|
||||
[MEMBLK_ID_AVB_ANDROID] = {
|
||||
.name = "AVB_ANDROID",
|
||||
.flags = M_ATTR_OFC | M_ATTR_CACHELINE_ALIGN |
|
||||
M_ATTR_KMEM_CAN_OVERLAP |
|
||||
M_ATTR_HIGHEST_MEM,
|
||||
},
|
||||
[MEMBLK_ID_FIT] = {
|
||||
.name = "FIT",
|
||||
.flags = M_ATTR_OFC | M_ATTR_CACHELINE_ALIGN |
|
||||
M_ATTR_KMEM_CAN_OVERLAP |
|
||||
M_ATTR_HIGHEST_MEM,
|
||||
},
|
||||
};
|
||||
|
||||
const struct memblk_attr *mem_attr = plat_mem_attr;
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ static int rockchip_read_distro_dtb(void *fdt_addr)
|
|||
return -EIO;
|
||||
|
||||
size = fdt_totalsize(fdt_addr);
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_FDT, (phys_addr_t)fdt_addr,
|
||||
if (!sysmem_alloc_base(MEM_FDT, (phys_addr_t)fdt_addr,
|
||||
ALIGN(size, RK_BLK_SIZE) + CONFIG_SYS_FDT_PAD))
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -1001,7 +1001,7 @@ int rockchip_read_dtb_file(void *fdt_addr)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_FDT, (phys_addr_t)fdt_addr,
|
||||
if (!sysmem_alloc_base(MEM_FDT, (phys_addr_t)fdt_addr,
|
||||
ALIGN(file->f_size, RK_BLK_SIZE) +
|
||||
CONFIG_SYS_FDT_PAD))
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ static int boot_rockchip_image(struct blk_desc *dev_desc,
|
|||
kaddr = kaddr_r;
|
||||
ksize = kernel_size * 100 / 45 ; /* Ratio: 45% */
|
||||
ksize = ALIGN(ksize, dev_desc->blksz);
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_UNCOMP_KERNEL,
|
||||
if (!sysmem_alloc_base(MEM_UNCOMP_KERNEL,
|
||||
(phys_addr_t)kaddr, ksize))
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_FASTBOOT,
|
||||
if (!sysmem_alloc_base(MEM_FASTBOOT,
|
||||
CONFIG_FASTBOOT_BUF_ADDR,
|
||||
CONFIG_FASTBOOT_BUF_SIZE)) {
|
||||
printf("The fastboot memory space is unusable!\n");
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ static int sysmem_alloc_uncomp_kernel(ulong andr_hdr,
|
|||
|
||||
kaddr = uncomp_kaddr;
|
||||
ksize = ALIGN(ksize, 512);
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_UNCOMP_KERNEL,
|
||||
if (!sysmem_alloc_base(MEM_UNCOMP_KERNEL,
|
||||
(phys_addr_t)kaddr, ksize))
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -1029,7 +1029,7 @@ int android_fdt_overlay_apply(void *fdt_addr)
|
|||
if (sysmem_free((phys_addr_t)fdt_addr))
|
||||
goto out;
|
||||
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_FDT_DTBO,
|
||||
if (!sysmem_alloc_base(MEM_FDT_DTBO,
|
||||
(phys_addr_t)fdt_addr,
|
||||
fdt_size + CONFIG_SYS_FDT_PAD))
|
||||
goto out;
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ static int image_read(img_t img, struct andr_img_hdr *hdr,
|
|||
ramdst = (void *)env_get_ulong("android_addr_r", 16, 0);
|
||||
datasz = hdr->kernel_size + pgsz;
|
||||
sizesz = sizeof(hdr->kernel_size);
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_KERNEL,
|
||||
if (!sysmem_alloc_base(MEM_KERNEL,
|
||||
(phys_addr_t)ramdst, blkcnt * blksz))
|
||||
return -ENOMEM;
|
||||
break;
|
||||
|
|
@ -323,7 +323,7 @@ static int image_read(img_t img, struct andr_img_hdr *hdr,
|
|||
ramdst = (void *)env_get_ulong("ramdisk_addr_r", 16, 0);
|
||||
datasz = hdr->ramdisk_size;
|
||||
sizesz = sizeof(hdr->ramdisk_size);
|
||||
if (datasz && !sysmem_alloc_base(MEMBLK_ID_RAMDISK,
|
||||
if (datasz && !sysmem_alloc_base(MEM_RAMDISK,
|
||||
(phys_addr_t)ramdst, blkcnt * blksz))
|
||||
return -ENOMEM;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -10,34 +10,37 @@
|
|||
#define MEM_RESV_COUNT 3
|
||||
|
||||
enum memblk_id {
|
||||
MEMBLK_ID_UNK,
|
||||
MEM_UNK,
|
||||
|
||||
/* Preloader */
|
||||
MEMBLK_ID_ATF,
|
||||
MEMBLK_ID_OPTEE,
|
||||
MEMBLK_ID_SHM,
|
||||
MEM_ATF,
|
||||
MEM_OPTEE,
|
||||
MEM_SHM,
|
||||
|
||||
/* U-Boot self */
|
||||
MEMBLK_ID_UBOOT,
|
||||
MEMBLK_ID_STACK,
|
||||
MEMBLK_ID_FASTBOOT,
|
||||
MEM_UBOOT,
|
||||
MEM_STACK,
|
||||
MEM_FASTBOOT,
|
||||
|
||||
/* Image */
|
||||
MEMBLK_ID_RAMDISK,
|
||||
MEMBLK_ID_FDT,
|
||||
MEMBLK_ID_FDT_DTBO,
|
||||
MEMBLK_ID_FDT_AOSP,
|
||||
MEMBLK_ID_KERNEL,
|
||||
MEMBLK_ID_UNCOMP_KERNEL,
|
||||
MEMBLK_ID_ANDROID,
|
||||
MEMBLK_ID_AVB_ANDROID,
|
||||
MEMBLK_ID_FIT,
|
||||
MEM_RESOURCE,
|
||||
MEM_RAMDISK,
|
||||
MEM_FDT,
|
||||
MEM_FDT_DTBO,
|
||||
MEM_KERNEL,
|
||||
MEM_UNCOMP_KERNEL,
|
||||
MEM_ANDROID,
|
||||
MEM_AVB_ANDROID,
|
||||
MEM_FIT_USER,
|
||||
MEM_FIT,
|
||||
MEM_UIMAGE_USER,
|
||||
MEM_UIMAGE,
|
||||
|
||||
/* Other */
|
||||
MEMBLK_ID_BY_NAME,
|
||||
MEMBLK_ID_KMEM_RESERVED,
|
||||
MEMBLK_ID_DEMO,
|
||||
MEMBLK_ID_MAX,
|
||||
MEM_SEARCH,
|
||||
MEM_BY_NAME,
|
||||
MEM_KMEM_RESERVED,
|
||||
MEM_MAX,
|
||||
};
|
||||
|
||||
struct memblk_attr {
|
||||
|
|
@ -61,25 +64,33 @@ extern const struct memblk_attr *mem_attr;
|
|||
#define SIZE_MB(len) ((len) >> 20)
|
||||
#define SIZE_KB(len) (((len) % (1 << 20)) >> 10)
|
||||
|
||||
#define M_ATTR_NONE 0
|
||||
/* Over-Flow-Check for region tail */
|
||||
#define M_ATTR_OFC (1 << 0)
|
||||
/* Over-Flow-Check for region Head, only for U-Boot stack */
|
||||
#define M_ATTR_HOFC (1 << 1)
|
||||
/* Memory can be overlap by fdt reserved memory, deprecated */
|
||||
#define M_ATTR_OVERLAP (1 << 2)
|
||||
/* Just peek, always return success, deprecated */
|
||||
#define M_ATTR_PEEK (1 << 3)
|
||||
/* The region start address should be aligned to cacheline size */
|
||||
#define M_ATTR_CACHELINE_ALIGN (1 << 4)
|
||||
/* Kernel 'reserved-memory' */
|
||||
#define M_ATTR_KMEM_RESERVED (1 << 5)
|
||||
/* The region can be overlap by kernel 'reserved-memory' */
|
||||
#define M_ATTR_KMEM_CAN_OVERLAP (1 << 6)
|
||||
/* Ignore invisable region reserved by bidram */
|
||||
#define M_ATTR_IGNORE_INVISIBLE (1 << 7)
|
||||
/* Highest memory right under the sp */
|
||||
#define M_ATTR_HIGHEST_MEM (1 << 8)
|
||||
#define F_NONE 0
|
||||
|
||||
/* Over-Flow-Check for region tail */
|
||||
#define F_OFC (1 << 0)
|
||||
|
||||
/* Over-Flow-Check for region Head, only for U-Boot stack */
|
||||
#define F_HOFC (1 << 1)
|
||||
|
||||
/* Memory can be overlap by fdt reserved memory, deprecated */
|
||||
#define F_OVERLAP (1 << 2)
|
||||
|
||||
/* The region start address should be aligned to cacheline size */
|
||||
#define F_CACHELINE_ALIGN (1 << 3)
|
||||
|
||||
/* Kernel 'reserved-memory' */
|
||||
#define F_KMEM_RESERVED (1 << 4)
|
||||
|
||||
/* The region can be overlap by kernel 'reserved-memory' */
|
||||
#define F_KMEM_CAN_OVERLAP (1 << 5)
|
||||
|
||||
/* Ignore invisible region reserved by bidram */
|
||||
#define F_IGNORE_INVISIBLE (1 << 6)
|
||||
|
||||
/* Highest memory right under the sp */
|
||||
#define F_HIGHEST_MEM (1 << 7)
|
||||
|
||||
/* No sysmem layout dump if failed */
|
||||
#define F_NO_FAIL_DUMP (1 << 8)
|
||||
|
||||
#endif /* _MEMBLK_H */
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static AvbSlotVerifyResult load_full_partition(AvbOps* ops,
|
|||
|
||||
/* Allocate and copy the partition. */
|
||||
if (!*out_image_preloaded) {
|
||||
*out_image_buf = sysmem_alloc(MEMBLK_ID_AVB_ANDROID, image_size);
|
||||
*out_image_buf = sysmem_alloc(MEM_AVB_ANDROID, image_size);
|
||||
if (*out_image_buf == NULL) {
|
||||
return AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
|
||||
}
|
||||
|
|
|
|||
10
lib/bidram.c
10
lib/bidram.c
|
|
@ -250,7 +250,7 @@ static int bidram_core_reserve(enum memblk_id id, const char *mem_name,
|
|||
if (!bidram_has_init())
|
||||
return -ENOSYS;
|
||||
|
||||
if (id == MEMBLK_ID_BY_NAME) {
|
||||
if (id == MEM_BY_NAME) {
|
||||
if (!mem_name) {
|
||||
BIDRAM_E("NULL name for reserve bidram\n");
|
||||
return -EINVAL;
|
||||
|
|
@ -258,7 +258,7 @@ static int bidram_core_reserve(enum memblk_id id, const char *mem_name,
|
|||
name = mem_name;
|
||||
}
|
||||
} else {
|
||||
if (id > MEMBLK_ID_UNK && id < MEMBLK_ID_MAX) {
|
||||
if (id > MEM_UNK && id < MEM_MAX) {
|
||||
attr = mem_attr[id];
|
||||
name = attr.name;
|
||||
} else {
|
||||
|
|
@ -309,7 +309,7 @@ static int bidram_core_reserve(enum memblk_id id, const char *mem_name,
|
|||
if (sysmem_has_init()) {
|
||||
void *paddr;
|
||||
|
||||
if (id == MEMBLK_ID_BY_NAME)
|
||||
if (id == MEM_BY_NAME)
|
||||
paddr = sysmem_alloc_base_by_name(name, base, size);
|
||||
else
|
||||
paddr = sysmem_alloc_base(id, base, size);
|
||||
|
|
@ -321,7 +321,7 @@ static int bidram_core_reserve(enum memblk_id id, const char *mem_name,
|
|||
#endif
|
||||
mem->base = base;
|
||||
mem->size = size;
|
||||
if (id == MEMBLK_ID_BY_NAME) {
|
||||
if (id == MEM_BY_NAME) {
|
||||
mem->attr.name = name;
|
||||
mem->attr.flags = 0;
|
||||
} else {
|
||||
|
|
@ -355,7 +355,7 @@ int bidram_reserve_by_name(const char *name,
|
|||
{
|
||||
int ret;
|
||||
|
||||
ret = bidram_core_reserve(MEMBLK_ID_BY_NAME, name, base, size);
|
||||
ret = bidram_core_reserve(MEM_BY_NAME, name, base, size);
|
||||
if (!ret)
|
||||
bidram_gen_gd_bi_dram();
|
||||
else
|
||||
|
|
|
|||
48
lib/sysmem.c
48
lib/sysmem.c
|
|
@ -94,11 +94,11 @@ void sysmem_dump(void)
|
|||
list_for_each(node, &sysmem->allocated_head) {
|
||||
mem = list_entry(node, struct memblock, node);
|
||||
allocated_size += mem->size;
|
||||
if (mem->attr.flags & M_ATTR_OFC) {
|
||||
if (mem->attr.flags & F_OFC) {
|
||||
check = (struct memcheck *)
|
||||
(mem->base + mem->size - sizeof(*check));
|
||||
overflow = (check->magic != SYSMEM_MAGIC);
|
||||
} else if (mem->attr.flags & M_ATTR_HOFC) {
|
||||
} else if (mem->attr.flags & F_HOFC) {
|
||||
check = (struct memcheck *)
|
||||
(mem->base - sizeof(*check));
|
||||
overflow = (check->magic != SYSMEM_MAGIC);
|
||||
|
|
@ -225,7 +225,7 @@ void sysmem_overflow_check(void)
|
|||
kmem = list_entry(knode, struct memblock, node);
|
||||
if (sysmem_is_overlap(smem->base, smem->size,
|
||||
kmem->base, kmem->size)) {
|
||||
if (smem->attr.flags & M_ATTR_KMEM_CAN_OVERLAP)
|
||||
if (smem->attr.flags & F_KMEM_CAN_OVERLAP)
|
||||
continue;
|
||||
|
||||
overlap = 1;
|
||||
|
|
@ -241,11 +241,11 @@ void sysmem_overflow_check(void)
|
|||
/*
|
||||
* Check sysmem allocated regions overflow.
|
||||
*/
|
||||
if (smem->attr.flags & M_ATTR_OFC) {
|
||||
if (smem->attr.flags & F_OFC) {
|
||||
check = (struct memcheck *)
|
||||
(smem->base + smem->size - sizeof(*check));
|
||||
overflow = (check->magic != SYSMEM_MAGIC);
|
||||
} else if (smem->attr.flags & M_ATTR_HOFC) {
|
||||
} else if (smem->attr.flags & F_HOFC) {
|
||||
check = (struct memcheck *)
|
||||
(smem->base - sizeof(*check));
|
||||
overflow = (check->magic != SYSMEM_MAGIC);
|
||||
|
|
@ -285,7 +285,7 @@ static const char *sysmem_alias2name(const char *name, int *id)
|
|||
int i, j;
|
||||
int match = 0;
|
||||
|
||||
for (i = 0; i < MEMBLK_ID_MAX; i++) {
|
||||
for (i = 0; i < MEM_MAX; i++) {
|
||||
/* Pirmary name */
|
||||
if (mem_attr[i].name && !strcasecmp(mem_attr[i].name, name)) {
|
||||
match = 1;
|
||||
|
|
@ -335,7 +335,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
if (!sysmem_has_init())
|
||||
goto out;
|
||||
|
||||
if (id == MEMBLK_ID_BY_NAME || id == MEMBLK_ID_KMEM_RESERVED) {
|
||||
if (id == MEM_BY_NAME || id == MEM_KMEM_RESERVED) {
|
||||
if (!mem_name) {
|
||||
SYSMEM_E("NULL name for alloc sysmem\n");
|
||||
goto out;
|
||||
|
|
@ -348,7 +348,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
attr.name = strdup(name);
|
||||
|
||||
/* Always make kernel 'reserved-memory' alloc successfully */
|
||||
if (id == MEMBLK_ID_KMEM_RESERVED) {
|
||||
if (id == MEM_KMEM_RESERVED) {
|
||||
struct memblock *mem;
|
||||
|
||||
mem = malloc(sizeof(*mem));
|
||||
|
|
@ -357,7 +357,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
return mem;
|
||||
}
|
||||
|
||||
attr.flags |= M_ATTR_KMEM_RESERVED;
|
||||
attr.flags |= F_KMEM_RESERVED;
|
||||
mem->orig_base = orig_base;
|
||||
mem->base = base;
|
||||
mem->size = size;
|
||||
|
|
@ -367,7 +367,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
|
||||
return (void *)base;
|
||||
}
|
||||
} else if (id > MEMBLK_ID_UNK && id < MEMBLK_ID_MAX) {
|
||||
} else if (id > MEM_UNK && id < MEM_MAX) {
|
||||
attr = mem_attr[id];
|
||||
name = attr.name;
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
* Fixup base and place right after U-Boot stack, adding a lot
|
||||
* of space(4KB) maybe safer.
|
||||
*/
|
||||
if (attr.flags & M_ATTR_HIGHEST_MEM) {
|
||||
if (attr.flags & F_HIGHEST_MEM) {
|
||||
base = gd->start_addr_sp -
|
||||
CONFIG_SYS_STACK_SIZE - size - 0x1000;
|
||||
|
||||
|
|
@ -396,12 +396,12 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
/*
|
||||
* On Rockchip platform:
|
||||
*
|
||||
* So far, we use M_ATTR_IGNORE_INVISIBLE for uncompress
|
||||
* So far, we use F_IGNORE_INVISIBLE for uncompress
|
||||
* kernel alloc, and for ARMv8 enabling AArch32 mode, the
|
||||
* ATF is still AArch64 and ocuppies 0~1MB and shmem 1~2M.
|
||||
* So let's ignore the region which overlap with them.
|
||||
*/
|
||||
if (attr.flags & M_ATTR_IGNORE_INVISIBLE) {
|
||||
if (attr.flags & F_IGNORE_INVISIBLE) {
|
||||
base = gd->bd->bi_dram[0].start;
|
||||
} else {
|
||||
SYSMEM_E("Failed to alloc invisible sub region 0x%08lx - 0x%08lx "
|
||||
|
|
@ -428,7 +428,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
* Aligned down to cacheline size if not aligned, otherwise the tail
|
||||
* of region maybe overflow.
|
||||
*/
|
||||
if (attr.flags & M_ATTR_CACHELINE_ALIGN &&
|
||||
if (attr.flags & F_CACHELINE_ALIGN &&
|
||||
!IS_ALIGNED(base, ARCH_DMA_MINALIGN)) {
|
||||
base = ALIGN(base, ARCH_DMA_MINALIGN);
|
||||
base -= ARCH_DMA_MINALIGN;
|
||||
|
|
@ -471,7 +471,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
}
|
||||
|
||||
/* Add overflow check magic ? */
|
||||
if (attr.flags & M_ATTR_OFC)
|
||||
if (attr.flags & F_OFC)
|
||||
alloc_size = size + sizeof(*check);
|
||||
else
|
||||
alloc_size = size;
|
||||
|
|
@ -493,7 +493,7 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
goto out;
|
||||
}
|
||||
/* Record original base for dump */
|
||||
if (attr.flags & M_ATTR_HIGHEST_MEM)
|
||||
if (attr.flags & F_HIGHEST_MEM)
|
||||
mem->orig_base = base;
|
||||
else
|
||||
mem->orig_base = orig_base;
|
||||
|
|
@ -505,10 +505,10 @@ static void *sysmem_alloc_align_base(enum memblk_id id,
|
|||
list_add_tail(&mem->node, &sysmem->allocated_head);
|
||||
|
||||
/* Add overflow check magic */
|
||||
if (mem->attr.flags & M_ATTR_OFC) {
|
||||
if (mem->attr.flags & F_OFC) {
|
||||
check = (struct memcheck *)(paddr + size);
|
||||
check->magic = SYSMEM_MAGIC;
|
||||
} else if (mem->attr.flags & M_ATTR_HOFC) {
|
||||
} else if (mem->attr.flags & F_HOFC) {
|
||||
check = (struct memcheck *)(paddr - sizeof(*check));
|
||||
check->magic = SYSMEM_MAGIC;
|
||||
}
|
||||
|
|
@ -548,7 +548,7 @@ out:
|
|||
if (base == 0)
|
||||
base = base + sizeof(ulong);
|
||||
|
||||
return (attr.flags & M_ATTR_IGNORE_INVISIBLE) ? (void *)base : NULL;
|
||||
return (attr.flags & F_IGNORE_INVISIBLE) ? (void *)base : NULL;
|
||||
}
|
||||
|
||||
void *sysmem_alloc(enum memblk_id id, phys_size_t size)
|
||||
|
|
@ -570,7 +570,7 @@ void *sysmem_alloc_by_name(const char *name, phys_size_t size)
|
|||
{
|
||||
void *paddr;
|
||||
|
||||
paddr = sysmem_alloc_align_base(MEMBLK_ID_BY_NAME,
|
||||
paddr = sysmem_alloc_align_base(MEM_BY_NAME,
|
||||
name,
|
||||
SYSMEM_ALLOC_ANYWHERE,
|
||||
size,
|
||||
|
|
@ -601,7 +601,7 @@ void *sysmem_alloc_base_by_name(const char *name,
|
|||
{
|
||||
void *paddr;
|
||||
|
||||
paddr = sysmem_alloc_align_base(MEMBLK_ID_BY_NAME,
|
||||
paddr = sysmem_alloc_align_base(MEM_BY_NAME,
|
||||
name,
|
||||
base,
|
||||
size,
|
||||
|
|
@ -617,7 +617,7 @@ void *sysmem_fdt_reserve_alloc_base(const char *name,
|
|||
{
|
||||
void *paddr;
|
||||
|
||||
paddr = sysmem_alloc_align_base(MEMBLK_ID_KMEM_RESERVED,
|
||||
paddr = sysmem_alloc_align_base(MEM_KMEM_RESERVED,
|
||||
name,
|
||||
base,
|
||||
size,
|
||||
|
|
@ -760,7 +760,7 @@ int sysmem_init(void)
|
|||
/* Reserved for U-boot framework: 'reserve_xxx()' */
|
||||
mem_start = gd->start_addr_sp;
|
||||
mem_size = gd->ram_top - mem_start;
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_UBOOT, mem_start, mem_size)) {
|
||||
if (!sysmem_alloc_base(MEM_UBOOT, mem_start, mem_size)) {
|
||||
SYSMEM_E("Failed to reserve sysmem for U-Boot framework\n");
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
|
|
@ -769,7 +769,7 @@ int sysmem_init(void)
|
|||
/* Reserved for U-Boot stack */
|
||||
mem_start = gd->start_addr_sp - CONFIG_SYS_STACK_SIZE;
|
||||
mem_size = CONFIG_SYS_STACK_SIZE;
|
||||
if (!sysmem_alloc_base(MEMBLK_ID_STACK, mem_start, mem_size)) {
|
||||
if (!sysmem_alloc_base(MEM_STACK, mem_start, mem_size)) {
|
||||
SYSMEM_E("Failed to reserve sysmem for stack\n");
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
|
|
|
|||
Loading…
Reference in New Issue