Kernel & shell rewrite

This commit is contained in:
Rémy GIBERT 2015-10-19 22:35:00 +02:00
parent 2ec85716eb
commit 7f06969e7d
29 changed files with 1680 additions and 896 deletions

Binary file not shown.

Binary file not shown.

View File

@ -4,22 +4,20 @@ NEW
INC 1
AUTO 6
SET PATH=%A2OSX%SBIN/;%A2OSX%BIN/
SET DRV=%A2OSX%DRV/
SET ETC=%A2OSX%ETC/
SET LIB=%A2OSX%LIB/
LOAD CONSOLE.DRV
EXEC GETTY KBD CON LOGIN
LOAD SSC.DRV 9600 N 8 1 X
EXEC GETTY COM2 COM2 LOGIN
*LOAD PPIC.DRV
LOAD UTHERNET.DRV 000E3A123456
LOAD %A2OSX%DRV/CONSOLE.DRV
EXEC GETTY CON LOGIN
*LOAD %A2OSX%DRV/SSC.DRV 9600 N 8 1 X
*EXEC GETTY COM2 LOGIN
*LOAD %A2OSX%DRV/PPIC.DRV
LOAD %A2OSX%DRV/UTHERNET.DRV 000E3A123456
EXEC TCPIP ETH3
EXEC DHCPCLNT
*EXEC TELNETD
*MOUNT TFTP 192.168.1.5:/A2OSX /MNT/A2OSX
*MOUNT CIFS 192.168.1.5:/MSSHARE /MNT/MSSHARE
*LOAD DHGR.DRV
*LOAD MOUSE.DRV
*LOAD %A2OSX%DRV/DHGR.DRV
*LOAD %A2OSX%DRV/MOUSE.DRV
*EXEC GUI
MAN
TEXT A2OSX.STARTUP

View File

@ -16,6 +16,7 @@ AUTO 6
.INB INC/LIBTCPIP.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -41,6 +42,7 @@ L.SSCANF.IP .DA SSCANF.IP
L.IP .DA IP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.DNSNAME .DA DNSNAME
.DA 0
*--------------------------------------
CS.INIT stz hHostName
@ -83,7 +85,6 @@ CS.INIT.ADD >PUSHA
>LIBCALL hLIBSTR,LIBSTR.SSCANF
bcs .9
>PUSHWI 1800 default TTL
>PUSHW L.IP
lda hHostName
>SYSCALL SYS.GetMemPtrA
@ -110,37 +111,46 @@ CS.INIT.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GETCACHE
lda (ZPPTR1)
beq .2
ldy #S.DNSCACHE.RDATA+3
lda (ZPPTR1),y
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
dey
ldy #S.DNSCACHE.RDATA+4
.5 dey
lda (ZPPTR1),y
>PUSHA
cpy #S.DNSCACHE.RDATA
bne .5
ldy #S.DNSCACHE.TTL+3
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
dey
lda (ZPPTR1),y
>PUSHA
dey
ldy #S.DNSCACHE.TTL+4
.6 dey
lda (ZPPTR1),y
>PUSHA
cpy #S.DNSCACHE.TTL
bne .6
ldy #S.DNSCACHE.hNAME
lda (ZPPTR1),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>STYA ZPPTR2
>PUSHB (ZPPTR1)
ldy #0 convert DNS-style string to PSTR
.10 lda (ZPPTR2),y
tax
beq .12
lda #'.'
sta DNSNAME,y
.11 iny
lda (ZPPTR2),y
sta DNSNAME,y
dex
bne .11
iny
bne .10
.12 dey
sty DNSNAME
>PUSHW L.DNSNAME
>PUSHB (ZPPTR1) Entry Status
>PUSHW L.MSG1
>LIBCALL hLIBSTR,LIBSTR.PRINTF
@ -151,11 +161,13 @@ CS.INIT.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GETCACHE
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 plx
dex
bne .1
beq .8
jmp .1
lda #0 tell TSKMGR that all done ok, but
.8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
@ -181,12 +193,13 @@ LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
SSCANF.IP >PSTRING "%d.%d.%d.%d"
MSG0 >CSTRING "STS Hostname TTL IP Address\n"
MSG1 >CSTRING "$%h %32S %09L %d.%d.%d.%d\n"
MSG1 >CSTRING "$%h %32S %h%h%h%h %d.%d.%d.%d\n"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
hHostName .BS 1
hIP .BS 1
IP .BS 4
DNSNAME .BS K.DNS.MAXLEN+1
MAN
SAVE BIN/DNS.S
ASM

View File

@ -114,8 +114,8 @@ CS.END
hLibStr .BS 1
PS.COUNT .BS 1
LIBSTR >PSTRING "libstr.o"
MSG0 >CSTRING "ID Flags PID CMD ARGS\n"
MSG1 >CSTRING "%03d %b %03d %16S %32S\n"
MSG0 >CSTRING "ID Flags PID CMD ARGS\n"
MSG1 >CSTRING "%03d %b %03d %30S %28S\n"
MSG2 >PSTRING "(none)"
MAN
SAVE BIN/PS.S

402
BIN/RPCINFO.S.txt Normal file
View File

@ -0,0 +1,402 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/RPCINFO
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/A2OSX.API.I
.INB INC/KERNEL.I
.INB INC/LIBSTR.I
.INB INC/LIBTCPIP.I
*--------------------------------------
RPCINFO.TIMEOUT .EQ 40 40*100ms = 4 sec.
*--------------------------------------
ZPFrameBase1 .EQ ZPBIN
ZPFrameLen1 .EQ ZPBIN+2
ZPFramePtr1 .EQ ZPBIN+4
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.LIBTCPIP .DA LIBTCPIP
L.SSCANF.IP .DA SSCANF.IP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
.DA 0
*--------------------------------------
CS.INIT ldy #S.PS.hARGS
lda (pPs),y
bne .1
lda #SYSMGR.ERRSYN
sec
rts
.1 >LDYA L.LIBSTR
>LOADLIBYA
sta hLIBSTR
>LDYA L.LIBTCPIP
>LOADLIBYA
sta hLIBTCPIP
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
bcs .9
>STYA ZPQuickPtr1
lda (ZPQuickPtr1) Configured ?
bpl .9
ldy #S.IPCFG.HDEV
lda (ZPQuickPtr1),y
sta hDev
lda A2OSX.RANDOM16
ldy #XID
sta (pData),y
lda A2OSX.RANDOM16+1
iny
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 rts
*--------------------------------------
CS.RUN >PUSHW pData DST.IP
>PUSHW L.SSCANF.IP
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.SSCANF
bcc CS.RUN.IPOK
lda #RPCINFO.TIMEOUT
ldy #TimeOut
sta (pData),y
CS.RUN.DNSQUERY >PUSHW pData DST.IP
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.DNS.QUERY
bcc CS.RUN.IPOK
jsr A2osX.SLEEP
ldy #TimeOut
lda (pData),y
bne CS.RUN.DNSQUERY
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
sec
CS.RUN.RTS rts
CS.RUN.IPOK ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
ldy #3
>PUSHB (pData),y DST.IP+3
dey
>PUSHB (pData),y DST.IP+2
dey
>PUSHB (pData),y DST.IP+1
>PUSHB (pData) DST.IP
>PUSHW L.MSG1
>LIBCALL hLIBSTR,LIBSTR.PRINTF
CS.RUN.RPCCALL >LIBCALL hLIBTCPIP,LIBTCPIP.NEW.UDP.FRAME
bcs CS.RUN.RTS
>STYA ZPFrameBase1
txa
ldy #hFrame
sta (pData),y
ldx #3
ldy #DST.IP
.10 lda (pData),y
pha
iny
dex
bpl .10
ldx #3
ldy #S.IP.DST+3
.1 pla
sta (ZPFrameBase1),y
dey
dex
bpl .1
ldy #S.UDP.SRCPORT
lda #UDP.PORT.PMAP
sta (ZPFrameBase1),y
ldy #S.UDP.DSTPORT
sta (ZPFrameBase1),y
ldy #XID
lda (pData),y
tax
iny
lda (pData),y
ldy #S.RPC.XID+1
sta (ZPFrameBase1),y
dey
txa
sta (ZPFrameBase1),y
.3 >PUSHWI S.RPC+32
ldy #hFrame
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.SEND.UDP.FRAME
bcc .4
jsr A2osX.SLEEP
ldy #TimeOut
lda (pData),y
bne .3
.4 ldy #hFrame
lda (pData),y
>SYSCALL SYS.FreeMemA
ldy #bReply
lda #0
sta (pData),y
lda #RPCINFO.TIMEOUT
ldy #TimeOut
sta (pData),y
CS.RUN.WAIT jsr A2osX.SLEEP
ldy #bReply
lda (pData),y
bne .1
ldy #bCTRLC
lda (pData),y
bne CS.RUN.ERROR
ldy #TimeOut
lda (pData),y
bne CS.RUN.WAIT
ldy #3
>PUSHB (pData),y DST.IP+3
dey
>PUSHB (pData),y DST.IP+2
dey
>PUSHB (pData),y DST.IP+1
>PUSHB (pData) DST.IP
>PUSHW L.MSG2
>LIBCALL hLIBSTR,LIBSTR.PRINTF
.1 ldy #bCTRLC
lda (pData),y
bne CS.RUN.ERROR
ldy #TimeOut
lda (pData),y
beq .2
jsr A2osX.SLEEP
bra .1
.2
CS.RUN.ERROR sec
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
and #S.EVT.F.TIMER is it a TIMER event?
beq .1 no....
ldy #TimeOut
lda (pData),y
beq .10
dec
sta (pData),y
.10 sec do not discard TIMER event
rts
.1 lda (pEvent)
and #S.EVT.F.KEY is it a KEY event?
beq .2
ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
ldy #S.PS.hINDEV
cmp (pPs),y
bne .9
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
lda (pEvent),y
bne .9
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$03 Ctrl-C
bne .8
lda #$FF
ldy #bCTRLC
sta (pData),y
bra .8
.2 lda (pEvent)
and #S.EVT.F.NET
beq .9
ldy #S.EVT.hDEV
lda (pEvent),y
cmp hDev
bne .9
ldy #S.EVT.DATALO Get Frame hMem
lda (pEvent),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPFrameBase1
ldy #S.IP.PROTOCOL
lda (ZPFrameBase1),y
cmp #S.IP.PROTOCOL.UDP
bne .9
ldy #S.UDP.DSTPORT
lda (ZPFrameBase1),y
cmp #S.ICMP.TYPE.ECHOREP
bne .9
ldy #S.RPC.XID
lda (ZPFrameBase1),y
tax
iny
lda (ZPFrameBase1),y
ldy #XID+1
cmp (pData),y
bne .9
dey
txa
cmp (pData),y
bne .9
jsr CS.EVENT.REPLY
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.EVENT.REPLY lda #RPCINFO.TIMEOUT
sec
sbc TimeOut
stz TimeOut.ms
stz TimeOut.ms+1
tay
beq .3
.1 lda TimeOut.ms
clc
adc #K.TIMER16RESOLUTION*20
sta TimeOut.ms
bcc .2
inc TimeOut
.2 dey
bne .1
.3 >PUSHW TimeOut.ms
ldy #S.IP.TTL
>PUSHB (ZPFrameBase1),y
ldy #S.ICMP.SEQUENCE+1
>PUSHB (ZPFrameBase1),y
dey
>PUSHB (ZPFrameBase1),y
ldy #S.IP.SRC+3
>PUSHB (ZPFrameBase1),y
dey
>PUSHB (ZPFrameBase1),y
dey
>PUSHB (ZPFrameBase1),y
dey
>PUSHB (ZPFrameBase1),y
>PUSHW L.MSG3
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #bReply
lda (pData),y
inc
sta (pData),y
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
>SYSCALL SYS.UnloadLibA
lda hLIBSTR
>SYSCALL SYS.UnloadLibA
clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
LIBTCPIP >PSTRING "libtcpip.o"
SSCANF.IP >PSTRING "%d.%d.%d.%d"
MSG0 >CSTRING "%S: Unknown host\n"
MSG1 >CSTRING "PING %d.%d.%d.%d (%S)\n"
MSG2 >CSTRING "%d.%d.%d.%d: TimeOut/Host unreachable\n"
MSG3 >CSTRING "32 bytes from %d.%d.%d.%d, icmp_seq=%D, ttl=%d, time=%D ms\n"
hLIBSTR .BS 1
hLIBTCPIP .BS 1
hDev .BS 1
TimeOut.ms .BS 2
*--------------------------------------
.DUMMY
.OR 0
DS.START
DST.IP .BS 4
hFrame .BS 1
TimeOut .BS 1
XID .BS 4
bCTRLC .BS 1
bReply .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/RPCINFO.S
ASM

