A2osX/SYS/KERNEL.S.DEV.txt
2019-02-28 16:45:33 +00:00

174 lines
2.9 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.

NEW
PREFIX
AUTO 4,1
*/--------------------------------------
* # GetDevByName
* Y,A = Ptr to device name (C-String)
* ## RETURN VALUE
* CC = OK, CS = ERROR
* Y,A = FD
* X = hDev
*\--------------------------------------
K.GetDevByName >STYA ZPPtr1 requested dev name
ldx #1
.1 lda Dev.Table-1,x
clc
adc #S.FD.DEV
sta ZPPtr2
lda Dev.Table,x
beq K.GetDev.NODEV
adc /S.FD.DEV
sta ZPPtr2+1
ldy #$ff
.2 iny
lda (ZPPtr1),y
cmp (ZPPtr2),y
bne .7
ora (ZPPtr2),y Both char are 0 ?
bne .2 no....loop
.3 ldy Dev.Table-1,x
.4 lda Dev.Table,x
clc
rts
.7 inx
inx
cpx #K.DEV.MAX*2+1
bne .1
K.GetDev.NODEV lda #MLI.E.NODEV
sec
K.GetDev.9 rts
*/--------------------------------------
* # GetDevStatus
* ## C
* `int getdevstatus(short int DevID, S.DIB* dstat);`
* ## ASM
* `>PUSHWI S.DIB`
* `lda DevID`
* `>SYSCALL GetDevStatus`
* ## RETURN VALUE
*\--------------------------------------
K.GetDevStatus tax
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
lda Dev.Table,x
beq K.GetDev.NODEV
ldy Dev.Table-1,x
>STYA pFD
lda #S.IOCTL.STATCODE.GETDIB
K.GetDevStatus.I
sta K.S.IOCTL+S.IOCTL.STATCODE
jsr K.IOCTL.GetPDrv
>LDYAI K.S.IOCTL
ldx #IOCTL.STATUS
jmp (pDrv)
*/--------------------------------------
* # MKDev
* Create a hDEV
* ## C
* `hDEV mkdev (S.FD * fd, const char *devname)`
* ## ASM
* `>PUSHW devname`
* `>LDYA fd`
* `>SYSCALL mkdev
* ## RETURN VALUE
* A = hDEV
*\--------------------------------------
K.MKDev jsr MEM.SPtr1PPtr2 ptr1=fd, ptr2=name
ldx DevMgr.DevIdx
cpx #K.DEV.MAX*2+1
beq .9
ldy #$ff
ldx #S.FD.DEV
.1 iny Get DEV name length
inx compute FD+NAME+\0 in X
lda (ZPPtr2),y
bne .1
txa
tay
lda #0
jsr MEM.GetKrnlBuf
bcs .99
>STYA pFD
>STYA .4+1
ldx DevMgr.DevIdx
sta Dev.Table,x
tya
sta Dev.Table-1,x
ldy #S.FD.DEV-1
.2 lda (ZPPtr1),y
sta (pFD),y
dey
bpl .2
ldy #$ff
ldx #S.FD.DEV-1
.3 iny
inx
lda (ZPPtr2),y
.4 sta $ffff,x
bne .3
>LDYAI K.IOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.STATUS
jsr K.GetDevStatus.I
bcs .99
lda K.IOBuf Get Status byte
bit #S.DIB.S.IRQ
beq .8
ldx #0
.5 lda IRQ.Vectors+1,x
beq .7
inx
inx
cpx #K.IRQDEV.MAX*2+1
bne .5
.9 lda #E.OOH
* sec
.99 rts
.7 lda pFD
sta IRQ.Vectors,x
lda pFD+1
sta IRQ.Vectors+1,x
.8 lda DevMgr.DevIdx
inc DevMgr.DevIdx
inc DevMgr.DevIdx
* clc
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.DEV
LOAD USR/SRC/SYS/KERNEL.S
ASM