From e8d09031cb4a8a4ac3f1757b7ee57a13f124ed14 Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Fri, 28 Apr 2017 21:04:33 +0000 Subject: [PATCH] started adding a vesa fb --- kernel/arch/x86/pc/include/multiboot.h | 22 +++++++++++----------- kernel/arch/x86/pc/start.cpp | 16 +++++++++++++++- kernel/arch/x86/pc/start.s | 8 ++++++++ kernel/hw/pc/config.py | 1 + 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/kernel/arch/x86/pc/include/multiboot.h b/kernel/arch/x86/pc/include/multiboot.h index 2e70d58..a669da9 100644 --- a/kernel/arch/x86/pc/include/multiboot.h +++ b/kernel/arch/x86/pc/include/multiboot.h @@ -92,7 +92,7 @@ #define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 #ifndef ASM_FILE - +#define multiboot_PACKED __attribute__((packed)) typedef unsigned char multiboot_uint8_t; typedef unsigned short multiboot_uint16_t; typedef unsigned int multiboot_uint32_t; @@ -230,7 +230,7 @@ struct multiboot_mmap_entry { #define MULTIBOOT_MEMORY_NVS 4 #define MULTIBOOT_MEMORY_BADRAM 5 multiboot_uint32_t type; -} GRUB_PACKED; +} multiboot_PACKED; typedef struct multiboot_mmap_entry multiboot_memory_map_t; struct multiboot_mod_list { @@ -248,15 +248,15 @@ typedef struct multiboot_mod_list multiboot_module_t; /* APM BIOS info. */ struct multiboot_apm_info { - grub_uint16_t version; - grub_uint16_t cseg; - grub_uint32_t offset; - grub_uint16_t cseg_16; - grub_uint16_t dseg; - grub_uint16_t flags; - grub_uint16_t cseg_len; - grub_uint16_t cseg_16_len; - grub_uint16_t dseg_len; + multiboot_uint16_t version; + multiboot_uint16_t cseg; + multiboot_uint32_t offset; + multiboot_uint16_t cseg_16; + multiboot_uint16_t dseg; + multiboot_uint16_t flags; + multiboot_uint16_t cseg_len; + multiboot_uint16_t cseg_16_len; + multiboot_uint16_t dseg_len; }; #endif /* ! ASM_FILE */ diff --git a/kernel/arch/x86/pc/start.cpp b/kernel/arch/x86/pc/start.cpp index 524c154..6c96869 100644 --- a/kernel/arch/x86/pc/start.cpp +++ b/kernel/arch/x86/pc/start.cpp @@ -1,8 +1,22 @@ +#include +#include +#ifndef ENABLE_FRAMEBUFFER #include "../../../hw/pc/cgaterm/cgaterm.hpp" +#else +#include "../../../hw/pc/vesafb/vesafb.hpp" +#endif #include +static multiboot_info_t *mb_info; +#ifndef ENABLE_FRAMEBUFFER CGATerm term; +#else +VESAfb term(mb_info); +#endif void main(); -extern "C" void start() { main(); } +extern "C" void start(int eax, multiboot_info_t *ebx) { + mb_info = ebx; + main(); +} void drivers_init() { setMainTTY(&term); --term; diff --git a/kernel/arch/x86/pc/start.s b/kernel/arch/x86/pc/start.s index 321ecdd..7bf1b75 100644 --- a/kernel/arch/x86/pc/start.s +++ b/kernel/arch/x86/pc/start.s @@ -7,8 +7,16 @@ _start: jmp _start2 .align MULTIBOOT_HEADER_ALIGN .int MULTIBOOT_HEADER_MAGIC +#ifndef ENABLE_FRAMEBUFFER .int 0x0 .int -(MULTIBOOT_HEADER_MAGIC) +#else +.int 0x7 +.int -(MULTIBOOT_HEADER_MAGIC+0x7) +.int 0,0,0,0,0 +.int 0 +.int 1024, 768, 24 +#endif .align MULTIBOOT_HEADER_ALIGN .extern start _start2: diff --git a/kernel/hw/pc/config.py b/kernel/hw/pc/config.py index eca48f4..acdfe98 100644 --- a/kernel/hw/pc/config.py +++ b/kernel/hw/pc/config.py @@ -2,6 +2,7 @@ config["ENABLE_FRAMEBUFFER"] = get_yes_no("Use VESA Framebuffer?", True) if config["ENABLE_FRAMEBUFFER"]: config["ENABLE_FRAMEBUFFER_UNICODE"] = get_yes_no("Enable full Unicode BMP font (Adds around 1MB to binary)", False) if config["ENABLE_FRAMEBUFFER"]: + add_driver(True, "framebuffer") add_driver(False, "vesafb") else: add_driver(False, "cgaterm")