Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading/Writing to Physical Devices

0 views
Skip to first unread message

Miles T. Smith

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to Miles.T...@gsfc.nasa.gov

What is the best way to read and write to a physical device under Windows NT?
I need to read status data and write control data to specific offsets on
a custom PCI board. I am writing a kernel-mode device driver and am not
mapping memory to the user-mode program. My specific questions are:

1. If I use the ReadFile and WriteFile API functions, how do I include
offset information? Microsoft's documentation says that offset information
is ignored in communication devices (ie., it only seems to apply to file
I/O).

2. If I add an offset to the base system virtual memory address obtained
from the MmMapIoSpace function, will the WRITE and READ macros output the
correct bus-relative addresses? For example, suppose my PCI base address
(bus-relative address) is 0x40000000 and it is ultimately translated to a
system virtual address of 0xEEBA2000. Now I want to write to the board with
an offset of 0x0A from the base address (ie., 0x4000000A). Can I simply use
the WRITE_REGISTER_UCHAR macro and write to 0xEEBA200A? If not, how do I
accomplish this mapping?

3. Has anyone out there written a simple Windows NT kernel-mode driver that
reads and writes to registers on a board (and would be willing to make the
source code available -- or at least the API calls and the dispatch calls)?
Almost all of the documentation on reads and writes relate to files. There
seems to be little documentation on reading and writing to physical devices,
the API calls that are made, and the specific functions or macros that are
used in the dispatch routine to actually do the work.

Thanks for your help.

Miles

Vadim Lebedev

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to
> MilesHi Miles,

I'd advice to you to use WinRT or WHC package, they giving direct
access to the hardware to the Win32 applications.

Or if Really like Divec Driver programming take a look on the PORTIO
sample in the DDK.

Vadim

Jamie Hanrahan, Kernel Mode Systems

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to

In article <31D960...@gsfc.nasa.gov>, "Miles T. Smith" <Miles.T...@gsfc.nasa.gov> writes:
> 1. If I use the ReadFile and WriteFile API functions, how do I include
> offset information? Microsoft's documentation says that offset information
> is ignored in communication devices (ie., it only seems to apply to file
> I/O).

It is ignored, or applied, in any driver that interprets it. The
Offset DWORDs from the OVERLAPPED structure show up in the I/O stack
location for read and write requests. Communication drivers may
ignore these fields in the stack location, but that's a decision made
by the people who wrote them; it isn't something enforced by the IO
system.

> 2. If I add an offset to the base system virtual memory address obtained
> from the MmMapIoSpace function, will the WRITE and READ macros output the
> correct bus-relative addresses? For example, suppose my PCI base address
> (bus-relative address) is 0x40000000 and it is ultimately translated to a
> system virtual address of 0xEEBA2000. Now I want to write to the board with
> an offset of 0x0A from the base address (ie., 0x4000000A). Can I simply use
> the WRITE_REGISTER_UCHAR macro and write to 0xEEBA200A? If not, how do I
> accomplish this mapping?

On Intel and MIPS platforms, yes. You may have some problems on the
Alpha. I don't know about the PPC; I suspect it'll be fine.

> 3. Has anyone out there written a simple Windows NT kernel-mode driver that
> reads and writes to registers on a board (and would be willing to make the
> source code available -- or at least the API calls and the dispatch calls)?
> Almost all of the documentation on reads and writes relate to files. There
> seems to be little documentation on reading and writing to physical devices,
> the API calls that are made, and the specific functions or macros that are
> used in the dispatch routine to actually do the work.

See portio\genport.c.

--- Jamie Hanrahan, Kernel Mode Systems, San Diego CA
drivers, internals, networks, applications, and training for VMS and Windows NT
NT driver seminars: email to semi...@solsem.com, or see http://www.solsem.com
Internet: j...@cmkrnl.com (JH645) CompuServe: 74140,2055

0 new messages