MVME2431: how to use vme?

Simone Piccardi Simone.Piccardi at
Wed May 12 02:27:04 EST 1999

Hi David,
thanks for the file. 

This time at least I can give to you an answer: looking carefully in the
Gabriel directory I found that vmetest.c is a new file, and I discover
also that the patches were newer than the ones I used )this was the
reason of the compilation failing). I downloaded them, recompiled
everything, and I could also compile testvme.c.

I find also a new file universe.tex in /usr/src/linux/drivers/vme/ with
some more info (I'm reading it carefully in this moment).

In any case I used your program and by simply changing the "window" with
"attr" (both in VME_window than in VME_GET_WINDOW and VME_SET_WINDOW) I
could compile it on the new patches and run it without error.

The problem is in the next step, when I try to write in the remapped
region I get a bus error (probably is right, because I don't know what
that region is), but at least when I try to read I have the dataway
display showing me activities on the bus, and this is enogh for the

Now the problem is to understand how to map a board that has a fixed
address set by jumpers in this way, and I'm still very confused by all
these VME_AM... constants.
I'm sending the "improved" version of your program in attachement, the
only things that it does is to read (showing bus activity) and get a bus
error when it try to write.

Simone Piccardi
Microsoft is NOT the answer. Microsoft is the Question.
The answer is: "NO!"
-------------- next part --------------
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vme.h>
#include <errno.h>
#include <sys/mman.h>

#define PATTERN 0x55

#define MBUFSIZE (1<<20)
/* static char membuf[MBUFSIZE]; */

int main(int argc, char ** argv)
        u_char *mp,*rp;	
  	int fd;
	int error;
	int i, j;

	VME_attr memdesc = {
	  base:  0xd00000, 
	  limit: 0xdfffff,
	  flags: VME_AM_A24(16) | VME_USE_MAP | VME_USE_RMW
	VME_atomic_access rmw = {
	  offset: 0,

	fd = open("/dev/vme",O_RDWR);
	if (fd < 0) {
	  perror("error opening vme"); 
	printf("/dev/vme opened.\n");

	error = ioctl(fd, VME_SET_ATTR, &memdesc);
	if (error) perror("Failed VME_SET_ATTR");

	error = ioctl(fd, VME_GET_ATTR, &memdesc);
	if (error) perror("Failed VME_GET_ATTR");

	printf("memdesc: flags %x, vme_addr %x, length %x\n", memdesc.flags,
	       memdesc.base, memdesc.limit-memdesc.base+1);

	if ((u_long)mp == -1) perror("Mmap failed with");
	else printf("mem mapped at %p\n", mp);

	/* new code from testvme.c */
	printf("Try to read\n");
	for (i=0; i<0x100; i++) {
	  printf("Read %x at %x\n",j,rp);

	printf("Try to write \n");
	for (i=0; i<MBUFSIZE; i+= 512) {
		memset(mp+i, PATTERN, 512);
	printf("Finished \n");

	return 0;

More information about the Linuxppc-dev mailing list