Kernel version 0.9 : Implementing R/W to StdIn/StdOut TCP Sockets

This commit is contained in:
Rémy GIBERT 2017-03-28 17:46:12 +02:00
parent c86aeab0c0
commit e2e972ee7e
12 changed files with 166 additions and 106 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -64,10 +64,11 @@ KrnBuf256 .EQ $0C00 Main
*--------------------------------------
KrnOut256 .EQ $0D00 Used to return Values to User Space
*--------------------------------------
MLICALL.PARAMS .EQ $0E00 Main, $12 bytes min for GetFileInfo
K.S.STAT .EQ MLICALL.PARAMS+$12 S.STAT for internal kernel operations (DIR,FIO)
K.MLI.PARAMS .EQ $0E00 Main, 18 bytes min for GetFileInfo
K.MLI.PATH .EQ K.MLI.PARAMS+18
K.S.STAT .EQ K.MLI.PATH+65 S.STAT for internal kernel operations (DIR,FIO)
K.S.DEVSTAT .EQ K.S.STAT+64
K.S.PORTCALL .EQ K.S.DEVSTAT+9
K.S.PORTCALL .EQ K.S.DEVSTAT+64 S.DEVSTAT=25 or higher depends on dev type
*--------------------------------------
*** Z80 Reserved $0F00-10FF***
*--------------------------------------
@ -571,11 +572,11 @@ S.NODE.DEV .EQ 5
* S.NODE.LNK
*--------------------------------------
S.NODE.SSOCK.HSKT .EQ 2
*S.NODE.SSOCK.OPEN .EQ 3
*S.NODE.SSOCK.CLOSE .EQ 4
*S.NODE.SSOCK.READ .EQ 5
*S.NODE.SSOCK.WRITE .EQ 6
*S.NODE.SSOCK.STATUS .EQ 7
S.NODE.SSOCK.OPEN .EQ 3
S.NODE.SSOCK.CLOSE .EQ 4
S.NODE.SSOCK.READ .EQ 5
S.NODE.SSOCK.WRITE .EQ 6
S.NODE.SSOCK.STATUS .EQ 7
*
S.NODE.SSOCK .EQ 8
*--------------------------------------

View File

@ -25,12 +25,12 @@ K.LoadEXEYA >STYA K.LoadEXEYA.Filename
txa
jmp K.GetMemPtrA X=hMem from K.GetMemByNameA
*--------------------------------------
K.LoadEXEYA.1 >PUSHWI KrnBuf256
K.LoadEXEYA.1 >PUSHWI K.S.STAT
>PUSHW K.LoadEXEYA.Filename
jsr K.STAT Look for AUXTYPE
bcs .9
>LDYA KrnBuf256+S.STAT.P.AUXTYPE
>LDYA K.S.STAT+S.STAT.P.AUXTYPE
>STYA BIN.Relocate.Start
>PUSHYA Push AUXTYPE

View File

