From 8716e896dac970d214f062c660d39cba9807a9a8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 20 May 2019 20:28:18 +0200 Subject: [PATCH] Working on gdt and autoscroll --- boot/loader/mem/structures.inc | 1 + include/io/vga.h | 2 ++ include/mm/mm.h | 2 +- kaleid/kernel/init/init.c | 2 +- kaleid/kernel/io/vga.c | 5 ++++ kaleid/kernel/mm/gdt.c | 49 +++++++++++++++++++++++++++------- kaleid/kernel/sh/shell.c | 4 +++ 7 files changed, 54 insertions(+), 11 deletions(-) diff --git a/boot/loader/mem/structures.inc b/boot/loader/mem/structures.inc index e538bea..590f651 100644 --- a/boot/loader/mem/structures.inc +++ b/boot/loader/mem/structures.inc @@ -28,6 +28,7 @@ extern kernelEnd extern _bss global newKernelEnd global newStackEnd +global GDT64 [section .text] KERNEL_STACK equ 16 * 1024 ; 16KB of stack diff --git a/include/io/vga.h b/include/io/vga.h index 7155fcf..7d183dd 100644 --- a/include/io/vga.h +++ b/include/io/vga.h @@ -65,6 +65,8 @@ void IoChangeTermColor(int, int); error_t IoInitVGABuffer(void); +uint IoGetScroll(void); + //----------------------------------------------------------------------------// #endif diff --git a/include/mm/mm.h b/include/mm/mm.h index f724260..3e1400d 100644 --- a/include/mm/mm.h +++ b/include/mm/mm.h @@ -114,7 +114,7 @@ struct Tss_t // The gdt pointer struct GdtPtr_t { - uchar limit; // upper 16 bits + ushort limit; // upper 16 bits ulong base; // address of the first entry } __attribute__((__packed__)); diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index c259438..65dc333 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -54,8 +54,8 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) BtDoSanityChecks(mbMagic); // Memory + //MmInitGdt(); MmInitMemoryMap(); - MmInitGdt(); MmInitPaging(); MmInitHeap(); diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index bdc18cb..6e4919f 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -108,6 +108,11 @@ error_t bvgaflusher(Buffer_t *buf) return EOK; } +uint IoGetScroll(void) +{ + return bscroll; +} + void IoScrollDown(void) { BLockBuf(BStdOut); diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index ef56e74..0b26975 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -24,13 +24,6 @@ #include -ulong gdtEntries[2] = -{ - (0L), // NULL descriptor - ((1L<<43) | (1L<<44) | (1L<<47) | (1L<<53)) // KERNEL CS 0x8 -}; - - //Tss_t tssEntry = { 0 }; GdtPtr_t gdtPtr; @@ -71,8 +64,46 @@ GdtPtr_t gdtPtr; void MmInitGdt(void) { - gdtPtr.limit = sizeof(gdtEntries) - 1; - gdtPtr.base = (ulong)&gdtEntries; + MmStoreGdt(); + + GdtEntry_t *gdt = (GdtEntry_t *)(gdtPtr.base); + extern ulong GDT64; + + DebugLog("GDT ADDR: %p\n", + gdt + ); + + gdt++; + + DebugLog("GDT : \n" + "lowLimit : %#016hx\n" + "lowBase : %#016hx\n" + "middleBase: %#016hx\n" + "access : %#016hx\n" + "flags : %#016hx\n" + "highBase : %#016hx\n", + gdt->lowLimit, + gdt->lowBase, + gdt->middleBase, + gdt->access, + gdt->flags, + gdt->highBase + ); + + /* DebugLog("GDT : \n" */ + /* "lowLimit : %#016hx\n" */ + /* "lowBase : %#016hx\n" */ + /* "middleBase: %#016hx\n" */ + /* "access : %#016hx\n" */ + /* "flags : %#016hx\n" */ + /* "highBase : %#016hx\n", */ + /* gdt->lowLimit, */ + /* gdt->lowBase, */ + /* gdt->middleBase, */ + /* gdt->access, */ + /* gdt->flags, */ + /* gdt->highBase */ + /* ); */ MmLoadGdt(); } diff --git a/kaleid/kernel/sh/shell.c b/kaleid/kernel/sh/shell.c index e37c31b..f7ce5de 100644 --- a/kaleid/kernel/sh/shell.c +++ b/kaleid/kernel/sh/shell.c @@ -134,6 +134,10 @@ void KeStartShell(void) bufptr = cmdbuf; ExecuteCommand(cmdbuf); + while (IoGetScroll() > 0) { + IoScrollDown(); + } + memzero(cmdbuf, CMDBUFSIZE); KernLog("%Cshell> %C", VGA_COLOR_WHITE, shcol); BFlushBuf(BStdIn);