rv1126-uboot/lib/sysmem.c

513 lines
12 KiB
C
Raw Normal View History

lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
*/
#include <common.h>
#include <sysmem.h>
#include <lmb.h>
#include <malloc.h>
#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
#define SYSMEM_MAGIC 0x4D454D53 /* "SMEM" */
#define SYSMEM_ALLOC_ANYWHERE 0
#define SYSMEM_ALLOC_NO_ALIGN 1
#define SYSMEM_I(fmt, args...) printf("Sysmem: "fmt, ##args)
#define SYSMEM_W(fmt, args...) printf("Sysmem Warn: "fmt, ##args)
#define SYSMEM_E(fmt, args...) printf("Sysmem Error: "fmt, ##args)
#define SYSMEM_D(fmt, args...) debug("Sysmem Debug: "fmt, ##args)
struct memcheck {
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
uint32_t magic;
};
/* Global for platform, must in data section */
struct sysmem plat_sysmem __section(".data") = {
.has_initf = false,
.has_initr = false,
};
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
bool sysmem_has_init(void)
{
return gd->flags & GD_FLG_RELOC ?
plat_sysmem.has_initr : plat_sysmem.has_initf;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
void sysmem_dump(void)
{
struct sysmem *sysmem = &plat_sysmem;
struct lmb *lmb = &sysmem->lmb;
struct memblock *mem;
struct memcheck *check;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
struct list_head *node;
ulong memory_size = 0;
ulong reserved_size = 0;
ulong allocated_size = 0;
bool overflow = false;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
ulong i;
if (!sysmem_has_init())
return;
printf("\nsysmem_dump_all:\n");
/* Memory pool */
printf(" --------------------------------------------------------------------\n");
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
for (i = 0; i < lmb->memory.cnt; i++) {
memory_size += lmb->memory.region[i].size;
printf(" memory.rgn[%ld].addr = 0x%08lx - 0x%08lx (size: 0x%08lx)\n", i,
(ulong)lmb->memory.region[i].base,
(ulong)lmb->memory.region[i].base +
(ulong)lmb->memory.region[i].size,
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
(ulong)lmb->memory.region[i].size);
}
printf("\n memory.total = 0x%08lx (%ld MiB. %ld KiB)\n",
(ulong)memory_size,
SIZE_MB((ulong)memory_size),
SIZE_KB((ulong)memory_size));
/* Allocated */
i = 0;
printf(" --------------------------------------------------------------------\n");
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
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) {
check = (struct memcheck *)
(mem->base + mem->size - sizeof(*check));
overflow = (check->magic != SYSMEM_MAGIC);
} else if (mem->attr.flags & M_ATTR_HOFC) {
check = (struct memcheck *)
(mem->base - sizeof(*check));
overflow = (check->magic != SYSMEM_MAGIC);
} else {
overflow = false;
}
printf(" allocated.rgn[%ld].name = \"%s\" %s\n",
i, mem->attr.name, overflow ? " <Overflow!>" : "");
printf(" .addr = 0x%08lx - 0x%08lx (size: 0x%08lx)\n",
(ulong)mem->base, (ulong)(mem->base + mem->size),
(ulong)mem->size);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
i++;
}
printf("\n malloc_r: %d MiB, malloc_f: %d KiB\n",
SIZE_MB(CONFIG_SYS_MALLOC_LEN), SIZE_KB(CONFIG_SYS_MALLOC_F_LEN));
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
printf("\n allocated.total = 0x%08lx (%ld MiB. %ld KiB)\n",
(ulong)allocated_size,
SIZE_MB((ulong)allocated_size),
SIZE_KB((ulong)allocated_size));
/* LMB core reserved */
printf(" --------------------------------------------------------------------\n");
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
reserved_size = 0;
for (i = 0; i < lmb->reserved.cnt; i++) {
reserved_size += lmb->reserved.region[i].size;
printf(" LMB.reserved[%ld].addr = 0x%08lx - 0x%08lx (size: 0x%08lx)\n", i,
(ulong)lmb->reserved.region[i].base,
(ulong)lmb->reserved.region[i].base +
(ulong)lmb->reserved.region[i].size,
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
(ulong)lmb->reserved.region[i].size);
}
printf("\n reserved.core.total = 0x%08lx (%ld MiB. %ld KiB)\n",
(ulong)reserved_size,
SIZE_MB((ulong)reserved_size),
SIZE_KB((ulong)reserved_size));
printf(" --------------------------------------------------------------------\n\n");
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
static inline int sysmem_is_overlap(phys_addr_t base1, phys_size_t size1,
phys_addr_t base2, phys_size_t size2)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
}
static int sysmem_add(phys_addr_t base, phys_size_t size)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
struct sysmem *sysmem = &plat_sysmem;
int ret;
if (!size)
return -EINVAL;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
ret = lmb_add(&sysmem->lmb, base, size);
if (ret < 0)
SYSMEM_E("Failed to add sysmem at 0x%08lx for 0x%08lx size\n",
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
(ulong)base, (ulong)size);
return (ret >= 0) ? 0 : ret;
}
static const char *sysmem_alias2name(const char *name, int *id)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
const char *alias;
int n, i, j;
int match = 0;
for (i = 0; i < MEMBLK_ID_MAX; i++) {
/* Pirmary name */
if (mem_attr[i].name && !strcasecmp(mem_attr[i].name, name)) {
match = 1;
goto finish;
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
/* Alias name */
alias = mem_attr[i].alias[0];
if (!alias)
continue;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
n = ARRAY_SIZE(mem_attr[i].alias);
for (j = 0; j < n; j++, alias++) {
if (alias && !strcasecmp(alias, name)) {
match = 1;
goto finish;
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
}
finish:
if (match) {
*id = i;
return mem_attr[i].name;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
return name;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
static void *sysmem_alloc_align_base(enum memblk_id id,
const char *mem_name,
phys_addr_t base,
phys_size_t size,
ulong align)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
struct sysmem *sysmem = &plat_sysmem;
struct memblk_attr attr;
struct memblock *mem;
struct memcheck *check;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
struct list_head *node;
const char *name;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
phys_addr_t paddr;
phys_addr_t alloc_base;
phys_size_t alloc_size;
bool req_overlap = false;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
if (!sysmem_has_init())
return NULL;
if (id == MEMBLK_ID_BY_NAME || id == MEMBLK_ID_FDT_RESV) {
if (!mem_name) {
SYSMEM_E("NULL name for alloc sysmem\n");
return NULL;
} else if (id == MEMBLK_ID_FDT_RESV) {
req_overlap = true;
if (base >= gd->ram_top)
return (void *)base;
}
name = sysmem_alias2name(mem_name, (int *)&id);
attr = mem_attr[id];
if (!attr.name)
attr.name = strdup(name);
} else if (id > MEMBLK_ID_UNK && id < MEMBLK_ID_MAX) {
attr = mem_attr[id];
name = attr.name;
} else {
SYSMEM_E("Unsupport memblk id %d for alloc sysmem\n", id);
return NULL;
}
if (!size) {
SYSMEM_E("\"%s\" size is 0 for alloc sysmem\n", name);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return NULL;
}
if (!IS_ALIGNED(base, 4)) {
SYSMEM_E("\"%s\" base=0x%08lx is not 4-byte aligned\n",
name, (ulong)base);
return NULL;
}
/* Must be 4-byte aligned */
size = ALIGN(size, 4);
SYSMEM_D("Enter alloc: \"%s\" 0x%08lx - 0x%08lx\n",
name, (ulong)base, (ulong)(base + size));
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
/* Already allocated ? */
list_for_each(node, &sysmem->allocated_head) {
mem = list_entry(node, struct memblock, node);
SYSMEM_D("Has allcated: %s, 0x%08lx - 0x%08lx\n",
mem->attr.name, (ulong)mem->base,
(ulong)(mem->base + mem->size));
if (!strcmp(mem->attr.name, name)) {
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
SYSMEM_E("Failed to double alloc for existence \"%s\"\n", name);
return NULL;
} else if (sysmem_is_overlap(mem->base, mem->size, base, size)) {
if (req_overlap && mem->attr.flags & M_ATTR_OVERLAP) {
if (lmb_reserve(&sysmem->lmb, base, size))
SYSMEM_E("Failed to overlap alloc \"%s\" "
"at 0x%08lx - 0x%08lx\n",
name, (ulong)base,
(ulong)(base + size));
return (void *)base;
}
SYSMEM_E("\"%s\" (0x%08lx - 0x%08lx) alloc is "
"overlap with existence \"%s\" (0x%08lx - "
"0x%08lx)\n",
name, (ulong)base, (ulong)(base + size),
mem->attr.name, (ulong)mem->base,
(ulong)(mem->base + mem->size));
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return NULL;
}
}
/* Add overflow check magic ? */
if (attr.flags & M_ATTR_OFC)
alloc_size = size + sizeof(*check);
else
alloc_size = size;
/* Alloc anywhere ? */
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
if (base == SYSMEM_ALLOC_ANYWHERE)
alloc_base = base;
else
alloc_base = base + alloc_size; /* LMB is align down alloc mechanism */
paddr = lmb_alloc_base(&sysmem->lmb, alloc_size, align, alloc_base);
if (paddr) {
if ((paddr == base) || (base == SYSMEM_ALLOC_ANYWHERE)) {
mem = malloc(sizeof(*mem));
if (!mem) {
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
SYSMEM_E("No memory for \"%s\" alloc sysmem\n", name);
return NULL;
}
mem->base = paddr;
mem->size = alloc_size;
mem->attr = attr;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
sysmem->allocated_cnt++;
list_add_tail(&mem->node, &sysmem->allocated_head);
if (mem->attr.flags & M_ATTR_OFC) {
check = (struct memcheck *)(paddr + size);
check->magic = SYSMEM_MAGIC;
} else if (mem->attr.flags & M_ATTR_HOFC) {
check = (struct memcheck *)(paddr - sizeof(*check));
check->magic = SYSMEM_MAGIC;
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
} else {
SYSMEM_E("Failed to alloc \"%s\" expect at 0x%08lx - 0x%08lx "
"but at 0x%08lx - x%08lx\n",
name, (ulong)base, (ulong)(base + size),
(ulong)paddr, (ulong)(paddr + size));
if (lmb_free(&sysmem->lmb, paddr, alloc_size))
SYSMEM_E("Failed to free \"%s\"\n", name);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return NULL;
}
} else {
SYSMEM_E("Failed to alloc \"%s\" at 0x%08lx - 0x%08lx\n",
name, (ulong)base, (ulong)(base + size));
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
SYSMEM_D("Exit alloc: \"%s\", paddr=0x%08lx, size=0x%08lx, align=0x%x, anywhere=%d\n",
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
name, (ulong)paddr, (ulong)size, (u32)align, !base);
return (void *)paddr;
}
void *sysmem_alloc_base(enum memblk_id id, phys_addr_t base, phys_size_t size)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
void *paddr;
paddr = sysmem_alloc_align_base(id,
NULL,
base,
size,
SYSMEM_ALLOC_NO_ALIGN);
if (!paddr)
sysmem_dump();
return paddr;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
void *sysmem_alloc_base_by_name(const char *name,
phys_addr_t base, phys_size_t size)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
void *paddr;
paddr = sysmem_alloc_align_base(MEMBLK_ID_BY_NAME,
name,
base,
size,
SYSMEM_ALLOC_NO_ALIGN);
if (!paddr)
sysmem_dump();
return paddr;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
void *sysmem_fdt_reserve_alloc_base(const char *name,
phys_addr_t base, phys_size_t size)
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
void *paddr;
paddr = sysmem_alloc_align_base(MEMBLK_ID_FDT_RESV,
name,
base,
size,
SYSMEM_ALLOC_NO_ALIGN);
if (!paddr)
sysmem_dump();
return paddr;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
int sysmem_free(phys_addr_t base)
{
struct sysmem *sysmem = &plat_sysmem;
struct memblock *mem;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
struct list_head *node;
int ret, found = 0;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
if (!sysmem_has_init())
return -ENOSYS;
/* Find existence */
list_for_each(node, &sysmem->allocated_head) {
mem = list_entry(node, struct memblock, node);
if (mem->base == base) {
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
found = 1;
break;
}
}
if (!found) {
SYSMEM_E("Failed to free no allocated sysmem at 0x%08lx\n",
(ulong)base);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return -EINVAL;
}
ret = lmb_free(&sysmem->lmb, mem->base, mem->size);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
if (ret >= 0) {
SYSMEM_D("Free: \"%s\" 0x%08lx - 0x%08lx\n",
mem->attr.name, (ulong)mem->base,
(ulong)(mem->base + mem->size));
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
sysmem->allocated_cnt--;
list_del(&mem->node);
free(mem);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
} else {
SYSMEM_E("Failed to free \"%s\" at 0x%08lx\n",
mem->attr.name, (ulong)base);
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
return (ret >= 0) ? 0 : ret;
}
int sysmem_initr(void)
{
return sysmem_init();
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
int sysmem_init(void)
{
struct sysmem *sysmem = &plat_sysmem;
phys_addr_t mem_start;
phys_size_t mem_size;
int ret;
lmb_init(&sysmem->lmb);
INIT_LIST_HEAD(&sysmem->allocated_head);
sysmem->allocated_cnt = 0;
if (gd->flags & GD_FLG_RELOC) {
sysmem->has_initr = true;
} else {
SYSMEM_I("init\n");
sysmem->has_initf = true;
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
/* Add all available system memory */
#ifdef CONFIG_NR_DRAM_BANKS
int i;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
if (!gd->bd->bi_dram[i].size)
continue;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
ret = sysmem_add(gd->bd->bi_dram[i].start,
gd->bd->bi_dram[i].size);
if (ret) {
SYSMEM_E("Failed to add sysmem from bi_dram[%d]\n", i);
goto fail;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
}
#else
mem_start = env_get_bootm_low();
mem_size = env_get_bootm_size();
ret = sysmem_add(mem_start, mem_size);
if (ret) {
SYSMEM_E("Failed to add sysmem from bootm_low/size\n");
goto fail;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
#endif
/* Reserved for board */
ret = board_sysmem_reserve(sysmem);
if (ret) {
SYSMEM_E("Failed to reserve sysmem for board\n");
goto fail;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
/* Reserved for U-boot framework: 'reserve_xxx()' */
mem_start = gd->start_addr_sp;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
mem_size = gd->ram_top - mem_start;
if (!sysmem_alloc_base(MEMBLK_ID_UBOOT, mem_start, mem_size)) {
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
SYSMEM_E("Failed to reserve sysmem for U-Boot framework\n");
ret = -ENOMEM;
goto fail;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
/* 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)) {
SYSMEM_E("Failed to reserve sysmem for stack\n");
ret = -ENOMEM;
goto fail;
}
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return 0;
fail:
if (ret && !(gd->flags & GD_FLG_RELOC)) {
sysmem_dump();
SYSMEM_W("Maybe malloc size %d MiB is too large?\n\n",
SIZE_MB(CONFIG_SYS_MALLOC_LEN));
}
return ret;
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
}
__weak int board_sysmem_reserve(struct sysmem *sysmem)
{
/* please define platform specific board_sysmem_reserve() */
return 0;
}
static int do_dump_sysmem(cmd_tbl_t *cmdtp, int flag,
int argc, char *const argv[])
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
{
sysmem_dump();
lib: introduce sysmem for permanent memory management U-Boot provides MALLOC for runtime temporary memory management and LMB for bootm memory management. There is not a mechanism for permanent memory management. so that the memory blocks are easy to overlap with each other. What does permanent memory mean ? - The memory can't be touched by U-Boot(ATF/OPTEE/SHM/kernel-reserved, etc); - The memory occupied even in kernel, such as some firmware load buffer; This patch introduces sysmem to do permanent memory management, which implements base on LMB. It provides memory block (pool): - init; - add; - alloc; - free; - reserve; - stat; - overflow check; Here is an example for RK3399 sysmem boot stat(assume the "fdt" region is Overflow) called by sysmem_dump_all(): sysmem_dump_all: ------------------------------------------------------ memory.rgn[0].base = 0x00000000 .size = 0x00000000 memory.rgn[1].base = 0x00200000 .size = 0x08200000 memory.rgn[2].base = 0x0a200000 .size = 0x75e00000 memory.total = 0x7e000000 (2016 MiB. 0 KiB) ------------------------------------------------------ reserved.rgn[0].name = "ATF" .base = 0x00000000 .size = 0x00100000 reserved.rgn[1].name = "PSTORE/ATAGS/SHM" .base = 0x00100000 .size = 0x00100000 reserved.rgn[2].name = "OP-TEE" .base = 0x08400000 .size = 0x01e00000 reserved.rgn[3].name = "U-Boot" .base = 0x71be03c0 .size = 0x0e41fc40 reserved.rgn[4].name = "secure-memory@20000000" .base = 0x20000000 .size = 0x10000000 reserved.total = 0x2041fc40 (516 MiB. 127 KiB) ------------------------------------------------------ allocated.rgn[0].name = "fdt" (Overflow) .base = 0x01f00000 .size = 0x00009704 allocated.rgn[1].name = "kernel" .base = 0x0027c000 .size = 0x0129da04 allocated.rgn[2].name = "ramdisk" .base = 0x0a200000 .size = 0x001e6c04 allocated.total = 0x0148dd0c (20 MiB. 567 KiB) ------------------------------------------------------ LMB.reserved[0].base = 0x00000000 .size = 0x00200000 LMB.reserved[1].base = 0x0027c000 .size = 0x0129da04 LMB.reserved[2].base = 0x01f00000 .size = 0x00009704 LMB.reserved[3].base = 0x08400000 .size = 0x01fe6c04 LMB.reserved[4].base = 0x20000000 .size = 0x10000000 LMB.reserved[5].base = 0x71be03c0 .size = 0x0e41fc40 reserved.core.total = 0x218ad94c (536 MiB. 694 KiB) ------------------------------------------------------ Change-Id: If63b7abed2cdd3c054719511fcceed733ddf606d Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-13 09:56:44 +00:00
return 0;
}
U_BOOT_CMD(
dump_sysmem, 1, 1, do_dump_sysmem,
"Dump sysmem layout",
""
);