Previous Next Contents

2.2 The full featured A32 capable PCI slave images

The four PCI slave images with A32 capability on thye VME side are mapped to four independent devices, each with it's own minor device number. To use such a device it must be open()ed and initialized via three or four ioctl() calls. One call sets the mapping parameters VME Adress space and maximum datasize on the VMEBus. The other call sets the VMEBus address of the image. Because not all bits of the VME-Address translation register are used the real starting address will always be aligned to some granularity, wich may be inquired with the VMEIMG_GETGRANULARITY ioctl(). The easiest way, however, is to inquire the real starting address via VMEIMG_GETVMEADDR and calculate offsets from there.

Here an example of how to use the image:


    struct vme_mapping_ctrl Mapping = {
    VMEMAP_DWIDTH_16, VMEMAP_ASPACE_A32,
    VMEMAP_SUPUSERAM_USER, VMEMAP_PRGDATAAM_DATA};

    fd = open(Device,O_RDWR);
    if (ioctl(fd, VMEIMG_SETMAPPING, &Mapping))
      {
        perror("ioctl VMEIMG_SETMAPPING");
        exit(1);
      }
    if (ioctl(fd, VMEIMG_SETVMEADDR, vme_addr))
      {
        perror("ioctl VMEIMG_SETVMEADDR");
        exit(1);
      }
    if (ioctl(fd, VMEIMG_GETVMEADDR, &real_vme_addr))
      {
        perror("ioctl VMEIMG_GETVMEADDR");
        exit(1);
      }
    {
      volatile unsigned chart *mappped_data;
      mapped_data = mmap(NULL,nof_bytes,
                        PROT_WRITE | PROT_READ, MAP_FILE|MAP_SHARED, fd,0);
      if (mapped_data == (volatile unsigned char*) -1)
        {
          perror("mmap()");
          exit(1);
        }
      *mapped_data+(vme_addr - real_vme_addr) = 1; /* write a 1 to the vme address */
    }


Previous Next Contents