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

View File

@ -277,57 +277,6 @@ S.MSTAT.DCount .EQ 22
* *
S.MSTAT .EQ 24 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 * DEVMGR (new API) = Smartport
*-------------------------------------- *--------------------------------------
* JMP : (A=Device) * JMP : (A=Device)
@ -366,6 +315,17 @@ IOCTL.READ .EQ 16
IOCTL.WRITE .EQ 18 IOCTL.WRITE .EQ 18
IOCTL.IRQ .EQ 20 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 .EQ 0
S.DSTAT.S.BLOCK .EQ %10000000 S.DSTAT.S.BLOCK .EQ %10000000
S.DSTAT.S.WRITE .EQ %01000000 S.DSTAT.S.WRITE .EQ %01000000
@ -408,6 +368,57 @@ S.DSTAT.VERSION .EQ 23
* *
S.DSTAT .EQ 25 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 * PS STRUCT
*-------------------------------------- *--------------------------------------
S.PS.F .EQ 0 S.PS.F .EQ 0

View File

@ -35,7 +35,7 @@ H.BIN.DRV.REL.TABLE .EQ 0
ZPKERNEL .EQ $0 ZPKERNEL .EQ $0
ZPMEMMGR .EQ $10 ZPMEMMGR .EQ $10
*-------------------------------------- *--------------------------------------
* MoveAux / XFer * AuxMove / XFer
*-------------------------------------- *--------------------------------------
A1L .EQ $3C A1L .EQ $3C
A2L .EQ $3E 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.STAT .EQ $0300 S.STAT for internal kernel operations
K.S.DSTAT .EQ $0340 S.DSTAT=25 or higher depends on dev type 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.PATH .EQ $0369 64+1
K.MLI.PARAMS .EQ $03AA Main, 18 bytes min for GetFileInfo (ATLK needs MORE!!!...32 max for now) 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 PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
*-------------------------------------- *--------------------------------------
IO.COut ldy #S.NODE.T IO.SELECT jsr K.GetMemPtr.A
lda (pNode),y >STYA pNode
asl rts
*--------------------------------------
IO
*--------------------------------------
IO.WRITE lda (pNode) #S.NODE.T
tax tax
*-------------------------------------- *--------------------------------------
jmp (.1,x) jmp (.1,x)
.1 .DA STDIO.Out.REG .1 .DA IO.WRITE.REG
.DA STDIO.IOERR DIR .DA STDIO.IOERR DIR
.DA STDIO.Out.CDEV .DA IO.WRITE.CDEV
.DA STDIO.IOERR BDEV .DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK .DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK .DA STDIO.IOERR DSOCK
.DA STDIO.Out.SSOCK .DA IO.WRITE.SSOCK
.DA STDIO.Out.FIFO .DA IO.WRITE.FIFO
*-------------------------------------- *--------------------------------------
IO.COut.REG >PUSHW pIOBuf IO.WRITE.REG >PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
>PUSHW STDIO.Out.Cnt >PUSHW K.S.IOCTL+S.IOCTL.BYTECNT
ldy #S.NODE.REG.REF ldy #S.NODE.REG.REF
>PUSHB (pNode),y >PUSHB (pNode),y
jmp K.FWrite jmp K.FWrite
*-------------------------------------- *--------------------------------------
IO.COut.CDEV ldy #S.NODE.DEV.JMP IO.WRITE.CDEV ldy #S.NODE.DEV.JMP
lda (pNode),y lda (pNode),y
sta .1+1 sta .1+1
iny iny
@ -35,7 +39,7 @@ IO.COut.CDEV ldy #S.NODE.DEV.JMP
ldx #IOCTL.WRITE ldx #IOCTL.WRITE
.1 jmp $ffff .1 jmp $ffff
*-------------------------------------- *--------------------------------------
IO.COut.SSOCK lda (pNode) #S.NODE.HANDLER IO.WRITE.SSOCK lda (pNode) #S.NODE.HANDLER
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA .1 >STYA .1
@ -48,7 +52,7 @@ IO.COut.SSOCK lda (pNode) #S.NODE.HANDLER
tax Function Offset for write tax Function Offset for write
.1 jmp $ffff .1 jmp $ffff
*-------------------------------------- *--------------------------------------
IO.COut.FIFO ldy #S.NODE.FIFO.S IO.WRITE.FIFO ldy #S.NODE.FIFO.S
lda (pNode),y lda (pNode),y
beq .9 Remote PS did not opened yet the pipe beq .9 Remote PS did not opened yet the pipe
cmp #S.NODE.FIFO.S.Closed cmp #S.NODE.FIFO.S.Closed

View File

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

View File

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