From da4c91d3c587345ee4198ec5034fe1c9e60fc2d3 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 6 Feb 2020 17:45:44 +0100 Subject: [PATCH] misc --- kaleid/kernel/io/keyb.c | 4 +-- kaleid/kernel/ke/idt.c | 5 ++++ kaleid/kernel/mm/gdt.c | 52 +++++++++++++++++++-------------------- kaleid/kernel/mm/heap.c | 2 ++ kaleid/kernel/mm/map.c | 11 +++++++++ kaleid/kernel/mm/paging.c | 2 +- kaleid/kernel/mm/palloc.c | 10 +++++++- 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/kaleid/kernel/io/keyb.c b/kaleid/kernel/io/keyb.c index 7c91e58..6a1e797 100644 --- a/kaleid/kernel/io/keyb.c +++ b/kaleid/kernel/io/keyb.c @@ -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(); diff --git a/kaleid/kernel/ke/idt.c b/kaleid/kernel/ke/idt.c index 1e0749d..adeacc8 100644 --- a/kaleid/kernel/ke/idt.c +++ b/kaleid/kernel/ke/idt.c @@ -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"); } // diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index 5fdf3d7..e99ef94 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -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); } diff --git a/kaleid/kernel/mm/heap.c b/kaleid/kernel/mm/heap.c index 8e94ebe..ad3449f 100644 --- a/kaleid/kernel/mm/heap.c +++ b/kaleid/kernel/mm/heap.c @@ -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); } // diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index ce4e443..1af8e26 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -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)); diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index ca658cb..42d1b87 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -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"); } diff --git a/kaleid/kernel/mm/palloc.c b/kaleid/kernel/mm/palloc.c index a9a2148..7994ebb 100644 --- a/kaleid/kernel/mm/palloc.c +++ b/kaleid/kernel/mm/palloc.c @@ -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 + ); + } } //