@ -74,8 +74,18 @@ K.PutCA.CDEV ldy #S.NODE.DEV.JMP
ldx #DEVMGR.WRITE
.1 jmp $ffff
*--------------------------------------
K.PutCA.SSOCK sec
rts
K.PutCA.SSOCK lda (pDev) #S.NODE.HANDLER
jsr K.GetMemPtrA
>STYA .1
ldy #S.NODE.SSOCK.HSKT
>PUSHB (pDev),y
>PUSHB K.PutC.Char
ldy #S.NODE.SSOCK.WRITE
lda (pDev),y
tax Function Offset for write
.1 jmp $ffff
*--------------------------------------
K.PutCA.FIFO ldy #S.NODE.FIFO.S
lda (pDev),y
@ -121,7 +131,6 @@ K.PutC.Node .BS 1
* CC = success
* A = char
*\--------------------------------------
K.FGetCA
*/--------------------------------------
* #GetC
* Get char from StdIn
@ -134,7 +143,8 @@ K.FGetCA
K.GetC ldy #S.PS.hStdIn
lda (pPs),y
sta K.PutC.Node
K.FGetCA sta K.PutC.Node
jsr K.GetMemPtrA
>STYA pDev
@ -153,7 +163,8 @@ K.GetC ldy #S.PS.hStdIn
.DA K.GetC.SSOCK
.DA K.GetC.FIFO
*--------------------------------------
K.GetC.REG
K.GetC.REG lda K.PutC.Node
jmp K.FReadA
*--------------------------------------
K.GetC.CDEV ldx #DEVMGR.READ
ldy #S.NODE.DEV.JMP
@ -164,12 +175,23 @@ K.GetC.CDEV ldx #DEVMGR.READ
sta .1+2
.1 jmp $ffff
*--------------------------------------
K.GetC.SSOCK
K.GetC.SSOCK lda (pDev) #S.NODE.HANDLER
jsr K.GetMemPtrA
>STYA .1
ldy #S.NODE.SSOCK.READ
lda (pDev),y
tax Function Offset for READ
ldy #S.NODE.SSOCK.HSKT
lda (pDev),y
.1 jmp $ffff
*--------------------------------------
K.GetC.FIFO
*/--------------------------------------
* #FPutS
* Print String to FILE
* Write String to FILE
* ##In:
* PUSHW : CPtr
* PUSHB : hFILE
@ -179,16 +201,31 @@ K.GetC.FIFO
K.FPutS
*/--------------------------------------
* #PutSYA
* Print String to StdOut
* Write String to StdOut
* ##In:
* Y,A : CPtr
* ##Out:
* CC = success
*\--------------------------------------
K.PutSYA
*--------------------------------------
*/--------------------------------------
* #FGetS
* Read String From FILE
* ##In:
* PUSHW : CPtr
* PUSHB : hFILE
* ##Out:
* CC = success
*\--------------------------------------
K.FGetS
*--------------------------------------
*/--------------------------------------
* #GetSYA
* Read String From StdIn
* ##In:
* Y,A : CPtr
* ##Out:
* CC = success
*\--------------------------------------
K.GetSYA
bra *
*--------------------------------------

View File

