Merge pull request #51 from os-k-team/master

master
This commit is contained in:
Adrien Bourmault 2019-03-23 00:09:49 +01:00 committed by GitHub
commit 2e6c08beaf
9 changed files with 227 additions and 162 deletions

View File

@ -61,103 +61,103 @@ all : OS/K
## KALEID MAKEFILE ----------------------------------------------------------- #
# Common objects
kal_com_obj= $(KOBJDIR)/atoi.o $(KOBJDIR)/ctype.o \
$(KOBJDIR)/itoa.o $(KOBJDIR)/mem.o \
$(KOBJDIR)/rand.o $(KOBJDIR)/sprintf.o \
$(KOBJDIR)/status.o $(KOBJDIR)/string.o \
$(KOBJDIR)/strtol.o $(KOBJDIR)/argv.o \
$(KOBJDIR)/prog.o $(KOBJDIR)/atol.o \
$(KOBJDIR)/atou.o $(KOBJDIR)/atoul.o \
$(KOBJDIR)/utoa.o $(KOBJDIR)/ltoa.o \
kal_com_obj= $(KOBJDIR)/atoi.o $(KOBJDIR)/ctype.o \
$(KOBJDIR)/itoa.o $(KOBJDIR)/mem.o \
$(KOBJDIR)/rand.o $(KOBJDIR)/sprintf.o \
$(KOBJDIR)/status.o $(KOBJDIR)/string.o \
$(KOBJDIR)/strtol.o $(KOBJDIR)/argv.o \
$(KOBJDIR)/prog.o $(KOBJDIR)/atol.o \
$(KOBJDIR)/atou.o $(KOBJDIR)/atoul.o \
$(KOBJDIR)/utoa.o $(KOBJDIR)/ltoa.o \
$(KOBJDIR)/ultoa.o
$(KOBJDIR)/atoi.o: $(KERNELDIR)/crtlib/atoi.c
$(KOBJDIR)/atoi.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ATOI $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/atol.o: $(KERNELDIR)/crtlib/atoi.c
$(KOBJDIR)/atol.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ATOL $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/atou.o: $(KERNELDIR)/crtlib/atoi.c
$(KOBJDIR)/atou.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ATOU $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/atoul.o: $(KERNELDIR)/crtlib/atoi.c
$(KOBJDIR)/atoul.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ATOUL $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/ctype.o: $(KERNELDIR)/crtlib/ctype.c
$(KOBJDIR)/ctype.o: $(KERNELDIR)/crtlib/ctype.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/itoa.o: $(KERNELDIR)/crtlib/itoa.c
$(KOBJDIR)/itoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ITOA $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/ltoa.o: $(KERNELDIR)/crtlib/itoa.c
$(KOBJDIR)/ltoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_LTOA $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/utoa.o: $(KERNELDIR)/crtlib/itoa.c
$(KOBJDIR)/utoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_UTOA $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/ultoa.o: $(KERNELDIR)/crtlib/itoa.c
$(KOBJDIR)/ultoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
@$(KCC) -D_NEED_ULTOA $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/mem.o: $(KERNELDIR)/crtlib/mem.c
$(KOBJDIR)/mem.o: $(KERNELDIR)/crtlib/mem.c $(KERNELDIR)/include/*/*.h
@$(KCC) -fno-strict-aliasing $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/rand.o: $(KERNELDIR)/crtlib/rand.c
$(KOBJDIR)/rand.o: $(KERNELDIR)/crtlib/rand.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/sprintf.o: $(KERNELDIR)/crtlib/sprintf.c
$(KOBJDIR)/sprintf.o: $(KERNELDIR)/crtlib/sprintf.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/status.o: $(KERNELDIR)/crtlib/status.c
$(KOBJDIR)/status.o: $(KERNELDIR)/crtlib/status.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/string.o: $(KERNELDIR)/crtlib/string.c
$(KOBJDIR)/string.o: $(KERNELDIR)/crtlib/string.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/strtol.o: $(KERNELDIR)/crtlib/strtol.c
$(KOBJDIR)/strtol.o: $(KERNELDIR)/crtlib/strtol.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/argv.o: $(KERNELDIR)/extras/argv.c
$(KOBJDIR)/argv.o: $(KERNELDIR)/extras/argv.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c
$(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
# Kernel objects
kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \
$(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \
$(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \
$(KOBJDIR)/kernel/panic.o $(KOBJDIR)/kernel/map.o \
kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \
$(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \
$(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \
$(KOBJDIR)/kernel/panic.o $(KOBJDIR)/kernel/map.o \
$(KOBJDIR)/kernel/heap.o $(KOBJDIR)/kernel/malloc.o
$(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c
$(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/init.o: $(KERNELDIR)/kernel/init/init.c
$(KOBJDIR)/kernel/init.o: $(KERNELDIR)/kernel/init/init.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/table.o: $(KERNELDIR)/kernel/init/table.c
$(KOBJDIR)/kernel/table.o: $(KERNELDIR)/kernel/init/table.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/cursor.o: $(KERNELDIR)/kernel/io/cursor.c
$(KOBJDIR)/kernel/cursor.o: $(KERNELDIR)/kernel/io/cursor.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/term.o: $(KERNELDIR)/kernel/io/term.c
$(KOBJDIR)/kernel/term.o: $(KERNELDIR)/kernel/io/term.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c
$(KOBJDIR)/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c
$(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/map.o: $(KERNELDIR)/kernel/mm/map.c
$(KOBJDIR)/kernel/map.o: $(KERNELDIR)/kernel/mm/map.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c
$(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c
$(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c $(KERNELDIR)/include/*/*.h
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
@ -165,13 +165,13 @@ $(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c
./ProjectTree: ./.stylehlp_sh
@cat ./.stylehlp_sh > ./ProjectTree
@echo "\n" >> ./ProjectTree
@tree >> ./ProjectTree
@tree --dirsfirst >> ./ProjectTree
@echo ${CL2}[$@] ${CL}Generated.${CL3}
## MAIN MAKEFILE ------------------------------------------------------------- #
.PHONY: test
test: all
@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 -m 5G -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
.PHONY: test32
@ -182,7 +182,7 @@ test32: all
.PHONY: debug
debug: all
@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 -m 5G -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

View File

@ -24,9 +24,7 @@
.
├── AUTHORS
├── boot
│   ├── folder.desc
│   ├── grub
│   │   ├── create_disk.sh
│   │   ├── grub.cfg
@ -34,69 +32,67 @@
│   │   ├── mount.sh
│   │   ├── multiboot.pdf
│   │   └── umount.sh
│   └── loader
│   ├── cpu
│   │   ├── cpu32.inc
│   │   └── cpu.inc
│   ├── io
│   │   └── terminal.inc
│   ├── loader.asm
│   ├── mem
│   │   ├── management.inc
│   │   └── structures.inc
│   └── multiboot
│   ├── check.inc
│   └── header.inc
│   ├── loader
│   │   ├── cpu
│   │   │   ├── cpu32.inc
│   │   │   └── cpu.inc
│   │   ├── io
│   │   │   └── terminal.inc
│   │   ├── mem
│   │   │   ├── management.inc
│   │   │   └── structures.inc
│   │   ├── multiboot
│   │   │   ├── check.inc
│   │   │   └── header.inc
│   │   └── loader.asm
│   └── folder.desc
├── build
│   ├── bin
│   │   ├── disk.img
│   │   └── kaleid
│   ├── kernel.ld
│   └── obj
│   ├── boot
│   │   ├── kaleid.x86_64
│   │   └── loader.o
│   └── kaleid
│   ├── argv.o
│   ├── atoi.o
│   ├── atol.o
│   ├── atoul.o
│   ├── atou.o
│   ├── ctype.o
│   ├── itoa.o
│   ├── kernel
│   │   ├── 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
│   │   ├── table.o
│   │   ├── term.o
│   │   └── vga.o
│   ├── ltoa.o
│   ├── mem.o
│   ├── prog.o
│   ├── rand.o
│   ├── sprintf.o
│   ├── status.o
│   ├── string.o
│   ├── strtol.o
│   ├── ultoa.o
│   └── utoa.o
├── ChangeLog
├── COPYING
├── grub.log
│   ├── obj
│   │   ├── boot
│   │   │   ├── kaleid.x86_64
│   │   │   └── loader.o
│   │   └── kaleid
│   │   ├── kernel
│   │   │   ├── init
│   │   │   │   ├── init.o
│   │   │   │   └── table.o
│   │   │   ├── io
│   │   │   │   ├── cursor.o
│   │   │   │   ├── term.o
│   │   │   │   └── vga.o
│   │   │   ├── ke
│   │   │   │   └── panic.o
│   │   │   ├── cpuid.o
│   │   │   ├── cursor.o
│   │   │   ├── heap.o
│   │   │   ├── init.o
│   │   │   ├── malloc.o
│   │   │   ├── map.o
│   │   │   ├── panic.o
│   │   │   ├── table.o
│   │   │   ├── term.o
│   │   │   └── vga.o
│   │   ├── argv.o
│   │   ├── atoi.o
│   │   ├── atol.o
│   │   ├── atoul.o
│   │   ├── atou.o
│   │   ├── ctype.o
│   │   ├── itoa.o
│   │   ├── ltoa.o
│   │   ├── mem.o
│   │   ├── prog.o
│   │   ├── rand.o
│   │   ├── sprintf.o
│   │   ├── status.o
│   │   ├── string.o
│   │   ├── strtol.o
│   │   ├── ultoa.o
│   │   └── utoa.o
│   └── kernel.ld
├── kaleid
│   ├── crtlib
│   │   ├── atoi.c
@ -126,20 +122,20 @@
│   │   │   ├── locks.h
│   │   │   ├── malloc.h
│   │   │   └── prog.h
│   │   ├── kernel
│   │   │   ├── base.h
│   │   │   ├── cpu.h
│   │   │   ├── heap.h
│   │   │   ├── iomisc.h
│   │   │   ├── mm.h
│   │   │   ├── multiboot.h
│   │   │   ├── panic.h
│   │   │   ├── proc.h
│   │   │   ├── sched.h
│   │   │   └── term.h
│   │   ├── kalbase.h
│   │   ├── kaleid.h
│   │   ├── kalext.h
│   │   └── kernel
│   │   ├── base.h
│   │   ├── cpu.h
│   │   ├── heap.h
│   │   ├── iomisc.h
│   │   ├── mm.h
│   │   ├── multiboot.h
│   │   ├── panic.h
│   │   ├── proc.h
│   │   ├── sched.h
│   │   └── term.h
│   │   └── kalext.h
│   └── kernel
│   ├── cpu
│   │   └── cpuid.c
@ -160,6 +156,10 @@
│   └── proc
│   ├── Makefile
│   └── sched.c
├── AUTHORS
├── ChangeLog
├── COPYING
├── grub.log
├── loader_disasm32.asm
├── loader_disasm64.asm
├── Makefile

View File

@ -44,6 +44,11 @@ MB_header:
dd MB_HEADER_MAGIC
dd MB_HEADER_FLAGS
dd CHECKSUM
times 5 dd 0x0
dd MB_VIDEO_MODE
dd MB_VIDEO_WIDTH
dd MB_VIDEO_HEIGHT
dd MB_VIDEO_DEPTH
[section .text]
@ -71,7 +76,7 @@ Error:
call write32
pop esi
jmp Die
.ergo : db 219, 219, 219, " Error "
.ergo : db 219, 219, 219, " OS/K Loader Error "
.code : db "00"
db 0x0
; ---------------------------------------------------------------------------- ;
@ -104,6 +109,12 @@ mbMagic dq 0
lbegin:
call clear ; Clear the screen
push esi ; Print the logo
mov bl, 0x0E
mov esi, LOGO
call write32
pop esi
;; BEGIN OF CHECKLIST
call MB_check ; Check Multiboot State, ERR 01
@ -115,12 +126,6 @@ lbegin:
call Setup_paging ; Enable paging
call Go64 ; Prepare switch into long mode
push esi ; Print the logo
mov bl, 0x0E
mov esi, LOGO
call write32
pop esi
;call disable_cursor
lgdt [GDT64.pointer]
@ -154,6 +159,7 @@ _loader64:
call write
;; Launch the kernel !
;; XXX CHECK THE RAM BEFORE CALLING KERNEL !
call tritemporize ; Let time to see
mov rdi, [mbInfo]

View File

@ -27,8 +27,13 @@
MB_AOUT_KLUDGE equ 0 << 16 ; if we are not an ELF executable
MB_ALIGN equ 1 << 0 ; Ask to align loaded modules on page boundaries
MB_MEMINFO equ 1 << 1 ; Ask to provide memory map
MB_VIDEOINFO equ 1 << 2 ; Ask to provide video infos
MB_VIDEO_MODE equ 0x1 ; Text mode
MB_VIDEO_WIDTH equ 80
MB_VIDEO_HEIGHT equ 24
MB_VIDEO_DEPTH equ 0x0
MB_HEADER_MAGIC equ 0x1badb002
MB_GRUB_MAGIC equ 0x2badb002
MB_HEADER_FLAGS equ MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO
MB_HEADER_FLAGS equ MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO|MB_VIDEOINFO
CHECKSUM equ -(MB_HEADER_MAGIC + MB_HEADER_FLAGS)
KERNEL_STACK equ 0x00200000 ; Stack starts at the 2mb address & grows down

View File

@ -102,33 +102,42 @@ struct BootInfo_t
{
// The Bootloader infos (GRUB in our case)
struct {
ushort valid;
uint grubFlags; //flags
uint modulesCount; //mods_count
void *modulesAddr; //mods_addr
uint grubName; //boot_loader_name
char *grubName; //boot_loader_name
void *mbHeaderAddr;
} btldr;
// Informations about drives
struct {
ushort drvValid;
ushort bufferValid;
uint bootDrv; //boot_device
uint bufferLength; //drives_length
void *bufferAddr; //drives_addr
void *bufferAddr; //drives_addr
} drives;
// Informations about memory
struct {
ushort memValid;
ushort mapValid;
//BIOS provided low and up memory
uint lowMemory; //mem_lower
uint upMemory; //mem_upper
//GRUB provided memory map
uint mapLength; //mmap_length
void *mapAddr; //mmap_addr
void *mapAddr; //mmap_addr
uint ramSize; //The ram (init by map.c)
} memory;
// Informations about the video drive
struct {
ushort valid;
uint vbeControl; //vbe_control_info
uint vbeModeInfo; //vbe_mode_info
ushort vbeMode; //vbe_mode
@ -145,6 +154,8 @@ struct BootInfo_t
// Informations about the microcode firmware (BIOS/EFI)
struct {
ushort apmValid;
ushort romValid;
uint apmTable; //apm_table
uint romTable; //config_table
} firmware;

View File

@ -25,6 +25,8 @@
#include <kernel/multiboot.h>
#include <kernel/base.h>
#define MINIMUM_RAM_SIZE 16 //Mio, the minimum RAM size.
//
// Returns a pointer to the first entry of the memory map
//

View File

@ -22,56 +22,87 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <kernel/multiboot.h>
#include <kernel/term.h>
#include <kernel/panic.h>
#include <kernel/mm.h>
//
// BootInfo_t initialization. It is necessary because grub will potentially be
// wiped since it is below 1MB....
// wiped since it is below 1MB.... And we must reorganize all that stuff.
//
void InitBootInfo(multiboot_info_t *mbi)
{
KalAssert(mbi);
extern uint MB_header;
char *okStr = "available";
char *noStr = "unavailable";
//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 = (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);
// We need the multiboot structure
KalAlwaysAssert(mbi);
//Retrieves the bootloader flags to ensure infos are valid
GetBootInfo(btldr).grubFlags = mbi->flags;
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).valid = 1;
}
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MODS) {
GetBootInfo(btldr).modulesCount = mbi->mods_count;
GetBootInfo(btldr).modulesAddr = (void*)(ullong)mbi->mods_addr;
}
//Retrieves the drives informations
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);
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_DRIVE_INFO) {
GetBootInfo(drives).bufferLength = mbi->drives_length;
GetBootInfo(drives).bufferAddr = (void*)(ullong)mbi->drives_addr;
GetBootInfo(drives).bufferValid = 1;
}
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_BOOTDEV) {
GetBootInfo(drives).bootDrv = mbi->boot_device;
GetBootInfo(drives).drvValid = 1;
}
//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);
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MEMORY) {
GetBootInfo(memory).lowMemory = mbi->mem_lower;
GetBootInfo(memory).upMemory = mbi->mem_upper;
GetBootInfo(memory).memValid = 1;
}
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MEM_MAP) {
GetBootInfo(memory).mapAddr = (void*)(ullong)mbi->mmap_addr;
GetBootInfo(memory).mapLength = mbi->mmap_length;
GetBootInfo(memory).mapValid = 1;
}
// 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);
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_CONFIG_TABLE) {
GetBootInfo(firmware).romTable = mbi->config_table;
GetBootInfo(firmware).romValid = 1;
}
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_APM_TABLE) {
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] ROM table %s\n",
GetBootInfo(firmware).romValid ? okStr : noStr);
DebugLog("[InitBootInfo] APM table %s\n\n",
GetBootInfo(firmware).apmValid ? okStr : noStr);
}
@ -90,13 +121,15 @@ 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", mbMagic);
KernLog("[Init] We have magic : %x\n\n", mbMagic);
//Initialize the BootInfo_t structure
InitBootInfo(mbInfo);
//Memory mapping
InitMemoryMap();
error_t mapBad = InitMemoryMap();
if (mapBad)
StartPanic("[Init] The memory map failed to initialize. Error : %d", mapBad);
// We're out
KernLog("\n[Init] Evil never dies !");

View File

@ -66,6 +66,6 @@ error_t KalAllocMemory(void **ptr, size_t req, int flags, size_t align)
error_t KalFreeMemory(void *ptr)
{
(void)ptr;
return 0;
return EOK;
}

View File

@ -27,8 +27,16 @@
error_t InitMemoryMap(void)
{
///uint MapIsValid = (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MEM_MAP = MULTIBOOT_INFO_MEM_MAP ? 1 : 0);
KalAlwaysAssert(0);
if (!GetBootInfo(memory).memValid && GetBootInfo(memory).mapValid)
return ENXIO;
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...
return ENOMEM;
DebugLog("[InitMemoryMap] Low memory : %d Kio, Up memory : %d Mio\n",
GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB));
return EOK;
}