* 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 6.2 (Berkeley) 6/8/85
#include "../machine/pte.h"
#include "../vaxuba/ubareg.h"
#include "../netinet/in.h"
#include "../netinet/in_systm.h"
#include "../netimp/if_imp.h"
#include "../vaxif/if_accreg.h"
#define min(a,b) (a<b ? a : b)
#define BUFSIZ (1006+sizeof(struct imp_leader))
struct imp_leader
*oip
= (struct imp_leader
*)outbuf
;
struct imp_leader
*iip
= (struct imp_leader
*)inbuf
;
register error
= 0, i
, len
;
short type
, host
, impno
, link
;
register struct accdevice
*addr
=
(struct accdevice
*)ubamem(0, 0767700);
register char *p
, pattern
= 0;
printf("imp interface loopback diagnostic\n");
printf("verbose(y or n)? ");
verbose
= (*input
!= 'n');
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");
oip
->il_format
= IMP_NFF
;
oip
->il_mtype
= IMPTYPE_NOOP
;
/* send 3 noops and init imp leader buffer */
impnoops((struct control_leader
*)oip
);
printf("initialization complete\n");
printf("starting write test...\n");
oip
->il_imp
= htons((u_short
)impno
);
for (p
= (char *)(oip
+ 1), i
= datalen
; i
--; )
error
= impwrite(oip
, datalen
+ sizeof (*oip
));
printf("imp write error, ocsr=%b\n", (short)error
,
printf("starting read test...\n");
printf("impread(%d)\n", sizeof (*iip
));
bzero(inbuf
, sizeof(inbuf
));
error
= impread(iip
, sizeof (inbuf
));
printf("impread, error=%b\n", error
, ACC_INBITS
);
if (bcmp(iip
, oip
, sizeof(*iip
) != 0))
printf("leader data error\n");
len
= ntohs(iip
->il_length
);
printf("length mismatch, got %d instead of %d\n",
while ((error
& IN_EOM
) == 0 &&
(error
& ~IN_EOM
) == 0 && len
> 0) {
printf("impread(%d)\n", 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
);
else if (bcmp(iip
+ 1, oip
+ 1, datalen
))
printf("data comparison error\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(cp
, sizeof (*cp
))) != 0) {
printf("imp init error, ocsr=%b\n", (short)error
,
for (i
= 0; i
< IMP_DROPCNT
+ 1; i
++ ) {
bzero((caddr_t
)iip
, sizeof(*iip
));
error
= impread(iip
, sizeof (inbuf
));
printf("impread, error=%b\n", error
, ACC_INBITS
);
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("impinit: 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]);