View File

@ -81,9 +81,17 @@ OPEN stz CURON
GETEVENT lda A2osX.TIMER16
and #CURSOR.BLINK.SPEED
eor CURON
beq .9
beq .1
jsr CURBLNK
.1 lda A2osX.SCREENS
and #A2osX.SCREENS.C is screen active?
beq .9
>SYSCALL SYS.GetKeyboardEvent
bcs .9
rts
.9 lda #0 Error = no event
sec
rts

View File

@ -23,7 +23,6 @@ SYS.PStrCat .EQ $14
SYS.PStrCmp .EQ $16
SYS.PStrGetTkn .EQ $18
SYS.GetPStrIndex .EQ $1A
*--------------------------------------
SYS.LoadBinA .EQ $20
SYS.LoadLibYA .EQ $22
@ -81,9 +80,13 @@ SYS.MLIWriteBlock .EQ $7E
SYS.GetDevByIDA .EQ $80
SYS.GetDevByNameA .EQ $82
SYS.GetDevByNameYA .EQ $84
SYS.GetKeyboardEvent .EQ $88
*--------------------------------------
SYS.ExecProcessA .EQ $90
SYS.CreateProcessA .EQ $92
SYS.ExecProcessNewEnvA .EQ $90
SYS.ExecProcessA .EQ $92
SYS.CreateProcessNewEnvA .EQ $94
SYS.CreateProcessA .EQ $96
SYS.GetPSByIDA .EQ $98
*--------------------------------------
@ -200,6 +203,7 @@ S.PS.F .EQ 0
S.PS.F.INUSE .EQ %10000000
S.PS.F.HOLD .EQ %01000000
S.PS.F.EVENT .EQ %00100000
S.PS.F.ENV .EQ %00010000
S.PS.ID .EQ 1
S.PS.PID .EQ 2
S.PS.hCS .EQ 3

View File

@ -25,6 +25,10 @@ K.UDPTABLE.SIZE .EQ 16
K.TCPTABLE.SIZE .EQ 16
K.ETH.FRAME.LEN .EQ 1514
K.IP.TTL .EQ 64
K.DNS.MAXLEN .EQ 64
K.DYNPORT.START .EQ 49152
K.DYNPORT.END .EQ 65535
K.DYNPORT.MAX .EQ 64
*--------------------------------------
H.BIN.HEADER .EQ 0
H.BIN.HEADER.DRV65 .EQ $4C8D 6502:cld,jmp abs

View File

@ -89,6 +89,8 @@ S.DNSCACHE.CLASS .EQ 4
S.DNSCACHE.TTL .EQ 6
S.DNSCACHE.RDLENGTH .EQ 10
S.DNSCACHE.RDATA .EQ 12
S.DNSCACHE.ID .EQ 12 Store Message.Id in cache (pending req.)
S.DNSCACHE.DYNPORT .EQ 14 Store Dyn.Port in cache (pending req.)
*
S.DNSCACHE .EQ 16
*--------------------------------------

View File

@ -287,9 +287,9 @@ AUTO 6
.EM
*--------------------------------------
.MA PSTRING
.DA #.74-.73
.73 .AS "]1"
.74 .AS ""
.DA #:2-:1
:1 .AS "]1"
:2 .EQ *
.EM
MAN
SAVE INC/MACROS.I

View File

