Didier Kryn a écrit :
Konstantin, I reproduced your ioctl() problem with the attached program. The conclusion is that the only valid size and base parameters for A16 are windowSizeL=0x10000 and xlatedAddrL=0. This means the A16 space can only be mapped as a whole. What you observed with xlatedAddrL=0x10100000 is that the ioctl(), gently masks the irrelevant high order bits.

    Best regards.
    Didier
   Oops! I forgot the attachment...
#include <linux/stddef.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "vmedrv.h"

#if !defined(offsetof)
/* maybe defined (if <linux/stddef.h> included indirectly) */
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

int main(void)
{
   int vmepd, i;
   char *devname="/dev/vme/vme_out0";
   vmeOutWindowCfg_t a16d16 = {0,1,0,0,0,0x1000000,0,0,0,0,0,0,VME_SSTNONE,
                               VME_A16,VME_D16,VME_SCT,VME_SUPER,VME_DATA,0};
   unsigned size_max=0x10000;
   unsigned base, size;
   unsigned short *vmebus;


   vmepd = open(devname, O_RDWR);
   if(vmepd==-1)
     {
        perror(devname);
        return 1;
     }

   for( base=0 ;   (size = size_max - base) ;   base+=0x100 )
     {
        a16d16.xlatedAddrL = base;
        a16d16.windowSizeL = size;
        if(ioctl(vmepd, VME_IOCTL_SET_OUTBOUND, &a16d16))
          printf("ioctl failed for base %x, size %x: %s\n", base, size, strerror(errno));
        else
          printf("ioctl OK for base %x, size %x\n", base, size);
     }

   for( base=0, size=0x100 ;   size <= size_max ;  size+=0x100 )
     {
        a16d16.xlatedAddrL = base;
        a16d16.windowSizeL = size;
        if(ioctl(vmepd, VME_IOCTL_SET_OUTBOUND, &a16d16))
          printf("ioctl failed for base %x, size %x: %s\n", base, size, strerror(errno));
        else
          printf("ioctl OK for base %x, size %x\n", base, size);
     }

  close(vmepd);
}

_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Reply via email to