A2osX/SYS/KERNEL.S.DEV.txt
2019-01-13 13:10:14 +00:00

176 lines
3.0 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 = DevID
*\--------------------------------------
K.GetDevByName >STYA ZPPtr1 requested dev name
ldx #0
.1 lda Dev.Table,x
sta .3+1
clc
adc #S.FD.DEV
sta ZPPtr2
lda Dev.Table+1,x
beq K.GetDev.NODEV
sta .4+1
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 #$ff SELF MODIFIED
.4 lda #$ff SELF MODIFIED
clc
rts
.7 inx
inx
cpx DevMgr.DevCnt
bne .1
K.GetDev.NODEV lda #MLI.E.NODEV
sec
K.GetDev.9 rts
*/--------------------------------------
* # GetDevStatus
* ## C
* `int getdevstatus(short int hDEV, 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+1,x
beq K.GetDev.NODEV
ldy Dev.Table,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.DevCnt
cpx #K.DEV.MAX
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.DevCnt
sta Dev.Table+1,x
tya
sta Dev.Table,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
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.DevCnt
inc DevMgr.DevCnt
inc DevMgr.DevCnt
* clc
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.DEV
LOAD USR/SRC/SYS/KERNEL.S
ASM