matos/core/allocArea.h

27 lines
769 B
C
Raw Permalink Normal View History

2021-02-10 23:22:57 +01:00
#pragma once
#include "paging.h"
2021-08-09 09:26:10 +02:00
#include "stdarg.h"
2021-02-10 23:22:57 +01:00
2021-10-26 22:29:51 +02:00
/* Pure Virtual Memory Allocation */
// areaAlloc map vmem to phy pages
#define AREA_PHY_MAP (1<<0)
2021-10-28 00:58:24 +02:00
#define AREA_MEM_TOP PAGING_MIRROR_VADDR
2021-10-26 22:29:51 +02:00
2021-08-19 16:44:47 +02:00
struct memArea {
vaddr_t startAddr;
uint nbPages;
struct memArea *next;
struct memArea *prev;
};
2021-10-28 00:32:35 +02:00
void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed, vaddr_t stack_bottom, vaddr_t stack_top);
2021-10-26 22:29:51 +02:00
vaddr_t areaAlloc(unsigned int nbPages, uint32_t flags);
2021-10-28 23:18:05 +02:00
// Remove an area from the free ones but do not add it into used ones.
// This area should be latter added woth areaAdd.
// Used by malloc to avoid recursivity issue
vaddr_t areaBook(unsigned int nbPages, uint32_t flags);
2021-04-10 00:24:02 +02:00
int areaFree(vaddr_t addr);
int areaAdd(vaddr_t begin, vaddr_t end, int isFree);