1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-08-11 13:25:02 +00:00

Fix TCP/IP bitrot and last dataseg zero length symbol overlap with code seg

This commit is contained in:
David Schmenk
2018-01-24 18:08:18 -08:00
parent b0535cd972
commit 5769cf67be
9 changed files with 57 additions and 59 deletions

View File

@@ -87,22 +87,14 @@ byte[] endDHCP
// //
// DEBUG // DEBUG
// //
//byte boundstr = "Apple II bound to:\n" def putip(ipptr)#0
//byte dnsstr = "DNS: " byte i
//def putb(hexb)
// return call($FDDA, hexb, 0, 0, 0) for i = 0 to 2
//end puti(ipptr->[i]); putc('.')
//def puth(hex) next
// return call($F941, hex >> 8, hex, 0, 0) puti(ipptr->[i])
//end end
//def putip(ipptr)
// byte i
//
// for i = 0 to 2
// puti(ipptr->[i]); putc('.')
// next
// puti(ipptr->[i])
//end
//def dumpbytes(buf, len) //def dumpbytes(buf, len)
// word i // word i
// //
@@ -132,13 +124,13 @@ def parseopts(opts, match)
i = 0 i = 0
while opts->[i] <> $FF and i < 64 while opts->[i] <> $FF and i < 64
while !opts->[i] and i < 64 while !opts->[i] and i < 64
i = i + 1 i++
loop loop
if opts->[i] == match if opts->[i] == match
return i return i
fin fin
i = i + opts->[i + 1] + 2 i = i + opts->[i + 1] + 2
loop loop
return -1 return -1
end end
@@ -224,7 +216,7 @@ repeat
until retry > 4 or optsOP.2 == DHCP_ACK until retry > 4 or optsOP.2 == DHCP_ACK
iNet:closeUDP(portDHCP) iNet:closeUDP(portDHCP)
iNet:setInterfaceIP(@localip, @localnet, @localgw) iNet:setInterfaceIP(@localip, @localnet, @localgw)
//puts(@boundstr);putip(@localip);putc('/');putip(@localnet);putln puts("Apple II bound to:\n");putip(@localip);putc('/');putip(@localnet);putln
iNet:setDNS(@localdns) iNet:setDNS(@localdns)
//puts(@dnsstr);putip(@localdns);putln //puts("DNS: ");putip(@localdns);putln
done done

View File

@@ -198,15 +198,15 @@ asm sum1(prevsum, buf, len)
STA ESTKL,X STA ESTKL,X
BEQ + BEQ +
!BYTE $A9 !BYTE $A9
- CLC - CLC
INC ESTKH,X INC ESTKH,X
+ BCS - + BCS -
CHKLP LDA (SRC),Y CHKLP LDA (SRC),Y
PHA PHA
INY INY
BNE + BNE +
INC SRCH INC SRCH
+ LDA (SRC),Y + LDA (SRC),Y
ADC ESTKH+2,X ADC ESTKH+2,X
STA ESTKH+2,X STA ESTKH+2,X
PLA PLA
@@ -215,7 +215,7 @@ CHKLP LDA (SRC),Y
INY INY
BNE + BNE +
INC SRCH INC SRCH
+ DEC ESTKL,X + DEC ESTKL,X
BNE CHKLP BNE CHKLP
DEC ESTKH,X DEC ESTKH,X
BNE CHKLP BNE CHKLP
@@ -224,7 +224,7 @@ CHKLP LDA (SRC),Y
BNE + BNE +
INC ESTKL+2,X INC ESTKL+2,X
BEQ - BEQ -
+ INX + INX
INX INX
RTS RTS
end end
@@ -255,10 +255,10 @@ def etherSendIP(ipdst, proto, seglist, size)
memcpy(@hdr.ip_dst, ipdst, IP4ADR_SIZE) memcpy(@hdr.ip_dst, ipdst, IP4ADR_SIZE)
retry = 0 retry = 0
while hdr:ip_dst:0 <> remoteip:0 and hdr:ip_dst:2 <> remoteip:2 while hdr:ip_dst:0 <> remoteip:0 and hdr:ip_dst:2 <> remoteip:2
if retry >= 3 if retry >= 3
return -1 // ARP failed return -1 // ARP failed
fin fin
retry = retry + 1 retry++
memset(@dstMAC, MAC_BROADCAST, MAC_SIZE) memset(@dstMAC, MAC_BROADCAST, MAC_SIZE)
memset(@remoteha, 0, MAC_SIZE) memset(@remoteha, 0, MAC_SIZE)
memcpy(@remoteip, @hdr.ip_dst, IP4ADR_SIZE) memcpy(@remoteip, @hdr.ip_dst, IP4ADR_SIZE)
@@ -560,13 +560,13 @@ end
// //
// Initialize the driver interface // Initialize the driver interface
// //
export def setEtherDriver(MAC, getlen, readframe, setlen, writeframe)#0 export def setEtherDriver(MAC, getlen, readfrm, setlen, writefrm)#0
memcpy(@myMAC, MAC, MAC_SIZE) memcpy(@myMAC, MAC, MAC_SIZE)
memcpy(@localha, MAC, MAC_SIZE) memcpy(@localha, MAC, MAC_SIZE)
getFrameLen = getlen getFrameLen = getlen
readFrame = readframe readFrame = readfrm
setFrameLen = setlen setFrameLen = setlen
writeFrame = writeframe writeFrame = writefrm
end end
// //
// Set the local IP addresses // Set the local IP addresses

