A2osX/SYS/KERNEL.S.DEV.txt
2020-03-16 07:50:15 +01:00

226 lines
3.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
AUTO 3,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
ldy Dev.Table-1,x
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
* `>PUSHB DevID`
* `>PUSHW S.DIB`
* `>SYSCALL GetDevStatus`
* ## RETURN VALUE
*\--------------------------------------
K.GetDevStatus >PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLA
tax
lda Dev.Table,x
beq K.GetDev.NODEV
ldy Dev.Table-1,x
>STYA pFD
lda #S.IOCTL.STATCODE.GETDIB
*--------------------------------------
SHARED.GetDevStatus
sta K.S.IOCTL+S.IOCTL.STATCODE
ldy #S.FD.DEV.DEVID
lda (pFD),y
sta K.S.IOCTL+S.IOCTL.UNITNUM
jsr SHARED.GetPDrv
>LDYAI K.S.IOCTL
ldx #IOCTL.STATUS
*--------------------------------------
SHARED.pDrvJmp jmp (pDrv)
*--------------------------------------
SHARED.GetPDrv ldy #S.FD.DEV.DRVPTR
lda (pFD),y
sta pDRV
iny
lda (pFD),y
sta pDRV+1
rts
*/--------------------------------------
* # MKDev
* Create a hDEV
* ## C
* `hDEV mkdev (S.FD *fd, const char *devname)`
* ## ASM
* `>PUSHW fd`
* `>PUSHW devname`
* `>SYSCALL mkdev`
* ## RETURN VALUE
* A = hDEV
*\--------------------------------------
K.MKDev >PULLW ZPPtr2 ptr2=name
>PULLW ZPPtr1 ptr1=fd
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 SHARED.GetDevStatus
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 ldy #IOCTL.IRQ+4
lda (pDRV),y
sta IRQ.Vectors,x
iny
lda (pDRV),y
sta IRQ.Vectors+1,x
.8 lda DevMgr.DevIdx
inc DevMgr.DevIdx
inc DevMgr.DevIdx
* clc
rts
*/--------------------------------------
* # IOCTL
* ## C
* `int ioctl(short int DevID, short int request, void *param);`
* ## ASM
* `>PUSHB hDEV`
* `>PUSHB request`
* `>PUSHW param`
* `>SYSCALL IOCTL`
* ## RETURN VALUE
* Y,A = ...
*\--------------------------------------
K.IOCTL ldy #3 hDev
lda (pStack),y
tax
lda Dev.Table,x
beq .9
ldy Dev.Table-1,x
>STYA pFD
jsr SHARED.GetPDrv
ldy #2 request
lda (pStack),y
tax
>PULLYA param
inc pStack
inc pStack
jmp (pDrv)
.9 sec
lda #MLI.E.NODEV
>RET 4
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.DEV
LOAD USR/SRC/SYS/KERNEL.S
ASM