@ -15,13 +15,15 @@ DNS.CLEAR ldx #K.DNSCACHE.SIZE*S.DNSCACHE
*--------------------------------------
* DNS.QUERY
* In:
* PULLA = hostname PSTR
* PULLW = hostname PTR to PSTR
* PULLW = PTR to IP to fill with cached data
* Out:
* CC: hit: IP filled with address
* CS: missed
*--------------------------------------
DNS.QUERY >PULLW ZPDNSHostname Get host string
DNS.QUERY >PULLYA Get host string
jsr PSTR2DNSHostName
>PULLW ZPDNSIP Get IP address to fill
ldx #0
@ -29,21 +31,25 @@ DNS.QUERY >PULLW ZPDNSHostname Get host string
.1 lda DNS.CACHE,x
beq .6 empty DNS cache entry?
phx
lda DNS.CACHE+S.DNSCACHE.hNAME,x
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr3
lda (ZPDNSHostname)
cmp (ZPQuickPtr3) Same Length?
plx
ldy #0
.2 lda DNSHostname,y
bne .21
lda (ZPQuickPtr3),y
beq .22
.21 cmp (ZPQuickPtr3),y
bne .6
tay
.2 lda (ZPDNSHostname),y
jsr ToLowerCaseA
cmp (ZPQuickPtr3),y
bne .6
dey
iny
bne .2
lda DNS.CACHE,x get back status...
.22 lda DNS.CACHE,x get back status...
bpl .4 Pending...
ldy #0
@ -92,18 +98,18 @@ DNS.REQUEST jsr NEW.UDP.FRAME
ldy #S.DNS.ID
lda A2osX.RANDOM16
sta (ZPFrameBase1),y
sta MESSAGE.ID
sta DNSMessageID
iny
lda A2osX.RANDOM16+1
sta (ZPFrameBase1),y
sta MESSAGE.ID+1
sta DNSMessageID+1
ldy #S.DNS.F
lda /S.DNS.F.RD
sta (ZPFrameBase1),y
iny
lda #S.DNS.F.RD
sta (ZPFrameBase1),y
* ldy #S.DNS.F
* lda /S.DNS.F.RD
* sta (ZPFrameBase1),y
* iny
* lda #S.DNS.F.RD
* sta (ZPFrameBase1),y
ldy #S.DNS.QDCOUNT
lda /1
@ -120,28 +126,14 @@ DNS.REQUEST jsr NEW.UDP.FRAME
adc ZPFrameBase1+1
sta ZPFramePtr1+1
lda (ZPDNSHostname) Get hostname len
tay
ldx #0
.2 lda (ZPDNSHostname),y
cmp #'.'
bne .3
txa
ldx #$FF
.3 sta (ZPFramePtr1),y
inx
dey
bne .2
txa
sta (ZPFramePtr1)
lda (ZPDNSHostname)
tay
iny
lda #$0 Ending #0
ldy #0
.2 lda DNSHostname,y
sta (ZPFramePtr1),y
beq .3
iny
bne .2
.3 iny
lda /S.DNS.QTYPE.A
sta (ZPFramePtr1),y
iny
@ -155,7 +147,7 @@ DNS.REQUEST jsr NEW.UDP.FRAME
lda #S.DNS.QCLASS.IN
sta (ZPFramePtr1),y
lda (ZPDNSHostname) Get hostname len again (QNAME)
lda DNSHostnameLen Get hostname len again (QNAME)
clc
adc #6 (len+1) + Ending 0 + QTYPE + QCLASS
adc #S.DNS
@ -203,13 +195,19 @@ DNS.REQUEST jsr NEW.UDP.FRAME
*--------------------------------------
* DNS.ADD
* In:
* PULLA = hostname PSTR to Add
* PULLW = hostname PSTR to Add
* PULLW = PTR to IP
* PULLW = TTL
*--------------------------------------
DNS.ADD >PULLW ZPDNSHostname Get host string
DNS.ADD >PULLYA Get host string
jsr PSTR2DNSHostName
>PULLW ZPDNSIP Get host IP address
>PULLW HOST.TTL
lda #$80
sta DNSHostTTL+3
stz DNSHostTTL+2
stz DNSHostTTL+1
stz DNSHostTTL
lda #S.DNSCACHE.STATUS.RESOLVED
bra DNS.ADD.I
@ -223,34 +221,35 @@ DNS.ADD.I sta Status
beq DNS.ADD.ENTRY free ?
lda DNS.CACHE+S.DNSCACHE.hNAME,x
phx
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr3
lda (ZPDNSHostname)
cmp (ZPQuickPtr3) Same Length?
bne .4
plx
tay
.2 lda (ZPDNSHostname),y
jsr ToLowerCaseA
ldy #0
.2 lda DNSHostname,y
cmp (ZPQuickPtr3),y
bne .4
dey
bne .2
bra DNS.UPD.ENTRY
and #$FF End Of String?
beq DNS.UPD.ENTRY
iny
bne .2
.4 txa
clc
adc #S.DNSCACHE
cmp #K.DNSCACHE.SIZE*S.DNSCACHE
beq .5
tax
bra .1
cmp #K.DNSCACHE.SIZE*S.DNSCACHE
bne .1
.5 lda DNS.CACHE+S.DNSCACHE.hNAME discard oldest entry hNAME
lda DNS.CACHE+S.DNSCACHE.hNAME discard oldest entry hNAME
>SYSCALL SYS.FreeMemA
ldx #K.DNSCACHE.SIZE*S.DNSCACHE-S.DNSCACHE
.6 lda DNS.CACHE+S.DNSCACHE-1,x
sta DNS.CACHE-1,x
dex
@ -259,9 +258,9 @@ DNS.ADD.I sta Status
ldx #K.DNSCACHE.SIZE*S.DNSCACHE-S.DNSCACHE
DNS.ADD.ENTRY phx
lda (ZPDNSHostname)
inc add 1 for len
tay
ldy DNSHostnameLen
iny add 1 for Ending 00
lda #0
>PUSHYA push PSTR len
>PUSHBI 0 no option
@ -270,29 +269,40 @@ DNS.ADD.ENTRY phx
plx
rts
.10 >STYA ZPQuickPtr3
.10 >STYA ZPQuickPtr4
txa
plx
sta DNS.CACHE+S.DNSCACHE.hNAME,x
lda (ZPDNSHostname)
sta (ZPQuickPtr3)
tay
.1 lda (ZPDNSHostname),y
jsr ToLowerCaseA
sta (ZPQuickPtr3),y
dey
ldy #0
.1 lda DNSHostname,y
sta (ZPQuickPtr4),y
iny
cpy DNSHostnameLen
bne .1
DNS.UPD.ENTRY lda Status
sta DNS.CACHE,x
bpl .9 pending...
lda #0
sta (ZPQuickPtr4),y
lda HOST.TTL
DNS.UPD.ENTRY lda Status
sta DNS.CACHE+S.DNSCACHE.STATUS,x
bmi .1 pending?
lda DNSMessageID
sta DNS.CACHE+S.DNSCACHE.ID,x
lda DNSMessageID+1
sta DNS.CACHE+S.DNSCACHE.ID+1,x
bra .9
.1 lda DNSHostTTL
sta DNS.CACHE+S.DNSCACHE.TTL,x
lda HOST.TTL+1
lda DNSHostTTL+1
sta DNS.CACHE+S.DNSCACHE.TTL+1,x
lda DNSHostTTL+2
sta DNS.CACHE+S.DNSCACHE.TTL+2,x
lda DNSHostTTL+3
sta DNS.CACHE+S.DNSCACHE.TTL+3,x
ldy #0
.2 lda (ZPDNSIP),y
@ -313,6 +323,53 @@ DNS.GETCACHE >LDYA L.DNS.CACHE
*--------------------------------------
* PRIVATE
*--------------------------------------
PSTR2DNSHostName >STYA ZPQuickPtr1
lda (ZPQuickPtr1)
beq .9
cmp #K.DNS.MAXLEN-1
bcs .9
tay
inc
sta DNSHostNameLen
lda #0 Ending 0
sta DNSHostName+1,y
ldx #0
.1 lda (ZPQuickPtr1),y
and #$7f
cmp #'.'
beq .2
cmp #'A'
bcc .10
cmp #'Z'+1
bcs .10
adc #$20
.10 inx
bra .3
.2 txa
ldx #0
.3 sta DNSHostName,y
dey
bne .1
stx DNSHostName
clc
rts
.9 sec
rts
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S.DNS
LOAD LIB/LIBTCPIP.S

View File

@ -19,7 +19,6 @@ ZPFrameLen1 .EQ ZPLIB+2
ZPFramePtr1 .EQ ZPLIB+4
ZPARPIP .EQ ZPLIB+6
ZPARPMAC .EQ ZPLIB+8
ZPDNSHostname .EQ ZPLIB+10
ZPDNSIP .EQ ZPLIB+12
*--------------------------------------
* File Header (16 Bytes)
@ -80,6 +79,7 @@ LIB.LOAD lda bFirstLoad
bne .8
jsr ARP.CLEAR
jsr DNS.CLEAR
jsr DYN.CLEAR
inc bFirstLoad
.8 clc
rts
@ -389,11 +389,19 @@ ADD.LISTENER sec
*--------------------------------------
REM.LISTENER sec
rts
*--------------------------------------
DYN.CLEAR
*--------------------------------------
DYN.GET
*--------------------------------------
DYN.RELEASE
*--------------------------------------
.INB LIB/LIBTCPIP.S.ARP
.INB LIB/LIBTCPIP.S.DNS
*--------------------------------------
* PRIVATE
*--------------------------------------
*--------------------------------------
ToLowerCaseA cmp #'A'
bcc .1
@ -466,14 +474,21 @@ CS.END
*--------------------------------------
bFirstLoad .DA #0
Status .BS 1
MESSAGE.ID .BS 2 for DNS functions
HOST.TTL .BS 4 for DNS functions
DNSMessageID .BS 2
DNSDynamicPort .BS 2
DNSHostTTL .BS 4
DNSHostName .BS K.DNS.MAXLEN+1
DNSHostNameLen .BS 1
IP.CHECKSUM .BS 4
IPCFG .BS S.IPCFG
ARP.CACHE .BS K.ARPCACHE.SIZE*S.ARPCACHE
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
UDP.TABLE .BS K.UDPTABLE.SIZE*S.LISTENER
TCP.TABLE .BS K.TCPTABLE.SIZE*S.LISTENER
DYNPORT.UDP.LAST .BS 2
DYNPORT.TCP.LAST .BS 2
DYNPORT.UDP .BS K.DYNPORT.MAX*4
DYNPORT.TCP .BS K.DYNPORT.MAX*4
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S

View File

@ -50,38 +50,20 @@ CS.INIT ldy #S.PS.hARGS
>PUSHBI $20 Push SEP=' '
>PUSHBI 1 Push 1 for getting INDEV
>SYSCALL SYS.PStrGetTkn
bcs .9
bcs .98
sta hDEVNAME
>SYSCALL SYS.GetDevByNameA
bcs .8
bcs .99
txa
ldy #S.PS.hINDEV
sta (pPs),y
lda hDEVNAME
>SYSCALL SYS.FreeMemA
ldy #S.PS.hARGS
lda (pPs),y
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 2 Push 1 for getting OUTDEV
>SYSCALL SYS.PStrGetTkn
.9 bcs .99
sta hDEVNAME
>SYSCALL SYS.GetDevByNameA
.8 bcs .98
>STYA pDev
txa
ldy #S.PS.hOUTDEV
sta (pPs),y
ldy #S.PS.hERRDEV
sta (pPs),y
lda hDEVNAME
>SYSCALL SYS.FreeMemA
@ -89,7 +71,7 @@ CS.INIT ldy #S.PS.hARGS
lda (pPs),y
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 3 Push 3 for getting BIN
>PUSHBI 2 Push 3 for getting BIN
>SYSCALL SYS.PStrGetTkn
bcs .99
@ -142,7 +124,7 @@ CS.RUN ldy #S.PS.hOUTDEV
ldy #hBinName
lda (pData),y
>SYSCALL SYS.ExecProcessA
>SYSCALL SYS.ExecProcessNewEnvA
.9 rts
*--------------------------------------
CS.DOEVENT sec

View File

@ -82,7 +82,7 @@ CS.RUN lda #0
ldy #hSHELL
lda (pData),y
>SYSCALL SYS.ExecProcessA
>SYSCALL SYS.ExecProcessNewEnvA
bcc .8

390
SBIN/SHELL.S.CMD.txt Normal file
View File