View File

@@ -211,7 +211,7 @@ def iNetInit
// //
while ^driver while ^driver
//puts(driver);putln //puts(driver);putln
if modexec(driver) >= 0 if cmdsys:modexec(driver) >= 0
break break
fin fin
driver = driver + ^driver + 1 driver = driver + ^driver + 1
@@ -222,7 +222,7 @@ def iNetInit
// //
// Get an IP address // Get an IP address
// //
modexec("DHCP") cmdsys:modexec("DHCP")
iNet:resolveIP = @iNetResolve iNet:resolveIP = @iNetResolve
return @iNet return @iNet
end end

View File

@@ -6,7 +6,7 @@ include "inc/cmdsys.plh"
// Include dependency on S/W IP stack // Include dependency on S/W IP stack
// //
import etherip import etherip
predef setEtherDriver(MAC, getlen, readframe, setlen, writeframe)#0 predef setEtherDriver(MAC, getlen, readfrm, setlen, writefrm)#0
end end
// //
// Uthernet register offsets // Uthernet register offsets
@@ -100,9 +100,9 @@ asm pokefrm(buf, len)
STA ESTKL,X STA ESTKL,X
BEQ + BEQ +
!BYTE $A9 !BYTE $A9
- CLC - CLC
INC ESTKH,X INC ESTKH,X
+ BCS - + BCS -
POKELP LDA (SRC),Y POKELP LDA (SRC),Y
end end
asm _pokefrml asm _pokefrml
@@ -114,8 +114,8 @@ asm _pokefrmh
STA $C000 STA $C000
INY INY
BNE + BNE +
INC SRCH INC SRCH
+ DEC ESTKL,X + DEC ESTKL,X
BNE POKELP BNE POKELP
DEC ESTKH,X DEC ESTKH,X
BNE POKELP BNE POKELP
@@ -137,24 +137,24 @@ asm peekfrm(buf, len)
ROR ROR
ADC #$00 ADC #$00
STA ESTKL,X STA ESTKL,X
BEQ + BEQ +
!BYTE $A9 !BYTE $A9
- CLC - CLC
INC ESTKH,X INC ESTKH,X
+ BCS - + BCS -
end end
asm _peekfrml asm _peekfrml
PEEKLP LDA $C000 PEEKLP LDA $C000
STA (DST),Y STA (DST),Y
INY INY
end end
asm _peekfrmh asm _peekfrmh
+ LDA $C000 + LDA $C000
STA (DST),Y STA (DST),Y
INY INY
BNE + BNE +
INC DSTH INC DSTH
+ DEC ESTKL,X + DEC ESTKL,X
BNE PEEKLP BNE PEEKLP
DEC ESTKH,X DEC ESTKH,X
BNE PEEKLP BNE PEEKLP

View File

