From f882e16db702aa831f09986889b5e63997eaaed2 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 7 Jan 2020 00:44:39 +0100 Subject: [PATCH] Cleanup and misc changes --- kaleid/kernel/ke/idt.c | 40 ++++++++++++++++++------------------- kaleid/kernel/mm/gdt.c | 1 + kaleid/kernel/sh/testcmds.c | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/kaleid/kernel/ke/idt.c b/kaleid/kernel/ke/idt.c index 002b972..c279bde 100644 --- a/kaleid/kernel/ke/idt.c +++ b/kaleid/kernel/ke/idt.c @@ -127,12 +127,12 @@ void KeSetupIDT(void) KeSetIDTGate(0x04, (ulong)isr4, codeSeg, 0x8E, 2); KeSetIDTGate(0x05, (ulong)isr5, codeSeg, 0x8E, 2); KeSetIDTGate(0x06, (ulong)isr6, codeSeg, 0x8E, 2); - KeSetIDTGate(0x07, (ulong)isr7, codeSeg, 0x8E, 2); - KeSetIDTGate(0x08, (ulong)isr8, codeSeg, 0x8E, 1); + KeSetIDTGate(0x07, (ulong)isr7, codeSeg, 0x8E, 2); // XXX device not available, useful for FPU save/restore when multitasking + KeSetIDTGate(0x08, (ulong)isr8, codeSeg, 0x8E, 1); // DOUBLE FAULT KeSetIDTGate(0x09, (ulong)isr9, codeSeg, 0x8E, 2); - KeSetIDTGate(0x0A, (ulong)isr10, codeSeg, 0x8E, 0); // INVALID TSS + KeSetIDTGate(0x0A, (ulong)isr10, codeSeg, 0x8E, 0); // INVALID TSS KeSetIDTGate(0x0B, (ulong)isr11, codeSeg, 0x8E, 2); - KeSetIDTGate(0x0C, (ulong)isr12, codeSeg, 0x8E, 1); + KeSetIDTGate(0x0C, (ulong)isr12, codeSeg, 0x8E, 1); // STACK SEGMENT FAULT KeSetIDTGate(0x0D, (ulong)isr13, codeSeg, 0x8E, 2); KeSetIDTGate(0x0E, (ulong)isr14, codeSeg, 0x8E, 2); KeSetIDTGate(0x0F, (ulong)isr15, codeSeg, 0x8E, 2); // INTEL RESERVED @@ -154,22 +154,22 @@ void KeSetupIDT(void) KeSetIDTGate(0x1F, (ulong)isr31, codeSeg, 0x8E, 2); // INTEL RESERVED // Set IDT IRQs Gates - KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 2); - KeSetIDTGate(0x21, (ulong)isr33, codeSeg, 0x8E, 2); - KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 2); - KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 2); - KeSetIDTGate(0x24, (ulong)isr36, codeSeg, 0x8E, 2); - KeSetIDTGate(0x25, (ulong)isr37, codeSeg, 0x8E, 2); - KeSetIDTGate(0x26, (ulong)isr38, codeSeg, 0x8E, 2); - KeSetIDTGate(0x27, (ulong)isr39, codeSeg, 0x8E, 2); - KeSetIDTGate(0x28, (ulong)isr40, codeSeg, 0x8E, 2); - KeSetIDTGate(0x29, (ulong)isr41, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2A, (ulong)isr42, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2B, (ulong)isr43, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2C, (ulong)isr44, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2D, (ulong)isr45, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E, 2); - KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E, 2); + KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 3); + KeSetIDTGate(0x21, (ulong)isr33, codeSeg, 0x8E, 3); + KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 3); + KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 3); + KeSetIDTGate(0x24, (ulong)isr36, codeSeg, 0x8E, 3); + KeSetIDTGate(0x25, (ulong)isr37, codeSeg, 0x8E, 3); + KeSetIDTGate(0x26, (ulong)isr38, codeSeg, 0x8E, 3); + KeSetIDTGate(0x27, (ulong)isr39, codeSeg, 0x8E, 3); + KeSetIDTGate(0x28, (ulong)isr40, codeSeg, 0x8E, 3); + KeSetIDTGate(0x29, (ulong)isr41, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2A, (ulong)isr42, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2B, (ulong)isr43, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2C, (ulong)isr44, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2D, (ulong)isr45, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E, 3); + KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E, 3); KeIdtIsInitialized++; diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index 0ec7cb6..79f9bc6 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -55,6 +55,7 @@ void MmInitGdt(void) tss.ist1 = (ulong)0x0007FFFF; // ISR RESCUE STACK, GARANTIED FREE FOR USE BY OSDEV.ORG tss.ist2 = (ulong)0x00EFFFFF; // ISR STACK, GARANTIED FREE FOR USE BY OSDEV.ORG + tss.ist3 = (ulong)0x00EF0000; // ISR STACK, GARANTIED FREE FOR USE BY OSDEV.ORG tss.iomap_base = sizeof(tss); memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t)); diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index 716ce2a..9c05d3c 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -109,6 +109,42 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline) return EOK; } +error_t CmdDumpMem(int argc, char **argv, char *cmdline) +{ + char sector[1024] = {0}; + char *address = (char*)atol(argv[1]); + int nb = 1; //atoi(argv[2]); + int x = 0; + int step = 16; + + KernLog("Address begin: %p\n", address); + + for (int i = 0; i < 1024*nb; i++) { + sector[i] = *address++; + } + + while(x < 1024*nb) { + KernLog("%C", shcol); + for (int i = 0; i < step; i++) { + KernLog("%02x ", (uchar)sector[i+x]); + } + KernLog(" %C ", VGA_COLOR_LIGHT_BLUE); + for (int i = 0; i < step; i++) { + if (isprint(sector[i+x])) + KernLog("%c", + sector[i+x] + ); + else + KernLog("%c", 0); + } + KernLog("\n"); + x += step; + } + + KernLog("\n\n"); + return EOK; +} + error_t CmdFloatDiv(int argc, char **argv, char *cmdline) { double a = (double)atoi(argv[1]); @@ -210,6 +246,7 @@ static Command_t testcmdtable[] = { "args", CmdArgs, "Print command line" }, { "atoi", CmdAtoi, "Print command line atoised" }, { "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" }, + { "dmp", CmdDumpMem, "Dump 1MB of memory starting from addr"}, { "help", CmdHelpTest, "Show this message" }, { "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"}, { "pf", CmdPF, "Provoke a PF. Usage: pfault
"},