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();
KeRegisterISR(KeybHandler, 0x21);
char readedInterruptConfig = IoReadByteFromPort(0x21);
IoWriteByteOnPort(0x21, 0xFD & readedInterruptConfig);
KeUnmaskIRQ(0x1);
KeRestoreIRQs(flags);
KeEnableNMI();

View File

@ -102,6 +102,7 @@ settingUp:
isrList.entry[n].isrNo = isrNo;
if (!OverWriting) isrList.n++;
DebugLog("Interrupt %d registered to function %p\n", isrNo, isr);
return EOK;
}
@ -260,6 +261,7 @@ void KeMaskIRQ(uchar isr)
value = IoReadByteFromPort(port) | (1 << isr);
IoWriteByteOnPort(port, value);
DebugLog("ISR masked : %d\n", isr);
}
void KeUnmaskIRQ(uchar isr)
@ -276,16 +278,19 @@ void KeUnmaskIRQ(uchar isr)
value = IoReadByteFromPort(port) & ~(1 << isr);
IoWriteByteOnPort(port, value);
DebugLog("ISR unmasked : %d\n", isr);
}
void KeEnableNMI(void)
{
IoWriteByteOnPort(0x70, IoReadByteFromPort(0x70) & 0x7F);
DebugLog("NMI Interrupts enabled\n");
}
void KeDisableNMI(void)
{
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));
/* DebugLog("TSS\n" */
/* "gdt[0] %#x\n" */
/* "gdt[2] %#x\n" */
/* "access : %#x\n" */
/* "flags : %#x\n" */
/* "lowBase : %#x\n" */
/* "middleBase : %#x\n" */
/* "highBase : %#x\n" */
/* "veryHighBase: %#x\n" */
/* "lowLimit : %#x\n" */
/* "ist : %#x\n" */
/* "iomap_base : %#x\n" */
/* "offset : %#x\n", */
/* &gdt[0], */
/* &gdt[2], */
/* tssDesc.access, */
/* tssDesc.flags, */
/* tssDesc.lowBase, */
/* tssDesc.middleBase, */
/* tssDesc.highBase, */
/* tssDesc.veryHighBase, */
/* tssDesc.lowLimit, */
/* tss.ist1, */
/* tss.iomap_base, */
/* tssOffset */
/* ); */
DebugLog("TSS setting up :\n"
"gdt[0] %#x\n"
"gdt[2] %#x\n"
"access : %#x\n"
"flags : %#x\n"
"lowBase : %#x\n"
"middleBase : %#x\n"
"highBase : %#x\n"
"veryHighBase: %#x\n"
"lowLimit : %#x\n"
"ist : %#x\n"
"iomap_base : %#x\n"
"offset : %#x\n",
&gdt[0],
&gdt[2],
tssDesc.access,
tssDesc.flags,
tssDesc.lowBase,
tssDesc.middleBase,
tssDesc.highBase,
tssDesc.veryHighBase,
tssDesc.lowLimit,
tss.ist1,
tss.iomap_base,
tssOffset
);
MmLoadGdt(&gdtPtr, tssOffset);
}

View File

@ -58,6 +58,8 @@ void MmInitHeap(void)
if ((ulong)_heap_start == _heap_max)
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*)
((ulong)currentEntry + (ulong)BtMemoryInfo.mapLength);
DebugLog("Initiliazing memory map...\n");
// fill the map
while (currentEntry < mapEnd) {
@ -80,6 +82,15 @@ static error_t InitMemoryMap(void)
memoryMap.entry[i].type = (uint)currentEntry->type;
// Adding the size to the size (yup)
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 !
currentEntry = (multiboot_memory_map_t*) ((ulong)currentEntry +
currentEntry->size + sizeof(currentEntry->size));

View File

@ -492,5 +492,5 @@ static void PagingHandler(ISRFrame_t *regs)
void MmActivatePageHandler(void)
{
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++;
DebugLog("Allocate page frame id %d, size %d MB, contiguousness %d\n",
id, size / MB, contiguous
);
return id;
}
@ -237,8 +241,12 @@ void MmFreePageFrame(ulong id)
}
}
if (success)
if (success) {
NSuccessfulFree++;
DebugLog("Free page frame id %d\n",
id
);
}
}
//