Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-06-19 17:08:22 +02:00
parent b7a46da3a6
commit 0128a9cfd9
6 changed files with 138 additions and 120 deletions

View File

@ -420,8 +420,8 @@ Print A (char) to hFILE
## ASM
**In:**
Y : character
A : stream
A : character
Y : stream
**Out:**
CC = success
@ -443,7 +443,7 @@ Write Str to StdOut, appends '\r\n'
## C
`int puts ( const char * str );`
**In:**
Y,A : CPtr
Y,A : str
**Out:**
CC = success
@ -604,12 +604,16 @@ Read bytes from file
Y,A = Bytes Read
# FWrite
int fwrite ( const void * ptr, int count, FILE * stream );
Write bytes to file
## C
`int fwrite ( const void * ptr, int count, hFILE stream );`
## ASM
**In:**
PUSHW = Src Ptr
PUSHW = Bytes To Write
PUSHB = hFILE
`>PUSHB = hFILE`
`>PUSHWI ptr`
`>LDYA count`
# Out:
Y,A = Bytes Written
@ -741,11 +745,12 @@ CS : A = Error Code
Returns Length of C-String
## C
`char * strcat ( char * destination, const char * source );`
`int strlen ( char * str);`
## ASM
**In:**
Y,A = Ptr to CSTR
`>LDYAI str`
`>SYSCALL strlen`
**Out:**
Y,A = String length

View File

@ -277,57 +277,6 @@ S.MSTAT.DCount .EQ 22
*
S.MSTAT .EQ 24
*--------------------------------------
* S.NODE
*--------------------------------------
S.NODE.HANDLER .EQ 0 0=KRNL,!0=hLIB (LIBNFS,LIBTCPIP.....)
S.NODE.T .EQ 1
S.NODE.T.REG .EQ 0
S.NODE.T.DIR .EQ 1
S.NODE.T.CDEV .EQ 2
S.NODE.T.BDEV .EQ 3
S.NODE.T.LNK .EQ 4
S.NODE.T.DSOCK .EQ 5
S.NODE.T.SSOCK .EQ 6
S.NODE.T.FIFO .EQ 7
*--------------------------------------
S.NODE.REG.REF .EQ 2
S.NODE.REG.IOBUF .EQ 3
*
S.NODE.REG .EQ 4
*--------------------------------------
S.NODE.DIR.REF .EQ 2
S.NODE.DIR.IOBUF .EQ 3
S.NODE.DIR.EL .EQ 4
S.NODE.DIR.EPB .EQ 5
S.NODE.DIR.FC .EQ 6 word
*
S.NODE.DIR .EQ 8
*--------------------------------------
S.NODE.DEV.ID .EQ 2
S.NODE.DEV.JMP .EQ 3 word
*
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 .EQ 8
*--------------------------------------
S.NODE.FIFO.S .EQ 2
S.NODE.FIFO.S.Opened .EQ 1
S.NODE.FIFO.S.Closed .EQ 2
S.NODE.FIFO.hMem .EQ 3
S.NODE.FIFO.Tail .EQ 4
S.NODE.FIFO.Head .EQ 5
*
S.NODE.FIFO .EQ 6
*--------------------------------------
* DEVMGR (new API) = Smartport
*--------------------------------------
* JMP : (A=Device)
@ -366,6 +315,17 @@ IOCTL.READ .EQ 16
IOCTL.WRITE .EQ 18
IOCTL.IRQ .EQ 20
*--------------------------------------
S.IOCTL.CNT .EQ 0
S.IOCTL.UNITNUM .EQ 1
S.IOCTL.BUFPTR .EQ 2
S.IOCTL.STATCODE .EQ 4 1 BYTE
S.IOCTL.CTRLCODE .EQ 4 1 BYTE
S.IOCTL.BLKNUM .EQ 4 3 BYTES
S.IOCTL.BYTECNT .EQ 4 2 BYTES
S.IOCTL.ADDRPTR .EQ 6 3 BYTES
*
S.IOCTRL .EQ 9
*--------------------------------------
S.DSTAT.S .EQ 0
S.DSTAT.S.BLOCK .EQ %10000000
S.DSTAT.S.WRITE .EQ %01000000
@ -408,6 +368,57 @@ S.DSTAT.VERSION .EQ 23
*
S.DSTAT .EQ 25
*--------------------------------------
* S.NODE
*--------------------------------------
S.NODE.T .EQ 0
S.NODE.T.REG .EQ 0
S.NODE.T.DIR .EQ 2
S.NODE.T.CDEV .EQ 4
S.NODE.T.BDEV .EQ 6
S.NODE.T.LNK .EQ 8
S.NODE.T.DSOCK .EQ 10
S.NODE.T.SSOCK .EQ 12
S.NODE.T.FIFO .EQ 14
S.NODE.HANDLER .EQ 1 0=KRNL,!0=hLIB (LIBNFS,LIBTCPIP.....)
*--------------------------------------
S.NODE.REG.REF .EQ 2
S.NODE.REG.IOBUF .EQ 3
*
S.NODE.REG .EQ 4
*--------------------------------------
S.NODE.DIR.REF .EQ 2
S.NODE.DIR.IOBUF .EQ 3
S.NODE.DIR.EL .EQ 4
S.NODE.DIR.EPB .EQ 5
S.NODE.DIR.FC .EQ 6 word
*
S.NODE.DIR .EQ 8
*--------------------------------------
S.NODE.DEV.ID .EQ 2
S.NODE.DEV.JMP .EQ 3 word
*
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 .EQ 8
*--------------------------------------
S.NODE.FIFO.S .EQ 2
S.NODE.FIFO.S.Opened .EQ 1
S.NODE.FIFO.S.Closed .EQ 2
S.NODE.FIFO.hMem .EQ 3
S.NODE.FIFO.Tail .EQ 4
S.NODE.FIFO.Head .EQ 5
*
S.NODE.FIFO .EQ 6
*--------------------------------------
* PS STRUCT
*--------------------------------------
S.PS.F .EQ 0

