Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-07-24 18:00:24 +02:00
parent 62efb2d2e0
commit 92922a9308
27 changed files with 339 additions and 128 deletions

View File

@ -694,7 +694,7 @@ TODO: mode="w+t=TYP,x=AUXTYPE"
Close a file
## C
int fclose ( FILE * stream );
int fclose ( hFILE streamm );
## ASM
**In:**
@ -702,12 +702,13 @@ int fclose ( FILE * stream );
**Out:**
# FRead
int fread ( void * ptr, int count, FILE * stream );
int fread (hFILE stream, void * ptr, int count );
Read bytes from file
**In:**
PUSHW = Dest Ptr
PUSHW = Bytes To Read
PUSHB = hFILE
`>PUSHWI count`
`>PUSHW ptr`
`lda hFILE`
`>SYSCALL fread`
**Out:**
Y,A = Bytes Read
@ -715,13 +716,14 @@ Read bytes from file
Write bytes to file
## C
`int fwrite ( const void * ptr, int count, hFILE stream );`
`int fwrite (hFILE stream, const void * ptr, int count );`
## ASM
**In:**
`>PUSHB = hFILE`
`>PUSHWI ptr`
`>LDYA count`
`>PUSHWI count`
`>PUSHW ptr`
`lda hFILE`
`>SYSCALL fwrite`
# Out:
Y,A = Bytes Written

Binary file not shown.

Binary file not shown.

View File

@ -146,7 +146,7 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>STYA ZPPTR1
>LDYA L.MSG0
>SYSCALL printf
>SYSCALL puts
ldx #K.ARPCACHE.SIZE
@ -222,7 +222,7 @@ CS.END
LIBTCPIP .AZ "libtcpip.o"
SSCANF.IP .AZ "%d.%d.%d.%d"
SSCANF.MAC .AZ "%h:%h:%h:%h:%h:%h"
MSG0 .AZ "STS TTL MAC Address IP Address\r\n"
MSG0 .AZ "STS TTL MAC Address IP Address"
MSG1 .AZ "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\r\n"
MSG2 .AZ "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\r\n"
hLIBTCPIP .BS 1

View File

@ -305,7 +305,6 @@ FIO.ReadFromFile
adc #SRC.hFILES-1
tay
lda (pData),y
>PUSHA
>SYSCALL FRead
bcs .9

View File

@ -42,7 +42,7 @@ MAC.Quit >LDA.G MAC.hCtxBuf
.1 >LDA.G MAC.hCtxList
beq .2
>SYSCALL SListFree.A
>SYSCALL SListFree
.2 >LDA.G MAC.hMacroBuf
beq .3
@ -51,7 +51,7 @@ MAC.Quit >LDA.G MAC.hCtxBuf
.3 >LDA.G MAC.hMacroList
beq .8
>SYSCALL SListFree.A
>SYSCALL SListFree
.8 clc
rts

View File

@ -66,7 +66,7 @@ SYM.Quit >LDA.G SYM.hLookupBuf
>SYSCALL FreeMem
.3 >LDA.G SYM.hGlobalList
beq .8
>SYSCALL SListFree.A
>SYSCALL SListFree
.8 clc
rts

View File

@ -4,7 +4,7 @@ AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/BIN/DEV/ASM
.TF BIN/DEV/ASM
*---------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I

View File

@ -135,7 +135,6 @@ CS.RUN >SYSCALL GetChar
>PUSHW ZPBufPtr
>PUSHWI 256
pla
>PUSHA
>SYSCALL FRead
bcc CS.RUN.PRINT

View File

@ -429,7 +429,7 @@ SaveFile >PUSHWI 0 Aux type
pla
pha
>PUSHA
>SYSCALL FWrite
bcc .1

View File

