Esempio n. 1
0
int init_vuprom( vuprom* v ) {

    if ((v->vme_mem = (u_int32_t*) vmeext( v->map_addr, RANGE )) == NULL) {
        perror("Error opening device.\n");
        return 0;
    }

    const u_int32_t magic_number = v->vme_mem[MAGIC_SCALER];

    u_int32_t firmware = 0;
    if (!vme_read_once( (v->map_addr & 0xFF000000) + FIRMWARE_SCALER, &firmware )) {
        printf("ERROR: Could not read firmware!\n");
    }

    if( magic_number != MAGIC_NUMBER ) {
        printf("Error: vuprom magic number not found. (base_addr: %#010x, scaler %d, value %x, expected %x)\n", v->base_addr, MAGIC_SCALER, magic_number, MAGIC_NUMBER );
        return FALSE;
    }

    if( firmware != v->firmware ) {
        printf("WARNING: vuprom firmware missmatch! (base_addr: %#010x, value %x, expected %x)\n", v->base_addr, firmware, v->firmware );
        return FALSE;
    }

    printf("Init vuprom @ %#010x, map addess: %#010x, max scaler index: %d\n", v->base_addr, v->map_addr, v->max_sclaer_index);
    return TRUE;
}
Esempio n. 2
0
int vme_read_once( u_int32_t addr, u_int32_t* out ) {
    addr &= 0x1fffffff;        // obere Bits ausmaskieren
    u_int32_t rest = addr % 0x1000;
    addr = (addr / 0x1000) * 0x1000;
    volatile u_int32_t* mem = NULL;

    if ((mem = vmeext(addr, 0x1000)) == NULL) {
        return FALSE;
    }

    *out = mem[rest/4];
    munmap((void*)mem,0x1000);
    return TRUE;
}
unsigned long VMERead(unsigned long Myaddr) {
	unsigned long Myrest, MyOrigAddr, Mypattern;
	volatile unsigned long *Mypoi;
	MyOrigAddr = Myaddr;
	Myaddr &= 0x1fffffff;	// obere Bits ausmaskieren
	Myrest = Myaddr % 0x1000;
	Myaddr = (Myaddr / 0x1000) * 0x1000;

	if ((Mypoi = vmeext(Myaddr, 0x1000)) == NULL) {
		perror("Error opening device.\n");
		exit (-1);
	}
	Mypoi += (Myrest / 4);  //da 32Bit-Zugriff

	//Lesen
	Mypattern = *Mypoi;
	if (Verbose) {
		printf("Read address = %0.8lx Pattern = %0.8lx\n", MyOrigAddr, Mypattern);
	}

	return Mypattern;
}
unsigned long VMEWrite(unsigned long Myaddr, unsigned long Mypattern) {
	unsigned long MyOrigAddr, Myrest;
	volatile unsigned long *Mypoi;
	volatile unsigned long MyTempPattern;
	MyOrigAddr = Myaddr;
	Myaddr &= 0x1fffffff;	// obere Bits ausmaskieren
	Myrest = Myaddr % 0x1000;
	Myaddr = (Myaddr / 0x1000) * 0x1000;

	if ((Mypoi = vmeext(Myaddr, 0x1000)) == NULL) {
		perror("Error opening device.\n");
		exit (-1);
	}
	Mypoi += (Myrest / 4);  //da 32Bit-Zugriff

	*Mypoi = Mypattern;  //Doppelter Zugriff beim Schreiben

	if (Verbose) {
		printf("Write address = %0.8lx Pattern = %0.8lx\n", MyOrigAddr, Mypattern);
	}

	return 0;
}
Esempio n. 5
0
unsigned long VMEWrite(unsigned long Myaddr, unsigned long Mypattern) {
	unsigned long MyOrigAddr, Myrest;
	volatile unsigned long *Mypoi;
	volatile unsigned long MyTempPattern;
	MyOrigAddr = Myaddr;
	Myaddr &= 0x1fffffff;	// obere Bits ausmaskieren
	Myrest = Myaddr % 0x1000;
	Myaddr = (Myaddr / 0x1000) * 0x1000;

	if ((Mypoi = vmeext(Myaddr, 0x1000)) == NULL) {
		perror("Error opening device.\n");
		exit (-1);
	}
	Mypoi += (Myrest / 4);  //da 32Bit-Zugriff

	MyTempPattern = *Mypoi;  //Erst mal die Adresse auf dem VMEbus setzen durch Lesen, um einen Fehler im VUPROM module auszugleichen
	*Mypoi = Mypattern;  //Doppelter Zugriff beim Schreiben

	if (Verbose) {
		printf("Write address = %0.8lx Pattern = %0.8lx\n", MyOrigAddr, Mypattern);
	}

	return 0;
}
Esempio n. 6
0
main(int argc, char *argv[])
{
  unsigned long i;
  unsigned int addr;
  volatile unsigned long pattern, testpattern;
  volatile unsigned long *poi, *poi1;

  if (argc != 3) {
    printf("Aufruf = eltec_ram Adr. std | ext\n");
    exit(1);
  }

  sscanf(argv[1], "%x\n", &addr);

  if (!strncmp(argv[2], "std", 2))  {
    if ((poi = vmestd(addr, 0x200000)) == NULL) {
      perror("Fehler beim Device oeffnen");
      exit (-1);
    }
    printf("ELTEC RAM512-2 im Standartmodus (32-Bit)\n");
  }

  if (!strncmp(argv[2], "ext", 2))  {
    if ((poi = vmeext(0x2a000000, 0x200000)) == NULL) {
      // 2a | 80 von vmeext gibt aaxxxxxx = Register ob. Bits
      perror("Fehler beim Device oeffnen");
      exit (-1);
    }
    // Setze obere Adress-Bits
    *poi = addr & 0xe0000000;
    if ((poi = vmeext(addr & 0x1fffffff, 0x200000)) == NULL) {
      perror("Fehler beim Device oeffnen");
      exit (-1);
    }
    printf("ELTEC RAM512-2 im Extended Modus (32-Bit)\n");
  }

  poi1 = poi;

  printf("Speichertest mit Inkrement\n");
  for (i = 0; i < 0x1fffff / 4; i++)  {
    //    warte(DELAY);
    *poi = i;
    //    warte(DELAY);
    pattern = *poi++;
    if (pattern != i) {
      printf("Fehler Soll = %x gelesen = %x\n", i, pattern);
      exit(-1);
    }

  }
  printf("fertig\n");

  poi = poi1;
  testpattern = 0xffffffff;
  printf("Speichertest mit Pattern %lx\n", testpattern);
  for (i = 0; i < 0x1fffff / 4; i++)  {
    warte(DELAY);
    *poi = testpattern;
    warte(DELAY);
    pattern = *poi++;
    if (pattern != testpattern) {
      printf("Fehler Soll = %x gelesen = %x\n", testpattern, pattern);
      exit(-1);
    }

  }
  printf("fertig\n");

  poi = poi1;
  testpattern = 0;
  printf("Speichertest mit Pattern %lx\n", testpattern);
  for (i = 0; i < 0x1fffff / 4; i++)  {
    warte(DELAY);
    *poi = testpattern;
    warte(DELAY);
    pattern = *poi++;
    if (pattern != testpattern) {
      printf("Fehler Soll = %x gelesen = %x\n", testpattern, pattern);
      exit(-1);
    }

  }
  printf("fertig\n");

  poi = poi1;
  testpattern = 0xaaaaaaaa;
  printf("Speichertest mit Pattern %lx\n", testpattern);
  for (i = 0; i < 0x1fffff / 4; i++)  {
    warte(DELAY);
    *poi = testpattern;
    warte(DELAY);
    pattern = *poi++;
    if (pattern != testpattern) {
      printf("Fehler Soll = %x gelesen = %x\n", testpattern, pattern);
      exit(-1);
    }

  }
  printf("fertig\n");

  poi = poi1;
  testpattern = 0x55555555;
  printf("Speichertest mit Pattern %lx\n", testpattern);
  for (i = 0; i < 0x1fffff / 4; i++)  {
    warte(DELAY);
    *poi = testpattern;
    warte(DELAY);
    pattern = *poi++;
    if (pattern != testpattern) {
      printf("Fehler Soll = %x gelesen = %x\n", testpattern, pattern);
      exit(-1);
    }

  }
  printf("fertig\n");
}