Kernel version 0.8 : Fixed a bug in DRV relocation

This commit is contained in:
Rémy GIBERT 2016-10-04 18:01:07 +02:00
parent 6fe1beb1ae
commit 728278c196
11 changed files with 111 additions and 113 deletions

Binary file not shown.

Binary file not shown.

View File

@ -36,9 +36,7 @@ CS.START cld
L.MSG.DETECT .DA MSG.DETECT L.MSG.DETECT .DA MSG.DETECT
.DA 0 End Of Reloc Table .DA 0 End Of Reloc Table
*-------------------------------------- *--------------------------------------
Dev.Detect >DEBUG Dev.Detect >LDYA L.MSG.DETECT
>LDYA L.MSG.DETECT
>SYSCALL SYS.PStrOutYA >SYSCALL SYS.PStrOutYA
clc clc

View File

@ -134,7 +134,7 @@ H.BIN.CODE.LEN .EQ 8
H.BIN.EXE.DS.SIZE .EQ 10 H.BIN.EXE.DS.SIZE .EQ 10
H.BIN.EXE.REL.TABLE .EQ 16 H.BIN.EXE.REL.TABLE .EQ 16
* *
H.BIN.DRV.DEVCTRLBLK.O .EQ 10 H.BIN.DRV.HEADER.O .EQ 10
H.BIN.DRV.CODE.O .EQ 12 H.BIN.DRV.CODE.O .EQ 12
H.BIN.DRV.CODE.LEN .EQ 14 H.BIN.DRV.CODE.LEN .EQ 14
H.BIN.DRV.REL.TABLE .EQ 0 H.BIN.DRV.REL.TABLE .EQ 0
@ -266,7 +266,7 @@ TSKMGR.ERRNSP .EQ $DD No Such Process Error
*-------------------------------------- *--------------------------------------
SYSMGR.ERRSYN .EQ $CF Syntax Error SYSMGR.ERRSYN .EQ $CF Syntax Error
SYSMGR.ERRENVF .EQ $CE Env is Full SYSMGR.ERRENVF .EQ $CE Env is Full
SYSMGR.ERRIBIN .EQ $CD Invalid BIN format
SYSMGR.ERRFTB .EQ $CC File Too Big Error SYSMGR.ERRFTB .EQ $CC File Too Big Error
SYSMGR.ERRFNF .EQ $CB File Not Found Error SYSMGR.ERRFNF .EQ $CB File Not Found Error
*-------------------------------------- *--------------------------------------

View File

