mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
151 lines
2.6 KiB
Plaintext
151 lines
2.6 KiB
Plaintext
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
|
||
|
||
ldx #0
|
||
|
||
.1 lda Dev.Table.hPath,x
|
||
beq K.GetDev.NODEV
|
||
jsr K.GetMemPtr
|
||
|
||
>STYA ZPPtr2
|
||
|
||
ldy #$ff
|
||
|
||
.2 iny
|
||
lda (ZPPtr1),y
|
||
cmp (ZPPtr2),y
|
||
bne .4
|
||
|
||
ora (ZPPtr2),y Both char are 0 ?
|
||
bne .2 no....loop
|
||
|
||
lda Dev.Table.hFD,x
|
||
jmp K.GetMemPtr
|
||
|
||
.4 inx
|
||
cpx DevMgr.DevCnt
|
||
bne .1
|
||
|
||
K.GetDev.NODEV lda #MLI.E.NODEV
|
||
sec
|
||
K.GetDev.9 rts
|
||
*/--------------------------------------
|
||
* # GetDevStatus
|
||
* ## C
|
||
* `int getdevstatus(short int hFD, S.DIB* dstat);`
|
||
* ## ASM
|
||
* `>PUSHWI S.DIB`
|
||
* `lda DevID`
|
||
* `>SYSCALL GetDevStatus`
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
K.GetDevStatus jsr K.GetMemPtr
|
||
>STYA pFD
|
||
|
||
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
|
||
|
||
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
|
||
cmp #K.DEV.MAX
|
||
beq .9
|
||
|
||
>LDYAI S.FD.DEV
|
||
ldx #S.MEM.F.FD
|
||
jsr MEM.GetMem.YAX
|
||
bcs .99
|
||
>STYA pFD
|
||
txa
|
||
|
||
ldx DevMgr.DevCnt
|
||
sta Dev.Table.hFD,x
|
||
|
||
ldy #S.FD.DEV-1
|
||
|
||
.1 lda (ZPPtr1),y
|
||
sta (pFD),y
|
||
dey
|
||
bpl .1
|
||
|
||
>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
|
||
|
||
.3 lda IRQ.Vectors+1,x
|
||
beq .7
|
||
|
||
inx
|
||
inx
|
||
cpx #K.IRQDEV.MAX*2
|
||
bne .3
|
||
|
||
.9 lda #E.OOH
|
||
* sec
|
||
.99 rts
|
||
|
||
.7 lda pFD
|
||
sta IRQ.Vectors,x
|
||
lda pFD+1
|
||
sta IRQ.Vectors+1,x
|
||
|
||
.8 >LDYA ZPPtr2
|
||
jsr K.NewStr
|
||
bcs .99
|
||
txa
|
||
|
||
ldx DevMgr.DevCnt
|
||
sta Dev.Table.hPath,x
|
||
|
||
txa
|
||
|
||
inc DevMgr.DevCnt
|
||
* clc
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/SYS/KERNEL.S.DEV
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|