Skip to content

Commit

Permalink
Merge branch 'master' into lars/fix-mchokp
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff authored Nov 21, 2024
2 parents fb5f7f5 + 4557f5d commit e37fefa
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/system/chaos.291 → src/system/chaos.292
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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
Expand Down

0 comments on commit e37fefa

Please sign in to comment.