Actually it is up to the driver writer to use the proper REGISTER or PORT routine.
Use the REGISTER routines to access your device if it has BARS marked as type memory. Use the PORT routines to access your device if it has BARS marked as type IO port. This holds whether or not your processor truly supports in/out instructions or not (e.g. IA64)). The underlying routines will do the correct thing for the processor architecture.
Normally, if a device has a BAR of type IO port there is another BAR that is of type memory that maps the same set of registers (ie. you can get to the device registers using either the REGISTER or PORT routines, but you must use the addresses associated with the proper BAR with the proper access routine). There was a requirement in the PCI spec compliance that if you had registers in the IO port space that you also had to have aliases in the memory map space (i.e. you needed at least two BARS in you used PORT space). However, not all devices are compliant.
Most modern devices only have BARS of type memory, since the memory mapped address space is very large, whereas the PORT address space is very small. Large SMP boxes, can’t support many PCI devices if they all require a large PORT address space, therefore most devices should just be using memory type BARS (unless of course there is some legacy reason to have PORT address space (aka video)).
Duane.
-----Original Message-----
From: Christian Grenier [mailto:xxxxx@mcdi.com]
Sent: Friday, October 17, 2003 5:43 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] RE: IO bus address spaces
Thanks for your help Mark, on a platform that does not support native IO
operations, the PnP manager has to translate the IO address space into
memory space. I think that the Pnp Manager must query the HAL in order to
know more about the platform (supports or not IO) before to translate raw IO
resources to memory resources. Is that right?
Christian
----- Original Message -----
From: “Roddy, Mark”
To: “Windows System Software Devs Interest List”
Sent: Friday, October 17, 2003 5:08 PM
Subject: [ntdev] RE: IO bus address spaces
>
> > -----Original Message-----
> > From: Christian Grenier [mailto:xxxxx@mcdi.com]
> > Sent: Friday, October 17, 2003 4:47 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] IO bus address spaces
> >
> >
> > From http://www.wd-3.com/archive/PioAccess.htm Mark Roddy Author.
> >
> > 1. What`s the difference between REGISTER address space and
> > PORT address space.
> >
>
> The DDK docs attempt to use the terms REGISTER address space for Memory
> registers and PORT address space for IO registers. They are trying to
avoid
> the confusion of having two address spaces one of which is commonly
referred
> to as ‘Memory space’ while the other is ‘IO space’ and both are used to do
> device ‘IO’. Unfortunately they overloaded the term ‘register’ which has
its
> own set of meanings. Oh well…
>
> > Register address : is it only memory access (LOAD, STORE instruction?)
>
> Yes, but be careful here. The article is about how this can change. It
> doesn’t ever change for REGISTER space on any platform NT runs on.
>
> >
> > PORT address : it uses the instructions IN,OUT…?
> >
>
> Yes, but see above, and in the case of PORT addresses, NT, on some
> platforms, provides access to these PORTs through REGISTER space
operations.
>
> > I’m confused between READ_or_WRITE_REGISTER_XX and
> > READ_or_WRITE_PORT_XX functions.
> >
>
> These are the HAL functions that provide platform independent and correct
> access to device registers in either REGISTER space (memory) or PORT space
> (IO.)
>
> >
> >
> > 2. The difference between RAW and TRANSLATED resources.
>
> The raw resources are the resources as defined on the hardware, for
example
> a PCI device has a BAR in IO space and its config space indicates that
this
> BAR is allocated IO addresses 400-43F. The NT raw resource would be a PORT
> resource with length 40 and address 400.
>
> The translated resources are how the OS has mapped the raw resources into
> the platfrom’s bus access architecture. For example on a platform that
does
> not support native IO operations, our raw IO resource might be translated
> into a memory resource. The NT translated resource might be a REGISTER
> resource with a logical address of FFFF0400 and a length of 40.
>
> As my article indicates, you use the translated resource address space to
> decide which set of the READ/WRITE_REGISTER/PORT* functions you should use
> to access the register.
>
> =====================
> Mark Roddy
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@mcdi.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@infiniconsys.com
To unsubscribe send a blank email to xxxxx@lists.osr.com