From 882aaa3844a77628d709363f0103086348ac5735 Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Mon, 11 Mar 2019 14:07:16 +0100 Subject: [PATCH 01/22] Stuff I don't remember --- Makefile | 25 +++++++++++++++++++++---- Makefile.in | 2 +- kaleid/crtlib/sprintf.c | 1 + kaleid/kernel/init/init.c | 9 ++++++++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0dc4347..cb4500f 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,24 @@ OBJDIR=build/obj BINDIR=build/bin # Object to link (temp) -l_objects=./build/obj/kaleid/crtlib/memory.o ./build/obj/kaleid/crtlib/rand.o ./build/obj/kaleid/crtlib/string.o ./build/obj/kaleid/crtlib/ultoa.o ./build/obj/kaleid/crtlib/strtol.o ./build/obj/kaleid/crtlib/utoa.o ./build/obj/kaleid/crtlib/status.o ./build/obj/kaleid/crtlib/atoul.o ./build/obj/kaleid/crtlib/atol.o ./build/obj/kaleid/crtlib/itoa.o ./build/obj/kaleid/crtlib/ltoa.o ./build/obj/kaleid/crtlib/atou.o ./build/obj/kaleid/crtlib/arith.o ./build/obj/kaleid/crtlib/atoi.o ./build/obj/kaleid/extras/prog.o ./build/obj/kaleid/extras/argv.o ./build/obj/kaleid/kernel/init/table.o ./build/obj/kaleid/kernel/init/init.o ./build/obj/kaleid/kernel/io/vga.o ./build/obj/kaleid/kernel/io/cursor.o ./build/obj/kaleid/kernel/io/term.o ./build/obj/kaleid/kernel/ke/panic.o ./build/obj/boot/loader.o +l_objects=./build/obj/kaleid/crtlib/memory.o \ + ./build/obj/kaleid/crtlib/rand.o \ + ./build/obj/kaleid/crtlib/string.o \ + ./build/obj/kaleid/crtlib/ultoa.o \ + ./build/obj/kaleid/crtlib/utoa.o \ + ./build/obj/kaleid/crtlib/ctype.o \ + ./build/obj/kaleid/crtlib/itoa.o \ + ./build/obj/kaleid/crtlib/ltoa.o \ + ./build/obj/kaleid/crtlib/sprintf.o \ + ./build/obj/kaleid/extras/prog.o \ + ./build/obj/kaleid/extras/argv.o \ + ./build/obj/kaleid/kernel/init/table.o \ + ./build/obj/kaleid/kernel/init/init.o \ + ./build/obj/kaleid/kernel/io/vga.o \ + ./build/obj/kaleid/kernel/io/cursor.o \ + ./build/obj/kaleid/kernel/io/term.o \ + ./build/obj/kaleid/kernel/ke/panic.o \ + ./build/obj/boot/loader.o #Color codes CL='\033[0;32m' @@ -92,18 +109,18 @@ make_disk: @echo ${CL2}[make_disk]${CL} OK${CL3} test: kernel loader - @qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & + qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm test32: kernel loader - @qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & + qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm debug: kernel loader - @qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & + qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm diff --git a/Makefile.in b/Makefile.in index 8e4c573..4e4c536 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,7 +27,7 @@ // The madman's Makefile #include "build/preproc.h" -CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc" +CCNAME=x86_64-elf-gcc CC2NAME=gcc COPTIM=-O2 CWARNS=-Wall -Wextra // -Werror=implicit-function-declaration diff --git a/kaleid/crtlib/sprintf.c b/kaleid/crtlib/sprintf.c index 5613434..8174ddd 100644 --- a/kaleid/crtlib/sprintf.c +++ b/kaleid/crtlib/sprintf.c @@ -230,6 +230,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) // Unknown/unsupported modifier :| *str++ = mod; + ret++; break; } diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index c50108a..961e55d 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -28,11 +28,18 @@ // // Entry point of the Kaleid kernel // -noreturn void StartKern(void* multibooot_info, int multiboot_magic) +noreturn void StartKern(void *mbInfo, int mbMagic) { + (void)mbInfo; + (void)mbMagic; + // We're not ready to deal with interrupts DisableIRQs(); + volatile ushort *vga = (volatile ushort *)0xB8000; + + *vga++ = 'AA'; + // Kernel terminals InitTerms(); From 1e2bf99bd46d9bdc35c9e0d774e2456847eca78c Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 14:16:56 +0100 Subject: [PATCH 02/22] merge --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 37b89cd..64e4a70 100644 --- a/Makefile +++ b/Makefile @@ -117,7 +117,6 @@ test: kaleid @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm -<<<<<<< HEAD test32: kernel loader qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm From c39f733e6d0cd97167bb3028990d812315fdd531 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 14:17:02 +0100 Subject: [PATCH 03/22] merge --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 64e4a70..c4f5406 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ test32: kernel loader debug: kernel loader qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & -======= + test32: kaleid @qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @@ -132,7 +132,6 @@ test32: kaleid debug: kaleid @qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & ->>>>>>> master @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm From 1beaf2b46d1a2e41c22aba249662cbb3b6857326 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 14:47:11 +0100 Subject: [PATCH 04/22] Step 0 : InitTerms() is the bug --- Makefile.in | 9 --------- boot/loader/io/terminal.inc | 13 ++++++++++++- boot/loader/loader.asm | 22 +++++++++++++--------- kaleid/kernel/init/init.c | 10 ++++++---- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4e4c536..84325f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -48,16 +48,7 @@ KERNDIR=kaleid/kernel SYSTDIR=kaleid/system LINXDIR=kaleid/test -//----------------------------------------------------------------------------# -// TESTING MAKEFILE -pseudo_kern: - $(ASM) $(BOOTFLAGS) $(BOOTDIR)/pseudo_kernel.s -o $(OBJDIR)/boot/pkernel.bin - -testing: bootloader pseudo_kern - cat $(BINDIR)/bootloader.bin $(OBJDIR)/boot/pkernel.bin > $(BINDIR)/boot.bin - -//----------------------------------------------------------------------------# // COMMON MAKEFILE COBJDIR=$(OBJDIR)/$(COMMDIR) diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc index 1037c10..2df0252 100644 --- a/boot/loader/io/terminal.inc +++ b/boot/loader/io/terminal.inc @@ -22,7 +22,7 @@ ; You should have received a copy of the GNU General Public License ; ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; - +global testf ;;VIDEO %define TRAM 0xB8000 ; [T]ext[RAM] @@ -41,6 +41,17 @@ VGA_X dq 0 [BITS 64] +testf: + push rsi + push rbx + mov esi, teststr + mov bl, 0xF + call write + pop rsi + pop rbx + ret +teststr: db "Salut",0 + ;-----------------------------------------------------------------------; ; x64/LM Clear Text Screen Function ; diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 0ddf7b6..13278b3 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -62,16 +62,16 @@ MB_start: ; Prints 'ERR:XX' where 'XX' is the str in AX ; ; ---------------------------------------------------------------------------- ; Error: - mov word [CODE], ax + mov word [.code], ax push esi mov bl, 0x0c - mov esi, ERGO + mov esi, .ergo call write32 pop esi jmp Die -ERGO : db "A", 219, 219, " Error " -CODE : db "00" - db 0x0 +.ergo : db 219, 219, 219, " Error " +.code : db "00" + db 0x0 ; ---------------------------------------------------------------------------- ; ; Kills the mind of your computer to get it prostrated ; ; ---------------------------------------------------------------------------- ; @@ -101,11 +101,11 @@ lbegin: call clear ; Clear the screen ;; BEGIN OF CHECKLIST - call MB_check ; Check Multiboot State + call MB_check ; Check Multiboot State, ERR 01 - call Check_cpuid ; Check if cpuid supported - call Is64Bits ; Check if long mode available - call CheckA20 ; Check if A20 is correctly enable + call Check_cpuid ; Check if cpuid supported, ERR 02 + call Is64Bits ; Check if long mode available, ERR 03 + call CheckA20 ; Check if A20 is correctly enable, ERR 04 ;; BEGIN OF WORK call Setup_paging ; Enable paging @@ -126,6 +126,7 @@ lbegin: x64_K db "Now in x64 long mode", 0x0A, 0x0D, 0x0 GoKernel db "Launching Kernel...", 0 +nokernel db "ERROR 05 : Kernel launching error",0 _loader64: ;; Some cleanup @@ -155,4 +156,7 @@ _loader64: jmp StartKern ;; We must never reach this point ------------------------------------------- ;; + mov bl, 0x0c + mov esi, nokernel ; Error 05 + call write jmp Die diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index bda40a5..af6cfa7 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -25,10 +25,12 @@ #include #include + +extern void testf(void); + // // Entry point of the Kaleid kernel // - noreturn void StartKern(void *mbInfo, int mbMagic) { (void)mbInfo; @@ -39,12 +41,12 @@ noreturn void StartKern(void *mbInfo, int mbMagic) volatile ushort *vga = (volatile ushort *)0xB8000; - *vga++ = 'AA'; - // Kernel terminals //InitTerms(); + *vga++ = ('A' << 8 | 0x0F); + // We're out - //StartPanic("Goodbye World :("); + StartPanic("Goodbye World :("); } From fe12e3bca9d39b31f63bc2d3cd148d2f9221d8c1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 15:23:01 +0100 Subject: [PATCH 05/22] Debug stuff --- Makefile.in | 2 +- kaleid/include/kernel/term.h | 3 +++ kaleid/kernel/init/init.c | 8 +++----- kaleid/kernel/init/table.c | 4 +++- kaleid/kernel/io/term.c | 4 +--- kaleid/kernel/io/vga.c | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index 84325f7..194b4ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,7 @@ CINCLUDES=-Ikaleid/include CFLAGS1=-nostdlib -ffreestanding -mcmodel=large // -std=gnu11 CFLAGS2=_ASMTYPE -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -CFLAGS=$(CFLAGS1) $(CFLAGS2) +CFLAGS=$(CFLAGS1) $(CFLAGS2) -DNDEBUG CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CINCLUDES) diff --git a/kaleid/include/kernel/term.h b/kaleid/include/kernel/term.h index 83d2bb2..29477ee 100644 --- a/kaleid/include/kernel/term.h +++ b/kaleid/include/kernel/term.h @@ -96,6 +96,9 @@ extern Terminal_t *stdOut; #define GetStdOut() (stdOut) #define SetStdOut(x) (stdOut = (x)) +// Debug purposes +volatile ushort *vga; + //------------------------------------------// #ifndef _NO_DEBUG diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index af6cfa7..3caa32d 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -39,14 +39,12 @@ noreturn void StartKern(void *mbInfo, int mbMagic) // We're not ready to deal with interrupts DisableIRQs(); - volatile ushort *vga = (volatile ushort *)0xB8000; - // Kernel terminals - //InitTerms(); + InitTerms(); - *vga++ = ('A' << 8 | 0x0F); + *vga = 'A' | (0x0F << 8); // We're out - StartPanic("Goodbye World :("); + // StartPanic("Goodbye World :("); } diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 273105a..5fcdd2c 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -27,5 +27,7 @@ int cpuCount = 1; Processor_t cpuTable[NCPUS] = {0}; -Terminal_t *stdOut, *stdDbg; +Terminal_t *stdOut = 0, *stdDbg = 0; + +volatile ushort *vga = (volatile ushort *)0xB8000; diff --git a/kaleid/kernel/io/term.c b/kaleid/kernel/io/term.c index 1d8adcc..fa5da06 100644 --- a/kaleid/kernel/io/term.c +++ b/kaleid/kernel/io/term.c @@ -32,12 +32,10 @@ extern Terminal_t VGA_Terminal; // void InitTerms(void) { - KalAssert(!GetStdOut() && !GetStdDbg()); + //KalAssert(!GetStdOut() && !GetStdDbg()); VGA_Init(); - // vgaTerm.initDone = INITOK; - SetStdDbg(&VGA_Terminal); SetStdOut(&VGA_Terminal); diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index 54bc63d..dea935b 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -37,12 +37,12 @@ #define VGA_ComputeEntry(ch, cl) (((ushort)(ch)) | (ushort)(cl) << 8) // -// Fill terminal with '\0' +// Clear terminal // error_t VGA_ClearTermUnlocked(Terminal_t *term) { const uchar color = VGA_ComputeColorCode(term->fgColor, term->bgColor); - const ushort filler = VGA_ComputeEntry('\0', color); + const ushort filler = VGA_ComputeEntry(' ', color); const size_t bufsize = term->width * term->height; // Fill the buffer From 2aeaefe7acf17c7ae9b0e95647b7ccd743069f3f Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 18:10:54 +0100 Subject: [PATCH 06/22] Step 1 : StartPanic is the real problem --- boot/loader/loader.asm | 6 ++++-- kaleid/kernel/init/init.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 13278b3..33236e0 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -126,7 +126,7 @@ lbegin: x64_K db "Now in x64 long mode", 0x0A, 0x0D, 0x0 GoKernel db "Launching Kernel...", 0 -nokernel db "ERROR 05 : Kernel launching error",0 +nokernel db 219, 219, 219, " Error 05 : Kernel returns",0 _loader64: ;; Some cleanup @@ -153,9 +153,11 @@ _loader64: call tritemporize ; Let time to see extern StartKern - jmp StartKern + call StartKern ;; We must never reach this point ------------------------------------------- ;; + call tritemporize ; Let time to see + call clear mov bl, 0x0c mov esi, nokernel ; Error 05 call write diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 3caa32d..ce72856 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -42,9 +42,11 @@ noreturn void StartKern(void *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - *vga = 'A' | (0x0F << 8); + vga = 0xB8000; + + *vga = ('A') | (0x0F << 8); // We're out - // StartPanic("Goodbye World :("); + //StartPanic("Goodbye World :("); } From 021c94489bea8adc4eb2bc0d4801e85a5b4a505e Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 18:17:08 +0100 Subject: [PATCH 07/22] Step 1 : StartPanic is the real problem --- boot/loader/cpu/cpu.inc | 4 ++++ kaleid/kernel/init/init.c | 2 -- kaleid/kernel/ke/panic.c | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index 8b92819..2bf937a 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -23,6 +23,10 @@ ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; +global temporize +global bitemporize +global tritemporize + [BITS 64] temporize: diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index ce72856..39858b5 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -42,8 +42,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - vga = 0xB8000; - *vga = ('A') | (0x0F << 8); // We're out diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index 3127321..cbb9ac0 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -62,6 +62,7 @@ noreturn void StartPanic(const char *fmt, ...) if (GetPanicStr()) { GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\ndouble panic!"); + tritemporize(); HaltCPU(); } @@ -72,6 +73,7 @@ noreturn void StartPanic(const char *fmt, ...) GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\npanic!\n\n"); GetStdOut()->PrintOnTermUnlocked(GetStdOut(), GetPanicStr()); + tritemporize(); HaltCPU(); } @@ -81,6 +83,7 @@ noreturn void StartPanic(const char *fmt, ...) noreturn void CrashSystem(void) { DisableIRQs(); + tritemporize(); HaltCPU(); } From 348c3b7eadd16623f1e19c4c5842f2943b954973 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 18:17:49 +0100 Subject: [PATCH 08/22] Step 1 : StartPanic is the real problem --- kaleid/kernel/ke/panic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index cbb9ac0..4e8c7d6 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -50,6 +50,7 @@ noreturn void StartPanic(const char *fmt, ...) va_list ap; DisableIRQs(); + *vga = ('B') | (0x0F << 8); if (GetCurProc()) _SetCurProc(NULL); if (GetStdOut() == NULL) CrashSystem(); From 4ba948669fdfa622b2931e05a3de18963990d332 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 18:25:35 +0100 Subject: [PATCH 09/22] Step 1 : In StartPanic is the real problem --- Makefile | 9 -------- Makefile.in | 46 ++++++++++++++++++------------------- boot/loader/cpu/cpu.inc | 6 ++--- boot/loader/io/terminal.inc | 2 +- kaleid/kernel/init/init.c | 2 +- kaleid/kernel/ke/panic.c | 2 ++ 6 files changed, 30 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index c4f5406..d7ae0dc 100644 --- a/Makefile +++ b/Makefile @@ -116,15 +116,6 @@ test: kaleid @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm - -test32: kernel loader - qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & - @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm - @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm - -debug: kernel loader - qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & - test32: kaleid @qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm diff --git a/Makefile.in b/Makefile.in index 194b4ce..eec9b98 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,25 +60,25 @@ TCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES) KCC=$(CC) -D_OSK_SOURCE -D_KALEID_KERNEL comm-convert: - COMPILE_CONVRT1(itoa) -D_NEED_ITOA - COMPILE_CONVRT1(ltoa) -D_NEED_LTOA - COMPILE_CONVRT1(utoa) -D_NEED_UTOA - COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA - COMPILE_CONVRT2(atoi) -D_NEED_ATOI - COMPILE_CONVRT2(atol) -D_NEED_ATOL - COMPILE_CONVRT2(atou) -D_NEED_ATOU - COMPILE_CONVRT2(atoul) -D_NEED_ATOUL + @COMPILE_CONVRT1(itoa) -D_NEED_ITOA + @COMPILE_CONVRT1(ltoa) -D_NEED_LTOA + @COMPILE_CONVRT1(utoa) -D_NEED_UTOA + @COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA + @COMPILE_CONVRT2(atoi) -D_NEED_ATOI + @COMPILE_CONVRT2(atol) -D_NEED_ATOL + @COMPILE_CONVRT2(atou) -D_NEED_ATOU + @COMPILE_CONVRT2(atoul) -D_NEED_ATOUL common: comm-convert - COMPILE_COMMON(rand) - COMPILE_COMMON(ctype) - COMPILE_COMMON(string) - COMPILE_COMMON(status) - COMPILE_COMMON(memory) -fno-strict-aliasing - COMPILE_COMMON(strtol) - COMPILE_COMMON(sprintf) - COMPILE_COMMON(../extras/prog) - COMPILE_COMMON(../extras/argv) + @COMPILE_COMMON(rand) + @COMPILE_COMMON(ctype) + @COMPILE_COMMON(string) + @COMPILE_COMMON(status) + @COMPILE_COMMON(memory) -fno-strict-aliasing + @COMPILE_COMMON(strtol) + @COMPILE_COMMON(sprintf) + @COMPILE_COMMON(../extras/prog) + @COMPILE_COMMON(../extras/argv) tests: common $(TCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o @@ -92,12 +92,12 @@ KOBJDIR=$(OBJDIR)/$(KERNDIR) KERNOBJS=KOBJ6(init/init, init/table, ke/panic, io/term, io/cursor, io/vga) kernel: common - COMPILE_KERNEL(init/init) - COMPILE_KERNEL(init/table) - COMPILE_KERNEL(ke/panic) - COMPILE_KERNEL(io/cursor) - COMPILE_KERNEL(io/term) - COMPILE_KERNEL(io/vga) + @COMPILE_KERNEL(init/init) + @COMPILE_KERNEL(init/table) + @COMPILE_KERNEL(ke/panic) + @COMPILE_KERNEL(io/cursor) + @COMPILE_KERNEL(io/term) + @COMPILE_KERNEL(io/vga) //LINK_KERNEL(kaleid-kernel.elf) //----------------------------------------------------------------------------# diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index 2bf937a..5fa0a5d 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -23,9 +23,9 @@ ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; -global temporize -global bitemporize -global tritemporize +[global temporize] +[global bitemporize] +[global tritemporize] [BITS 64] diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc index 2df0252..c2bce9a 100644 --- a/boot/loader/io/terminal.inc +++ b/boot/loader/io/terminal.inc @@ -22,7 +22,7 @@ ; You should have received a copy of the GNU General Public License ; ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; -global testf +[global testf] ;;VIDEO %define TRAM 0xB8000 ; [T]ext[RAM] diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 39858b5..943d3a5 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -45,6 +45,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) *vga = ('A') | (0x0F << 8); // We're out - //StartPanic("Goodbye World :("); + StartPanic("Goodbye World :("); } diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index 4e8c7d6..366dd14 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -55,6 +55,8 @@ noreturn void StartPanic(const char *fmt, ...) if (GetCurProc()) _SetCurProc(NULL); if (GetStdOut() == NULL) CrashSystem(); + HaltCPU(); + GetStdOut()->ClearTermUnlocked(GetStdOut()); if (fmt == NULL) { From 228df83a1a1e0927eadae0a2ca74d7d16a3ce80e Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 19:22:37 +0100 Subject: [PATCH 10/22] Merging from master (#34) * Update Readme.md * Debug this beautiful panicked kernel ! * Stuff I don't remember * stuff * merge * merge * Step 0 : InitTerms() is the bug * Debug stuff * Step 1 : StartPanic is the real problem * Step 1 : StartPanic is the real problem * Step 1 : StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1.5 : \n was a problem * Step 2 : Well... It was a 'sleepy' problem * Step 2 : Well... It was a 'sleepy' problem * Step 2.1 : GetPanicStr is an array * Step 2.2 : Now panic accept 8 chars * Ok then ! --- Makefile | 23 ++++++++++++-- Makefile.in | 59 +++++++++++++++--------------------- boot/grub/grub-install.sh | 4 +++ boot/grub/umount.sh | 2 +- boot/loader/cpu/cpu.inc | 4 +++ boot/loader/io/terminal.inc | 13 +++++++- boot/loader/loader.asm | 26 ++++++++++------ kaleid/crtlib/sprintf.c | 1 + kaleid/include/kernel/base.h | 3 +- kaleid/include/kernel/term.h | 3 ++ kaleid/kernel/init/init.c | 8 ++++- kaleid/kernel/init/table.c | 4 ++- kaleid/kernel/io/term.c | 4 +-- kaleid/kernel/io/vga.c | 12 ++++---- kaleid/kernel/ke/panic.c | 8 ++--- 15 files changed, 109 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 9383282..d7ae0dc 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ ASM=nasm LD=ld ASMFLAGS=-f elf64 -LDFLAGS= -melf_x86_64 +LDFLAGS=-melf_x86_64 #Folders MBRDIR=boot/grub @@ -37,7 +37,24 @@ OBJDIR=build/obj BINDIR=build/bin # Object to link (temp) -l_objects=./build/obj/kaleid/crtlib/memory.o ./build/obj/kaleid/crtlib/rand.o ./build/obj/kaleid/crtlib/string.o ./build/obj/kaleid/crtlib/ultoa.o ./build/obj/kaleid/crtlib/strtol.o ./build/obj/kaleid/crtlib/utoa.o ./build/obj/kaleid/crtlib/status.o ./build/obj/kaleid/crtlib/atoul.o ./build/obj/kaleid/crtlib/atol.o ./build/obj/kaleid/crtlib/itoa.o ./build/obj/kaleid/crtlib/ltoa.o ./build/obj/kaleid/crtlib/atou.o ./build/obj/kaleid/crtlib/arith.o ./build/obj/kaleid/crtlib/atoi.o ./build/obj/kaleid/extras/prog.o ./build/obj/kaleid/extras/argv.o ./build/obj/kaleid/kernel/init/table.o ./build/obj/kaleid/kernel/init/init.o ./build/obj/kaleid/kernel/io/vga.o ./build/obj/kaleid/kernel/io/cursor.o ./build/obj/kaleid/kernel/io/term.o ./build/obj/kaleid/kernel/ke/panic.o ./build/obj/boot/loader.o +l_objects=./build/obj/kaleid/crtlib/memory.o \ + ./build/obj/kaleid/crtlib/rand.o \ + ./build/obj/kaleid/crtlib/string.o \ + ./build/obj/kaleid/crtlib/ultoa.o \ + ./build/obj/kaleid/crtlib/utoa.o \ + ./build/obj/kaleid/crtlib/ctype.o \ + ./build/obj/kaleid/crtlib/itoa.o \ + ./build/obj/kaleid/crtlib/ltoa.o \ + ./build/obj/kaleid/crtlib/sprintf.o \ + ./build/obj/kaleid/extras/prog.o \ + ./build/obj/kaleid/extras/argv.o \ + ./build/obj/kaleid/kernel/init/table.o \ + ./build/obj/kaleid/kernel/init/init.o \ + ./build/obj/kaleid/kernel/io/vga.o \ + ./build/obj/kaleid/kernel/io/cursor.o \ + ./build/obj/kaleid/kernel/io/term.o \ + ./build/obj/kaleid/kernel/ke/panic.o \ + ./build/obj/boot/loader.o #Color codes CL='\033[0;32m' @@ -91,6 +108,7 @@ make_disk: @$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img @echo ${CL2}[make_disk]${CL} OK${CL3} + kaleid: kernel loader test: kaleid @@ -98,7 +116,6 @@ test: kaleid @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm - test32: kaleid @qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm diff --git a/Makefile.in b/Makefile.in index 8e4c573..eec9b98 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,7 +27,7 @@ // The madman's Makefile #include "build/preproc.h" -CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc" +CCNAME=x86_64-elf-gcc CC2NAME=gcc COPTIM=-O2 CWARNS=-Wall -Wextra // -Werror=implicit-function-declaration @@ -35,7 +35,7 @@ CINCLUDES=-Ikaleid/include CFLAGS1=-nostdlib -ffreestanding -mcmodel=large // -std=gnu11 CFLAGS2=_ASMTYPE -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -CFLAGS=$(CFLAGS1) $(CFLAGS2) +CFLAGS=$(CFLAGS1) $(CFLAGS2) -DNDEBUG CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CINCLUDES) @@ -48,16 +48,7 @@ KERNDIR=kaleid/kernel SYSTDIR=kaleid/system LINXDIR=kaleid/test -//----------------------------------------------------------------------------# -// TESTING MAKEFILE -pseudo_kern: - $(ASM) $(BOOTFLAGS) $(BOOTDIR)/pseudo_kernel.s -o $(OBJDIR)/boot/pkernel.bin - -testing: bootloader pseudo_kern - cat $(BINDIR)/bootloader.bin $(OBJDIR)/boot/pkernel.bin > $(BINDIR)/boot.bin - -//----------------------------------------------------------------------------# // COMMON MAKEFILE COBJDIR=$(OBJDIR)/$(COMMDIR) @@ -69,25 +60,25 @@ TCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES) KCC=$(CC) -D_OSK_SOURCE -D_KALEID_KERNEL comm-convert: - COMPILE_CONVRT1(itoa) -D_NEED_ITOA - COMPILE_CONVRT1(ltoa) -D_NEED_LTOA - COMPILE_CONVRT1(utoa) -D_NEED_UTOA - COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA - COMPILE_CONVRT2(atoi) -D_NEED_ATOI - COMPILE_CONVRT2(atol) -D_NEED_ATOL - COMPILE_CONVRT2(atou) -D_NEED_ATOU - COMPILE_CONVRT2(atoul) -D_NEED_ATOUL + @COMPILE_CONVRT1(itoa) -D_NEED_ITOA + @COMPILE_CONVRT1(ltoa) -D_NEED_LTOA + @COMPILE_CONVRT1(utoa) -D_NEED_UTOA + @COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA + @COMPILE_CONVRT2(atoi) -D_NEED_ATOI + @COMPILE_CONVRT2(atol) -D_NEED_ATOL + @COMPILE_CONVRT2(atou) -D_NEED_ATOU + @COMPILE_CONVRT2(atoul) -D_NEED_ATOUL common: comm-convert - COMPILE_COMMON(rand) - COMPILE_COMMON(ctype) - COMPILE_COMMON(string) - COMPILE_COMMON(status) - COMPILE_COMMON(memory) -fno-strict-aliasing - COMPILE_COMMON(strtol) - COMPILE_COMMON(sprintf) - COMPILE_COMMON(../extras/prog) - COMPILE_COMMON(../extras/argv) + @COMPILE_COMMON(rand) + @COMPILE_COMMON(ctype) + @COMPILE_COMMON(string) + @COMPILE_COMMON(status) + @COMPILE_COMMON(memory) -fno-strict-aliasing + @COMPILE_COMMON(strtol) + @COMPILE_COMMON(sprintf) + @COMPILE_COMMON(../extras/prog) + @COMPILE_COMMON(../extras/argv) tests: common $(TCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o @@ -101,12 +92,12 @@ KOBJDIR=$(OBJDIR)/$(KERNDIR) KERNOBJS=KOBJ6(init/init, init/table, ke/panic, io/term, io/cursor, io/vga) kernel: common - COMPILE_KERNEL(init/init) - COMPILE_KERNEL(init/table) - COMPILE_KERNEL(ke/panic) - COMPILE_KERNEL(io/cursor) - COMPILE_KERNEL(io/term) - COMPILE_KERNEL(io/vga) + @COMPILE_KERNEL(init/init) + @COMPILE_KERNEL(init/table) + @COMPILE_KERNEL(ke/panic) + @COMPILE_KERNEL(io/cursor) + @COMPILE_KERNEL(io/term) + @COMPILE_KERNEL(io/vga) //LINK_KERNEL(kaleid-kernel.elf) //----------------------------------------------------------------------------# diff --git a/boot/grub/grub-install.sh b/boot/grub/grub-install.sh index 44d591f..cd76028 100755 --- a/boot/grub/grub-install.sh +++ b/boot/grub/grub-install.sh @@ -38,6 +38,10 @@ sudo losetup /dev/loop1 $1 -o 1048576 > /dev/null #mounting the logical partitio echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3} ## Mount +if [ -e $2/boot ]  +then + sudo umount $2 > /dev/null +fi sudo mount /dev/loop1 $2 > /dev/null echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3} diff --git a/boot/grub/umount.sh b/boot/grub/umount.sh index cf8035b..0948aba 100755 --- a/boot/grub/umount.sh +++ b/boot/grub/umount.sh @@ -29,8 +29,8 @@ CL3='\033[0m' NC='\033[1;37m' set -e #exit if error -#sleep 3 sync +sleep 1 echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3} sudo umount $1 echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3} diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index d97e2d6..25a3b08 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -23,6 +23,10 @@ ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; +[global temporize] +[global bitemporize] +[global tritemporize] + [BITS 64] temporize: diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc index 1037c10..c2bce9a 100644 --- a/boot/loader/io/terminal.inc +++ b/boot/loader/io/terminal.inc @@ -22,7 +22,7 @@ ; You should have received a copy of the GNU General Public License ; ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; - +[global testf] ;;VIDEO %define TRAM 0xB8000 ; [T]ext[RAM] @@ -41,6 +41,17 @@ VGA_X dq 0 [BITS 64] +testf: + push rsi + push rbx + mov esi, teststr + mov bl, 0xF + call write + pop rsi + pop rbx + ret +teststr: db "Salut",0 + ;-----------------------------------------------------------------------; ; x64/LM Clear Text Screen Function ; diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index ed1b828..33236e0 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -62,16 +62,16 @@ MB_start: ; Prints 'ERR:XX' where 'XX' is the str in AX ; ; ---------------------------------------------------------------------------- ; Error: - mov word [CODE], ax + mov word [.code], ax push esi mov bl, 0x0c - mov esi, ERGO + mov esi, .ergo call write32 pop esi jmp Die -ERGO : db "A", 219, 219, " Error " -CODE : db "00" - db 0x0 +.ergo : db 219, 219, 219, " Error " +.code : db "00" + db 0x0 ; ---------------------------------------------------------------------------- ; ; Kills the mind of your computer to get it prostrated ; ; ---------------------------------------------------------------------------- ; @@ -101,11 +101,11 @@ lbegin: call clear ; Clear the screen ;; BEGIN OF CHECKLIST - call MB_check ; Check Multiboot State + call MB_check ; Check Multiboot State, ERR 01 - call Check_cpuid ; Check if cpuid supported - call Is64Bits ; Check if long mode available - call CheckA20 ; Check if A20 is correctly enable + call Check_cpuid ; Check if cpuid supported, ERR 02 + call Is64Bits ; Check if long mode available, ERR 03 + call CheckA20 ; Check if A20 is correctly enable, ERR 04 ;; BEGIN OF WORK call Setup_paging ; Enable paging @@ -126,6 +126,7 @@ lbegin: x64_K db "Now in x64 long mode", 0x0A, 0x0D, 0x0 GoKernel db "Launching Kernel...", 0 +nokernel db 219, 219, 219, " Error 05 : Kernel returns",0 _loader64: ;; Some cleanup @@ -152,7 +153,12 @@ _loader64: call tritemporize ; Let time to see extern StartKern - ;jmp StartKern + call StartKern ;; We must never reach this point ------------------------------------------- ;; + call tritemporize ; Let time to see + call clear + mov bl, 0x0c + mov esi, nokernel ; Error 05 + call write jmp Die diff --git a/kaleid/crtlib/sprintf.c b/kaleid/crtlib/sprintf.c index 5613434..8174ddd 100644 --- a/kaleid/crtlib/sprintf.c +++ b/kaleid/crtlib/sprintf.c @@ -230,6 +230,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) // Unknown/unsupported modifier :| *str++ = mod; + ret++; break; } diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index 507a7ce..cb5a160 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -61,6 +61,7 @@ typedef enum KernelState_t KernelState_t; // Get Process_t structure of current CPU #define GetCurCPU() (cpuTable[_GetCurCPU()]) +#define PANICSTR_SIZE 1024 //------------------------------------------// @@ -73,7 +74,7 @@ struct Processor_t int index; // Panic string - char panicStr[1024]; + char panicStr[PANICSTR_SIZE]; // Number of ticks since boot time ulong ticks; diff --git a/kaleid/include/kernel/term.h b/kaleid/include/kernel/term.h index 83d2bb2..29477ee 100644 --- a/kaleid/include/kernel/term.h +++ b/kaleid/include/kernel/term.h @@ -96,6 +96,9 @@ extern Terminal_t *stdOut; #define GetStdOut() (stdOut) #define SetStdOut(x) (stdOut = (x)) +// Debug purposes +volatile ushort *vga; + //------------------------------------------// #ifndef _NO_DEBUG diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 5dbbdcd..cfa2991 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -25,11 +25,17 @@ #include #include + +extern void testf(void); + // // Entry point of the Kaleid kernel // -noreturn void StartKern(void* mbt, unsigned int mb_magic) +noreturn void StartKern(void *mbInfo, int mbMagic) { + (void)mbInfo; + (void)mbMagic; + // We're not ready to deal with interrupts DisableIRQs(); diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 273105a..5fcdd2c 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -27,5 +27,7 @@ int cpuCount = 1; Processor_t cpuTable[NCPUS] = {0}; -Terminal_t *stdOut, *stdDbg; +Terminal_t *stdOut = 0, *stdDbg = 0; + +volatile ushort *vga = (volatile ushort *)0xB8000; diff --git a/kaleid/kernel/io/term.c b/kaleid/kernel/io/term.c index 1d8adcc..fa5da06 100644 --- a/kaleid/kernel/io/term.c +++ b/kaleid/kernel/io/term.c @@ -32,12 +32,10 @@ extern Terminal_t VGA_Terminal; // void InitTerms(void) { - KalAssert(!GetStdOut() && !GetStdDbg()); + //KalAssert(!GetStdOut() && !GetStdDbg()); VGA_Init(); - // vgaTerm.initDone = INITOK; - SetStdDbg(&VGA_Terminal); SetStdOut(&VGA_Terminal); diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index 54bc63d..9a75cdb 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -37,12 +37,12 @@ #define VGA_ComputeEntry(ch, cl) (((ushort)(ch)) | (ushort)(cl) << 8) // -// Fill terminal with '\0' +// Clear terminal // error_t VGA_ClearTermUnlocked(Terminal_t *term) { const uchar color = VGA_ComputeColorCode(term->fgColor, term->bgColor); - const ushort filler = VGA_ComputeEntry('\0', color); + const ushort filler = VGA_ComputeEntry(' ', color); const size_t bufsize = term->width * term->height; // Fill the buffer @@ -70,15 +70,15 @@ error_t VGA_PutOnTermUnlocked(Terminal_t *term, char ch) // Line feed first takes us to the very end of the line // Later in this function we actually do the line feed else if (ch == '\n') { - term->currentY = term->width - 1; + term->currentX = term->width - 1; } // Tabulations account for "term->tabSize" spaces else if (ch == '\t') { - prevY = term->currentY; + prevY = term->currentX; for (i = 0; i < term->tabSize; i++) { // Make sure tabulations can't spread over two lines - if (term->currentY == prevY) { + if (term->currentX == prevY) { VGA_PutOnTermUnlocked(term, ' '); } } @@ -86,7 +86,7 @@ error_t VGA_PutOnTermUnlocked(Terminal_t *term, char ch) else { ushort *buffer = (ushort *)term->data; - const size_t offset = VGA_ComputeOffset(term, term->currentY, term->currentY); + const size_t offset = VGA_ComputeOffset(term, term->currentX, term->currentY); buffer[offset] = VGA_ComputeEntry(ch, VGA_ComputeColorCode(term->fgColor, term->bgColor)); } diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index 3127321..c799d19 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -60,16 +60,16 @@ noreturn void StartPanic(const char *fmt, ...) fmt = "(no message given)"; } - if (GetPanicStr()) { - GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\ndouble panic!"); + if (*GetPanicStr()) { + GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\nDouble panic!"); HaltCPU(); } va_start(ap, fmt); - vsnprintf(GetPanicStr(), sizeof GetPanicStr(), fmt, ap); + vsnprintf(GetPanicStr(), PANICSTR_SIZE, fmt, ap); va_end(ap); - GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\npanic!\n\n"); + GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\nPanic!\n\n"); GetStdOut()->PrintOnTermUnlocked(GetStdOut(), GetPanicStr()); HaltCPU(); From 8660d529123ed8d872c6ac2be60b34130a2a4845 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 15:29:15 +0100 Subject: [PATCH 12/22] Assert --- kaleid/kernel/io/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kaleid/kernel/io/term.c b/kaleid/kernel/io/term.c index fa5da06..5392b23 100644 --- a/kaleid/kernel/io/term.c +++ b/kaleid/kernel/io/term.c @@ -32,7 +32,7 @@ extern Terminal_t VGA_Terminal; // void InitTerms(void) { - //KalAssert(!GetStdOut() && !GetStdDbg()); + KalAssert(!GetStdOut() && !GetStdDbg()); VGA_Init(); From b9322e60e0b895e9f487ad7169f709cc4e84316c Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 17:13:09 +0100 Subject: [PATCH 13/22] stuff --- .stylehlp | 26 ++++++++++++++++++++++++++ boot/loader/loader.asm | 8 +++++++- kaleid/kernel/init/init.c | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.stylehlp b/.stylehlp index 588d391..66bda54 100644 --- a/.stylehlp +++ b/.stylehlp @@ -24,3 +24,29 @@ //------------------------------------------// + +;=----------------------------------------------------------------------------=; +; GNU GPL OS/K ; +; ; +; Desc: ; +; ; +; ; +; 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 ; +; (at your option) 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 . ; +;=----------------------------------------------------------------------------=; + + diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 33236e0..5cf97c7 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -95,9 +95,15 @@ Die: _loader: jmp lbegin -LOGO: db 219, 219, 219, " OS/K", 0 +LOGO db 219, 219, 219, " OS/K", 0 +mbInfo dq 0 +mbMagic dq 0 lbegin: + + pop ebx ; 1st argument multiboot info pointer + pop eax ; 2nd argument is magic number + call clear ; Clear the screen ;; BEGIN OF CHECKLIST diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index cfa2991..1d56806 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -43,6 +43,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) InitTerms(); // We're out - StartPanic("Goodbye World :("); + StartPanic("We had\n *mbInfo : %x\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); } From 4a9b54cc3ebea56aa3730c571225153c1bcaebf4 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 17:25:25 +0100 Subject: [PATCH 14/22] stuff --- boot/loader/loader.asm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 5cf97c7..fffa136 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -102,7 +102,9 @@ mbMagic dq 0 lbegin: pop ebx ; 1st argument multiboot info pointer + mov [mbInfo], ebx pop eax ; 2nd argument is magic number + mov [mbMagic], eax call clear ; Clear the screen @@ -159,6 +161,9 @@ _loader64: call tritemporize ; Let time to see extern StartKern + + push qword 12 + push qword 12 call StartKern ;; We must never reach this point ------------------------------------------- ;; From 8fca2de33f62599fd87baeb813068f999f526082 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 17:31:25 +0100 Subject: [PATCH 15/22] Revert "stuff" This reverts commit be94ec4d2c1d5e3de08e50a0733bd53c69d1acd8, reversing changes made to 2d9e02db0e580eaf9ccb6a6d2176ee16107a4b0a. --- boot/loader/loader.asm | 1 + kaleid/kernel/init/init.c | 2 -- kaleid/kernel/io/term.c | 2 +- kaleid/kernel/ke/panic.c | 5 ----- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 7baa2c6..fffa136 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -161,6 +161,7 @@ _loader64: call tritemporize ; Let time to see extern StartKern + push qword 12 push qword 12 call StartKern diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index e454774..1d56806 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -42,8 +42,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - *vga = ('A') | (0x0F << 8); - // We're out StartPanic("We had\n *mbInfo : %x\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); } diff --git a/kaleid/kernel/io/term.c b/kaleid/kernel/io/term.c index fa5da06..5392b23 100644 --- a/kaleid/kernel/io/term.c +++ b/kaleid/kernel/io/term.c @@ -32,7 +32,7 @@ extern Terminal_t VGA_Terminal; // void InitTerms(void) { - //KalAssert(!GetStdOut() && !GetStdDbg()); + KalAssert(!GetStdOut() && !GetStdDbg()); VGA_Init(); diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index d946f7e..c799d19 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -50,13 +50,10 @@ noreturn void StartPanic(const char *fmt, ...) va_list ap; DisableIRQs(); - *vga = ('B') | (0x0F << 8); if (GetCurProc()) _SetCurProc(NULL); if (GetStdOut() == NULL) CrashSystem(); - HaltCPU(); - GetStdOut()->ClearTermUnlocked(GetStdOut()); if (fmt == NULL) { @@ -75,7 +72,6 @@ noreturn void StartPanic(const char *fmt, ...) GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\nPanic!\n\n"); GetStdOut()->PrintOnTermUnlocked(GetStdOut(), GetPanicStr()); - tritemporize(); HaltCPU(); } @@ -85,7 +81,6 @@ noreturn void StartPanic(const char *fmt, ...) noreturn void CrashSystem(void) { DisableIRQs(); - tritemporize(); HaltCPU(); } From fea5386d6de4f7c76208aee9f54e4f547cdd6a8a Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Tue, 12 Mar 2019 17:41:14 +0100 Subject: [PATCH 16/22] sprintf stuff --- kaleid/crtlib/sprintf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kaleid/crtlib/sprintf.c b/kaleid/crtlib/sprintf.c index 8174ddd..be93623 100644 --- a/kaleid/crtlib/sprintf.c +++ b/kaleid/crtlib/sprintf.c @@ -71,7 +71,7 @@ size_t snprintf(char *str, size_t n, const char *fmt, ...) } // Size of the buffer is for convertions -#define CONVBUF 4096 +#define CONVBUF 64 size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) { @@ -82,10 +82,13 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) char mod; char convbuf[CONVBUF] = { 0 }; - char c; - int d; - uint u; - char *s; + char c, *s; + int d; + uint u; + + assert(str && fmt); + + if (n == 0) return 0; // For aesthetic reasons... n--; @@ -235,6 +238,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) } // We fallthrough here from the "while (1)" + lflag = hflag = hhflag = altflag = 0; fmt++; } From f836157c902e5b4d2289caa8f271c6549b03d2ff Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 18:24:27 +0100 Subject: [PATCH 17/22] stuff --- boot/loader/loader.asm | 4 ++-- kaleid/kernel/init/init.c | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index fffa136..1a12b81 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -162,8 +162,8 @@ _loader64: extern StartKern - push qword 12 - push qword 12 + mov rsi, [mbInfo] + mov rdi, [mbMagic] call StartKern ;; We must never reach this point ------------------------------------------- ;; diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 1d56806..39ad1ed 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -33,9 +33,6 @@ extern void testf(void); // noreturn void StartKern(void *mbInfo, int mbMagic) { - (void)mbInfo; - (void)mbMagic; - // We're not ready to deal with interrupts DisableIRQs(); @@ -43,6 +40,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) InitTerms(); // We're out - StartPanic("We had\n *mbInfo : %x\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); + StartPanic("We had\n *mbInfo : %p\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); } From 32c7c99bc2bdccc29b152abf0144a85687b22774 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 22:11:00 +0100 Subject: [PATCH 18/22] Just learned SysV ABI calling conventions and clean-up stuff --- boot/loader/cpu/cpu.inc | 7 ++++--- boot/loader/cpu/cpu32.inc | 1 + boot/loader/io/terminal.inc | 8 +++----- boot/loader/loader.asm | 21 +++++++-------------- boot/loader/mem/management.inc | 2 +- boot/loader/mem/structures.inc | 4 ++-- kaleid/kernel/init/init.c | 2 +- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index 25a3b08..4700598 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -23,11 +23,12 @@ ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; -[global temporize] -[global bitemporize] -[global tritemporize] +global temporize +global bitemporize +global tritemporize [BITS 64] +[section .text] temporize: push rcx diff --git a/boot/loader/cpu/cpu32.inc b/boot/loader/cpu/cpu32.inc index c67fb08..9eaa036 100644 --- a/boot/loader/cpu/cpu32.inc +++ b/boot/loader/cpu/cpu32.inc @@ -24,6 +24,7 @@ ;=----------------------------------------------------------------------------=; [BITS 32] +[section .text] ; ---------------------------------------------------------------------------- ; ; Checks if the CPU is compatible with 64-bits operating systems ; diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc index c2bce9a..50b4175 100644 --- a/boot/loader/io/terminal.inc +++ b/boot/loader/io/terminal.inc @@ -22,7 +22,9 @@ ; You should have received a copy of the GNU General Public License ; ; along with OS/K. If not, see . ; ;=----------------------------------------------------------------------------=; -[global testf] + +[BITS 64] +[section .text] ;;VIDEO %define TRAM 0xB8000 ; [T]ext[RAM] @@ -30,16 +32,12 @@ %define VGA_HEIGHT 80 ;; GLOBAL DATA - NextTRAM dq 0xB8000 ; Last position of cursor NextTRAM32 dq 0xB8000 ; Last position of cursor VGA_X32 dq 0 VGA_HEIGHT64 dq VGA_HEIGHT VGA_X dq 0 -;; TEXT - -[BITS 64] testf: push rsi diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 1a12b81..785e4c2 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -31,9 +31,10 @@ %include "boot/loader/cpu/cpu.inc" %include "boot/loader/mem/structures.inc" -[BITS 32] -[global MB_start] +global MB_start +extern StartKern +[BITS 32] [section .multiboot] ;; MAGNIFICENT MULTIBOOT HEADER FOR GRUB ------------------------------------ ;; @@ -50,8 +51,8 @@ MB_start: mov esp, KERNEL_STACK ; Setup the stack push 0 ; Reset EFLAGS popf - push eax ; 2nd argument is magic number - push ebx ; 1st argument multiboot info pointer + mov [mbInfo], ebx + mov [mbMagic], eax mov ecx, eax ; For debug call _loader add esp, 8 ; Cleanup arguments "A la MIPS" @@ -100,12 +101,6 @@ mbInfo dq 0 mbMagic dq 0 lbegin: - - pop ebx ; 1st argument multiboot info pointer - mov [mbInfo], ebx - pop eax ; 2nd argument is magic number - mov [mbMagic], eax - call clear ; Clear the screen ;; BEGIN OF CHECKLIST @@ -160,10 +155,8 @@ _loader64: ;; Launch the kernel ! call tritemporize ; Let time to see - extern StartKern - - mov rsi, [mbInfo] - mov rdi, [mbMagic] + mov rdi, [mbInfo] + mov rsi, [mbMagic] call StartKern ;; We must never reach this point ------------------------------------------- ;; diff --git a/boot/loader/mem/management.inc b/boot/loader/mem/management.inc index 876d2fe..b44bf4f 100644 --- a/boot/loader/mem/management.inc +++ b/boot/loader/mem/management.inc @@ -24,7 +24,7 @@ ;=----------------------------------------------------------------------------=; [BITS 32] - +[section .text] ; ---------------------------------------------------------------------------- ; ; Constructor for the page tables in protected mode ; ; ---------------------------------------------------------------------------- ; diff --git a/boot/loader/mem/structures.inc b/boot/loader/mem/structures.inc index 4b92e56..0c7bd8b 100644 --- a/boot/loader/mem/structures.inc +++ b/boot/loader/mem/structures.inc @@ -24,7 +24,7 @@ ;=----------------------------------------------------------------------------=; [BITS 32] -section .rodata +[section .rodata] ;; GDT WITH DOC ALIGN 4096 GDT64: @@ -44,7 +44,7 @@ GDT64: dq GDT64 ;; EMPTY PAGE TABLES (identity of the first 1GiB) -section .bss +[section .bss] ALIGN 4096 PML4_table: resb 4096 diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 39ad1ed..6430af3 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -40,6 +40,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic) InitTerms(); // We're out - StartPanic("We had\n *mbInfo : %p\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); + StartPanic("We had\n *mbInfo : %p\n mbMagic : %p\n\nGoodbye World :(", mbInfo, mbMagic); } From 17f714719b0a3eeb575755f7b41a0b3f2bd5fb22 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 23:25:30 +0100 Subject: [PATCH 19/22] multiboooooooot --- boot/loader/multiboot/header.inc | 2 +- kaleid/include/multiboot/multiboot.h | 472 ++++++++++----------------- kaleid/kernel/init/init.c | 10 +- 3 files changed, 178 insertions(+), 306 deletions(-) diff --git a/boot/loader/multiboot/header.inc b/boot/loader/multiboot/header.inc index 337d168..06f89a4 100644 --- a/boot/loader/multiboot/header.inc +++ b/boot/loader/multiboot/header.inc @@ -29,6 +29,6 @@ MB_ALIGN equ 1 << 0 ; Ask to align loaded modules on page bounda MB_MEMINFO equ 1 << 1 ; Ask to provide memory map MB_HEADER_MAGIC equ 0x1badb002 MB_GRUB_MAGIC equ 0x2badb002 -MB_HEADER_FLAGS equ 0x0 ; MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO +MB_HEADER_FLAGS equ MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO CHECKSUM equ -(MB_HEADER_MAGIC + MB_HEADER_FLAGS) KERNEL_STACK equ 0x00200000 ; Stack starts at the 2mb address & grows down diff --git a/kaleid/include/multiboot/multiboot.h b/kaleid/include/multiboot/multiboot.h index 2c93a2a..2a5d469 100644 --- a/kaleid/include/multiboot/multiboot.h +++ b/kaleid/include/multiboot/multiboot.h @@ -1,91 +1,102 @@ -/* multiboot2.h - Multiboot 2 header file. */ -/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY - * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR - * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: multiboot.h - Multiboot header file. // +// // +// // +// Copyright © 1999,2003,2007-2010 Free Software Foundation, Inc. // +// // +// Note: In this header, "the software" refers to the multiboot.h file. // +// // +// Permission is hereby granted, free of charge, to any person // +// obtaining a copy of this software and associated documentation // +// files (the "Software"), to deal in the Software without restriction, // +// including without limitation the rights to use, copy, modify, merge, // +// publish, distribute, sublicense, and/or sell copies of the Software, // +// and to permit persons to whom the Software is furnished to do so, // +// subject to the following conditions: // +// // +// The above copyright notice and this permission notice shall be included // +// in all copies or substantial portions of the Software. // +// // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // +// IN NO EVENT SHALL ANY DEVELOPER OR DISTRIBUTOR BE LIABLE FOR // +// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // +// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.. // +//----------------------------------------------------------------------------// #ifndef MULTIBOOT_HEADER #define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT_SEARCH 32768 -#define MULTIBOOT_HEADER_ALIGN 8 +#define MULTIBOOT_SEARCH 8192 +#define MULTIBOOT_HEADER_ALIGN 4 /* The magic field should contain this. */ -#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* This should be in %eax. */ -#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* Alignment of multiboot modules. */ #define MULTIBOOT_MOD_ALIGN 0x00001000 /* Alignment of the multiboot info structure. */ -#define MULTIBOOT_INFO_ALIGN 0x00000008 +#define MULTIBOOT_INFO_ALIGN 0x00000004 /* Flags set in the 'flags' member of the multiboot header. */ -#define MULTIBOOT_TAG_ALIGN 8 -#define MULTIBOOT_TAG_TYPE_END 0 -#define MULTIBOOT_TAG_TYPE_CMDLINE 1 -#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 -#define MULTIBOOT_TAG_TYPE_MODULE 3 -#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 -#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 -#define MULTIBOOT_TAG_TYPE_MMAP 6 -#define MULTIBOOT_TAG_TYPE_VBE 7 -#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 -#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 -#define MULTIBOOT_TAG_TYPE_APM 10 -#define MULTIBOOT_TAG_TYPE_EFI32 11 -#define MULTIBOOT_TAG_TYPE_EFI64 12 -#define MULTIBOOT_TAG_TYPE_SMBIOS 13 -#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 -#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 -#define MULTIBOOT_TAG_TYPE_NETWORK 16 -#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 -#define MULTIBOOT_TAG_TYPE_EFI_BS 18 -#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 -#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 -#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 +/* Align all boot modules on i386 page (4KB) boundaries. */ +#define MULTIBOOT_PAGE_ALIGN 0x00000001 -#define MULTIBOOT_HEADER_TAG_END 0 -#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 -#define MULTIBOOT_HEADER_TAG_ADDRESS 2 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 -#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 -#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 -#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 -#define MULTIBOOT_HEADER_TAG_EFI_BS 7 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 -#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 +/* Must pass memory information to OS. */ +#define MULTIBOOT_MEMORY_INFO 0x00000002 -#define MULTIBOOT_ARCHITECTURE_I386 0 -#define MULTIBOOT_ARCHITECTURE_MIPS32 4 -#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 +/* Must pass video information to OS. */ +#define MULTIBOOT_VIDEO_MODE 0x00000004 -#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 -#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 -#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 +/* This flag indicates the use of the address fields in the header. */ +#define MULTIBOOT_AOUT_KLUDGE 0x00010000 -#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 -#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 +/* Flags to be set in the 'flags' member of the multiboot info structure. */ + +/* is there basic lower/upper memory information? */ +#define MULTIBOOT_INFO_MEMORY 0x00000001 +/* is there a boot device set? */ +#define MULTIBOOT_INFO_BOOTDEV 0x00000002 +/* is the command-line defined? */ +#define MULTIBOOT_INFO_CMDLINE 0x00000004 +/* are there modules to do something with? */ +#define MULTIBOOT_INFO_MODS 0x00000008 + +/* These next two are mutually exclusive */ + +/* is there a symbol table loaded? */ +#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 +/* is there an ELF section header table? */ +#define MULTIBOOT_INFO_ELF_SHDR 0X00000020 + +/* is there a full memory map? */ +#define MULTIBOOT_INFO_MEM_MAP 0x00000040 + +/* Is there drive info? */ +#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 + +/* Is there a config table? */ +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 + +/* Is there a boot loader name? */ +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 + +/* Is there a APM table? */ +#define MULTIBOOT_INFO_APM_TABLE 0x00000400 + +/* Is there video information? */ +#define MULTIBOOT_INFO_VBE_INFO 0x00000800 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 #ifndef ASM_FILE @@ -99,184 +110,96 @@ struct multiboot_header /* Must be MULTIBOOT_MAGIC - see above. */ multiboot_uint32_t magic; - /* ISA */ - multiboot_uint32_t architecture; - - /* Total header length. */ - multiboot_uint32_t header_length; + /* Feature flags. */ + multiboot_uint32_t flags; /* The above fields plus this one must equal 0 mod 2^32. */ multiboot_uint32_t checksum; -}; -struct multiboot_header_tag -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; -}; - -struct multiboot_header_tag_information_request -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t requests[0]; -}; - -struct multiboot_header_tag_address -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; + /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ multiboot_uint32_t header_addr; multiboot_uint32_t load_addr; multiboot_uint32_t load_end_addr; multiboot_uint32_t bss_end_addr; -}; - -struct multiboot_header_tag_entry_address -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; multiboot_uint32_t entry_addr; -}; -struct multiboot_header_tag_console_flags -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t console_flags; -}; - -struct multiboot_header_tag_framebuffer -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; + /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ + multiboot_uint32_t mode_type; multiboot_uint32_t width; multiboot_uint32_t height; multiboot_uint32_t depth; }; -struct multiboot_header_tag_module_align +/* The symbol table for a.out. */ +struct multiboot_aout_symbol_table { - multiboot_uint16_t type; - multiboot_uint16_t flags; + multiboot_uint32_t tabsize; + multiboot_uint32_t strsize; + multiboot_uint32_t addr; + multiboot_uint32_t reserved; +}; +typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; + +/* The section header table for ELF. */ +struct multiboot_elf_section_header_table +{ + multiboot_uint32_t num; multiboot_uint32_t size; + multiboot_uint32_t addr; + multiboot_uint32_t shndx; }; +typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; -struct multiboot_header_tag_relocatable +struct multiboot_info { - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t min_addr; - multiboot_uint32_t max_addr; - multiboot_uint32_t align; - multiboot_uint32_t preference; -}; + /* Multiboot info version number */ + multiboot_uint32_t flags; -struct multiboot_color -{ - multiboot_uint8_t red; - multiboot_uint8_t green; - multiboot_uint8_t blue; -}; - -struct multiboot_mmap_entry -{ - multiboot_uint64_t addr; - multiboot_uint64_t len; -#define MULTIBOOT_MEMORY_AVAILABLE 1 -#define MULTIBOOT_MEMORY_RESERVED 2 -#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 -#define MULTIBOOT_MEMORY_NVS 4 -#define MULTIBOOT_MEMORY_BADRAM 5 - multiboot_uint32_t type; - multiboot_uint32_t zero; -}; -typedef struct multiboot_mmap_entry multiboot_memory_map_t; - -struct multiboot_tag -{ - multiboot_uint32_t type; - multiboot_uint32_t size; -}; - -struct multiboot_tag_string -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - char string[0]; -}; - -struct multiboot_tag_module -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t mod_start; - multiboot_uint32_t mod_end; - char cmdline[0]; -}; - -struct multiboot_tag_basic_meminfo -{ - multiboot_uint32_t type; - multiboot_uint32_t size; + /* Available memory from BIOS */ multiboot_uint32_t mem_lower; multiboot_uint32_t mem_upper; -}; -struct multiboot_tag_bootdev -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t biosdev; - multiboot_uint32_t slice; - multiboot_uint32_t part; -}; + /* "root" partition */ + multiboot_uint32_t boot_device; -struct multiboot_tag_mmap -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t entry_size; - multiboot_uint32_t entry_version; - struct multiboot_mmap_entry entries[0]; -}; + /* Kernel command line */ + multiboot_uint32_t cmdline; -struct multiboot_vbe_info_block -{ - multiboot_uint8_t external_specification[512]; -}; + /* Boot-Module list */ + multiboot_uint32_t mods_count; + multiboot_uint32_t mods_addr; -struct multiboot_vbe_mode_info_block -{ - multiboot_uint8_t external_specification[256]; -}; + union + { + multiboot_aout_symbol_table_t aout_sym; + multiboot_elf_section_header_table_t elf_sec; + } u; -struct multiboot_tag_vbe -{ - multiboot_uint32_t type; - multiboot_uint32_t size; + /* Memory Mapping buffer */ + multiboot_uint32_t mmap_length; + multiboot_uint32_t mmap_addr; + /* Drive Info buffer */ + multiboot_uint32_t drives_length; + multiboot_uint32_t drives_addr; + + /* ROM configuration table */ + multiboot_uint32_t config_table; + + /* Boot Loader Name */ + multiboot_uint32_t boot_loader_name; + + /* APM table */ + multiboot_uint32_t apm_table; + + /* Video */ + multiboot_uint32_t vbe_control_info; + multiboot_uint32_t vbe_mode_info; multiboot_uint16_t vbe_mode; multiboot_uint16_t vbe_interface_seg; multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_len; - struct multiboot_vbe_info_block vbe_control_info; - struct multiboot_vbe_mode_info_block vbe_mode_info; -}; - -struct multiboot_tag_framebuffer_common -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint64_t framebuffer_addr; multiboot_uint32_t framebuffer_pitch; multiboot_uint32_t framebuffer_width; @@ -286,19 +209,12 @@ struct multiboot_tag_framebuffer_common #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 multiboot_uint8_t framebuffer_type; - multiboot_uint16_t reserved; -}; - -struct multiboot_tag_framebuffer -{ - struct multiboot_tag_framebuffer_common common; - union { struct { + multiboot_uint32_t framebuffer_palette_addr; multiboot_uint16_t framebuffer_palette_num_colors; - struct multiboot_color framebuffer_palette[0]; }; struct { @@ -311,21 +227,46 @@ struct multiboot_tag_framebuffer }; }; }; +typedef struct multiboot_info multiboot_info_t; -struct multiboot_tag_elf_sections +struct multiboot_color { - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t num; - multiboot_uint32_t entsize; - multiboot_uint32_t shndx; - char sections[0]; + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; }; -struct multiboot_tag_apm +struct multiboot_mmap_entry { - multiboot_uint32_t type; multiboot_uint32_t size; + multiboot_uint64_t addr; + multiboot_uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 +#define MULTIBOOT_MEMORY_BADRAM 5 + multiboot_uint32_t type; +} __attribute__((packed)); +typedef struct multiboot_mmap_entry multiboot_memory_map_t; + +struct multiboot_mod_list +{ + /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ + multiboot_uint32_t mod_start; + multiboot_uint32_t mod_end; + + /* Module command line */ + multiboot_uint32_t cmdline; + + /* padding to take it to 16 bytes (must be zero) */ + multiboot_uint32_t pad; +}; +typedef struct multiboot_mod_list multiboot_module_t; + +/* APM BIOS info. */ +struct multiboot_apm_info +{ multiboot_uint16_t version; multiboot_uint16_t cseg; multiboot_uint32_t offset; @@ -337,81 +278,6 @@ struct multiboot_tag_apm multiboot_uint16_t dseg_len; }; -struct multiboot_tag_efi32 -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t pointer; -}; - -struct multiboot_tag_efi64 -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint64_t pointer; -}; - -struct multiboot_tag_smbios -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t major; - multiboot_uint8_t minor; - multiboot_uint8_t reserved[6]; - multiboot_uint8_t tables[0]; -}; - -struct multiboot_tag_old_acpi -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t rsdp[0]; -}; - -struct multiboot_tag_new_acpi -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t rsdp[0]; -}; - -struct multiboot_tag_network -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t dhcpack[0]; -}; - -struct multiboot_tag_efi_mmap -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t descr_size; - multiboot_uint32_t descr_vers; - multiboot_uint8_t efi_mmap[0]; -}; - -struct multiboot_tag_efi32_ih -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t pointer; -}; - -struct multiboot_tag_efi64_ih -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint64_t pointer; -}; - -struct multiboot_tag_load_base_addr -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t load_base_addr; -}; - #endif /* ! ASM_FILE */ #endif /* ! MULTIBOOT_HEADER */ diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 6430af3..fe17fd9 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -31,7 +31,7 @@ extern void testf(void); // // Entry point of the Kaleid kernel // -noreturn void StartKern(void *mbInfo, int mbMagic) +noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) { // We're not ready to deal with interrupts DisableIRQs(); @@ -39,7 +39,13 @@ noreturn void StartKern(void *mbInfo, int mbMagic) // Kernel terminals InitTerms(); + char *grubver = mbInfo->boot_loader_name; + + // We're out - StartPanic("We had\n *mbInfo : %p\n mbMagic : %p\n\nGoodbye World :(", mbInfo, mbMagic); + StartPanic("We get\n *mbInfo : %x\n mbMagic : %x\n\n\ + We were loaded by : %s \n\n\ + \nGoodbye World :(", mbInfo, mbMagic, grubver); } + From afdd3508c6ba602e0bd0685beb3c0ec65ac81660 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Mar 2019 23:36:47 +0100 Subject: [PATCH 20/22] stuff --- kaleid/kernel/init/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index fe17fd9..c41a1f2 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -39,7 +39,7 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - char *grubver = mbInfo->boot_loader_name; + multiboot_uint32_t *grubver = mbInfo->boot_loader_name; // We're out From 9ab5bbc58c7fb52ab98c2e65d4be323be983b027 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 13 Mar 2019 09:19:43 +0100 Subject: [PATCH 21/22] multiboot&memory stuff --- kaleid/include/multiboot/multiboot.h | 2 +- kaleid/kernel/init/init.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/kaleid/include/multiboot/multiboot.h b/kaleid/include/multiboot/multiboot.h index 2a5d469..8c7d00f 100644 --- a/kaleid/include/multiboot/multiboot.h +++ b/kaleid/include/multiboot/multiboot.h @@ -6,7 +6,7 @@ // // // Copyright © 1999,2003,2007-2010 Free Software Foundation, Inc. // // // -// Note: In this header, "the software" refers to the multiboot.h file. // +// Note: In this header, "the Software" refers to the multiboot.h file. // // // // Permission is hereby granted, free of charge, to any person // // obtaining a copy of this software and associated documentation // diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index c41a1f2..d2dd85f 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -39,13 +39,19 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) // Kernel terminals InitTerms(); - multiboot_uint32_t *grubver = mbInfo->boot_loader_name; - - // We're out - StartPanic("We get\n *mbInfo : %x\n mbMagic : %x\n\n\ - We were loaded by : %s \n\n\ - \nGoodbye World :(", mbInfo, mbMagic, grubver); + StartPanic( "We were loaded by : %s\n\n\n" + "We get\n" + " *mbInfo : %x\n" + " mbMagic : %x\n" + " mbBootdrv : %x\n" + "\nGoodbye World :(", + + mbInfo->boot_loader_name, + mbInfo, + mbMagic, + mbInfo->boot_device + ); } From ced75b51f2e22fe4548dd18180dcca59e0e5071a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 13 Mar 2019 17:03:52 +0100 Subject: [PATCH 22/22] stuff I don't remember --- boot/loader/cpu/cpu.inc | 13 ---- kaleid/include/multiboot/multiboot.h | 91 +++++++++++++--------------- kaleid/kernel/init/init.c | 10 +-- kaleid/kernel/init/table.c | 2 - 4 files changed, 48 insertions(+), 68 deletions(-) diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index 4700598..f0fbc95 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -60,16 +60,3 @@ tritemporize: loop .looping pop rcx ret - - -; ---------------------------------------------------------------------------- ; -; Returns the CPU Vendor String.pointer in eax ; -; ---------------------------------------------------------------------------- ; -cpu_vendor: - - ;; Calling the competent authorities - mov eax, 0 - cpuid - - ret -.string db " " diff --git a/kaleid/include/multiboot/multiboot.h b/kaleid/include/multiboot/multiboot.h index 8c7d00f..04f6322 100644 --- a/kaleid/include/multiboot/multiboot.h +++ b/kaleid/include/multiboot/multiboot.h @@ -5,105 +5,98 @@ // // // // // Copyright © 1999,2003,2007-2010 Free Software Foundation, Inc. // +// Copyright © 2018-2019 The OS/K Team // // // -// Note: In this header, "the Software" refers to the multiboot.h file. // +// This file is part of OS/K. // // // -// Permission is hereby granted, free of charge, to any person // -// obtaining a copy of this software and associated documentation // -// files (the "Software"), to deal in the Software without restriction, // -// including without limitation the rights to use, copy, modify, merge, // -// publish, distribute, sublicense, and/or sell copies of the Software, // -// and to permit persons to whom the Software is furnished to do so, // -// subject to the following conditions: // +// 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. // // // -// The above copyright notice and this permission notice shall be included // -// in all copies or substantial portions of the Software. // +// 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. // // // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // -// IN NO EVENT SHALL ANY DEVELOPER OR DISTRIBUTOR BE LIABLE FOR // -// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // -// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.. // +// You should have received a copy of the GNU General Public License // +// along with OS/K. If not, see . // //----------------------------------------------------------------------------// #ifndef MULTIBOOT_HEADER #define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT_SEARCH 8192 -#define MULTIBOOT_HEADER_ALIGN 4 +#define MULTIBOOT_SEARCH 8192 +#define MULTIBOOT_HEADER_ALIGN 4 /* The magic field should contain this. */ -#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* This should be in %eax. */ -#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* Alignment of multiboot modules. */ -#define MULTIBOOT_MOD_ALIGN 0x00001000 +#define MULTIBOOT_MOD_ALIGN 0x00001000 /* Alignment of the multiboot info structure. */ -#define MULTIBOOT_INFO_ALIGN 0x00000004 +#define MULTIBOOT_INFO_ALIGN 0x00000004 /* Flags set in the 'flags' member of the multiboot header. */ /* Align all boot modules on i386 page (4KB) boundaries. */ -#define MULTIBOOT_PAGE_ALIGN 0x00000001 +#define MULTIBOOT_PAGE_ALIGN 0x00000001 /* Must pass memory information to OS. */ -#define MULTIBOOT_MEMORY_INFO 0x00000002 +#define MULTIBOOT_MEMORY_INFO 0x00000002 /* Must pass video information to OS. */ -#define MULTIBOOT_VIDEO_MODE 0x00000004 +#define MULTIBOOT_VIDEO_MODE 0x00000004 /* This flag indicates the use of the address fields in the header. */ -#define MULTIBOOT_AOUT_KLUDGE 0x00010000 +#define MULTIBOOT_AOUT_KLUDGE 0x00010000 -/* Flags to be set in the 'flags' member of the multiboot info structure. */ -/* is there basic lower/upper memory information? */ -#define MULTIBOOT_INFO_MEMORY 0x00000001 +#define MULTIBOOT_INFO_MEMORY 0x00000001 /* is there a boot device set? */ -#define MULTIBOOT_INFO_BOOTDEV 0x00000002 +#define MULTIBOOT_INFO_BOOTDEV 0x00000002 /* is the command-line defined? */ -#define MULTIBOOT_INFO_CMDLINE 0x00000004 +#define MULTIBOOT_INFO_CMDLINE 0x00000004 /* are there modules to do something with? */ -#define MULTIBOOT_INFO_MODS 0x00000008 +#define MULTIBOOT_INFO_MODS 0x00000008 /* These next two are mutually exclusive */ /* is there a symbol table loaded? */ -#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 +#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 /* is there an ELF section header table? */ -#define MULTIBOOT_INFO_ELF_SHDR 0X00000020 +#define MULTIBOOT_INFO_ELF_SHDR 0x00000020 /* is there a full memory map? */ -#define MULTIBOOT_INFO_MEM_MAP 0x00000040 +#define MULTIBOOT_INFO_MEM_MAP 0x00000040 /* Is there drive info? */ -#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 +#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 /* Is there a config table? */ -#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 /* Is there a boot loader name? */ -#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 /* Is there a APM table? */ -#define MULTIBOOT_INFO_APM_TABLE 0x00000400 +#define MULTIBOOT_INFO_APM_TABLE 0x00000400 /* Is there video information? */ -#define MULTIBOOT_INFO_VBE_INFO 0x00000800 -#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 +#define MULTIBOOT_INFO_VBE_INFO 0x00000800 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 #ifndef ASM_FILE -typedef unsigned char multiboot_uint8_t; -typedef unsigned short multiboot_uint16_t; -typedef unsigned int multiboot_uint32_t; -typedef unsigned long long multiboot_uint64_t; +typedef unsigned char multiboot_uint8_t; +typedef unsigned short multiboot_uint16_t; +typedef unsigned int multiboot_uint32_t; +typedef unsigned long long multiboot_uint64_t; struct multiboot_header { @@ -207,7 +200,7 @@ struct multiboot_info multiboot_uint8_t framebuffer_bpp; #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 -#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 multiboot_uint8_t framebuffer_type; union { @@ -241,8 +234,8 @@ struct multiboot_mmap_entry multiboot_uint32_t size; multiboot_uint64_t addr; multiboot_uint64_t len; -#define MULTIBOOT_MEMORY_AVAILABLE 1 -#define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 #define MULTIBOOT_MEMORY_NVS 4 #define MULTIBOOT_MEMORY_BADRAM 5 diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index d2dd85f..c6a1853 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -42,16 +42,18 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) // We're out StartPanic( "We were loaded by : %s\n\n\n" "We get\n" - " *mbInfo : %x\n" + " *mbInfo : %p\n" " mbMagic : %x\n" " mbBootdrv : %x\n" + " *mbMmap : %p\n" + " `-length : %d\n" "\nGoodbye World :(", mbInfo->boot_loader_name, mbInfo, mbMagic, - mbInfo->boot_device + mbInfo->boot_device, + mbInfo->mmap_addr, + mbInfo->mmap_length ); } - - diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 5fcdd2c..7a51088 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -29,5 +29,3 @@ Processor_t cpuTable[NCPUS] = {0}; Terminal_t *stdOut = 0, *stdDbg = 0; -volatile ushort *vga = (volatile ushort *)0xB8000; -