add: ksize and vsize
This commit is contained in:
parent
a66f9174f4
commit
0bcc99997a
@ -89,3 +89,5 @@ void vfree(void *ptr);
|
||||
void *vrealloc(void *ptr, size_t size);
|
||||
void show_kalloc_mem(void);
|
||||
void show_valloc_mem(void);
|
||||
size_t ksize(void* virt_addr);
|
||||
size_t vsize(void* virt_addr);
|
@ -33,6 +33,7 @@ void kernel_main(void)
|
||||
kprintf(KERN_NOTICE "KERN_NOTICE\n");
|
||||
kprintf(KERN_INFO "KERN_INFO\n");
|
||||
kprintf(KERN_DEBUG "KERN_DEBUG\n");
|
||||
vmalloc(10);
|
||||
void *ptr = vmalloc(100);
|
||||
kprintf("%d\n", ksize(ptr));
|
||||
shell_init();
|
||||
}
|
||||
|
8
src/memory/phys/ksize.c
Normal file
8
src/memory/phys/ksize.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "alloc.h"
|
||||
|
||||
size_t ksize(void *ptr)
|
||||
{
|
||||
Block *meta_data = (Block *)((size_t)ptr - sizeof(Block));
|
||||
|
||||
return meta_data->sub_size;
|
||||
}
|
8
src/memory/virt/vsize.c
Normal file
8
src/memory/virt/vsize.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "alloc.h"
|
||||
|
||||
size_t vsize(void *ptr)
|
||||
{
|
||||
Block *meta_data = (Block *)((size_t)ptr - sizeof(Block));
|
||||
|
||||
return meta_data->sub_size;
|
||||
}
|
Loading…
Reference in New Issue
Block a user