mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 05:32:20 +00:00
249 lines
4.9 KiB
Plaintext
249 lines
4.9 KiB
Plaintext
PR#3
|
||
PREFIX /DATA/A2OSX
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
*--------------------------------------
|
||
* S.DevMgrInit
|
||
*--------------------------------------
|
||
S.DevMgrInit ldx #S.DEV.SIZE*K.DEV.MAX
|
||
.1 stz DEVMGR.TABLE-1,x
|
||
dex
|
||
bne .1
|
||
|
||
ldy #5
|
||
.2 lda DEVMGR.TABLE.NUL,y
|
||
sta DEVMGR.TABLE,y
|
||
dey
|
||
bpl .2
|
||
|
||
ldy #5
|
||
ldx #S.DEV.SIZE+5
|
||
.3 lda DEVMGR.TABLE.KBD,y
|
||
sta DEVMGR.TABLE,x
|
||
dex
|
||
dey
|
||
bpl .3
|
||
|
||
lda #1 reserve #0=NUL, #1=KBD
|
||
sta DEVMGR.LASTID
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* S.GetDevByIDA
|
||
* IN:
|
||
* A = DevID
|
||
* OUT:
|
||
* CC = OK, CS = ERROR
|
||
* Y,A = devslot
|
||
* X Unmodified
|
||
*--------------------------------------
|
||
S.GetDevByIDA sta ZPQuickPtr1
|
||
lda #K.DEV.MAX
|
||
sta ZPQuickPtr1+1
|
||
|
||
>LDYAI DEVMGR.TABLE
|
||
>STYA ZPQuickPtr2
|
||
|
||
.1 lda (ZPQuickPtr2) get S.DEV.F
|
||
bpl .3 In use ?
|
||
ldy #S.DEV.ID
|
||
lda (ZPQuickPtr2),y
|
||
cmp ZPQuickPtr1
|
||
beq .8
|
||
|
||
.2 lda ZPQuickPtr2
|
||
clc
|
||
adc #S.DEV.SIZE
|
||
sta ZPQuickPtr2
|
||
bcc .3
|
||
inc ZPQuickPtr2+1
|
||
|
||
.3 dec ZPQuickPtr1+1
|
||
bne .1
|
||
sec
|
||
rts
|
||
|
||
.8 >LDYA ZPQuickPtr2
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* GetDevIDByNameA
|
||
* IN:
|
||
* A = hPStr
|
||
* OUT:
|
||
* CC = OK, CS = ERROR
|
||
* A = DEVID
|
||
* set DEVMGR.DEVPTR to devslot
|
||
*--------------------------------------
|
||
S.GetDevByNameA jsr S.GetMemPtrA
|
||
>STYA ZPQuickPtr1
|
||
>LDYAI DEVMGR.TABLE
|
||
>STYA DEVMGR.DEVPTR
|
||
|
||
ldx #K.DEV.MAX
|
||
.1 lda (DEVMGR.DEVPTR) get S.DEV.F
|
||
bpl .3 empty ?
|
||
lda DEVMGR.DEVPTR
|
||
clc
|
||
adc #S.DEV.NAME
|
||
sta ZPQuickPtr2
|
||
lda DEVMGR.DEVPTR+1
|
||
adc /S.DEV.NAME
|
||
sta ZPQuickPtr2+1
|
||
lda (ZPQuickPtr1)
|
||
cmp (ZPQuickPtr2)
|
||
bne .3
|
||
tay
|
||
.2 lda (ZPQuickPtr1),y
|
||
cmp (ZPQuickPtr2),y
|
||
bne .3
|
||
dey
|
||
bne .2
|
||
ldy #S.DEV.ID
|
||
lda (DEVMGR.DEVPTR),y
|
||
clc
|
||
rts
|
||
.3 lda DEVMGR.DEVPTR
|
||
clc
|
||
adc #S.DEV.SIZE
|
||
sta DEVMGR.DEVPTR
|
||
bcc .5
|
||
inc DEVMGR.DEVPTR+1
|
||
.5 dex
|
||
bne .1
|
||
lda #DEVMGR.ERRDNF
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
* S.GetDevTable
|
||
* IN :
|
||
* OUT CC = OK, CS = ERROR
|
||
* Y,A = PTR to dev table
|
||
* X = LASTID
|
||
*--------------------------------------
|
||
S.GetDevTable >LDYAI DEVMGR.TABLE
|
||
|
||
ldx DEVMGR.LASTID
|
||
rts
|
||
*--------------------------------------
|
||
* S.DevOutA
|
||
* IN :
|
||
* A = hDev
|
||
*--------------------------------------
|
||
S.DevOutA ldx #DEVMGR.OUT
|
||
jmp S.DevCallFunc
|
||
*--------------------------------------
|
||
* S.GetDevInfoA
|
||
*--------------------------------------
|
||
S.GetDevInfoA ldx #DEVMGR.GETINFO
|
||
jmp S.DevCallFunc
|
||
*--------------------------------------
|
||
* PRIVATE
|
||
*--------------------------------------
|
||
* S.DevOpenA
|
||
* IN :
|
||
* A = hDev
|
||
* OUT CC = OK, CS = ERROR
|
||
*--------------------------------------
|
||
S.DevOpenA ldx #DEVMGR.OPEN
|
||
bra S.DevCallFunc
|
||
*--------------------------------------
|
||
* S.DevGetEventA
|
||
* IN :
|
||
* A = hDev
|
||
* OUT CC = OK, CS = ERROR
|
||
*--------------------------------------
|
||
S.DevGetEventA ldx #DEVMGR.GETEVENT
|
||
bra S.DevCallFunc
|
||
*--------------------------------------
|
||
* S.DevCloseA
|
||
*--------------------------------------
|
||
S.DevCloseA ldx #DEVMGR.CLOSE
|
||
bra S.DevCallFunc
|
||
*--------------------------------------
|
||
S.DevCallFunc jsr S.GetDevByIDA
|
||
bcs .9
|
||
>STYA pDevContext
|
||
ldy #S.DEV.hCS
|
||
lda (pDevContext),y
|
||
jsr S.GetMemPtrA X = unmodified
|
||
>STYA Kernel.JMP
|
||
>LDYA pDevContext
|
||
jsr Kernel.DRVCALL Call DRV function
|
||
.9 rts
|
||
*--------------------------------------
|
||
* S.CreateDevSlot
|
||
* IN : none
|
||
* OUT : A = DevID
|
||
* set DEVMGR.DEVPTR to freeslot
|
||
* init (DEVMGR.DEVPTR),S.DEV.ID with Dev.ID
|
||
*--------------------------------------
|
||
S.CreateDevice >LDYAI DEVMGR.TABLE
|
||
>STYA DEVMGR.DEVPTR
|
||
ldx #K.DEV.MAX
|
||
|
||
.1 lda (DEVMGR.DEVPTR)
|
||
bpl .3
|
||
lda DEVMGR.DEVPTR
|
||
clc
|
||
adc #S.DEV.SIZE
|
||
sta DEVMGR.DEVPTR
|
||
bcc .2
|
||
inc DEVMGR.DEVPTR+1
|
||
.2 dex
|
||
bne .1
|
||
lda #DEVMGR.ERROOS
|
||
sec
|
||
rts
|
||
|
||
.3 lda #0
|
||
tay
|
||
.4 sta (DEVMGR.DEVPTR),y
|
||
iny
|
||
cpy #S.DEV.SIZE
|
||
bne .4
|
||
inc DEVMGR.LASTID
|
||
lda DEVMGR.LASTID
|
||
ldy #S.DEV.ID
|
||
sta (DEVMGR.DEVPTR),y
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* S.DestroyDevSlot
|
||
* selected by (DEVMGR.DEVPTR)
|
||
*--------------------------------------
|
||
S.DestroyDevice ldy #S.DEV.hCS
|
||
lda (DEVMGR.DEVPTR),y
|
||
beq .1
|
||
jsr S.FreeMemA
|
||
.1 ldy #S.DEV.hDS
|
||
lda (DEVMGR.DEVPTR),y
|
||
beq .2
|
||
jsr S.FreeMemA
|
||
.2 ldy #S.DEV.hCMD
|
||
lda (DEVMGR.DEVPTR),y
|
||
beq .3
|
||
jsr S.FreeMemA
|
||
.3 ldy #S.DEV.hARGS
|
||
lda (DEVMGR.DEVPTR),y
|
||
beq .4
|
||
jsr S.FreeMemA
|
||
.4 rts
|
||
*--------------------------------------
|
||
DEVMGR.TABLE.NUL .DA #S.DEV.F.INUSE+S.DEV.F.CHAR+S.DEV.F.BLOCK
|
||
.HS 00 ID
|
||
>PSTRING "NUL" NAME
|
||
DEVMGR.TABLE.KBD .DA #S.DEV.F.INUSE+S.DEV.F.CHAR
|
||
.HS 01 ID
|
||
>PSTRING "KBD" NAME
|
||
DEVMGR.LASTID .BS 1
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.DEV
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|