SomeGuyWithAKeyboard wrote:
Because I don't know how to separate them.
Define a binary format that includes a load address and an entry point, then write a bootloader that can load a binary in that format and link your kernel into that format. ELF is one such format.
If ELF is too complicated, you can make it really simple: have the load address and entry point both be fixed values. For example, you can say the load address is always 0x10000 and the entry point is always 0x10000. For that to work, you need to tell the linker to put an assembly function at the start of your kernel binary that jumps to your real kernel entry point. (And you already know how to do that, since that's what you're doing right now to put your boot sector at the start of your binary.)
SomeGuyWithAKeyboard wrote:
Code:
.text : ALIGN(1K)
{
bootloader.o(.text)
*(.text .text.*)
}
.auxFunctions : ALIGN(1K)
{
misc_tools.o(.auxFunctions)
*(.auxFunctions .auxFunctions.*)
}
All of your kernel's code will be placed where you write "*(.text .text.*)". You need to move that somewhere else. Something like this:
Code:
.bootsector : ALIGN(1K)
{
bootloader.o(.text)
}
.auxFunctions : ALIGN(1K)
{
misc_tools.o(.auxFunctions)
*(.auxFunctions .auxFunctions.*)
}
.text : ALIGN(4K)
{
*(.text .text.*)
}
SomeGuyWithAKeyboard wrote:
I think maybe the error I was getting is caused because the "enable gate A20" subroutine in .auxFunctions
Do you really call your "enable gate A20" subroutine in vga_readMapSelect, vga_setreset_reg, and vga_ChangeWriteMode?
SomeGuyWithAKeyboard wrote:
is more than 32kb or 64kb from where it gets called which causes errors
Distance has nothing to do with it. The distance could be zero bytes and you'd still get the error if the address doesn't fit in 16 bits.
SomeGuyWithAKeyboard wrote:
(it gets called while the system is in protected mode so it shouldn't be causing issues anyway but that's not what actually happens so it is what it is)
Protected mode also has nothing to do with it. You can still have 16-bit addresses in protected mode.
SomeGuyWithAKeyboard wrote:
it just doesn't boot unless I remove the SECTION .kernel directive from the line right before the "call begin" in the bootloader.
You know the linker will rearrange sections, right?
SomeGuyWithAKeyboard wrote:
Edit: adding #pragma SECTION .kernel t the top of my top level cpp file seemed to allow it to both compile and run on qemu. It still doesn't boot anymore once I copy the image to a drive but that's been broken ever since I fixed my memory manager bugs and is hopefully a different problem.
It's better to fix your linker script instead of doing that.