From a93bea20e1eeb16ad3c415c3dcfb0eef9a7e9d91 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 9 Aug 2018 01:42:12 +0100 Subject: [PATCH] WIP: Produces an ARP reply that slirp responds to! --- src/system/ether.1 | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/system/ether.1 b/src/system/ether.1 index 0a7fecc1..4ed04e93 100644 --- a/src/system/ether.1 +++ b/src/system/ether.1 @@ -22,10 +22,10 @@ %NE8==377 .BEGIN %NEH ;Fields in the Ethernet header - LENGTH==<2+6+6+2> + PAD==2 ;padding at start of buffer + LENGTH== WORDS== - PAD==<.BP <%NE16_20.>,0> ;FIXME Would all the MAC stuff be easier if this was 3 16-bit fields? DMAC0==<.BP <%NE16_4>,0> DMAC12==<.BP <%NE32_4>,1> @@ -99,6 +99,7 @@ IPKSNE: BUG INFO,[ipksne] ETHRX: MOVEI TT,ETHHBF ;Unpack Ethernet header into ETHHBF HRL TT,R BLTUB TT, + BUG INFO,[RX packet length ],OCT,I,[ ptr ],OCT,R SUBI I,%NEH"LENGTH ;I now contains data length ADDI R,%NEH"WORDS ;R points to data @@ -113,7 +114,8 @@ ETHRX: MOVEI TT,ETHHBF ;Unpack Ethernet header into ETHHBF ;Process an ARP packet. ; -ETHRXA: CAIN I,%NEAH"LENGTH ;Check size first +ETHRXA: BUG INFO,[ARP length ],OCT,I + CAIGE I,%NEAH"LENGTH ;Check size first JRST ETHRAS MOVEI TT,ETHABF ;Unpack packet into ETHABF @@ -195,7 +197,7 @@ ETHRX3: DPB A,[%NEAT"PA+ETHAT(E)] ;Store IP address MOVEI I,%NEAH"LENGTH JRST ETHTX -ETHRAS: BUG INFO,[ARP wrong size packet ],OCT,I +ETHRAS: BUG INFO,[ARP packet too short, length ],OCT,I POPJ P, ETHRAH: BUG INFO,[ARP wrong hardware type ],OCT,B POPJ P, @@ -227,14 +229,14 @@ ETHTX: BUG INFO,[ethtx ptr ],OCT,R,[ len ],OCT,I HRL TT,R MOVE A,I ADDI A,3 - IDIVI A,4 + LSH A,-2 ADD A,B - MOVE C,TT - BUG INFO,[ethtx bltbu tt ],OCT,C,[ a ],OCT,A + MOVE C,TT ;XXX + BUG INFO,[ethtx data bltbu tt ],OCT,C,[ a ],OCT,A BLTBU TT,(A) - ADDI I,%NEH"LENGTH ;Add length of header - BUG INFO,[ethtx end buf ],OCT,B,[ desc ],OCT,D,[ len ],OCT,I + ADDI I,%NEH"LENGTH-%NEH"PAD ;Add length of header + BUG INFO,[ethtx end desc ],OCT,D,[ len ],OCT,I JRST UNATX ;Transmit it ;Check whether the interface is able to send a packet. @@ -396,7 +398,7 @@ IFE 0,[ SETZM C ;Buffer index UNAIN2: MOVE TT,C ;Work out index into UNPAGS/UNPAGU - IDIVI TT,2 + LSH TT,-1 AOS TT HLRZ B,UNPAGU(TT) ;Get Unibus addr. Even on the left... TRNE C,1 @@ -412,7 +414,7 @@ UNAIN2: MOVE TT,C ;Work out index into UNPAGS/UNPAGU MOVE A,UNTXRP(C) ;BUG INFO,[ring],OCT,C,[ptr],OCT,A - MOVSI A,%UNBSZ ;SLEN (only useful for recv at this point) + MOVSI A,%UNBSZ ;SLEN (only used for recv) HRR A,B ;SEGB low bits MOVEM A,0(D) ;BUG INFO,[t/rdr ],OCT,C,[ at ],OCT,D,[ 0/1 = ],OCT,A @@ -560,6 +562,7 @@ UNARX1: HRRZ A,W ;Wrap index around HRRZ R,UNRXRP(W) ;Buffer LDB I,[.BP 7777,1(J)] ;Get MLEN + SUBI I,4 ;Ignore CRC at end PUSHJ P,ETHRX UNARX3: TLO Q,%UNTD"OWN ;Set OWN=1 to mark as free @@ -610,11 +613,11 @@ UNAFF1: HRRZ A,E ;Wrap index around AOS (P) ;Skip return POPJ P, -;Transmit a packet from a buffer obtained by UNAFF. -;Descriptor in D, buffer in B, data length in bytes in I. +;Transmit a packet from a descriptor obtained by UNAFF. +;Descriptor in D, data length in bytes in I. ;Clobbers A. ; -UNATX: BUG INFO,[unatx desc ],OCT,D,[ buff ],OCT,B,[ length ],OCT,I +UNATX: BUG INFO,[unatx desc ],OCT,D,[ length ],OCT,I HRLM I,0(D) ;Set SLEN MOVSI A,%UNTD"OWN+%UNTD"STF+%UNTD"ENF IORM A,1(D) ;Set flags