Problem with int 0x13 sector read

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nekton
Posts: 4
Joined: Sat May 02, 2009 10:03 am

Problem with int 0x13 sector read

Post by nekton »

Hello,

I'm making a multitasking OS in real mode, and trying to use the BIOS to read sectors from floppy but I have a problem with it.

I have three interrupt handlers, timer, keyboard and int 0x60. In them I instantly disable interrupts with the cli instruction, and in the end again enable them with sti instruction.

I have int 0x60 handler handling the system calls. Inside this handler I call the BIOS int 0x13 to read sectors from a floppy. It seems that BIOS at some point temporarily enables interrupts, and this causes one of my two other interrupt handlers to pop up messing everything up and crashing the system. Maybe because of those interrupt handlers are trying to do a task switch, but in reality the CPU is executing in the kernel.

So can you tell me what are my options? Can I keep using BIOS by somehow adjusting the interrupt priority levels, or do I have to program the floppy disk controller directly, ...?
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Problem with int 0x13 sector read

Post by Troy Martin »

Excuse me for saying this, but, why the crap do you have custom timer and keyboard IRQs? The normal BIOS ones accessed through the BIOS interrupts should be fine.

Maybe it's some multitasking thing I haven't grasped and particularly don't mind not having to... :D


Oh, and welcome!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: Problem with int 0x13 sector read

Post by bontanu »

No you can not...

The BIOS is not designed to be multi-thread or multi-task safe.

Hence BIOS will assume that for the time of it's execution it has full control over them machine and it can do whatever it likes (including enabling interrupts or going into PMODE temporarily or reprogramming hardware).

Then, If you are going to write your own drivers (as every OS developer should) then I guess that it is more easy to do this in PMODE or LONG MODE and forget about RMODE and BIOS for anything else but the initial start-up.

Alternatively you could:
1) keep on using BIOS and forget about multitasking (standard DOS clone).
2) Critical sections everywhere to protect against the BIOS... (slow and a lot of work and guess work to be done)
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
nekton
Posts: 4
Joined: Sat May 02, 2009 10:03 am

Re: Problem with int 0x13 sector read

Post by nekton »

Alright thank you for your help. I don't know why everyone keeps suggesting I should start using protected mode :) I'm quite determined to keep on using real mode, I like the challenge, smallness, etc. I guess I'm going to have to start learning how to program the floppy disk controller then. Otherwise the kind of OS I'm writing isn't going to have that many drivers, keyboard, floppy, serial port, and maybe later mouse and vga for the GUI.
nekton
Posts: 4
Joined: Sat May 02, 2009 10:03 am

Re: Problem with int 0x13 sector read

Post by nekton »

Whoa, I found out a way to keep using the simple int 0x13 and not have to do the whole floppy disk controller programming at this point of development. Before reading the floppy with the int 0x13 I set the timer and keyboard interrupts to dummy handlers that do nothing more than "out 0x20, 0x20, iret", and after reading restore the normal interrupts handlers.
Post Reply