A2osX/SYS/KERNEL.S.DEV.txt

223 lines
3.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* #GetDevByIDA
* ##IN:
* A = DevID
* ##OUT:
* CC = OK, CS = ERROR
* Y,A = DEVSLOT
* note: X Unmodified
*\--------------------------------------
K.GetDevByIDA cmp DevMgr.Count
bcs K.GetDevDNF
asl
asl
asl
asl
php
clc
adc #DevMgr.Table
tay
plp
lda #0
adc /DevMgr.Table
rts CC
*/--------------------------------------
* #GetDevByNameYA
* ##IN:
* Y,A = Ptr to device name (PStr)
* ##OUT:
* CC = OK, CS = ERROR
* X = DEVID
* Y,A = DEVSLOT
*\--------------------------------------
K.GetDevByNameYA
>STYA ZPPtr1
>LDYAI DevMgr.Table+S.DEV.NAME
>STYA ZPPtr2
ldx #0
.1 lda (ZPPtr2)
cmp (ZPPtr1)
bne .3
tay
.2 lda (ZPPtr1),y
cmp (ZPPtr2),y
bne .3
dey
bne .2
lda ZPPtr2
sec
sbc #S.DEV.NAME
tay
lda ZPPtr2+1
sbc /S.DEV.NAME
clc
rts
.3 lda ZPPtr2
clc
adc #S.DEV
sta ZPPtr2
bcc .4
inc ZPPtr2+1
.4 inx
cpx DevMgr.Count
bne .1
K.GetDevDNF lda #MLI.ERR.NODEV CS from cpx/beq
rts
*/--------------------------------------
* #GetDevStatusA
* ##IN:
* A = DevID
* ##OUT:
* CC = OK, CS = ERROR
* Y,A = Ptr to S.DEVINFO
*\--------------------------------------
K.GetDevStatusA jsr K.GetDevByIDA
bcs K.GetDevDNF
>STYA ZPPtr1
ldx #DEVMGR.STATUS
jmp (ZPPtr1)
*/--------------------------------------
* #MkNodYA
* return a hFile for a given Device Name
* ##IN:
* Y,A=DevName
* ##OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MkNodYA jsr K.GetDevByNameYA Ptr1=NAME
bcs .9
>STYA pDev
stx .1+1
ldy #S.DEV.S
lda (pDev),y
bit #S.DEV.S.BLOCK
bne .99
txa Pass DEV.ID to OPEN
ldx #DEVMGR.OPEN
jsr pDevJmp
bcs .9
>PUSHWI S.NODE.DEV
>PUSHBI S.MEM.F.INIT0
jsr K.GetMem
bcs .9
>STYA ZPPtr3 Ptr3=S.NODE
ldy #S.NODE.T
lda #S.NODE.T.CDEV
sta (ZPPtr3),y
ldy #S.NODE.DEV.ID
.1 lda #$ff Self Modified
sta (ZPPtr3),y
ldy #S.NODE.DEV.JMP
lda pDev
sta (ZPPtr3),y
iny
lda pDev+1
sta (ZPPtr3),y
txa
clc
.9 rts
.99 lda #MLI.ERR.IO
sec
rts
*/--------------------------------------
* #MkNodA
* return a hFile for a given Socket
* ##IN:
* A=hSocket
* ##OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MkNodA sta .1+1
>PUSHWI S.NODE.SSOCK
>PUSHBI S.MEM.F.INIT0
jsr K.GetMem
bcs .9
>STYA ZPPtr1
ldy #S.NODE.T
lda #S.NODE.T.SSOCK
sta (ZPPtr1),y
ldy #S.NODE.SSOCK.HSKT
.1 lda #$ff
sta (ZPPtr1),y
txa
.9 rts
*/--------------------------------------
* #MKFIFO
* return a S.FILE to a new FIFO
* ##IN:
* ##OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MKFIFO >PUSHWI 256
>PUSHBI 0
jsr K.GetMem
bcs .99
stx .1+1 save FIFO buffer
>PUSHWI S.NODE.FIFO
>PUSHBI S.MEM.F.INIT0
jsr K.GetMem
bcs .9
>STYA ZPPtr1
ldy #S.NODE.T
lda #S.NODE.T.FIFO
sta (ZPPtr1),y
iny S.NODE.FIFO.hMem
.1 lda #$ff Self Modified
sta (ZPPtr1),y
txa
clc
rts
.9 pha save error code
lda .1+1 get back FIFO buffer
jsr K.FreeMemA
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DEV
LOAD SYS/KERNEL.S
ASM