Skip to content

Commit 3fc9438

Browse files
committed
Check checksum on CH11 under KLH10
1 parent b7fc027 commit 3fc9438

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/system/chaos.291

+35
Original file line numberDiff line numberDiff line change
@@ -2426,29 +2426,49 @@ BBLK
24262426
JRST [ AOS CHNLOS ;No buffers, lose this packet
24272427
JRST CHXBK1 ]
24282428
HRLI A,-%CPKDT ;Copy out the packet header
2429+
IFN KLH10P,[
2430+
;; The KLH10P-marked code is a workaround for a bug in the
2431+
;; KLH10 implementation of the CH11. It seems to be a synchronization
2432+
;; bug which results in packets being corrupted after being received
2433+
;; from the net, and before being read by the 10.
2434+
;; The workaround is to compute the checksum here, and verify it.
2435+
;; When someone either fixes the CH11 bug or simply reimplements it,
2436+
;; this code should be taken out again.
2437+
;; Note that the performance impact is very small.
2438+
;; /BV November 2024.
2439+
;; (Side note: is "ADDI J,(B)" faster than "ADD J,B"?)
2440+
IFN KLH10P,SETZ J, ; Clear checksum
24292441
CHSRC1: IORDI B,CAIRBF
2442+
IFN KLH10P,ADD J,B
24302443
IORDI C,CAIRBF
2444+
IFN KLH10P,ADD J,C
24312445
PACK16 B,(A)
24322446
AOBJN A,CHSRC1
24332447
PUSHJ P,CHSHDR ;Decode the header
24342448
JRST CHSRC4 ;No byte swapping
24352449
JUMPGE D,CHSRC3
24362450
CHSRC2: IORDI B,CAIRBF ;Read out the data, byte-swapped
2451+
IFN KLH10P,ADD J,B
24372452
IORDI C,CAIRBF
2453+
IFN KLH10P,ADD J,C
24382454
PACK8 B,(D)
24392455
AOBJN D,CHSRC2
24402456
CHSRC3: JUMPGE H,CHSRC7 ;Jump if even packet length
24412457
IORDI B,CAIRBF ;Residual halfword
2458+
IFN KLH10P,ADD J,B
24422459
SETZ C, ;Somebody depends on zero here
24432460
PACK8 B,(D)
24442461
AOJA D,CHSRC7
24452462

24462463
CHSRC4: JUMPGE D,CHSRC6
24472464
CHSRC5: IORDI B,CAIRBF ;Read out the data, halfwords
2465+
IFN KLH10P,ADD J,B
24482466
IORDI C,CAIRBF
2467+
IFN KLH10P,ADD J,C
24492468
PACK16 B,(D)
24502469
AOBJN D,CHSRC5
24512470
CHSRC6: JUMPL H,[ IORDI B,CAIRBF ;Residual halfword
2471+
IFN KLH10P, ADD J,B
24522472
SETZ C, ;Somebody depends on zero here
24532473
PACK16 B,(D)
24542474
AOJA D,CHSRC7 ]
@@ -2457,8 +2477,23 @@ CHSRC7: SUB D,R ;AOBJN pointer minus number of words in packet
24572477
JRST [ AOS CHNPLE ;Packet length disagrees with hardware length
24582478
JRST CHXBK2 ]
24592479
IORDI T,CAIRBF ;Read the three hardware header words
2480+
IFN KLH10P,ADD J,T
24602481
IORDI T,CAIRBF
2482+
IFN KLH10P,ADD J,T
24612483
IORDI T,CAIRBF
2484+
IFN KLH10P,ADD J,T
2485+
IFN KLH10P,[ ; Wrap it up - see IPCKS3
2486+
CHSRCZ::CAILE J,177777 ; Does the checksum fit?
2487+
JRST [ LDB Q,[202400,,J] ; No, get overflow bits
2488+
ANDI J,177777 ; then clear them
2489+
ADDI J,(Q) ; and add at low end
2490+
JRST CHSRCZ ]
2491+
ANDCAI J,177777 ; Make ones complement
2492+
JUMPE J,CHSRCY ; No problem
2493+
AOS CHNCR2 ; CRC checksum error after reading
2494+
;; BUG CHECK,[Chaos: CRC error - cks =],OCT,J
2495+
JRST CHXBK2
2496+
CHSRCY::]
24622497
IORDI T,CAICSR
24632498
TRNE T,%CAERR ;Make sure packet came out of RAM okay
24642499
JRST [ AOS CHNCR2 ;Garbage, try again

0 commit comments

Comments
 (0)