[comp.sys.sun] Sun 4/1xx vs Sun 4/2xx using mmap

paul@altar.ee.byu.edu (Paul Rawlins) (12/12/90)

I have a VME board which is mapped in user space via mmap().  The board is
in vme24d32 space.  The location of the registers are shown below.  The
routine which calls mmap() is at the tail-end of this message.


              $FFFF    ----------------------------
	               |		       	  |
                       |     RESERVED             |
	               |	        	  |
	      $813F    ----------------------------
	               |	        	  |
                       |     UPPER REGISTERS      |
                       |                          |
              $8100    ----------------------------
                       |                          |
                       |                          |
                       |     LOWER REGISTERS      |
                       |                          |
                       |                          |
              $8000    ----------------------------
	               |                          |
	               |                          |
	               |     DATA                 |
                       |                          |
                       |                          |
              $0000    ----------------------------

I am able to access both the lower and upper registers when running on a
Sun 3/180 and Sun 4/110.  However, when running on a Sun 4/260 and Sun
4/280, I can access the lower registers, but I have difficulty accessing
the upper registers.  More specifically, I try to reset a chip through
$8119 and read its status through $810D.  On the Sun 4/2X0 either the chip
does not get properly reset, or the status register is read incorrectly.

Does anyone know of any peculularities between the different machines?  I
have combed through the documentation and contacted Sun support, but still
haven't come up with any explanation.  Any suggestions would be greatly
appreciated.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Paul Rawlins
paul@ee.byu.edu

int init_lkio(offset)
off_t offset;
{
	int fd, pgsize, len;
	caddr_t iova;
	int result;

	if ((fd = open("/dev/vme24d32",O_RDWR)) < 0) {
		if (errormsg)
			ErrorMsg("Cannot open /dev/vmeXX");
		return(FALSE);
		}

	len = 0xFFFF;
	pgsize = getpagesize();

	len = len + pgsize - (len % pgsize);	/* align to page boundary */

	if ((iova = (caddr_t)valloc(len)) == (caddr_t) 0) {
		if (errormsg) 
			ErrorMsg("Unable to allocate memory"); 
		return(FALSE);
		}

	result = mmap((caddr_t)iova, len, PROT_READ|PROT_WRITE,
		MAP_SHARED, fd, offset);

	if (result ==  -1) {
		if (errormsg) 
			ErrorMsg("mmap failed"); 
		return(FALSE);
		}

	lkb = (link_st *)result;

	return(TRUE);
}

schultz@halley.serc.3m.com (John C. Schultz) (12/31/90)

Possible solution #1

I use mmap() calls to access image processing boards as VME24D16 devices.
This works fine on a Sun 3, including the ability to do symbolic debugging
of the VME board's registers.  Howver on a Sun 4/330, SunOS 4.0.3, trying
to get gdb (or dbx) to access the registers hangs the cpu (L1-a time).  As
I recall, this is a problem with the device driver under 4.0.3.

Probable solution #2

Using the VME24D32 device implies that your VME board has 32 bit
addressing which in turn implies that it has both a P1 and a P2 VME
backplane connector, both of which must be connected to the SUN VME
backplane connectors.  My guess is that for whatever reason, your board
should be addressed as a VME24D16 device.

John C. Schultz                    EMAIL: schultz@halley.est.3m.com
3M Company,  Building 518-01-1     WRK: +1 (612) 733-4047
1865 Woodlane Drive, Dock 4,       Woodbury, MN  55125