@ -87,9 +87,9 @@ CS.RUN >LDYA L.MSG0
>SYSCALL GetDevStatus
>LEA.G DCB.NIC
>STYA IOCTL+S.IOCTL.BUFPTR
lda S.IOCTL.STATCODE.GETDCB
sta S.IOCTL.STATCODE
>STYA.G IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETDCB
>STA.G IOCTL+S.IOCTL.STATCODE
>PUSHEA.G IOCTL
>PUSHBI IOCTL.STATUS
@ -99,11 +99,14 @@ CS.RUN >LDYA L.MSG0
CS.RUN.DUMP >LDYA L.MSG0.L
>SYSCALL printf
ldy #5
ldy #DCB.NIC+S.DCB.NIC.MAC+5
ldx #6
.1 >PUSHB DCB.NIC+S.DCB.NIC.MAC,y
.1 lda (pData),y
>PUSHA
dey
bpl .1
dex
bne .1
>PUSHEA.G DIB+S.DIB.IDS
@ -142,18 +145,19 @@ CS.RUN.DUMP >LDYA L.MSG0.L
>LDYA L.MSG1.DEV.IP
>SYSCALL printf
>LDYA L.MSG1.LINK
>SYSCALL printf
lda DCB.NIC+S.DCB.NIC.LINK
and #S.DCB.NIC.LINK.OK
bne CS.RUN.LINK
>PUSHW L.MSG1.LINK.KO
>LDYA L.MSG1.LINK
>SYSCALL printf
>LDYA L.MSG1.LINK.KO
>SYSCALL puts
bra CS.RUN.DUMPIP
CS.RUN.LINK >PUSHW L.MSG1.LINK.OK
>LDYA L.MSG1.LINK
>SYSCALL printf
CS.RUN.LINK >LDYA L.MSG1.LINK.OK
>SYSCALL puts
>LDYA L.MSG1.LINKSPEED
>SYSCALL printf
@ -177,7 +181,7 @@ CS.RUN.LINK >PUSHW L.MSG1.LINK.OK
bra .6
.5 >LDYA L.MSG1.DPLX.FD
.6 >SYSCALL printf
.6 >SYSCALL puts
CS.RUN.DUMPIP >LDYA L.MSG2
>SYSCALL printf
@ -190,7 +194,7 @@ CS.RUN.DUMPIP >LDYA L.MSG2
.11 >LDYA L.MSG2.U
.10 >SYSCALL printf
.10 >SYSCALL puts
ldy #S.IPCFG.DHCPSRVR+3
ldx #4
@ -275,16 +279,16 @@ MSG1.DEV .AS "\r\nDevice Configuration :\r\n"
.AZ " HW Address : %02h:%02h:%02h:%02h:%02h:%02h\r\n"
MSG1.DEV.ARP .AZ " ARP Offload : %d\r\n"
MSG1.DEV.IP .AZ " IP Offload : %d\r\n"
MSG1.LINK .AZ " Link Status : %s\r\n"
MSG1.LINK .AZ " Link Status : "
MSG1.LINK.OK .AZ "OK"
MSG1.LINK.KO .AZ "Media Disconnected"
MSG1.LINKSPEED .AZ " Link Speed : 1"
MSG1.DPLX.FD .AZ " Mbit/s,Full Duplex\r\n"
MSG1.DPLX.HD .AZ " Mbit/s,Half Duplex\r\n"
MSG1.DPLX.FD .AZ " Mbit/s,Full Duplex"
MSG1.DPLX.HD .AZ " Mbit/s,Half Duplex"
*--------------------------------------
MSG2 .AZ "\r\nIP Configuration : "
MSG2.C .AZ "Configured\r\n"
MSG2.U .AZ "Not Configured\r\n"
MSG2.C .AZ "Configured"
MSG2.U .AZ "Not Configured"
MSG2.DHCPSRVR .AZ " DHCP Server : %d.%d.%d.%d\r\n"
MSG2.IP .AZ " IP/Mask : %d.%d.%d.%d/%d.%d.%d.%d\r\n"
MSG2.GW .AZ " Gateway : %d.%d.%d.%d\r\n"

View File

@ -158,7 +158,7 @@ CS.RUN.FILE >LDA.G Arg
.1 >PUSHW ZPDataBufPtr Dst Ptr
>PUSHWI FILEBUF.SIZE Bytes To Read
>PUSHB.G hFile
>LDA.G hFile
>SYSCALL FRead
bcc .2

View File

