Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-08-27 17:26:01 +02:00
parent 2c0e0d15f7
commit 5d71a71b09
6 changed files with 145 additions and 22 deletions

View File

@ -214,10 +214,45 @@ Load a file in memory
A = hFD
note : if file is created on ProDOS : T=TXT,X=$0000
# close
## C
`int close(hFD fd);`
## ASM
**In:**
`lda fd`
`>SYSCALL close`
# read
## C
`int read(int fd, void *buf, size_t count);`
`int read(hFD fd, void *buf, int count);`
## ASM
**In:**
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL read`
**Out:**
CC: Y,A = bytes read
CS: A = EC
# write
## C
`int write(hFD fd, const void *buf, int count);`
## ASM
**In:**
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL write`
**Out:**
CC: Y,A = bytes written
CS: A = EC
# IOCTL

Binary file not shown.

Binary file not shown.

View File

@ -12,11 +12,10 @@ AUTO 4,1
.INB INC/LIBTCPIP.I
*--------------------------------------
TIMEOUT.MAX .EQ 20 2 sec.
BUFSIZE .EQ 256
*--------------------------------------
ZPFrameBase .EQ ZPBIN
ZPFrameLen .EQ ZPBIN+2
ZPFramePtr1 .EQ ZPBIN+4
ZPIPCfgPtr .EQ ZPBIN+6
ZPIPCfgPtr .EQ ZPBIN
ZPBufPtr .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -28,7 +27,7 @@ CS.START cld
.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 #2 ZP
.DA 0
*--------------------------------------
.1 .DA CS.INIT
@ -42,6 +41,7 @@ L.MSG.USAGE .DA MSG.USAGE
L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.HOSTOK .DA MSG.HOSTOK
L.MSG.SKTKO .DA MSG.SKTKO
L.MSG.SKTOK .DA MSG.SKTOK
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
@ -76,7 +76,7 @@ CS.RUN.IPOK ldy #S.PS.ARGC
jsr Init.Timeout
.2 >PUSHW pData DST.IP
.2 >PUSHEA.G DST.IP
lda #1
>SYSCALL GetArg
>PUSHYA
@ -93,6 +93,7 @@ CS.RUN.IPOK ldy #S.PS.ARGC
bra .99
.9 >LDYA L.MSG.USAGE
.99 >SYSCALL puts
lda #K.E.SYN
sec
@ -133,10 +134,60 @@ CS.RUN.OPENSKT ldx #3
>SYSCALL puts
lda #K.E.SYN
sec
rts
.9 rts
.2 txa
>STA.G hSocket
>LDYA L.MSG.SKTOK
>SYSCALL puts
>LDYAI BUFSIZE
>SYSCALL getmem
bcs .9
>STYA ZPBufPtr
txa
>STA.G hBuf
CS.RUN.LOOP >PUSHB.G hSocket
>PUSHW ZPBufPtr
>PUSHWI BUFSIZE
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Read
bcc .1
tay
beq .2 no char
rts
.1 >PUSHYA len
>PUSHW ZPBufPtr
ldy #S.PS.hStdOut
lda (pPs),y
>SYSCALL write
bcs CS.RUN.ERR
.2 >PUSHWI BUFSIZE
>PUSHW ZPBufPtr
ldy #S.PS.hStdIn
lda (pPs),y
>SYSCALL read
bcc .3
tay
beq CS.RUN.LOOP
rts
.3 phy
pha
>PUSHB.G hSocket
>PUSHW ZPBufPtr
pla
>PUSHA
pla
>PUSHA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Write
bcs CS.RUN.ERR
jmp CS.RUN.LOOP
.9 lda #0
sec
@ -161,7 +212,12 @@ CS.QUIT ldy #hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
.1 lda hLIBTCPIP
.1 >LDA.G hBuf
beq .2
>SYSCALL freemem
.2 lda hLIBTCPIP
>SYSCALL UnloadLib
clc
rts
@ -181,13 +237,14 @@ Wait.TimeOut sec
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip.o"
hLIBTCPIP .BS 1
MSG.IPKO .AZ "TCP/IP Not Loaded/Configured."
MSG.USAGE .AZ "Usage : TELNET <ip|host> [port]"
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."
hLIBTCPIP .BS 1
TimeOut.ms .BS 2
MSG.SKTOK .AZ "Connected."
*--------------------------------------
Socket .DA #S.SOCKET.SOCK.STREAM
.BS 1
.DA #S.IP.PROTOCOL.TCP
@ -201,6 +258,7 @@ Socket.Dst.Port .DA TCP.PORT.TELNET
.OR 0
DS.START
DST.IP .BS 4
hBuf .BS 1
hSocket .BS 1
TimeOut .BS 1
DS.END

