From 5c7f4bb49a18d43f6af4b3c386b74351ff1ddbd8 Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Wed, 8 May 2019 00:28:42 +0200 Subject: [PATCH] Stuff --- Makefile | 3 +- kaleid/kernel/init/init.c | 63 ++------------------------------------- kaleid/kernel/init/init.h | 56 ++++++++++++++++++++++++++++++++++ kaleid/kernel/io/keyb.c | 15 ++++++++-- kaleid/kernel/ke/shell.c | 63 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 65 deletions(-) create mode 100644 kaleid/kernel/init/init.h create mode 100644 kaleid/kernel/ke/shell.c diff --git a/Makefile b/Makefile index 6488f72..4566daa 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,8 @@ KernSources = kernel/cpu/cpuid.c \ kernel/mm/gdt.c kernel/ps/sched.c \ kernel/init/info.c kernel/init/ssp.c \ kernel/io/rtc.c kernel/io/keyb.c \ - kernel/io/spkr.c kernel/po/shtdwn.c + kernel/io/spkr.c kernel/po/shtdwn.c \ + kernel/ke/shell.c LibCObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(LibCSources)) diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 234af40..5c7bcd9 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -22,45 +22,13 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// info.c -extern void BtDoSanityChecks(uint mbMagic); -extern void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg); - -// io/vga.c -extern error_t IoInitVGABuffer(void); -extern void IoScrollDown(void); -extern void IoScrollUp(void); - -// io/keyb.c -extern void IoEnableKeyb(void); - -// cpu/idt.c -extern void IdtSetup(void); - -// ps/proc.c test function -extern void pstest(void); - -// interrupts tests -extern void divideByZero(void); +#include "init.h" // // Entry point of the Kaleid kernel // noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) { - uchar ch; - error_t rc; - KeDisableIRQs(); // Initialize the BootInfo_t structure @@ -94,34 +62,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) IoGetRtcTimeChar(); IoPrintRtcTime(); - int i=0; - while(i++<50)KernLog("%d\n", i); - - // Main loop - while ((rc = bgetc(BStdIn, &ch)) == EOK) { - switch (ch) { - - case 7: // BEL - if (rand() % 32 == 0) { - IoDoStarWars(); - } - else IoDoBeep(); - break; - - case 17: // DC1 - IoScrollUp(); - break; - - case 18: // DC2 - IoScrollDown(); - break; - - case 27: // ESC - BFlushBuf(BStdOut); - PoShutdownQemu(); - break; - } - } + KeStartShell(); KernLog("End of input reached\n"); PoShutdownQemu(); diff --git a/kaleid/kernel/init/init.h b/kaleid/kernel/init/init.h new file mode 100644 index 0000000..fa90d51 --- /dev/null +++ b/kaleid/kernel/init/init.h @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: Kernel entry point // +// // +// // +// Copyright © 2018-2019 The OS/K Team // +// // +// This file is part of OS/K. // +// // +// OS/K is free software: you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation, either version 3 of the License, or // +// any later version. // +// // +// OS/K is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY//without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with OS/K. If not, see . // +//----------------------------------------------------------------------------// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// info.c +extern void BtDoSanityChecks(uint mbMagic); +extern void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg); + +// io/vga.c +extern error_t IoInitVGABuffer(void); + +// ke/shell.c +extern void KeStartShell(void); + +// io/keyb.c +extern void IoEnableKeyb(void); + +// cpu/idt.c +extern void IdtSetup(void); + +// ps/proc.c test function +extern void pstest(void); + +// interrupts tests +extern void divideByZero(void); + diff --git a/kaleid/kernel/io/keyb.c b/kaleid/kernel/io/keyb.c index b3eb126..42b476a 100644 --- a/kaleid/kernel/io/keyb.c +++ b/kaleid/kernel/io/keyb.c @@ -26,12 +26,15 @@ #include #include -char ScanCodes[100] = { 0 }; +static char ScanCodes[100] = { 0 }; +static char Invisible[100] = { 0 }; void KeybPrint(char code) { - bputc(BStdIn, ScanCodes[(int)code]); - if (code && (isprint(ScanCodes[(int)code]) || ScanCodes[(int)code]=='\n')) { + uchar ch = ScanCodes[(int)code]; + + bputc(BStdIn, ch); + if (code && Invisible[(int)code] == 0) { bputc(BStdOut, ScanCodes[(int)code]); //bprintf(BStdOut, "%x ", code); BStdOut->flusher(BStdOut); @@ -41,6 +44,7 @@ void KeybPrint(char code) void ScanCodesInit(void) { ScanCodes[0x01] = 27; // ESC + Invisible[0x01] = 1; ScanCodes[0x02] = '1'; ScanCodes[0x03] = '2'; ScanCodes[0x04] = '3'; @@ -97,12 +101,17 @@ void ScanCodesInit(void) ScanCodes[0x39] = ' '; ScanCodes[0x40] = 7; // BEL + Invisible[0x40] = 1; // Numpad ScanCodes[0x48] = 17; // DC1, will serve as Arrow Up ScanCodes[0x50] = 18; // DC2, will serve as Arrow Down ScanCodes[0x4B] = 19; // DC3, will serve as Arrow Left ScanCodes[0x4D] = 20; // DC4, will serve as Arrow Right + Invisible[0x48] = 1; + Invisible[0x50] = 1; + Invisible[0x4B] = 1; + Invisible[0x4D] = 1; } void KeybHandler(ISRFrame_t *regs) diff --git a/kaleid/kernel/ke/shell.c b/kaleid/kernel/ke/shell.c new file mode 100644 index 0000000..afc77ba --- /dev/null +++ b/kaleid/kernel/ke/shell.c @@ -0,0 +1,63 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: Kernel "shell" entry point // +// // +// // +// Copyright © 2018-2019 The OS/K Team // +// // +// This file is part of OS/K. // +// // +// OS/K is free software: you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation, either version 3 of the License, or // +// any later version. // +// // +// OS/K is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY//without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with OS/K. If not, see . // +//----------------------------------------------------------------------------// + +#include +#include +#include +#include + +extern void IoScrollDown(void); +extern void IoScrollUp(void); + +void KeStartShell(void) +{ + uchar ch; + error_t rc; + + while ((rc = bgetc(BStdIn, &ch)) == EOK) { + switch (ch) { + + case 7: // BEL + if (rand() % 64 == 0) { + IoDoStarWars(); + } + else IoDoBeep(); + break; + + case 17: // DC1 + IoScrollUp(); + break; + + case 18: // DC2 + IoScrollDown(); + break; + + case 27: // ESC + BFlushBuf(BStdOut); + PoShutdownQemu(); + break; + } + } +} +