2020301918-os/kern/kmalloc.c
2022-10-29 19:48:58 +08:00

22 lines
367 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <assert.h>
#include <mmu.h>
#include <kern/kmalloc.h>
#include <kern/trap.h>
static phyaddr_t malloc_4k_p = 64 * MB;
/*
* 分配物理内存每次分配4kb一页
* 分配的物理内存区间为64MB~128MB
*/
phyaddr_t
phy_malloc_4k(void)
{
assert(malloc_4k_p < 128 * MB);
phyaddr_t addr = malloc_4k_p;
malloc_4k_p += PGSIZE;
return addr;
}