Commit 52d513c3 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Generate ROM patches from source

It looks like the source to the ROM patches got lost in one of the numerous reorganisations, so while "ROMPatch2" was here "ROMPatch3" including the crucial > 2GB drive lockup fix were lost.
* Reverse engineered ROMPatch3, see userdocs/v204/!ReadMe
* Added support to the patch tool for 2MB ROMs as used in RISC OS 3.50
* Convert the BASIC patch for 3.50 (in Sources/ROMPatch4M) into patch tool format, unfortunately it's not clear what all the patches actually do so they're mostly grouped by module with little explanation
* Removed source attribution from obey files copied to the user
* Use Push/Pull macros
Tested by applying the original patch to a ROM, saving it, then applying this patch, and diffing the result.

Version 0.95. Tagged as 'Boot-0_95'
parent f9f23b51
......@@ -59,17 +59,20 @@ FILES350 = \
RO350Hook.Boot.PreDesk.MemFix \
RO350Hook.Boot.PreDesk.DPMSUtils \
RO350Hook.Boot.PreDesk.WimpUtils \
RO350Hook.Boot.PreDesk.ROMPatch \
# Files required by a 3.6x machine
FILES360 = \
RO360Hook \
RO360Hook.Boot.Tasks.~CDReinit \
RO360Hook.Boot.PreDesk.ROMPatch \
# Files required by a 3.7x machine
FILES370 = \
RO370Hook \
RO370Hook.Boot.PreDesk.Configure.BandLimit \
RO370Hook.Boot.Tasks.~CDReinit \
RO370Hook.Boot.PreDesk.ROMPatch \
# Files required by a 4.0x machine
FILES400 = \
......@@ -112,7 +115,6 @@ install_BootUNIVERSAL: install_Configure ${FILESUNIVERSAL} install_AppFiles
@Echo Deleting superfluous files ...
${XWIPE} ${INSTAPP}.RO310Hook.Boot ${WFLAGS} # <-- Nobble 3.10 until Hdr:Generic32 fixed
${XWIPE} ${INSTAPP}.RO350Hook.Boot.Tasks.!ROMPatch ${WFLAGS}
${XWIPE} ${INSTAPP}.RO360Hook.Boot.PreDesk.ROMPatch ${WFLAGS}
${XWIPE} ${INSTAPP}.RO360Hook.Boot.PreDesk.SoundDMA ${WFLAGS}
${XWIPE} ${INSTAPP}.Utils.NetBye ${WFLAGS}
${XWIPE} ${INSTAPP}.Library.Repeat ${WFLAGS}
......@@ -130,7 +132,6 @@ install_ShareBootUNIVERSAL: install_Configure ${FILESUNIVERSAL} install_AppFiles
@Echo Deleting superfluous files ...
${XWIPE} ${INSTAPP}.RO310Hook.Boot ${WFLAGS} # <-- Nobble 3.10 until Hdr:Generic32 fixed
${XWIPE} ${INSTAPP}.RO350Hook.Boot.Tasks.!ROMPatch ${WFLAGS}
${XWIPE} ${INSTAPP}.RO360Hook.Boot.PreDesk.ROMPatch ${WFLAGS}
${XWIPE} ${INSTAPP}.RO360Hook.Boot.PreDesk.SoundDMA ${WFLAGS}
${XWIPE} ${INSTAPP}.Utils.NetBye ${WFLAGS}
${XWIPE} ${INSTAPP}.Library.Repeat ${WFLAGS}
......@@ -204,6 +205,11 @@ clean:
${XWIPE} RO370Hook.Boot.Tasks.~CDReinit ${WFLAGS}
${XWIPE} RO400Hook.Boot.Tasks.~CDReinit ${WFLAGS}
${XWIPE} Source.CDReinit.o ${WFLAGS}
${XWIPE} RO350Hook.Boot.PreDesk.*ROMPatch ${WFLAGS}
${XWIPE} RO360Hook.Boot.PreDesk.*ROMPatch ${WFLAGS}
${XWIPE} RO370Hook.Boot.PreDesk.*ROMPatch ${WFLAGS}
${XWIPE} Source.ROMPatch.o ${WFLAGS}
${XWIPE} Source.ROMPatch.Install.ROMPatch.!RunImage ${WFLAGS}
${XWIPE} RO370Hook.Boot.PreDesk.Configure.BandLimit ${WFLAGS}
${XWIPE} RO400Hook.Boot.PreDesk.Configure.BandLimit ${WFLAGS}
${XWIPE} Source.BandLimit.Source.o.BandLimit ${WFLAGS}
......@@ -282,7 +288,16 @@ RO350Hook.Boot.PreDesk.MemFix: Source.MemFix.Source.MemFix
${LD} ${LDFLAGS} -bin -o $@ Source.MemFix.o.MemFix
${SETTYPE} $@ Utility
RO360Hook.Boot.Tasks.~CDReinit RO370Hook.Boot.Tasks.~CDReinit RO400Hook.Boot.Tasks.~CDReinit: Source.CDReinit.s.CDReinit
RO350Hook.Boot.PreDesk.ROMPatch RO360Hook.Boot.PreDesk.ROMPatch RO370Hook.Boot.PreDesk.ROMPatch:
${MKDIR} Source.ROMPatch.o
${CC} ${CFLAGS} -ISource.ROMPatch -o Source.ROMPatch.o.rompatch Source.ROMPatch.c.rompatch
${AS} ${ASFLAGS} -o Source.ROMPatch.o.asmutils Source.ROMPatch.s.asmutils
${AS} ${ASFLAGS} -o Source.ROMPatch.o.module Source.ROMPatch.s.module
${LD} ${LDFLAGS} -aif -o Source.ROMPatch.Install.ROMPatch.!RunImage Source.ROMPatch.o.rompatch Source.ROMPatch.o.asmutils Source.ROMPatch.o.module ${CLIB}
${SQZ} Source.ROMPatch.Install.ROMPatch.!RunImage
${CP} Source.ROMPatch.Install $@.^ ${CPFLAGS}
RO360Hook.Boot.Tasks.~CDReinit RO370Hook.Boot.Tasks.~CDReinit RO400Hook.Boot.Tasks.~CDReinit:
${MKDIR} Source.CDReinit.o
${AS} ${ASFLAGS} -o Source.CDReinit.o.CDReinit Source.CDReinit.s.CDReinit
${LD} ${LDFLAGS} -bin -o $@ Source.CDReinit.o.CDReinit
......
| Copyright 1997 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.
|
WimpSlot -min 128K
Run <Obey$Dir>.ROMPatch.!RunImage
| Copyright 1997 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.
|
|do nothing
......@@ -37,12 +37,16 @@ Squeezeflags = -o $@
# Static dependencies:
@.o.debug: @.c.debug
cdir o
cc $(ccflags) -o @.o.debug @.c.debug
@.o.rompatch: @.c.rompatch
cdir o
cc $(ccflags) -o @.o.rompatch @.c.rompatch
@.o.asmutils: @.s.asmutils
cdir o
objasm $(objasmflags) -from @.s.asmutils -to @.o.asmutils
@.o.module: @.s.module
cdir o
objasm $(objasmflags) -from @.s.module -to @.o.module
......
......@@ -15,8 +15,10 @@
/* UK/messages.h */
#define M_name360 "ROM patches 3.60/1"
#define M_name370 "ROM patches 3.70/2"
#define M_name350 "ROM patches 3.50/2"
#define M_name360 "ROM patches 3.60/2"
#define M_name370 "ROM patches 3.70/3"
#define M_name371 "ROM patches 3.71/1"
#define E_ROMunknown "No patches for this ROM\n"
#define E_malloc "Not enough memory (malloc)\n"
......
File deleted
......@@ -18,15 +18,12 @@
#include "defs.h"
#include "debug.h"
#if Debug
#if DEBUG
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
extern uint32 logtophys(uint32 log);
extern uint32 logtopagenum(uint32 log);
/* ------------------------------------------------------------------------ */
void dbtrace_patchhits(int *romsection,int *romlpage,int *rompage)
......@@ -35,19 +32,19 @@ void dbtrace_patchhits(int *romsection,int *romlpage,int *rompage)
static char *sym = ".123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ**";
fprintf(stderr,"section hits:");
for (i=0; i<ROMsections; i++)
for (i=0; i<ROMsections(ROMsize); i++)
{
if ((i & 63) == 0) fprintf(stderr,"\n");
fprintf(stderr,"%c",sym[romsection[i]]);
}
fprintf(stderr,"\nlarge page hits:");
for (i=0; i<ROMlpages; i++)
for (i=0; i<ROMlpages(ROMsize); i++)
{
if ((i & 63) == 0) fprintf(stderr,"\n");
fprintf(stderr,"%c",sym[romlpage[i]]);
}
fprintf(stderr,"\npage hits:");
for (i=0; i<ROMpages; i++)
for (i=0; i<ROMpages(ROMsize); i++)
{
if ((i & 63) == 0) fprintf(stderr,"\n");
j = rompage[i];
......@@ -77,4 +74,4 @@ void dbtrace_DApages(int DAN, uint32 DAbase, int DAsize)
/* ------------------------------------------------------------------------ */
#endif /* Debug */
#endif /* DEBUG */
......@@ -32,7 +32,7 @@
(see patches directory for details)
*/
/* version string is maintained in s.module */
/* version string is maintained in module.s */
#include <stdio.h>
#include <stdlib.h>
......@@ -53,6 +53,9 @@ extern uint32 svcpeek(uint32 *addr);
extern void svcpoke(uint32 *addr, uint32 val);
extern void svcsetROML1PT(uint32 *L1PTaddr, uint32 *L1PTvals, int count);
/* currently considered ROM size in bytes */
uint32 ROMsize;
/* ROMs and their patches */
#include "patches/patch.h"
......@@ -111,9 +114,9 @@ static int scan_patches(patchlist_proc patchlist[],
patchentry_t *pl;
/* initialise hit tables */
for (i=0; i<ROMsections; i++) romsection[i] = 0;
for (i=0; i<ROMlpages; i++) romlpage[i] = 0;
for (i=0; i<ROMpages; i++) rompage[i] = 0;
for (i=0; i<ROMsections(ROMsize); i++) romsection[i] = 0;
for (i=0; i<ROMlpages(ROMsize); i++) romlpage[i] = 0;
for (i=0; i<ROMpages(ROMsize); i++) rompage[i] = 0;
for (Npatchpages=i=0; patchlist[i] != NULL; i++)
{
......@@ -136,13 +139,13 @@ static int scan_patches(patchlist_proc patchlist[],
exit(ErrorReturnCode);
}
/* mark section and large page hits with 1 */
romsection[(ila - ROMstart) >> 20] = 1;
romlpage[(ila - ROMstart) >> 16] = 1;;
if (rompage[(ila - ROMstart) >> 12] == 0)
romsection[ROMsections(ila - ROMstart)] = 1;
romlpage[ROMlpages(ila - ROMstart)] = 1;
if (rompage[ROMpages(ila - ROMstart)] == 0)
{
/* count newly hit pages, and mark with 1 for now */
Npatchpages++;
rompage[(ila - ROMstart) >> 12] = 1;
rompage[ROMpages(ila - ROMstart)] = 1;
}
}
}
......@@ -150,7 +153,7 @@ static int scan_patches(patchlist_proc patchlist[],
/* now rescan page hit table, and mark with ascending sequence of
hit number */
for (i=j=0; i<ROMpages; i++) if (rompage[i]) rompage[i] = ++j;
for (i=j=0; i<ROMpages(ROMsize); i++) if (rompage[i]) rompage[i] = ++j;
return Npatchpages;
}
......@@ -178,9 +181,9 @@ static int find_DA_first_pagenum(int pagesneeded, uint32 *first_pagenum)
e = _swix(OS_Memory,_IN(0)|_OUT(1),6,&tablesize);
if (e) return 0;
# if Debug
#if DEBUG
fprintf(stderr,"physical arrangement tablesize=%1d\n",tablesize);
# endif
#endif
table = malloc(tablesize);
if (table == NULL) return 0;
......@@ -194,9 +197,9 @@ static int find_DA_first_pagenum(int pagesneeded, uint32 *first_pagenum)
L1PTphys = logtophys(L1PT);
L1PTpap = L1PTphys >> 12; /* physical arrangement (4k) page index, into table */
# if Debug
#if DEBUG
fprintf(stderr,"L1PTpap=%1d end=%1d\n",L1PTpap,tablesize*2);
# endif
#endif
foundfirstpage = 0;
firstpagepap = 0;
......@@ -204,16 +207,16 @@ static int find_DA_first_pagenum(int pagesneeded, uint32 *first_pagenum)
for (pap=L1PTpap; (pap<tablesize*2) && pagestofind; pap++)
{
pt = pagetype(pap,table);
# if Debug
#if DEBUG
fprintf(stderr,"pap=0x%5.5x pt=0x%2.2x\n",pap,pt);
# endif
#endif
if (foundfirstpage)
{
/* we must collect subsequent pages that are DRAM and not marked Unavailable */
if (pt == pt_availableDRAM) pagestofind--; else foundfirstpage = 0;
# if Debug
#if DEBUG
fprintf(stderr," - %1d %5d\n",foundfirstpage,pagestofind);
# endif
#endif
}
else
{
......@@ -223,9 +226,9 @@ static int find_DA_first_pagenum(int pagesneeded, uint32 *first_pagenum)
pagestofind = pagesneeded - 1;
firstpagepap = pap;
foundfirstpage = 1;
# if Debug
#if DEBUG
fprintf(stderr," > %1d %5d\n",foundfirstpage,pagestofind);
# endif
#endif
}
}
}
......@@ -265,10 +268,10 @@ static void create_patchDA(uint32 RMAaddr, int DAsize, uint32 DAhandler_addr,
md = (moduledata_t *)((uint32)(&moddata)-(uint32)(&module)+RMAaddr);
md->nextpageneeded = first_pagenum;
md->firstpagenotneeded = first_pagenum + (DAsize >> 12);
# if Debug
#if DEBUG
fprintf(stderr,"DA page numbers 0x%1.1x..0x%1.1x\n",
md->nextpageneeded,md->firstpagenotneeded-1);
# endif
#endif
/* grow the area to DAsize */
e = _swix(OS_ChangeDynamicArea,_INR(0,1),*patchDAN,DAsize);
}
......@@ -294,7 +297,7 @@ static void fill_patchpages(patchlist_proc patchlist[],uint32 patchDAbase,
uint32 addr, *waddr, ppaddr;
/* negate rompage entries to flag 'not copied yet' */
for (i=0; i<ROMpages; i++) if (rompage[i]) rompage[i] = -rompage[i];
for (i=0; i<ROMpages(ROMsize); i++) if (rompage[i]) rompage[i] = -rompage[i];
for (i=0; patchlist[i] != NULL; i++)
{
......@@ -314,15 +317,16 @@ static void fill_patchpages(patchlist_proc patchlist[],uint32 patchDAbase,
(uint32 *)(patchDAbase + (rompage[ppage] << 12)),0x1000);
}
waddr = (uint32 *)(patchDAbase + (rompage[ppage]<<12) + (addr&0xfff));
# if Debug
#if DEBUG
fprintf(stderr," %8.8x %8.8x --> %8.8x %8.8x\n",
addr,pl[j].oldval,(int)waddr,pl[j].newval);
# endif
#endif
svcpoke(waddr,pl[j].newval);
}
}
}
UNUSED(romlpage);
UNUSED(romsection);
}
/* ------------------------------------------------------------------------ */
......@@ -355,7 +359,7 @@ static void fill_patchL2PTpage(int writeprotect, uint32 armid, uint32 patchDAbas
patchL2PT = (uint32 *)patchDAbase; /* 0'th page is used for L2PT stuff */
for (p=lp=s=0; s<ROMsections; s++)
for (p=lp=s=0; s<ROMsections(ROMsize); s++)
{
if (romsection[s])
{
......@@ -379,10 +383,10 @@ static void fill_patchL2PTpage(int writeprotect, uint32 armid, uint32 patchDAbas
ppage_physaddr = ROMphysstart + (p << 12);
}
svcpoke(patchL2PT+p,ppage_physaddr | mmu_sp);
# if Debug
#if DEBUG
fprintf(stderr,"SPG %8.8x %8.8x\n",
(int)patchL2PT+p,ppage_physaddr | mmu_sp);
# endif
#endif
}
}
else
......@@ -391,10 +395,10 @@ static void fill_patchL2PTpage(int writeprotect, uint32 armid, uint32 patchDAbas
lpage_physaddr = ROMphysstart + (lp << 16);
for (i=lp*16; i<(lp+1)*16; i++)
svcpoke(patchL2PT+i,lpage_physaddr | mmu_lp);
# if Debug
#if DEBUG
fprintf(stderr,"LPG %8.8x %8.8x\n",
(int)patchL2PT+i,lpage_physaddr | mmu_lp);
# endif
#endif
}
}
}
......@@ -402,9 +406,9 @@ static void fill_patchL2PTpage(int writeprotect, uint32 armid, uint32 patchDAbas
{
/* section map can remain, set unused L2PT to Fault */
for (i=s*256; i<(s+1)*256; i++) svcpoke(patchL2PT+i,0);
# if Debug
#if DEBUG
fprintf(stderr,"SEC %8.8x %8.8x\n",(int)patchL2PT+i,0);
# endif
#endif
}
}
......@@ -449,39 +453,40 @@ static void set_ROM_L1PT(uint32 RMAaddr, int patchDAN, uint32 patchDAbase,
*/
int i;
uint32 ROM_L1PTvalues[ROMsections];
uint32 ROM_L1PTvalues[ROMsections(ROMsize)];
moduledata_t *md;
# define MMU_L1PR 0x11 /* flag L1 descriptor as page reference */
#define MMU_L1PR 0x11 /* flag L1 descriptor as page reference */
/* current L1PT settings */
for (i=0; i<ROMsections; i++)
for (i=0; i<ROMsections(ROMsize); i++)
ROM_L1PTvalues[i] = svcpeek((uint32 *)(L1PT + (ROMstart >> 18) + (i<<2)));
/* now poke all required values into module data space, in RMA */
md = (moduledata_t *)((uint32)(&moddata)-(uint32)(&module)+RMAaddr);
md->DAN = patchDAN;
md->DAN = patchDAN;
md->sections = ROMsections(ROMsize);
md->kernL1PT = L1PT + (ROMstart >> 18);
for (i=0; i<ROMsections; i++) md->L1PTentries[i] = ROM_L1PTvalues[i];
for (i=0; i<ROMsections(ROMsize); i++) md->L1PTentries[i] = ROM_L1PTvalues[i];
/* new settings, for any sections hit by patches */
for (i=0; i<ROMsections; i++)
for (i=0; i<ROMsections(ROMsize); i++)
{
if (romsection[i])
ROM_L1PTvalues[i] = logtophys(patchDAbase + (i << 10)) | MMU_L1PR;
}
# if Debug
for (i=0; i<ROMsections; i++)
#if DEBUG
for (i=0; i<ROMsections(ROMsize); i++)
printf(" romsection %1d %8.8x\n",i,ROM_L1PTvalues[i]);
# endif
#endif
# if ReallyDoRemap
svcsetROML1PT((uint32 *)(L1PT + (ROMstart >> 18)),ROM_L1PTvalues,ROMsections);
# else
#if REALLY_DO_REMAP
svcsetROML1PT((uint32 *)(L1PT + (ROMstart >> 18)),ROM_L1PTvalues,ROMsections(ROMsize));
#else
fprintf(stderr,"** svcsetROML1PT skipped **\n");
# endif
#endif
}
......@@ -494,13 +499,14 @@ static ROMentry_t *identify_ROM(void)
for (rom=knownROMs[r=0]; rom != NULL; rom=knownROMs[++r])
{
# if Debug
#if DEBUG
fprintf(stderr,"check %s\n",rom->patchname);
# endif
#endif
ROMsize = rom->romsize << 20;
if (match_romcrc(rom->romcrc)) break;
}
# if Debug
#if DEBUG
if (rom == NULL) fprintf(stderr,E_ROMunknown);
#endif
......@@ -517,26 +523,29 @@ int main(int argc, char *argv[])
/* marked in order to construct best mapping granularity
allowed by patches (to minimise stress on processor TLB(s)) */
static int romsection[ROMsections];
static int romlpage[ROMlpages];
static int rompage[ROMpages];
static int romsection[ROMsections(ROMlimit)];
static int romlpage[ROMlpages(ROMlimit)];
static int rompage[ROMpages(ROMlimit)];
UNUSED(argc);
UNUSED(argv);
rom = identify_ROM();
if (!rom) exit(0); /* not classed as error */
armid = svcarmid();
# if Debug
#if DEBUG
fprintf(stderr,"ARM ID = %8.8x\n",armid);
# endif
#endif
/* sets hit tables, calculates number of pages required for patches */
Npatchpages = scan_patches(rom->patchlist,romsection,romlpage,rompage);
if (Npatchpages == 0) exit(0); /* not classed as error */
# if Debug
#if DEBUG
dbtrace_patchhits(romsection,romlpage,rompage);
# endif
#endif
/* insert module first, since DAhandler code there */
RMAaddr = insert_ROMPatches_module();
......@@ -547,9 +556,9 @@ int main(int argc, char *argv[])
create_patchDA(RMAaddr,patchDAsize,DAhandler_addr,rom->patchname,
&patchDAN,&patchDAbase);
# if Debug
#if DEBUG
dbtrace_DApages(patchDAN,patchDAbase,patchDAsize);
# endif
#endif
/* rescans patches, and sets patch pages in DA */
fill_patchpages(rom->patchlist,patchDAbase,romsection,romlpage,rompage);
......
......@@ -15,5 +15,9 @@
/* debug.h */
extern uint32 logtophys(uint32 log);
extern uint32 logtopagenum(uint32 log);
extern uint32 ROMsize;
extern void dbtrace_patchhits(int *romsection,int *romlpage,int *rompage);
extern void dbtrace_DApages(int DAN, uint32 DAbase, int DAsize);
......@@ -15,15 +15,18 @@
/* defs.h */
#define Debug 0
#define ReallyDoRemap 1
#define DEBUG 0
#define REALLY_DO_REMAP 1
/* compiler pacifier */
#define UNUSED(k) (k)=(k)
/* exit code on error */
#define ErrorReturnCode 257
/* Caution! these defs are valid for RISC OS 3.60, 3.70, 3.71. Make
/* Caution! these defs are valid for RISC OS 3.50, 3.60, 3.70, 3.71. Make
sure valid for all ROM versions supported by given release of ROMPatch.
Note that only 4Mb ROMs currently supported. */
*/
#define CAMstart 0x1e02000 /* soft CAM */
#define PageFlags_Unavailable 0x2000 /* flag bit in CAM PPL word */
......@@ -31,14 +34,15 @@
#define L1PT 0x2c0c000 /* MMU level 1 page table */
#define ROMstart 0x3800000
#define ROMphysstart 0x0
#define ROMsize 0x400000 /* code assumes 4Mb in various places */
#define ROMlimit 0x400000 /* Largest ROM patchable */
#define ROMsections (ROMsize >> 20) /* 1M MMU sections */
#define ROMlpages (ROMsize >> 16) /* 64k MMU large pages */
#define ROMpages (ROMsize >> 12) /* 4k MMU (small) pages */
#define ROMsections(k) ((k) >> 20) /* 1M MMU sections */
#define ROMlpages(k) ((k) >> 16) /* 64k MMU large pages */
#define ROMpages(k) ((k) >> 12) /* 4k MMU (small) pages */
typedef unsigned char uint8;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef struct
{
......@@ -68,8 +72,9 @@ typedef struct
uint32 nextpageneeded; /* next page number needed to grow area */
uint32 firstpagenotneeded; /* first page number not needed (determines fully grown) */
uint32 DAN; /* dynamic area number */
uint32 sections; /* used entries in L1PTentries */
uint32 kernL1PT; /* address of kernel L1PT entries for ROM */
uint32 L1PTentries[4]; /* 'unpatch' values of the 4 entries */
uint32 L1PTentries[4]; /* 'unpatch' values of the sections */
} moduledata_t;
/* procedure that returns list of patches
......@@ -82,8 +87,9 @@ typedef patchentry_t * (*patchlist_proc)(void *handle);
/* one entry of list of recognised ROMs */
typedef struct
{
uint32 *romcrc; /* ROM checksum and CRC's */
int writeprotect; /* whether ROM supports ROM-space write protection */
char *patchname; /* for dynamic Area */
patchlist_proc *patchlist; /* list of patch applier procs, terminated by NULL */
uint32 *romcrc; /* ROM checksum and CRC's */
uint16 writeprotect; /* whether ROM supports ROM-space write protection */
uint16 romsize; /* the ROM size in MB */
char *patchname; /* for dynamic Area */
patchlist_proc *patchlist; /* list of patch applier procs, terminated by NULL */
} ROMentry_t;
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/COLPpatch.h */
static patchentry_t *COLPpatches350_proc(void *handle)
{
static patchentry_t COLPpatches350[] =
{
/* addr old new */
{(uint32 *)(0x039DF2E4+0x82C8), 0xEB001751, 0xE3A00000},
{(uint32 *)(0x039DF2E4+0x2660), 0xEB002E6B, 0xE3A00000},
{(uint32 *)(0x039DF2E4+0x0C18), 0x1A000003, 0x195BA870},
{(uint32 *)(0x039DF2E4+0x0C48), 0xE5951018, 0xE1A01000},
{(uint32 *)(0x039DF2E4+0x59C0), 0x1A000003, 0x195BA870},
{(uint32 *)(0x039DF2E4+0x59F0), 0xE5951014, 0xE1A01000},
{(uint32 *)(0x039DF2E4+0xB1D4), 0x1A000003, 0x195BA870},
{(uint32 *)(0x039DF2E4+0xB204), 0xE5951014, 0xE1A01000},
{(uint32 *)(0x039DF2E4+0x37A0), 0xE3590000, 0xE3E01000},
{(uint32 *)(0x039DF2E4+0x37A4), 0x0A000003, 0xEF0600D4},
{(uint32 *)(0x039DF2E4+0x37A8), 0xE597000C, 0xE3590000},
{(uint32 *)(0x039DF2E4+0x37AC), 0xEB002C28, 0x0A000001},
{(uint32 *)(0x039DF2E4+0x37B0), 0xE3580000, 0xE597000C},
{(uint32 *)(0x039DF2E4+0x37B4), 0x01A08000, 0xEB002C26},
{(uint32 *)(0x039DF2E4+0x38CC), 0xE2150001, 0xE3350000},
{(uint32 *)(0x039DF2E4+0x38D4), 0xE5940010, 0xE3E01000},
{(uint32 *)(0x039DF2E4+0x38D8), 0xEBFEACB2, 0xEF0600D4},
{(uint32 *)(0x039DF2E4+0x38DC), 0xEA000004, 0x00000000},
{(uint32 *)(0x039DF2E4+0x3C74), 0xE1A01004, 0xE2041001},
{(uint32 *)(0x039DF2E4+0x3D44), 0xE1A01002, 0xE3A01000},
{(uint32 *)(0x039DF2E4+0x431C), 0xE3A01001, 0x13A01000},
{(uint32 *)(0x039DF2E4+0x4F20), 0xE1A00002, 0xE3A00000},
{(uint32 *)(0x039DF2E4+0xA7A8), 0xE1A00004, 0xE3A00000},
{(uint32 *)0,0,0}
};
return COLPpatches350; /* ColourPicker module */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/FCREpatch.h */
static patchentry_t *FCREpatches350_proc(void *handle)
{
static patchentry_t FCREpatches350[] =
{
/*           addr old new */
{(uint32 *)0x038EECD8, 0xEA000005, 0xEA042300},
{(uint32 *)0x039F78E0, 0x736B6E61, 0xE0859008},
{(uint32 *)0x039F78E4, 0x65726120, 0xE1A09219},
{(uint32 *)0x039F78E8, 0x65756420, 0xE1540009},
{(uint32 *)0x039F78EC, 0x3A6F7420, 0xCAFBDD24},
{(uint32 *)0x039F78F0, 0x7572420A, 0xEAFBDCFF},
{(uint32 *)0,0,0}
};
return FCREpatches350; /* FileCore (patch jumps out to code poked over the hero list) */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/IICMpatch.h */
static patchentry_t *IICMpatches350_proc(void *handle)
{
static patchentry_t IICMpatches350[] =
{
/*           addr old new */
{(uint32 *)0x039230A4, 0xE3A00001, 0xE3A00000},
{(uint32 *)0,0,0}
};
return IICMpatches350; /* See IIC module version 0.14 */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/KERNpatch.h */
static patchentry_t *KERNpatches350_proc(void *handle)
{
static patchentry_t KERNpatches350[] =
{
/*           addr old new */
{(uint32 *)0x038275A0, 0xE3A00001, 0xE3A00000},
{(uint32 *)0x0380419C, 0xE3A00004, 0xE3A0CA01},
{(uint32 *)0x038041A0, 0xEBFFFFBA, 0xEB007F60},
{(uint32 *)0x038041A4, 0xE3A0CA01, 0xE3A0CE9A},
{(uint32 *)0x038041A8, 0xEB007F5E, 0xE3A00004},
{(uint32 *)0x038041AC, 0xE3A0CE9A, 0xEBFFFFB7},
{(uint32 *)0,0,0}
};
return KERNpatches350; /* Kernel or Utility module */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/ROMcrc.h */
/* RISC OS 3.50 - checksum and CRC's */
/* 3 words at end of ROM */
static uint32 romcrc350[3] = { 0xF0561D7C, 0xEAE37D58, 0xC33AE184 };
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/SQSHpatch.h */
static patchentry_t *SQSHpatches350_proc(void *handle)
{
static patchentry_t SQSHpatches350[] =
{
/* addr old new */
{(uint32 *)0x03983EA8, 0xE3560A01, 0xE59DB004},
{(uint32 *)0x03983EAC, 0x2A000007, 0xE026760E},
{(uint32 *)0x03983EB0, 0xE59DB004, 0xE78B7103},
{(uint32 *)0x03983EB4, 0xE026E60E, 0xE2866001},
{(uint32 *)0x03983EB8, 0xE78BE103, 0xE3560A01},
{(uint32 *)0x03983EBC, 0xE2866001, 0x2A000003},
{(uint32 *)0,0,0}
};
return SQSHpatches350; /* Squash module */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/VRAMfix.h */
static patchentry_t *VRAMfix350_proc(void *handle)
{
_kernel_oserror *e;
uint32 pages, pagesize;
/* check how much VRAM (type 2) memory is installed */
e = _swix(OS_Memory, _IN(0) | _OUTR(1,2), (2<<8) | 8, &pages, &pagesize);
if ((pages * pagesize) == (2 * 1024 * 1024))
{
static patchentry_t VRAMpatches350[] =
{
/* addr old new */
{(uint32 *)0x038150D8, 0x13A0E000, 0x13822A02},
{(uint32 *)0x038150DC, 0xE1822B2E, 0x01822B2E},
{(uint32 *)0,0,0}
};
return VRAMpatches350; /* Only if 2M of VRAM */
}
return NULL;
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/WIMPpatch.h */
static patchentry_t *WIMPpatches350_proc(void *handle)
{
static patchentry_t WIMPpatches350[] =
{
/* addr old new */
{(uint32 *)0x038C3074, 0xE79CE00E, 0xEA000009},
{(uint32 *)0x038C30A0, 0xE35F0000, 0xE35E0000},
{(uint32 *)0x038C30A4, 0xE92D4CFF, 0xC79CE00E},
{(uint32 *)0x038C30A8, 0xE3A0EF42, 0xCAFFFFF2},
{(uint32 *)0x038C30AC, 0xE49EE000, 0xE8FD800F},
{(uint32 *)0,0,0}
};
return WIMPpatches350; /* WindowManager module */
}
/* Copyright 2012 Castle Technology 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.
*/
/* patches/350/patch.h */
/* sum of patches for RISC OS 3.50 */
#include "patches/350/ROMcrc.h"
#include "patches/350/VRAMfix.h"
#include "patches/350/WIMPpatch.h"
#include "patches/350/SQSHpatch.h"
#include "patches/350/KERNpatch.h"
#include "patches/350/IICMpatch.h"
#include "patches/350/FCREpatch.h"
#include "patches/350/COLPpatch.h"
static patchlist_proc patchlist350[] =
{
VRAMfix350_proc,
WIMPpatches350_proc,
SQSHpatches350_proc,
KERNpatches350_proc,
IICMpatches350_proc,
FCREpatches350_proc,
COLPpatches350_proc,
NULL
};
static ROMentry_t ROMentry350 =
{
romcrc350,
0, /* 3.50 does not support ROM-space write protect */
2, /* 3.50 comes on 2MB of ROM */
M_name350,
patchlist350
};
/* Copyright 2012 Castle Technology 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.
*/
/* patches/360/ADFSpatch.h */
static patchentry_t *ADFSpatches360_proc(void *handle)
{
static patchentry_t ADFSpatches360[] =
{
/*           addr old new */
{(uint32 *)0x03934440, 0xE3540502, 0xE3540501},
{(uint32 *)0x03934444, 0x23E04000, 0x23E04102},
{(uint32 *)0,0,0}
};
return ADFSpatches360;
}
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