View File

@ -330,13 +330,13 @@ note : '$VAR' does NOT expand Variable
| | | -1..9 : Catalog Size (block count) | |
| CHTYP | Working | -C : Continue On Error | 0.92 |
| | | -R : Recurse subdirectories | |
| MD5 | Working | -D : String Input | 0.92 |
| CHMOD | In Progress | -C : Continue On Error | 0.9 |
| | | -R : Recurse subdirectories | |
| CHOWN | In Progress | -C : Continue On Error | 0.9 |
| | | -R : Recurse subdirectories | |
| CHGRP | In Progress | -C : Continue On Error | 0.9 |
| | | -R : Recurse subdirectories | |
| MD5 | In Progress | -D : String Input | 0.92 |
| NSCUTIL | Working | Tool for setting time in NSC/DL1216E | 0.9 |
## Network (TCPIP) tools:
@ -347,6 +347,7 @@ note : '$VAR' does NOT expand Variable
| ARP | Working | dump ARP cache, setup a static ARP entry | 0.92 |
| DNSINFO | Working | dump DNS cache, setup a static DNS entry | 0.92 |
| PING | Working | | 0.92 |
| TELNET | In Progress | | 0.92 |
## DEV tools:
| Name | Status | Comment | K.Ver |
@ -354,7 +355,7 @@ note : '$VAR' does NOT expand Variable
| MEMDUMP | Working | Tool to track memory leak| 0.92 |
| ASM | In Progress | S-C MASM based multi CPU assembler | 0.9.1 |
| ---- | ------ | ------- | ----- |
| RPCDUMP | Working | tool based on UDP socket API, renamed from RPCINFO | 0.9.1 |
| RPCDUMP | In Progress | tool based on UDP socket API, renamed from RPCINFO | 0.9.1 |
## Misc

View File

@ -4,7 +4,7 @@ AUTO 4,1
*/--------------------------------------
* # open
* ## C
* `int open(const char *pathname, int flags);`
* `hFD open(const char *pathname, int flags);`
* ## ASM
* **In:**
* `>PUSHB flags`
@ -63,9 +63,15 @@ K.Open.REG >LDYAI K.MLI.PATH
* sta K.S.IOCTL
>RET 1
*--------------------------------------
* int close(short int hFD);
*--------------------------------------
*/--------------------------------------
* # close
* ## C
* `int close(hFD fd);`
* ## ASM
* **In:**
* `lda fd`
* `>SYSCALL close`
*\--------------------------------------
K.Close jsr K.GetMemPtr
bcs .9
@ -99,7 +105,16 @@ IO.CLOSE.FIFO clc
*/--------------------------------------
* # read
* ## C
* `int read(int fd, void *buf, size_t count);`
* `int read(hFD fd, void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL read`
* **Out:**
* CC: Y,A = bytes read
* CS: A = EC
*\--------------------------------------
K.Read jsr K.GetMemPtr
bcs K.Write.9
@ -121,9 +136,20 @@ IO.Read.I lda (pFD) #S.FD.T
.DA STDIO.IOERR DSOCK
.DA IO.READ.SSOCK
.DA IO.READ.FIFO
*--------------------------------------
* int write(int fd, const void *buf, size_t count);
*--------------------------------------
*/--------------------------------------
* # write
* ## C
* `int write(hFD fd, const void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL write`
* **Out:**
* CC: Y,A = bytes written
* CS: A = EC
*\--------------------------------------
K.Write jsr K.GetMemPtr
bcs K.Write.9
@ -178,7 +204,10 @@ IO.WRITE.CDEV ldx #IOCTL.WRITE
>LDYAI K.S.IOCTL
.1 jmp $ffff
.1 jsr $ffff
bcs .9
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
.9 rts
*--------------------------------------
IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE
.HS 2C BIT ABS