1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Some tests

This commit is contained in:
Adrien Bourmault 2020-01-18 00:48:05 +01:00
parent 018bdc4ff6
commit 6a498c2d08
4 changed files with 49 additions and 17 deletions

View File

@ -64,7 +64,7 @@ void KeEnablePIT(void);
void KeSleep(uint); void KeSleep(uint);
Timer_t *KeSetTimer(uint delay); Timer_t *KeSetTimer(uint delay);
int KeGetTimer(Timer_t*); int KeGetTimer(Timer_t*);
ulong KeGetTicks(void);
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//

View File

@ -219,3 +219,8 @@ ulong KeGetTimeStamp(void)
+ (time->year + time->century * 100) + (time->year + time->century * 100)
* dpy * 24 * 60 * 60; * dpy * 24 * 60 * 60;
} }
ulong KeGetTicks(void)
{
return Ticks;
}

View File

@ -89,7 +89,7 @@ void MmInitPaging(void)
memzero((void *)&MmPageMapLevel4[0], 512*sizeof(ulong)); memzero((void *)&MmPageMapLevel4[0], 512*sizeof(ulong));
KalAllocMemoryEx((void**)&MmPhysicalPageTable, phDirSize, M_ZEROED, KPAGESIZE); KalAllocMemoryEx((void**)&MmPhysicalPageTable, phDirSize, M_ZEROED, KPAGESIZE);
DebugLog("\t\t\t\tPhysical map addr : %p\n", MmPhysicalPageTable); //DebugLog("\t\t\t\tPhysical map addr : %p\n", MmPhysicalPageTable);
for (curAddrPML4 = 0; for (curAddrPML4 = 0;
curAddrPML4 < 512 * KPAGESIZE * 0x8000000; curAddrPML4 < 512 * KPAGESIZE * 0x8000000;
@ -170,31 +170,31 @@ void MmInitPaging(void)
MmPT[index] = (ulong)curAddrPT | PRESENT; MmPT[index] = (ulong)curAddrPT | PRESENT;
MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
MmStackGuards[0] = (ulong)curAddrPT; MmStackGuards[0] = (ulong)curAddrPT;
//DebugLog("\tStack Guard at %p\n", curAddrPT); DebugLog("\tStack Guard at %p\n", curAddrPT);
} }
else if ((ulong)curAddrPT == (ulong)BtLoaderInfo.kernelEndAddr) { else if ((ulong)curAddrPT == (ulong)BtLoaderInfo.kernelEndAddr) {
MmPT[index] = (ulong)curAddrPT | PRESENT; MmPT[index] = (ulong)curAddrPT | PRESENT;
MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
MmStackGuards[1] = (ulong)curAddrPT; MmStackGuards[1] = (ulong)curAddrPT;
//DebugLog("\tStack Guard at %p\n", curAddrPT); DebugLog("\tStack Guard at %p\n", curAddrPT);
} }
// SECTION .TEXT PROTECTION // SECTION .TEXT PROTECTION
else if ((ulong)curAddrPT >= (ulong)&_text && (ulong)curAddrPT <= (ulong)&_text_end) { else if ((ulong)curAddrPT >= (ulong)&_text && (ulong)curAddrPT <= (ulong)&_text_end) {
MmPT[index] = (ulong)curAddrPT | PRESENT; MmPT[index] = (ulong)curAddrPT | PRESENT;
MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
//DebugLog("\tSection .text at %p\n", curAddrPT); DebugLog("\tSection .text at %p\n", curAddrPT);
} }
// SECTION .DATA PROTECTION // SECTION .DATA PROTECTION
else if ((ulong)curAddrPT >= (ulong)&_data && (ulong)curAddrPT <= (ulong)&_data_end) { else if ((ulong)curAddrPT >= (ulong)&_data && (ulong)curAddrPT <= (ulong)&_data_end) {
MmPT[index] = (ulong)curAddrPT | PRESENT | WRITETHR | READWRITE | NX; MmPT[index] = (ulong)curAddrPT | PRESENT | WRITETHR | READWRITE | NX;
MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
//DebugLog("\tSection .data at %p\n", curAddrPT); DebugLog("\tSection .data at %p\n", curAddrPT);
} }
// SECTION .RODATA PROTECTION // SECTION .RODATA PROTECTION
else if ((ulong)curAddrPT >= (ulong)&_rodata && (ulong)curAddrPT <= (ulong)&_rodata_end) { else if ((ulong)curAddrPT >= (ulong)&_rodata && (ulong)curAddrPT <= (ulong)&_rodata_end) {
MmPT[index] = (ulong)curAddrPT | PRESENT | NX; MmPT[index] = (ulong)curAddrPT | PRESENT | NX;
MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
//DebugLog("\tSection .rodata at %p\n", curAddrPT); DebugLog("\tSection .rodata at %p\n", curAddrPT);
} }
// While we're inside the kernel pages // While we're inside the kernel pages
else if ((ulong)curAddrPT <= MmPhysLastKernAddress) { else if ((ulong)curAddrPT <= MmPhysLastKernAddress) {

View File

@ -29,6 +29,7 @@
#include <mm/palloc.h> #include <mm/palloc.h>
#include <mm/map.h> #include <mm/map.h>
#include <io/vga.h> #include <io/vga.h>
#include <lib/buf.h>
#include <ke/time.h> #include <ke/time.h>
//--------- //---------
@ -82,6 +83,23 @@ static void printBusyPages(void)
} }
} }
static ulong MmBusyPagesSpace(void)
{
ulong c = 0;
AllocatedPage_t *busyPage = &busyPagesList;
if (!busyPage->next) {
return 0;
} else {
while(busyPage->next) {
busyPage = busyPage->next;
c += 4096;
}
}
return c;
}
static void addPageToBusyList(void *phyPageAddr, ulong id) static void addPageToBusyList(void *phyPageAddr, ulong id)
{ {
AllocatedPage_t *busyPage = &busyPagesList; AllocatedPage_t *busyPage = &busyPagesList;
@ -247,30 +265,39 @@ error_t MmUnmapPageFrame(ulong id)
return EOK; return EOK;
} }
ulong tab[4000] = {0};
error_t MmTestBusyPage(void) error_t MmTestBusyPage(void)
{ {
for (ulong curAddrPT = 0x00971cb000; curAddrPT <= 0x00971fb000; curAddrPT+= (ulong)KPAGESIZE) { int j = 0;
DebugLog("\t\t\t\tTable %p : %p\n", MmTransPhyToVirtAddr((void*)curAddrPT), MmTransVirtToPhyAddr((void*)curAddrPT));
}
/* ulong tab[2000] = {0}; */
/* int j = 0; */
/* for (int i = 0; i < 2000; i++) { */ /* for (int i = 0; i < 2000; i++) { */
/* if (rand() %2) { */ /* if (rand() %2) { */
/* if (rand() %2) { */ /* if (rand() %2) { */
/* tab[j++] = MmAllocPageFrame(rand()%65536, NORMAL); */ /* tab[j++] = MmAllocPageFrame(rand()%6553689, NORMAL); */
/* } else { */ /* } else { */
/* tab[j++] = MmAllocPageFrame(rand()%65536, CONTIGUOUS); */ /* tab[j++] = MmAllocPageFrame(rand()%6553689, CONTIGUOUS); */
/* } */ /* } */
/* } else { */ /* } else { */
/* MmFreePageFrame(tab[rand() % (j+1)]); */ /* MmFreePageFrame(tab[rand() % (j+1)]); */
/* } */ /* } */
/* DebugLog("Alloc : %d; Free : %d; Count : %lu Mo\n", NSuccessfulAlloc, NSuccessfulFree, MmBusyPagesSpace() / MB); */
/* } */ /* } */
/* //printBusyPages(); */ ulong a = KeGetTicks();
tab[j++] = MmAllocPageFrame(50*MB, NORMAL);
tab[j++] = MmAllocPageFrame(50*MB, NORMAL);
tab[j++] = MmAllocPageFrame(50*MB, NORMAL);
tab[j++] = MmAllocPageFrame(50*MB, NORMAL);
tab[j++] = MmAllocPageFrame(50*MB, NORMAL);
ulong b = KeGetTicks();
/* DebugLog("Alloc : %d; Free : %d\n", NSuccessfulAlloc, NSuccessfulFree); */ DebugLog("Alloc time per MB : %lu\n", (b-a)/5/5);
//printBusyPages();
DebugLog("Alloc : %d; Free : %d; Count : %lu Mo\n", NSuccessfulAlloc, NSuccessfulFree, MmBusyPagesSpace() / MB);
DebugLog("Finished !\n");
return EOK; return EOK;
} }