Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
i second that. Make sure you read the WikiFAQ about proper implementation of interrupt handlers and check push/pops pairing at your ASM interrupt stub ...
you are most probably messing up your stack inside an interrupt handler. have you recently added or changed some interrupt handler code?
Yes, I added code for my page_fault handler.
second that. Make sure you read the WikiFAQ about proper implementation of interrupt handlers and check push/pops pairing at your ASM interrupt stub ...
I figured out that my stack was causing this error and not my interrupt handler code. IF I change it to another value or comment it out, my code will run but nothing gets displayed. When I check my memory map from ld, it links the addresses correctly starting at 1MB.
If I look at the bochs_dump: EIP = a higher address.
I am compilng my os with cygwin. I first have it create a PE file: kernel.exe and then convert it using objcopy to binary.
Could this be my problem? The reason Im compiling it to binary is, this is the only way I know how to get bochs to run with my custom bootloader (binary).
I wonder if I should have my bootloader support elf and load a elf file instead. Can bochs load other file formats besides binary?
I wonder if I should have my bootloader support elf and load a elf file instead. Can bochs load other file formats besides binary?
Mistake: I know bochs can only load a drive or an .img of one.
This is what Ive been thinking about. At the moment my os isnt fully dependent on my custom bootloader. It can either be booted from it or booted from grub. At the moment it has support for FAT but it doesnt actually have a filesystem. If I decide to have it load elf, I want it to just load a elf file off the disk. I wonder if my already bootloader would be able to load a .elf file. Basicly the bootloader enters pmode and transfers code to the C compiler at the 1MB and then links the rest of the code. So in theory this might work, I just dont know if it will work on bochs or my pc.
The bootsector is assembled to binary, but the rest of the C code is linked to pe(.exe) and then converted to .bin. or .elf depending on how I want to load it.
EDIT: Bootloader will load a file compiled to .elf, but nothing gets displayed to the screen. Grub boots it fine.
that sounds like being a problem with your entry point ... make sure your own bootloader still jumps at the correct start address with your new modifications.
The explanation stands for elf files not loaded properly too: an ELF file has a bunch of headers before the first instructions, so the entry point is somewhere else. Moreover, the first section at file offset X has been compiled/linked to be running at virtual address Y, so if you load the file as if it was binary, you need to load it at Y-X rather than loading it at Y.
Moreover, it's common for ELF format to put section .data at a file offset which is X+sizeof(.text section) while the data need to be placed somewhere else (Y+roundup(alignment, sizeof(.text section))