@ -71,6 +71,7 @@ K.LoadEXEYA.1 >PUSHWI KrnBuf256
jsr BIN.SetupCodeEndPtr2 jsr BIN.SetupCodeEndPtr2
jsr BIN.RelocateEXE jsr BIN.RelocateEXE
bcs .98
>LDYA K.LoadEXEYA.Filename get back bin path >LDYA K.LoadEXEYA.Filename get back bin path
>SYSCALL SYS.NewPStrYA make a copy of this string >SYSCALL SYS.NewPStrYA make a copy of this string
@ -106,13 +107,28 @@ K.LoadEXEYA.Filename .BS 2
K.LoadEXEYA.hMem .BS 1 K.LoadEXEYA.hMem .BS 1
*-------------------------------------- *--------------------------------------
* BIN.InstallDRV * BIN.InstallDRV
* In:
* pDrv = .DRV File Loaded Address * pDrv = .DRV File Loaded Address
* Note:
* K.LoadEXEYA called from K.LoadDrvYA
* Already setup correctly pDrv,
* BIN.Relocate.Start,End
*-------------------------------------- *--------------------------------------
BIN.InstallDRV ldy #H.BIN.DRV.CODE.O BIN.InstallDRV lda DevMgr.Free Offset = Target DRV address-AUXTYPE
sec
sbc BIN.Relocate.Start
sta BIN.Relocate.Offset
lda DevMgr.Free+1
sbc BIN.Relocate.Start+1
sta BIN.Relocate.Offset+1
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y lda (pDrv),y
clc clc
adc BIN.Relocate.Start Advance start From Bin code to DRV code adc BIN.Relocate.Start Advance start From Bin code to DRV code
sta BIN.Relocate.Start sta BIN.Relocate.Start
iny iny
lda (pDrv),y lda (pDrv),y
adc BIN.Relocate.Start+1 adc BIN.Relocate.Start+1
@ -133,113 +149,60 @@ BIN.InstallDRV ldy #H.BIN.DRV.CODE.O
sta BIN.InstallDRV.DRVEnd sta BIN.InstallDRV.DRVEnd
tay Save DRVEnd LO tay Save DRVEnd LO
lda DevMgr.Free+1 lda DevMgr.Free+1
sta ZPQuickPtr3+1 save it for DrvMove
adc BIN.InstallDRV.DRVLen+1 A = DRVEnd HI adc BIN.InstallDRV.DRVLen+1 A = DRVEnd HI
sta BIN.InstallDRV.DRVEnd+1 sta BIN.InstallDRV.DRVEnd+1
bcs .98 we crossed $FFFF, out of mem bcs .9 we crossed $FFFF, out of mem
cpy #DevMgr.HiMem cpy #DevMgr.HiMem
sbc /DevMgr.HiMem sbc /DevMgr.HiMem
bcs .98 No More Room to load Driver.... bcs .9 No More Room to load Driver....
lda DevMgr.LastDevID lda DevMgr.LastDevID
inc inc
cmp #K.DEV.MAX cmp #K.DEV.MAX
beq .99 No Device Handle Left bne .10 No Device Handle Left
sta DevMgr.LastDevID lda #DEVMGR.ERROOH
ldy #H.BIN.DRV.DEVCTRLBLK.O
lda (pDrv),y
clc
adc pDrv
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
sta ZPQuickPtr1+1
ldy #S.DEV.JMP
lda DevMgr.Free
sec
sbc (ZPQuickPtr1),y
sta BIN.Relocate.Offset
lda DevMgr.Free+1
iny
sbc (ZPQuickPtr1),y
sta BIN.Relocate.Offset+1
ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
clc
adc pDrv
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
sta ZPQuickPtr1+1
ldy #H.BIN.DRV.CODE.LEN
jsr BIN.SetupCodeEndPtr2
jsr BIN.RelocateDRV
jsr BIN.MoveDRV
>LDYA BIN.InstallDRV.DrvEnd
>STYA DevMgr.Free
clc
rts
.98 lda #DEVMGR.ERROOM
sec sec
rts rts
.99 lda #DEVMGR.ERROOH .9 lda #DEVMGR.ERROOM
sec sec
rts rts
*--------------------------------------
BIN.MoveDRV ldy #H.BIN.DRV.DEVCTRLBLK.O
lda (pDrv),y
clc
adc pDrv
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
sta ZPQuickPtr1+1
ldy #S.DEV.JMP Relocate Main JMP .10 sta DevMgr.LastDevID
lda (ZPQuickPtr1),y
clc
adc BIN.Relocate.Offset
sta (ZPQuickPtr1),y
iny
lda (ZPQuickPtr1),y
adc BIN.Relocate.Offset+1
sta (ZPQuickPtr1),y
lda DevMgr.LastDevID
jsr K.GetDevByIDA jsr K.GetDevByIDA
>STYA pDev >STYA ZPQuickPtr2 setup Ptr2 to dest HEADER
ldy #S.DEV Make sure DevMgr.Table Ends with 0 ldy #H.BIN.DRV.HEADER.O
lda #0 lda (pDrv),y
sta (pDev),y clc
adc pDrv
sta ZPQuickPtr1
iny
lda (pDrv),y
adc pDrv+1
sta ZPQuickPtr1+1 set Ptr1 to Src HEADER
dey ldy #S.DEV-1
.1 lda (ZPQuickPtr1),y Copy DRV.Header .1 lda (ZPQuickPtr1),y copy header to DevMgr.Table
sta (pDev),y sta (ZPQuickPtr2),y
dey dey
bpl .1 bpl .1
lda DevMgr.LastDevID Save Dev.ID in the driver for SELECT ldy #S.DEV.JMP Setup Main JMP
ldy #S.DEV.ID lda DevMgr.Free
sta (pDev),y sta (ZPQuickPtr2),y
tax
iny
lda DevMgr.Free+1
sta (ZPQuickPtr2),y
stx ZPQuickPtr2 set Ptr2 to Dest CODE
sta ZPQuickPtr2+1
ldy #H.BIN.DRV.CODE.O ldy #H.BIN.DRV.CODE.O
lda (pDrv),y lda (pDrv),y
@ -249,10 +212,7 @@ BIN.MoveDRV ldy #H.BIN.DRV.DEVCTRLBLK.O
iny iny
lda (pDrv),y lda (pDrv),y
adc pDrv+1 adc pDrv+1
sta ZPQuickPtr1+1 Make ZPQuickPtr1=DRV.CODE sta ZPQuickPtr1+1 set Ptr1 to Src CODE
>LDYA DevMgr.Free
>STYA ZPQuickPtr2 Make ZPQuickPtr1=Dest location in LC
lda BIN.InstallDRV.DrvLen+1 lda BIN.InstallDRV.DrvLen+1
eor #$ff eor #$ff
@ -263,11 +223,11 @@ BIN.MoveDRV ldy #H.BIN.DRV.DEVCTRLBLK.O
ldy #0 ldy #0
.2 inx .2 inx Move CODE in LC
bne .3 bne .3
pla pla
dec inc
beq .8 beq .4
pha pha
.3 lda (ZPQuickPtr1),y .3 lda (ZPQuickPtr1),y
@ -278,7 +238,25 @@ BIN.MoveDRV ldy #H.BIN.DRV.DEVCTRLBLK.O
inc ZPQuickPtr2+1 inc ZPQuickPtr2+1
bra .2 bra .2
.8 rts .4 ldy #H.BIN.DRV.CODE.LEN
lda DevMgr.Free Make Ptr1 = code start
sta ZPQuickPtr1
clc
adc (pDrv),y
sta ZPQuickPtr2
iny
lda DevMgr.Free+1
sta ZPQuickPtr1+1
adc (pDrv),y
sta ZPQuickPtr2+1 Make ZPQuickPtr2 = ZPQuickPtr1 + CodeLen
jsr BIN.RelocateDRV
>LDYA BIN.InstallDRV.DrvEnd
>STYA DevMgr.Free
clc
rts
*-------------------------------------- *--------------------------------------
BIN.InstallDRV.DrvLen .BS 2 BIN.InstallDRV.DrvLen .BS 2
BIN.InstallDRV.DrvEnd .BS 2 BIN.InstallDRV.DrvEnd .BS 2
@ -306,9 +284,15 @@ BIN.Relocate.Offset .BS 2
BIN.RelocateEXE ldy #H.BIN.HEADER+1 BIN.RelocateEXE ldy #H.BIN.HEADER+1
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
cmp /H.BIN.HEADER.BIN65 cmp /H.BIN.HEADER.BIN65
bne * beq .1
cmp /H.BIN.HEADER.DRV65
beq .1
ldy #H.BIN.JMP relocate Main JMP lda #SYSMGR.ERRIBIN
sec
rts
.1 ldy #H.BIN.JMP relocate Main JMP
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
clc clc
adc BIN.Relocate.Offset adc BIN.Relocate.Offset

14
SYS/KERNEL.S.DAT.txt Normal file
View File

@ -0,0 +1,14 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
ENV.DRV >PSTRING "DRV"
ENV.LIB >PSTRING "LIB"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DAT
LOAD SYS/KERNEL.S
ASM

View File

@ -42,6 +42,7 @@ K.LoadDrvYA >STYA K.LoadDrv.CmdArray
inc ZPQuickPtr1+1 inc ZPQuickPtr1+1
.1 >LDYA ZPQuickPtr1 .1 >LDYA ZPQuickPtr1
jsr pDrvJmp call Dev.Detect jsr pDrvJmp call Dev.Detect
bcs .97 bcs .97
@ -73,7 +74,6 @@ K.LoadDrvYA >STYA K.LoadDrv.CmdArray
sec sec
rts rts
*-------------------------------------- *--------------------------------------
ENV.DRV >PSTRING "DRV"
K.LoadDrv.CmdArray .BS 2 K.LoadDrv.CmdArray .BS 2
K.LoadDrv.hFullName .BS 1 K.LoadDrv.hFullName .BS 1
K.LoadDrv.hMem .BS 1 K.LoadDrv.hMem .BS 1

View File

@ -13,8 +13,7 @@ AUTO 6
* Y,A = PSTR to FilePath (PSTRING) * Y,A = PSTR to FilePath (PSTRING)
* X = hMem to FilePath * X = hMem to FilePath
*-------------------------------------- *--------------------------------------
K.FileSearch >DEBUG K.FileSearch >PULLW ZPQuickPtr4 ZPQuickPtr1 trashed by ExpandPStrYA
>PULLW ZPQuickPtr4 ZPQuickPtr1 trashed by ExpandPStrYA
>PULLYA Get Search list >PULLYA Get Search list
>SYSCALL SYS.ExpandPStrYA Expand it (SYSCALL to BNK1) >SYSCALL SYS.ExpandPStrYA Expand it (SYSCALL to BNK1)
bcs .99 bcs .99
@ -66,13 +65,13 @@ K.FileSearch >DEBUG
jsr K.FreeMemA jsr K.FreeMemA
>LDYAI KrnBuf256 >LDYAI KrnBuf256
>SYSCALL SYS.NewPStrYA >SYSCALL SYS.NewPStrYA
rts .99 rts
.98 lda K.FileSearch.hSrch Discard Expanded hSrch list .98 lda K.FileSearch.hSrch Discard Expanded hSrch list
jsr K.FreeMemA jsr K.FreeMemA
lda #SYSMGR.ERRFNF lda #SYSMGR.ERRFNF
sec sec
.99 rts rts
*-------------------------------------- *--------------------------------------
K.FileSearch.hSrch .BS 1 K.FileSearch.hSrch .BS 1
K.FileSearch.Index .BS 1 K.FileSearch.Index .BS 1

View File

@ -17,6 +17,9 @@ Kernel.Init3 jsr K.DevMgrInit
ldx #DEVMGR.SELECT ldx #DEVMGR.SELECT
jsr pDevJmp jsr pDevJmp
lda #2
sta A2osX.ASCREEN
>LDYAI MSG.Init3 >LDYAI MSG.Init3
>SYSCALL SYS.PStrOutYA >SYSCALL SYS.PStrOutYA

View File

@ -89,7 +89,6 @@ K.UnloadLibA pha
pla pla
jmp K.FreeMemA jmp K.FreeMemA
*-------------------------------------- *--------------------------------------
ENV.LIB >PSTRING "LIB"
MAN MAN
SAVE SYS/KERNEL.S.LIB SAVE SYS/KERNEL.S.LIB
LOAD SYS/KERNEL.S LOAD SYS/KERNEL.S

View File

@ -94,6 +94,7 @@ A2osX.D002.END .EQ *
A2osX.E000 .EQ * A2osX.E000 .EQ *
.PH $E000 .PH $E000
.INB SYS/KERNEL.S.JMP .INB SYS/KERNEL.S.JMP
.INB SYS/KERNEL.S.DAT
.INB SYS/KERNEL.S.IRQ .INB SYS/KERNEL.S.IRQ
.INB SYS/KERNEL.S.MEM .INB SYS/KERNEL.S.MEM
*-------------------------------------- *--------------------------------------