Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Fred Zwarts <ZWARTS@KVIASV.KVI.nl>
Subject: Re: PCI Sparse Address Space
Date: 1996/09/18	[thread overview]
Message-ID: <51obq0$b9u@info.service.rug.nl> (raw)
In-Reply-To: 51k83t$c70@mashie.cs.umd.edu


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




  parent reply	other threads:[~1996-09-18  4:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-16  4:00 PCI Sparse Address Space Jeff Hollingsworth
1996-09-17  4:00 ` Hubert Robitaille
1996-09-17  4:00 ` Dirk Grunwald
1996-09-19  4:00   ` Fred Kleinsorge
1996-09-18  4:00 ` Fred Zwarts [this message]
1996-09-18  4:00 ` Fred Kleinsorge
1996-09-19  4:00 ` zrepachol
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox