Page 2 of 3
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 11:59 am
by PeterX
I strongly believe that's the reason for the BIOS freeze.
Another thing: Would you mind telling the repository link? Or don't you have the code online?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 4:24 pm
by MichaelPetch
I agree this is a better place than Stackoverflow to ask this kind of question, I'm going to give you a piece of advice I wanted to share in a comment on SO but never did. Often problems people have are often not directly related to the code they post. Switching in and out of protected mode and not getting it right could cause issues. Maybe you aren't reading enough sectors of your kernel. Maybe something is not initialized properly. Maybe you have used undefined behaviour. Maybe an optimization bug. Maybe a problem in how you build the project.
What would really help is if you posted your complete project on something like GitHub including build scripts makes files and everything else to build your kernel and allow people to see everything.
Debugging on real equipment can be a real pain. Back in the day using In Circuit Emulators for debugging were very powerful and useful. If you don't have an in circuit emulator you may wish to consider investing time into adding a gdb stub into your kernel. You can then debug over a serial port.
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 9:34 pm
by pranavappu007
PeterX wrote:Replace
with
That's important, or else you skip over part of the to-real-mode instructions
I did this:
Code: Select all
lgdt [gdt_desc_16]
jmp 0x8:bit_16_set
bit_16_set:
mov eax, cr0
But nothing

Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 9:41 pm
by pranavappu007
MichaelPetch wrote:Switching in and out of protected mode and not getting it right could cause issues. Maybe you aren't reading enough sectors of your kernel. Maybe something is not initialized properly. Maybe you have used undefined behaviour. Maybe an optimization bug. Maybe a problem in how you build the project.
But how come that the code works on one hardware but not the other?
Regarding sectors, I only need one.
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 9:44 pm
by pranavappu007
One more thing, the working hardware is where I actually compiled/assembled the code. So far it haven't worked on the 2 other (older) systems.
EDIT: I found something. I am more confused now.
I can actually call some BIOS routines! I used 10h to reset video mode and used my own 16-bit subroutine to that prints strings using 10h and it all worked! Right until int 0x13!
Then I tried to reset disk using int 13h. But no even that didn't happen.
my modified code:
Code: Select all
[bits 16]
mov dl, 0x80
mov ah, 0
;int 0x13 ;doesn't work!
mov al, 3
mov ah, 0
int 0x10 ; works!
mov bx, checkdata
call print_bx ;also works!
mov al, [0x7a00]
mov cl, [0x7a01]
mov dh, [0x7a02]
mov dl, [drivedata]
mov ch, [0x7a03]
mov bx, [0x7a06]
mov es, bx
mov bx, [0x7a04]
mov ah, 0x02
int 0x13 ;doesn't work!
If real mode has problem, how am I able to call a function from the boot loader to print a string but not even reset the disk system?!
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 10:23 pm
by Octocontrabass
The INT 0x10 routines tend to be very self-contained for a variety of reasons, so they're less likely to break if you fail to restore all of the things you've changed before you switch back to real mode.
Do you manipulate any hardware while you're in protected mode?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 10:51 pm
by pranavappu007
Octocontrabass wrote:
Do you manipulate any hardware while you're in protected mode?
hardware? I have drivers accessing keyboard, display is memory mapped so no problems there, but I use a small function to disable cursor, I also use rtc to get time. That's it I guess.
edit: my kernel is compiled in C, and I have only written specific functions in assembly to assist kernel. Does the code generated by compiler change hardware in some way?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 10:55 pm
by Octocontrabass
pranavappu007 wrote:I have drivers accessing keyboard,
Does your keyboard driver use interrupts? Do you configure the interrupt controller at all?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 10:58 pm
by pranavappu007
Octocontrabass wrote:pranavappu007 wrote:I have drivers accessing keyboard,
Does your keyboard driver use interrupts? Do you configure the interrupt controller at all?
No no, My keyboard driver is polling based. I can't use interrupts as I need bios interrupts later, right? So I disabled interrupts in protected mode.(re-nabled it in this subroutine in real mode)
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 11:07 pm
by Octocontrabass
Your keyboard driver must generate a lot of heat.
Do you change the IDT at all?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 11:16 pm
by pranavappu007
Octocontrabass wrote:Do you change the IDT at all?
No. But that does mean the BIOS routines should work, right?
I'm planning to set up interrupts later. By the way, but would you suggest an easy method for USB (HDD emulation, I think) driver to read my drive?
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 11:28 pm
by Octocontrabass
pranavappu007 wrote:But that does mean the BIOS routines should work, right?
Only if you haven't made a mistake somewhere else. It's best to load all of your data before you switch to protected mode so you don't need to worry about running BIOS routines.
pranavappu007 wrote:By the way, but would you suggest an easy method for USB (HDD emulation, I think) driver to read my drive?
Emulation is only available for INT 0x13. You need proper USB drivers to use USB without the BIOS.
Re: BIOS I/O function causing older systems to freeze
Posted: Mon Jul 06, 2020 11:39 pm
by pranavappu007
Octocontrabass wrote:
Only if you haven't made a mistake somewhere else. It's best to load all of your data before you switch to protected mode so you don't need to worry about running BIOS routines.
I did, and my kernel is working. The problem arises when I try to load files from my "filesystem". This is when I check for the existence of a filesystem in my drive, or if I disable it(then it lands into kernel successfully)if I try to load a file or filelist. And the problem is not there on my laptop which I use as daily driver.
Octocontrabass wrote:
Emulation is only available for INT 0x13. You need proper USB drivers to use USB without the BIOS.
So that means I'm stuck with int 0x13. I am using a USB and I tried to look up how USB drives work, and understood nothing(Please explain if easy).
Re: BIOS I/O function causing older systems to freeze
Posted: Tue Jul 07, 2020 12:12 am
by Octocontrabass
pranavappu007 wrote:I am using a USB and I tried to look up how USB drives work, and understood nothing(Please explain if easy).
Unfortunately, it is not easy.
Re: BIOS I/O function causing older systems to freeze
Posted: Tue Jul 07, 2020 1:13 am
by pranavappu007
Yes, this is the exact same thing I read.
what about my current setup? It actually works on my current hardware, so it almost usable.