2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-25 19:24:07 +00:00
|
|
|
|
AUTO 3,1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* # GetDevByName
|
2017-09-14 15:21:06 +00:00
|
|
|
|
* Y,A = Ptr to device name (C-String)
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* CC = OK, CS = ERROR
|
|
|
|
|
* Y,A = FD
|
2021-07-24 20:42:23 +00:00
|
|
|
|
* X = hFD
|
2016-10-26 20:51:06 +00:00
|
|
|
|
*\--------------------------------------
|
2019-01-13 13:10:14 +00:00
|
|
|
|
K.GetDevByName >STYA ZPPtr1 requested dev name
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2019-02-27 15:00:56 +00:00
|
|
|
|
ldx #1
|
2018-12-13 16:39:24 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.1 lda hFDs-1,x
|
|
|
|
|
beq .7
|
|
|
|
|
|
|
|
|
|
sta IO.hFD
|
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA pFD
|
2020-05-04 20:46:21 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
lda hFDs.hName-1,x
|
|
|
|
|
bne .2
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
jsr DEV.GetPDrv
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
lda pFD
|
2020-12-15 13:23:22 +00:00
|
|
|
|
clc
|
2019-01-13 13:10:14 +00:00
|
|
|
|
adc #S.FD.DEV
|
2021-07-24 20:42:23 +00:00
|
|
|
|
sta ZPPtr2
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
lda pFD+1
|
2019-01-13 13:10:14 +00:00
|
|
|
|
adc /S.FD.DEV
|
2021-07-24 20:42:23 +00:00
|
|
|
|
sta ZPPtr2+1
|
|
|
|
|
bra .3
|
|
|
|
|
|
|
|
|
|
.2 jsr K.GetMemPtr
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2)
|
|
|
|
|
cmp #'/' REG/DIR
|
2020-12-15 13:23:22 +00:00
|
|
|
|
beq .7
|
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.3 ldy #$ff
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.4 iny
|
2020-12-15 13:23:22 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp (ZPPtr2),y
|
2021-07-24 20:42:23 +00:00
|
|
|
|
bne .7
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
eor #0
|
2021-07-24 20:42:23 +00:00
|
|
|
|
bne .4
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
stx IO.hFILE
|
|
|
|
|
>LDYA pFD
|
|
|
|
|
ldx IO.hFD
|
2020-12-15 13:23:22 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2021-05-19 12:44:47 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.7 inx no....loop
|
|
|
|
|
cpx #K.hFD.MAX+1
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #MLI.E.NODEV
|
|
|
|
|
* sec
|
2021-05-19 12:44:47 +00:00
|
|
|
|
|
2018-07-11 15:13:29 +00:00
|
|
|
|
K.GetDev.9 rts
|
2018-01-15 06:50:44 +00:00
|
|
|
|
*/--------------------------------------
|
2021-08-10 10:20:41 +00:00
|
|
|
|
* # MkFD
|
2020-12-15 13:23:22 +00:00
|
|
|
|
* ## C
|
2021-08-10 10:20:41 +00:00
|
|
|
|
* `short int mkfd(short int type, );`
|
2018-07-19 15:33:55 +00:00
|
|
|
|
* ## ASM
|
2020-02-19 06:53:24 +00:00
|
|
|
|
* `>PUSHB DevID`
|
2020-02-16 20:45:16 +00:00
|
|
|
|
* `>PUSHW S.DIB`
|
2022-01-31 21:48:25 +00:00
|
|
|
|
* `>SYSCALL MkFD`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-01-15 06:50:44 +00:00
|
|
|
|
*\--------------------------------------
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-05-19 12:44:47 +00:00
|
|
|
|
|
2022-10-18 05:56:59 +00:00
|
|
|
|
* clc
|
|
|
|
|
* rts
|
2018-07-17 15:45:59 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # MKDev
|
2018-10-05 14:58:38 +00:00
|
|
|
|
* Create a hDEV
|
|
|
|
|
* ## C
|
2020-02-16 20:45:16 +00:00
|
|
|
|
* `hDEV mkdev (S.FD *fd, const char *devname)`
|
2018-10-05 14:58:38 +00:00
|
|
|
|
* ## ASM
|
2020-02-16 20:45:16 +00:00
|
|
|
|
* `>PUSHW fd`
|
2018-12-11 16:41:25 +00:00
|
|
|
|
* `>PUSHW devname`
|
2020-03-16 06:50:15 +00:00
|
|
|
|
* `>SYSCALL mkdev`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-05 14:58:38 +00:00
|
|
|
|
* A = hDEV
|
2018-07-17 15:45:59 +00:00
|
|
|
|
*\--------------------------------------
|
2022-01-30 21:47:08 +00:00
|
|
|
|
K.MKDev jsr SHARED.PullP2P1 ptr2=name,ptr1=fd
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
ldy #$ff
|
|
|
|
|
ldx #S.FD.DEV
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
.1 iny Get DEV name length
|
|
|
|
|
inx compute FD+NAME+\0 in X
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
bne .1
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
txa
|
|
|
|
|
tay
|
2021-07-25 14:03:41 +00:00
|
|
|
|
lda #S.FD.T.CDEV
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2021-07-25 14:03:41 +00:00
|
|
|
|
jsr DEV.MkFDy
|
2021-07-24 20:42:23 +00:00
|
|
|
|
bcs .9
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
>STYA .4+1
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-09-07 14:12:42 +00:00
|
|
|
|
ldy #S.FD.DEV-1
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
.2 lda (ZPPtr1),y
|
2018-10-05 14:58:38 +00:00
|
|
|
|
sta (pFD),y
|
2018-09-07 14:12:42 +00:00
|
|
|
|
dey
|
2019-01-13 13:10:14 +00:00
|
|
|
|
bpl .2
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
ldy #$ff
|
|
|
|
|
ldx #S.FD.DEV-1
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
.3 iny
|
|
|
|
|
inx
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
.4 sta $ffff,x
|
|
|
|
|
bne .3
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-09-07 14:12:42 +00:00
|
|
|
|
>LDYAI K.IOBuf
|
|
|
|
|
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
|
2022-01-30 21:47:08 +00:00
|
|
|
|
ldy #S.FD.DEV.DRVPTR+1
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
lda /DRV.SmartPort
|
|
|
|
|
sta (pFD),y
|
|
|
|
|
dey
|
|
|
|
|
lda #DRV.SmartPort
|
2022-01-31 17:25:19 +00:00
|
|
|
|
sta (pFD),y
|
2022-01-30 21:47:08 +00:00
|
|
|
|
|
|
|
|
|
.5 jsr DEV.GetPDrv
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-05-04 17:31:21 +00:00
|
|
|
|
lda #S.IOCTL.S.STATUS
|
2021-05-14 20:58:20 +00:00
|
|
|
|
jsr DEV.GetStatus
|
2021-07-24 20:42:23 +00:00
|
|
|
|
bcs .9
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-10-11 15:23:06 +00:00
|
|
|
|
lda K.IOBuf Get Status byte
|
|
|
|
|
bit #S.DIB.S.IRQ
|
|
|
|
|
beq .8
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-10-11 15:23:06 +00:00
|
|
|
|
ldx #0
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2022-01-30 21:47:08 +00:00
|
|
|
|
.6 lda IRQ.Vectors+1,x
|
2018-12-11 16:41:25 +00:00
|
|
|
|
beq .7
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-10-11 15:23:06 +00:00
|
|
|
|
inx
|
|
|
|
|
inx
|
2019-02-27 15:00:56 +00:00
|
|
|
|
cpx #K.IRQDEV.MAX*2+1
|
2022-01-30 21:47:08 +00:00
|
|
|
|
bne .6
|
2019-10-23 09:34:25 +00:00
|
|
|
|
|
2018-07-17 15:45:59 +00:00
|
|
|
|
* sec
|
2021-07-24 20:42:23 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2018-10-11 15:23:06 +00:00
|
|
|
|
|
2020-02-16 20:45:16 +00:00
|
|
|
|
.7 ldy #IOCTL.IRQ+4
|
|
|
|
|
lda (pDRV),y
|
2018-10-11 15:23:06 +00:00
|
|
|
|
sta IRQ.Vectors,x
|
2019-07-16 15:42:36 +00:00
|
|
|
|
iny
|
2020-02-16 20:45:16 +00:00
|
|
|
|
lda (pDRV),y
|
2018-10-11 15:23:06 +00:00
|
|
|
|
sta IRQ.Vectors+1,x
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.8 lda IO.hFD
|
2018-12-18 14:37:07 +00:00
|
|
|
|
* clc
|
2018-10-11 15:23:06 +00:00
|
|
|
|
rts
|
2020-02-16 20:45:16 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # IOCTL
|
|
|
|
|
* ## C
|
2021-07-24 20:42:23 +00:00
|
|
|
|
* `int ioctl(short int hFD, short int request, void *param);`
|
2020-02-16 20:45:16 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHB hDEV`
|
|
|
|
|
* `>PUSHB request`
|
|
|
|
|
* `>PUSHW param`
|
|
|
|
|
* `>SYSCALL IOCTL`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* Y,A = ...
|
|
|
|
|
*\--------------------------------------
|
2021-07-24 20:42:23 +00:00
|
|
|
|
K.IOCTL ldy #3 hFD
|
2020-02-16 20:45:16 +00:00
|
|
|
|
lda (pStack),y
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
jsr DEV.GetPFD
|
2020-02-16 20:45:16 +00:00
|
|
|
|
|
|
|
|
|
ldy #2 request
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
>PULLYA param
|
|
|
|
|
inc pStack
|
|
|
|
|
inc pStack
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2020-02-16 20:45:16 +00:00
|
|
|
|
jmp (pDrv)
|
2016-02-24 19:52:24 +00:00
|
|
|
|
*--------------------------------------
|
2021-08-10 10:20:41 +00:00
|
|
|
|
DEV.OPEN ldx #IOCTL.OPEN
|
2022-10-18 05:56:59 +00:00
|
|
|
|
lda IO.hFD
|
|
|
|
|
jsr DEV.pDrvJmp.1
|
2021-08-10 10:20:41 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda IO.hFD
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.READ ldx #IOCTL.READ
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.WRITE ldx #IOCTL.WRITE
|
|
|
|
|
|
|
|
|
|
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
|
|
|
|
|
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
|
|
|
|
|
inc pStack pop hFD
|
|
|
|
|
|
|
|
|
|
jsr DEV.pDrvJmp
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.EOF lda #S.IOCTL.S.EOF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.GetStatus sta K.S.IOCTL+S.IOCTL.S
|
|
|
|
|
|
|
|
|
|
ldx #IOCTL.STATUS
|
2022-03-06 22:28:52 +00:00
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.CLOSE ldx #IOCTL.CLOSE
|
2021-08-10 10:20:41 +00:00
|
|
|
|
*--------------------------------------
|
2022-01-31 21:48:25 +00:00
|
|
|
|
DEV.pDrvJmp >LDYAI K.S.IOCTL
|
2022-10-18 05:56:59 +00:00
|
|
|
|
DEV.pDrvJmp.1 jmp (pDrv)
|
2021-08-10 10:20:41 +00:00
|
|
|
|
*--------------------------------------
|
2021-07-24 20:42:23 +00:00
|
|
|
|
DEV.GetPFD sta IO.hFD
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA pFD
|
|
|
|
|
|
|
|
|
|
DEV.GetPDrv ldy #S.FD.DEV.DRVPTR
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
sta pDRV
|
|
|
|
|
iny
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
sta pDRV+1
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2021-07-25 14:03:41 +00:00
|
|
|
|
DEV.MkFD ldy #16 Y = Size, MAX=16 for S.FD.DIR
|
|
|
|
|
|
|
|
|
|
DEV.MkFDy sta .8+1 A = S.FD.T
|
2021-07-24 20:42:23 +00:00
|
|
|
|
|
2021-07-26 13:45:29 +00:00
|
|
|
|
jsr DEV.GetFreeFD
|
|
|
|
|
bcs .9
|
2021-07-25 14:03:41 +00:00
|
|
|
|
|
|
|
|
|
.2 stx IO.hFILE
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldx #S.MEM.F.INIT0+S.MEM.F.FD
|
|
|
|
|
jsr MEM.GetMem.YAX
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA pFD
|
|
|
|
|
stx IO.hFD
|
2021-07-24 20:42:23 +00:00
|
|
|
|
|
2021-08-01 13:45:15 +00:00
|
|
|
|
jsr Mem.SetOwnerPS0
|
2021-07-25 14:03:41 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
txa
|
|
|
|
|
|
|
|
|
|
.7 ldx IO.hFILE
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
sta hFDs-1,x
|
|
|
|
|
stz hFDs.hName-1,x
|
|
|
|
|
|
|
|
|
|
.8 lda #$ff SELF MODIFIED
|
2021-07-25 14:03:41 +00:00
|
|
|
|
sta (pFD)
|
|
|
|
|
|
2021-08-01 13:45:15 +00:00
|
|
|
|
>LDYA pFD Y,A = pFD, X = hFILE
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
.9 rts
|
2021-07-24 20:42:23 +00:00
|
|
|
|
*--------------------------------------
|
2021-07-26 13:45:29 +00:00
|
|
|
|
DEV.GetFreeFD lda #0
|
|
|
|
|
|
|
|
|
|
DEV.GetFD ldx #1
|
|
|
|
|
|
|
|
|
|
.1 cmp hFDs-1,x
|
2021-08-01 13:45:15 +00:00
|
|
|
|
beq DEV.GetFD.8
|
2021-07-26 13:45:29 +00:00
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
cpx #K.hFD.MAX+1
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
tax
|
2021-08-01 13:45:15 +00:00
|
|
|
|
beq DEV.GetFD.8
|
2021-07-26 13:45:29 +00:00
|
|
|
|
|
|
|
|
|
lda #E.INVH
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
.9 lda #E.OOH
|
|
|
|
|
* sec
|
|
|
|
|
rts
|
|
|
|
|
|
2022-10-18 05:56:59 +00:00
|
|
|
|
K.MkFD
|
2021-08-01 13:45:15 +00:00
|
|
|
|
DEV.GetFD.8 clc
|
2021-07-26 13:45:29 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2021-07-24 20:42:23 +00:00
|
|
|
|
DEV.hFDFree lda IO.hFD
|
2021-08-01 13:45:15 +00:00
|
|
|
|
beq DEV.GetFD.8
|
2021-07-24 20:42:23 +00:00
|
|
|
|
|
|
|
|
|
jmp K.FreeMem
|
2020-12-15 13:23:22 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
2020-12-15 13:23:22 +00:00
|
|
|
|
SAVE usr/src/sys/kernel.s.dev
|
|
|
|
|
LOAD usr/src/sys/kernel.s
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|