mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Some cleanup
This commit is contained in:
parent
23362604f9
commit
f1ae002ded
@ -332,8 +332,10 @@ void _KeHandleISR(ISRFrame_t *regs)
|
||||
}
|
||||
}
|
||||
|
||||
bprintf(BStdDbg, "[%d]\tISR 0x%x %s\n",
|
||||
bprintf(BStdDbg, "[%C%8d%C]\tISR 0x%x %s\n",
|
||||
VGA_COLOR_BROWN,
|
||||
KeGetTicks(),
|
||||
VGA_COLOR_LIGHT_GREY,
|
||||
regs->intNo,
|
||||
"Unknown ISR Exception");
|
||||
KeSendEOItoPIC(regs->intNo);
|
||||
|
@ -54,14 +54,14 @@ void DebugLog(const char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
|
||||
if (ticks) {
|
||||
BPrintOnBuf(BStdDbg, "[%C%9d%C]\t",
|
||||
BPrintOnBuf(BStdDbg, "[%C%8d%C]\t",
|
||||
VGA_COLOR_LIGHT_BROWN,
|
||||
ticks,
|
||||
VGA_COLOR_LIGHT_GREY);
|
||||
} else {
|
||||
BPrintOnBuf(BStdDbg, "[%C%s%C]\t",
|
||||
VGA_COLOR_GREEN,
|
||||
" ok",
|
||||
" ok",
|
||||
VGA_COLOR_LIGHT_GREY);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,8 @@ static void GetTimeFromRTC(void)
|
||||
IoWriteByteOnPort(0x70, 0x32);
|
||||
OriginTime.century = IoReadByteFromPort(0x71);
|
||||
|
||||
// Now while we don't get the same value, read the registers (ensure data are valid)
|
||||
// Now while we don't get the same value,
|
||||
// read the registers (ensure data are valid)
|
||||
do {
|
||||
lastTime.sec = OriginTime.sec;
|
||||
lastTime.min = OriginTime.min;
|
||||
@ -212,7 +213,7 @@ void KeEnableRTC(void)
|
||||
KeRestoreIRQs(flags);
|
||||
KeEnableNMI();
|
||||
|
||||
srand(KeGetTimeStamp()); // Initializes the kernel number generator
|
||||
srand(KeGetTimeStamp()); // init number generator
|
||||
DebugLog("RTC interrupt frequency set to %d Hz\n",
|
||||
32768 >> (RTC_RATE - 1));
|
||||
}
|
||||
|
@ -158,7 +158,6 @@ bool MmIsBusyZone(void *start)
|
||||
(ulong)start < ((ulong)memoryMap.entry[i].addr +
|
||||
(ulong)memoryMap.entry[i].length)
|
||||
) {
|
||||
//KernLog("Non free because %d type : %p\n", memoryMap.entry[i].type, start);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +219,8 @@ void MmInitPaging(void)
|
||||
MmLoadPML4((void *)MmPageMapLevel4);
|
||||
MmEnableWriteProtect();
|
||||
|
||||
DebugLog("Page table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
||||
DebugLog("Page table size : %u MB\n",
|
||||
(lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
||||
}
|
||||
|
||||
//
|
||||
@ -311,7 +312,8 @@ void *MmTransVirtToPhyAddr(void* virtualAddr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*)(((ulong)*page & 0xFFFFFFFFFF000)+ ((ulong)virtualAddr - (ulong)virtAddrPage));
|
||||
return (void*)(((ulong)*page & 0xFFFFFFFFFF000)+
|
||||
((ulong)virtualAddr - (ulong)virtAddrPage));
|
||||
}
|
||||
|
||||
void *MmTransPhyToVirtAddr(void* physicalAddr)
|
||||
@ -409,7 +411,8 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||
{
|
||||
ulong StackGuardOne = (ulong)MmGetStackGuards(0);
|
||||
ulong StackGuardTwo = (ulong)MmGetStackGuards(1);
|
||||
if ((regs->cr2 >= StackGuardOne) && (regs->cr2 <= StackGuardOne + KPAGESIZE) && (regs->rsp <= regs->cr2)) {
|
||||
if ((regs->cr2 >= StackGuardOne) && (regs->cr2 <= StackGuardOne + KPAGESIZE)
|
||||
&& (regs->rsp <= regs->cr2)) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Underflow\n\n"
|
||||
" Page Fault Error code : %#x (%b)\n"
|
||||
@ -420,7 +423,9 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||
regs->ErrorCode,
|
||||
StackGuardOne
|
||||
);
|
||||
} else if ((regs->cr2 >= StackGuardTwo) && (regs->cr2 <= StackGuardTwo + KPAGESIZE) && (regs->rsp >= regs->cr2)) {
|
||||
} else if ((regs->cr2 >= StackGuardTwo)
|
||||
&& (regs->cr2 <= StackGuardTwo + KPAGESIZE)
|
||||
&& (regs->rsp >= regs->cr2)) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Overflow\n\n"
|
||||
" Page Fault Error code : %#x (%b)\n"
|
||||
@ -443,7 +448,7 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||
);
|
||||
} else if (regs->cr2 >= MmVirtLastAddress || regs->cr2 <= 0) {
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Out of bound of the address space at %p !\n\n"
|
||||
"\n\n%CPANIC\n[ISR 0x8] Out of bound of the address space at %p !\n\n"
|
||||
" End of the address space : %p\n"
|
||||
" Page Fault Error code : %#x (%b)\n",
|
||||
|
||||
@ -455,7 +460,8 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||
);
|
||||
} else {
|
||||
//XXX page fault
|
||||
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x8] Irrecoverable Page Fault at %p\n\n"
|
||||
bprintf(BStdOut,
|
||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Page Fault at %p\n\n"
|
||||
" Error code : 0x%x (%b)",
|
||||
|
||||
VGA_COLOR_LIGHT_RED,
|
||||
|
@ -40,7 +40,9 @@ enum
|
||||
Whatever2 = 1UL << 62
|
||||
};
|
||||
|
||||
static AllocatedPage_t busyPagesList = { (void*)0, (void*)0, 0, (AllocatedPage_t*)0 };
|
||||
static AllocatedPage_t busyPagesList =
|
||||
{ (void*)0, (void*)0, 0, (AllocatedPage_t*)0 };
|
||||
|
||||
extern MemoryMap_t memoryMap;
|
||||
extern ulong MmPhysLastKernAddress;
|
||||
|
||||
@ -112,7 +114,8 @@ ulong MmGetTotalPageSize(void)
|
||||
((MmPhysLastKernAddress + KPAGESIZE) & 0xFFFFFFFFFF000));
|
||||
}
|
||||
|
||||
static void addPageToBusyList(void *phyPageAddrBegin, void *phyPageAddrEnd, ulong id)
|
||||
static void addPageToBusyList(void *phyPageAddrBegin,
|
||||
void *phyPageAddrEnd, ulong id)
|
||||
{
|
||||
AllocatedPage_t *busyPage = &busyPagesList;
|
||||
AllocatedPage_t *prevBusyPage = NULL;
|
||||
@ -179,7 +182,8 @@ ulong MmAllocPageFrame(size_t size, bool contiguous)
|
||||
DebugLog("Allocating %d pages (%u o)...\n", pageNumber, size);
|
||||
|
||||
// Through the pages in physical memory...
|
||||
for (void *curPage = (void*)((MmPhysLastKernAddress + KPAGESIZE) & 0xFFFFFFFFFF000);
|
||||
for (void *curPage =
|
||||
(void*)((MmPhysLastKernAddress + KPAGESIZE) & 0xFFFFFFFFFF000);
|
||||
curPage < (void*)(phRamSize & 0xFFFFFFFFFF000); curPage += KPAGESIZE) {
|
||||
busyLastAddr = isPageBusy(curPage);
|
||||
|
||||
@ -263,7 +267,8 @@ error_t MmMapPageFrame(ulong id, void *virtAddr, ulong flags)
|
||||
busyPage = busyPage->next;
|
||||
|
||||
if (id == busyPage->id) {
|
||||
for (void *addr = busyPage->phyAddressBegin; addr <= busyPage->phyAddressEnd; addr += KPAGESIZE) {
|
||||
for (void *addr = busyPage->phyAddressBegin;
|
||||
addr <= busyPage->phyAddressEnd; addr += KPAGESIZE) {
|
||||
if (MmTransPhyToVirtAddr(addr)) {
|
||||
return EADDRINUSE;
|
||||
}
|
||||
@ -290,7 +295,8 @@ error_t MmUnmapPageFrame(ulong id)
|
||||
busyPage = busyPage->next;
|
||||
|
||||
if (id == busyPage->id) {
|
||||
for (void *addr = busyPage->phyAddressBegin; addr <= busyPage->phyAddressEnd; addr += KPAGESIZE) {
|
||||
for (void *addr = busyPage->phyAddressBegin;
|
||||
addr <= busyPage->phyAddressEnd; addr += KPAGESIZE) {
|
||||
actualPhys = MmTransPhyToVirtAddr(addr);
|
||||
//DebugLog("Map %p at %p\n", addr, virtAddr);
|
||||
if (actualPhys && id == busyPage->id) {
|
||||
|
Loading…
Reference in New Issue
Block a user