linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Simone Piccardi <Simone.Piccardi@fi.infn.it>
To: David De Ridder <david.de.ridder@bitsmart.com>
Cc: linuxppc-dev@lists.linuxppc.org
Subject: Re: MVME2431: how to use vme?
Date: Tue, 11 May 1999 18:27:04 +0200	[thread overview]
Message-ID: <37385A58.BE9B4396@fi.infn.it> (raw)
In-Reply-To: Pine.SO4.4.05.9905111658130.18026-200000@hsins.uia.ac.be

[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]

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
moment!

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.

Bye
-- 
Simone Piccardi
Microsoft is NOT the answer. Microsoft is the Question.
The answer is: "NO!"

[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 1425 bytes --]

#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"); 
	  exit(0);
	}
	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);

	mp = mmap(0, MBUFSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 
	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");
	rp=mp;	
	for (i=0; i<0x100; i++) {
	  j=*(rp++);	
	  printf("Read %x at %x\n",j,rp);
	  usleep(1000);
	}

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


	close(fd);
	return 0;
}

  reply	other threads:[~1999-05-11 16:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-10 13:45 MVME2431: how to use vme? Simone Piccardi
1999-05-11 15:03 ` David De Ridder
1999-05-11 16:27   ` Simone Piccardi [this message]
1999-05-14  9:58     ` David De Ridder
1999-05-15 12:22       ` Simone Piccardi
1999-05-24 10:33         ` Gabriel Paubert
1999-05-24 14:18           ` Simone Piccardi
1999-05-25  9:11             ` Gabriel Paubert
1999-05-26 13:07               ` David De Ridder
1999-05-26 15:22                 ` Gabriel Paubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37385A58.BE9B4396@fi.infn.it \
    --to=simone.piccardi@fi.infn.it \
    --cc=david.de.ridder@bitsmart.com \
    --cc=linuxppc-dev@lists.linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).