@ -0,0 +1,390 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
EXEC.CMD stz hFullCmd
stz hEnvPath
ldy #hCmdLine
>PUSHB (pData),y
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD & ARGS
>SYSCALL SYS.PStrGetTkn
bcs .99
sta hExecCmd
stx hExecArgs
>SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1
ldx #0
stz ExecCmdIdx
.1 lda CMDS,x
beq EXEC.CMD.EXT
cmp (ZPPtr1)
bne .5
phx
ldy #0
.2 iny
inx
lda (ZPPtr1),y
cmp #'a'
bcc .3
cmp #'{'
bcs .3
eor #$20 to Uppercase
.3 cmp CMDS,x
bne .4
tya
cmp (ZPPtr1)
bne .2
plx
jsr EXEC.CMD.INT
jmp EXEC.CMD.ClnUp
.4 plx
.5 txa
sec
adc CMDS,x
tax
inc ExecCmdIdx
inc ExecCmdIdx
bra .1
.99 rts
EXEC.CMD.EXT ldy #1
lda (ZPPtr1),y
cmp #'/'
bne .2
ldy #hCmdLine
lda (pPs),y
bra .11
.2 >PUSHW L.ENV.PATH push ENVNAME=PATH
ldy #S.PS.hENV
lda (pPs),y
>PUSHA
>SYSCALL SYS.GetEnvVarP get value for ENV=PATH
bcs EXEC.CMD.ClnUp
sta hEnvPath
>PUSHB hExecCmd
>PUSHB hEnvPath
>SYSCALL SYS.FileSearch
bcc .10
>PUSHB hExecCmd
ldy #S.PS.hPREFIX
lda (pPs),y
>PUSHA
>SYSCALL SYS.FileSearch
bcs EXEC.CMD.ClnUp
.10 sta hFullCmd
.11 >SYSCALL SYS.MLIGetFileInfoA
bcs EXEC.CMD.ClnUp
>STYA ZPPTR1
ldy #1 Get File Type
lda (ZPPTR1),y
cmp #$04 TXT File ?
bne .1
bra *
.1 jsr EXEC.CMD.ClnUp Discard CMD & ARGS
ldy #hCmdLine
lda (pData),y
>SYSCALL SYS.ExecProcessNewEnvA
rts
EXEC.CMD.ClnUp pha
php
lda hFullCmd
beq .1
>SYSCALL SYS.FreeMemA
.1 lda hEnvPath
beq .2
>SYSCALL SYS.FreeMemA
.2 lda hExecArgs
beq .3
>SYSCALL SYS.FreeMemA
.3 lda hExecCmd
beq .8
>SYSCALL SYS.FreeMemA
.8 plp
pla
rts
*--------------------------------------
EXEC.CMD.INT ldx ExecCmdIdx
jmp (J.INTCMDS,x)
*--------------------------------------
EXEC.CMD.CD lda hExecArgs
bne EXEC.CMD.CD.C
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
clc
rts
EXEC.CMD.CD.C >SYSCALL SYS.GetMemPtrA
>STYA ZPPTR2
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
>PUSHWI MLI.MAXPATH+1 Get a buffer for new PATH
>PUSHBI 0 no particular Option
>SYSCALL SYS.GetMem
bcs .99
>STYA ZPPTR3
stx hNEWPATH
lda #0
sta (ZPPTR3)
ldy #1
lda (ZPPTR2),y
cmp #'/' Full Path?
beq .3
cmp #'.' ".." ?
bne .2
lda (ZPPTR2)
cmp #2
bne .97
iny
lda (ZPPTR2),y
cmp #'.'
bne .97
lda (ZPPTR1)
tay
.1 dey
beq .97
lda (ZPPTR1),y
cmp #'/'
bne .1
tya
sta (ZPPTR3)
.11 lda (ZPPTR1),y
sta (ZPPTR3),y
dey
bne .11
bra .4
.97 lda #SYSMGR.ERRSYN
.98 pha
lda hNEWPATH
>SYSCALL SYS.FreeMemA
pla
sec
.99 rts
.2 >PUSHW ZPPTR1
>PUSHW ZPPTR3
>LIBCALL hLIBSTR,LIBSTR.STRCPYP
.3 >PUSHW ZPPTR2
>PUSHW ZPPTR3
>LIBCALL hLIBSTR,LIBSTR.STRCATP
lda (ZPPTR3)
tay
lda #'/' Ending with '/'?
cmp (ZPPTR3),y
beq .4
iny
sta (ZPPTR3),y
tya
sta (ZPPTR3)
.4 lda hNEWPATH
>SYSCALL SYS.CheckPrefixA
bcs .98
ldy #S.PS.hPREFIX
lda (pPs),y
pha
lda hNEWPATH
sta (pPs),y
pla
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
EXEC.CMD.SET lda hExecArgs
bne .2
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda (ZPPTR1)
beq .8 Ending 0 ?
>PUSHW ZPPTR1
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
lda ZPPTR1
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR1
bcc .1
inc ZPPTR1
bra .1
.8 clc
rts
.2 >PUSHA Push Cmd Line
>PUSHBI $3D Push SEP='='
>PUSHBI 0 Push Token IDX
>SYSCALL SYS.PStrGetTkn
bcc .3
lda #SYSMGR.ERRSYN
rts
.3 sta hVarName
stx hVarValue
txa
bne .7
lda hExecArgs
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
lda (ZPPTR1)
tay
lda (ZPPTR1),y
cmp #'='
beq .7
>PUSHB hVarName
ldy #S.PS.hENV
>PUSHB (pPs),y
>SYSCALL SYS.GetEnvVarH
bcs .97
sta hVarValue
lda hVarName
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
lda #'='
jsr COUT
lda hVarValue
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
bra .97
.7 >PUSHB hVarValue
>PUSHB hVarName
ldy #S.PS.hENV
>PUSHB (pPs),y
>SYSCALL SYS.SetEnvVarH
.97 php
pha
lda hVarValue
beq .98
>SYSCALL SYS.FreeMemA
.98 lda hVarName
>SYSCALL SYS.FreeMemA
pla
php
rts
*--------------------------------------
EXEC.CMD.DATE >SYSCALL SYS.MLIGetTime
bcs .9
>PUSHW DATELO
>LIBCALL hLIBSTR,LIBSTR.PRINTDATE
jsr CROUT
clc
.9 rts
*--------------------------------------
EXEC.CMD.TIME >SYSCALL SYS.MLIGetTime
bcs .9
>PUSHW TIMELO
>LIBCALL hLIBSTR,LIBSTR.PRINTTIME
jsr CROUT
clc
.9 rts
*--------------------------------------
EXEC.CMD.ECHO lda hExecArgs
beq .98
>SYSCALL SYS.ExpandPStrA
bcs .99
pha
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
pla
>SYSCALL SYS.FreeMemA
clc
rts
.98 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
EXEC.CMD.TYPE lda hExecArgs
beq .98
>SYSCALL SYS.LoadFileA
bcs .99
>STYA ZPPTR2 store file len
phx
txa
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda ZPPTR2
bne .2
lda ZPPTR2+1
beq .3
dec ZPPTR2+1
.2 dec ZPPTR2
lda (ZPPTR1)
jsr COUT
inc ZPPTR1
bne .1
inc ZPPTR1+1
bra .1
.3 pla
>SYSCALL SYS.FreeMemA
clc
rts
.98 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
EXEC.CMD.EXIT ldy #bEXIT
lda #$FF
sta (pData),y
clc
rts
*--------------------------------------
MAN
SAVE SBIN/SHELL.S.CMD
LOAD SBIN/SHELL.S
ASM

186
SBIN/SHELL.S.HIS.txt Normal file
View File

@ -0,0 +1,186 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
History.Init >PUSHWI 256 Get a buffer for History
>PUSHBI S.MEM.F.INIT0
>SYSCALL SYS.GetMem
bcs .9
txa
ldy #hCmdHistory
sta (pData),y
lda #0
ldy #CmdHistory.IDX
sta (pData),y
ldy #CmdHistory.END
sta (pData),y
.9 rts
*--------------------------------------
History.Add ldy #hCmdHistory
lda (pData),y
beq .9
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.10 ldy #CmdHistory.END
lda (pData),y
sec add len+1
adc (pData) CmdBuffer length
bcc .2 enough room
lda (ZPPTR1) get len of oldest string
sec
adc ZPPTR1
sta ZPPTR2
lda ZPPTR1+1
adc #0
sta ZPPTR2+1
ldy #$FF
.1 iny
lda (ZPPTR2),y move back until ending 0 found
sta (ZPPTR1),y
bne .1
tya
ldy #CmdHistory.END mark new end of history
sta (pData),y
bra .10 retry....
.2 tax keep new CmdHistory.END
tay
lda #0
sta (ZPPTR1),y set ending 0
ldy #CmdHistory.END save old END
lda (pData),y
pha
txa get back new END
ldy #CmdHistory.IDX set it as new IDX
sta (pData),y
ldy #CmdHistory.END
sta (pData),y set new CmdHistory.END
pla get back old END
clc
adc ZPPTR1
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 lda (pData)
tay
.4 lda (pData),y
sta (ZPPTR1),y
dey
bpl .4
.9 rts
*--------------------------------------
History.GetPrev ldy #hCmdHistory
lda (pData),y
beq HISTORY.RTS
tax
ldy #CmdHistory.END
lda (pData),y
beq HISTORY.RTS empty history,nothing to do
ldy #CmdHistory.IDX
lda (pData),y
beq HISTORY.RTS already oldest,nothing to do
txa
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
lda #0
.1 tax
tay
sec
adc (ZPPTR1),y
ldy #CmdHistory.IDX
cmp (pData),y
bne .1 reached current index
.2 txa
ldy #CmdHistory.IDX set new index
sta (pData),y
bra History.SetBuf
History.RTS rts
*--------------------------------------
History.GetNext ldy #hCmdHistory
lda (pData),y
beq HISTORY.RTS
tax
ldy #CmdHistory.END
lda (pData),y
beq HISTORY.RTS empty history,nothing to do
ldy #CmdHistory.IDX
cmp (pData),y
beq HISTORY.RTS already oldest,nothing to do
txa
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
ldy #CmdHistory.IDX
lda (pData),y
phy
tay
sec
adc (ZPPTR1),y add length+1 of current line in history
ply
sta (pData),y
ldy #CmdHistory.END
cmp (pData),y
bne History.SetBuf
jmp CmdBuffer.CLR end of history, just blank buffer
*--------------------------------------
History.SetBuf jsr CmdBuffer.CLR
ldy #CmdHistory.IDX
lda (pData),y
tay keep length of string
clc
adc ZPPTR1
sta ZPPTR1
bcc .1
inc ZPPTR1+1
.1 lda (ZPPTR1),y
sta (pData),y
dey
bpl .1
jmp CmdBuffer.PRINT
*--------------------------------------
History.Quit ldy #hCmdHistory
lda (pData),y
beq .9
>SYSCALL SYS.FreeMemA
.9 rts
*--------------------------------------
MAN
SAVE SBIN/SHELL.S.HIS
LOAD SBIN/SHELL.S
ASM

View File

