diff --git a/Ubiquitous/XiZi_AIoT/softkernel/memory/kalloc.c b/Ubiquitous/XiZi_AIoT/softkernel/memory/kalloc.c index 28fef6c67..39b2138f1 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/memory/kalloc.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/memory/kalloc.c @@ -33,9 +33,6 @@ Modification: #include "actracer.h" #include "buddy.h" -#ifndef V2P_LINK -#define V2P_LINK V2P -#endif struct KBuddy kern_virtmem_buddy; struct KBuddy user_phy_freemem_buddy; @@ -43,7 +40,11 @@ struct KBuddy user_phy_freemem_buddy; extern uintptr_t kernel_data_end[]; bool module_phymem_init() { +#ifndef __riscv + uintptr_t kern_freemem_start = V2P(kernel_data_end); +#else uintptr_t kern_freemem_start = V2P_LINK(kernel_data_end); +#endif uintptr_t kern_freemem_end = PHY_USER_FREEMEM_BASE; uintptr_t user_freemem_start = PHY_USER_FREEMEM_BASE; uintptr_t user_freemem_end = PHY_MEM_STOP; @@ -59,7 +60,11 @@ char* kalloc(uintptr_t size) if (mem_alloc == NULL) { return NULL; } +#ifndef __riscv + assert((uintptr_t)mem_alloc >= V2P(&kernel_data_end) && (uintptr_t)mem_alloc < PHY_USER_FREEMEM_BASE); +#else assert((uintptr_t)mem_alloc >= V2P_LINK(&kernel_data_end) && (uintptr_t)mem_alloc < PHY_USER_FREEMEM_BASE); +#endif mem_alloc = P2V(mem_alloc); if ((uintptr_t)mem_alloc < KERN_MEM_BASE) { DEBUG("Error Alloc: %x by size: %d (Caused by double free)\n", mem_alloc, size); diff --git a/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_state.c b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_state.c index 6f672a1bb..502fde0e4 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_state.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_state.c @@ -113,7 +113,11 @@ void show_mem(void) { SHOWINFO_BORDER_LINE(); +#ifndef __riscv uint64_t total = (PHY_MEM_STOP - V2P(kernel_data_end)); +#else + uint64_t total = (PHY_MEM_STOP - V2P_LINK(kernel_data_end)); +#endif uint64_t user_dynamic_free = 0; uint64_t kernel_free = 0; for (int j = 0; j < MAX_BUDDY_ORDER; j++) {