Commit d4b36dc7 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Merged to trunk.

Detail:
  Work in progress for 32-bit support.
Admin:
  Do not use this version.
  Now uses srccommit.
  Now uses objasm.

Version 0.05. Tagged as 'UnSqzAIF-0_05'
parent 632805f7
......@@ -23,19 +23,22 @@ EXP_HDR = <export$dir>
# Generic options:
#
MKDIR = cdir
AS = aasm
AS = objasm
CP = copy
LD = link
RM = remove
CCFLAGS = -c -depend !Depend -IC:
ASFLAGS = -depend !Depend -Stamp -quit -module -To $@ -From
ASFLAGS = -depend !Depend -Stamp -quit -module
CPFLAGS = ~cfr~v
LDFLAGS = -bin -base 0
#
# Program specific options:
#
COMPONENT = UnSqzAIF
SOURCE = s.Front
SOURCE = s.ModHead
TARGET = rm.UnSqzAIF
OBJECT = o.ModHead
#
# Generic rules:
......@@ -49,9 +52,15 @@ install_rom: ${TARGET}
clean:
${RM} ${TARGET}
${RM} o
@echo ${COMPONENT}: cleaned
${TARGET}: ${SOURCE}
${AS} ${ASFLAGS} ${SOURCE}
${TARGET}: ${OBJECT}
${LD} ${LDFLAGS} -o $@ ${OBJECT}
settype $@ Module
${OBJECT}: ${SOURCE}
${MKDIR} o
${AS} ${ASFLAGS} -o $@ ${SOURCE}
# Dynamic dependencies:
; > Version
;; History:
GBLA Version
GBLS VString
GBLS Date
Version SETA 003
VString SETS "0.03"
Date SETS "10 Jul 1996"
END
;
; This file is automatically maintained by srccommit, do not edit manually.
;
GBLS Module_MajorVersion
GBLA Module_Version
GBLS Module_MinorVersion
GBLS Module_Date
GBLS Module_FullVersion
Module_MajorVersion SETS "0.05"
Module_Version SETA 5
Module_MinorVersion SETS ""
Module_Date SETS "30 Nov 1999"
Module_FullVersion SETS "0.05"
END
/* (0.05)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.05
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 30 Nov 1999
#define Module_MajorVersion "0.05"
#define Module_Version 5
#define Module_MinorVersion ""
#define Module_Date "30 Nov 1999"
#define Module_FullVersion "0.05"
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.Front
;;-----------------------------------------------------------------------------
;; Decompression module for squeezed AIF files with intact AIF header
;;-----------------------------------------------------------------------------
Module_BaseAddr
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Services
GET Hdr:ModHand
GET Hdr:MsgTrans
GET Hdr:NdrDebug
GET Version
GBLL hostvdu
GBLL debugwt
debug SETL false
debugwt SETL true ; Misc debugging by WT
hostvdu SETL false
; ----------------------------------------------------------------------------------------------------------------------
; Definitions
; ----------------------------------------------------------------------------------------------------------------------
; Workspace layout
workspace RN R12
^ 0,workspace
! 0, "Module workspace is &":CC:(:STR:(:INDEX:@)):CC:" bytes"
; ----------------------------------------------------------------------------------------------------------------------
LNK s.ModHead
......@@ -13,10 +13,34 @@
; limitations under the License.
;
; > Sources.ModHead
LEADR Module_LoadAddr
ASSERT (.=Module_BaseAddr)
;;-----------------------------------------------------------------------------
;; Decompression module for squeezed AIF files with intact AIF header
;;-----------------------------------------------------------------------------
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Services
GET Hdr:ModHand
GET Hdr:MsgTrans
GET Hdr:NdrDebug
GET VersionASM
GBLL hostvdu
GBLL debugwt
debug SETL false
debugwt SETL false
hostvdu SETL false
! 0, "Module workspace is &":CC:(:STR:(:INDEX:@)):CC:" bytes"
; ----------------------------------------------------------------------------------------------------------------------
AREA |!!!ModuleHeader|, CODE, READONLY, PIC
Module_BaseAddr
DCD 0
DCD Initialise - Module_BaseAddr
DCD 0
......@@ -24,17 +48,28 @@
DCD Title - Module_BaseAddr
DCD Helpstr - Module_BaseAddr
DCD 0 ; Helptable
[ :LNOT: No32bitCode
DCD 0 ; SWIbase
DCD 0
DCD 0
DCD 0 ; SWI handler code
DCD 0 ; SWI decode table
DCD 0 ; SWIdecode
DCD 0
DCD 0
DCD 0 ; International messages
DCD ModuleFlags - Module_BaseAddr ; Module flags
]
; ---------------------------------------------------------------------------------------------------
Title DCB "UnSqueezeAIF",0
Helpstr DCB "UnSqueezeAIF",9,"$VString ($Date)",0
ALIGN
Helpstr DCB "UnSqueezeAIF",9,"$Module_MajorVersion ($Module_Date)"
[ Module_MinorVersion <> ""
DCB " $Module_MinorVersion"
]
DCB 0
ALIGN
[ :LNOT: No32bitCode
ModuleFlags
DCD 1 ; Module is 32-bit safe
]
; ---------------------------------------------------------------------------------------------------
......@@ -69,27 +104,30 @@ notneedederror
DCB "UnSqueezeAIF not needed on this platform",0
ALIGN
Service
ROUT
ServiceTable
DCD 0 ;flags
DCD UService - Module_BaseAddr
DCD Service_UKCompression
DCD 0 ;terminator
DCD ServiceTable - Module_BaseAddr
Service ROUT
MOV r0, r0 ;magic instruction
TEQ r1, #Service_UKCompression
MOVNES pc, lr ;Not our service.
CMP r0, #0 ;Is it the pre-decompression call?
MOVNES pc, lr ;No, so we're not interested.
MOVNE pc, lr ;Not our service.
UService
CMP r0, #0 ;Is it the pre-decompression call?
MOVNE pc, lr ;No, so we're not interested.
Push "r0,r2-r6,lr"
LDR r0,[r12]
ANDS r0,r0,#1
Pull "r0,r2-r6,pc",EQ,^ ; forget it if not needed
Pull "r0,r2-r6,pc",EQ ; forget it if not needed
;Check whether the file is an AIF-headered file.
LDR lr, [r2, #&10] ; We know R2 is &8000, 'cos it's an app
MOV r0, #&EF000000 ; 'SWI'
ORR r0, r0, #&0011 ; 'OS_Exit'
CMP r0, lr ; Is the 5th word a 'SWI OS_Exit'?
EOR r0, lr, #&EF000000 ; 'SWI'
EORS r0, r0, #&0011 ; 'OS_Exit' Is the 5th word a 'SWI OS_Exit'?
MOVEQ r6,#1
MOVNE r6,#0 ;flag AIF/non-AIF
[ :LNOT: AllowNonAIF
......@@ -107,12 +145,13 @@ Service
;there's nothing to do, so quit, unclaimed.
01 MOV r1, #Service_UKCompression
Debug wt,"give up 1"
Pull "r0,r2-r6,pc",,^
Pull "r0,r2-r6,pc"
02
LDR lr,[r2]
BIC lr,lr,#&FF000000
ADD r0,r2,lr,LSL #2 ;add offset of branch in bytes (should be +ve)
MOVS lr, lr, LSL #8 ;remove top 8 bits
BMI %BT01 ;negative? nasty branch - forget this code
ADD r0,r2,lr,ASR #6 ;add offset of branch in bytes (should be +ve)
ADD r0,r0,#8 ;and account for PC+8
ADR r4,UnsqSignature
......@@ -134,7 +173,7 @@ Service
;give up
04 MOV r1, #Service_UKCompression
Debug wt,"give up 2"
Pull "r0,r2-r6,pc",,^
Pull "r0,r2-r6,pc"
05 ;found 1st word of signature
MOV r3,#UnsqSigSize-4
......@@ -159,7 +198,7 @@ Service
ADR r5,CopySyncAndGoR4
STR r5,[r4],#4
;if non-AIF, can't fix-up header to unsqueeze first, so cliam and return now
;if non-AIF, can't fix-up header to unsqueeze first, so claim and return now
;this means code can't really be patched after unsqueeze, but at least the
;unsqueeze is fixed
;
......@@ -167,22 +206,19 @@ Service
;because we know FileSwitch does a sychronise, after this service call (after
;the next service call, for patching, in fact)
CMP r6,#0
MOVEQ r1, #0 ; Mark it as claimed.
Pull "r0,r2-r6,pc",EQ,^ ; That's all folks!
ANDS r1, r6, #1 ; AIF bit set? If not, set Z, R1=0
Pull "r0,r2-r6,pc",EQ ; That's all folks!
;Now calculate the B needed to get back here once it's unsqueezed
Debug wt,"It's a squeezed AIF file which we can handle!"
ADR r0, retfrmunsq
MOV r2, #&8000
ADD r2, r2, #&14
MOV r1, #&8000
ADD r2, r1, #&14
SUB r0, r0, r2 ; R0 is the offset, accounting for PC+8
MOV r2, #&EA000000 ; Create the BAL bit of the instruction
ORR r0, r2, r0, LSR #2 ; OR in the offset
MOV r1, #&8000
ADD r1, r1, #&0C
LDR lr, [r1] ; Grab what was at the ImageEntryPoint
LDR lr, [r1, #&0C]! ; Grab what was at the ImageEntryPoint
STR r0, [r1] ; Replace it with the branch
Push "lr" ; Stuff it safe on the stack, along with the cache status
Debug wt,"synchronise"
......@@ -190,9 +226,13 @@ Service
SWI XOS_SynchroniseCodeAreas ; we've been poking code
LDR lr,[sp]
;Now go do the unsqueeze
TEQP pc, #0 ; USR mode, all ints on
MOV r12, #&80000000 ; Cause address extinction if used
MOV r13, #&80000000 ; (keep 1.20 compat capable)
MOV r0, #0
MRS r0, CPSR
BICS r0, r0, #&F ; SVC32->USR32; SVC26->USR26
TEQEQP pc, #Z_bit ; USR26, retain Z set
MSRNE CPSR_c, r0 ; USR mode, all ints on
MVN r12, #0 ; Cause address extinction if used
MOV r13, r12 ; (keep 1.20 compat capable)
MOV pc, #&8000 ; Away the noo!
retfrmunsq
......@@ -200,17 +240,15 @@ retfrmunsq
SWI XOS_EnterOS ; Back into SVC mode
Pull "r1"
Debug wt,"back from unsqueeze",r1
MOV r0, #&8000
ADD r0, r0, #&0C
STR r1, [r0] ; Put the ImageEntryPoint instruction back!
MOV r4, r0 ; This is the new execution point
MOV r4, #&8000 ; Construct the new execution point
STR r1, [r4, #&C]! ; Put the ImageEntryPoint instruction back!
MOV r0,#1
MOV r1,r4
MOV r2,r4
SWI XOS_SynchroniseCodeAreas ;we've been poking again
STR r4,[sp,#12] ; update the stacked r4
MOV r1, #0 ; Mark it as claimed.
Pull "r0,r2-r6,pc",,^ ;That's all folks!
Pull "r0,r2-r6,pc" ;That's all folks!
;code to look for
......
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