*BSD News Article 98984


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.Hawaii.Edu!news.uoregon.edu!hammer.uoregon.edu!news.radio.cz!nntprelay.mathworks.com!news.mathworks.com!chi-news.cic.net!su-news-hub1.bbnplanet.com!su-news-feed4.bbnplanet.com!news.bbnplanet.com!newsfeed1.uswest.net!news.uswest.net!tera.com!not-for-mail
From: Eric McRae <eric@tera.com>
Newsgroups: comp.unix.bsd.freebsd.misc,comp.unix.bsd.freebsd.misc
Subject: Need help with VME memory access
Date: Thu, 03 Jul 1997 10:34:38 -0700
Organization: Tera Computer Company
Lines: 61
Message-ID: <33BBE2AE.167EB0E7@tera.com>
NNTP-Posting-Host: baldr.tera.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 4.1.4 sun4m)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:43931

I'm running RTMX (variation on OpenBSD) on an MVME162 with a 32 Mbyte
VME RAM card.

Using 162-Bug, I set the VME Master #1 start address to 0x40000000 and
end to 0x41ffffff.  I can read/write the entire VME RAM using a tiny
loop assembled using 162-Bug.

The following tiny application however, produces a segmentation fault
due to an attempt read from the VME RAM virtual address:

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>

typedef unsigned long u32;

int
main( int argc, char **argv )
{
    char buf[8192];
    volatile u32 *vmeP;
    int resultN;

    int fd = open("/dev/vmel0", O_RDWR, 0);
    if( fd == -1 )
        perror("Open Failed");

    vmeP = (u32 *)mmap( 0, 0x2000, PROT_READ|PROT_WRITE,
        MAP_FILE, fd, 0xc0000000 );

    if( vmeP == (u32 *)-1 )
        perror("mmap Failed");
    else
    {
        printf("VME starts at %x\n", (u32)vmeP);
        printf("Contents = %x\n", *vmeP);
    }
}

Running this program results in the following output on the tty

VME starts at 400d000
Bus error (core dumped)

And the following output is produced on the console (Thanks to a printf
left in vmelmmap()):
vmel c0000000 pa 40000000
vmel c0001000 pa 40001000
vmel c0000000 pa 40000000

vmelmmap actually returns 0xc0000000 >> 12 or 0xc0000.  I don't know why
mmap() is returning 0x400d000 or if that matters.

Can anyone tell me what I'm doing wrong?

-- 
Eric McRae, Electro-Logic Machines, Inc.  eric@elmi.com (consultant to:)
Tera Computer Company	2815 Eastlake Ave E., Seattle WA, 98102
eric@tera.com, Phone: 206.325.0800x479, FAX: 206.325.2433