Esempio n. 1
0
int Set_csr (unsigned short pat, char *st)
{
    unsigned short csr = 0;
    unsigned short str1[20], str2[20];

    if (log_print != 2)
        sleep (1);
    print (2, "Mise a 1 du BIT %s\r", st);
    csr = pat;
    if (set_csr (bc, rt, &csr, &status) == (-1)) {
        print (1, "Probleme systeme [%d] avec set_csr", errno);
        return (1);
    }
    if (get_csr (bc, rt, &csr, &status) == (-1)) {
        print (1, "Probleme systeme [%d] avec get_csr", errno);
        return (1);
    }
    if ((csr & pat) != pat) {
        convbin (pat, (char *) str1);
        convbin (csr, (char *) str2);
        print (1, " Set bit of CSR faild. Pattern: [%s] CSR: [%s]\n", (char *) str1, (char *) str2);
        return (1);
    }
    return (0);
}
Esempio n. 2
0
int main ()
{
  int i, q = 0, p = 0, r = 0;

  for (i = 0; i < 20; i++)
    {
      set_csr ((volatile void *) 0xbf0100a8, 0xffff0002);
      set_csr ((volatile void *) 0xbf0100a4, 0x80000008);
    }

  for (i = 0; i < 20; i++)
    {
      register int k, j;
      k = get_csr ((volatile void *) 0xbf0100b8);
      p += k;
      j = get_csr ((volatile void *) 0xbf0100b4);
      r += j;
      q = j + k;
    }
  return q + r + p;
}
Esempio n. 3
0
int reset (void)
{
    char st[20];
    unsigned short csr;

    print (2, "\rReset (MC8) du bc[%d] rt[%d] ", bc, rt);
    if (mdrop (bc, rt, 1, 0, 8, &status, (char *) &csr) != 0) {
        print (1, "\nReset:System error for mdrop mode_code:RESET");
        return (-1);
    }
    convbin (status, st);
    print (1, "    MC(8) - Status: %s\n", st);
    sleep (4);
    if (get_csr (bc, rt, &csr, &status) == (-1)) {
        print (1, "\nReset:System error for get_csr");
        return (-1);
    }
    return (status);
}
Esempio n. 4
0
int Clr_csr (unsigned short pat, char *st)
{
    unsigned short csr = 0;

    print (2, "Mise a 0 du BIT %s\r", st);
    csr = pat;
    if (clr_csr (bc, rt, &csr, &status) == (-1)) {
        print (1, "Probleme systeme [%d] avec clr_csr", errno);
        return (1);
    }
    if (get_csr (bc, rt, &csr, &status) == (-1)) {
        print (1, "Probleme systeme [%d] avec get_csr", errno);
        return (1);
    }
    if (csr & pat) {
        print (1, " FAILED.\n");
        return (1);
    }
    return (0);
}
Esempio n. 5
0
int wait_for_csr (int pattern, int res, int delai, int flg)
{
    unsigned short csr;

    do {
        if (flg)
            print (2, "Attente du CSR [%04X]=[%04X] :%.3d secondes    \r", pattern, csr, delai);
        if (get_csr (bc, rt, &csr, &status) == (-1)) {
            print (1, "\nwait_for_csr:Sysytem error in the get_csr()");
            return (0);
        }
        if ((csr & pattern) == res) {
            if (flg)
                print (2, "Detection CSR OK \n");
            return (1);
        }
        if (go_on == 0)
            return (0);
        if (flg)
            sleep (1);
    } while (--delai);
    return (0);
}
Esempio n. 6
0
int bit_local (void)
{
    unsigned short csr;
    int delai;

    csr = 0xFFFF;
    print (2, "Clear du csr       \r");
    if (clr_csr (bc, rt, &csr, &status) == -1) {
	print (1, "System error [%d] in clr_csr", errno);
	erreur++;
	if (t_err)
	    return t_err;
    }
    print (2, "Envoi d'une interruption\r");
    csr = INT_BIT + INE_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1) {
	print (1, "System error [%d] in set_csr", errno);
	erreur++;
	if (t_err)
	    return t_err;
    }
    csr = INE_BIT;
    if (clr_csr (bc, rt, &csr, &status) == -1) {
	print (1, "System error [%d] in clr_csr", errno);
	erreur++;
	if (t_err)
	    return t_err;
    }
    print (2, "Set des bits LRR et LOCAL\r");
    csr = LRREQ_BIT + LM_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1) {
	print (1, "System error [%d] in set_csr", errno);
	erreur++;
	if (t_err)
	    return t_err;
    }
    delai = 60;
    print (1, "Le G64 a %d secondes pour demarrer son test LOCAL\n", delai);

    if (wait_for_csr (LRREQ_BIT + LM_BIT, LM_BIT, delai, 1) == 0)
	return (++erreur);
    print (1, "Le test LOCAL vient de demarrer sur le host.\n");
    print (1, "\tAttente de fin des tests sur le host.\n");
    if (wait_for_csr (LM_BIT, 0, 600, 1) == 0)
	return (++erreur);
    print (1, "Le test LOCAL vient de finir sur le host.");
    if (get_csr (bc, rt, &csr, &status) == -1) {
	print (1, "System error [%d] in get_csr", errno);
	erreur++;
	if (t_err)
	    return t_err;
    }
    if ((csr & INV_BIT) == INV_BIT) {
	print (0,
	       "Le G64 a detecte une ou plusieurs erreurs au cours du test local.\n");
	erreur++;
	csr = INV_BIT;
	if (clr_csr (bc, rt, &csr, &status) == -1) {
	    print (1, "System error [%d] in clr_csr", errno);
	    erreur++;
	}
	if (t_err)
	    return t_err;
    }
    return (erreur);
}
Esempio n. 7
0
int bounce (void)
{
    unsigned short csr;
    unsigned short buff[4096], data[4096], *pts, *ptd;
    int i, l = 0, flag = 0;
    int seuil = 0;
    unsigned char str1[20], str2[20];
    char dir;

    seuil = 128;
    dir = 8;
    /* tell G64 to start bounce with LRR and NEM set */
    csr = LRREQ_BIT + NEM_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in set LRR+NEM");

    /* reset bit TB et RB */
    csr = TB_BIT + RB_BIT;
    if (clr_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in clr RB+TB");

    /* fill data */
    for (i = 0; i < seuil; i++)
	data[i] = (i * (0xffff / seuil)) + ((0xffff / seuil) * l + l);

    l = 1;
    while (go_on) {
	print (1, "%c%c", '|' + (l & 0xfffe), dir);
	print (2, "Test avec %4d mots\n", l);

	/* reset receive pointer */
	csr = RRP_BIT;
	if (set_csr (bc, rt, &csr, &status) == -1)
	    BAD ("system error in set RRP");

	/* fill buffer */
	if (set_rx_buf (bc, rt, l * 2, (char *) data, &status) != 0)
	    BAD ("system error in set_rc_buf");

	/* set bits RB */
	csr = RB_BIT;
	if (set_csr (bc, rt, &csr, &status) == -1)
	    BAD ("system error in set RB");

	/* wait for reponse */
	if (wait_for_csr (TB_BIT, TB_BIT, 20000, 0) == 0) {
	    print (1, "TIME_OUT a l'attente du Transmit Buffer plein.\n");
	    erreur++;
	    if (t_err)
		continue;
	}

	/* reset transmit pointer */
	csr = RTP_BIT;
	if (set_csr (bc, rt, &csr, &status) == -1)
	    BAD ("system error in set RTP");

	/* read reponse */
	for (i = 0; i < l; i++)
	    buff[i] = 0;
	if (get_tx_buf (bc, rt, l * 2, (char *) buff, &status) != 0)
	    BAD ("system error in get_tx_buf");

	/* reset bit TB */
	csr = TB_BIT;
	if (clr_csr (bc, rt, &csr, &status) == -1)
	    BAD ("system error in clr TB");

	/* compare */
	flag = 0;
	i = l;
	pts = data;
	ptd = buff;
	do {
	    if (*pts != *ptd) {
		flag++;
		erreur++;
		convbin (*pts, (char *) str1);
		convbin (*ptd, (char *) str2);
		print (1, "DATA error in test_BOUNCE:\tPointer %d\n  read [%s]\n write [%s]\n", i, str2, str1);
		break;
	    }
	    pts++;
	    ptd++;
	} while (--i);
	if (++l > seuil)
	    break;
    }
    /* clear collision pattern LRR and NEM set */
    csr = LRREQ_BIT + NEM_BIT;
    if (clr_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in clr LRR+NEM");

    if (get_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in get_csr");
    if ((csr & INV_BIT) == INV_BIT) {
	print (0, "Le G64 a detecte une ou plusieurs erreurs au cours du test collision\n");
	erreur++;
	csr = INV_BIT;
	if (clr_csr (bc, rt, &csr, &status) == -1)
	    BAD1 ("system error in clr INV");
	if (t_err)
	    return t_err;
    }
    return (erreur);
}
Esempio n. 8
0
int collision (void)
{
    unsigned short csr, sta;

    /* tell G64 to start bounce with LRR and BRD set */
    print (2, "\rTest Remote collision:\n");
    csr = LRREQ_BIT + BRDIS_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in set LRR+BRD");
    print (2, "LRR + BRD set in RT\r");

    /* test first the receive buffer */
    csr = RB_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in set RB");
    if (wait_for_csr (TB_BIT, TB_BIT, 60, 1) == 0) {
	print (1, "Erreur de synchro. Le RT n'a pas mits son bit TB a 1\n");
	erreur++;
	return (1);
    }
    print (1, "Test du receive buffer");

    rx_buf ();			/* test receive buffer */
    rx_buf ();			/* test receive buffer */
    rx_buf ();			/* test receive buffer */
    print (1, "\n");
    csr = RB_BIT;
    if (clr_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in clr RB");

    /* Wait for the end of the G64 */
    if (wait_for_csr (TB_BIT, 0, 60, 1) == 0) {
	print (1, "Erreur de synchro. Le RT n'a pas mis son bit TB a 0\n");
	erreur++;
	return (1);
    }

    /* Then test the transmit buffer */
    csr = TB_BIT;
    if (set_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in set TB");
    if (wait_for_csr (RB_BIT, RB_BIT, 60, 1) == 0) {
	print (1, "Erreur de synchro. Le RT n'a pas mits son bit RB a 1\n");
	erreur++;
	return (1);
    }
    print (1, "Test du transmit buffer");
    tx_buf ();			/* test transmit buffer */
    tx_buf ();			/* test transmit buffer */
    tx_buf ();			/* test transmit buffer */
    print (1, "\n");
    csr = TB_BIT;
    if (clr_csr (bc, rt, &csr, &sta) == -1)
	BAD1 ("system error in clr TB");

    /* Wait for the end of the G64 */
    if (wait_for_csr (RB_BIT, 0, 60, 1) == 0) {
	print (1, "Erreur de synchro. Le RT n'a pas mis son bit RB a 0\n");
	return (1);
    }

    /* clear collision pattern LRR and BRD set */
    csr = LRREQ_BIT + BRDIS_BIT;
    if (clr_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in clr LRR+BRD");

    if (get_csr (bc, rt, &csr, &status) == -1)
	BAD1 ("system error in get_csr");
    if ((csr & INV_BIT) == INV_BIT) {
	print (0, "Le G64 a detecte une ou plusieurs erreurs au cours du test collision\n");
	erreur++;
	csr = INV_BIT;
	if (clr_csr (bc, rt, &csr, &status) == -1)
	    BAD1 ("system error in clr INV");
	if (t_err)
	    return t_err;
    }
    return (erreur);
}