@ -15,7 +15,7 @@ AUTO 6
*\--------------------------------------
K.OpenDirYA jsr PFT.CheckPathYA
>STYA ZPPtr2
>STYA MLICALL.PARAMS+1 For GETFILEINFO,MLIOPEN
>STYA K.MLI.PARAMS+1 For GETFILEINFO,MLIOPEN
>PUSHWI S.NODE.DIR
>PUSHBI S.MEM.F.INIT0
@ -39,7 +39,7 @@ K.OpenDirYA jsr PFT.CheckPathYA
.7 >MLICALL MLIGETFILEINFO
bcs .98 file/dir does not exists....quit
lda MLICALL.PARAMS+4
lda K.MLI.PARAMS+4
cmp #$0F Directory ?
bne .98
@ -50,7 +50,7 @@ K.OpenDirYA jsr PFT.CheckPathYA
>MLICALL MLIOPEN
bcs .98
lda MLICALL.PARAMS+5 get ref_num
lda K.MLI.PARAMS+5 get ref_num
ldy #S.NODE.DIR.REF
sta (ZPPtr1),y
@ -104,10 +104,10 @@ K.ReadDirA.ROOT ldy #S.NODE.DIR.FC did we already returned something ?
lda (ZPPtr1),y
bne K.ReadDirA.NoMore
stz MLICALL.PARAMS+1 All Volumes
stz K.MLI.PARAMS+1 All Volumes
>LDYAI KrnBuf256
>STYA MLICALL.PARAMS+2
>STYA K.MLI.PARAMS+2
>STYA ZPPtr2
>MLICALL MLIONLINE
bcc .10
@ -153,13 +153,13 @@ K.ReadDirA.ROOT ldy #S.NODE.DIR.FC did we already returned something ?
tax
jsr K.ReadDirA.AddToBuf
inc
sta KrnOut256
sta K.MLI.PATH
lda #'/'
sta KrnOut256+1
sta K.MLI.PATH+1
ldy #1
.4 lda (ZPPtr2),y
sta KrnOut256+1,y
sta K.MLI.PATH+1,y
jsr K.ReadDirA.AddToBuf
iny
dex
@ -183,16 +183,16 @@ K.ReadDirA.ROOT ldy #S.NODE.DIR.FC did we already returned something ?
lsr
sta K.S.STAT+S.STAT.P.SLOT
>LDYAI KrnOut256
>STYA MLICALL.PARAMS+1
>LDYAI K.MLI.PATH
>STYA K.MLI.PARAMS+1
>MLICALL MLIGETFILEINFO
sta K.S.STAT+S.STAT.P.DEVSTATUS
bcs .80
>LDYA MLICALL.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>LDYA K.MLI.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>STYA K.S.STAT+S.STAT.P.DEVBLOCKS
>LDYA MLICALL.PARAMS+8
>LDYA K.MLI.PARAMS+8
>STYA K.S.STAT+S.STAT.BLOCKS
.80 jsr K.ReadDirA.ADDSTAT
@ -217,7 +217,7 @@ K.ReadDirA.ROOT ldy #S.NODE.DIR.FC did we already returned something ?
tax
jmp K.GetMemPtrA
*--------------------------------------
K.ReadDirA.DIR sta MLICALL.PARAMS+1 A=#S.DIR.PRODOS.REF
K.ReadDirA.DIR sta K.MLI.PARAMS+1 A=#S.DIR.PRODOS.REF
>PUSHWI 512 Get a 512 bytes buffer for reading dir...
>PUSHBI 0
@ -225,7 +225,7 @@ K.ReadDirA.DIR sta MLICALL.PARAMS+1 A=#S.DIR.PRODOS.REF
bcs .99
stx K.ReadDirA.hMem
>STYA MLICALL.PARAMS+2 For reading
>STYA K.MLI.PARAMS+2 For reading
pha
tya
@ -240,7 +240,7 @@ K.ReadDirA.DIR sta MLICALL.PARAMS+1 A=#S.DIR.PRODOS.REF
sta ZPPtr3+1 PTR to Buffer for PASS #2
>LDYAI 512
>STYA MLICALL.PARAMS+4
>STYA K.MLI.PARAMS+4
>MLICALL MLIREAD Read A block from directory
bcs .98
@ -583,7 +583,7 @@ K.CloseDirA.1 .EQ K.FCloseA.1
* ldy #S.NODE.DIR.REF
* lda (ZPPtr1),y
* beq .1
* sta MLICALL.PARAMS+1
* sta K.MLI.PARAMS+1
* >MLICALL MLICLOSE
*.1 ldy #S.NODE.DIR.IOBUF
@ -603,19 +603,19 @@ K.CloseDirA.1 .EQ K.FCloseA.1
* A = EC
*\-------------------------------------
K.MKDirYA jsr PFT.CheckPathYA
>STYA MLICALL.PARAMS+1
>STYA K.MLI.PARAMS+1
lda #S.FILEINFO.ACCESS.FULL
sta MLICALL.PARAMS+S.FILEINFO.ACCESS
sta K.MLI.PARAMS+S.FILEINFO.ACCESS
lda #S.FILEINFO.TYPE.DIR
sta MLICALL.PARAMS+S.FILEINFO.TYPE
sta K.MLI.PARAMS+S.FILEINFO.TYPE
lda #S.FILEINFO.STORETYPE.DIR
sta MLICALL.PARAMS+S.FILEINFO.STORETYPE
sta K.MLI.PARAMS+S.FILEINFO.STORETYPE
* jsr DATETIME
ldx #3
.1 lda DATELO,x
sta MLICALL.PARAMS+8,x
sta K.MLI.PARAMS+8,x
dex
bpl .1

View File

