ai_regtests.c
2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#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);
}