* PCI Sparse Address Space
@ 1996-09-16 4:00 Jeff Hollingsworth
1996-09-17 4:00 ` Dirk Grunwald
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jeff Hollingsworth @ 1996-09-16 4:00 UTC (permalink / raw)
Does anyone know how to generate "sparse space" addresses on a DEC Alpha?
The situation is that I have a PCI board that I map into an application's
address space. The mapping seems to work fine, but the board is getting
mapped as a "sparse" address space. This seems to be a trick to let
the Alpha processors generate byte and word requests to hardware (rather than
the 64 bit requests the Alpha wants to generate). The problem I am having is
how do I generate the appropriate addresses to read word y at a location x
bytes from that start of the mapped area? If anyone knows how this works (or
better yet has macros to generate addresses), please send me mail.
Thanks.
--
-------------------------------------------------------------------------------
Jeff Hollingsworth Work: (301) 405-2708
Internet: hollings@cs.umd.edu FAX: (301) 405-6707
WWW: http://www.cs.umd.edu/~hollings Home: (301) 649-5829
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PCI Sparse Address Space
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
1996-09-17 4:00 ` Dirk Grunwald
@ 1996-09-17 4:00 ` Hubert Robitaille
1996-09-18 4:00 ` Fred Kleinsorge
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hubert Robitaille @ 1996-09-17 4:00 UTC (permalink / raw)
To: Jeff Hollingsworth
There are only few informations about the sparse address space in the
Digital documentation because normally it should be use through a device
driver with read or write PIO command.
The device driver can use some functions like "read_pio" or "io_copyin"
to access to the sparse space and the address conversion is done by the
kernel.
To access the sparse space from a user program, you must convert your
address "by hand" (there is no specific function") and I amn't sure that
the conversion is not hardware dependent.
You can find the appropriate information when you have a VME interface
(which is behind the PCI and uses the same sparse space). In this case
you have some examples which include macros to access the VME space in
sparse mode from a user program. With the software for the DWPVC PCI-VME
adapter (the Bit3 PCI-VME interface), there is a file "qb_mmap_test.c".
I have found too on my machine (a 2100A) the file "lh_test.c" in the
directory "/usr/examples/devdriver/lh100" . The "README" file specifies
that this example is for a AXPVME system.I think you should find this
file on your system.
--
Hubert Robitaille mailto:hrobitaille@encore.fr
Responsable Support Logiciel
Encore Computer S.A. http://www.encore.com
B.P. 54 78185 St Quentin en Yvelines Cedex France
Tel.: (33) 1 30 23 36 00 Fax : (33) 1 34 60 43 95
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PCI Sparse Address Space
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
@ 1996-09-17 4:00 ` Dirk Grunwald
1996-09-19 4:00 ` Fred Kleinsorge
1996-09-17 4:00 ` Hubert Robitaille
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Dirk Grunwald @ 1996-09-17 4:00 UTC (permalink / raw)
Here's my experienced based on trying to port the driver for the
Myricom Myrinet PCi interface to the DEC Alpha.
The system start up code (not certain if it's the SROM bootup or the
SRM firmware) puts a device into "sparse space" based on a number of
reasons. The importance of this varies from machine to machine.
For example, the AlphaServer 2100 PCI interface (the "T3" chip, I
think) maps any device as "sparse" if it marks a memory region as "not
prefetchable". The myrinet has a 256KByte on-chip SRAM memory that was
marked "not prefetchable", and thus communication with that memory
requires the PIO functions. More recently, I've received EEPROM
upgrades that mark it as "prefetchable", and that should fix the
problem ( but I haven't had time to plug it into the 2100's).
By comparison, a system using the 21070 or 21170 PCI interface chipset
doesn't appear to care diddly about the "prefetch" bit. On both EV4
and EV5 based systems, the same Myrinet card can be mapped into a
"dense" address space.
If you trace the code path for the code that reads/writes sparse
address space, you'll get down ( in .../src/kernel/arch/alpha/hal) to
a hardware abstraction layer that diddles the appropriate PCI bridge
in the proper manner.
We couldn't afford the overhead of those function calls for the
Myrinet interface and asked Myricom to spin another FPGA with the
prefetch bit marked as prefetchable.
Dirk Grunwald Assoc. Prof, Univ. of Colorado at Boulder
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PCI Sparse Address Space
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
` (2 preceding siblings ...)
1996-09-18 4:00 ` Fred Kleinsorge
@ 1996-09-18 4:00 ` Fred Zwarts
1996-09-19 4:00 ` zrepachol
4 siblings, 0 replies; 7+ messages in thread
From: Fred Zwarts @ 1996-09-18 4:00 UTC (permalink / raw)
Jeff Hollingsworth writes:
>
> Does anyone know how to generate "sparse space" addresses on a DEC Alpha?
>
> The situation is that I have a PCI board that I map into an application's
> address space. The mapping seems to work fine, but the board is getting
> mapped as a "sparse" address space. This seems to be a trick to let
> the Alpha processors generate byte and word requests to hardware (rather than
> the 64 bit requests the Alpha wants to generate). The problem I am having is
> how do I generate the appropriate addresses to read word y at a location x
> bytes from that start of the mapped area? If anyone knows how this works (or
> better yet has macros to generate addresses), please send me mail.
>
> Thanks.
>
> --
> -------------------------------------------------------------------------------
> Jeff Hollingsworth Work: (301) 405-2708
> Internet: hollings@cs.umd.edu FAX: (301) 405-6707
> WWW: http://www.cs.umd.edu/~hollings Home: (301) 649-5829
This is documented in the VxWorks documentation. The VxWorks documentation is
on the first documentation CD-ROM and can be read with the BOOKREADER.
Basically the idea is that the Sparse addressing mapping sets up a mapping of
a base hardware address and a base physical address at a given starting point.
Suppose hardware base address H is mapped to physical base address P.
For each hardware address there are a few physical addresses that can be used:
P + 0 is used for byte transfers
P + 8 is used for word (16-bit) transfers
P + 16 is used for tribyte transfers
P + 24 is used for longword (32-bit) transfers
P + 120 is used for quadword (64-bit) transfers
There are a few mor transfer modes, like shifted byte transfers.
Note that the processor always accesses each address as a quadword, even if the
bus performs only a byte, word, or longword cycle.
Hardware address H + 1 is mapped to physical address P + 128, etc.
Here follows some code that I use to access VME modules on an AXPvme taken from
http://www.kvi.nl/kvi$root/kvimain/cdaq/VME.h
and
http://www.kvi.nl/kvi$root/kvimain/cdaq/VME.c
/* Perform a read in sparse space as documented in the VxWorks programmer's
Guide, appendix C.1: "VxWorks for Alpha AXP I/O Architecture". This
documentation is not completely clear, but I understand that the following
algorithm can be used:
The address to be accessed is
srcAddress | busOffset << 5 |datasize << 3
where srcAddress is returned from adpCreateMapPath, busOffset is the offset
from the base VME address and datasize is 0 for byte, 1 for word, 3 for
integer and 15 for quadword access. A further complication is that the data
resulting from the read operations is stored in a uint64 and must be
shifted by an amount equal to ((busOffset % 4) * 8).
*/
/* Define macros to find the virtual address: */
#define D08ptr(srcA, busO) \
((volatile uint64*)((uint64)(srcA) + ((uint64)(busO) << 5)))
#define D16ptr(srcA, busO) \
((volatile uint64*)((uint64)(srcA) + ((uint64)(busO) << 5) | 8))
/* 1<<3 = 8 */
#define D32ptr(srcA, busO) \
((volatile uint64*)((uint64)(srcA) + ((uint64)(busO) << 5) | 24))
/* 3<<3 = 24 */
#define D64ptr(srcA, busO) \
((volatile uint64*)((uint64)(srcA) + ((uint64)(busO) << 5) | 120))
/* 15<<3 = 120 */
/* Define macros to shift the data */
#define ShiftIn(busO, data) \
((data) << (((busO) & 3) << 3))
#define ShiftOut(busO, data) \
((data) >> (((busO) & 3) << 3))
static uint8 ReadD08 (const void *srcA, const uint64 busO)
{ return (uint8) ShiftOut (busO, *D08ptr (srcA, busO)); }
static uint16 ReadD16 (const void *srcA, const uint64 busO)
{ return (uint16) ShiftOut (busO, *D16ptr (srcA, busO)); }
static uint32 ReadD32 (const void *srcA, const uint64 busO)
{ return (uint32) ShiftOut (busO, *D32ptr (srcA, busO)); }
static uint64 ReadD64 (const void *srcA, const uint64 busO)
{ return (uint64) ShiftOut (busO, *D64ptr (srcA, busO)); }
static void WrtD08 (const void *srcA, const uint64 busO, const uint8 data)
{ *D08ptr (srcA, busO) = ShiftIn (busO, (uint64) data); }
static void WrtD16 (const void *srcA, const uint64 busO, const uint16 data)
{ *D16ptr (srcA, busO) = ShiftIn (busO, (uint64) data); }
static void WrtD32 (const void *srcA, const uint64 busO, const uint32 data)
{ *D32ptr (srcA, busO) = ShiftIn (busO, (uint64) data); }
static void WrtD64 (const void *srcA, const uint64 busO, const uint64 data)
{ *D64ptr (srcA, busO) = ShiftIn (busO, data); }
Fred Zwarts KVI Internet: F.Zwarts@KVI.nl
Phone: (+31)50-3633619 Telefax: (+31)50-3634003
X400: C=nl;ADMD=400net;PRMD=surf;O=KVI;S=Zwarts;G=Fred
Zernikelaan 25, 9747 AA Groningen, The Netherlands
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PCI Sparse Address Space
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
1996-09-17 4:00 ` Dirk Grunwald
1996-09-17 4:00 ` Hubert Robitaille
@ 1996-09-18 4:00 ` Fred Kleinsorge
1996-09-18 4:00 ` Fred Zwarts
1996-09-19 4:00 ` zrepachol
4 siblings, 0 replies; 7+ messages in thread
From: Fred Kleinsorge @ 1996-09-18 4:00 UTC (permalink / raw)
Jeff Hollingsworth wrote:
>
> Does anyone know how to generate "sparse space" addresses on a DEC Alpha?
>
> The situation is that I have a PCI board that I map into an application's
> address space. The mapping seems to work fine, but the board is getting
> mapped as a "sparse" address space. This seems to be a trick to let
> the Alpha processors generate byte and word requests to hardware (rather than
> the 64 bit requests the Alpha wants to generate). The problem I am having is
> how do I generate the appropriate addresses to read word y at a location x
> bytes from that start of the mapped area? If anyone knows how this works (or
> better yet has macros to generate addresses), please send me mail.
>
Generally speaking, you don't want to do this. Your code will be both platform and
chip specific. Operating system code, including device drivers, use O/S calls that
are vectored for the correct semantics. The reason I say this is that partial word
I/O is implemented in a number of ways on different platforms.
The TurboChannel machines use a asymetric mechanism that allows byte writes, but
not byte reads. The DEC2000 (aka Jensen, aka AXP150) uses a sparse space with
a different address "swizzle" than the rest of the current generation of machines.
And the next generation of machines will have a flat byte addressable I/O space
(that is, no more dense/sparse).
Having said that. If you are willing to deal with the fact that this code will
have transportability issues... Here is the current sparse space on machines
other than the AXP150 and Turbochannel systems.
Sparse space is implemented by permuting the address to allow the offset into a
doubleword, and the size of the access to be placed into the address bits. This
is done by shifting the virtual address left 5 places. The length of the transfer
is 0 = byte, 1 = short, 2 = tri-byte, and 3 = doubleword. This is shifted by 3
and or'ed into the address. This is the "swizzled" address.
The low order of the address looks like:
+-+-+-+-+-+-+-+-+
|x|B|B|L|L|0|0|0|
+-+-+-+-+-+-+-+-+
with BB being the byte offset into the doubleword, and LL being the length of
the I/O. Note that some combinations aren't legal or useful, like a tribyte
I/O with a offset more than 1.
Now. In addition, the data for the transfer needs to be swizzled, or "byte laned".
This is simply taking the offset (the BB above) and using this to shift the data
left by (BB * 8) bits.
So, sparse space has a "stride" of 32 bytes of virtual address space between
each physical byte of memory.
In the end you wind up writing a couple macros:
extern unsigned long CSR_ADDRESS; // This would get the mapped base address
#define swizzleShift 5
#define ioLong (3 << 3)
#define SWIZZLE_ADDRESS(a) (a << swizzleShift)
#define SWIZZLE_DATA(d,a) (((int)(d)) << ((((unsigned long)(a)) & 3) * 8))
#define UNSWIZZLE_DATA(d,a) (((int)(d)) >> (((unsigned long)(a)) & 3) * 8))
#define ADDRESS_BYTE(a) (unsigned int *)((unsigned long) CSR_ADDRESS + \
(unsigned long) SWIZZLE_ADDRESS(a))
#define ADDRESS_DW(a) (unsigned int *)((unsigned long) CSR_ADDRESS + \
(unsigned long) SWIZZLE_ADDRESS(a) + ioLong)
#define outp(a, d) { \
volatile unsigned int *rP; \
rP = ADDRESS_BYTE(a); \
MB(); \
*rP = SWIZZLE_DATA(d & 0xFF, a);\
}
You should be able to figure out the rest from here. Reading is the inverse of
writing. The MB() (memory barrier) prevents the write from collapsing in the
write buffer (that is, if you try to write the same location twice in succession,
without the MB() it is probable that the first write will be thrown out). If you
know that you are not writing to the same address within say, the last 6 writes -
then you don't need the memory barrier - OR if you don't care that some of the
writes will be thrown out - i.e. frame buffer writes typically only care about
the final value, but CSR writes usually need all writes to actually happen.
Note that the mapped virtual address is already "swizzled" as it were, so you
are swizzling the offset (the "a" argument in the macros) and adding to the
base to get the effective address.
Good luck... cause if you get it wrong, you will machine check the system if the
address is in PCI address space. And when you get a machine with a flat byte
addressable space, it will also not work, and likely will machine check (since
you will get a completely bogus address if you try and swizzle things).
I tell people to try *not* to do this by mapping I/O space into a usermode
application (like the X server - which is why I know how to do this), and to
instead write a device driver and use the O/S callbacks instead.
_Fred
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: PCI Sparse Address Space
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
` (3 preceding siblings ...)
1996-09-18 4:00 ` Fred Zwarts
@ 1996-09-19 4:00 ` zrepachol
4 siblings, 0 replies; 7+ messages in thread
From: zrepachol @ 1996-09-19 4:00 UTC (permalink / raw)
In Article <51k83t$c70@mashie.cs.umd.edu>
hollings@cs.umd.edu (Jeff Hollingsworth) writes:
>
>Does anyone know how to generate "sparse space" addresses on a DEC Alpha?
With angst, agro, and hardware dependance...
Get the chipset docs off digital.com. You wtll want the ones
that match the system you are using, 21070/1/2. This gives
all the horrors and detail of byte, word, tribyte accessing
etc...
I can understand why the ARM has been upgraded to include
byte and word instructions now.
~Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PCI Sparse Address Space
1996-09-17 4:00 ` Dirk Grunwald
@ 1996-09-19 4:00 ` Fred Kleinsorge
0 siblings, 0 replies; 7+ messages in thread
From: Fred Kleinsorge @ 1996-09-19 4:00 UTC (permalink / raw)
Dirk Grunwald wrote:
>
> Here's my experienced based on trying to port the driver for the
> Myricom Myrinet PCi interface to the DEC Alpha.
>
> The system start up code (not certain if it's the SROM bootup or the
> SRM firmware) puts a device into "sparse space" based on a number of
> reasons. The importance of this varies from machine to machine.
>
> For example, the AlphaServer 2100 PCI interface (the "T3" chip, I
> think) maps any device as "sparse" if it marks a memory region as "not
> prefetchable". The myrinet has a 256KByte on-chip SRAM memory that was
> marked "not prefetchable", and thus communication with that memory
> requires the PIO functions. More recently, I've received EEPROM
> upgrades that mark it as "prefetchable", and that should fix the
> problem ( but I haven't had time to plug it into the 2100's).
>
> By comparison, a system using the 21070 or 21170 PCI interface chipset
> doesn't appear to care diddly about the "prefetch" bit. On both EV4
> and EV5 based systems, the same Myrinet card can be mapped into a
> "dense" address space.
>
> If you trace the code path for the code that reads/writes sparse
> address space, you'll get down ( in .../src/kernel/arch/alpha/hal) to
> a hardware abstraction layer that diddles the appropriate PCI bridge
> in the proper manner.
>
> We couldn't afford the overhead of those function calls for the
> Myrinet interface and asked Myricom to spin another FPGA with the
> prefetch bit marked as prefetchable.
>
In a different thread, I started to explain this...
The selection of a sparse versus dense space address is made by the console
firmware as it configures the system. The selection criteria is see if the
memory is prefetchable. If it is, then you get dence, if it isn't then you
get sparse.
The reason for the decision is simple: If a memory-like region can be
read without side effects (prefetchable implies this) then the assumption
is made that all I/O to it can be made using doubleword reads and writes -
and using read-mod-write sequences for partial word I/O. If however the
region is non-prefetchable, then the assumption is made that arbitrary reads
can have side-effects, and doubleword read-mod-writes are probably not
sufficient.
So, the O/S gets this physical address from the PCI card, and the choice has
been made... or has it?
Now we get down to platform decisions (as opposed to Alpha chip decisions). Each
platform is based on a collection of parts, including the PCI interface and bridge
chips. And each lays out some scheme for address spaces. On the AlphaStations,
and on a few of AlphaServers - sparse space and dense space physically overmap each
other. That is, the address for any physical location in dense space is also available
in sparse space. This means that given the physical address from the PCI card,
the operating system can permute it into either sparse or dense space as requested.
Now, on _most_ AlphaServer boxes (like the 2100), the address space available for
dense and sparse regions was not the same, and so they could not be completely
overmapped. So, the firmware makes them physically disjoint (one of the registers
like the HAE). A physical address in dense space cannot be mapped in dense space,
and vice versa. So now the physical address that you got from the PCI card will
dictate how the card is accessable, and the decision is dictated by the prefetchable
attribute.
In general, the rule of thumb is: If the PCI card does not have the prefetchable
bit set, then you should be prepared to only use sparse space. If the bit is set
then you should be prepared to use dense space. If you want to use a mixture, or
have a preference to use the other space, then you will need to check the status
from your attempt to map the space and make sure that it succeeds. This is exactly
what I did in writing frame buffer logic - I have a sparse-only implementation, and
a mixed dense/sparse implementation - and I select which one to use based on the
availability of dense space.
Now. Having said this. The decision to make sparse and dense disjoint was done,
I think, because the hardware group did not want to end up in the situation where
some cards could be overmapped, and some cards could not - depending on the number,
location, and requirements of the cards for PCI address space. It is purely a
software decision made by the firmware... and could be changed if there was a
compelling reason. Or perhaps it would be interesting to have a mechanism to
alter the address assignment on a card-by-card basis (either in the O/S or in the
firmware).
Hope this clarifies things a little.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1996-09-19 4:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-09-16 4:00 PCI Sparse Address Space Jeff Hollingsworth
1996-09-17 4:00 ` Dirk Grunwald
1996-09-19 4:00 ` Fred Kleinsorge
1996-09-17 4:00 ` Hubert Robitaille
1996-09-18 4:00 ` Fred Kleinsorge
1996-09-18 4:00 ` Fred Zwarts
1996-09-19 4:00 ` zrepachol
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox