PeterX wrote:Maybe this is case for *dramatic music* Captain Debug.
Haha, good one! And you're absolutely correct.
To the OP:
TimothyARyazanov wrote:The loop occurs whenever the two stage bootloader tries to read KRNL32.EXE which I wrote.
This suggests you haven't loaded the file yet.
TimothyARyazanov wrote:It appears to be a triple fault caused by the kernel file that I wrote in MinGW.
This suggests you have loaded the file. Which one is it?
Do debug, and figure out which part is failing.
1. does you bootloader load the file properly? (has nothing to do with MinGW)
2. if the file is loaded, do you parse the PE header correctly? (has nothing to do with MinGW)
3. do you copy the code segment and data segments at the positions they should be? (not MinGW related either)
4. do you identify the entry point correctly? Is it in the code segment, and does it point the instruction as it should? (not MinGW related)
5. do you transfer the control correctly? Are the registers containing the correct arguments? Does your jmp really jump where it supposed to? (not MinGW related)
6. if you put nothing more than an infinite loop in your kernel file, do simulation stop there? (not MinGW related)
7. if you replace that infinite loop with something else, does it work? (Probably linker script or could be MinGW related, as it should compile for freestanding, no libraries and no functions like printf)
Please check this list one-by-one. Don't go to the next step unless you're certain (==you debugged it successfully).
A few notes: for 1., run debugger and dump memory at load address. Do you see the MZ header there? For 4., check with objdump what instructions are in the file at _start label, and with a debugger dump the memory to see if the instructions in memory at the entry point are the same. For 7., it could be that it's not working because your load address and linking address are not the same.
One more hint: if you're using long mode, then you'll have to sign extend the entry point address, because the memory address is 64 bit, but the entry point in the file is just 32 bit. This is very important if you're using upper-half.
Cheers,
bzt