A2osX/SYS/KERNEL.S.DEV.txt
Rémy GIBERT bae3f91aab 0.9
2017-01-12 18:43:45 +01:00

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
NEW
INC 1
AUTO 6
.LIST OFF
*/--------------------------------------
* #GetDevByIDA
* ##IN:
* A = DevID
* ##OUT:
* CC = OK, CS = ERROR
* Y,A = DEVSLOT
* note: X Unmodified
*\--------------------------------------
K.GetDevByIDA cmp DevMgr.Count
bcs K.GetDevDNF
pha save ID
asl
asl
asl
adc #DevMgr.Table
tay
pla
php
lsr
lsr
lsr
plp
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.F
>STYA ZPPtr2
ldx #0
.1 lda (ZPPtr2)
and #S.DEV.F.LEN
cmp (ZPPtr1)
bne .3
tay
.2 lda (ZPPtr1),y
cmp (ZPPtr2),y
bne .3
dey
bne .2
lda ZPPtr2
sec
sbc #S.DEV.F
tay
lda ZPPtr2+1
sbc /S.DEV.F
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 S.FILE 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
lda (pDev)
sta .2+1
sta .4+1
ldy #1
lda (pDev),y
sta .3+1
sta .4+2
txa Pass DEV.ID to OPEN
ldx #DEVMGR.OPEN
jsr .4
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
iny #S.NODE.DEV.ID
.1 lda #$ff Self Modified
sta (ZPPtr3),y
iny #S.NODE.DEV.JMP
.2 lda #$ff
sta (ZPPtr3),y
iny ##S.NODE.DEV.JMP+1
.3 lda #$ff
sta (ZPPtr3),y
txa
clc
.9 rts
.99 lda #MLI.ERR.IO
sec
rts
.4 jmp $ffff
*/--------------------------------------
* #MkNodA
* return a S.FILE for a given Socket
* ##IN:
* A=hSocket
* ##OUT:
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MkNodA sec
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
phx 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
pla
sta (ZPPtr1),y
txa
clc
rts
.9 plx get back FIFO buffer
pha save error code
txa
jsr K.FreeMemA
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DEV
LOAD SYS/KERNEL.S
ASM