Cleanup and misc changes

This commit is contained in:
Adrien Bourmault 2020-01-07 00:44:39 +01:00
parent 5155287309
commit f882e16db7
3 changed files with 58 additions and 20 deletions

View File

@ -127,12 +127,12 @@ void KeSetupIDT(void)
KeSetIDTGate(0x04, (ulong)isr4, codeSeg, 0x8E, 2); KeSetIDTGate(0x04, (ulong)isr4, codeSeg, 0x8E, 2);
KeSetIDTGate(0x05, (ulong)isr5, codeSeg, 0x8E, 2); KeSetIDTGate(0x05, (ulong)isr5, codeSeg, 0x8E, 2);
KeSetIDTGate(0x06, (ulong)isr6, codeSeg, 0x8E, 2); KeSetIDTGate(0x06, (ulong)isr6, codeSeg, 0x8E, 2);
KeSetIDTGate(0x07, (ulong)isr7, codeSeg, 0x8E, 2); 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); KeSetIDTGate(0x08, (ulong)isr8, codeSeg, 0x8E, 1); // DOUBLE FAULT
KeSetIDTGate(0x09, (ulong)isr9, codeSeg, 0x8E, 2); 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(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(0x0D, (ulong)isr13, codeSeg, 0x8E, 2);
KeSetIDTGate(0x0E, (ulong)isr14, codeSeg, 0x8E, 2); KeSetIDTGate(0x0E, (ulong)isr14, codeSeg, 0x8E, 2);
KeSetIDTGate(0x0F, (ulong)isr15, codeSeg, 0x8E, 2); // INTEL RESERVED 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 KeSetIDTGate(0x1F, (ulong)isr31, codeSeg, 0x8E, 2); // INTEL RESERVED
// Set IDT IRQs Gates // Set IDT IRQs Gates
KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 2); KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 3);
KeSetIDTGate(0x21, (ulong)isr33, codeSeg, 0x8E, 2); KeSetIDTGate(0x21, (ulong)isr33, codeSeg, 0x8E, 3);
KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 2); KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 3);
KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 2); KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 3);
KeSetIDTGate(0x24, (ulong)isr36, codeSeg, 0x8E, 2); KeSetIDTGate(0x24, (ulong)isr36, codeSeg, 0x8E, 3);
KeSetIDTGate(0x25, (ulong)isr37, codeSeg, 0x8E, 2); KeSetIDTGate(0x25, (ulong)isr37, codeSeg, 0x8E, 3);
KeSetIDTGate(0x26, (ulong)isr38, codeSeg, 0x8E, 2); KeSetIDTGate(0x26, (ulong)isr38, codeSeg, 0x8E, 3);
KeSetIDTGate(0x27, (ulong)isr39, codeSeg, 0x8E, 2); KeSetIDTGate(0x27, (ulong)isr39, codeSeg, 0x8E, 3);
KeSetIDTGate(0x28, (ulong)isr40, codeSeg, 0x8E, 2); KeSetIDTGate(0x28, (ulong)isr40, codeSeg, 0x8E, 3);
KeSetIDTGate(0x29, (ulong)isr41, codeSeg, 0x8E, 2); KeSetIDTGate(0x29, (ulong)isr41, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2A, (ulong)isr42, codeSeg, 0x8E, 2); KeSetIDTGate(0x2A, (ulong)isr42, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2B, (ulong)isr43, codeSeg, 0x8E, 2); KeSetIDTGate(0x2B, (ulong)isr43, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2C, (ulong)isr44, codeSeg, 0x8E, 2); KeSetIDTGate(0x2C, (ulong)isr44, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2D, (ulong)isr45, codeSeg, 0x8E, 2); KeSetIDTGate(0x2D, (ulong)isr45, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E, 2); KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E, 3);
KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E, 2); KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E, 3);
KeIdtIsInitialized++; KeIdtIsInitialized++;

View File

@ -55,6 +55,7 @@ void MmInitGdt(void)
tss.ist1 = (ulong)0x0007FFFF; // ISR RESCUE STACK, GARANTIED FREE FOR USE BY OSDEV.ORG 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.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); tss.iomap_base = sizeof(tss);
memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t)); memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t));

View File

@ -109,6 +109,42 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
return EOK; 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) error_t CmdFloatDiv(int argc, char **argv, char *cmdline)
{ {
double a = (double)atoi(argv[1]); double a = (double)atoi(argv[1]);
@ -210,6 +246,7 @@ static Command_t testcmdtable[] =
{ "args", CmdArgs, "Print command line" }, { "args", CmdArgs, "Print command line" },
{ "atoi", CmdAtoi, "Print command line atoised" }, { "atoi", CmdAtoi, "Print command line atoised" },
{ "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" }, { "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" },
{ "dmp", CmdDumpMem, "Dump 1MB of memory starting from addr"},
{ "help", CmdHelpTest, "Show this message" }, { "help", CmdHelpTest, "Show this message" },
{ "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"}, { "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"},
{ "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"}, { "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"},