@ -43,8 +43,8 @@ L.LIBSTR .DA LIBSTR
L.MSG.GREETINGS .DA MSG.GREETINGS
L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.SYNERR .DA MSG.SYNERR
L.CMDS .DA CMDS
T.INTCMDS .DA EXEC.CMD.CD
L.ENV.PATH .DA ENV.PATH
J.INTCMDS .DA EXEC.CMD.CD
.DA EXEC.CMD.SET
.DA EXEC.CMD.DATE
.DA EXEC.CMD.TIME
@ -53,26 +53,23 @@ T.INTCMDS .DA EXEC.CMD.CD
.DA EXEC.CMD.EXIT
.DA 0
*--------------------------------------
CS.INIT lda #0
ldy #bEXIT
sta (pData),y
ldy #CmdHistory.IDX
sta (pData),y
ldy #CmdHistory.END
sta (pData),y
>PUSHWI 256 Get a buffer for History
>PUSHBI S.MEM.F.INIT0
>SYSCALL SYS.GetMem
bcs .99
stx hCmdHistory
>LDYA L.LIBSTR
CS.INIT >LDYA L.LIBSTR
>LOADLIBYA
bcs .99
bcs .9
sta hLIBSTR
ldy #S.PS.hARGS Batch mode ?
lda (pPs),y
beq CS.INIT.INTERACTIVE no,continue starting interactive
clc
.9 rts
*--------------------------------------
CS.INIT.INTERACTIVE
jsr History.Init
bcs .9
ldy #S.PS.ID
lda (pPs),y
>PUSHA
@ -90,7 +87,7 @@ CS.INIT lda #0
sta (pPs)
clc
.99 rts
.9 rts
*--------------------------------------
CS.RUN lda #0
sta (pData)
@ -107,14 +104,19 @@ CS.RUN lda #0
.2 and #$7F
sta (pData)
beq CS.RUN Empty line
ldy #1
lda (pData),y
cmp #'#' Comment
beq CS.RUN
jsr History.Add
>LDYA pData
>SYSCALL SYS.NewPStrYA
bcs .99
ldy #hCMDLINE
ldy #hCmdLine
sta (pData),y
jsr HISTORY.ADD
jsr EXEC.CMD
bcc .3
@ -127,10 +129,10 @@ CS.RUN lda #0
jsr COUT
jsr CROUT
.3 ldy #hCMDLINE
.3 ldy #hCmdLine
lda (pData),y
>SYSCALL SYS.FreeMemA
ldy #hCMDLINE
ldy #hCmdLine
lda #0
sta (pData),y
@ -238,371 +240,14 @@ CS.EVENT.CTRL.CHAR
clc
rts
*--------------------------------------
CS.QUIT lda hCmdHistory
beq .1
>SYSCALL SYS.FreeMemA
.1 lda hLIBSTR
CS.QUIT jsr History.Quit
lda hLIBSTR
>SYSCALL SYS.UnloadLibA
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
EXEC.CMD ldy #hCMDLINE
>PUSHB (pData),y
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD & ARGS
>SYSCALL SYS.PStrGetTkn
bcs .99
ldy #hCMD
sta (pData),y
pha
txa
ldy #hARGS
sta (pData),y
pla
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.UCASEP
>PUSHW L.CMDS
>SYSCALL SYS.GetPStrIndex
bcs .1 Not An internal command
jsr EXEC.CMD.INT
bcs .98
jsr .98
clc
rts
.1 jsr .98 Discard CMD & ARGS
ldy #hCMDLINE
lda (pData),y
>SYSCALL SYS.ExecProcessA
rts
.98 pha
ldy #hCMD
lda (pData),y
>SYSCALL SYS.FreeMemA
ldy #hARGS
lda (pData),y
>SYSCALL SYS.FreeMemA
pla
sec
.99 rts
*--------------------------------------
EXEC.CMD.INT asl
tax
jmp (T.INTCMDS,x)
*--------------------------------------
EXEC.CMD.CD ldy #hARGS
lda (pData),y
bne EXEC.CMD.CD.C
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
clc
rts
EXEC.CMD.CD.C >SYSCALL SYS.GetMemPtrA
>STYA ZPPTR2
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
>PUSHWI MLI.MAXPATH+1 Get a buffer for new PATH
>PUSHBI 0 no particular Option
>SYSCALL SYS.GetMem
bcs .99
>STYA ZPPTR3
stx hNEWPATH
lda #0
sta (ZPPTR3)
ldy #1
lda (ZPPTR2),y
cmp #'/' Full Path?
beq .3
cmp #'.' ".." ?
bne .2
lda (ZPPTR2)
cmp #2
bne .97
iny
lda (ZPPTR2),y
cmp #'.'
bne .97
lda (ZPPTR1)
tay
.1 dey
beq .97
lda (ZPPTR1),y
cmp #'/'
bne .1
tya
sta (ZPPTR3)
.11 lda (ZPPTR1),y
sta (ZPPTR3),y
dey
bne .11
bra .4
.97 lda #SYSMGR.ERRSYN
.98 pha
lda hNEWPATH
>SYSCALL SYS.FreeMemA
pla
sec
.99 rts
.2 >PUSHW ZPPTR1
>PUSHW ZPPTR3
>LIBCALL hLIBSTR,LIBSTR.STRCPYP
.3 >PUSHW ZPPTR2
>PUSHW ZPPTR3
>LIBCALL hLIBSTR,LIBSTR.STRCATP
lda (ZPPTR3)
tay
lda #'/' Ending with '/'?
cmp (ZPPTR3),y
beq .4
iny
sta (ZPPTR3),y
tya
sta (ZPPTR3)
.4 lda hNEWPATH
>SYSCALL SYS.CheckPrefixA
bcs .98
ldy #S.PS.hPREFIX
lda (pPs),y
pha
lda hNEWPATH
sta (pPs),y
pla
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
EXEC.CMD.SET ldy #hARGS
lda (pData),y
bne .2
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda (ZPPTR1)
beq .8 Ending 0 ?
>PUSHW ZPPTR1
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
lda ZPPTR1
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR1
bcc .1
inc ZPPTR1
bra .1
.2 sec
rts
.8 clc
rts
*--------------------------------------
EXEC.CMD.DATE >SYSCALL SYS.MLIGetTime
bcs .9
>PUSHW DATELO
>LIBCALL hLIBSTR,LIBSTR.PRINTDATE
jsr CROUT
clc
.9 rts
*--------------------------------------
EXEC.CMD.TIME >SYSCALL SYS.MLIGetTime
bcs .9
>PUSHW TIMELO
>LIBCALL hLIBSTR,LIBSTR.PRINTTIME
jsr CROUT
clc
.9 rts
*--------------------------------------
EXEC.CMD.ECHO ldy #hARGS
lda (pData),y
beq .98
>SYSCALL SYS.ExpandPStrA
bcs .99
pha
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LIBCALL hLIBSTR,LIBSTR.PRINTP
jsr CROUT
pla
>SYSCALL SYS.FreeMemA
clc
rts
.98 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
EXEC.CMD.TYPE ldy #hARGS
lda (pData),y
beq .98
>SYSCALL SYS.LoadFileA
bcs .99
>STYA ZPPTR2 store file len
phx
txa
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda ZPPTR2
bne .2
lda ZPPTR2+1
beq .3
dec ZPPTR2+1
.2 dec ZPPTR2
lda (ZPPTR1)
jsr COUT
inc ZPPTR1
bne .1
inc ZPPTR1+1
bra .1
.3 pla
>SYSCALL SYS.FreeMemA
clc
rts
.98 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
EXEC.CMD.EXIT ldy #bEXIT
lda #$FF
sta (pData),y
clc
rts
*--------------------------------------
HISTORY.ADD lda hCmdHistory
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.10 lda CmdHistory.END ending 0
inc keep room for new ending 0
sec add len+1
adc (pData) CmdBuffer
bcc .2 enough room
lda (ZPPTR1) get len of oldest string
sec
adc ZPPTR1
sta ZPPTR2
lda ZPPTR1+1
adc #0
sta ZPPTR2+1
ldy #$FF
.1 iny
lda (ZPPTR2),y move back until 0 found
sta (ZPPTR1),y
bne .1
sty CmdHistory.END mark new end of history
bra .10 retry....
.2 ldy CmdHistory.END
lda (pData)
tax
lda pData
sta ZPPTR2
lda pData+1
sta ZPPTR2+1
.3 lda (ZPPTR2)
sta (ZPPTR1),y
inc ZPPTR2
bne .4
inc ZPPTR2+1
.4 iny
dex
bpl .3
lda #0
sta (ZPPTR1),y set ending 0
sty CmdHistory.IDX
sty CmdHistory.END
.9 rts
*--------------------------------------
HISTORY.GETPREV lda CmdHistory.END
beq HISTORY.RTS empty history,nothing to do
lda CmdHistory.IDX
beq HISTORY.RTS already oldest,nothing to do
lda hCmdHistory
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
lda #0
.1 tay save current index
sec
adc (ZPPTR1),y
cmp CmdHistory.IDX
bne .1 not yet reached current index
sty CmdHistory.IDX set new index
bra HISTORY.SETBUF
HISTORY.RTS rts
*--------------------------------------
HISTORY.GETNEXT ldx CmdHistory.END
beq HISTORY.RTS empty history,nothing to do
cpx CmdHistory.IDX
beq HISTORY.RTS
lda hCmdHistory
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
ldy CmdHistory.IDX
lda (ZPPTR1),y
sec
adc CmdHistory.IDX
cmp CmdHistory.END
sta CmdHistory.IDX
beq CmdBuffer.CLR end of history, just blank buffer
*--------------------------------------
HISTORY.SETBUF jsr CmdBuffer.CLR
lda pData
sta ZPPTR2
lda pData+1
sta ZPPTR2+1
ldy CmdHistory.IDX
lda (ZPPTR1),y
tax
.1 lda (ZPPTR1),y
sta (ZPPTR2)
inc ZPPTR2
bne .2
inc ZPPTR2+1
.2 iny
dex
bpl .1
*--------------------------------------
CmdBuffer.PRINT ldy #0
.1 iny
lda (pData),y
@ -615,7 +260,7 @@ CmdBuffer.PRINT ldy #0
*--------------------------------------
CmdBuffer.CLR jsr CmdBuffer.DEL
bne CmdBuffer.CLR
.9 rts
rts
*--------------------------------------
CmdBuffer.DEL lda (pData)
beq .9
@ -654,17 +299,21 @@ COUT phx
plx
rts
pDevJmp jmp (pDev)
*--------------------------------------
.INB SBIN/SHELL.S.CMD
.INB SBIN/SHELL.S.HIS
*--------------------------------------
CS.END
*--------------------------------------
ENV.PATH >PSTRING "PATH"
CMDS >PSTRING "CD"
CMDS1 >PSTRING "SET"
CMDS2 >PSTRING "DATE"
CMDS3 >PSTRING "TIME"
CMDS4 >PSTRING "ECHO"
CMDS5 >PSTRING "TYPE"
CMDS6 >PSTRING "EXIT"
.DA #0
>PSTRING "SET"
>PSTRING "DATE"
>PSTRING "TIME"
>PSTRING "ECHO"
>PSTRING "TYPE"
>PSTRING "EXIT"
.HS 00
*--------------------------------------
LIBSTR >PSTRING "libstr.o"
MSG.GREETINGS >CSTRING "\nA2osX-Shell on Dev=(%h:%h),PS=%h\n\n"
@ -672,15 +321,20 @@ MSG.UNKNOWN >CSTRING "Command Not Found\n"
MSG.SYNERR >CSTRING "Syntax Error Or Invalid Pathname\n"
hLIBSTR .BS 1
hNEWPATH .BS 1
hExecCmd .BS 1
hExecArgs .BS 1
hEnvPath .BS 1
hFullCmd .BS 1
hVarName .BS 1
hVarValue .BS 1
ExecCmdIdx .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
CmdBuffer .BS CmdBuffer.MAX+1
bEXIT .BS 1
hCMDLINE .BS 1
hCMD .BS 1
hARGS .BS 1
hCmdLine .BS 1
hCmdHistory .BS 1
CmdHistory.IDX .BS 1
CmdHistory.END .BS 1

