mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
reloc: store ReadHandle and pHunks pointers in frame pointer
This commit is contained in:
parent
1cf84db951
commit
19307ccdac
@ -1,5 +1,5 @@
|
|||||||
; reloc.S
|
; reloc.S
|
||||||
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a4091-software
|
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a3091-software
|
||||||
INCLUDE "exec/memory.i"
|
INCLUDE "exec/memory.i"
|
||||||
INCLUDE "lvo/exec_lib.i"
|
INCLUDE "lvo/exec_lib.i"
|
||||||
|
|
||||||
@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
NUM_ENTRIES EQU 5
|
NUM_ENTRIES EQU 5
|
||||||
|
|
||||||
|
; Frame pointer offsets
|
||||||
|
PHUNKS EQU -4
|
||||||
|
READHANDLE_TYPE EQU -8
|
||||||
|
READHANDLE_CURRENT EQU -12
|
||||||
|
FP_SIZE EQU READHANDLE_CURRENT
|
||||||
|
|
||||||
; API:
|
; API:
|
||||||
; Zorro ROM access:
|
; Zorro ROM access:
|
||||||
; a0: rombase
|
; a0: rombase
|
||||||
@ -19,6 +25,7 @@ NUM_ENTRIES EQU 5
|
|||||||
public _relocate
|
public _relocate
|
||||||
_relocate
|
_relocate
|
||||||
movem.l d1-d7/a0-a6,-(sp)
|
movem.l d1-d7/a0-a6,-(sp)
|
||||||
|
link a4,#FP_SIZE
|
||||||
|
|
||||||
bsr InitHandle
|
bsr InitHandle
|
||||||
|
|
||||||
@ -39,7 +46,7 @@ _relocate
|
|||||||
; Go through hunk header and allocate all segments
|
; Go through hunk header and allocate all segments
|
||||||
move.l 4,a6 ; execbase
|
move.l 4,a6 ; execbase
|
||||||
|
|
||||||
move.l pHunks(pc),a2 ; segment pointers
|
move.l PHUNKS(a4),a2 ; segment pointers
|
||||||
lea.l 4*NUM_ENTRIES(a2),a3 ; segment lengths
|
lea.l 4*NUM_ENTRIES(a2),a3 ; segment lengths
|
||||||
.AllocateLoop
|
.AllocateLoop
|
||||||
moveq.l #MEMF_PUBLIC,d1
|
moveq.l #MEMF_PUBLIC,d1
|
||||||
@ -54,7 +61,7 @@ _relocate
|
|||||||
move.l d0,(a2)+ ; segment pointer
|
move.l d0,(a2)+ ; segment pointer
|
||||||
dbra d7,.AllocateLoop
|
dbra d7,.AllocateLoop
|
||||||
|
|
||||||
move.l pHunks(pc),a5
|
move.l PHUNKS(a4),a5
|
||||||
.HunkLoop
|
.HunkLoop
|
||||||
move.l (a5),a0 ; current hunk
|
move.l (a5),a0 ; current hunk
|
||||||
bsr RomFetch32
|
bsr RomFetch32
|
||||||
@ -85,6 +92,7 @@ _relocate
|
|||||||
ENDIF
|
ENDIF
|
||||||
bsr .RelocateCleanup
|
bsr .RelocateCleanup
|
||||||
moveq.l #0,d0 ; NULL = Failure
|
moveq.l #0,d0 ; NULL = Failure
|
||||||
|
unlk a4
|
||||||
movem.l (sp)+,d1-d7/a0-a6
|
movem.l (sp)+,d1-d7/a0-a6
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -129,16 +137,16 @@ _relocate
|
|||||||
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
||||||
|
|
||||||
lsl.l #2,d2 ; *4 ; offset from Hunks
|
lsl.l #2,d2 ; *4 ; offset from Hunks
|
||||||
move.l pHunks(pc),a2
|
move.l PHUNKS(a4),a2
|
||||||
add.l d2,a2 ; hunk number num
|
add.l d2,a2 ; hunk number num
|
||||||
move.l (a2),d3 ; base address of hunk
|
move.l (a2),d3 ; base address of hunk
|
||||||
|
|
||||||
.Reloc32Tight
|
.Reloc32Tight
|
||||||
bsr RomFetch32
|
bsr RomFetch32
|
||||||
; get baseaddr + d0, add d3 to the data there.
|
; get baseaddr + d0, add d3 to the data there.
|
||||||
move.l a0,a4
|
move.l a0,a3
|
||||||
add.l d0,a4
|
add.l d0,a3
|
||||||
add.l d3,(a4)
|
add.l d3,(a3)
|
||||||
dbra d1,.Reloc32Tight
|
dbra d1,.Reloc32Tight
|
||||||
|
|
||||||
bra .HunkReloc32
|
bra .HunkReloc32
|
||||||
@ -158,21 +166,21 @@ _relocate
|
|||||||
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
||||||
|
|
||||||
lsl.l #2,d2 ; *4 ; offset from Hunks
|
lsl.l #2,d2 ; *4 ; offset from Hunks
|
||||||
move.l pHunks(pc),a2
|
move.l PHUNKS(a4),a2
|
||||||
add.l d2,a2 ; hunk number num
|
add.l d2,a2 ; hunk number num
|
||||||
move.l (a2),d3 ; base address of hunk
|
move.l (a2),d3 ; base address of hunk
|
||||||
|
|
||||||
.Reloc32ShortTight
|
.Reloc32ShortTight
|
||||||
bsr RomFetch16
|
bsr RomFetch16
|
||||||
; get baseaddr + d0, add d3 to the data there.
|
; get baseaddr + d0, add d3 to the data there.
|
||||||
move.l a0,a4
|
move.l a0,a3
|
||||||
add.l d0,a4
|
add.l d0,a3
|
||||||
add.l d3,(a4)
|
add.l d3,(a3)
|
||||||
dbra d1,.Reloc32ShortTight
|
dbra d1,.Reloc32ShortTight
|
||||||
|
|
||||||
bra .HunkReloc32Short
|
bra .HunkReloc32Short
|
||||||
.HunkLoopPrep
|
.HunkLoopPrep
|
||||||
lea ReadHandle(pc),a2
|
lea READHANDLE_CURRENT(a4),a2
|
||||||
move.l (a2),d0 ; align pointer to longword
|
move.l (a2),d0 ; align pointer to longword
|
||||||
addq.l #2,d0 ; in case we had an odd number
|
addq.l #2,d0 ; in case we had an odd number
|
||||||
and.l #$fffffffc,d0 ; of relocations
|
and.l #$fffffffc,d0 ; of relocations
|
||||||
@ -202,17 +210,18 @@ _relocate
|
|||||||
|
|
||||||
bsr.s CreateSegList
|
bsr.s CreateSegList
|
||||||
|
|
||||||
move.l pHunks(pc),a0
|
move.l PHUNKS(a4),a0
|
||||||
move.l (a0),d2
|
move.l (a0),d2
|
||||||
subq.l #4,d2
|
subq.l #4,d2
|
||||||
|
|
||||||
bsr.s .RelocateCleanup
|
bsr.s .RelocateCleanup
|
||||||
move.l d2,d0
|
move.l d2,d0
|
||||||
|
unlk a4
|
||||||
movem.l (sp)+,d1-d7/a0-a6
|
movem.l (sp)+,d1-d7/a0-a6
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.RelocateCleanup
|
.RelocateCleanup
|
||||||
move.l pHunks(pc),a1
|
move.l PHUNKS(a4),a1
|
||||||
moveq.l #(8*NUM_ENTRIES),d0
|
moveq.l #(8*NUM_ENTRIES),d0
|
||||||
jsr _LVOFreeMem(a6)
|
jsr _LVOFreeMem(a6)
|
||||||
rts
|
rts
|
||||||
@ -233,7 +242,7 @@ _relocate
|
|||||||
; +->| | | | 0| | | | | 0|
|
; +->| | | | 0| | | | | 0|
|
||||||
; +--+--+--+--+ +--+--+--+--+
|
; +--+--+--+--+ +--+--+--+--+
|
||||||
CreateSegList:
|
CreateSegList:
|
||||||
move.l pHunks(pc),a0
|
move.l PHUNKS(a4),a0
|
||||||
|
|
||||||
.NextSeg
|
.NextSeg
|
||||||
move.l (a0),a1 ; Hunks[x]
|
move.l (a0),a1 ; Hunks[x]
|
||||||
@ -269,10 +278,10 @@ RomFetch32
|
|||||||
|
|
||||||
RomFetch
|
RomFetch
|
||||||
movem.l a0-a1/d1-d3,-(sp)
|
movem.l a0-a1/d1-d3,-(sp)
|
||||||
lea ReadHandle(pc),a1
|
lea READHANDLE_CURRENT(a4),a1
|
||||||
move.l (a1),a0
|
move.l (a1),a0
|
||||||
|
|
||||||
tst.l 4(a1) ; access type Zorro?
|
tst.l READHANDLE_TYPE(a4) ; access type Zorro?
|
||||||
bne.s .RomFetchZ
|
bne.s .RomFetchZ
|
||||||
|
|
||||||
cmp.b #3,d0
|
cmp.b #3,d0
|
||||||
@ -310,7 +319,7 @@ RomFetch
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
InitHandle
|
InitHandle
|
||||||
; initialize readhandle to beginning of device driver
|
; initialize READHANDLE_CURRENT to beginning of device driver
|
||||||
; ROM_OFFSET needs to be multiplied by 4 because of the
|
; ROM_OFFSET needs to be multiplied by 4 because of the
|
||||||
; nibble mapped nature of the AutoConfig ROM.
|
; nibble mapped nature of the AutoConfig ROM.
|
||||||
; ROM_ADDRESS is passed in a0
|
; ROM_ADDRESS is passed in a0
|
||||||
@ -320,24 +329,15 @@ InitHandle
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
add.l d0,a0
|
add.l d0,a0
|
||||||
lea ReadHandle(pc),a1
|
move.l a0,READHANDLE_CURRENT(a4) ; memory location passed in a0
|
||||||
move.l a0,(a1) ; memory location passed in a0
|
move.l d0,READHANDLE_TYPE(a4) ; Set access type: 0 = memory, Zorro otherwise
|
||||||
move.l d0,4(a1) ; Set access type: 0 = memory, Zorro otherwise
|
|
||||||
|
|
||||||
moveq.l #(8*NUM_ENTRIES),d0
|
moveq.l #(8*NUM_ENTRIES),d0
|
||||||
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
|
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
|
||||||
jsr _LVOAllocMem(a6)
|
jsr _LVOAllocMem(a6)
|
||||||
lea pHunks(pc),a1
|
move.l d0,PHUNKS(a4)
|
||||||
move.l d0,(a1)
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
ReadHandle
|
|
||||||
dc.l 0 ; Current address
|
|
||||||
dc.l 0 ; 0=memory, otherwise Zorro
|
|
||||||
|
|
||||||
pHunks
|
|
||||||
dc.l 0
|
|
||||||
|
|
||||||
IFD HAVE_ERRNO
|
IFD HAVE_ERRNO
|
||||||
public _rErrno
|
public _rErrno
|
||||||
_rErrno
|
_rErrno
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user