mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
[MM] Update MM System (#10989)
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
doc_doxygen / doxygen_doc generate (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
doc_doxygen / doxygen_doc generate (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
* [MM] Fixup MM 1. Fixup some LOG_D args. 2. Stop installing page when `rt_aspace_map_phy` fail. * [MM] Support page MPR dynamic size For RISC-V or dynamic address space arch in the future. Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
menu "Memory management"
|
||||
|
||||
config RT_PAGE_MPR_SIZE_DYNAMIC
|
||||
bool "Page MPR size is dynamic"
|
||||
default n
|
||||
help
|
||||
Some platforms' virtual address width is not a compile-time constant
|
||||
and must be determined dynamically at runtime.
|
||||
|
||||
config RT_PAGE_AFFINITY_BLOCK_SIZE
|
||||
hex "Affinity block size in bytes for page management"
|
||||
default 0x1000
|
||||
|
||||
@@ -641,7 +641,7 @@ static rt_varea_t _varea_create(void *start, rt_size_t size)
|
||||
}
|
||||
|
||||
#define _IS_OVERFLOW(start, length) ((length) > (0ul - (uintptr_t)(start)))
|
||||
#define _IS_OVERSIZE(start, length, limit_s, limit_sz) (((length) + (rt_size_t)((char *)(start) - (char *)(limit_start))) > (limit_size))
|
||||
#define _IS_OVERSIZE(start, length, limit_s, limit_sz) (((length) + (rt_size_t)((char *)(start) - (char *)(limit_s))) > (limit_sz))
|
||||
|
||||
static inline int _not_in_range(rt_size_t flags, void *start, rt_size_t length,
|
||||
void *limit_start, rt_size_t limit_size)
|
||||
|
||||
@@ -162,14 +162,14 @@ static rt_err_t _memblock_add_range(struct rt_memblock *memblock,
|
||||
rt_err_t rt_memblock_add_memory(const char *name, rt_size_t start, rt_size_t end, mmblk_flag_t flags)
|
||||
{
|
||||
LOG_D("add physical address range [0x%.*lx-0x%.*lx) with flag 0x%x" \
|
||||
" to overall memory regions\n", MIN_BIT, base, MIN_BIT, base + size, flag);
|
||||
" to overall memory regions", MIN_BIT, start, MIN_BIT, end, flags);
|
||||
|
||||
return _memblock_add_range(&mmblk_memory, name, start, end, flags);
|
||||
}
|
||||
|
||||
rt_err_t rt_memblock_reserve_memory(const char *name, rt_size_t start, rt_size_t end, mmblk_flag_t flags)
|
||||
{
|
||||
LOG_D("add physical address range %s [0x%.*lx-0x%.*lx) to reserved memory regions\n",
|
||||
LOG_D("add physical address range %s [0x%.*lx-0x%.*lx) to reserved memory regions",
|
||||
name, MIN_BIT, start, MIN_BIT, end);
|
||||
|
||||
return _memblock_add_range(&mmblk_reserved, name, start, end, flags);
|
||||
@@ -389,7 +389,10 @@ void rt_memblock_setup_memory_environment(void)
|
||||
.map_size = reg.end - reg.start,
|
||||
.prefer = (void *)reg.start};
|
||||
|
||||
rt_aspace_map_phy(&rt_kernel_space, &hint, MMU_MAP_K_RWCB, (reg.start + PV_OFFSET) >> MM_PAGE_SHIFT, &err);
|
||||
if (rt_aspace_map_phy(&rt_kernel_space, &hint, MMU_MAP_K_RWCB,
|
||||
(reg.start + PV_OFFSET) >> MM_PAGE_SHIFT, &err))
|
||||
continue;
|
||||
|
||||
rt_page_install(reg);
|
||||
mem += reg.end - reg.start;
|
||||
}
|
||||
|
||||
+21
-4
@@ -417,9 +417,26 @@ static inline rt_page_t addr_to_page(rt_page_t pg_start, void *addr)
|
||||
const rt_size_t shadow_mask =
|
||||
((1ul << (RT_PAGE_MAX_ORDER + ARCH_PAGE_SHIFT - 1)) - 1);
|
||||
|
||||
const rt_size_t rt_mpr_size = CEIL(
|
||||
((1ul << (ARCH_VADDR_WIDTH - ARCH_PAGE_SHIFT))) * sizeof(struct rt_page),
|
||||
ARCH_PAGE_SIZE);
|
||||
#define MPR_SIZE CEIL( \
|
||||
((1ul << (ARCH_VADDR_WIDTH - ARCH_PAGE_SHIFT))) * sizeof(struct rt_page), \
|
||||
ARCH_PAGE_SIZE)
|
||||
|
||||
#ifdef RT_PAGE_MPR_SIZE_DYNAMIC
|
||||
/**
|
||||
* @brief Get the size of Memory Page Region (MPR)
|
||||
*
|
||||
* When RT_PAGE_MPR_SIZE_DYNAMIC is enabled, MPR size is calculated at runtime
|
||||
* for platforms where virtual address width is not a compile-time constant.
|
||||
*
|
||||
* @return MPR size in bytes
|
||||
*/
|
||||
const rt_size_t rt_mpr_size_dynamic(void)
|
||||
{
|
||||
return MPR_SIZE;
|
||||
}
|
||||
#else
|
||||
const rt_size_t rt_mpr_size = MPR_SIZE;
|
||||
#endif
|
||||
|
||||
void *rt_mpr_start;
|
||||
|
||||
@@ -1168,7 +1185,7 @@ void rt_page_init(rt_region_t reg)
|
||||
shadow.start = reg.start & ~shadow_mask;
|
||||
shadow.end = CEIL(reg.end, shadow_mask + 1);
|
||||
LOG_D("[Init page] start: 0x%lx, end: 0x%lx, total: 0x%lx", reg.start,
|
||||
reg.end, page_nr);
|
||||
reg.end, ((reg.end - reg.start) >> ARCH_PAGE_SHIFT));
|
||||
|
||||
int err;
|
||||
|
||||
|
||||
@@ -70,7 +70,12 @@ typedef struct tag_region
|
||||
const char *name;
|
||||
} rt_region_t;
|
||||
|
||||
#ifdef RT_PAGE_MPR_SIZE_DYNAMIC
|
||||
const rt_size_t rt_mpr_size_dynamic(void);
|
||||
#define rt_mpr_size rt_mpr_size_dynamic()
|
||||
#else
|
||||
extern const rt_size_t rt_mpr_size;
|
||||
#endif
|
||||
extern void *rt_mpr_start;
|
||||
|
||||
void rt_page_init(rt_region_t reg);
|
||||
|
||||
Reference in New Issue
Block a user