@ -348,7 +348,7 @@ S.UnsetEnvPtr1 jsr ENV.FindVarPtr1
* ZPPtr1 -> NAME
* Out:
* CC: Found
* YA -> VALUE
* ZPPtr3=YA -> VALUE
* CS: Not Found
*--------------------------------------
ENV.CheckSysVarPtr1
@ -381,7 +381,7 @@ ENV.CheckSysVarPtr1
asl
tax
jmp (ENV.SysVarsJmp,x)
*--------------------------------------
ENV.SysVars .AS "*#?@$!"
ENV.SysVarsJmp .DA ENV.SysVarsArgs
.DA ENV.SysVarsArgC
@ -431,36 +431,39 @@ ENV.SysVarsPID ldy #S.PS.PID
.HS 2C
ENV.SysVarsCPID ldy #S.PS.CPID
lda (pPS),y
ENV.SysVarsA sta HEXBUF
stz HEXBUF+1
stz HEXBUF+2
stz HEXBUF+3
jsr HEX2DEC
ldy #0
ldy #6 Start at 0000000xxx
ldx #4 len is 4 for now
.1 lda ASCBUF,y
.1 dex
lda ASCBUF+1,y
cmp #'0'
bne .2
iny
cpy #10
cpy #8 Print always ast char
bne .1
sta KrnOut256+1
ldx #1
bra ENV.SysVarsExit
.2 txa
sta ASCBUF,y
.2 ldx #0
.3 lda ASCBUF,y
inx
sta KrnOut256,x
iny
cpy #10
bne .3
tya
clc
adc #ASCBUF
tay
lda /ASCBUF
adc #0
bra ENV.SysVarsExit2
ENV.SysVarsExit stx KrnOut256
>LDYAI KrnOut256
ENV.SysVarsExit2
>STYA ZPPtr3
clc
rts

View File

