So, I have my kernel which is Kernel.c. I have my second bootloader which loads my kernel and copies it to the 1 MB after i enter Protected Mode. Bochs has a GPF and infinitely reboots. It's not that it can't find the file because I added in a way to display a message if the file didn't exist. So if you guys could take a look at it I'd be grateful.
These are the variables that I use and I show what they are so you guys can get a better understanding of it.:
Code:
CODE_DESC = 0x08
DATA_DESC = 0x10
IMAGE_RMODE_BASE = 0x3000
IMAGE_PMODE_BASE = 0x100000
Kernel.c:
Code:
void ClrScr();
int main(void)
{
ClrScr();
for (;;);
}
void ClrScr()
{
char *vidmem = (char*)0xB8000;
unsigned int i;
for (i = 0; i < (80*25); i++) {
*vidmem++ = 0;
*vidmem++ = 0xF;
}
}
From when I enter PMode from second bootloader:
Setup.asm:
Code:
Loader:
mov ax, DATA_DESC
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 0x90000
Copy_Image:
mov eax, DWORD [ImageSize]
movzx ebx, WORD [bpbBytesPerSector]
mul ebx
mov ebx, 4
div ebx
cld
mov esi, IMAGE_RMODE_BASE
mov edi, IMAGE_PMODE_BASE
mov ecx, eax
rep movsd
jmp CODE_DESC:IMAGE_PMODE_BASE
cli
hlt
And this is how I'm compiling the Kernel.c file if it matters at all. By the way Setup.asm looks for the file called "KRNL32.BIN".
GCC Code:
Code:
gcc -ffreestanding -c Kernel.c -o KRNL32.BIN
Thanks for taking the time to read this and help me.