Skip to content

Commit b2b293a

Browse files
committed
[MM] Support page MPR dynamic size
For RISC-V or dynamic address space arch in the future. Signed-off-by: GuEe-GUI <[email protected]>
1 parent bd2f06e commit b2b293a

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

components/mm/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
menu "Memory management"
22

3+
config RT_PAGE_MPR_SIZE_DYNAMIC
4+
bool "Page MPR size is dynamic"
5+
default n
6+
help
7+
Some platform's virtual address is not a constant, Change by dynamic.
8+
39
config RT_PAGE_AFFINITY_BLOCK_SIZE
410
hex "Affinity block size in bytes for page management"
511
default 0x1000

components/mm/mm_page.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,18 @@ static inline rt_page_t addr_to_page(rt_page_t pg_start, void *addr)
417417
const rt_size_t shadow_mask =
418418
((1ul << (RT_PAGE_MAX_ORDER + ARCH_PAGE_SHIFT - 1)) - 1);
419419

420-
const rt_size_t rt_mpr_size = CEIL(
421-
((1ul << (ARCH_VADDR_WIDTH - ARCH_PAGE_SHIFT))) * sizeof(struct rt_page),
422-
ARCH_PAGE_SIZE);
420+
#define MPR_SIZE CEIL( \
421+
((1ul << (ARCH_VADDR_WIDTH - ARCH_PAGE_SHIFT))) * sizeof(struct rt_page), \
422+
ARCH_PAGE_SIZE)
423+
424+
#ifdef RT_PAGE_MPR_SIZE_DYNAMIC
425+
const rt_size_t rt_mpr_size_dynamic(void)
426+
{
427+
return MPR_SIZE;
428+
}
429+
#else
430+
const rt_size_t rt_mpr_size = MPR_SIZE;
431+
#endif
423432

424433
void *rt_mpr_start;
425434

components/mm/mm_page.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ typedef struct tag_region
7070
const char *name;
7171
} rt_region_t;
7272

73+
#ifdef RT_PAGE_MPR_SIZE_DYNAMIC
74+
const rt_size_t rt_mpr_size_dynamic(void);
75+
#define rt_mpr_size rt_mpr_size_dynamic()
76+
#else
7377
extern const rt_size_t rt_mpr_size;
78+
#endif
7479
extern void *rt_mpr_start;
7580

7681
void rt_page_init(rt_region_t reg);

0 commit comments

Comments
 (0)