Page 1 of 1

I/O Address Bit Map and MINIX

Posted: Tue Dec 31, 2013 3:06 pm
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.

Re: I/O Address Bit Map and MINIX

Posted: Tue Dec 31, 2013 8:20 pm
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"

Re: I/O Address Bit Map and MINIX

Posted: Thu Jan 02, 2014 12:49 am
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

Re: I/O Address Bit Map and MINIX

Posted: Thu Jan 02, 2014 5:02 am
by lexected
Thanks. I will use it.