Hello,
I was playing around with BrokenThorn's tutorials in NASM and tried to get the bootloader to read the file.
When I put in the kernel in a virtual floppy drive, it just keeps on looping.
Hope you can help me out,
Timothy Ryazanov.
Trying to get bootloader to read EXE file compiled in MinGW
- Thunderbirds747
- Member
- Posts: 83
- Joined: Sat Sep 17, 2016 2:14 am
- Location: Moscow, Russia
Trying to get bootloader to read EXE file compiled in MinGW
- Attachments
-
- os.zip
- OS written in NASM (Mike's tutorial + my code in C)
- (50.89 KiB) Downloaded 65 times
Coffee is not airplane fuel.
Re: Trying to get bootloader to read EXE file compiled in Mi
It would be useful to know where the loop occurs. In the bootloader? In which part of it? Or in the kernel? And does it reboot or does it print endlessly on the screen or does it showing the same message again after some input from the user?
Maybe this is case for *dramatic music* Captain Debug.
Maybe this is case for *dramatic music* Captain Debug.
- Thunderbirds747
- Member
- Posts: 83
- Joined: Sat Sep 17, 2016 2:14 am
- Location: Moscow, Russia
Re: Trying to get bootloader to read EXE file compiled in Mi
The loop occurs whenever the two stage bootloader tries to read KRNL32.EXE which I wrote.PeterX wrote:It would be useful to know where the loop occurs. In the bootloader? In which part of it? Or in the kernel? And does it reboot or does it print endlessly on the screen or does it showing the same message again after some input from the user?
Maybe this is case for *dramatic music* Captain Debug.
Technically, I should have used some commands from Bare Bones tutorial (OSDev Wiki)
I suddenly realised that I haven't used the command while I was asleep.
Will try again to get the kernel to load.
Cheers,
Tim
Coffee is not airplane fuel.
- Thunderbirds747
- Member
- Posts: 83
- Joined: Sat Sep 17, 2016 2:14 am
- Location: Moscow, Russia
Re: Trying to get bootloader to read EXE file compiled in Mi
It appears to be a triple fault caused by the kernel file that I wrote in MinGW.
Tried out Bochs and VirtualBox, no improvements.
Tried out Bochs and VirtualBox, no improvements.
Coffee is not airplane fuel.
Re: Trying to get bootloader to read EXE file compiled in Mi
You are referencing an array over a simple char pointer. Seems wrong to me. There is no array, I think.
Re: Trying to get bootloader to read EXE file compiled in Mi
Haha, good one! And you're absolutely correct.PeterX wrote:Maybe this is case for *dramatic music* Captain Debug.
To the OP:
This suggests you haven't loaded the file yet.TimothyARyazanov wrote:The loop occurs whenever the two stage bootloader tries to read KRNL32.EXE which I wrote.
This suggests you have loaded the file. Which one is it?TimothyARyazanov wrote:It appears to be a triple fault caused by the kernel file that I wrote in MinGW.
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
Re: Trying to get bootloader to read EXE file compiled in Mi
I would start by using Bochs with reboot on triple fault disabled.
That way you can inspect the register and memory contents and actually see what's going on instead of guessing
That way you can inspect the register and memory contents and actually see what's going on instead of guessing
Re: Trying to get bootloader to read EXE file compiled in Mi
in core/main.c:
That is wrong, I think.
Use something like:
Code: Select all
vidptr[j] = ' ';
Use something like:
Code: Select all
vidptr++;
*vidptr = ' ';