1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-02-11 01:31:03 +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
//
//byte boundstr = "Apple II bound to:\n"
//byte dnsstr = "DNS: "
//def putb(hexb)
// return call($FDDA, hexb, 0, 0, 0)
//end
//def puth(hex)
// return call($F941, hex >> 8, hex, 0, 0)
//end
//def putip(ipptr)
// byte i
//
// for i = 0 to 2
// puti(ipptr->[i]); putc('.')
// next
// puti(ipptr->[i])
//end
def putip(ipptr)#0
byte i
for i = 0 to 2
puti(ipptr->[i]); putc('.')
next
puti(ipptr->[i])
end
//def dumpbytes(buf, len)
// word i
//
@ -132,13 +124,13 @@ def parseopts(opts, match)
i = 0
while opts->[i] <> $FF and i < 64
while !opts->[i] and i < 64
i = i + 1
loop
while !opts->[i] and i < 64
i++
loop
if opts->[i] == match
return i
fin
i = i + opts->[i + 1] + 2
return i
fin
i = i + opts->[i + 1] + 2
loop
return -1
end
@ -224,7 +216,7 @@ repeat
until retry > 4 or optsOP.2 == DHCP_ACK
iNet:closeUDP(portDHCP)
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)
//puts(@dnsstr);putip(@localdns);putln
//puts("DNS: ");putip(@localdns);putln
done

View File

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

View File

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

View File

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

View File

@ -40,12 +40,6 @@ byte mimeOctetStream = "application/octet-stream"
//
// 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
byte i
@ -203,12 +197,11 @@ if !iNet:initIP()
return -1
fin
puts(@hello)
getpfx(@prefix)
fileio:getpfx(@prefix)
//
// Alloc aligned file/io buffers
//
filebuff = heapallocalign(1024, 8, 0)
//iobuff = heapallocalign(1024, 8, 0)
//
// Service IP
//

View File

@ -17,6 +17,7 @@ static int defs = 0;
static int asmdefs = 0;
static int codetags = 1; // Fix check for break_tag and cont_tag
static int fixups = 0;
static int lastglobalsize = 0;
static char idconst_name[1024][ID_LEN+1];
static int idconst_value[1024];
static char idglobal_name[1024][ID_LEN+1];
@ -465,7 +466,11 @@ void emit_sysflags(int val)
void emit_bytecode_seg(void)
{
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);
}
outflags |= BYTECODE_SEG;
}
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)
{
lastglobalsize = size;
if (size == 0)
printf("_D%03d%c\t\t\t\t\t; %s\n", tag, LBL, name);
else

View File

@ -125,6 +125,11 @@ def emit_data(vartype, consttype, constval, constsize)
fin
return size
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
emit_pending_seq
if cval == $0000 // ZERO
@ -421,6 +426,7 @@ def new_iddata(nameptr, len, type, size)#0
else
lastglobal=>idval = new_tag(WORD_FIXUP)//datasize
emit_tag(lastglobal=>idval)
lastglobalsize = size
if size
emit_fill(size)
datasize = datasize + size

View File

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

View File

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