OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 8:53 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 11:59 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
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?


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 4:24 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
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.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 9:34 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
PeterX wrote:
Replace
Code:
jmp 0x8:$+7

with
Code:
jmp 0x8:$+5

That's important, or else you skip over part of the to-real-mode instructions

I did this:
Code:
lgdt [gdt_desc_16]
   jmp 0x8:bit_16_set
bit_16_set:
   mov eax, cr0

But nothing :cry:

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 9:41 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 9:44 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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:
[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?!

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 10:23 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
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?


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 10:51 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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?

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 10:55 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
pranavappu007 wrote:
I have drivers accessing keyboard,

Does your keyboard driver use interrupts? Do you configure the interrupt controller at all?


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 10:58 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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)

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 11:07 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
Your keyboard driver must generate a lot of heat.

Do you change the IDT at all?


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 11:16 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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?

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 11:28 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
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.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Mon Jul 06, 2020 11:39 pm 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
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).

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Tue Jul 07, 2020 12:12 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
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.


Top
 Profile  
 
 Post subject: Re: BIOS I/O function causing older systems to freeze
PostPosted: Tue Jul 07, 2020 1:13 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 91
Octocontrabass wrote:

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.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 184 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group