Fix Area research and init size

This commit is contained in:
Mathieu Maret 2021-10-26 21:42:57 +02:00
parent 1e7f99a3e2
commit fbb51dff0f

View File

@ -19,14 +19,15 @@ void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed)
vaddr_t areaAddr, descAddr, entryAddr;
allocSetup(sizeof(struct memArea), &areaAddr, &descAddr, &entryAddr);
areaAdd(descAddr, PAGE_SIZE, FALSE);
areaAdd(descAddr, 1, FALSE);
if (entryAddr != descAddr)
areaAdd(entryAddr, PAGE_SIZE, FALSE);
areaAdd(entryAddr, 1, FALSE);
if (areaAddr != descAddr && areaAddr != entryAddr)
areaAdd(areaAddr, PAGE_SIZE, FALSE);
areaAdd(areaAddr, 1, FALSE);
int nbPages = DIV_ROUND_UP((lastUsed - firstMemUsed), PAGE_SIZE);
areaAdd(ALIGN_DOWN(firstMemUsed, PAGE_SIZE), nbPages, FALSE);
//TODO: fix the 300
areaAdd(ALIGN_DOWN(areaAddr + PAGE_SIZE, PAGE_SIZE), 300 , TRUE);
allocPopulate();
}
@ -158,7 +159,7 @@ static struct memArea *areaFindMemArea(struct memArea *list, vaddr_t addr)
int count;
list_foreach(list, area, count)
{
if (area->startAddr <= addr && addr <= area->startAddr + area->nbPages * PAGE_SIZE)
if (area->startAddr <= addr && addr < area->startAddr + area->nbPages * PAGE_SIZE)
return area;
}