View File

@ -35,7 +35,7 @@ H.BIN.DRV.REL.TABLE .EQ 0
ZPKERNEL .EQ $0
ZPMEMMGR .EQ $10
*--------------------------------------
* MoveAux / XFer
* AuxMove / XFer
*--------------------------------------
A1L .EQ $3C
A2L .EQ $3E
@ -98,7 +98,8 @@ A2osX.SaveSX .EQ $101 Aux
*--------------------------------------
K.S.STAT .EQ $0300 S.STAT for internal kernel operations
K.S.DSTAT .EQ $0340 S.DSTAT=25 or higher depends on dev type
K.SP.PARAMS .EQ $0360 Max 9 bytes
K.S.IOCTL .EQ $0360 9 bytes
K.SP.PARAMS .EQ $0360 9 bytes
K.MLI.PATH .EQ $0369 64+1
K.MLI.PARAMS .EQ $03AA Main, 18 bytes min for GetFileInfo (ATLK needs MORE!!!...32 max for now)
*--------------------------------------

View File

@ -2,29 +2,33 @@ NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
IO.COut ldy #S.NODE.T
lda (pNode),y
asl
IO.SELECT jsr K.GetMemPtr.A
>STYA pNode
rts
*--------------------------------------
IO
*--------------------------------------
IO.WRITE lda (pNode) #S.NODE.T
tax
*--------------------------------------
jmp (.1,x)
.1 .DA STDIO.Out.REG
.1 .DA IO.WRITE.REG
.DA STDIO.IOERR DIR
.DA STDIO.Out.CDEV
.DA IO.WRITE.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA STDIO.Out.SSOCK
.DA STDIO.Out.FIFO
.DA IO.WRITE.SSOCK
.DA IO.WRITE.FIFO
*--------------------------------------
IO.COut.REG >PUSHW pIOBuf
>PUSHW STDIO.Out.Cnt
IO.WRITE.REG >PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
>PUSHW K.S.IOCTL+S.IOCTL.BYTECNT
ldy #S.NODE.REG.REF
>PUSHB (pNode),y
jmp K.FWrite
*--------------------------------------
IO.COut.CDEV ldy #S.NODE.DEV.JMP
IO.WRITE.CDEV ldy #S.NODE.DEV.JMP
lda (pNode),y
sta .1+1
iny
@ -35,7 +39,7 @@ IO.COut.CDEV ldy #S.NODE.DEV.JMP
ldx #IOCTL.WRITE
.1 jmp $ffff
*--------------------------------------
IO.COut.SSOCK lda (pNode) #S.NODE.HANDLER
IO.WRITE.SSOCK lda (pNode) #S.NODE.HANDLER
jsr K.GetMemPtr.A
>STYA .1
@ -48,7 +52,7 @@ IO.COut.SSOCK lda (pNode) #S.NODE.HANDLER
tax Function Offset for write
.1 jmp $ffff
*--------------------------------------
IO.COut.FIFO ldy #S.NODE.FIFO.S
IO.WRITE.FIFO ldy #S.NODE.FIFO.S
lda (pNode),y
beq .9 Remote PS did not opened yet the pipe
cmp #S.NODE.FIFO.S.Closed

View File