View File

@ -252,11 +252,11 @@ CS.QUIT lda hDev
>SYSCALL SYS.GetDevByIDA
>STYA pDev
ldx #DEVMGR.OPEN
ldx #DEVMGR.CLOSE
jsr pDevJmp
lda hLIBTCPIP
>SYSCALL SYS.FreeMemA
>SYSCALL SYS.UnloadLibA
clc
rts
*--------------------------------------
@ -399,7 +399,11 @@ DNSListener ldy #S.DNS.F+1
and /S.DNS.F.QR
beq .9
ldy #S.DNS.QDCOUNT
ldy #S.DNS.ANCOUNT+1
lda (ZPFrameBase1),y
beq .9
ldy #S.DNS.QDCOUNT+1
lda (ZPFrameBase1),y
tax
beq .3 no QUERY to skip
@ -417,22 +421,9 @@ DNSListener ldy #S.DNS.F+1
dex skip another QUERY ?
bne .1
.3 lda (ZPFrameBase1),y get offset of NAME
phy save current offset in frame
tay
.3 iny skip high byte of offset
iny skip lo byte of offset
ldx #0
.4 lda (ZPFrameBase1),y compute len of NAME
beq .5
inx
iny
bne .4
.5 inx X=length of NAME
ply get back offset in frame
>STYA ZPQuickPtr1
clc
rts

View File

@ -6,44 +6,81 @@ AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF SBIN/TELNETD
.TF /A2OSX.BOOT/SBIN/TELNETD
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MONITOR.I
.INB INC/A2OSX.API.I
.INB INC/KERNEL.I
.INB INC/LIBTCPIP.I
*--------------------------------------
* Main entry point
*--------------------------------------
* Code signature and INIT table
*--------------------------------------
* CLD $D8
* JMP (*,x) $7C
* #JMPTABLE
* /JMPTABLE
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segemnt to Allocate
.DA 0
.DA 0
.DA 0
*--------------------------------------
CS.INIT clc
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>LOADLIBYA
bcs .99
sta hLIBTCPIP
>PUSHWI S.IP.PROTOCOL.TCP
>PUSHWI TCP.PORT.TELNETS
>LIBCALL hLIBTCPIP,LIBTCPIP.CreateSocket
bcs .99
sta hSrvSocket
clc
.99 rts
*--------------------------------------
CS.RUN lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.ListenSocket
bcs .8
>LIBCALL hLIBTCPIP,LIBTCPIP.CreateDevice
bcs *
.8 clc
rts
*--------------------------------------
CS.RUN clc
CS.DOEVENT clc
rts
*--------------------------------------
CS.EVENT clc
rts
*--------------------------------------
CS.QUIT clc
CS.QUIT >PUSHB hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.DestroySocket
lda hLIBTCPIP
>SYSCALL SYS.UnloadLibA
clc
rts
*--------------------------------------
CS.END
*--------------------------------------
LIBTCPIP >PSTRING "libtcpip.o"
hLIBTCPIP .BS 1
hSrvSocket .BS 1
*--------------------------------------
MAN
SAVE SBIN/TELNETD.S
ASM

View File

@ -10,15 +10,15 @@ DevMgr.HiMem .EQ $FFFE Protect IRQ vector in Aux LC
*--------------------------------------
* S.DevMgrInit
*--------------------------------------
S.DevMgrInit ldx #S.DEV.SIZE*2
S.DevMgrInit ldx #S.DEV.SIZE*DevMgr.Count
.1 lda DevMgr.NUL-1,x
sta DevMgr.Table-1,x
dex
bne .1
stz DevMgr.Table+S.DEV.SIZE*2+1
stz DevMgr.Table+S.DEV.SIZE*DevMgr.Count+1
lda #1 reserve #0=NUL, #1=KBD
lda #DevMgr.Count-1
sta DevMgr.LastDevID
>LDYAI DevMgr.End
@ -146,45 +146,7 @@ S.GetDevEvent >LDYAI DevMgr.Table
sta (pEvent),y
rts
*--------------------------------------
DevMgr.Free .BS 2
DevMgr.DevID .BS 1
DevMgr.LastDevID .BS 1
*--------------------------------------
DevMgr.NUL cld
jmp (DevMgr.NUL.Code,x)
.DA #S.DEV.F.INUSE+S.DEV.F.SHARE+S.DEV.F.COUT+S.DEV.F.CHAR
>PSTRING "NUL" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
DevMgr.KBD cld
jmp (DevMgr.KBD.Code,x)
.DA #S.DEV.F.INUSE+S.DEV.F.EVENT+S.DEV.F.CHAR
>PSTRING "KBD" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
DevMgr.NUL.Code .DA .8 OPEN
.DA .8 GETEVENT
.DA .8 COUT
.DA .8 CLOSE
.DA .8 GETINFO
.DA .8 IRQ
.8 clc
rts
*--------------------------------------
DevMgr.KBD.Code .DA .8 OPEN
.DA DevMgr.KBD.GETEVENT
.DA .8 COUT
.DA .8 CLOSE
.DA .8 GETINFO
.DA .8 IRQ
.8 clc
rts
*--------------------------------------
DevMgr.KBD.GETEVENT
S.GetKeyboardEvent
lda KBD
bpl .9
@ -212,6 +174,46 @@ DevMgr.KBD.GETEVENT
sec no event
rts
*--------------------------------------
DevMgr.Free .BS 2
DevMgr.DevID .BS 1
DevMgr.LastDevID .BS 1
*--------------------------------------
DevMgr.Count .EQ 2
*--------------------------------------
DevMgr.NUL cld
jmp (DevMgr.NUL.Code,x)
.DA #S.DEV.F.INUSE+S.DEV.F.SHARE+S.DEV.F.COUT+S.DEV.F.CHAR
>PSTRING "NUL" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
DevMgr.SYS cld
jmp (DevMgr.SYS.Code,x)
.DA #S.DEV.F.INUSE+S.DEV.F.CHAR
>PSTRING "SYS" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
DevMgr.NUL.Code .DA .8 OPEN
.DA .8 GETEVENT
.DA .8 COUT
.DA .8 CLOSE
.DA .8 GETINFO
.DA .8 IRQ
.8 clc
rts
*--------------------------------------
DevMgr.SYS.Code .DA .8 OPEN
.DA .8 GETEVENT
.DA .8 COUT
.DA .8 CLOSE
.DA .8 GETINFO
.DA .8 IRQ
.8 clc
rts
*--------------------------------------
DevMgr.End .EQ *
MAN
SAVE SYS/KERNEL.S.DEV

View File

@ -24,24 +24,11 @@ S.LoadDrvA >PUSHA push Cmd Line for S.PStrGetTkn
.1 sta LoadDrv.Cmd
stx LoadDrv.Args
>PUSHA push CMD for S.FileSearch
>PUSHWI ENV.DRV push ENVNAME=DRV
ldy #S.PS.hENV
lda TskMgr.Table,y Get PS #0 Env
>PUSHA
jsr S.GetEnvVarP get value for ENV=%DRV%
bcs .98
sta LoadDrv.Path
>PUSHA A=PStr to Value
jsr S.FileSearch find File in %DRV%
bcs .97 not Found
sta LoadDrv.FullName
pha
jsr S.SysScrPPSTRA
lda LoadDrv.FullName
pla
jsr S.ExpandPStrA
sta LoadDrv.ExpCmd
jsr S.LoadBinA
bcs .96
@ -71,12 +58,7 @@ S.LoadDrvA >PUSHA push Cmd Line for S.PStrGetTkn
pla
.96 pha
lda LoadDrv.FullName
jsr S.FreeMemA
pla
.97 pha
lda LoadDrv.Path
lda LoadDrv.ExpCmd
jsr S.FreeMemA
pla
@ -91,11 +73,10 @@ S.LoadDrvA >PUSHA push Cmd Line for S.PStrGetTkn
rts
*--------------------------------------
MSG.DRVLOAD >PSTRING "\nLoadDrv:"
LoadDrv.Cmd .BS 1
LoadDrv.Args .BS 1
LoadDrv.Path .BS 1
LoadDrv.FullName .BS 1
LoadDrv.hMem .BS 1
LoadDrv.Cmd .BS 1
LoadDrv.Args .BS 1
LoadDrv.ExpCmd .BS 1
LoadDrv.hMem .BS 1
*--------------------------------------
* pCode = .DRV File Loaded Address
*--------------------------------------

