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:
parent
018bdc4ff6
commit
6a498c2d08
@ -64,7 +64,7 @@ void KeEnablePIT(void);
|
||||
void KeSleep(uint);
|
||||
Timer_t *KeSetTimer(uint delay);
|
||||
int KeGetTimer(Timer_t*);
|
||||
|
||||
ulong KeGetTicks(void);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
@ -219,3 +219,8 @@ ulong KeGetTimeStamp(void)
|
||||
+ (time->year + time->century * 100)
|
||||
* dpy * 24 * 60 * 60;
|
||||
}
|
||||
|
||||
ulong KeGetTicks(void)
|
||||
{
|
||||
return Ticks;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void MmInitPaging(void)
|
||||
memzero((void *)&MmPageMapLevel4[0], 512*sizeof(ulong));
|
||||
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;
|
||||
curAddrPML4 < 512 * KPAGESIZE * 0x8000000;
|
||||
@ -170,31 +170,31 @@ void MmInitPaging(void)
|
||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||
MmPhysicalPageTable[xedni] = (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) {
|
||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||
MmStackGuards[1] = (ulong)curAddrPT;
|
||||
//DebugLog("\tStack Guard at %p\n", curAddrPT);
|
||||
DebugLog("\tStack Guard at %p\n", curAddrPT);
|
||||
}
|
||||
// SECTION .TEXT PROTECTION
|
||||
else if ((ulong)curAddrPT >= (ulong)&_text && (ulong)curAddrPT <= (ulong)&_text_end) {
|
||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||
//DebugLog("\tSection .text at %p\n", curAddrPT);
|
||||
DebugLog("\tSection .text at %p\n", curAddrPT);
|
||||
}
|
||||
// SECTION .DATA PROTECTION
|
||||
else if ((ulong)curAddrPT >= (ulong)&_data && (ulong)curAddrPT <= (ulong)&_data_end) {
|
||||
MmPT[index] = (ulong)curAddrPT | PRESENT | WRITETHR | READWRITE | NX;
|
||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||
//DebugLog("\tSection .data at %p\n", curAddrPT);
|
||||
DebugLog("\tSection .data at %p\n", curAddrPT);
|
||||
}
|
||||
// SECTION .RODATA PROTECTION
|
||||
else if ((ulong)curAddrPT >= (ulong)&_rodata && (ulong)curAddrPT <= (ulong)&_rodata_end) {
|
||||
MmPT[index] = (ulong)curAddrPT | PRESENT | NX;
|
||||
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
|
||||
else if ((ulong)curAddrPT <= MmPhysLastKernAddress) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <mm/palloc.h>
|
||||
#include <mm/map.h>
|
||||
#include <io/vga.h>
|
||||
#include <lib/buf.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)
|
||||
{
|
||||
AllocatedPage_t *busyPage = &busyPagesList;
|
||||
@ -247,30 +265,39 @@ error_t MmUnmapPageFrame(ulong id)
|
||||
return EOK;
|
||||
}
|
||||
|
||||
ulong tab[4000] = {0};
|
||||
|
||||
error_t MmTestBusyPage(void)
|
||||
{
|
||||
for (ulong curAddrPT = 0x00971cb000; curAddrPT <= 0x00971fb000; curAddrPT+= (ulong)KPAGESIZE) {
|
||||
DebugLog("\t\t\t\tTable %p : %p\n", MmTransPhyToVirtAddr((void*)curAddrPT), MmTransVirtToPhyAddr((void*)curAddrPT));
|
||||
}
|
||||
|
||||
/* ulong tab[2000] = {0}; */
|
||||
/* int j = 0; */
|
||||
int j = 0;
|
||||
|
||||
/* for (int i = 0; i < 2000; i++) { */
|
||||
/* if (rand() %2) { */
|
||||
/* if (rand() %2) { */
|
||||
/* tab[j++] = MmAllocPageFrame(rand()%65536, NORMAL); */
|
||||
/* tab[j++] = MmAllocPageFrame(rand()%6553689, NORMAL); */
|
||||
/* } else { */
|
||||
/* tab[j++] = MmAllocPageFrame(rand()%65536, CONTIGUOUS); */
|
||||
/* tab[j++] = MmAllocPageFrame(rand()%6553689, CONTIGUOUS); */
|
||||
/* } */
|
||||
/* } else { */
|
||||
/* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user