user_space #4

Merged
mathieu merged 40 commits from user_space into master 2021-11-04 16:17:36 +01:00
Showing only changes of commit fbb51dff0f - Show all commits

View File

@ -19,14 +19,15 @@ void areaInit(vaddr_t firstMemUsed, vaddr_t lastUsed)
vaddr_t areaAddr, descAddr, entryAddr; vaddr_t areaAddr, descAddr, entryAddr;
allocSetup(sizeof(struct memArea), &areaAddr, &descAddr, &entryAddr); allocSetup(sizeof(struct memArea), &areaAddr, &descAddr, &entryAddr);
areaAdd(descAddr, PAGE_SIZE, FALSE); areaAdd(descAddr, 1, FALSE);
if (entryAddr != descAddr) if (entryAddr != descAddr)
areaAdd(entryAddr, PAGE_SIZE, FALSE); areaAdd(entryAddr, 1, FALSE);
if (areaAddr != descAddr && areaAddr != entryAddr) if (areaAddr != descAddr && areaAddr != entryAddr)
areaAdd(areaAddr, PAGE_SIZE, FALSE); areaAdd(areaAddr, 1, FALSE);
int nbPages = DIV_ROUND_UP((lastUsed - firstMemUsed), PAGE_SIZE); int nbPages = DIV_ROUND_UP((lastUsed - firstMemUsed), PAGE_SIZE);
areaAdd(ALIGN_DOWN(firstMemUsed, PAGE_SIZE), nbPages, FALSE); areaAdd(ALIGN_DOWN(firstMemUsed, PAGE_SIZE), nbPages, FALSE);
//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();
} }
@ -158,7 +159,7 @@ static struct memArea *areaFindMemArea(struct memArea *list, vaddr_t addr)
int count; int count;
list_foreach(list, area, 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; return area;
} }