mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 07:54:37 +00:00
219 lines
3.8 KiB
Plaintext
219 lines
3.8 KiB
Plaintext
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 jsr SHARED.GetDevFD
|
||
bcs K.GetDev.NODEV
|
||
|
||
pha
|
||
tya
|
||
* clc
|
||
adc #S.FD.DEV
|
||
sta ZPPtr2
|
||
pla
|
||
|
||
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
|
||
|
||
beq SHARED.GetDevFD yes, get Ptr
|
||
|
||
.7 inx no....loop
|
||
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
|
||
|
||
jsr SHARED.GetDevFD
|
||
bcs K.GetDev.9
|
||
>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.GetDevFD lda Dev.Table,x
|
||
beq K.GetDev.NODEV
|
||
ldy Dev.Table-1,x
|
||
clc
|
||
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
|
||
|
||
jsr SHARED.GetDevFD
|
||
bcs .9
|
||
>STYA pFD
|
||
|
||
jsr SHARED.GetPDrv
|
||
|
||
ldy #2 request
|
||
lda (pStack),y
|
||
tax
|
||
|
||
>PULLYA param
|
||
inc pStack
|
||
inc pStack
|
||
|
||
jmp (pDrv)
|
||
|
||
.9 >RET 4
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/SYS/KERNEL.S.DEV
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|