View File

@ -306,28 +306,6 @@ S.SetEnvVar plp
*--------------------------------------
* PRIVATE
*--------------------------------------
S.SetSysEnvA >PUSHA Push Cmd Line
>PUSHBI $3D Push SEP='='
>PUSHBI 0 Push Token IDX
jsr S.PStrGetTkn
bcs *
phx save X,A for discard
pha
pha
txa
>PUSHA
pla
>PUSHA
ldy #S.PS.hENV
lda TSKMGR.TABLE,y
>PUSHA
jsr S.SetEnvVarH
pla disard NAME
jsr S.FreeMemA
pla discard VALUE
jmp S.FreeMemA
*--------------------------------------
* S.SelectEnvH
* In:
* PULLB = hENV
@ -392,24 +370,6 @@ S.SelectEnv
.9 sec
rts
*--------------------------------------
S.PrintSysEnv ldy #S.PS.hENV
lda TskMgr.Table,y Get PS #0 ENV
jsr S.GetMemPtrA
>STYA R.AX
.1 lda (R.AX)
beq .8 Ending 0 ?
>LDYA R.AX
jsr S.SysScrPPSTRYA
jsr S.SysScrCROUT
lda R.AL
sec
adc (R.AX) Add len+1 to PTR
sta R.AL
bcc .1
inc R.AH
bra .1
.8 rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.ENV
LOAD SYS/KERNEL.S

199
SYS/KERNEL.S.EXE.txt Normal file
View File

@ -0,0 +1,199 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
* S.ExecFileA (R)
* in :
* A = hMem of FilePath (PSTRING)
* out :
*
*--------------------------------------
S.ExecFileA jsr S.LoadFileA
bcc S.ExecFileAOK
rts
S.ExecFileAOK >STYA S.ExecFileA.DataLen
stx S.ExecFileA.hData
txa
jsr S.GetMemPtrA
>STYA S.ExecFileA.DataPtr
.1 stz TmpBuffer256
.2 >LDYA S.ExecFileA.DataPtr
>STYA ZPQuickPtr1
inc S.ExecFileA.DataPtr
bne .21
inc S.ExecFileA.DataPtr+1
.21 lda S.ExecFileA.DataLen
bne .22
dec S.ExecFileA.DataLen+1
.22 dec S.ExecFileA.DataLen
lda (ZPQuickPtr1)
cmp #$0D
beq .3
inc TmpBuffer256
ldx TmpBuffer256
sta TmpBuffer256,x
lda S.ExecFileA.DataLen
bne .2
lda S.ExecFileA.DataLen+1
bne .2
.3 lda TmpBuffer256
beq .4
lda TmpBuffer256+1
cmp #'*'
beq .4
lda #'-'
jsr S.SysScrCOUTA
lda #'>'
jsr S.SysScrCOUTA
>LDYAI TmpBuffer256
jsr S.SysScrPPSTRYA
>LDYAI TmpBuffer256
jsr S.NewPStrYA
bcs .99
pha
jsr S.ExecCmdLineA
jsr S.SysScrPRCode
pla
jsr S.FreeMemA
.4 lda S.ExecFileA.DataLen
bne .1
lda S.ExecFileA.DataLen+1
bne .1
jsr .99
clc
rts
.99 lda S.ExecFileA.hData
jsr S.FreeMemA
sec
rts
*--------------------------------------
S.ExecCmdLineA >PUSHA Push Cmd Line
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push Token IDX
jsr S.PStrGetTkn
bcs .99
sta S.ExecFileA.hCMD
stx S.ExecFileA.hARGS
jsr S.GetMemPtrA
>PUSHYA
>PUSHWI EXECCMDS
jsr S.GetPStrIndex
bcs .98
asl
tax
lda S.ExecFileA.hARGS
jsr S.ExecCmdLine
bcs .98
jsr .98
clc
rts
.98 pha
lda S.ExecFileA.hARGS
jsr S.FreeMemA
lda S.ExecFileA.hCMD
jsr S.FreeMemA
pla
.99 sec
rts
*--------------------------------------
S.ExecFileA.hData .BS 1
S.ExecFileA.DataLen .BS 2
S.ExecFileA.DataPtr .BS 2
S.ExecFileA.hCMD .BS 1
S.ExecFileA.hARGS .BS 1
*--------------------------------------
EXECCMDS .HS .03
.AS "SET"
.HS 04
.AS "LOAD"
.HS 04
.AS "EXEC"
.DA #0
*--------------------------------------
S.ExecCmdLine jmp (.1,x)
.1 .DA S.SetSysEnvA
.DA S.LoadDrvA VCPU!!!!
.DA S.CreateProcessA VCPU!!!!
*--------------------------------------
* S.GetPStrIndex
* in :
* PULLW = String Table (Array Of PSTR)
* PULLW = String To Search (PSTR)
* out :
* CC: A = String Index In Table
*--------------------------------------
S.GetPStrIndex >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2
ldx #0
.1 lda (ZPQuickPtr1)
beq .99
cmp (ZPQuickPtr2)
bne .3
tay
.2 lda (ZPQuickPtr1),y
eor (ZPQuickPtr2),y
and #$7F
bne .3
dey
bne .2
txa
clc
rts
.3 inx
lda (ZPQuickPtr1)
sec
adc ZPQuickPtr1
sta ZPQuickPtr1
bcc .1
inc ZPQuickPtr1+1
bra .1
.99 lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
S.SetSysEnvA >PUSHA Push Cmd Line
>PUSHBI $3D Push SEP='='
>PUSHBI 0 Push Token IDX
jsr S.PStrGetTkn
bcs *
phx save X,A for discard
pha
pha
txa
>PUSHA
pla
>PUSHA
ldy #S.PS.hENV
lda TSKMGR.TABLE,y
>PUSHA
jsr S.SetEnvVarH
pla disard NAME
jsr S.FreeMemA
pla discard VALUE
jmp S.FreeMemA
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.EXE
LOAD SYS/KERNEL.S
ASM

View File

@ -339,42 +339,6 @@ S.PStrGetTkn >PULLA Get IDX
.99 sec
rts
*--------------------------------------
* S.GetPStrIndex
* in :
* PULLW = String Table (Array Of PSTR)
* PULLW = String To Search (PSTR)
* out :
* CC: A = String Index In Table
*--------------------------------------
S.GetPStrIndex >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2
ldx #0
.1 lda (ZPQuickPtr1)
beq .99
cmp (ZPQuickPtr2)
bne .3
tay
.2 lda (ZPQuickPtr1),y
eor (ZPQuickPtr2),y
and #$7F
bne .3
dey
bne .2
txa
clc
rts
.3 inx
lda (ZPQuickPtr1)
sec
adc ZPQuickPtr1
sta ZPQuickPtr1
bcc .1
inc ZPQuickPtr1+1
bra .1
.99 lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.STR
LOAD SYS/KERNEL.S

View File

