user_space #4
@ -12,7 +12,9 @@ static struct memArea *usedArea;
|
|||||||
|
|
||||||
static int areaMergeFreeArea(struct memArea *prev, struct memArea *next);
|
static int areaMergeFreeArea(struct memArea *prev, struct memArea *next);
|
||||||
|
|
||||||
void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed)
|
|
||||||
|
//Kernel stack is inside firstMemUsed-lastUsed
|
||||||
|
void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed, vaddr_t stackBottom, vaddr_t stackTop)
|
||||||
{
|
{
|
||||||
list_init(freeArea);
|
list_init(freeArea);
|
||||||
list_init(usedArea);
|
list_init(usedArea);
|
||||||
@ -25,8 +27,12 @@ void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed)
|
|||||||
if (areaAddr != descAddr && areaAddr != entryAddr)
|
if (areaAddr != descAddr && areaAddr != entryAddr)
|
||||||
areaAdd(areaAddr, 1, FALSE);
|
areaAdd(areaAddr, 1, FALSE);
|
||||||
|
|
||||||
int nbPages = DIV_ROUND_UP((lastUsed - firstMemUsed), PAGE_SIZE);
|
int nbPagesKernel = DIV_ROUND_UP((lastUsed - firstMemUsed), PAGE_SIZE);
|
||||||
areaAdd(ALIGN_DOWN(firstMemUsed, PAGE_SIZE), nbPages, FALSE);
|
areaAdd(ALIGN_DOWN(firstMemUsed, PAGE_SIZE), nbPagesKernel, FALSE);
|
||||||
|
if(stackBottom > lastUsed){
|
||||||
|
int nbPagesStack = DIV_ROUND_UP((stackTop - stackBottom), PAGE_SIZE);
|
||||||
|
areaAdd(ALIGN_DOWN(stackBottom, PAGE_SIZE), nbPagesStack, FALSE);
|
||||||
|
}
|
||||||
//TODO: fix the 300
|
//TODO: fix the 300
|
||||||
areaAdd(ALIGN_DOWN(areaAddr + PAGE_SIZE, PAGE_SIZE), 300 , TRUE);
|
areaAdd(ALIGN_DOWN(areaAddr + PAGE_SIZE, PAGE_SIZE), 300 , TRUE);
|
||||||
allocPopulate();
|
allocPopulate();
|
||||||
|
@ -15,7 +15,7 @@ struct memArea {
|
|||||||
struct memArea *prev;
|
struct memArea *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed);
|
void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed, vaddr_t stack_bottom, vaddr_t stack_top);
|
||||||
vaddr_t areaAlloc(unsigned int nbPages, uint32_t flags);
|
vaddr_t areaAlloc(unsigned int nbPages, uint32_t flags);
|
||||||
int areaFree(vaddr_t addr);
|
int areaFree(vaddr_t addr);
|
||||||
int areaAdd(vaddr_t addr, uint nbPages, int isFree);
|
int areaAdd(vaddr_t addr, uint nbPages, int isFree);
|
||||||
|
@ -161,7 +161,7 @@ void kmain(unsigned long magic, unsigned long addr)
|
|||||||
serialSetup(115200);
|
serialSetup(115200);
|
||||||
|
|
||||||
printf("[Setup] allocation system\n");
|
printf("[Setup] allocation system\n");
|
||||||
areaInit(firstUsedByMem, lastUsedByMem);
|
areaInit(firstUsedByMem, lastUsedByMem, _stack_bottom, _stack_top);
|
||||||
|
|
||||||
cpu_context_subsystem_setup();
|
cpu_context_subsystem_setup();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user