@ -25,7 +25,7 @@ AUTO 6
* CS : A = EC
*\--------------------------------------
K.FOpen jsr PFT.CheckPathSTK
>PULLW MLICALL.PARAMS+1
>PULLW K.MLI.PARAMS+1
>PULLB K.FOpen.MODE
>PULLB K.FOpen.TYPE
>PULLW K.FOpen.AUXTYPE
@ -37,17 +37,17 @@ K.FOpen jsr PFT.CheckPathSTK
bpl K.FOpen.9 No, return MLI error
lda #S.FILEINFO.ACCESS.FULL Yes, Create...
sta MLICALL.PARAMS+3 Access
sta K.MLI.PARAMS+3 Access
lda K.FOpen.TYPE
sta MLICALL.PARAMS+4 File type
sta K.MLI.PARAMS+4 File type
>LDYA K.FOpen.AUXTYPE
>STYA MLICALL.PARAMS+5 Aux type
>STYA K.MLI.PARAMS+5 Aux type
lda #S.FILEINFO.STORETYPE.STD
sta MLICALL.PARAMS+7
sta K.MLI.PARAMS+7
ldx #3
.1 lda DATELO,x
sta MLICALL.PARAMS+8,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
@ -69,11 +69,11 @@ K.FOpen.10 >PUSHWI S.NODE.REG
>MLICALL MLIOPEN
bcs .98
lda MLICALL.PARAMS+5 get ref_num
lda K.MLI.PARAMS+5 get ref_num
ldy #S.NODE.REG.REF
sta (ZPPtr1),y
sta MLICALL.PARAMS+1 Next MLI Calls are REF_NUM based
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
lda K.FOpen.MODE
bit #SYS.FOpen.W
@ -82,9 +82,9 @@ K.FOpen.10 >PUSHWI S.NODE.REG
and #SYS.FOpen.A Append ?
bne .11 yes, go to end of file
stz MLICALL.PARAMS+2
stz MLICALL.PARAMS+3
stz MLICALL.PARAMS+4
stz K.MLI.PARAMS+2
stz K.MLI.PARAMS+3
stz K.MLI.PARAMS+4
>MLICALL MLISETEOF no, reset size to 0
bcs .98
bra .20
@ -100,9 +100,9 @@ K.FOpen.10 >PUSHWI S.NODE.REG
beq .30
lda #$FF
sta MLICALL.PARAMS+2
sta K.MLI.PARAMS+2
lda #$0D
sta MLICALL.PARAMS+3
sta K.MLI.PARAMS+3
>MLICALL MLINEWLINE
.30 ldy #S.NODE.T
@ -138,7 +138,7 @@ K.FCloseA jsr PFT.CheckNodeA
K.FCloseA.1 ldy #S.NODE.REG.REF
lda (ZPPtr1),y
beq .1
sta MLICALL.PARAMS+1
sta K.MLI.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.NODE.REG.IOBUF
@ -172,10 +172,10 @@ K.FWriteAY jsr PFT.CheckNodeA
ldx #MLIWRITE
K.FReadWrite.0 jsr FILE.SetupPrt1A
>LDYAI K.FWriteAY.Buf
>STYA MLICALL.PARAMS+2
>STYA K.MLI.PARAMS+2
lda #1
sta MLICALL.PARAMS+4
stz MLICALL.PARAMS+5
sta K.MLI.PARAMS+4
stz K.MLI.PARAMS+5
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr A2osX.MLICALL
bcs .9
@ -208,13 +208,13 @@ K.FWrite jsr PFT.CheckNodeSTK
ldx #MLIWRITE
K.FReadWrite.1 >PULLA
jsr FILE.SetupPrt1A
>PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2
>PULLW K.MLI.PARAMS+4
>PULLW K.MLI.PARAMS+2
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr A2osX.MLICALL
bcs .9
>LDYA MLICALL.PARAMS+6
>LDYA K.MLI.PARAMS+6
.9 rts
*/--------------------------------------
* #FFlushA
@ -245,9 +245,9 @@ K.FSeek jsr PFT.CheckNodeSTK
* cmp #SYS.FSeek.SET =0
bne .1
stz MLICALL.PARAMS+2
stz MLICALL.PARAMS+3
stz MLICALL.PARAMS+4
stz K.MLI.PARAMS+2
stz K.MLI.PARAMS+3
stz K.MLI.PARAMS+4
bra .8
.1 cmp #SYS.FSeek.CUR
@ -261,15 +261,15 @@ K.FSeek jsr PFT.CheckNodeSTK
>MLICALL MLIGETEOF
bcs .9
.8 lda MLICALL.PARAMS+2
.8 lda K.MLI.PARAMS+2
adc K.FSeek.OFFSET
sta MLICALL.PARAMS+2
lda MLICALL.PARAMS+3
sta K.MLI.PARAMS+2
lda K.MLI.PARAMS+3
adc K.FSeek.OFFSET+1
sta MLICALL.PARAMS+3
lda MLICALL.PARAMS+4
sta K.MLI.PARAMS+3
lda K.MLI.PARAMS+4
adc K.FSeek.OFFSET+2
sta MLICALL.PARAMS+4
sta K.MLI.PARAMS+4
bcs .99 Offset out of range!
>MLICALL MLISETMARK
@ -295,8 +295,8 @@ K.FTellA jsr PFT.CheckNodeA
K.FTellA.1 jsr FILE.SetupPrt1A
>MLICALL MLIGETMARK
bcs .9
>LDYA MLICALL.PARAMS+2
ldx MLICALL.PARAMS+4
>LDYA K.MLI.PARAMS+2
ldx K.MLI.PARAMS+4
.9 rts
*/--------------------------------------
* #FEOFA
@ -319,13 +319,13 @@ K.FEOFA jsr PFT.CheckNodeA
bcs .9
sec
lda MLICALL.PARAMS+2
lda K.MLI.PARAMS+2
sbc K.FEOFA.MARK
bne .8
lda MLICALL.PARAMS+3
lda K.MLI.PARAMS+3
sbc K.FEOFA.MARK+1
bne .8
lda MLICALL.PARAMS+4
lda K.MLI.PARAMS+4
sbc K.FEOFA.MARK+2
.8 clc
.9 rts
@ -334,7 +334,7 @@ K.FEOFA.MARK .BS 3
* #RemoveYA
*\--------------------------------------
K.RemoveYA jsr PFT.CheckPathYA
>STYA MLICALL.PARAMS+1
>STYA K.MLI.PARAMS+1
>MLICALL MLIDESTROY
rts
*/--------------------------------------
@ -346,8 +346,8 @@ K.RemoveYA jsr PFT.CheckPathYA
* ##Out :
*\--------------------------------------
K.Rename jsr PFT.CheckPathSTK
>PULLW MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+3
>PULLW K.MLI.PARAMS+1
>PULLW K.MLI.PARAMS+3
>MLICALL MLIRename
rts
*/--------------------------------------
@ -359,7 +359,7 @@ K.Rename jsr PFT.CheckPathSTK
* ##Out :
*\--------------------------------------
K.Stat jsr PFT.CheckPathSTK
>PULLW MLICALL.PARAMS+1
>PULLW K.MLI.PARAMS+1
>PULLW ZPPtr2
>MLICALL MLIGETFILEINFO
bcs .9
@ -372,7 +372,7 @@ FILE.SetIOBUF >PUSHWI 1024 get a ProDOS IOBUF
jsr K.GetMem
bcs .9
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa
ldy #S.NODE.REG.IOBUF
sta (ZPPtr1),y
@ -382,10 +382,10 @@ FILE.SetupPrt1A jsr K.GetMemPtrA
>STYA ZPPtr1
ldy #S.NODE.REG.REF
lda (ZPPtr1),y
sta MLICALL.PARAMS+1
sta K.MLI.PARAMS+1
rts
*--------------------------------------
FILE.MLI2STAT lda MLICALL.PARAMS+S.FILEINFO.ACCESS
FILE.MLI2STAT lda K.MLI.PARAMS+S.FILEINFO.ACCESS
cmp #S.FILEINFO.ACCESS.FULL
bne .1
@ -402,7 +402,7 @@ FILE.MLI2STAT lda MLICALL.PARAMS+S.FILEINFO.ACCESS
ldx #2
ldy #S.STAT.P.TYPE+2
.3 lda MLICALL.PARAMS+S.FILEINFO.TYPE,x
.3 lda K.MLI.PARAMS+S.FILEINFO.TYPE,x
sta (ZPPtr2),y
dey
dex

