Octocontrabass wrote:
If your kernel is small enough to fit in low memory, you can load it all in real mode and then copy it above 1M after you switch to protected mode.
It's also possible to load part of the kernel in real mode, switch to protected mode to copy that part above 1M, then switch back to real mode and repeat until the entire kernel is loaded.
My favorite option is to install a GPF handler that switches to
unreal mode for transparent 32-bit addressing, although you probably don't need something that complicated.
All good ideas, I'll look into them in the future.
iansjack wrote:
Produce an elf file as well as a binary file, and use that as the file you "load" to provide symbols. Or, without symbols, you can still use gdb to debug at the assembler level.
MichaelPetch wrote:
An observation. If you want a symbol file don't use GCC/LD to output as binary. Output as ELF (with the symbols) and then use Objcopy to convert the ELF to binary.
Code:
ld -Ttext 0x1000 -m elf_i386 -o kernel/kernel.elf <list of objects>
objcopy -O binary kernel.elf kernel.bin
this would generate an intermediate ELF file called `kernel.elf` that is then converted into `kernel.bin`.
Using these two replies and the wiki article on debugging with QEMU I got it working, thanks!
MichaelPetch wrote:
If you had a project available (github etc) we could have a look.
I'll probably move there soon, and I'll let you know if and when I do.
LtG wrote:
Didn't see it mentioned yet, but you should think if you want to do osdev or write a bootloader, the two are almost completely different, in design and goals.
If you don't care about bootloaders then use GRUB or some other existing one, and it's their responsibility to load your binary, if you want to do a bootloader then do that, but it doesn't really have much to do with osdev, except it's job is to load some OS.
Good point, but since this is mainly to learn about all of whats going on under the hood I'm doing both, please and thank you.
Also good and bad news, I solved the original issue, I wasn't reading enough sectors from the disk. The bad news is that paging isn't working, but thanks to you guys I should be able to use gdb and find the problem.