diff --git a/Makefile b/Makefile index d6588b7..0c75b9e 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ $(LOBJDIR)/kaleid.x86_64: $(kal_kern_obj) $(kal_com_obj) $(LOBJDIR)/loader.o -o $(LOBJDIR)/kaleid.x86_64 @echo ${CL2}[$@] ${CL}Success.${CL3} -$(LOBJDIR)/loader.o: $(LOADERDIR)/loader.asm +$(LOBJDIR)/loader.o: $(LOADERDIR)/loader.asm $(LOADERDIR)/*/*.inc @echo ${CL2}[$@] ${NC}Making loader...${CL3} @$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(LOBJDIR)/loader.o > /dev/null @echo ${CL2}[$@] ${CL}Success.${CL3} diff --git a/ProjectTree b/ProjectTree index 8203b54..290b5cf 100644 --- a/ProjectTree +++ b/ProjectTree @@ -68,7 +68,16 @@ │   │   ├── cpuid.o │   │   ├── cursor.o │   │   ├── heap.o +│   │   ├── init +│   │   │   ├── init.o +│   │   │   └── table.o │   │   ├── init.o +│   │   ├── io +│   │   │   ├── cursor.o +│   │   │   ├── term.o +│   │   │   └── vga.o +│   │   ├── ke +│   │   │   └── panic.o │   │   ├── malloc.o │   │   ├── map.o │   │   ├── panic.o @@ -159,4 +168,4 @@ ├── qemu.log └── Readme.md -28 directories, 106 files +31 directories, 112 files diff --git a/boot/grub/multiboot.pdf b/boot/grub/multiboot.pdf index e32056f..978ff78 100644 Binary files a/boot/grub/multiboot.pdf and b/boot/grub/multiboot.pdf differ diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 785e4c2..8e39fa7 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -32,6 +32,7 @@ %include "boot/loader/mem/structures.inc" global MB_start +global MB_header extern StartKern [BITS 32] diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index 199385e..055a2c9 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -64,7 +64,7 @@ typedef enum TermColor_t TermColor_t; #define PANICSTR_SIZE 1024 //Get the BootInfo_t structure -#define GetBootInfo() (bootTab) +#define GetBootInfo(x) bootTab.x //------------------------------------------// // @@ -101,22 +101,23 @@ struct Processor_t #define FB_EGA_TEXT 2 #define FB_INDEXED 0 #define FB_RGB 1 - +#define BINFO_SIZE 4096 struct BootInfo_t { // The Bootloader infos (GRUB in our case) struct { uint grubFlags; //flags uint modulesCount; //mods_count - uint modulesAddr; //mods_addr + void *modulesAddr; //mods_addr uint grubName; //boot_loader_name + void *mbHeaderAddr; } btldr; // Informations about drives struct { uint bootDrv; //boot_device uint bufferLength; //drives_length - uint bufferAddr; //drives_addr + void *bufferAddr; //drives_addr } drives; // Informations about memory @@ -127,18 +128,18 @@ struct BootInfo_t //GRUB provided memory map uint mapLength; //mmap_length - uint mapAddr; //mmap_addr + void *mapAddr; //mmap_addr } memory; // Informations about the video drive struct { uint vbeControl; //vbe_control_info - uint vbeModeInfo; //vbe_mode_info + uint vbeModeInfo; //vbe_mode_info ushort vbeMode; //vbe_mode ushort vbeInterfaceSeg; //vbe_interface_seg ushort vbeInterfaceOff; //vbe_interface_off ushort vbeInterfaceLen; //vbe_interface_len - ullong 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 2f634dc..163b457 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -33,19 +33,45 @@ // void InitBootInfo(multiboot_info_t *mbi) { + KalAssert(mbi); + + extern uint MB_header; + //Retrieves the bootloader informations - GetBootInfo().btldr.grubFlags = mbi->flags; - GetBootInfo().btldr.grubName = mbi->boot_loader_name; - GetBootInfo().btldr.modulesCount = mbi->mods_count; - GetBootInfo().btldr.modulesAddr = mbi->mods_addr; - DebugLog("[InitBootInfo] %s\n", GetBootInfo().btldr.grubName); + GetBootInfo(btldr).grubFlags = mbi->flags; + GetBootInfo(btldr).grubName = (mbi->boot_loader_name); + GetBootInfo(btldr).modulesCount = mbi->mods_count; + GetBootInfo(btldr).modulesAddr = (void*)(ullong)mbi->mods_addr; + GetBootInfo(btldr).mbHeaderAddr = (void*)(ullong)&MB_header; + DebugLog("\n[InitBootInfo] %s\n", GetBootInfo(btldr).grubName); + DebugLog("[InitBootInfo] Header address : %p, modules address : %p\n", + GetBootInfo(btldr).mbHeaderAddr, GetBootInfo(btldr).modulesAddr); + DebugLog("[InitBootInfo] GRUB flags : %x\n", GetBootInfo(btldr).grubFlags); //Retrieves the drives informations - GetBootInfo().drives.bootDrv = mbi->boot_device; - GetBootInfo().drives.bufferLength = mbi->drives_length; - GetBootInfo().drives.bufferAddr = mbi->drives_addr; + GetBootInfo(drives).bootDrv = mbi->boot_device; + GetBootInfo(drives).bufferLength = mbi->drives_length; + GetBootInfo(drives).bufferAddr = (void*)(ullong)mbi->drives_addr; DebugLog("[InitBootInfo] Root drive : %x\n", - GetBootInfo().drives.bootDrv); + GetBootInfo(drives).bootDrv); + + //Retrieves the memory informations + GetBootInfo(memory).lowMemory = mbi->mem_lower; + GetBootInfo(memory).upMemory = mbi->mem_upper; + GetBootInfo(memory).mapAddr = (void*)(ullong)mbi->mmap_addr; + GetBootInfo(memory).mapLength = mbi->mmap_length; + DebugLog("[InitBootInfo] Low memory : %d Kio, Up memory : %d Mio\n", + GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB)); + DebugLog("[InitBootInfo] Memory map address : %p, length : %d\n", + GetBootInfo(memory).mapAddr, GetBootInfo(memory).mapLength); + + // XXX assign video infos, but unused at this time + + // Retrieves the firmware infos + GetBootInfo(firmware).apmTable = mbi->apm_table; + GetBootInfo(firmware).romTable = mbi->config_table; + DebugLog("[InitBootInfo] APM Table : %p, ROM Table : %p\n", + GetBootInfo(firmware).apmTable, GetBootInfo(firmware).romTable); } @@ -71,6 +97,6 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) InitMemoryMap(); // We're out - KernLog("\n[Init] Evil never dies"); + KernLog("\n[Init] Evil never dies !"); CrashSystem(); //yay }