O sorry, i really did put 0F instead 07, but in the code this is right.
And the ticks sounds regular, i know this because i've played a game with very fast growing numbers by almost 10 years (since i was 7), so i could determine either this is regular or not regular, and this gets more clear when you disables DMA and Burst mode, forcing the IDE controller to stay much slower, the showstat ticks get slower, and the code takes more time to crash, but the ticks are always regular.
I already tried to disable showstat, but the system still crashes in a random time, and in the aproximate max time that the code took when it was using showstat.
[SOLVED]Entering protected mode: tutorial disambiguation
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Entering protected mode: tutorial disambiguation
If you feel you aren't making any further progress, perhaps you could provide a floppy disk image for me so that I can get at the machine code directly - I'd then be able to index it and run it through my monitor program. I don't have the means to convert an assembly program into machine code and to get it onto a disk, so that's why I'd need the disk image. I would then also find it much easier to read as I'd be working with the whole thing in decimal form. (Rawwrite is the easiest way to make a floppy disk image - if you don't know where to download it from there's a link to it on my site.)
First though, I'm not sure what values you're now using in your GDT as you may have changed them from the ones below:-
These differ from the values I use, even though they are setting up four descriptors to do exactly the same thing as mine. I always work in decimals, so mine look like:-
0,0,0,0,0,0,0,0,
255,255,0,0,0,155,207,0,
255,255,0,0,0,147,207,0,
255,255,0,0,0,155,0,0,
255,255,0,0,0,147,0,0.
Yours are (or used to be):-
0,0,0,0,0,0,0,0,
255,255,0,0,0,154,207,0,
255,255,0,0,0,146,207,0,
255,255,0,0,0,154,15,0,
255,255,0,0,0,146,15,0,
I can't remember what the second last byte of each descriptor does, but I know that mine work and I've been using them for a decade without problems. I've just written a lot of code to jump in and out of real mode from protected mode specifically to use the BIOS to load and save from/to floppy disks, and it works beautifully. My OS is also capable of running with the interrupts either on or off, so the only significant difference in what you're doing is that you're accessing a hard drive via the BIOS (which is something I have never done). Try my GDT values and see if it cures the problem. Next, cut out the actual Int 13 calls and see if your program still crashes. If it does, that will give us a much clearer idea of where the bug lies.
First though, I'm not sure what values you're now using in your GDT as you may have changed them from the ones below:-
Code: Select all
GDT:
dq 00000000000000000h
dw 0FFFFh
dw 00000h
db 00h
db 010011010b
db 011001111b
db 00h
dw 0FFFFh
dw 00000h
db 00h
db 010010010b
db 011001111b
db 00h
dw 0FFFFh
dw 00000h
db 00h
db 010011010b
db 000001111b
db 00h
dw 0FFFFh
dw 00000h
db 00h
db 010010010b
db 000001111b
db 00h
0,0,0,0,0,0,0,0,
255,255,0,0,0,155,207,0,
255,255,0,0,0,147,207,0,
255,255,0,0,0,155,0,0,
255,255,0,0,0,147,0,0.
Yours are (or used to be):-
0,0,0,0,0,0,0,0,
255,255,0,0,0,154,207,0,
255,255,0,0,0,146,207,0,
255,255,0,0,0,154,15,0,
255,255,0,0,0,146,15,0,
I can't remember what the second last byte of each descriptor does, but I know that mine work and I've been using them for a decade without problems. I've just written a lot of code to jump in and out of real mode from protected mode specifically to use the BIOS to load and save from/to floppy disks, and it works beautifully. My OS is also capable of running with the interrupts either on or off, so the only significant difference in what you're doing is that you're accessing a hard drive via the BIOS (which is something I have never done). Try my GDT values and see if it cures the problem. Next, cut out the actual Int 13 calls and see if your program still crashes. If it does, that will give us a much clearer idea of where the bug lies.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
Re: Entering protected mode: tutorial disambiguation
I FINALLY FOUND THE ERROR!!!.
Listen to this history:
I was trying to isolate the code piece-by-piece, trying to find out what was wrong.
I booted by the floppy and turned my eyes to the screen, an not even a second after, something took the attention of my vision in the right corner of this: It was the diskette LED turning off, what meant that the motor was turning off.
Then i remembered that the BIOS manages the turning off of the motors of the diskette drives, what means the BIOS still was running, and means that the interrupt flag was, somehow, enabled.
Then i realized everithing:
The PIC still was generating the IRQ0 ticks, and still was calling BIOS real-mode interrupts during the whole code, even inside the protected mode, where it could cause exceptions.
So i changed the code of each protected-mode routine, by adding a CLI to it, and DONE!!!.
This happened at randomic times because the protected-mode routines was too fast, but even been fast sometimes a IRQ0 ticks happened inside protected-mode, destroying everything.
THANKS!!!
And, how do i set this topic as solved?
Listen to this history:
I was trying to isolate the code piece-by-piece, trying to find out what was wrong.
I booted by the floppy and turned my eyes to the screen, an not even a second after, something took the attention of my vision in the right corner of this: It was the diskette LED turning off, what meant that the motor was turning off.
Then i remembered that the BIOS manages the turning off of the motors of the diskette drives, what means the BIOS still was running, and means that the interrupt flag was, somehow, enabled.
Then i realized everithing:
The PIC still was generating the IRQ0 ticks, and still was calling BIOS real-mode interrupts during the whole code, even inside the protected mode, where it could cause exceptions.
So i changed the code of each protected-mode routine, by adding a CLI to it, and DONE!!!.
This happened at randomic times because the protected-mode routines was too fast, but even been fast sometimes a IRQ0 ticks happened inside protected-mode, destroying everything.
THANKS!!!
And, how do i set this topic as solved?
Re: Entering protected mode: tutorial disambiguation
No great surprise really. As you were told, the bios regularly re-enables interrupts when you make bios calls.interrupt flag was, somehow, enabled.
If a trainstation is where trains stop, what is a workstation ?
Re: Entering protected mode: tutorial disambiguation
Edit your initial post, changing the subject line to read "...[SOLVED]".guilherme wrote:And, how do i set this topic as solved?
Every good solution is obvious once you've found it.