diff --git a/src/system/chaos.291 b/src/system/chaos.292 similarity index 98% rename from src/system/chaos.291 rename to src/system/chaos.292 index 88daed215..c4be842ea 100644 --- a/src/system/chaos.291 +++ b/src/system/chaos.292 @@ -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