This commit is contained in:
Adrien Bourmault 2020-02-06 17:45:44 +01:00
parent 7dc39cf628
commit da4c91d3c5
7 changed files with 55 additions and 31 deletions

View File

@ -125,9 +125,7 @@ void IoEnableKeyb(void)
ulong flags = KePauseIRQs(); ulong flags = KePauseIRQs();
KeRegisterISR(KeybHandler, 0x21); KeRegisterISR(KeybHandler, 0x21);
char readedInterruptConfig = IoReadByteFromPort(0x21); KeUnmaskIRQ(0x1);
IoWriteByteOnPort(0x21, 0xFD & readedInterruptConfig);
KeRestoreIRQs(flags); KeRestoreIRQs(flags);
KeEnableNMI(); KeEnableNMI();

View File

@ -102,6 +102,7 @@ settingUp:
isrList.entry[n].isrNo = isrNo; isrList.entry[n].isrNo = isrNo;
if (!OverWriting) isrList.n++; if (!OverWriting) isrList.n++;
DebugLog("Interrupt %d registered to function %p\n", isrNo, isr);
return EOK; return EOK;
} }
@ -260,6 +261,7 @@ void KeMaskIRQ(uchar isr)
value = IoReadByteFromPort(port) | (1 << isr); value = IoReadByteFromPort(port) | (1 << isr);
IoWriteByteOnPort(port, value); IoWriteByteOnPort(port, value);
DebugLog("ISR masked : %d\n", isr);
} }
void KeUnmaskIRQ(uchar isr) void KeUnmaskIRQ(uchar isr)
@ -276,16 +278,19 @@ void KeUnmaskIRQ(uchar isr)
value = IoReadByteFromPort(port) & ~(1 << isr); value = IoReadByteFromPort(port) & ~(1 << isr);
IoWriteByteOnPort(port, value); IoWriteByteOnPort(port, value);
DebugLog("ISR unmasked : %d\n", isr);
} }
void KeEnableNMI(void) void KeEnableNMI(void)
{ {
IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) & 0x7F); IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) & 0x7F);
DebugLog("NMI Interrupts enabled\n");
} }
void KeDisableNMI(void) void KeDisableNMI(void)
{ {
IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) | 0x80); IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) | 0x80);
DebugLog("NMI Interrupts disabled\n");
} }
// //

View File

@ -70,32 +70,32 @@ void MmInitGdt(void)
memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t)); memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t));
/* DebugLog("TSS\n" */ DebugLog("TSS setting up :\n"
/* "gdt[0] %#x\n" */ "gdt[0] %#x\n"
/* "gdt[2] %#x\n" */ "gdt[2] %#x\n"
/* "access : %#x\n" */ "access : %#x\n"
/* "flags : %#x\n" */ "flags : %#x\n"
/* "lowBase : %#x\n" */ "lowBase : %#x\n"
/* "middleBase : %#x\n" */ "middleBase : %#x\n"
/* "highBase : %#x\n" */ "highBase : %#x\n"
/* "veryHighBase: %#x\n" */ "veryHighBase: %#x\n"
/* "lowLimit : %#x\n" */ "lowLimit : %#x\n"
/* "ist : %#x\n" */ "ist : %#x\n"
/* "iomap_base : %#x\n" */ "iomap_base : %#x\n"
/* "offset : %#x\n", */ "offset : %#x\n",
/* &gdt[0], */ &gdt[0],
/* &gdt[2], */ &gdt[2],
/* tssDesc.access, */ tssDesc.access,
/* tssDesc.flags, */ tssDesc.flags,
/* tssDesc.lowBase, */ tssDesc.lowBase,
/* tssDesc.middleBase, */ tssDesc.middleBase,
/* tssDesc.highBase, */ tssDesc.highBase,
/* tssDesc.veryHighBase, */ tssDesc.veryHighBase,
/* tssDesc.lowLimit, */ tssDesc.lowLimit,
/* tss.ist1, */ tss.ist1,
/* tss.iomap_base, */ tss.iomap_base,
/* tssOffset */ tssOffset
/* ); */ );
MmLoadGdt(&gdtPtr, tssOffset); MmLoadGdt(&gdtPtr, tssOffset);
} }

View File

@ -58,6 +58,8 @@ void MmInitHeap(void)
if ((ulong)_heap_start == _heap_max) if ((ulong)_heap_start == _heap_max)
KeStartPanic("The heap failed to initialize ! (Not enough memory)"); KeStartPanic("The heap failed to initialize ! (Not enough memory)");
DebugLog("Heap initialized from %p to %p\n", _heap_start, _heap_max);
} }
// //

View File

@ -67,6 +67,8 @@ static error_t InitMemoryMap(void)
mapEnd = (multiboot_memory_map_t*) mapEnd = (multiboot_memory_map_t*)
((ulong)currentEntry + (ulong)BtMemoryInfo.mapLength); ((ulong)currentEntry + (ulong)BtMemoryInfo.mapLength);
DebugLog("Initiliazing memory map...\n");
// fill the map // fill the map
while (currentEntry < mapEnd) { while (currentEntry < mapEnd) {
@ -80,6 +82,15 @@ static error_t InitMemoryMap(void)
memoryMap.entry[i].type = (uint)currentEntry->type; memoryMap.entry[i].type = (uint)currentEntry->type;
// Adding the size to the size (yup) // Adding the size to the size (yup)
memoryMap.length++; memoryMap.length++;
DebugLog("Zone: %lp type %d with length: %4luMB+%4luKB+%4luB\n",
memoryMap.entry[i].addr,
memoryMap.entry[i].type,
_ADDR_TO_MB(memoryMap.entry[i].length),
_ADDR_TO_KB(memoryMap.entry[i].length),
_ADDR_TO_B(memoryMap.entry[i].length)
);
// moving up ! // moving up !
currentEntry = (multiboot_memory_map_t*) ((ulong)currentEntry + currentEntry = (multiboot_memory_map_t*) ((ulong)currentEntry +
currentEntry->size + sizeof(currentEntry->size)); currentEntry->size + sizeof(currentEntry->size));

View File

@ -492,5 +492,5 @@ static void PagingHandler(ISRFrame_t *regs)
void MmActivatePageHandler(void) void MmActivatePageHandler(void)
{ {
KeRegisterISR(PagingHandler, 0xe); KeRegisterISR(PagingHandler, 0xe);
//DebugLog("\tPage handler activated\n"); DebugLog("Page handler activated\n");
} }

View File

@ -216,6 +216,10 @@ ulong MmAllocPageFrame(size_t size, bool contiguous)
NSuccessfulAlloc++; NSuccessfulAlloc++;
DebugLog("Allocate page frame id %d, size %d MB, contiguousness %d\n",
id, size / MB, contiguous
);
return id; return id;
} }
@ -237,8 +241,12 @@ void MmFreePageFrame(ulong id)
} }
} }
if (success) if (success) {
NSuccessfulFree++; NSuccessfulFree++;
DebugLog("Free page frame id %d\n",
id
);
}
} }
// //