@ -49,7 +49,7 @@ CS.RUN >LDYA L.MemStat
>SYSCALL GetMemStat
>LDYA L.MSG.Main
>SYSCALL printf
>SYSCALL puts
lda MemStat+S.MSTAT.MF
sec
@ -67,7 +67,7 @@ CS.RUN >LDYA L.MemStat
>SYSCALL printf
*--------------------------------------
>LDYA L.MSG.Aux
>SYSCALL printf
>SYSCALL puts
lda MemStat+S.MSTAT.XF
sec
@ -85,7 +85,7 @@ CS.RUN >LDYA L.MemStat
>SYSCALL printf
*--------------------------------------
>LDYA L.MSG.Kernel
>SYSCALL printf
>SYSCALL puts
lda MemStat+S.MSTAT.DH
sec
@ -103,7 +103,7 @@ CS.RUN >LDYA L.MemStat
>SYSCALL printf
>LDYA L.MSG.End
>SYSCALL printf
>SYSCALL puts
lda #0
sec
rts
@ -115,11 +115,14 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG.Main .AZ "--- Main Memory ---------------\r\n"
MSG.Aux .AZ "--- Aux Memory ----------------\r\n"
MSG.Kernel .AZ "--- Kernel (Drivers) Memory ---\r\n"
MSG.Stat .AZ " Low : $%H\r\n Free Ptr : $%H\r\n High : $%H\r\n Available Memory : %05D Bytes\r\n"
MSG.End .AZ "-------------------------------\r\n"
MSG.Main .AZ "--- Main Memory ---------------"
MSG.Aux .AZ "--- Aux Memory ----------------"
MSG.Kernel .AZ "--- Kernel (Drivers) Memory ---"
MSG.Stat .AS " Low : $%H\r\n"
.AS " Free Ptr : $%H\r\n"
.AS " High : $%H\r\n"
.AZ " Available Memory : %05D Bytes\r\n"
MSG.End .AZ "-------------------------------"
MemStat .BS S.MSTAT
*--------------------------------------
.DUMMY

View File

@ -47,7 +47,8 @@ L.MSG5 .DA MSG5
L.MSG.FREE .DA MSG.FREE
.DA 0
*--------------------------------------
CS.INIT >INC.G MEM.COUNT Skip SLOT0
CS.INIT lda #1
>STA.G MEM.COUNT Skip SLOT0
>LEA.G MemStat
>SYSCALL GetMemStat
@ -90,7 +91,7 @@ CS.RUN >SYSCALL GetChar
bne .1
>LDYA L.MSG0
>SYSCALL printf
>SYSCALL puts
.1 >LDA.G MEM.COUNT
>SYSCALL GetMemByID
@ -282,7 +283,7 @@ CS.QUIT clc
rts
*--------------------------------------
CS.END
MSG0 .AZ " # Flags PID REF PTR LEN BINPATH/DATA\r\n"
MSG0 .AZ " # Flags PID REF PTR LEN BINPATH/DATA"
MSG1.INV .AZ "\e[7m"
MSG1 .AZ "%03d %s %03d %03d $%H %05D "
MSG1.BIN .AZ "{%s}\e[0m\r\n"

211
BIN/TELNET.S.txt Normal file
View File

