1
0
mirror of https://github.com/PDP-10/its.git synced 2026-02-27 09:18:58 +00:00

Check checksum on CH11 under KLH10

This commit is contained in:
Björn Victor
2024-11-19 19:07:23 +01:00
committed by Lars Brinkhoff
parent b7fc0277e1
commit 4557f5dac3

View File

@@ -2426,29 +2426,47 @@ BBLK
JRST [ AOS CHNLOS ;No buffers, lose this packet
JRST CHXBK1 ]
HRLI A,-%CPKDT ;Copy out the packet header
;; The KLH10P-marked code is a workaround for a bug in the
;; KLH10 implementation of the CH11. It seems to be a synchronization
;; bug which results in packets being corrupted after being received
;; from the net, and before being read by the 10.
;; The workaround is to compute the checksum here, and verify it.
;; When someone either fixes the CH11 bug or simply reimplements it,
;; this code should be taken out again.
;; Note that the performance impact is very small.
;; /BV November 2024.
IFN KLH10P,SETZ J, ; Clear checksum
CHSRC1: IORDI B,CAIRBF
IFN KLH10P,ADD J,B
IORDI C,CAIRBF
IFN KLH10P,ADD J,C
PACK16 B,(A)
AOBJN A,CHSRC1
PUSHJ P,CHSHDR ;Decode the header
JRST CHSRC4 ;No byte swapping
JUMPGE D,CHSRC3
CHSRC2: IORDI B,CAIRBF ;Read out the data, byte-swapped
IFN KLH10P,ADD J,B
IORDI C,CAIRBF
IFN KLH10P,ADD J,C
PACK8 B,(D)
AOBJN D,CHSRC2
CHSRC3: JUMPGE H,CHSRC7 ;Jump if even packet length
IORDI B,CAIRBF ;Residual halfword
IFN KLH10P,ADD J,B
SETZ C, ;Somebody depends on zero here
PACK8 B,(D)
AOJA D,CHSRC7
CHSRC4: JUMPGE D,CHSRC6
CHSRC5: IORDI B,CAIRBF ;Read out the data, halfwords
IFN KLH10P,ADD J,B
IORDI C,CAIRBF
IFN KLH10P,ADD J,C
PACK16 B,(D)
AOBJN D,CHSRC5
CHSRC6: JUMPL H,[ IORDI B,CAIRBF ;Residual halfword
IFN KLH10P, ADD J,B
SETZ C, ;Somebody depends on zero here
PACK16 B,(D)
AOJA D,CHSRC7 ]
@@ -2457,8 +2475,23 @@ CHSRC7: SUB D,R ;AOBJN pointer minus number of words in packet
JRST [ AOS CHNPLE ;Packet length disagrees with hardware length
JRST CHXBK2 ]
IORDI T,CAIRBF ;Read the three hardware header words
IFN KLH10P,ADD J,T
IORDI T,CAIRBF
IFN KLH10P,ADD J,T
IORDI T,CAIRBF
IFN KLH10P,ADD J,T
IFN KLH10P,[ ; Wrap it up - see IPCKS3
CHSRCZ::CAILE J,177777 ; Does the checksum fit?
JRST [ LDB Q,[202400,,J] ; No, get overflow bits
ANDI J,177777 ; then clear them
ADDI J,(Q) ; and add at low end
JRST CHSRCZ ]
ANDCAI J,177777 ; Make ones complement
JUMPE J,CHSRCY ; No problem
AOS CHNCR2 ; CRC checksum error after reading
;; BUG CHECK,[Chaos: CRC error - cks =],OCT,J
JRST CHXBK2
CHSRCY::]
IORDI T,CAICSR
TRNE T,%CAERR ;Make sure packet came out of RAM okay
JRST [ AOS CHNCR2 ;Garbage, try again