Skip to contentSkip to conversation

Issuing BIOS interrupts in Linux

DISCUSSION Rajat Jain 5 participants 8 messages Aug 4, 2006 – Aug 9, 2006 1 message not in the archive

lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

Hi List,

I want to issue BIOS interrupts in Linux (both user space & kernel space are fine). More specifically I want to issue BIOS interrupt 13h for accessing disk using the BIOS routines. How can I do so (issue the BIOS interrupt)?

In the file /proc/interrupts on my system, the interrupt 13 h (19 decimal) is used by some USB driver:

16:          0        Phys-irq  uhci_hcd:usb1, uhci_hcd:usb4
17:          2        Phys-irq  peth0
18:     637572        Phys-irq  eth1
19:          0        Phys-irq  uhci_hcd:usb2
20:    1275249        Phys-irq  uhci_hcd:usb3

So will I be able to use the BIOS routine in this case?

TIA,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw

In a single sentence,
"you cannot".
The reason is that bios interrupts can only be used in real mode and not in protected mode. Linux runs in protected mode, and so this would not be possible.

What is it you are trying to do? Maybe there's a better way to do it... (by using the block device subsystem, for instance)
-rahul

Quoted 18 lines · Rajat Jain

Hi List,

I want to issue BIOS interrupts in Linux (both user space & kernel space are fine). More specifically I want to issue BIOS interrupt 13h for accessing disk using the BIOS routines. How can I do so (issue the BIOS interrupt)?

In the file /proc/interrupts on my system, the interrupt 13 h (19 decimal) is used by some USB driver:

 16:          0        Phys-irq  uhci_hcd:usb1, uhci_hcd:usb4
 17:          2        Phys-irq  peth0
 18:     637572        Phys-irq  eth1
 19:          0        Phys-irq  uhci_hcd:usb2
 20:    1275249        Phys-irq  uhci_hcd:usb3

So will I be able to use the BIOS routine in this case?

Quoted 9 lines

TIA,

Rajat

--

Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw
Quoted 15 lines

Hi List,

I want to issue BIOS interrupts in Linux (both user space & kernel space are fine). More specifically I want to issue BIOS interrupt 13h for accessing disk using the BIOS routines. How can I do so (issue the BIOS interrupt)?

Rajat

Quoted 5 lines · Rahul Iyer

In a single sentence,
"you cannot".
The reason is that bios interrupts can only be used in real mode and not in protected mode. Linux runs in protected mode, and so this would not be possible.

Uh ... :-(

Quoted 4 lines
Quoted 4 lines

What is it you are trying to do? Maybe there's a better way to do it... (by using the block device subsystem, for instance)
-rahul

Actually I was thinking that if it is possible to perform all the Disk IO operations using the BIOS routines, then why can't we write a SINGLE disk driver that will work with all the kinds of disks. The idea was ofcourse based on the assumption that the driver will be able to do all disk operation using the BIOS interupts, instead of actually communicating with the Disk controller hardware.

So all this seems like a bad idea ... or should I say TOTALLY IMPOSSIBLE?

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#4 lore raw
Quoted 3 lines · Rajat Jain

Actually I was thinking that if it is possible to perform all the Disk IO operations using the BIOS routines, then why can't we write a SINGLE disk driver that will work with all the kinds of disks.

Because that would be incredibly slow. You could only have one I/O request in flight at a time, and the system could not run other processes while I/O was being done.

Quoted 1 line

So all this seems like a bad idea ... or should I say TOTALLY IMPOSSIBLE?

It might be possible, but it is still a very bad idea :)

Signature · 8 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
author
#5 lore raw
Quoted 9 lines · Rik van Riel
Quoted 3 lines · Rajat Jain

Actually I was thinking that if it is possible to perform all the Disk IO operations using the BIOS routines, then why can't we write a SINGLE disk driver that will work with all the kinds of disks.

Because that would be incredibly slow. You could only have one I/O request in flight at a time, and the system could not run other processes while I/O was being done.

Oh ... I got you. That sure sounds like a lot of baggage, but despite all the disadvantages you just mentioned, it will STILL be of lot of use to me.

Quoted 4 lines
Quoted 2 lines

So all this seems like a bad idea ... or should I say TOTALLY IMPOSSIBLE?

It might be possible, but it is still a very bad idea :)

Okay ... NOW we are talking. Any idea / links / references on where should I start looking for? How tough / practical is it to switch from protected mode to real mode and back? Is it possible at all (in linux)?

