feature: both physical and virtual allocators should be done
This commit is contained in:
@ -18,7 +18,7 @@ enum { BPZ = 128, PAGES_TINY = 16, PAGES_SMALL = 64, MEM_ALIGN = 8 };
|
||||
typedef enum { TINY, SMALL, LARGE } block_type_t;
|
||||
|
||||
/* METADATA:
|
||||
* ptr: the ptr to return with kalloc (aligned)
|
||||
* ptr: the ptr to return with kmalloc (aligned)
|
||||
* size: the actual size
|
||||
* sub_size: the size asked by the user (different
|
||||
* from size only if krealloc and krealloc size < size)
|
||||
@ -67,7 +67,8 @@ typedef struct Zone {
|
||||
* For TINY and SMALL, the zone will be divided in blocks.
|
||||
* For LARGE, it will be entire page(s).
|
||||
*/
|
||||
extern Zone *zones[3];
|
||||
extern Zone *kzones[3];
|
||||
extern Zone *vzones[3];
|
||||
|
||||
/*----------- UTILS ----------*/
|
||||
block_type_t get_type(size_t size);
|
||||
@ -76,10 +77,15 @@ size_t align_mem(size_t addr);
|
||||
/*----------------------------*/
|
||||
|
||||
/*-------- ALLOCATOR ---------*/
|
||||
int new_zone(block_type_t type, size_t size);
|
||||
int new_kzone(block_type_t type, size_t size);
|
||||
int new_vzone(block_type_t type, size_t size);
|
||||
/*----------------------------*/
|
||||
|
||||
void *kalloc(size_t size);
|
||||
void *kmalloc(size_t size);
|
||||
void kfree(void *ptr);
|
||||
void *krealloc(void *ptr, size_t size);
|
||||
void show_alloc_mem(void);
|
||||
void *vmalloc(size_t size);
|
||||
void vfree(void *ptr);
|
||||
void *vrealloc(void *ptr, size_t size);
|
||||
void show_kalloc_mem(void);
|
||||
void show_valloc_mem(void);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define PRESENT (1 << 0)
|
||||
#define RW (1 << 1)
|
||||
@ -10,5 +10,7 @@
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
void init_memory(void);
|
||||
void *kalloc_frame(uint32_t nb_frames);
|
||||
int kfree_frame(void *frame, uint32_t nb_frames);
|
||||
void *alloc_frames(size_t size);
|
||||
int free_frames(void *frame_ptr, size_t size);
|
||||
void *alloc_pages(size_t size);
|
||||
int free_pages(void *page_ptr, size_t size);
|
||||
|
Reference in New Issue
Block a user