From 4c782da79e519745db86ab996178034fcf767527 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 23 Mar 2019 20:34:32 +0100 Subject: [PATCH 1/3] For the terminal stuff --- kaleid/include/kernel/base.h | 9 +++++---- kaleid/kernel/init/init.c | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index 9b9ed11..a053f8f 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -137,14 +137,15 @@ struct BootInfo_t // Informations about the video drive struct { - ushort valid; - uint vbeControl; //vbe_control_info - uint vbeModeInfo; //vbe_mode_info + ushort vbeValid; + ushort fbuValid; + void *vbeControl; //vbe_control_info + void *vbeModeInfo; //vbe_mode_info ushort vbeMode; //vbe_mode ushort vbeInterfaceSeg; //vbe_interface_seg ushort vbeInterfaceOff; //vbe_interface_off ushort vbeInterfaceLen; //vbe_interface_len - void* framebufferAddr; //framebuffer_addr + void *framebufferAddr; //framebuffer_addr uint framebufferPitch; //framebuffer_pitch uint framebufferWidth; //framebuffer_width uint framebufferHeight; //framebuffer_height diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 7941eb6..5a313de 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -74,7 +74,25 @@ void InitBootInfo(multiboot_info_t *mbi) GetBootInfo(memory).mapValid = 1; } - // XXX assign video infos, but unused at this time + // Retrieves video mode informations + if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_VBE_INFO) { + GetBootInfo(video).vbeControl = (void*)(ullong)mbi->vbe_control_info; + GetBootInfo(video).vbeModeInfo = (void*)(ullong)mbi->vbe_mode_info; + GetBootInfo(video).vbeMode = mbi->vbe_mode; + GetBootInfo(video).vbeInterfaceSeg = mbi->vbe_interface_seg; + GetBootInfo(video).vbeInterfaceOff = mbi->vbe_interface_off; + GetBootInfo(video).vbeInterfaceLen = mbi->vbe_interface_len; + GetBootInfo(video).vbeValid = 1; + } + if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) { + GetBootInfo(video).framebufferAddr = (void*)(ullong)mbi->framebuffer_addr; + GetBootInfo(video).framebufferPitch = mbi->framebuffer_pitch; + GetBootInfo(video).framebufferWidth = mbi->framebuffer_width; + GetBootInfo(video).framebufferHeight= mbi->framebuffer_height; + GetBootInfo(video).framebufferBpp = mbi->framebuffer_bpp; + GetBootInfo(video).framebufferType = mbi->framebuffer_type; + GetBootInfo(video).fbuValid = 1; + } // Retrieves the firmware infos if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_CONFIG_TABLE) { @@ -99,6 +117,10 @@ void InitBootInfo(multiboot_info_t *mbi) GetBootInfo(memory).memValid ? okStr : noStr); DebugLog("[InitBootInfo] Memory map %s\n", GetBootInfo(memory).mapValid ? okStr : noStr); + DebugLog("[InitBootInfo] Video infos %s\n", + GetBootInfo(video).vbeValid ? okStr : noStr); + DebugLog("[InitBootInfo] Framebuffer %s\n", + GetBootInfo(video).fbuValid ? okStr : noStr); DebugLog("[InitBootInfo] ROM table %s\n", GetBootInfo(firmware).romValid ? okStr : noStr); DebugLog("[InitBootInfo] APM table %s\n\n", From fd9f87ddd469ef987fa309435601d93acbf24038 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 23 Mar 2019 23:52:18 +0100 Subject: [PATCH 2/3] VGA initialization --- kaleid/include/kernel/base.h | 2 +- kaleid/kernel/init/init.c | 41 +++++++++--------------------------- kaleid/kernel/io/vga.c | 12 +++++++---- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index a053f8f..e6efe12 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -107,7 +107,7 @@ struct BootInfo_t uint modulesCount; //mods_count void *modulesAddr; //mods_addr char *grubName; //boot_loader_name - void *mbHeaderAddr; + void *kernelAddr; } btldr; // Informations about drives diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 5a313de..0dac2bf 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -32,9 +32,7 @@ // void InitBootInfo(multiboot_info_t *mbi) { - extern uint MB_header; - char *okStr = "available"; - char *noStr = "unavailable"; + extern void MB_header(void); // We need the multiboot structure KalAlwaysAssert(mbi); @@ -44,7 +42,7 @@ void InitBootInfo(multiboot_info_t *mbi) if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) { GetBootInfo(btldr).grubName = (char*)(ullong)(mbi->boot_loader_name); - GetBootInfo(btldr).mbHeaderAddr = (void*)(ullong)&MB_header; + GetBootInfo(btldr).kernelAddr = (void*)&MB_header; GetBootInfo(btldr).valid = 1; } if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MODS) { @@ -103,28 +101,6 @@ void InitBootInfo(multiboot_info_t *mbi) GetBootInfo(firmware).apmTable = mbi->apm_table; GetBootInfo(firmware).apmValid = 1; } - - //Now we check (debug) - /*DebugLog("[InitBootInfo] Flags : %b\n\n", - GetBootInfo(btldr).grubFlags);*/ - DebugLog("[InitBootInfo] Boot loader %s\n", - GetBootInfo(btldr).valid ? okStr : noStr); - DebugLog("[InitBootInfo] Boot drive %s\n", - GetBootInfo(drives).drvValid ? okStr : noStr); - DebugLog("[InitBootInfo] Disk buffer %s\n", - GetBootInfo(drives).bufferValid ? okStr : noStr); - DebugLog("[InitBootInfo] Basic mem %s\n", - GetBootInfo(memory).memValid ? okStr : noStr); - DebugLog("[InitBootInfo] Memory map %s\n", - GetBootInfo(memory).mapValid ? okStr : noStr); - DebugLog("[InitBootInfo] Video infos %s\n", - GetBootInfo(video).vbeValid ? okStr : noStr); - DebugLog("[InitBootInfo] Framebuffer %s\n", - GetBootInfo(video).fbuValid ? okStr : noStr); - DebugLog("[InitBootInfo] ROM table %s\n", - GetBootInfo(firmware).romValid ? okStr : noStr); - DebugLog("[InitBootInfo] APM table %s\n\n", - GetBootInfo(firmware).apmValid ? okStr : noStr); } @@ -136,6 +112,9 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) // We're not ready to deal with interrupts DisableIRQs(); + //Initialize the BootInfo_t structure + InitBootInfo(mbInfo); + // Kernel terminals InitTerms(); @@ -143,10 +122,10 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) KernLog("%c%c%c OS/K\n\n", 219, 219, 219); KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC); - KernLog("[Init] We have magic : %x\n\n", mbMagic); - - //Initialize the BootInfo_t structure - InitBootInfo(mbInfo); + KernLog("[Init] Kernel successfully loaded at %p with %x magic\n\n", + GetBootInfo(btldr).kernelAddr, + mbMagic + ); //Memory mapping error_t mapBad = InitMemoryMap(); @@ -154,6 +133,6 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) StartPanic("[Init] The memory map failed to initialize. Error : %d", mapBad); // We're out - KernLog("\n[Init] Evil never dies !"); + KernLog("\n[Init] Evil never dies !\n"); CrashSystem(); //yay } diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index 600eae0..b24f876 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -76,9 +76,9 @@ Terminal_t VGA_Terminal = { .name = "VGA Output Terminal", .type = "VGA", - .data = (void *)0xB8000, - .width = 80, - .height = 25, + .data = (void *)0, + .width = 0, + .height = 0, .currentX = 0, .currentY = 0, @@ -90,7 +90,6 @@ Terminal_t VGA_Terminal = { .putchar = VGA_PutOnTermUnlocked, }; - // // Initialize VGA output // @@ -98,6 +97,11 @@ void VGA_Init(void) { KalAssert(VGA_Terminal.initDone != INITOK); + //Use the infos provided in the BootInfo_t structure + VGA_Terminal.data = GetBootInfo(video).framebufferAddr; + VGA_Terminal.width = GetBootInfo(video).framebufferWidth; + VGA_Terminal.height = GetBootInfo(video).framebufferHeight; + VGA_Terminal.initDone = INITOK; } From 5cfc5997dca85d575ddeab307b3bb69f02958f86 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 23 Mar 2019 23:58:49 +0100 Subject: [PATCH 3/3] Init clean-up --- kaleid/kernel/init/init.c | 9 ++++++--- kaleid/kernel/mm/map.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 0dac2bf..94c8034 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -109,6 +109,8 @@ void InitBootInfo(multiboot_info_t *mbi) // noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) { + error_t mapBad; + // We're not ready to deal with interrupts DisableIRQs(); @@ -128,9 +130,10 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) ); //Memory mapping - error_t mapBad = InitMemoryMap(); - if (mapBad) - StartPanic("[Init] The memory map failed to initialize. Error : %d", mapBad); + if ((mapBad = InitMemoryMap())) + StartPanic("[Init] The memory map failed to initialize. Error : %d", + mapBad + ); // We're out KernLog("\n[Init] Evil never dies !\n"); diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 5ea56c6..d84f662 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -32,7 +32,7 @@ error_t InitMemoryMap(void) DebugLog("[InitMemoryMap] Memory map address : %p, length : %d\n", GetBootInfo(memory).mapAddr, GetBootInfo(memory).mapLength); - if ((GetBootInfo(memory).upMemory / (MB/KB)) <= MINIMUM_RAM_SIZE) //XXX before loading kernel... + if ((GetBootInfo(memory).upMemory / (MB/KB)) <= MINIMUM_RAM_SIZE) return ENOMEM; DebugLog("[InitMemoryMap] Low memory : %d Kio, Up memory : %d Mio\n", GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB));