How to access IO ports from the user mode

I am wondering is there an API or an IOCTL for the application to read/write
the IO ports of an PCI device.

Thank you,
shakeel

NO.

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

-----Original Message-----
From: shakeel [mailto:xxxxx@yahoo.com]
Sent: Monday, June 07, 2004 5:58 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to access IO ports from the user mode

I am wondering is there an API or an IOCTL for the
application to read/write
the IO ports of an PCI device.

Thank you,
shakeel


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@ati.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Or, to be even more obtuse, YES: it is called “your device driver”.

=====================
Mark Roddy


From: Calvin Guan [mailto:xxxxx@ati.com]
Sent: Monday, June 07, 2004 6:22 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

NO.

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

-----Original Message-----
From: shakeel [mailto:xxxxx@yahoo.com mailto:xxxxx]
> Sent: Monday, June 07, 2004 5:58 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How to access IO ports from the user mode
>
>
> I am wondering is there an API or an IOCTL for the
> application to read/write
> the IO ports of an PCI device.
>
> Thank you,
> shakeel
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
http:
>
> You are currently subscribed to ntdev as: xxxxx@ati.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</http:></mailto:xxxxx>

Oh ABSOLUTELY!! It’s called DOS.


Gary G. Little
Seagate Technologies, LLC

“shakeel” wrote in message news:xxxxx@ntdev…
> I am wondering is there an API or an IOCTL for the application to
read/write
> the IO ports of an PCI device.
>
> Thank you,
> shakeel
>
>
>

Or “Linux” ?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
Sent: Tuesday, June 08, 2004 10:53 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to access IO ports from the user mode

Oh ABSOLUTELY!! It’s called DOS.


Gary G. Little
Seagate Technologies, LLC

“shakeel” wrote in message news:xxxxx@ntdev…
> I am wondering is there an API or an IOCTL for the application to
read/write
> the IO ports of an PCI device.
>
> Thank you,
> shakeel
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Linux allows this stupidity?

OK, let’s forget about it as a stable OS :slight_smile:

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Moreira, Alberto”
To: “Windows System Software Devs Interest List”
Sent: Tuesday, June 08, 2004 7:04 PM
Subject: RE: [ntdev] How to access IO ports from the user mode

> Or “Linux” ?
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
> Sent: Tuesday, June 08, 2004 10:53 AM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] How to access IO ports from the user mode
>
>
> Oh ABSOLUTELY!! It’s called DOS.
>
> –
> Gary G. Little
> Seagate Technologies, LLC
>
> “shakeel” wrote in message news:xxxxx@ntdev…
> > I am wondering is there an API or an IOCTL for the application to
> read/write
> > the IO ports of an PCI device.
> >
> > Thank you,
> > shakeel
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Nope, Linux does not support poking/peeking of any PCI device (or any other
IO port). Unless of course, you load a kernel module to do that, and you
have to be root to do that, just like you would have to have admin priv’s on
the Windows machine to load a driver to poke PCI device.

Now, on a more serious note, I seem to remember that someone wrote (in a
magazine or web-site, maybe DDJ) about some (undocumented?) call to Windows
that would allow you to change the IOPL-mapping of a IO port, which would
allow you to do what the OP wanted. Anyone have a link to that, or any
comments? It was several years back, so I may have “misremembered”, as well
as it may have been changed so that Windows no longer have this “feature”.

I believe there is such a function in Linux, (if you’re root)…


Mats

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Tuesday, June 08, 2004 4:04 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

Or “Linux” ?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
Sent: Tuesday, June 08, 2004 10:53 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to access IO ports from the user mode

Oh ABSOLUTELY!! It’s called DOS.


Gary G. Little
Seagate Technologies, LLC

“shakeel” wrote in message news:xxxxx@ntdev…
> > I am wondering is there an API or an IOCTL for the application to
> read/write
> > the IO ports of an PCI device.
> >
> > Thank you,
> > shakeel
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named
> addressee only. It
> contains information that may be confidential. Unless you are
> the named
> addressee or an authorized designee, you may not copy or use
> it, or disclose
> it to anyone else. If you received it in error please notify
> us immediately
> and then destroy it.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Well, you do it through a device driver. But if you’re doing video, direct
rendering goes direct to the iron.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
xxxxx@3Dlabs.com
Sent: Tuesday, June 08, 2004 11:25 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

Nope, Linux does not support poking/peeking of any PCI device (or any other
IO port). Unless of course, you load a kernel module to do that, and you
have to be root to do that, just like you would have to have admin priv’s on
the Windows machine to load a driver to poke PCI device.

Now, on a more serious note, I seem to remember that someone wrote (in a
magazine or web-site, maybe DDJ) about some (undocumented?) call to Windows
that would allow you to change the IOPL-mapping of a IO port, which would
allow you to do what the OP wanted. Anyone have a link to that, or any
comments? It was several years back, so I may have “misremembered”, as well
as it may have been changed so that Windows no longer have this “feature”.

I believe there is such a function in Linux, (if you’re root)…


Mats

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Tuesday, June 08, 2004 4:04 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

Or “Linux” ?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
Sent: Tuesday, June 08, 2004 10:53 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to access IO ports from the user mode

Oh ABSOLUTELY!! It’s called DOS.


Gary G. Little
Seagate Technologies, LLC

“shakeel” wrote in message news:xxxxx@ntdev…
> > I am wondering is there an API or an IOCTL for the application to
> read/write
> > the IO ports of an PCI device.
> >
> > Thank you,
> > shakeel
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named
> addressee only. It
> contains information that may be confidential. Unless you are
> the named
> addressee or an authorized designee, you may not copy or use
> it, or disclose
> it to anyone else. If you received it in error please notify
> us immediately
> and then destroy it.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Mats is correct, there is a DDJ article on how to do this in 1995 I believe.
The package was called directio, and required a driver to open the ports for
the application. I don’t recomend this for anyone doing a product that will
leave a controlled environment, but I have suggested this to customers of
embedded equipment and test equipment. We shouldn’t say never.

For that matter the portio sample of the DDK will access registers, and
could certainly be modified to handle PNP if needed, again not for
production but for controlled circumstances.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

wrote in message news:xxxxx@ntdev…
> Nope, Linux does not support poking/peeking of any PCI device (or any
other
> IO port). Unless of course, you load a kernel module to do that, and you
> have to be root to do that, just like you would have to have admin priv’s
on
> the Windows machine to load a driver to poke PCI device.
>
> Now, on a more serious note, I seem to remember that someone wrote (in a
> magazine or web-site, maybe DDJ) about some (undocumented?) call to
Windows
> that would allow you to change the IOPL-mapping of a IO port, which would
> allow you to do what the OP wanted. Anyone have a link to that, or any
> comments? It was several years back, so I may have “misremembered”, as
well
> as it may have been changed so that Windows no longer have this “feature”.
>
> I believe there is such a function in Linux, (if you’re root)…
>
> –
> Mats
>
> > -----Original Message-----
> > From: Moreira, Alberto [mailto:xxxxx@compuware.com]
> > Sent: Tuesday, June 08, 2004 4:04 PM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How to access IO ports from the user mode
> >
> >
> > Or “Linux” ?
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
> > Sent: Tuesday, June 08, 2004 10:53 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] How to access IO ports from the user mode
> >
> >
> > Oh ABSOLUTELY!! It’s called DOS.
> >
> > –
> > Gary G. Little
> > Seagate Technologies, LLC
> >
> > “shakeel” wrote in message news:xxxxx@ntdev…
> > > I am wondering is there an API or an IOCTL for the application to
> > read/write
> > > the IO ports of an PCI device.
> > >
> > > Thank you,
> > > shakeel
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@compuware.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> > The contents of this e-mail are intended for the named
> > addressee only. It
> > contains information that may be confidential. Unless you are
> > the named
> > addressee or an authorized designee, you may not copy or use
> > it, or disclose
> > it to anyone else. If you received it in error please notify
> > us immediately
> > and then destroy it.
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

> Nope, Linux does not support poking/peeking of any PCI device (or any other

IO port). Unless of course, you load a kernel module to do that, and you
have to be root to do that, just like you would have to have admin priv’s on
the Windows machine to load a driver to poke PCI device.

Same as in Windows, just use the PORTIO DDK sample.

BTW - FreeBSD has some i386_xxx syscalls, so, maybe this is doable in UNIXen
without adding a module.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Hi!

I am wondering is there an API or an IOCTL for the
application to read/write the IO ports of an PCI
device.

You might want to have a look at this:

http://www.beyondlogic.org/porttalk/porttalk.htm

The “allowio” app uses a kernel-mode driver to change
the IOPL bitmap. Might suffice.
Sourcecode included.
I think it’s free software, but check it out at the
homepage though.

AFAIK there’s no direct support from the OS.
And there shouldn’t be too.

Regards,

Paul Groke

…being first passed to a kernel pipe from the app to X11 server :slight_smile:

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Moreira, Alberto”
To: “Windows System Software Devs Interest List”
Sent: Tuesday, June 08, 2004 7:24 PM
Subject: RE: [ntdev] How to access IO ports from the user mode

> Well, you do it through a device driver. But if you’re doing video, direct
> rendering goes direct to the iron.
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of
> xxxxx@3Dlabs.com
> Sent: Tuesday, June 08, 2004 11:25 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How to access IO ports from the user mode
>
>
> Nope, Linux does not support poking/peeking of any PCI device (or any other
> IO port). Unless of course, you load a kernel module to do that, and you
> have to be root to do that, just like you would have to have admin priv’s on
> the Windows machine to load a driver to poke PCI device.
>
> Now, on a more serious note, I seem to remember that someone wrote (in a
> magazine or web-site, maybe DDJ) about some (undocumented?) call to Windows
> that would allow you to change the IOPL-mapping of a IO port, which would
> allow you to do what the OP wanted. Anyone have a link to that, or any
> comments? It was several years back, so I may have “misremembered”, as well
> as it may have been changed so that Windows no longer have this “feature”.
>
> I believe there is such a function in Linux, (if you’re root)…
>
> –
> Mats
>
> > -----Original Message-----
> > From: Moreira, Alberto [mailto:xxxxx@compuware.com]
> > Sent: Tuesday, June 08, 2004 4:04 PM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How to access IO ports from the user mode
> >
> >
> > Or “Linux” ?
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Gary G. Little
> > Sent: Tuesday, June 08, 2004 10:53 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] How to access IO ports from the user mode
> >
> >
> > Oh ABSOLUTELY!! It’s called DOS.
> >
> > –
> > Gary G. Little
> > Seagate Technologies, LLC
> >
> > “shakeel” wrote in message news:xxxxx@ntdev…
> > > I am wondering is there an API or an IOCTL for the application to
> > read/write
> > > the IO ports of an PCI device.
> > >
> > > Thank you,
> > > shakeel
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@compuware.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> > The contents of this e-mail are intended for the named
> > addressee only. It
> > contains information that may be confidential. Unless you are
> > the named
> > addressee or an authorized designee, you may not copy or use
> > it, or disclose
> > it to anyone else. If you received it in error please notify
> > us immediately
> > and then destroy it.
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@compuware.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> The contents of this e-mail are intended for the named addressee only. It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or disclose
> it to anyone else. If you received it in error please notify us immediately
> and then destroy it.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

> Well, you do it through a device driver. But if you’re doing

video, direct rendering goes direct to the iron.

Yeah, but that’s because the low-level driver tells the OS that the
application should be able to access the hardware directly. And this is a
performance enhancement that you have to accept if you want reasonably
performance, and as I’m sure you’re aware, people don’t pay top dollar for a
graphics card without expecting to get a decent performance. If you have to
pass everything from user mode to kernel mode and back again for even the
most minute pixel operation, performance gets very reduced. This is why
Windows NT 4.0 had a completely different interface than WinNT 3.x.

[Snip]


Mats

> -----Original Message-----

From: Don Burn [mailto:xxxxx@acm.org]
Sent: Tuesday, June 08, 2004 4:27 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to access IO ports from the user mode

Mats is correct, there is a DDJ article on how to do this in
1995 I believe.
The package was called directio, and required a driver to
open the ports for
the application. I don’t recomend this for anyone doing a
product that will
leave a controlled environment, but I have suggested this to
customers of
embedded equipment and test equipment. We shouldn’t say never.

I agree, there’s no reason why you should need this in a production
environment.

But it’s very handy to be able to write a regular C/C++ application to try
some concept out, assuming you have a trivial piece of hardware.

I did this for the PowerNow! hardware on AMD’s Athlon Mobile chips, just to
play around with it a bit.

Of course, some operations will definitely never work, for instance when a
device needs pages to be locked in memory (DMA buffers etc).


Mats

> -----Original Message-----

From: xxxxx@3Dlabs.com [mailto:xxxxx@3Dlabs.com]
Sent: Tuesday, June 08, 2004 11:58 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

This is why
Windows NT 4.0 had a completely different interface than WinNT 3.x.

And now Windows Longhorn has a completely different interface than any
previous NTs in terms of the graphic driver stack and I’m banging my head on
it right now.

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

I dont know about performance/reliablity issues, but VDD is the way to have direct port access, NTVDM is based on that, and 16bit codes can still access, but as Don said it is portio that can be used as an example. For Win98, since the dos is alive there, there is a way to get to the port i/o w/o much trouble ( like coming up with a krnl mode component to expose the accessiblity …

Well, I dont want to sound like the old comments of Andy Roony (well, I probably did sound that way) “You know I dont understand why people goto psycho-therapist !. They save their precious income, time, and go thru the hassel of reservation for appointments, set his(her) schedule around, etc.etc”. As soon as they get their, the most of the time therapist says - U ARE SCREWED UP. - Andy Roony (198x).

Also I dont want you say anything against Linux, since I heard an old joke that why mathematicians dont get Nobel prizes ?. Someone suspects that a mathematicial took away Alferd’s wife. If I hear someone is talking a lot against Linux, I might have to find Linus and check his backgroud :slight_smile:

-pro

Yes, I’ve seen that. I’m working on current versions of Windows at the
moment, but I’m sure we’ll have lots of fun with the Longhorn implementation
later on.


Mats

-----Original Message-----
From: Calvin Guan [mailto:xxxxx@ati.com]
Sent: Tuesday, June 08, 2004 5:28 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to access IO ports from the user mode

-----Original Message-----
From: xxxxx@3Dlabs.com [ mailto:xxxxx@3Dlabs.com
mailto:xxxxx ]
> Sent: Tuesday, June 08, 2004 11:58 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How to access IO ports from the user mode

> This is why
> Windows NT 4.0 had a completely different interface than WinNT 3.x.

And now Windows Longhorn has a completely different interface than any
previous NTs in terms of the graphic driver stack and I’m banging my head on
it right now.

-
Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</mailto:xxxxx>

> I dont know about performance/reliablity issues, but VDD is the way to have
direct port

access, NTVDM is based on that

VDD does not give the ability of direct port access. It just emulates the ports
for 16bit apps, nothing more.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

On Tue, 8 Jun 2004 16:57:34 +0100, wrote:

>> Well, you do it through a device driver. But if you’re doing
>> video, direct rendering goes direct to the iron.
>
> Yeah, but that’s because the low-level driver tells the OS that the
> application should be able to access the hardware directly. And this is a
> performance enhancement that you have to accept if you want reasonably
> performance, and as I’m sure you’re aware, people don’t pay top dollar
> for a
> graphics card without expecting to get a decent performance. If you have
> to
> pass everything from user mode to kernel mode and back again for even the
> most minute pixel operation, performance gets very reduced. This is why
> Windows NT 4.0 had a completely different interface than WinNT 3.x.
>
> [Snip]

There seems to be some old rumors being reiterated in this thread, here is
how I see it.

1. The “good” thing for doing hardware access in a (trusted) user mode
process is that it improves system stability by limiting the potential
damage caused by a bad driver. This is good for debugging. It is also
good in production systems whenever stability is more important than
performance. “Pure” Microkernel systems do this exclusively. “Modified”
Microkernel systems (such as NT) put some drivers in kernel mode, others
in user mode.

2. In NT 3.x, the video hardware access was done from a DLL in
the trusted CSRSS process, while the video port/miniport driver
handled the subset of video calls that could not be done in user
mode. The video port also used some kernel calls to modify the
IOPL map for the CSRSS process only. In NT 4.0 and NT 5.x this
precaution was dropped for speed reasons, causing much debate over
the speed / stability tradeoff this implied.

3. In all versions of NT on i386, both the Video miniport, as well as
any other kernel mode driver that offers services for old DOS programs,
may use special calls to modify the IOPL map for NTVDM, if the driver
writer / hardware maker is sure that for that particular I/O port, there
is no possibility of compromising overall system security from a
dedicated
16 bit virus etc. This is most thoroughly documented in the context of
“VGA compatible” video miniports.

4. NuMega DriverStudio includes a rapid prototyping tool which lets you
enable I/O access from test programs, the tool also supports PCI and PnP.

5. On Linux, the situation is this:
Normal processes cannot touch hardware.
There is a “capability” (The Linux equivalent of an NT privilege), which
allows a user mode process to make a special system call to modify its
own IOPL.
By default, this “capability” is granted only to administrators (root),
and can be dropped as desired through policy or restricted tokens.
This is used by: The user mode display subsystem (equivalent to CSRSS on
NT 3.1), hardware diagnostic programs, and various PnP code run only
during boot. In each case, this is done to reduce the amount of
trusted kernel code.

6. Both Linux 2.7 (look for “early user mode”) and Longhorn (WDF) are
openly
proposing to move a lot of not-speed-critical driver and kernel code to
trusted user mode processes as a means of reducing the chance of crashes
or kernel mode security holes.

In the hope that this clears things up a bit.

Jakob


#include <disclaimer.h></disclaimer.h>

(1) You can look at the VDD for the serial ports. This is very interesting
to me in the fact that you are “emulating” hardware and then “remapping” it
hardware to events and threads indeed into a user api. Again as Mr.
Shatskih points out when you access the ports in say in the serial VDD you
are “reflected” back to your callback you supply. By the way the sample
code for the serial port VDD has a “few” bugs in it which I have fixed.

(2) Again you can circumvent the Windows OS with a kernel driver to get this
desired functionality. I would go down the Mr. Don Burn’s path.

(3) Very interesting stuff. Number 1 in particular.
(1) How to take a hardware design. State machine. Registers, Memory Mapped
Io, Interrupts etc. Serial is a good place to start because alot of Dos
Apps wrote to the hardware.
(2) Develop an Ring 3 api for this hardware that users use to communicate to
this and then “insure” that this api will enable a VDD to work and how to
write the VDD. Interesting!

Thanks
Mike Jones - I hope my 2 cents is not too distracting. Just thanks for the
opportunity.
What is a honest man?

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
> > I dont know about performance/reliablity issues, but VDD is the way to
have
> direct port
> >access, NTVDM is based on that
>
> VDD does not give the ability of direct port access. It just emulates the
ports
> for 16bit apps, nothing more.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>