Thanks,

Rajat

--

Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/
#6 lore raw
Quoted 4 lines

Okay ... NOW we are talking. Any idea / links / references on where should I start looking for? How tough / practical is it to switch from protected mode to real mode and back? Is it possible at all (in linux)?

Paging only works in protected mode. And once paging is turned off, all the kernel code is unusable because it is linked at PAGE_OFFSET + something. ( 3GB + )

Disabling paging itself is not easy, let alone going to real mode (where only 64KB memory is available ) and coming back.

Nilesh

Signature · 6 lines
And ye shall know the truth (source) and the truth shall set you free.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
#7 lore raw
Quoted 11 lines · Nilesh Agrawal
Quoted 4 lines

Okay ... NOW we are talking. Any idea / links / references on where should I start looking for? How tough / practical is it to switch from protected mode to real mode and back? Is it possible at all (in linux)?

Paging only works in protected mode. And once paging is turned off, all the kernel code is unusable because it is linked at PAGE_OFFSET + something. ( 3GB + )

Disabling paging itself is not easy, let alone going to real mode (where only 64KB memory is available ) and coming back.

on an x86 real mode has access to 1MB of memory. Not 64K. Frequently this is quoted a 640K because the upper part of the real
mode address space may contain graphics adapters, and roms.

uClinux is now part of the distribution kernel it is intended for
systems without an MMU. But basically uClinux means linux without
paging PAGE_OFFSET = 0;

On some processors some faults must be handled in real mode.

Switching from protected mode to real mode and back may not be all
that hard. But doing something while in real mode could be extremely hard.
You can not use any Linux resource that assumes protected mode -
that means pretty much everything.
Basically you would have to get a hunk of memory you can access in
Real Mode, switch to real mode do your task switch back and copy the results from your memory.
While you were in real mode, interrupts would probably have to be
disabled.

The x86 also has something called virtual x86 mode which might be
more useful. I do not remember all the details, but I think you could create a linux process, that executed in virtual x86 mode,
that would execute concurrently with virtual x386 processes. That
said Linux has no builtin facilities to work with virtual x86 processes.

Quoted 5 lines

Nilesh

Signature · 14 lines
Dave Lynch 					  	    DLA Systems
Software Development:  				         Embedded Linux
717.627.3770 	       [email protected] 	  http://www.dlasys.net
fax: 1.253.369.9244 			           Cell: 1.717.587.7774
Over 25 years' experience in platforms, languages, and technologies too numerous to list.

"Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Albert Einstein

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
author
#8 lore raw

Hi,

Firstly, thanks for the directions.

Quoted 3 lines

uClinux is now part of the distribution kernel it is intended for
systems without an MMU. But basically uClinux means linux without
paging PAGE_OFFSET = 0;

I could not find IA32 / x86 compatibility explicitly mentioned on the uClinux site. Can uClinux work only on embedded (which ACTUALLY do not have MMU), or can it also work on x86 (which has MMU, but I'm ok with the idea of doing away with it)?

Quoted 7 lines

On some processors some faults must be handled in real mode.

Switching from protected mode to real mode and back may not be all
that hard. But doing something while in real mode could be extremely hard.
You can not use any Linux resource that assumes protected mode -
that means pretty much everything.

:-( ... That is sad.

Quoted 5 lines

Basically you would have to get a hunk of memory you can access in
Real Mode, switch to real mode do your task switch back and copy the results from your memory.
While you were in real mode, interrupts would probably have to be
disabled.

Ok. Basically my purpose is to write a minimal disk driver (that will be independent of the disk hardware) using BIOS interrups. So if I want to copy a sector from disk to memory, here is how I should proceed:

1) Get hold of a memory chunk that is "usable" in real mode ( <1 mb physical memory).
2) switch to real mode.
3) Issue BIOS interrupt (13h) that will copy the desired sector to this memory.
4) Switch back to protected mode.
5) Now copy data from this memory to the actual "usable" memory (any memory accessible to the kernel)

Does the above seem ok?

Thanks,

Rajat

Quoted 7 lines

The x86 also has something called virtual x86 mode which might be
more useful. I do not remember all the details, but I think you could create a linux process, that executed in virtual x86 mode,
that would execute concurrently with virtual x386 processes. That
said Linux has no builtin facilities to work with virtual x86 processes.

Quoted 1 line

Thanks ... I will check it out.

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs