A2osX/SYS/KERNEL.S.DRV.txt

286 lines
5.2 KiB
Plaintext
Raw Normal View History

2015-06-03 18:30:57 +00:00
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* S.LoadDrvA
* in :
* A = hMem To Full Cmd Line
* out :
* none
*--------------------------------------
S.LoadDrvA >PUSHA push Cmd Line for S.PStrGetTkn
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD And ARGS
jsr S.PStrGetTkn
bcc .1
rts
2016-06-07 06:10:18 +00:00
.1 sta S.LoadDrv.Name
stx S.LoadDrv.Args
>LDYAI ENV.DRV push ENVNAME=DRV
jsr S.GetEnvVarYA get value for ENV=$DRV
bcs .98
2016-06-07 06:10:18 +00:00
sta S.LoadDrv.Srch
>PUSHB S.LoadDrv.Name push CMD for S.FileSearch
>PUSHB S.LoadDrv.Srch
jsr S.FileSearch find File in $DRV
bcs .97 not Found
2016-06-07 06:10:18 +00:00
sta S.LoadDrv.FullName
2015-06-03 18:30:57 +00:00
jsr S.LoadBinA
bcs .96
>STYA pDrv
2016-06-07 06:10:18 +00:00
stx S.LoadDrv.hMem
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.Args
jsr S.LoadDrvA.Jmp call Dev.Detect
2015-06-03 18:30:57 +00:00
bcs .95
jsr S.InsDrv
bcs .95
jsr .95
ldy #S.DEV.F
lda (pDev),y
ora #S.DEV.F.INUSE
sta (pDev),y
clc
rts
.95 pha
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.hMem
2015-06-03 18:30:57 +00:00
jsr S.FreeMemA
pla
.96 pha
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.FullName
jsr S.FreeMemA
pla
.97 pha
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.Srch
2015-06-03 18:30:57 +00:00
jsr S.FreeMemA
pla
.98 pha
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.Args
2015-06-03 18:30:57 +00:00
jsr S.FreeMemA
2016-06-07 06:10:18 +00:00
lda S.LoadDrv.Name
2015-06-03 18:30:57 +00:00
jsr S.FreeMemA
pla
.99 sec
rts
*--------------------------------------
S.LoadDrvA.Jmp jmp (pDrv)
*--------------------------------------
2016-06-07 06:10:18 +00:00
S.LoadDrv.Name .BS 1
S.LoadDrv.Args .BS 1
S.LoadDrv.Srch .BS 1
S.LoadDrv.FullName .BS 1
S.LoadDrv.hMem .BS 1
2015-06-03 18:30:57 +00:00
*--------------------------------------
* pDrv = .DRV File Loaded Address
2015-06-03 18:30:57 +00:00
*--------------------------------------
S.InsDrv ldy #H.BIN.DRV.CODE.LEN
lda (pDrv),y
2015-06-03 18:30:57 +00:00
sta R.AL
iny
lda (pDrv),y
2015-06-03 18:30:57 +00:00
sta R.AH
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
2015-06-03 18:30:57 +00:00
clc
adc S.LoadBinA.AuxType
sta R.BL
iny
lda (pDrv),y
2015-06-03 18:30:57 +00:00
adc S.LoadBinA.AuxType+1
sta R.BH set BX=End Of Code
lda S.LoadBinA.AuxType
clc
adc S.LoadBinA.FileLen
sta R.CL
lda S.LoadBinA.AuxType+1
adc S.LoadBinA.FileLen+1
sta R.CH set CX=End Of Range
ldy #H.BIN.DRV.CODE.O
lda S.LoadBinA.FileLen
sec
sbc (pDrv),y
2015-06-03 18:30:57 +00:00
sta S.InsDrv.DRVLen
iny
lda S.LoadBinA.FileLen+1
sbc (pDrv),y
2015-06-03 18:30:57 +00:00
sta S.InsDrv.DRVLen+1 Compute DRV Len
lda DevMgr.Free
clc
adc S.InsDrv.DRVLen
sta S.InsDrv.DRVEnd
lda DevMgr.Free+1
adc S.InsDrv.DRVLen+1
sta S.InsDrv.DRVEnd+1
bcs .98 we crossed $FFFF, out of mem
lda S.InsDrv.DRVEnd
sec
sbc #DevMgr.HiMem
lda S.InsDrv.DRVEnd+1
sbc /DevMgr.HiMem
bcs .98 No More Room to load Driver....
lda DevMgr.LastDevID
inc
cmp #K.DEV.MAX
beq .99 No Device Handle Left
sta DevMgr.LastDevID
ldy #H.BIN.DEV.HEADER.O
lda (pDrv),y
2015-06-03 18:30:57 +00:00
clc
adc pDrv
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1+1
ldy #S.DEV.JMP
lda DevMgr.Free
sec
sbc (ZPQuickPtr1),y
sta R.DL
lda DevMgr.Free+1
iny
sbc (ZPQuickPtr1),y
sta R.DH set DX=Offset
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
2015-06-03 18:30:57 +00:00
clc
adc pDrv
2015-06-03 18:30:57 +00:00
pha
iny
lda (pDrv),y
adc pDrv+1
2015-06-03 18:30:57 +00:00
ply
jsr S.DrvRelocateYA
jsr S.InsDrv.Move
>LDYA S.InsDrv.DrvEnd
>STYA DevMgr.Free
clc
rts
.98 lda #DEVMGR.ERROOM
sec
rts
.99 lda #DEVMGR.ERROOH
sec
rts
*--------------------------------------
S.InsDrv.Move ldy #H.BIN.DEV.HEADER.O
lda (pDrv),y
2015-06-03 18:30:57 +00:00
clc
adc pDrv
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1+1
ldy #S.DEV.JMP Relocate Main JMP
lda (ZPQuickPtr1),y
clc
adc R.DL
sta (ZPQuickPtr1),y
iny
lda (ZPQuickPtr1),y
adc R.DH
sta (ZPQuickPtr1),y
lda DevMgr.LastDevID
jsr S.GetDevByIDA
>STYA pDev
ldy #S.DEV.SIZE Make sure DevMgr.Table Ends with 0
lda #0
sta (pDev),y
dey
.1 lda (ZPQuickPtr1),y Copy DRV.Header
2015-06-03 18:30:57 +00:00
sta (pDev),y
dey
bpl .1
2016-06-07 06:10:18 +00:00
lda DevMgr.LastDevID Save Dev.ID in the driver for SELECT
ldy #S.DEV.ID
sta (pDev),y
2015-06-03 18:30:57 +00:00
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
2015-06-03 18:30:57 +00:00
clc
adc pDrv
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
2015-06-03 18:30:57 +00:00
sta ZPQuickPtr1+1 Make ZPQuickPtr1=DRV.CODE
lda DevMgr.Free
sta ZPQuickPtr2
lda DevMgr.Free+1
sta ZPQuickPtr2+1 Make ZPQuickPtr2=Dest Ram Location
ldy S.InsDrv.DrvLen
ldx S.InsDrv.DrvLen+1
.2 lda (ZPQuickPtr1)
sta (ZPQuickPtr2)
inc ZPQuickPtr1
bne .3
inc ZPQuickPtr1+1
.3 inc ZPQuickPtr2
bne .4
inc ZPQuickPtr2+1
.4 tya
bne .5
txa
beq .8
dex
.5 dey
bra .2
.8 rts
*--------------------------------------
2016-06-07 06:10:18 +00:00
ENV.DRV >PSTRING "DRV"
2015-06-03 18:30:57 +00:00
S.InsDrv.DrvLen .BS 2
S.InsDrv.DrvEnd .BS 2
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DRV
LOAD SYS/KERNEL.S
ASM