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 am having some trouble with getting my code to work and when I ran it in Bochs, I got a weird error. Does anybody know what this error means and how I would go about solving it.
Your Os is trying to return from an interrupt with IRET but the values on the stack are not accurate or appropriate. Its a problem with the interrupt and stack working together. If you are trying tp set up a stack frame for stack based task switching then you frame setup code is not working properly!
if you paste code, it will be easier to know exactly what is the problem.
HI,
you are setting ESP to 4GB without paging on in your boot code!!! You should put it an adress that EXISTS such as 1mb,2mb or 4mb!
Try that and see.
then the problem occurs when it wants to execute the c kernel try this, put
hlt
before
jmp LINEAR_CODE_SEL:0x1000
this will halt the cpu, if there isn't any problem then the boot code is fine and the problem is with the kernel part.
how did you write the kernel binary file to the disk?
all so add
-fwritable-string --nostdlib --freestanding (check the syntac in gcc info files) when you are compiling the kernel and remove the del *.bin and *.o commands from you compile.bat, you might be deleting the kernel before you even write it to disk!
did you first try halting the cpu as i suggested above?
what happened when you did?(if everything is fine, you should not get any messages from BOCHS, it will just stop)
Then tell me how you compiled the kernel(you can paste the lines in you next post)
ans how you wrote it to the disk?
hi,
i once had a problem when i started my kernel and the only way i was able to solve it was by writing out my adresses in full in the linker script! so try
0x00001000 instead of 0x1000!
I noticed something. When I set my pmode stack which is esp = 0xffff, it says running in bogus memory and when I look at the bochs dump, it says 00000fff.
If I set esp = 0x100000 (1 MB) it loads, displays a whole screen of blue symbols and then halts = running in bogus memory.
If I set esp = 0xFFFFFFFF it loads and halts like a: hlt.
its the kernel code!
what is makeboot?
I think you should use a program like partcopy to copy the bootcode to the first sector and then the kernel to the 2nd sector of a real disk and then use partcopy to make an image of the disk
eg
partcopy -f0 0 1680000 test.img will create an image of the entire floppy called test.img
partcopy kernel.bin 200 <size of the kernel> -f0 will copy the kernel.bin file to sector 2 of the floppy(sectors numbers start from 1 not 0)
I tried what you suggested and I get the same results. Look at the bochs memory dump and see if you see anything weird. In my pmode bootsector, ESP = 0x100000.