Port Mapping in Device Drivers

You should not use MmMapIoSpace on a translated Port resource, only on a
translated Memory resource.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Monisha Barooah
Sent: Wednesday, September 14, 2005 6:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Port Mapping in Device Drivers

Hello Everybody,
I had a small query regarding the port resources allocated by the pnp
manager which are accessed in the startdevice routine of the driver.

I have been trying to map the translated port resources allocated by the
pnp manager for our driver as follows:

“DeviceExtension->PortMappedSpace.MappedAddress = (PULONG)
MmMapIoSpace(resourceTrans->u.Port.Start, resourceTrans->u.Port.Length,
MmNonCached);”

I found that there seems to be something going wrong for which I am
unable to read the register values correctly. As per the hardware specs, I
am attempting to read the register values as DWORDs as:

“RegValue = READ_PORT_ULONG((PULONG)
DeviceExtension->PortMappedSpace.MappedAddress);”

A write to the mapped locations keeps in the value there and I am able
to read the values correctly after performing the write but I am unable to
see the default values of the register after system power up.

Is it compulsory that we require doing the mapping of the port resources
by using the API ‘MmIoSpace’? We are doing our development for an x86
system. I tried out by trying to read directly from the port pointers
provided in the translated resources without performing any mapping for the
port resources as below:

“RegValue = READ_PORT_ULONG((PULONG)
((PVOID)(ULONG_PTR)resourceTrans->u.Port.Start.QuadPart));”

but still the same results.

Can anyone suggest what can be the problem here for this behavior?
Anything missing that needs to be done or anything going wrong somewhere?

Thanking you.
With Regards,
Monisha.


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

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