I/O Address Bit Map and MINIX

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

I/O Address Bit Map and MINIX

Post by lexected »

I was reading Tanenbaum–Torvalds debate when I found this interesting post about MINIX drivers:
ast wrote: The I/O drivers are also separate processes (in the kernel, but only because the brain-dead nature of the Intel CPUs makes that difficult to do otherwise)
....
The drivers have to read and write the device registers in I/O space, and
this cannot be done in user mode on the 286 and 386. If it were possible
to do I/O in a protected way in user space, all the I/O tasks could have
been user programs, like FS and MM.
Few posts later I found this:
Jim Burns wrote: > The drivers have to read and write the device registers in I/O space, and
> this cannot be done in user mode on the 286 and 386. If it were possible
> to do I/O in a protected way in user space, all the I/O tasks could have
> been user programs, like FS and MM.
The standard way of doing that is to trap on i/o space protection
violations, and emulate the i/o for the user.
I opened original 80386 manual released in 1986 and there, chapter 8.3.2 informs about I/O permission map, which is able to handle user I/O port access using bit vectors in a task segment. Why couldn't MINIX use it? Linux 0.1 code in kernel/sched.c uses TSS, but getting through a bit of MINX3 code I couldn't find anything. Is it because of some performance penalty when using I/O permission map? Why was the emulation necessary?

I'm interested in it as I'm trying to write a small microkernel. I have also decided to have kernel-mode drivers in separate address spaces, but then I found this in TSS and I don't know if it wouldn't be better if I chose to use this ability.

Thanks,
Filip.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: I/O Address Bit Map and MINIX

Post by thepowersgang »

I'm not sure about earlier processors, but modern ones (post 386 I guess) support the IO space bitmap (if CPL>IOPL, it's used)

See Intel manuals Vol 1 Chapter 14 "Input/Output"
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: I/O Address Bit Map and MINIX

Post by Brendan »

Hi,
thepowersgang wrote:I'm not sure about earlier processors, but modern ones (post 386 I guess) support the IO space bitmap (if CPL>IOPL, it's used)

See Intel manuals Vol 1 Chapter 14 "Input/Output"
IO permission bitmap was introduced with 80386 (at the same time as paging, hardware task switching, virtual8086, etc).

Early versions of Minix were designed for 8086 and 80286 (before this stuff existed). For those CPUs you couldn't even do the "trap on i/o space protection" thing.

Also note that "it cannot be done in user mode on the 286 and 386" can be considered technically correct: it can't be done on "286 and 386" because only one of those CPUs supports it. ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

Re: I/O Address Bit Map and MINIX

Post by lexected »

Thanks. I will use it.
Post Reply