@ -0,0 +1,211 @@
NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/TELNET
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
TIMEOUT.MAX .EQ 20 2 sec.
*--------------------------------------
ZPFrameBase .EQ ZPBIN
ZPFrameLen .EQ ZPBIN+2
ZPFramePtr1 .EQ ZPBIN+4
ZPIPCfgPtr .EQ ZPBIN+6
*--------------------------------------
* 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 #16 SS
.DA #8 ZP
.DA 0
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.Socket .DA Socket
L.MSG.IPKO .DA MSG.IPKO
L.MSG.USAGE .DA MSG.USAGE
L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.HOSTOK .DA MSG.HOSTOK
L.MSG.SKTKO .DA MSG.SKTKO
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 rts
*--------------------------------------
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr) Configured ?
bmi CS.RUN.IPOK
>LDYA L.MSG.IPKO
>SYSCALL printf
lda #K.E.SYN
sec
rts
CS.RUN.IPOK ldy #S.PS.ARGC
lda (pPs),y
beq .9
jsr Init.Timeout
.2 >PUSHW pData DST.IP
lda #1
>SYSCALL GetArg
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc CS.RUN.HOSTOK
>SLEEP
jsr Wait.Timeout
bcc .2
lda #1
>SYSCALL GetArg
>PUSHYA
>LDYA L.MSG.UNKNOWN
bra .99
.9 >LDYA L.MSG.USAGE
.99 >SYSCALL printf
lda #K.E.SYN
sec
rts
CS.RUN.HOSTOK lda #1
>SYSCALL GetArg
>PUSHYA
ldy #DST.IP+3
ldx #3
.1 lda (pData),y
sta Socket.Dst.Addr,x
>PUSHA
dey
dex
bpl .1
>LDYA L.MSG.HOSTOK
>SYSCALL printf
CS.RUN.OPENSKT ldx #3
ldy #S.IPCFG.IP+3
.1 lda (ZPIPCfgPtr),y
sta Socket.Src.Addr,x
dey
dex
bpl .1
>PUSHW L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.New
bcc .2
>LDYA L.MSG.SKTKO
>SYSCALL printf
lda #K.E.SYN
sec
rts
.2 txa
ldy #hSocket
sta (pData),y
.9 lda #0
sec
CS.RUN.ERR rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
ldy #TimeOut
lda (pData),y
beq .9
dec
sta (pData),y
.9 sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT ldy #hSocket
lda (pData),y
beq .1
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
.1 lda hLIBTCPIP
>SYSCALL UnloadLib
clc
rts
*--------------------------------------
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
clc
.9 rts
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip.o"
MSG.IPKO .AZ "TCP/IP Not Loaded/Configured.\r\n"
MSG.USAGE .AZ "Usage : TELNET <ip|host> [port]\r\n"
MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d (%s) ...\r\n"
MSG.SKTKO .AZ "Failed to Open Socket.\r\n"
hLIBTCPIP .BS 1
TimeOut.ms .BS 2
Socket .DA #S.SOCKET.SOCK.STREAM
.BS 1
.DA #S.IP.PROTOCOL.TCP
.BS 1
Socket.Src.Addr .BS 4
Socket.Src.Port .DA 0 Dynamic
Socket.Dst.Addr .BS 4
Socket.Dst.Port .DA TCP.PORT.TELNET
*--------------------------------------
.DUMMY
.OR 0
DS.START
DST.IP .BS 4
hSocket .BS 1
TimeOut .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/TELNET.S
ASM

View File

@ -622,8 +622,7 @@ CS.RUN.Copy stz .90+1
>PUSHW ZPPtr1 Dst Ptr
>PUSHWI X.COPY.BUF.SIZE Bytes To Read
ldy #hSrcFile
>PUSHB (pData),y
>LDA.G hSrcFile
>SYSCALL FRead
bcc .1
cmp #MLI.E.EOF
@ -635,8 +634,7 @@ CS.RUN.Copy stz .90+1
>PUSHW ZPPtr1 Src Ptr
>PUSHW ZPPtr2 Bytes To Write
ldy #hDstFile
>PUSHB (pData),y
>LDA.G hDstFile
>SYSCALL FWrite
bcs .9

View File

@ -252,7 +252,6 @@ CS.RUN lda #S.BM.F.BBP1
>PUSHEA.G PIX.Header
>PUSHWI S.BM
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
bcs CS.RUN.RTS
@ -290,7 +289,6 @@ CS.RUN.LOOP inc ZPLineCount
>PUSHW ZPBufPtr
>PUSHW ZPPIXRowBytes
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
bcs CS.RUN.RTS

View File

@ -2,6 +2,6 @@ NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
# put your IP address and your hostname and aliases below
# 1.2.3.4 myserver.mydomain myserver
1.2.3.4 myserver.mydomain myserver
MAN
TEXT ETC/HOSTS

View File

@ -703,7 +703,6 @@ CS.RUN.WriteByte
>PUSHW ZPOutPutBufPtr
>PUSHWI 256
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
bcs .9
@ -726,7 +725,6 @@ CS.RUN.FlushOutPutBuf
lda #0
>PUSHYA
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
.8 rts
@ -754,7 +752,6 @@ CS.RUN.WriteBMAndTbl
>PUSHYA
>PUSHWI S.FON
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
bcs .9
@ -774,7 +771,6 @@ CS.RUN.WriteBMAndTbl
ply
>PUSHYA
>LDA.G hOutputFile
>PUSHA
>SYSCALL FWrite
clc

View File

