1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
This commit is contained in:
Adrien Bourmault 2019-03-24 00:02:00 +01:00
commit 92c00a9508
4 changed files with 26 additions and 40 deletions

View File

@ -107,7 +107,7 @@ struct BootInfo_t
uint modulesCount; //mods_count uint modulesCount; //mods_count
void *modulesAddr; //mods_addr void *modulesAddr; //mods_addr
char *grubName; //boot_loader_name char *grubName; //boot_loader_name
void *mbHeaderAddr; void *kernelAddr;
} btldr; } btldr;
// Informations about drives // Informations about drives

View File

@ -32,9 +32,7 @@
// //
void InitBootInfo(multiboot_info_t *mbi) void InitBootInfo(multiboot_info_t *mbi)
{ {
extern uint MB_header; extern void MB_header(void);
char *okStr = "available";
char *noStr = "unavailable";
// We need the multiboot structure // We need the multiboot structure
KalAlwaysAssert(mbi); KalAlwaysAssert(mbi);
@ -44,7 +42,7 @@ void InitBootInfo(multiboot_info_t *mbi)
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) { if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) {
GetBootInfo(btldr).grubName = (char*)(ullong)(mbi->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; GetBootInfo(btldr).valid = 1;
} }
if (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MODS) { 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).apmTable = mbi->apm_table;
GetBootInfo(firmware).apmValid = 1; 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);
} }
@ -133,9 +109,14 @@ void InitBootInfo(multiboot_info_t *mbi)
// //
noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic) noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic)
{ {
error_t mapBad;
// We're not ready to deal with interrupts // We're not ready to deal with interrupts
DisableIRQs(); DisableIRQs();
//Initialize the BootInfo_t structure
InitBootInfo(mbInfo);
// Kernel terminals // Kernel terminals
InitTerms(); InitTerms();
@ -143,17 +124,18 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic)
KernLog("%c%c%c OS/K\n\n", 219, 219, 219); KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC); KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC);
KernLog("[Init] We have magic : %x\n\n", mbMagic); KernLog("[Init] Kernel successfully loaded at %p with %x magic\n\n",
GetBootInfo(btldr).kernelAddr,
//Initialize the BootInfo_t structure mbMagic
InitBootInfo(mbInfo); );
//Memory mapping //Memory mapping
error_t mapBad = InitMemoryMap(); if ((mapBad = InitMemoryMap()))
if (mapBad) StartPanic("[Init] The memory map failed to initialize. Error : %d",
StartPanic("[Init] The memory map failed to initialize. Error : %d", mapBad); mapBad
);
// We're out // We're out
KernLog("\n[Init] Evil never dies !"); KernLog("\n[Init] Evil never dies !\n");
CrashSystem(); //yay CrashSystem(); //yay
} }

View File

@ -76,9 +76,9 @@ Terminal_t VGA_Terminal = {
.name = "VGA Output Terminal", .name = "VGA Output Terminal",
.type = "VGA", .type = "VGA",
.data = (void *)0xB8000, .data = (void *)0,
.width = 80, .width = 0,
.height = 25, .height = 0,
.currentX = 0, .currentX = 0,
.currentY = 0, .currentY = 0,
@ -90,7 +90,6 @@ Terminal_t VGA_Terminal = {
.putchar = VGA_PutOnTermUnlocked, .putchar = VGA_PutOnTermUnlocked,
}; };
// //
// Initialize VGA output // Initialize VGA output
// //
@ -98,6 +97,11 @@ void VGA_Init(void)
{ {
KalAssert(VGA_Terminal.initDone != INITOK); 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; VGA_Terminal.initDone = INITOK;
} }

View File

@ -32,7 +32,7 @@ error_t InitMemoryMap(void)
DebugLog("[InitMemoryMap] Memory map address : %p, length : %d\n", DebugLog("[InitMemoryMap] Memory map address : %p, length : %d\n",
GetBootInfo(memory).mapAddr, GetBootInfo(memory).mapLength); 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; return ENOMEM;
DebugLog("[InitMemoryMap] Low memory : %d Kio, Up memory : %d Mio\n", DebugLog("[InitMemoryMap] Low memory : %d Kio, Up memory : %d Mio\n",
GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB)); GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB));