rv1126-uboot/include/sysmem.h

183 lines
4.1 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+ */
/*
* (C) Copyright 2019 Rockchip Electronics Co., Ltd
*/
#ifndef _SYSMEM_H
#define _SYSMEM_H
#include <memblk.h>
#include <malloc.h>
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
/*
* CONFIG_SYS_FDT_PAD default value is sync with bootm framework in:
* common/image-fdt.c
*/
#ifndef CONFIG_SYS_FDT_PAD
#define CONFIG_SYS_FDT_PAD 0x3000
#endif
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 {
struct lmb lmb;
struct list_head allocated_head;
struct list_head kmem_resv_head;
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 allocated_cnt;
ulong kmem_resv_cnt;
bool has_initf;
bool has_initr;
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
};
#ifdef CONFIG_SYSMEM
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_has_init() - Is sysmem initialized
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 true or 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);
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_init() - Sysmem initialization
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 on success, otherwise error
*/
int sysmem_init(void);
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_initr() - Sysmem initialization after relocation
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 on success, otherwise error
*/
int sysmem_initr(void);
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_alloc() - Alloc sysmem region at anywhere
*
* @id: memblk 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
* @size: region size
*
* @return NULL on error, otherwise the allocated region address ptr
*/
void *sysmem_alloc(enum memblk_id id, 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
/**
* sysmem_alloc_by_name() - Alloc sysmem region by name at the expect addr
*
* @name: memblk name
* @size: region size
*
* @return NULL on error, otherwise the allocated region address ptr
*/
void *sysmem_alloc_by_name(const char *name, 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
/**
* sysmem_alloc_base() - Alloc sysmem region at the expect addr
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
*
* @id: memblk id
* @base: region 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
* @size: region size
*
* @return NULL on error, otherwise the allocated region address ptr
*/
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
/**
* sysmem_alloc_base_by_name() - Alloc sysmem region at the expect addr by 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
*
* @name: memblk 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
* @base: region base
* @size: region size
*
* @return NULL on error, otherwise the allocated region address ptr
*/
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
/**
* sysmem_fdt_reserve_alloc_base() - Alloc sysmem region at the expect addr by name,
* called only for reserve memory from fdt.
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: memblk 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
* @base: region base
* @size: region size
*
* @return NULL on error, otherwise the allocated region address ptr
*/
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
/**
* sysmem_can_alloc() - Check if the region can be allocated
*
* @base: region base
* @size: region size
*
* @return true on okay.
*/
bool sysmem_can_alloc(phys_size_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
/**
* sysmem_free() - Free allocated sysmem region
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
*
* @base: region base
*
* @return 0 on success, otherwise error
*/
int sysmem_free(phys_addr_t base);
/**
* sysmem_dump() - Dump all sysmem region state
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);
/**
* sysmem_overflow_check() - Sysmem regions overflow check
*/
void sysmem_overflow_check(void);
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
/**
* board_sysmem_reserve() - Weak function for board to implement
*
* @sysmem: global sysmem point, ignored
*
* @return 0 on success, otherwise error
*/
int board_sysmem_reserve(struct sysmem *sysmem);
#else
static inline bool sysmem_has_init(void) { return false; }
static inline int sysmem_init(void) { return 0; }
static inline int sysmem_initr(void) { return 0; }
static inline int sysmem_free(phys_addr_t base) { return 0; }
static inline void sysmem_dump(void) {}
static inline void sysmem_overflow_check(void) {}
__weak int board_sysmem_reserve(struct sysmem *sysmem) { return 0; }
static inline void *sysmem_alloc(enum memblk_id id, phys_size_t size)
{
return malloc(size);
}
static inline bool sysmem_can_alloc(phys_size_t base, phys_size_t size)
{
return true;
}
static inline void *sysmem_alloc_base(enum memblk_id id,
phys_addr_t base, phys_size_t size)
{
return (void *)base;
}
static inline void *sysmem_alloc_base_by_name(const char *name,
phys_addr_t base,
phys_size_t size)
{
return (void *)base;
}
static inline void *sysmem_fdt_reserve_alloc_base(const char *name,
phys_addr_t base,
phys_size_t size)
{
return (void *)base;
}
#endif /* CONFIG_SYSMEM */
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 /* _SYSMEM_H */