Issuing BIOS interrupts in Linux

Issuing BIOS interrupts in Linux

am 04.08.2006 13:00:03 von 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?

TIA,

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

Re: Issuing BIOS interrupts in Linux

am 05.08.2006 03:20:33 von 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.

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

On Fri, 2006-08-04 at 16:30 +0530, Rajat Jain wrote:
> 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
>
> --
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Issuing BIOS interrupts in Linux

am 05.08.2006 15:11:04 von 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)?

> Rajat

> On 8/5/06, Rahul Iyer wrote:
> > 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 ... :-(

> > 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Issuing BIOS interrupts in Linux

am 05.08.2006 16:54:44 von Rik van Riel

Rajat Jain wrote:

> 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.

> 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 :)

--
"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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Issuing BIOS interrupts in Linux

am 05.08.2006 17:26:16 von Rajat Jain

On 8/5/06, Rik van Riel wrote:
> Rajat Jain wrote:
>
> > 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.

>
> > 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/

Re: Issuing BIOS interrupts in Linux

am 05.08.2006 18:33:48 von Nilesh Agrawal

> 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


--
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Issuing BIOS interrupts in Linux

am 09.08.2006 03:50:29 von dhlii

Nilesh Agrawal wrote:
>> 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.
>
>
> Nilesh
>
>


--
Dave Lynch DLA Systems
Software Development: Embedded Linux
717.627.3770 dhlii@dlasys.net 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: Issuing BIOS interrupts in Linux

am 09.08.2006 07:14:31 von Rajat Jain

Hi,

Firstly, thanks for the directions.

> 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)?

>
> 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.

> 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

>
> 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.
> >

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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs