source: trunk/lisp/lmio1/chatst.lisp @ 253

Last change on this file since 253 was 253, checked in by rjs, 3 years ago

Update.

File size: 19.7 KB
Line 
1;; -*- Mode: LISP; Package: CHAOS -*-
2
3;;; TESTING FUNCTIONS:
4
5;;;   SET-BASE-ADDRESS - sets the base unibus address for the network interface
6;;;                      (defaults to 764140)
7;;;   CHATST         - send to self with and without loopback printing the results,
8;;;                    using pattern set by SET-PATTERN
9;;;   CHATST-LOOP    - send packets to another host (defaults to MC) which will echo it back
10;;;                    (useful for scope loops)
11;;;   CHATST-MONITOR - looks at everying flowing on the network
12;;;   CHATST-STATUS  - prints the status of the network interface, interpreting the CSR
13;;;   CHATST-RESET   - resets the network interface
14;;;   CHATST-ECHO    -
15;;;   CHATST-ECHO-ONCE
16;;;   CHATST-SOAK
17;;;   SET-NCP-BASE-ADDRESS - Sets the device address used by the NCP so that the
18;;;                          interface to be tested can be tried in full service.
19;;;                          NOTE!!!! A bus grant jumper must be run to the board you are
20;;;                          debugging in order for interrupts to work!
21
22;;;  **** NOTE *****
23;;;  Here are some typical screws encountered in testing chaos boards:
24;;;  If you get a CRC error, but the contents of the packet is NOT printed out,
25;;;  this means the data came back correctly, but a CRC error was indicated
26;;;  (often implying a bad CRC generator chip).
27;;;  MAKE SURE AND TEST WITH SEVERAL PATTERNS!!  Certain patterns (e.g all zeros)
28;;;  will not show certain errors.
29
30(DECLARE (SPECIAL
31   ;;; hardware related specials
32        CONTROL-STATUS-REGISTER-TEST    ;the control-status register
33        MY-NUMBER-REGISTER-TEST ;the cable address register
34        WRITE-BUFFER-REGISTER-TEST      ;the write-data register
35        READ-BUFFER-REGISTER-TEST       ;the read-data register
36        BIT-COUNT-REGISTER-TEST ;the bit count register
37        INITIATE-TRANSFER-REGISTER-TEST ;the start transfer register
38        INTERVAL-TIMER-REGISTER-TEST    ;start the interval timer
39        CHATST-PATTERN
40        CHATST-ADDRESS                  ;Host address of interface we're testing
41))
42
43
44;;;Format of control register
45;;; 1           ;XMT BUSY
46;;; 2           ;LOOP BACK
47;;; 4           ;RECEIVE-ALL
48;;; 10          ;RESET-RECEIVE
49;;; 20          ;RCV INTERRUPT ENABLE
50;;; 40          ;TRANSMIT INTERRUPT ENABLE
51;;; 100         ;TRANSMIT ABORT
52;;; 200         ;TRANSMIT DONE
53;;; 400         ;TRANSMIT RESET
54;;; 17000       ;LOST COUNT
55;;; 20000       ;IO RESET
56;;; 40000       ;CRC ERROR
57;;; 10000       ;RCV DONE
58
59
60(DEFUN SET-BASE-ADDRESS (&OPTIONAL (BASE-ADDRESS 764140))
61    "Set the base UNIBUS address for the Chaos net device.
62Argument is optional and defaults to 764140.  Defines various
63special variables and read and prints the host address of
64the device at the specified address."
65
66    (SETQ CONTROL-STATUS-REGISTER-TEST BASE-ADDRESS
67          MY-NUMBER-REGISTER-TEST (+ BASE-ADDRESS (LSH %CHAOS-MY-NUMBER-OFFSET 1))
68          WRITE-BUFFER-REGISTER-TEST (+ BASE-ADDRESS (LSH %CHAOS-WRITE-BUFFER-OFFSET 1))
69          READ-BUFFER-REGISTER-TEST (+ BASE-ADDRESS (LSH %CHAOS-READ-BUFFER-OFFSET 1))
70          BIT-COUNT-REGISTER-TEST (+ BASE-ADDRESS (LSH %CHAOS-BIT-COUNT-OFFSET 1))
71          INITIATE-TRANSFER-REGISTER-TEST
72          (+ BASE-ADDRESS (LSH %CHAOS-START-TRANSMIT-OFFSET 1))
73          INTERVAL-TIMER-REGISTER-TEST
74          (+ BASE-ADDRESS 20))
75    (FORMAT T "~%My number: ~O" (setq chatst-address (%unibus-read MY-NUMBER-REGISTER-TEST))))
76
77(SET-BASE-ADDRESS)
78
79(DEFVAR CHATST-PATTERN (MAKE-ARRAY NIL 'ART-16B 256.))
80
81(DEFVAR CHATST-PATTERN-TYPE 0)
82
83(DEFUN SET-PATTERN (PAT)
84  (SETQ CHATST-PATTERN-TYPE PAT)
85  (DO I 0 (1+ I) (= I 20)
86    (AS-1 (COND ((EQ PAT 'FLOATING-ONE) (LSH 1 I))
87                ((EQ PAT 'FLOATING-ZERO) (LOGXOR (LSH 1 I) -1))
88                ((EQ PAT 'ADDRESS) I)
89                ((NUMBERP PAT) PAT)
90                ((ERROR "BAD PATTERN" I)))
91          CHATST-PATTERN
92          I)))
93
94(SET-PATTERN 'FLOATING-ONE)                     ;REASONABLE DEFAULT
95
96(DEFVAR CHATST-USE-RECEIVE-ALL T)               ;reasonable???
97
98(DEFUN CHATST ()
99    "Standard test function for the chaos network interface.
100If it passes this test, sending and receiving packets from the network
101probably works.  Use SET-NCP-BASE-ADDRESS to give it a full test.
102Things not tested by this function include UNIBUS interrupts, bus grant
103logic, etc.  This function cycles through several bit patterns, sending
1044 packets with each pattern, both in loopback and out on the cable.
105It does not send a properly formated packet with a header, but just
106a packet of raw bits."
107    (CHATST-RESET)
108    (DOLIST (PAT '(FLOATING-ONE FLOATING-ZERO ADDRESS 52525 0 177777))
109      (FORMAT T "~%Pattern:  ~A ~%Using Loopback ~%" PAT)
110      (SET-PATTERN PAT)
111      (LET ((CHATST-USE-RECEIVE-ALL T))
112        (DO I 0 (1+ I) (= I 4) (CHATST-PREP T) (CHATST-XMT) (CHATST-RCV)))
113      (FORMAT T "~%Using the cable ~%")
114      (LET ((CHATST-USE-RECEIVE-ALL NIL))
115        (DO I 0 (1+ I) (= I 4) (CHATST-PREP NIL) (CHATST-XMT) (CHATST-RCV T)))))
116
117(DEFUN CHATST-ONCE (&OPTIONAL (LOOPBACK NIL) (CHATST-USE-RECEIVE-ALL LOOPBACK))
118  "Like CHATST, but only tries the currently defined pattern.  Call SET-PATTERN
119to change the pattern."
120  (CHATST-RESET)
121  (FORMAT T "~%Loopback: ~A,  Pattern:  ~A" LOOPBACK CHATST-PATTERN-TYPE)
122  (DO I 0 (1+ I) (= I 4) (CHATST-PREP NIL) (CHATST-XMT) (CHATST-RCV T)))
123
124(DEFUN CHATST-TR-LOOP (&OPTIONAL LOOPBACK &AUX (CHATST-USE-RECEIVE-ALL LOOPBACK))
125  (CHATST-RESET)
126  (DO () ((KBD-TYI-NO-HANG)) (CHATST-PREP LOOPBACK) (CHATST-XMT) (CHATST-RCV T)))
127
128(DEFUN CHATST-XMT ()
129    "Send a packet consisting of 16 rotating 1's and my address."
130    (DO I 0 (1+ I) (= I 20)
131        (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
132    (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (%UNIBUS-READ MY-NUMBER-REGISTER-TEST))
133    (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST ;improve chances of avoiding an abort
134                   (LOGIOR 10 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST)))
135    (%UNIBUS-READ INITIATE-TRANSFER-REGISTER-TEST))
136
137(DEFUN CHATST-PACKET (&OPTIONAL (CABLE-DEST 440))       ;MC-11
138    "Send a packet to some host (defaults to MC) which it will echo back."
139  (DO () ((bit-test 200 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST)))) ;AWAIT TDONE
140  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST 100000)  ;DATA
141  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST 40) ;NBYTES
142  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST 1440)       ;MC
143  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST 0)
144  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST chatst-address)     ;LISPM
145  (DO I 0 (1+ I) (= I 3)                        ;SEND THE PATTERN AS IDX, PKT, ACK
146    (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
147  (DO I 0 (1+ I) (= I 20)                       ;SEND THE PATTERN AS 40 BYTES OF DATA
148    (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
149  (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST CABLE-DEST)
150  (%UNIBUS-READ INITIATE-TRANSFER-REGISTER-TEST))
151
152
153(DEFUN CHATST-LOOP (&OPTIONAL (CABLE-DEST 440) (LOOP-BACK-P NIL))       ;MC-11, NO LOOPBACK
154    "Scope loop, ignore what is received (defaults to mc)"
155    (DO () ((KBD-TYI-NO-HANG))
156      (CHATST-PREP LOOP-BACK-P)
157      (CHATST-PACKET CABLE-DEST)))
158
159;;; Prepare the interface to receive.
160(DEFUN CHATST-PREP (LOOPBACK-P)
161  (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST
162                 (+ (COND ((NOT LOOPBACK-P) 10) (T 12))
163                    (COND ((NOT CHATST-USE-RECEIVE-ALL) 0) (T 4)))))
164
165(DEFUN CHATST-RESET ()
166    (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 20000))
167
168(SETQ INBUF (MAKE-ARRAY NIL 'ART-16B 256.))
169(DECLARE (SPECIAL INBUF))
170
171;;; Look for a received packet, and complain in various ways.
172(DEFUN CHATST-RCV ( &OPTIONAL BUSY-WAIT (CNT 16.) &AUX CSR TEM ME LOSE)
173  (IF BUSY-WAIT
174      (DO () ((LDB-TEST %%CHAOS-CSR-RECEIVE-DONE
175                        (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))))
176      (PROCESS-SLEEP 10.))  ;Give it time to arrive
177  (SETQ CSR (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
178  (SETQ ME (%UNIBUS-READ MY-NUMBER-REGISTER-TEST))
179  (IF (NOT (ZEROP (LDB-TEST %%CHAOS-CSR-TRANSMIT-ABORT CSR)))
180      (FORMAT t "~%Transmit aborted, then~%"))
181  (COND ((NOT (LDB-TEST %%CHAOS-CSR-RECEIVE-DONE CSR))
182         (SETQ LOSE T) (PRINT 'NO-RECEIVE))
183        (T (AND (LDB-TEST %%CHAOS-CSR-CRC-ERROR CSR)
184                (PROGN (SETQ LOSE T)
185                       (PRINT '"CRC Error indicated (check the data)")))
186           (OR (= (%UNIBUS-READ BIT-COUNT-REGISTER-TEST) (1- (* 16. (+ 3 CNT))))
187               (PROGN (SETQ LOSE T)
188                      (PRINT (LIST (%UNIBUS-READ BIT-COUNT-REGISTER-TEST) 'BAD-BIT-COUNT))))
189           (DO I 0 (1+ I) (= I CNT)
190             (AS-1 (%UNIBUS-READ READ-BUFFER-REGISTER-TEST) INBUF I))
191           (OR (= (SETQ TEM (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)) ME)
192               (PROGN (SETQ LOSE T)
193                      (FORMAT T "~% DEST=~O SHOULD=~O" TEM ME)))
194           (OR (= (SETQ TEM (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)) ME)
195               (PROGN (SETQ LOSE T)
196                      (FORMAT T "~% SOURCE=~O SHOULD=~O" TEM ME)))
197           (DO ((I 0 (1+ I))
198                (K))
199               ((= I CNT) (IF LOSE (PRINT "Data returned was correct")))
200             (SETQ K (AR-1 CHATST-PATTERN I))
201             (COND (( K (AR-1 INBUF I))
202                    (SETQ LOSE T)
203                    (TERPRI) (PRINC "LOC    GOOD   BAD")
204                    (DO I 0 (1+ I) (= I CNT)
205                      (FORMAT T "~%~2O  ~6O ~6O" I (AR-1 CHATST-PATTERN I) (AR-1 INBUF I)))
206                    (RETURN NIL))))))
207  (OR LOSE (FORMAT T "~&WIN")))
208
209;;; Monitor the Net for traffic
210
211(DEFUN CHATST-MONITOR (&OPTIONAL (SHORT-P T) &AUX BITS cnt)
212 "Monitor all network traffic.  This will often tell you if your interface or
213  transceiver has trouble receiving packets from a particular host.  It all
214  may tell you if something strange is happening on the network, such as
215  a random host sending garbage packets, etc."
216  (CHATST-RESET)
217      (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 14)        ;reset rcvr, RCV ALL
218  (DO () ((KBD-CHAR-AVAILABLE) (KBD-TYI-NO-HANG))
219    (DO ((i 0 (1+ i)))
220        ((> I 50.) (FORMAT T "."))
221      (COND ((bit-test 100000 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
222             (FORMAT T "~%---------------------~%")
223             (AND (LDB-TEST %%CHAOS-CSR-CRC-ERROR (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
224                  (FORMAT T "CRC-Error "))
225             (SETQ BITS (1+ (%UNIBUS-READ BIT-COUNT-REGISTER-TEST))
226                   CNT (// BITS 16.))
227             (OR (ZEROP (\  BITS 16.))
228                 (FORMAT T "Bad bit count, is ~O" BITS))
229             (COND ((AND SHORT-P (> CNT 8))
230                    (DO I 0 (1+ I) (= I 5)
231                        (FORMAT T "~&~O   ~O" I (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)))
232                    (FORMAT T "~%     ...")
233                    (DO I 0 (1+ I) ( I (- CNT 8))(%UNIBUS-READ READ-BUFFER-REGISTER-TEST))
234                    (DO I (- CNT 3) (1+ I) (= I CNT)
235                        (FORMAT T "~%~O   ~O" I (%UNIBUS-READ READ-BUFFER-REGISTER-TEST))))
236                   (T (DO I 0 (1+ I) (= I CNT)
237                          (FORMAT T "~&~O   ~O" I (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)))))
238             (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 14)        ;reset rcvr, RCV ALL
239             (RETURN NIL)))))
240  (CHATST-RESET))
241
242
243(DECLARE (SPECIAL CHATST-HEADER))
244(SETQ CHATST-HEADER (MAKE-ARRAY NIL 'ART-16B 8))
245
246(DEFUN CHATST-SET-HEADER NIL
247   (AS-1 100000 CHATST-HEADER 0)                   ;OPCODE (DATA)
248   (AS-1 0 CHATST-HEADER 1)                        ;LENGTH IN BYTES
249   (AS-1 chatst-address CHATST-HEADER 2)               ;DESTINATION (CAUSE FORWARDING)
250   (AS-1 0 CHATST-HEADER 3)
251   (AS-1 chatst-address CHATST-HEADER 4)               ;SOURCE
252   (DO I 0 (1+ I) (= I 3)                          ;SRC-IDX, PK#, ACK#
253       (AS-1 (AR-1 CHATST-PATTERN I) CHATST-HEADER (+ I 5))))
254
255(CHATST-SET-HEADER)                                ;Setup an echo header
256
257(DEFUN CHATST-ECHO (&OPTIONAL (DEST 440)  (LEN 20))
258  (CHATST-RESET)
259  (SETQ LEN (MIN LEN 248.))         ;4096.-header
260  (AS-1 (* LEN 2) CHATST-HEADER 1)
261  (DO ((pat1 0 (1+ pat1))
262       (pat2 (random) (random)))
263      ((KBD-TYI-NO-HANG))
264    (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 10)        ;reset rcvr
265      (do i 0 (+ i 2) ( i len)
266          (as-1 pat1 chatst-pattern i)
267          (as-1 pat2 chatst-pattern (1+ i)))
268      (format t "~%Patterns ~O, ~O" pat1 pat2)
269      ;;Try this pattern 10. times
270      (do ((j 0 (1+ j))) ((= j 10.))
271          (DO ((i 0 (1+ i)))
272              ((bit-test 200 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))) ;AWAIT TDONE
273              (COND ((> i 50.)
274                     (FORMAT T "~% TDONE timeout")
275                     (RETURN NIL))))
276          (DO I 0 (1+ I) (= I 8)    ;Fill in IDX, PKT, ACK with pattern
277              (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-HEADER I)))
278          (DO I 0 (1+ I) (= I LEN)
279              (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
280          (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 10)    ;reset rcvr
281          (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST DEST)
282          (%UNIBUS-READ INITIATE-TRANSFER-REGISTER-TEST)     ;start xmission
283          (DO ((i 0 (1+ i)))
284              ((> I 1000.) (FORMAT T "~% Rcv-done timeout"))
285              (COND ((BIT-TEST 100000 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
286                     (CHATST-CHECK-PK DEST LEN)
287                     (RETURN NIL)))) )))
288
289;;Scope trace - echo from some host
290
291(DEFUN CHATST-BUZZ (&OPTIONAL (DEST 440) (LEN 20))
292  (CHATST-RESET)
293  (SETQ LEN (MIN LEN 248.))         ;4096.-header
294  (AS-1 (* LEN 2) CHATST-HEADER 1)
295  (DO () ((KBD-TYI-NO-HANG)(CHATST-PRINT-STATUS DEST LEN))
296      (as-1 (1+ (ar-1 chatst-pattern 0)) chatst-pattern 0)
297      ;;Try this pattern 10. times
298      (do ((j 0 (1+ j))) ((= j 10.))
299          ;;Wait for Transmit side idle
300          (DO ((i 0 (1+ i)))
301              ((bit-test 200 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST)))
302              (COND ((> i 50.)
303                     (FORMAT T "~% TDONE timeout")
304                     (RETURN NIL))))
305          ;;Fill in header, data with pattern
306          (DO I 0 (1+ I) (= I 8)
307              (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-HEADER I)))
308          (DO I 0 (1+ I) (= I LEN)
309              (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
310          (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST DEST)
311          ;;Now wait for echoed packet
312          (DO ((i 0 (1+ i)))
313              ((> I 50.))
314              (COND ((bit-test 100000 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
315                     (RETURN NIL))))
316          (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST (IF (= DEST 0) 12 10))
317          (%UNIBUS-READ INITIATE-TRANSFER-REGISTER-TEST))))
318
319(DEFUN CHATST-PRINT-STATUS ( &OPTIONAL (DEST 100) (LEN 16.))
320  (TERPRI)
321  (PROCESS-SLEEP 30.)  ;Give it time to arrive
322  (CHATST-STATUS)                                           ;Decode status
323  (CHATST-CHECK-PK DEST LEN)                             ;Check if any errors in PK
324)
325
326
327(DEFUN CHATST-CHECK-PK (&OPTIONAL (DEST-HOST 100) (CNT 16.) &AUX DEST CSR TEM ME BITS)
328  (SETQ CSR (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST)
329        ME (%UNIBUS-READ MY-NUMBER-REGISTER-TEST)
330        BITS (1- (* 16. (+ 11. CNT)))
331        DEST DEST-HOST)
332  (AND (LDB-TEST %%CHAOS-CSR-CRC-ERROR CSR)
333       (PRINT 'CRC-ERROR))
334  (OR (= (SETQ TEM (%UNIBUS-READ BIT-COUNT-REGISTER-TEST)) BITS)
335      (FORMAT T "~%Bad bit count, is ~O, should be ~O" TEM BITS))
336  (DO I 0 (1+ I) (= I (+ 8 CNT))
337      (AS-1 (%UNIBUS-READ READ-BUFFER-REGISTER-TEST) INBUF I))
338  (OR (= (SETQ TEM (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)) ME)
339         (FORMAT T "~% DEST=~O, should be ~O"  TEM ME))
340  (OR (= (SETQ TEM (%UNIBUS-READ READ-BUFFER-REGISTER-TEST)) DEST)
341         (FORMAT T "~% SOURCE=~O, should be ~O"  TEM DEST))
342  (AS-1 (LOGAND (AR-1 INBUF 1) 7777) INBUF 1)           ;FLUSH FORWARDING COUNT
343  (DO I 0 (1+ I) (= I 8)
344      (COND (( (AR-1 CHATST-HEADER I) (AR-1 INBUF I))
345             (TERPRI) (PRINC "HEADER  SENT    RCVD")
346             (DO I 0 (1+ I) (= I 8)
347                 (FORMAT T "~%~2O  ~6O ~6O" I (AR-1 CHATST-HEADER I) (AR-1 INBUF I)))
348             (RETURN NIL))))
349  (DO ((I 0 (1+ I)) (J 8 (1+ J))) ((= I CNT))
350      (COND (( (AR-1 CHATST-PATTERN I) (AR-1 INBUF J))
351             (TERPRI) (PRINC "LOC    SENT    RCVD")
352             (DO ((I 0 (1+ I))(J 8 (1+ J))) ((= I CNT))
353                 (FORMAT T "~%~2O  ~6O ~6O" I (AR-1 CHATST-PATTERN I) (AR-1 INBUF J)))
354             (RETURN NIL))))
355  (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 10)    ;reset rcvr
356)
357
358(DEFUN CHATST-ECHO-ONCE (&OPTIONAL (DEST 500) (LEN 20))
359       (DO ()((bit-test 200 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))))
360       (DO I 0 (1+ I) (= I LEN)                 ;SEND THE PATTERN AS 40 BYTES OF DATA
361           (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST (AR-1 CHATST-PATTERN I)))
362      (%UNIBUS-WRITE WRITE-BUFFER-REGISTER-TEST DEST)
363      (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 10)    ;reset rcvr
364      (%UNIBUS-READ INITIATE-TRANSFER-REGISTER-TEST)
365      (DO ((i 0 (1+ i)))
366          ((or (bit-test 200 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
367               (> i 50.)))) ;AWAIT TDONE
368      (%UNIBUS-WRITE CONTROL-STATUS-REGISTER-TEST 14)        ;RCV ALL
369      (CHATST-PRINT-STATUS DEST LEN))
370
371(DEFUN CHATST-STATUS ( &AUX CSR LC)
372    "Describes the bits currently on in the control status register for the
373board being tested."
374    (SETQ CSR (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
375    (FORMAT T "~2%CSR = ~O~%" CSR)
376    (AND (LDB-TEST %%CHAOS-CSR-TIMER-INTERRUPT-ENABLE CSR)
377         (FORMAT T "Timer interrupt enable. ?? ~%"))  ;This bit doesnt seem to do anything.
378;    (AND (LDB-TEST %%CHAOS-CSR-TRANSMIT-BUSY CSR)
379;        (FORMAT T "Transmit busy.~%"))
380    (AND (LDB-TEST %%CHAOS-CSR-LOOP-BACK CSR)
381         (FORMAT T "Loopback.~%"))
382    (AND (LDB-TEST %%CHAOS-CSR-RECEIVE-ALL CSR)
383         (FORMAT T "Receive all messages mode is on.~%"))
384    (AND (LDB-TEST %%CHAOS-CSR-RECEIVE-ENABLE CSR)
385         (FORMAT T "Receiver interrupt enabled.~%"))
386    (AND (LDB-TEST %%CHAOS-CSR-TRANSMIT-ENABLE CSR)
387         (FORMAT T "Transmit interrupt enabled.~%"))
388    (AND (LDB-TEST %%CHAOS-CSR-TRANSMIT-ABORT CSR)
389         (FORMAT T "Transmit aborted by collision.~%"))
390    (AND (LDB-TEST %%CHAOS-CSR-TRANSMIT-DONE CSR)
391         (FORMAT T "Transmit done.~%"))
392    (OR  (ZEROP (SETQ LC (LDB %%CHAOS-CSR-LOST-COUNT CSR)))
393         (FORMAT T "Lost count = ~O~%" LC))
394    (AND (LDB-TEST %%CHAOS-CSR-RESET CSR)
395         (FORMAT T "I//O reset.~%"))
396    (AND (LDB-TEST %%CHAOS-CSR-CRC-ERROR CSR)
397         (FORMAT T "==> CRC ERROR!!! <==~%"))
398    (AND (LDB-TEST %%CHAOS-CSR-RECEIVE-DONE CSR)
399         (FORMAT T "Receive done.~%"))
400    (FORMAT T "Bit count: ~O~%" (%UNIBUS-READ BIT-COUNT-REGISTER-TEST))
401    NIL)
402
403(DEFUN CHATST-SOAK (&AUX (M-ONES 0) (OTHERS 0))
404  (%unibus-write control-status-register-test 14)
405  (DO () ((KBD-TYI-NO-HANG) (FORMAT T "~%-1 length packets ~O, others ~O" m-ones others))
406    (COND ((bit-test 100000 (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST))
407;          (DO ((I 0 (1+ I))) ((> I 10.))
408;            (FORMAT T "~%~O" (%UNIBUS-READ CONTROL-STATUS-REGISTER-TEST)))
409           (let ((tem (%unibus-read bit-count-register-test)))
410             (if (= tem 7777)                   ;Null packet "received"
411                 (setq m-ones (1+ m-ones))
412                 (setq others (1+ others))))
413               (%unibus-write control-status-register-test 14)))))
414
415
416(DEFUN SET-NCP-BASE-ADDRESS (ADDR &AUX (OLD-CSR CONTROL-STATUS-REGISTER))
417 "Set the base address that the NCP uses for all Chaos net functions.
418NOTE!!!! A bus grant jumper must be run to the board you are debugging in
419order for interrupts to work!  This function makes the board you are debugging
420used for everything, rather than the default."
421  (SET-BASE-ADDRESS ADDR)
422  (SETQ BASE-ADDRESS ADDR
423        CONTROL-STATUS-REGISTER BASE-ADDRESS
424        MY-NUMBER-REGISTER (+ BASE-ADDRESS (LSH %CHAOS-MY-NUMBER-OFFSET 1))
425        WRITE-BUFFER-REGISTER (+ BASE-ADDRESS (LSH %CHAOS-WRITE-BUFFER-OFFSET 1))
426        READ-BUFFER-REGISTER (+ BASE-ADDRESS (LSH %CHAOS-READ-BUFFER-OFFSET 1))
427        BIT-COUNT-REGISTER (+ BASE-ADDRESS (LSH %CHAOS-BIT-COUNT-OFFSET 1))
428        INITIATE-TRANSFER-REGISTER (+ BASE-ADDRESS (LSH %CHAOS-START-TRANSMIT-OFFSET 1)))
429
430  (SETQ SI:%CHAOS-CSR-ADDRESS
431        (SI:MAKE-24-BIT-UNSIGNED (+ 77400000 (LSH ADDR -1))))  ; SET THE A MEMORY LOCATION
432  (INITIALIZE-NCP-SYSTEM)
433  (%UNIBUS-WRITE OLD-CSR 20010)                 ;avoid interrupt hang screw
434  (%UNIBUS-WRITE CONTROL-STATUS-REGISTER 20010)
435  (FORMAT NIL "NCP now using ~6O as the network interface base address." ADDR))
436
437
438(DEFUN TIMER-LOOP (&OPTIONAL (COUNT 511.) (SLEEP-TIME 1))
439  "Scope loop for looking at the interval timer."
440  (DO NIL ((KBD-TYI-NO-HANG))
441    (%UNIBUS-WRITE INTERVAL-TIMER-REGISTER-TEST COUNT)
442    (PROCESS-SLEEP SLEEP-TIME)))
Note: See TracBrowser for help on using the repository browser.