Commit 20bf84a4 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Squeeze code adjusted to be StrongARM compatible.

Detail:
  The code inserted by squeeze into an application to perform
    unsqueezing is now StrongARM compatible and no longer relies
    on the presence of the UnsqueezeAIF module.  Since it has
    better information on what it's been updating, it can actually
    make a superior call to OS_SynchroniseCodeAreas marking the
    exact area of memory that it has updated.
Admin:
  Tested on Risc PC with UnsqueezeAIF unplugged.

Version 5.03. Tagged as 'squeeze-5_03'
parent 28eebfef
/* (5.02) /* (5.03)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 5.02 #define Module_MajorVersion_CMHG 5.03
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 11 Nov 1999 #define Module_Date_CMHG 10 Dec 1999
#define Module_MajorVersion "5.02" #define Module_MajorVersion "5.03"
#define Module_Version 502 #define Module_Version 503
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "11 Nov 1999" #define Module_Date "10 Dec 1999"
#define Module_FullVersion "5.02" #define Module_FullVersion "5.03"
...@@ -641,6 +641,8 @@ static char *writeunsqueeze(char *out, int execoffset) ...@@ -641,6 +641,8 @@ static char *writeunsqueeze(char *out, int execoffset)
} }
rotr -= 8; rotr -= 8;
} }
*p++ = SUB_R1_R8_IMM4;
*p++ = SWI_XOS_SynchroniseCodeAreas;
*p++ = MOV_PC_R8; *p++ = MOV_PC_R8;
return((char *)p); return((char *)p);
} }
......
...@@ -70,3 +70,5 @@ typedef struct SqueezeHeader { ...@@ -70,3 +70,5 @@ typedef struct SqueezeHeader {
#define MOV_R0_R0 0xe1a00000 #define MOV_R0_R0 0xe1a00000
#define LDR_PC_R8_MINUS4 0xe518f004 #define LDR_PC_R8_MINUS4 0xe518f004
#define NV (0xf0000000 - 0xe0000000) #define NV (0xf0000000 - 0xe0000000)
#define SUB_R1_R8_IMM4 (0xE2481004)
#define SWI_XOS_SynchroniseCodeAreas (0xEF02006E)
...@@ -50,11 +50,11 @@ asmcall_call ...@@ -50,11 +50,11 @@ asmcall_call
MOV r1, r2 MOV r1, r2
MOV r2, r3 MOV r2, r3
MOV lk, pc MOV lk, pc
MOVS pc, ip MOV pc, ip
asmcall_exit asmcall_exit
NOP ; 2 spurious instructions here in case the caller NOP ; 2 spurious instructions here in case the caller
NOP ; forgets to allow for prefetch ... NOP ; forgets to allow for prefetch ...
ADR ip, asmcall_savedregs ADR ip, asmcall_savedregs
LDMIA ip, {r4-lk} LDMIA ip, {r4-lk}
MOVS pc, lk MOV pc, lk
END END
...@@ -81,7 +81,7 @@ unsqueeze_base MOV r0, r0 ...@@ -81,7 +81,7 @@ unsqueeze_base MOV r0, r0
upcall_handler SUB r12, r0, #256 upcall_handler SUB r12, r0, #256
CMP r12, #1 CMP r12, #1
MOVEQ r0, #0 MOVEQ r0, #0
MOVS pc, lr MOV pc, lr
unsqueeze_end DCD 0 unsqueeze_end DCD 0
......
...@@ -104,9 +104,11 @@ MinLong * 2 ...@@ -104,9 +104,11 @@ MinLong * 2
|UnSqueeze_UnSqueezeBase| |UnSqueeze_UnSqueezeBase|
|UnsqueezeAIFImage| |UnsqueezeAIFImage|
; If it was an AIF image, we enter here and overwrite the BL decompress ; If it was an AIF image, we enter here and overwrite the BL decompress
MOV R0, #&FB000000 ; hex for instruction BLNV $+0 MOV R0, #&E1000000 ; hex for instruction MOV r0, r0
BIC R1, LR, #&FC000000 ; clear status bits ORR R0, R0, #&00A00000
STR R0, [R1, #-4] ; overwrite the instruction we just BL'ed from SUB R1, LR, PC ; mode independent status bit removal
ADD R1, PC, R1 ; R1 = LR (- any PSR bits if there) + 4
STR R0, [R1, #-8]! ; overwrite the instruction we just BL'ed from
|UnsqueezeADFSImage| |UnsqueezeADFSImage|
; We arrive here knowing very little about anything. ; We arrive here knowing very little about anything.
...@@ -131,15 +133,21 @@ MinLong * 2 ...@@ -131,15 +133,21 @@ MinLong * 2
CMP R6, R8 ; find highest of top of squeezed and unsqueezed image CMP R6, R8 ; find highest of top of squeezed and unsqueezed image
MOVLT R6, R8 ; use SWI if you prefer... (UNIX ?) MOVLT R6, R8 ; use SWI if you prefer... (UNIX ?)
[ expand_memcheck
TEQ r1, #&8000 ; AIF at &8000 - application?
]
; Allocate space for tables ; Allocate space for tables
ADD R1, R11, R12 ; nLongs + nShorts ADD R1, R11, R12 ; nLongs + nShorts
ADD R7, R6, R1, LSL #2 ; curFree += (nLongs + nShorts) * 4; ADD R7, R6, R1, LSL #2 ; curFree += (nLongs + nShorts) * 4;
[ expand_memcheck [ expand_memcheck
BNE %FT05
SWI OS_GetEnv SWI OS_GetEnv
ADD R2,R7, #(8 + runImage - decodeImage) ADD R2,R7, #(8 + runImage - decodeImage)
CMP R1,R2 CMP R1,R2
BLO expand_would_overwrite BLO expand_would_overwrite
05
] ]
MOV R5, R10 ; R5 is ptr into encoded tables MOV R5, R10 ; R5 is ptr into encoded tables
...@@ -235,13 +243,21 @@ moveRestOfCode ...@@ -235,13 +243,21 @@ moveRestOfCode
; Decompression is going to scribble on us here, so copy the ; Decompression is going to scribble on us here, so copy the
; rest of the code up into free space. ; rest of the code up into free space.
ADR R5, decodeImage ADR R5, decodeImage
ADR R6, |UnSqueeze_UnSqueezeLimit|+16 ; allow for branch to exec addr ADR R6, |UnSqueeze_UnSqueezeLimit|+24 ; allow for branch to exec addr
MOV R4, R7 ; we will jump to R4 MOV R4, R7 ; we will jump to R4
; The following code is what is recognised by UnSqzAIF to interfere
; in the decompression (to do OS_SynchroniseCodeAreas). Changing it
; will stop it interfering.
moveCode moveCode
LDMIA R5!, {R0-R3} LDMIA R5!, {R0-R3}
STMIA R7!, {R0-R3} ; NB this updates free space pointer as we go STMIA R7!, {R0-R3} ; NB this updates free space pointer as we go
CMPS R5, R6 CMPS R5, R6
BLT moveCode BLT moveCode
MOV R1, R7 ; this instruction causes a non-match in UnSqzAIF
ADD R2, R1, #|UnSqueeze_UnSqueezeLimit|+28-decodeImage
MOV R0, #1
SWI XOS_SynchroniseCodeAreas ; we've written some code.
MOV PC, R4 ; jump to the new copy of the rest of the code MOV PC, R4 ; jump to the new copy of the rest of the code
[ expand_memcheck [ expand_memcheck
...@@ -381,8 +397,12 @@ moveEncoded ...@@ -381,8 +397,12 @@ moveEncoded
; Now R8 should be a pointer to the first word of the decoded image, ; Now R8 should be a pointer to the first word of the decoded image,
; so lets cross our fingers and jump to it... ; so lets cross our fingers and jump to it...
runImage runImage
; MOV PC, R8 ADR r2, decodeImage-4
; changed in version 0.15 - now mod.squeeze generates jump to exec address MOV R0, #1
; [up to 3 SUB instructions here] R8 adjusted to point back to AIF header
; SUB R1, R8, #4
; SWI XOS_SynchroniseCodeAreas
; MOV PC, R8
|UnSqueeze_UnSqueezeLimit| |UnSqueeze_UnSqueezeLimit|
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment