From: "Konstantin Boyanov" <kkboyanov@gmail.com>
To: linuxppc-embedded@ozlabs.org
Subject: Reading and writing from/to VME device
Date: Mon, 26 Mar 2007 17:14:54 +0200 [thread overview]
Message-ID: <929bf310703260814q18957942s218d56bed8fb4009@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 4490 bytes --]
Hi list,
I'm using the MVME6100 board with the Motorola driver for linux v3.5 (kernel
2.6.15). I try to access the CSR registers of an ADC board, in order to
configure it as to be able to access its memory, on the VME bus using one of
the outbound windows defined by the driver. As I am new to the whole VME
stuff, I'm getting into trouble to find out when I'm actually reading
something on the VME, i.e. which addresses respond.
I'm trying the following schema (source code @ EOM):
1. open() and ioctl() one of the /dev/vme_m* devices, which I assume is
corresponding to an outbound window (at least I try to configure it as one),
2. then mmap() a memory area to hold the contents of the /dev/vme_m* device
file
3. and finally doing incrementation of the pointer returned by mmap() and
dereferencing it in the hope that I'll read something, which in most cases
is 0xFF
In fact my code is very similar to test code that comes with the driver and
also with a sample code I found in this thread ->
http://ozlabs.org/pipermail/linuxppc-dev/1999-May/001906.html
I've tried to do a read() on the opened /dev/vme_m* device but I only
succeed in reading 0 bytes, and when I try to read in chunks from the VME
bus i get errno 22 on reads like read(fd, buffer, 1024) for example.
I don't know if my strategy is correct in the first place but that's what I
came up with.
When I try to run one of the test applications that came with the driver
(the "testout" one) I get an errno = 29 (Illegal seek?! ) on the read()
operations.
So my question is whether I make the right steps in reading an address on
the VME bus. I know I'm missing something, so I'll be glad to get some
directions as to how to be sure whether I'm reading something from the VME
bus and where I'm able to write.
Best regards,
Konstantin
________________________________
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "vmedrv.h"
int main(int argc, char* argv[])
{
vmeOutWindowCfg_t outWinCfg;
vmeOutWindowCfg_t outWinGet;
int fdOut, status, i, j;
unsigned int n;
u_char *rdPtr, *getPtr;
if(getMyVmeInfo()){
printf("getMyVmeInfo failed.\n");
exit (1);
}
fdOut = open("/dev/vme_m0", O_RDWR);
perror("open");
if(fdOut < 0){
printf("Opening /dev/vme_m0 failed. Errno = %d\n", errno);
}
memset(&outWinCfgADC, 0, sizeof(vmeOutWindowCfg_t));
perror("memset");
outWinCfgADC.windowNbr = 0;
outWinCfgADC.windowEnable = 1;
outWinCfgADC.wrPostEnable = 0;
outWinCfgADC.userAccessType = VME_SUPER;
outWinCfgADC.dataAccessType = VME_DATA;
outWinCfgADC.windowSizeL = 0x200000;
outWinCfgADC.xferProtocol = VME_SCT;
outWinCfgADC.addrSpace = VME_A24;
outWinCfgADC.maxDataWidth = VME_D16;
status = ioctl(fdOut, VME_IOCTL_SET_OUTBOUND, &outWinCfgADC);
perror("ioctl");
if(status < 0){
printf("*** ioctl set on outWinCfgADC failed. Errno = %d\n", errno);
exit (1);
}
memset(&outWinGetADC, 0, sizeof(vmeOutWindowCfg_t));
outWinGetADC.windowNbr = 0;
status = ioctl(fdOut, VME_IOCTL_GET_OUTBOUND, &outWinGetADC);
perror("ioctl");
if(status < 0){
printf("*** ioctl get on outWinGetADC failed. Errno = %d\n", errno);
exit (1);
}
/*
* Check wheather the get and set configurations are the same
*/
getPtr = (u_char *) mmap(0, outWinCfgADC.windowSizeL,
PROT_READ|PROT_WRITE, MAP_SHARED, fdOut, 0);
perror("mmap");
printf("# Start of outbound win in virtual address space of the process:
%p\n", getPtr);
rdPtr = getPtr;
for(i=0;i<0x100;i++){
printf("# Read at address %x = %x\n", rdPtr, *rdPtr);
rdPtr++;
}
status = close(fdOut);
if(status != 0){
printf("*** close() failed. Errno = %d\n", errno);
exit (1);
}
return 0;
}
__________________________________
Part of the output:
mmap: Illegal seek
# Start of outbound win in virtual address space of the process: 0x30029000
# Read at address 30029000 = ff
# Read at address 30029001 = ff
# Read at address 30029002 = ff
# Read at address 30029003 = ff
# Read at address 30029004 = ff
# Read at address 30029005 = ff
# Read at address 30029006 = ff
# Read at address 30029007 = ff
# Read at address 30029008 = ff
# Read at address 30029009 = ff
# Read at address 3002900a = ff
# Read at address 3002900b = ff
and etc.
[-- Attachment #2: Type: text/html, Size: 6396 bytes --]
next reply other threads:[~2007-03-26 15:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-26 15:14 Konstantin Boyanov [this message]
2007-03-26 18:31 ` Reading and writing from/to VME device Martin, Tim
2007-03-27 9:09 ` Didier Kryn
2007-03-27 12:38 ` Didier Kryn
2007-03-27 15:47 ` Konstantin Boyanov
2007-03-27 19:02 ` Martin, Tim
2007-03-28 9:56 ` Didier Kryn
2007-03-29 10:13 ` Konstantin Boyanov
2007-03-29 19:27 ` Martin, Tim
2007-03-30 9:24 ` Didier Kryn
2007-04-02 9:15 ` Didier Kryn
2007-04-02 9:21 ` Didier Kryn
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=929bf310703260814q18957942s218d56bed8fb4009@mail.gmail.com \
--to=kkboyanov@gmail.com \
--cc=linuxppc-embedded@ozlabs.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).