ai_regtests.c 2.42 KB
#include <sys/types.h>
#ifdef __sgi__
#include <sys/sbd.h>
#endif
#include <sys/stat.h>
#include <sys/mman.h>
#ifdef __sgi__
#include <sys/sema.h>
#endif
#include <netinet/in.h>

#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>



#include <rcp.h>

#include "diag.h"
#include <dbg_comm.h>


int
ai_status_rd(TEST_REF *test_ref)
{
    unsigned int rbuf;

    /* read hard-wired bits in status reg
     * should produce the pattern:
     * xx00 xxx1 xxx1 x00x xxxx xxxx xxxx xxxx
     */
    if (dgReadWord(AI_STATUS_REG, &rbuf) ) return (1);
    if ((rbuf & 0x31160000) != 0x01100000) {
    errlog(ERR_SEVERE,
           "data miscompare - actual = %x, expected = %x",
          rbuf, 0x01100000);
          return(1);
    }
   return(0);

}

int
ai_length_reg(TEST_REF *test_ref)
{
/* purpose: beat up the length reg.
 * length reg is double buffered and 2nd copy is readable
 * length is decremented as dma xfers are advanced.
 * length cleared when bit rate is non-zero
 */

int NumFailures = 0;

    unsigned int rbuf ;
    unsigned int wbuf ;
    unsigned int revision;
    unsigned int Length_Reg_Bit_Length;
    int i;
    int reg_value ;
    unsigned int bit_rate_clear;
    unsigned int bit_rate_set;

#define BIT_RATE_CLEAR 0
#define BIT_RATE_SET 0xf

 /* length can be written as bits MSB:3 unique with 2:0 = 0 */
 /* RCP1 has MSB = 14, RCP2 and above has MSB = 17 */
 /* 17 16 - 15 14 13 12 - 11 10 09 08 - 07 06 05 04 - 03 0 0 0 */


 /* Determine if RCP2 or RCP1 */
    if (dgReadWord(MI_VERSION_REG,&revision))return (1);

    if (revision == 0x01010101) {
	/* RCP1 */
        Length_Reg_Bit_Length = 12;
    }
    else {

	Length_Reg_Bit_Length = 15;
    }

    bit_rate_clear = BIT_RATE_CLEAR ;
    bit_rate_set = BIT_RATE_SET ;

    for (i = 0 ; i < Length_Reg_Bit_Length ; i++ ){

    reg_value = (1 << i) << 3 ;
    /* clear bit rate */
    if (dgWriteWord(AI_BITRATE_REG, bit_rate_clear)) return (1);

    /* set bit rate */
    if (dgWriteWord(AI_BITRATE_REG, bit_rate_set)) return (1);

    /* write entry to length */
    if (dgWriteWord(AI_LEN_REG,(reg_value))) return (1);

    if (dgReadWord(AI_LEN_REG,&rbuf))return (1);

    errlog(DEBUG,
        "length reg passed for data %04x",rbuf);

        if (rbuf  != reg_value) {
        errlog(ERR_SEVERE,
               "data miscompare - actual = %08x, expected = %08x",
              rbuf, reg_value);
        NumFailures ++;
        }


    }
    return(NumFailures);

}