@@ -40,12 +40,6 @@ byte mimeOctetStream = "application/octet-stream"
// //
// DEBUG // DEBUG
// //
def putb(hexb)#0
call($FDDA, hexb, 0, 0, 0)
end
def puth(hex)#0
call($F941, hex >> 8, hex, 0, 0)
end
def putip(ipptr)#0 def putip(ipptr)#0
byte i byte i
@@ -203,12 +197,11 @@ if !iNet:initIP()
return -1 return -1
fin fin
puts(@hello) puts(@hello)
getpfx(@prefix) fileio:getpfx(@prefix)
// //
// Alloc aligned file/io buffers // Alloc aligned file/io buffers
// //
filebuff = heapallocalign(1024, 8, 0) filebuff = heapallocalign(1024, 8, 0)
//iobuff = heapallocalign(1024, 8, 0)
// //
// Service IP // Service IP
// //

View File

@@ -17,6 +17,7 @@ static int defs = 0;
static int asmdefs = 0; static int asmdefs = 0;
static int codetags = 1; // Fix check for break_tag and cont_tag static int codetags = 1; // Fix check for break_tag and cont_tag
static int fixups = 0; static int fixups = 0;
static int lastglobalsize = 0;
static char idconst_name[1024][ID_LEN+1]; static char idconst_name[1024][ID_LEN+1];
static int idconst_value[1024]; static int idconst_value[1024];
static char idglobal_name[1024][ID_LEN+1]; static char idglobal_name[1024][ID_LEN+1];
@@ -465,7 +466,11 @@ void emit_sysflags(int val)
void emit_bytecode_seg(void) void emit_bytecode_seg(void)
{ {
if ((outflags & MODULE) && !(outflags & BYTECODE_SEG)) if ((outflags & MODULE) && !(outflags & BYTECODE_SEG))
{
if (lastglobalsize == 0) // Pad a byte if last label is at end of data segment
printf("\t%s\t$00\t\t\t; PAD BYTE\n", DB);
printf("_SUBSEG%c\t\t\t\t; BYTECODE STARTS\n", LBL); printf("_SUBSEG%c\t\t\t\t; BYTECODE STARTS\n", LBL);
}
outflags |= BYTECODE_SEG; outflags |= BYTECODE_SEG;
} }
void emit_comment(char *s) void emit_comment(char *s)
@@ -482,6 +487,7 @@ void emit_idlocal(char *name, int value)
} }
void emit_idglobal(int tag, int size, char *name) void emit_idglobal(int tag, int size, char *name)
{ {
lastglobalsize = size;
if (size == 0) if (size == 0)
printf("_D%03d%c\t\t\t\t\t; %s\n", tag, LBL, name); printf("_D%03d%c\t\t\t\t\t; %s\n", tag, LBL, name);
else else

View File

@@ -125,6 +125,11 @@ def emit_data(vartype, consttype, constval, constsize)
fin fin
return size return size
end end
def emit_codeseg#0
if lastglobalsize == 0
emit_byte($00) // Pad byte between last data tag and code seg
fin
end
def emit_const(cval)#0 def emit_const(cval)#0
emit_pending_seq emit_pending_seq
if cval == $0000 // ZERO if cval == $0000 // ZERO
@@ -421,6 +426,7 @@ def new_iddata(nameptr, len, type, size)#0
else else
lastglobal=>idval = new_tag(WORD_FIXUP)//datasize lastglobal=>idval = new_tag(WORD_FIXUP)//datasize
emit_tag(lastglobal=>idval) emit_tag(lastglobal=>idval)
lastglobalsize = size
if size if size
emit_fill(size) emit_fill(size)
datasize = datasize + size datasize = datasize + size

View File

@@ -1225,6 +1225,7 @@ def parse_module#0
// //
while parse_mods; nextln; loop while parse_mods; nextln; loop
while parse_vars(GLOBAL_TYPE); nextln; loop while parse_vars(GLOBAL_TYPE); nextln; loop
emit_codeseg
while parse_defs; nextln; loop while parse_defs; nextln; loop
entrypoint = codeptr entrypoint = codeptr
prevstmnt = 0 prevstmnt = 0

View File

@@ -246,7 +246,7 @@ word fixup_tag, fixup_addr
word tag_addr, tag_type word tag_addr, tag_type
word idglobal_tbl, idlocal_tbl word idglobal_tbl, idlocal_tbl
word pending_seq word pending_seq
word globals, lastglobal, lastlocal, savelast word globals, lastglobal, lastglobalsize, lastlocal, savelast
word tag_num, fixup_num, globalbufsz, localbufsz, codebufsz word tag_num, fixup_num, globalbufsz, localbufsz, codebufsz
word datasize, framesize, savesize word datasize, framesize, savesize
byte locals, savelocals byte locals, savelocals