Multiboot2Initializator stub

This commit is contained in:
Alex 2022-10-13 09:32:26 +03:00
parent 8f108466fa
commit 398d889c74
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
3 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,43 @@
#include <types.h>
EXTERNC __attribute__((no_stack_protector, section(".multiboot.text"))) void Multiboot2Initializator()
{
for (int i = 0; i < 2000; i++)
{
((unsigned int *)0xb8000)[i * 2] = ' ';
((unsigned int *)0xb8000)[i * 2 + 1] = 0;
}
((uint8_t *)0xb8000)[2 * (80) * (25) - 2] = 'W';
((uint8_t *)0xb8000)[2 * (80) * (25) - 1] = 6;
unsigned char *SMBIOSAddress = (unsigned char *)0xF0000;
while ((unsigned int)(unsigned long)SMBIOSAddress < 0x100000)
{
if (SMBIOSAddress[0] == '_' &&
SMBIOSAddress[1] == 'S' &&
SMBIOSAddress[2] == 'M' &&
SMBIOSAddress[3] == '_')
{
unsigned char Checksum = 0;
int Length = SMBIOSAddress[5];
for (int i = 0; i < Length; i++)
Checksum += SMBIOSAddress[i];
if (Checksum == 0)
break;
}
SMBIOSAddress += 16;
}
if ((unsigned int)(unsigned long)SMBIOSAddress == 0x100000)
{
// No SMBIOS found
((uint8_t *)0xb8000)[2 * (80) * (25) - 4] = 'S';
((uint8_t *)0xb8000)[2 * (80) * (25) - 3] = 4;
while (1)
asmv("hlt");
}
((uint8_t *)0xb8000)[2 * (80) * (25) - 10] = 'Y';
((uint8_t *)0xb8000)[2 * (80) * (25) - 9] = 2;
return;
}

View File

@ -26,6 +26,7 @@ BOOT_PAGE_TBL1: resb 4096
section .multiboot2.text
extern x32Entry
extern Multiboot2Initializator
extern _kernel_start
extern _kernel_end
global _start
@ -58,6 +59,7 @@ _start:
add edi, 4
loop .PagingLoop
.LoopEnd:
call Multiboot2Initializator
push ebx
mov dword [BOOT_PAGE_DIR0 - KERNEL_VIRTUAL_BASE + (000 * 4)], (BOOT_PAGE_TBL0 - KERNEL_VIRTUAL_BASE + 3)
mov dword [BOOT_PAGE_DIR0 - KERNEL_VIRTUAL_BASE + (001 * 4)], (BOOT_PAGE_TBL1 - KERNEL_VIRTUAL_BASE + 3)

View File

@ -8,6 +8,7 @@
#include <time.hpp>
#include <debug.h>
#include <smp.hpp>
#include <io.h>
NEWLOCK(KernelLock);
@ -42,9 +43,9 @@ EXTERNC void KPrint(const char *format, ...)
EXTERNC void Entry(BootInfo *Info)
{
BootClock = ReadClock();
trace("Hello, World!");
InitializeMemoryManagement(Info);
trace("Hello, World!");
BootClock = ReadClock();
bInfo = (BootInfo *)KernelAllocator.RequestPages(TO_PAGES(sizeof(BootInfo)));
memcpy(bInfo, Info, sizeof(BootInfo));
debug("BootInfo structure is at %p", bInfo);