@ -1,9 +1,6 @@
NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
STDIO.Out.pBuf .EQ K.SP.PARAMS+2
STDIO.Out.Cnt .EQ K.SP.PARAMS+4
*/--------------------------------------
* # FPutC
* Print A (char) to hFILE
@ -11,13 +8,13 @@ STDIO.Out.Cnt .EQ K.SP.PARAMS+4
* `int fputc ( int character, hFILE stream );`
* ## ASM
* **In:**
* Y : character
* A : stream
* A : character
* Y : stream
* **Out:**
* CC = success
*\--------------------------------------
K.FPutC sty K.IOBuf
K.FPutC sta K.IOBuf
tya
bra K.PutChar.1
*/--------------------------------------
* # PutChar
@ -35,36 +32,39 @@ K.PutChar sta K.IOBuf
ldy #S.PS.hStdOut
lda (pPs),y
K.PutChar.1 jsr K.GetMemPtr.A
>STYA pNode
>LDYAI K.IOBuf
>STYA pIOBuf
lda #1
sta STDIO.Out.Cnt
stz STDIO.Out.Cnt+1
jmp STDIO.Out
K.PutChar.1 jsr IO.SELECT
ldx #1
K.PutChar.X >LDYAI K.IOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
stx K.S.IOCTL+S.IOCTL.BYTECNT
stz K.S.IOCTL+S.IOCTL.BYTECNT.1
jmp IO.WRITE
*/--------------------------------------
* # PutS
* Write Str to StdOut, appends '\r\n'
* ## C
* `int puts ( const char * str );`
* **In:**
* Y,A : CPtr
* Y,A : str
* **Out:**
* CC = success
*\--------------------------------------
K.PutS >STYA pIOBuf
K.PutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR
>STYA ZPPtr1
ldy #S.PS.hStdOut
lda (pPs),y
jsr K.FPutS.1
jsr K.FPutS.I
bcs .9
lda #13
jsr K.PutChar
bcs .9
sta K.IOBuf
lda #10
jmp K.PutChar
sta K.IOBuf+1
ldx #2
bra K.PutChar.X
.9 rts
*/--------------------------------------
* # FPutS
@ -77,32 +77,28 @@ K.PutS >STYA pIOBuf
* **Out:**
* CC = success
*\--------------------------------------
K.FPutS >STYA pIOBuf
K.FPutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR
>STYA ZPPtr1
>PULLA
K.FPutS.1 jsr K.GetMemPtr.A
>STYA pNode
K.FPutS.I jsr IO.SELECT
ldy #0
ldy #0
ldx #0
lda pIOBuf+1
pha
.1 lda (pIOBuf),y
.1 lda (ZPPtr1),y
beq .2
iny
bne .1
inx
inc pIOBuf+1
inc ZPPtr1+1
bra .1
.2 pla
sta pIOBuf+1
sty STDIO.Out.Cnt
stx STDIO.Out.Cnt+1
jmp STDIO.Out
.2 sty K.S.IOCTL+S.IOCTL.BYTECNT
stx K.S.IOCTL+S.IOCTL.BYTECNT.1
jmp IO.WRITE
*/--------------------------------------
* # PrintF/SPrintF/FPrintF
* Prints C-Style String
@ -168,16 +164,14 @@ K.SPrintF >STYA pIOBuf Out Buffer
>PULLW ZPPtr1 format
bra K.PrintF.1
K.FPrintF jsr K.GetMemPtr.A A = hFILE
>STYA pNode
K.FPrintF jsr IO.SELECT A = hFILE
>PULLW ZPPtr1 format
bra K.PrintF.0
K.PrintF >STYA ZPPtr1 format
ldy #S.PS.hStdOut
lda (pPs),y
jsr K.GetMemPtr.A
>STYA pNode
jsr IO.SELECT
K.PrintF.0 >LDYAI K.IOBuf
>STYA pIOBuf
@ -973,12 +967,14 @@ K.FRead jsr PFT.CheckNodeSTK
bra K.FReadWrite.1
*/--------------------------------------
* # FWrite
* int fwrite ( const void * ptr, int count, FILE * stream );
* Write bytes to file
* ## C
* `int fwrite ( const void * ptr, int count, hFILE stream );`
* ## ASM
* **In:**
* PUSHW = Src Ptr
* PUSHW = Bytes To Write
* PUSHB = hFILE
* `>PUSHB = hFILE`
* `>PUSHWI ptr`
* `>LDYA count`
* # Out:
* Y,A = Bytes Written
*\--------------------------------------

View File

@ -5,10 +5,11 @@ AUTO 4,1
* # StrLen
* Returns Length of C-String
* ## C
* `char * strcat ( char * destination, const char * source );`
* `int strlen ( char * str);`
* ## ASM
* **In:**
* Y,A = Ptr to CSTR
* `>LDYAI str`
* `>SYSCALL strlen`
* **Out:**
* Y,A = String length
*\--------------------------------------