@ -206,7 +206,11 @@ S.TskMgrQuit clc
* out :
* A = Child PSID
*--------------------------------------
S.ExecProcessA jsr S.CreateProcessA
S.ExecProcessNewEnvA
ldy #S.PS.F.ENV
bra S.ExecProcess
S.ExecProcessA ldy #0
S.ExecProcess jsr S.CreateProcess
bcs .9 terminated, do not set PID as HOLD
ldy #S.PS.CID
@ -226,7 +230,12 @@ S.ExecProcessA jsr S.CreateProcessA
* out :
* A = Child PSID
*--------------------------------------
S.CreateProcessNewEnvA
ldy #S.PS.F.ENV
bra S.CreateProcess
S.CreateProcessA
ldy #0
S.CreateProcess sty S.CreateChildProcess.Flags
sta S.CreateProcessA.Cmd
>LDYAI MSG.NEWPS
jsr S.SysScrPPSTRYA
@ -353,6 +362,7 @@ S.CreateChildProcess
.30 inc TSKMGR.SIZE
.3 lda #S.PS.F.INUSE
ora S.CreateChildProcess.Flags
sta (R.AX)
.4 inc TSKMGR.LASTID Get a PSID not alredy running
@ -372,6 +382,10 @@ S.CreateChildProcess
cpy #S.PS.SIZE
bne .5
lda S.CreateChildProcess.Flags
and #S.PS.F.ENV need to create ENV & Prefix ?
beq .6
ldy #S.PS.hPREFIX copy hPREFIX...
lda (pPs),y
jsr S.PStrCpyA
@ -387,8 +401,17 @@ S.CreateChildProcess
ldy #S.PS.hENV
sta (R.AX),y
bra .8
ldy #S.PS.hINDEV
.6 ldy #S.PS.hPREFIX reuse same hPREFIX...
lda (pPs),y
sta (R.AX),y
ldy #S.PS.hENV ...and hENV from parent PS
lda (pPs),y
sta (R.AX),y
.8 ldy #S.PS.hINDEV
lda (pPs),y
sta (R.AX),y
ldy #S.PS.hOUTDEV
@ -404,52 +427,72 @@ S.CreateChildProcess
ldy #S.PS.PID
sta (R.AX),y
ldy #S.PS.ID
lda (R.AX),y
lda TSKMGR.LASTID
clc Exit with A=PSID
rts
.99 sec
rts
*--------------------------------------
S.CreateChildProcess.Flags
.BS 1
*--------------------------------------
* S.InitProcessA
* In :
* A = hMem To Full Cmd Line
*--------------------------------------
S.InitProcessA >PUSHA Push Cmd Line
S.InitProcessA stz S.InitProcessA.hPath
stz S.InitProcessA.hFullPath
>PUSHA Push Cmd Line
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD And ARGS
jsr S.PStrGetTkn
bcc .10
rts OOM error
.99 rts OOM error
.10 ldy #S.PS.hCMD
sta (pPs),y
>PUSHA push CMD for S.FileSearch
.10 sta S.InitProcessA.hCmd
pha
txa
ldy #S.PS.hARGS
sta (pPs),y set ARGS hMem (0 if none)
>PUSHWI ENV.PATH push ENVNAME=PATH
pla
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
lda (ZPQuickPtr1)
cmp #'/'
bne .20
lda S.InitProcessA.hCmd
bra .30
.20 >PUSHWI ENV.PATH push ENVNAME=PATH
ldy #S.PS.hENV
lda (pPs),y
>PUSHA
jsr S.GetEnvVarP get value for ENV=PATH
bcs .99
sta S.InitProcessA.PATH save VALUE hMem for discard
sta S.InitProcessA.hPath save VALUE hMem for discard
pha
lda S.InitProcessA.hCmd
>PUSHA push CMD for S.FileSearch
pla
>PUSHA A=PStr to ENV Value
jsr S.FileSearch find File in %PATH%
bcs .98
bcs S.InitProcessA.ClnUp
sta S.InitProcessA.FULLPATH save FULLPATH hMem for discard
sta S.InitProcessA.hFullPath save FULLPATH hMem for discard
.30 jsr S.PStrCpyA
ldy #S.PS.hCMD
sta (pPs),y
pha
jsr S.SysScrPPSTRA
pla
jsr S.LoadBinA A = BinPath hMem
bcs .97
bcs S.InitProcessA.ClnUp
>STYA pCode save PTR to Code Segment
txa
@ -468,7 +511,7 @@ S.InitProcessA >PUSHA Push Cmd Line
>PUSHAX Push DS.SIZE
>PUSHBI S.MEM.F.INIT0 Clear DS
jsr S.GetMem
bcs .97
bcs S.InitProcessA.ClnUp
>STYA pData
txa
@ -477,25 +520,25 @@ S.InitProcessA >PUSHA Push Cmd Line
.1 ldx #TSKMGR.INIT
jsr pCodeJmp Call INIT function
bcs .97
jsr .97
clc
rts
.97 pha save ERR
lda S.InitProcessA.FULLPATH
S.InitProcessA.ClnUp
php save Carry
pha save ERR
lda S.InitProcessA.hFullPath
beq .1
jsr S.FreeMemA
pla
.98 pha save ERR
lda S.InitProcessA.PATH
.1 lda S.InitProcessA.hPath
beq .2
jsr S.FreeMemA
pla
.99 sec
.2 pla
plp
rts
S.InitProcessA.PATH .BS 1
S.InitProcessA.FULLPATH .BS 1
*--------------------------------------
S.InitProcessA.hCmd .BS 1
S.InitProcessA.hPath .BS 1
S.InitProcessA.hFullPath .BS 1
*--------------------------------------
* S.SelectProcessA
* In : A=PSID
@ -545,6 +588,10 @@ S.FreeProcessA jsr S.GetPSByIDA
jsr S.FreeMemA
lda (ZPQuickPtr1) get S.PS.F
and #S.PS.F.ENV do we have to dscard duplicated env & prefix ?
beq .4
.2 ldy #S.PS.hENV
lda (ZPQuickPtr1),y
beq .3

View File

@ -35,7 +35,7 @@ KERNEL jmp S.KernelInit KERNEL.COLDBOOT
.DA S.PStrCmp
.DA S.PStrGetTkn
.DA S.GetPStrIndex
.DA 0
.DA 0
.DA 0
*--------------------------------------
@ -104,15 +104,15 @@ KERNEL jmp S.KernelInit KERNEL.COLDBOOT
.DA S.GetDevByNameYA
.DA 0
.DA 0
.DA S.GetKeyboardEvent
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.ExecProcessA $90
.DA S.ExecProcessNewEnvA $90
.DA S.ExecProcessA
.DA S.CreateProcessNewEnvA
.DA S.CreateProcessA
.DA 0
.DA 0
.DA S.GetPSByIDA
.DA 0
@ -288,140 +288,28 @@ S.KernelRun jsr S.TskMgrRun
jsr S.DestroyEvent
jmp S.KernelRun
*--------------------------------------
S.KernelQuit bra *
*--------------------------------------
* PUBLIC
*--------------------------------------
* S.ExecFileA (R)
* in :
* A = hMem of FilePath (PSTRING)
* out :
*
*--------------------------------------
S.ExecFileA jsr S.LoadFileA
bcc S.ExecFileAOK
rts
S.ExecFileAOK >STYA S.ExecFileA.DataLen
stx S.ExecFileA.hData
txa
S.PrintSysEnv ldy #S.PS.hENV
lda TskMgr.Table,y Get PS #0 ENV
jsr S.GetMemPtrA
>STYA S.ExecFileA.DataPtr
.1 stz TmpBuffer256
.2 >LDYA S.ExecFileA.DataPtr
>STYA ZPQuickPtr1
inc S.ExecFileA.DataPtr
bne .21
inc S.ExecFileA.DataPtr+1
.21 lda S.ExecFileA.DataLen
bne .22
dec S.ExecFileA.DataLen+1
.22 dec S.ExecFileA.DataLen
lda (ZPQuickPtr1)
cmp #$0D
beq .3
inc TmpBuffer256
ldx TmpBuffer256
sta TmpBuffer256,x
lda S.ExecFileA.DataLen
bne .2
lda S.ExecFileA.DataLen+1
bne .2
.3 lda TmpBuffer256
beq .4
lda TmpBuffer256+1
cmp #'*'
beq .4
lda #'-'
jsr S.SysScrCOUTA
lda #'>'
jsr S.SysScrCOUTA
>LDYAI TmpBuffer256
jsr S.SysScrPPSTRYA
>LDYAI TmpBuffer256
jsr S.NewPStrYA
bcs .99
pha
jsr S.ExecCmdLineA
jsr S.SysScrPRCode
pla
jsr S.FreeMemA
.4 lda S.ExecFileA.DataLen
bne .1
lda S.ExecFileA.DataLen+1
bne .1
jsr .99
clc
rts
.99 lda S.ExecFileA.hData
jsr S.FreeMemA
>STYA R.AX
.1 lda (R.AX)
beq .8 Ending 0 ?
>LDYA R.AX
jsr S.SysScrPPSTRYA
jsr S.SysScrCROUT
lda R.AL
sec
rts
*--------------------------------------
S.ExecCmdLineA >PUSHA Push Cmd Line
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push Token IDX
jsr S.PStrGetTkn
bcs .99
sta S.ExecFileA.hCMD
stx S.ExecFileA.hARGS
jsr S.GetMemPtrA
>PUSHYA
>PUSHWI EXECCMDS
jsr S.GetPStrIndex
bcs .98
asl
tax
lda S.ExecFileA.hARGS
jsr S.ExecCmdLine
bcs .98
jsr .98
clc
rts
.98 pha
lda S.ExecFileA.hARGS
jsr S.FreeMemA
lda S.ExecFileA.hCMD
jsr S.FreeMemA
pla
.99 sec
rts
*--------------------------------------
S.ExecFileA.hData .BS 1
S.ExecFileA.DataLen .BS 2
S.ExecFileA.DataPtr .BS 2
S.ExecFileA.hCMD .BS 1
S.ExecFileA.hARGS .BS 1
*--------------------------------------
S.ExecCmdLine jmp (.1,x)
.1 .DA S.SetSysEnvA
.DA S.LoadDrvA VCPU!!!!
.DA S.CreateProcessA VCPU!!!!
adc (R.AX) Add len+1 to PTR
sta R.AL
bcc .1
inc R.AH
bra .1
.8 rts
*--------------------------------------
pDevJmp jmp (pDev)
pCodeJmp jmp (pCode)
pLibJmp jmp (pLib)
*--------------------------------------
EXECCMDS >PSTRING "SET"
EXECCMDS1 >PSTRING "LOAD"
EXECCMDS2 >PSTRING "EXEC"
.DA #0
*--------------------------------------
MSG.Init >PSTRING "A2osX[Stage2]:Init\n"
MSG.Init.MemMgr >PSTRING "->MemMgr Init"
MSG.Init.TskMgr >PSTRING "->TskMgr Init"
@ -438,8 +326,6 @@ STARTUP.FILE >PSTRING "A2osX.STARTUP"
*--------------------------------------
ENV.A2osX >PSTRING "A2OSX"
ENV.PATH >PSTRING "PATH"
ENV.DRV >PSTRING "DRV"
ENV.ETC >PSTRING "ETC"
ENV.LIB >PSTRING "LIB"
*--------------------------------------
.INB SYS/KERNEL.S.MEM
@ -455,6 +341,7 @@ ENV.LIB >PSTRING "LIB"
.INB SYS/KERNEL.S.ENV
.INB SYS/KERNEL.S.TSK
.INB SYS/KERNEL.S.EVT
.INB SYS/KERNEL.S.EXE
*--------------------------------------
.INB SYS/KERNEL.S.DEV
*--------------------------------------

View File

@ -6,6 +6,7 @@ CREATE INC
CREATE LIB
CREATE SBIN
CREATE SYS
CREATE USR
PREFIX /A2OSX.SRC
CREATE BIN
CREATE DRV
@ -14,3 +15,4 @@ CREATE INC
CREATE LIB
CREATE SBIN
CREATE SYS
CREATE USR

View File

@ -4,7 +4,6 @@ NEW
INC 1
AUTO 6
PREFIX /A2OSX.BOOT
DELETE A2OSX.SYSTEM
BLOAD A
BSAVE A2OSX.SYSTEM,TSYS,A$2000,L$1300
-A2OSX.SYSTEM