matos/core/alloc.h
Mathieu Maret 9c36f3afa2 Add zalloc
2021-10-04 21:20:16 +02:00

38 lines
797 B
C

#pragma once
#include "paging.h"
#include "stdarg.h"
/*
* Initialize malloc system
*/
int allocSetup(size_t sizeOfArea, vaddr_t *areaAddr, vaddr_t *descAddr, vaddr_t *entryAddr);
int allocPopulate();
/*
* Allow malloc to allocate elements of this precise size.
* Otherwise the allocation will be in the closest biggest pool.
* */
int allocBookSlab(size_t size, size_t sizeSlab, int selfContained);
void *malloc(size_t size);
void *zalloc(size_t size);
void free(void *ptr);
/* Stuct definition shared for test purpose
*/
struct slabEntry {
vaddr_t page;
size_t size;
void *freeEl;
char full;
struct slabEntry *next;
struct slabEntry *prev;
};
struct slabDesc {
struct slabEntry slab;
size_t size;
struct slabDesc *next;
struct slabDesc *prev;
};