@ -68,6 +68,8 @@ ERR.DEV .EQ $B3
UDP.PORT.DNS .EQ 53
UDP.PORT.PMAP .EQ 111
*--------------------------------------
TCP.PORT.TELNET .EQ 23
*--------------------------------------
S.IPCFG.STATUS .EQ 0
S.IPCFG.STATUS.OFF .EQ %00000000 TCPIP Unconfigured
S.IPCFG.STATUS.SDISC .EQ %00000001 DISCOVERY Sent
@ -83,8 +85,8 @@ S.IPCFG.MASK .EQ 16
S.IPCFG.GW .EQ 20
S.IPCFG.DNS1 .EQ 24
S.IPCFG.DNS2 .EQ 28
S.IPCFG.HOSTNAME .EQ 32 1+15 char PSTR
S.IPCFG.DOMAIN .EQ 48 1+79 char PSTR
S.IPCFG.HOSTNAME .EQ 32 15+\0 C String
S.IPCFG.DOMAIN .EQ 48 79+\0 C String
*
S.IPCFG .EQ 128
*--------------------------------------

View File

@ -231,7 +231,6 @@ CS.RUN.Save >PUSHWI 0 AUXTYPE
pla
pha
>PUSHA
>SYSCALL FWrite
bcc .1

View File

@ -13,22 +13,22 @@ CFG.Read >PUSHW L.HOSTNAME
lda IPCFG+S.IPCFG.HOSTNAME
bne .4
ldy DefaultHostName
ldy #$ff
.2 lda DefaultHostName,y
.2 iny
lda DefaultHostName,y
sta IPCFG+S.IPCFG.HOSTNAME,y
dey
bpl .2
bne .2
.3 lda A2osX.TIMER16
jsr CFG.A2CharAX
sta IPCFG+S.IPCFG.HOSTNAME+7
stx IPCFG+S.IPCFG.HOSTNAME+8
sta IPCFG+S.IPCFG.HOSTNAME+6
stx IPCFG+S.IPCFG.HOSTNAME+7
lda A2osX.TIMER16+1
jsr CFG.A2CharAX
sta IPCFG+S.IPCFG.HOSTNAME+9
stx IPCFG+S.IPCFG.HOSTNAME+10
sta IPCFG+S.IPCFG.HOSTNAME+8
stx IPCFG+S.IPCFG.HOSTNAME+9
.4 >PUSHW L.TCPIP.CONF
>LDYA L.MSG.CFG
@ -71,12 +71,13 @@ CFG.Read.HOSTNAME
cmp #13
beq .8 A CR, end of name
iny
sta IPCFG+S.IPCFG.HOSTNAME,y
iny
dex
bne .2
.8 sty IPCFG+S.IPCFG.HOSTNAME
.8 lda #0
sta IPCFG+S.IPCFG.HOSTNAME,y
jsr CFG.Read.CleanUp
clc

View File

@ -138,7 +138,7 @@ MSG.CFG.OK .AZ "OK.\r\n"
HOSTNAME .AZ "${A2OSX}ETC/HOSTNAME"
TCPIP.CONF .AZ "${A2OSX}ETC/TCPIP.CONF"
HOSTS .AZ "${A2OSX}ETC/HOSTS"
DefaultHostName >PSTR "a2osx-XXXX"
DefaultHostName .AZ "a2osx-XXXX"
CFG.Keywords >PSTR "DOMAIN"
>PSTR "IP"
>PSTR "MASK"

View File

@ -1,8 +1,6 @@
PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
@ -10,6 +8,7 @@ AUTO 6
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
TIMEOUT.MAX .EQ 30 30 sec.
@ -175,7 +174,7 @@ CS.RUN.CLIENT ldy #SktIndex
sta .1+1 hSocket
sta .3+1
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetC.A
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.GetC
bcc .10
tax
@ -283,7 +282,7 @@ Socket .DA #S.SOCKET.SOCK.STREAM
.DA #S.SOCKET.TCP.STATUS.LISTEN
.BS 1
Socket.Src.Addr .BS 4
Socket.Src.Port .DA 23
Socket.Src.Port .DA TCP.PORT.TELNET
Socket.Dst.Addr .BS 4
Socket.Dst.Port .BS 2
*--------------------------------------

View File

@ -58,7 +58,7 @@ K.LoadFile clc
>PUSHW FIO.Mem
>PUSHW FIO.FSize
>PUSHB FIO.hFile
lda FIO.hFile
jsr K.FRead
bcs .98

View File

