* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)imptst.c 7.2 (Berkeley) %G%
#include "../vaxuba/ubareg.h"
#include "../netinet/in.h"
#include "../netinet/in_systm.h"
#include "../netimp/if_imp.h"
#include "../vaxif/if_acc.h"
#define min(a,b) (a<b ? a : b)
struct imp_leader imps
, *ip
= &imps
;
register error
= 0, i
, len
;
short type
, host
, impno
, link
;
register struct accdevice
*addr
=
(struct accdevice
*)ubamem(0, 0767700);
printf("imp interface diagnostic\n");
printf("read or write test(r or w)? ");
while (*input
!= 'r' && *input
!= 'w') {
printf("reply r or w: ");
printf("enter destination host number: ");
while ((host
= (short)atol(input
)) < 0 || host
> 255) {
printf("range [0, 255], re-enter: ");
while ((impno
= (short)atol(input
)) < 0 || impno
> 32767) {
printf("range [0, 32767], re-enter: ");
while ((link
= (short)atol(input
)) < 0 || link
> 255) {
printf("range [0, 255], re-enter: ");
printf("initialization starting...\n");
/* send 3 noops and init imp leader buffer */
impnoops((struct control_leader
*)ip
);
printf("initialization complete\n");
printf("starting write test...\n");
ip
->il_imp
= htons((u_short
)impno
);
error
= impwrite(ip
, sizeof (*ip
));
printf("imp write error, ocsr=%b\n", (short)error
,
printf("starting read test...\n");
printf("impread(%d)\n", sizeof (*ip
));
error
= impread(ip
, sizeof (*ip
));
printf("impread, error=%b\n", error
, ACC_INBITS
);
len
= ntohs(ip
->il_length
);
printf("length=%d\n", len
);
while ((error
& IN_EOM
) == 0 &&
(error
& ~IN_EOM
) == 0 && len
> 0) {
printf("impread(%d)\n", i
);
error
= impread(inbuf
, i
);
printf("error=%b, len=%d\n", error
, ACC_INBITS
, len
);
if (error
== 0 && (len
> 0 || addr
->iwc
))
printf("imp input length mismatch\n");
printf("imp read error, icsr=%b\n", (short)error
, ACC_INBITS
);
printf("...imptest exiting\n");
register struct control_leader
*cp
;
bzero((caddr_t
)cp
, sizeof (struct control_leader
));
cp
->dl_mtype
= IMPTYPE_NOOP
;
for (i
= 0; i
< IMP_DROPCNT
+ 1; i
++ ) {
if ((error
= impwrite(ip
, sizeof (*ip
))) != 0) {
printf("imp init error, ocsr=%b\n", (short)error
,
register struct imp
*buf
;
register struct accdevice
*addr
=
(struct accdevice
*)ubamem(0, 0767600);
/* set regs and perform i/o */
addr
->oba
= (u_short
)uba
;
addr
->owc
= -((io
.i_cc
+ 1) >> 1);
addr
->ocsr
= ((short) ((uba
& 0x30000) >> 12) | OUT_ENLB
| ACC_GO
);
while ((addr
->ocsr
& ACC_RDY
) == 0)
error
= addr
->ocsr
& (ACC_NXM
|ACC_ERR
);
register struct imp
*buf
;
register struct accdevice
*addr
=
(struct accdevice
*)ubamem(0, 0767600);
/* set regs and perform i/o */
addr
->iba
= (u_short
)uba
;
addr
->iwc
= -(io
.i_cc
>> 1);
addr
->icsr
= IN_MRDY
| IN_WEN
| ((uba
& 0x30000) >> 12) | ACC_GO
;
while ((addr
->icsr
& ACC_RDY
) == 0)
error
= addr
->icsr
& (IN_EOM
|ACC_ERR
|IN_RMR
|ACC_NXM
);
register struct accdevice
*addr
=
(struct accdevice
*)ubamem(0, 0767600);
* Reset the imp interface;
* the delays are pure guesswork.
addr
->icsr
= ACC_RESET
; DELAY(5000);
addr
->ocsr
= ACC_RESET
; DELAY(5000);
addr
->ocsr
= OUT_BBACK
; DELAY(5000); /* reset host master ready */
addr
->icsr
= IN_MRDY
| IN_WEN
; /* close the relay */
for (i
= 0; i
< 500; i
++) {
if ((addr
->icsr
& IN_HRDY
) &&
(addr
->icsr
& (IN_RMR
| IN_IMPBSY
)) == 0)
addr
->icsr
= IN_MRDY
| IN_WEN
; DELAY(10000);
/* keep turning IN_RMR off */
printf("imp doesn't respond, icsr=%b, ocsr=%b\n",
addr
->icsr
, ACC_INBITS
, addr
->ocsr
, ACC_OUTBITS
);
* Convert null-terminated ascii string to binary
if ((digit
= (*as
++)) == 0)
return(value
) ; /* null */
while (digit
= (*as
++)) {
if ((digit
>= 'A') && (digit
<= 'F')) {
if ((digit
>= 'a') && (digit
<= 'f')) {
value
= (value
* base
) + digit
;
register struct imp_leader
*ip
;
printbyte((char *)ip
, 12);
printf("<fmt=%x,net=%x,flags=%x,mtype=", ip
->il_format
, ip
->il_network
,
if (ip
->il_mtype
<= IMPTYPE_READY
)
printf("%s,", impleaders
[ip
->il_mtype
]);
printf("%x,", ip
->il_mtype
);
printf("htype=%x,host=%x,imp=%x,link=", ip
->il_htype
, ip
->il_host
,
if (ip
->il_link
== IMPLINK_IP
)
printf("%x,", ip
->il_link
);
printf("subtype=%x,len=%x>\n",ip
->il_subtype
,ntohs(ip
->il_length
)>>3);
putchar("0123456789abcdef"[(c
>>((1-j
)*4))&0xf]);