Page 1 of 1

Problem with int 0x13 sector read

Posted: Sat May 02, 2009 10:18 am
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, ...?

Re: Problem with int 0x13 sector read

Posted: Sat May 02, 2009 10:37 am
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!

Re: Problem with int 0x13 sector read

Posted: Sat May 02, 2009 12:04 pm
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)

Re: Problem with int 0x13 sector read

Posted: Sat May 02, 2009 10:22 pm
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.

Re: Problem with int 0x13 sector read

Posted: Sun May 03, 2009 3:32 am
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.