@ -115,29 +115,6 @@ IO.Read.I lda (pFD) #S.FD.T
K.Read.9 >RET 4
*--------------------------------------
IO.READ.REG
clc
rts
*--------------------------------------
IO.READ.CDEV ldy #S.FD.DEV.DRVPTR
lda (pFD),y
sta .1+1
iny
lda (pFD),y
sta .1+2
>LDYAI K.S.IOCTL
ldx #IOCTL.READ
.1 jmp $ffff
*--------------------------------------
IO.READ.SSOCK
*--------------------------------------
IO.READ.FIFO
clc
rts
*--------------------------------------
* int write(int fd, const void *buf, size_t count);
*--------------------------------------
K.Write jsr IO.SELECT
@ -161,14 +138,25 @@ IO.Write.I lda (pFD) #S.FD.T
K.Write.9 >RET 4
*--------------------------------------
IO.WRITE.REG >PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
IO.READ.REG clc
.HS B0 BCS
*--------------------------------------
IO.WRITE.REG sec
>PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
>PUSHW K.S.IOCTL+S.IOCTL.BYTECNT
ldy #S.FD.REG.REF
>PUSHB (pFD),y
jmp K.FWrite
lda (pFD),y
bcs .1
jmp K.FRead
.1 jmp K.FWrite
*--------------------------------------
IO.WRITE.CDEV ldy #S.FD.DEV.DRVPTR
IO.READ.CDEV ldx #IOCTL.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.CDEV ldx #IOCTL.WRITE
ldy #S.FD.DEV.DRVPTR
lda (pFD),y
sta .1+1
iny
@ -176,10 +164,18 @@ IO.WRITE.CDEV ldy #S.FD.DEV.DRVPTR
sta .1+2
>LDYAI K.S.IOCTL
ldx #IOCTL.WRITE
.1 jmp $ffff
*--------------------------------------
IO.WRITE.SSOCK lda (pFD) #S.FD.HANDLER
IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE
.HS 2C BIT ABS
*--------------------------------------
IO.READ.SSOCK ldy #S.FD.SSOCK.READ
lda (pFD),y
tax Function Offset in LIB
ldy #S.FD.HANDLER
lda (pFD),y
jsr K.GetMemPtr
>STYA .1
@ -187,11 +183,13 @@ IO.WRITE.SSOCK lda (pFD) #S.FD.HANDLER
>PUSHB (pFD),y
>PUSHB K.IOBuf
ldy #S.FD.SSOCK.WRITE
lda (pFD),y
tax Function Offset for write
.1 jmp $ffff
*--------------------------------------
IO.READ.FIFO
clc
rts
*--------------------------------------
IO.WRITE.FIFO ldy #S.FD.FIFO.S
lda (pFD),y
beq .9 Remote PS did not opened yet the pipe

View File

@ -894,7 +894,7 @@ K.FOpen.AUXTYPE .BS 2
* # FClose
* Close a file
* ## C
* int fclose ( FILE * stream );
* int fclose ( hFILE streamm );
* ## ASM
* **In:**
* A = hFILE
@ -923,35 +923,36 @@ K.FClose jsr PFT.CheckNodeA
.9 rts
*/--------------------------------------
* # FRead
* int fread ( void * ptr, int count, FILE * stream );
* int fread (hFILE stream, void * ptr, int count );
* Read bytes from file
* **In:**
* PUSHW = Dest Ptr
* PUSHW = Bytes To Read
* PUSHB = hFILE
* `>PUSHWI count`
* `>PUSHW ptr`
* `lda hFILE`
* `>SYSCALL fread`
* **Out:**
* Y,A = Bytes Read
*\--------------------------------------
K.FRead jsr PFT.CheckNodeSTK
K.FRead jsr PFT.CheckNodeA
ldx #MLIREAD
bra K.FReadWrite.1
*/--------------------------------------
* # FWrite
* Write bytes to file
* ## C
* `int fwrite ( const void * ptr, int count, hFILE stream );`
* `int fwrite (hFILE stream, const void * ptr, int count );`
* ## ASM
* **In:**
* `>PUSHB = hFILE`
* `>PUSHWI ptr`
* `>LDYA count`
* `>PUSHWI count`
* `>PUSHW ptr`
* `lda hFILE`
* `>SYSCALL fwrite`
* # Out:
* Y,A = Bytes Written
*\--------------------------------------
K.FWrite jsr PFT.CheckNodeSTK
K.FWrite jsr PFT.CheckNodeA
ldx #MLIWRITE
K.FReadWrite.1 >PULLA
jsr STDIO.GetRefNum
K.FReadWrite.1 jsr STDIO.GetRefNum
>PULLW K.MLI.PARAMS+4
>PULLW K.MLI.PARAMS+2