MVME2431: how to use vme?
David De Ridder
s970707 at uia.ua.ac.be
Wed May 12 01:03:28 EST 1999
On Mon, 10 May 1999, Simone Piccardi wrote:
> I can also load the universe module without problems (at least it gave
> me the message: Universe VME bridge #1 found at bus=0, dev=13 that seems
> OK).
OK.
> Now the problem is to test VME (to be precise the real problem is that
> this is my first experience with VME, so have no idea from where to
> start).
> I read the README.universe in the kernel source, and I tried also to use
> the program vmetest.c that I found in the same directory of the kernel
> patches.
> The problem is that that program cannot compile, it start with an error:
> testvme.c:43: 'VME_attr' undeclared ....
> and then gave a lot of other errors. I suppose that this depends on some
> version mismatch (I'm using kernel 2.2.6, with related patch).
OK, Gabriel is currently unreachable for two weeks (correct me if
I'm wrong). So here's some advice to all VME testers : take the
testvme.c program from Gabriel's website - make sure you have
a patched 2.2.6 kernel -, strip the program from everything you
think you don't need. The problem is : use ``window'' instead
of ``attr''. I think Gabriel was using different (newer? older?)
include files, because this solves the problem.
You can start from my own stripped-down version (in attachment).
Regards,
+-----------------------------------------------------------------+
David 'Septimus' De Ridder <david.de.ridder at bitsmart.com>
"Watching eyes wait for sadness to rise,
true superstitions combine and thicken
this poison that reaches my soul,
this terror that blackens my soul."
- Anne Clark
+-----------------------------------------------------------------+
-------------- 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 memorymap[MBUFSIZE];
*/
int main(int argc, char *argv[])
{
u_char *mp;
int fd;
int error;
int i, j;
VME_window memdesc = {base: 0xd00000,
limit: 0xdfffff,
flags: VME_AM_A24(16) | VME_USE_MAP | VME_USE_RMW
};
VME_atomic_access rmw = {offset: 0,
};
/* Open the VME device : */
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_WINDOW, &memdesc);
if (error)
perror("Failed VME_SET_WINDOW");
error = ioctl(fd, VME_GET_WINDOW, &memdesc);
if (error)
perror("Failed VME_GET_WINDOW");
printf("memdesc: flags %x, vme_addr %x, length %d\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);
close(fd);
return 0;
}
More information about the Linuxppc-dev
mailing list