View File

@ -81,11 +81,11 @@ A2osX.LIBCALL1 pha No need to save X, K.GetMemPtrA will leave it unmodified
.1 jmp $ffff
*--------------------------------------
A2osX.MLICALL1 stx .1
sta MLICALL.PARAMS
sta K.MLI.PARAMS
jsr GO.ProDOS
jsr MLI
.1 .BS 1
.DA MLICALL.PARAMS
.DA K.MLI.PARAMS
jsr GO.A2osX
rts
*--------------------------------------

View File

@ -159,11 +159,11 @@ IrqMgrInit php
>STYA $FFFE
>LDYAI IrqHandler
>STYA MLICALL.PARAMS+2
>STYA K.MLI.PARAMS+2
>MLICALL MLIALLOCIRQ
bcs .9
lda MLICALL.PARAMS+1
lda K.MLI.PARAMS+1
sta ProDOS.INTNUM
stz ZPPtr1 Try finding a Mouse Card...
@ -468,7 +468,7 @@ TskMgrInit >LDYAI TskMgr.Table+S.PS Clear whole process table except PS0
sta (pPs),y
>LDYAI UsrBuf256
>STYA MLICALL.PARAMS+1
>STYA K.MLI.PARAMS+1
>MLICALL MLIGETPREFIX
bcs .9

View File

@ -59,7 +59,7 @@ Get char from StdIn
+ A = char
#FPutS
Print String to FILE
Write String to FILE
##In:
+ PUSHW : CPtr
@ -69,7 +69,26 @@ Print String to FILE
+ CC = success
#PutSYA
Print String to StdOut
Write String to StdOut
##In:
+ Y,A : CPtr
##Out:
+ CC = success
#FGetS
Read String From FILE
##In:
+ PUSHW : CPtr
+ PUSHB : hFILE
##Out:
+ CC = success
#GetSYA
Read String From StdIn
##In:
+ Y,A : CPtr