Skip to content

Commit a1b5b92

Browse files
committed
Initialised the file modules
1 parent 980949b commit a1b5b92

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

platform/m6/sub/101a/boot.c

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void plant_hacks_for_e0070000(unsigned addr) {
6060
*(unsigned short*) (addr + 0x9DA2) = 0xbf00;
6161
}
6262

63-
// following should be integrated in dcache_clean_all
63+
// should be integrated in dcache_clean_all
6464
void l2_cache_sync(void) {
6565
*(int*) 0xc1100730 = 0;
6666
}
@@ -155,6 +155,56 @@ void __attribute__((naked,noinline)) sub_e00200f8_my() {
155155
);
156156
}
157157

158+
void __attribute__((naked,noinline)) CreateTask_my() {
159+
asm volatile (
160+
" push {r0}\n"
161+
" ldr r0, =task_InitFileModules\n"
162+
" cmp r0, r3\n"
163+
" it eq\n"
164+
" ldreq r3, =init_file_modules_task\n"
165+
"exitHook:\n"
166+
" pop {r0}\n" // restore overwritten register(s)
167+
168+
// execute overwritten instructions from original code, then jump to firmware
169+
// capdis -f=chdk -jfw -stubs -s=CreateTask -c=4 PRIMARY.BIN 0xe0000000
170+
// CreateTask 0xdffc93a3
171+
" push {r1, r2, r3, r4, r5, r6, r7, lr}\n"
172+
" mov r4, r3\n"
173+
" mov.w r3, #0x1000\n"
174+
" ldr r5, [sp, #0x20]\n"
175+
" ldr pc, =0xdffc93ad\n"// Continue in firmware
176+
".ltorg\n"
177+
);
178+
}
179+
180+
void __attribute__((naked,noinline)) init_file_modules_task() {
181+
// tools/capdis -f=chdk -jfw -stubs -s=task_InitFileModules -c=18 PRIMARY.BIN 0xe0000000
182+
// task_InitFileModules 0xe00fdd05
183+
asm volatile (
184+
" push {r4, r5, r6, lr}\n"
185+
" movs r0, #6\n"
186+
" bl sub_e0362f64\n" // return
187+
" bl sub_e011ce98\n"
188+
" movs r4, r0\n"
189+
" movw r5, #0x5006\n"
190+
" beq loc_e00fdd20\n"
191+
" movs r1, #0\n"
192+
" mov r0, r5\n"
193+
" bl _PostLogicalEventToUI\n"
194+
"loc_e00fdd20:\n"
195+
" bl sub_e011cec0\n"
196+
" BL core_spytask_can_start\n"// set "it's-safe-to-start" flag for spytask
197+
" cmp r4, #0\n"
198+
" bne loc_e00fdd34\n"// return
199+
" mov r0, r5\n"
200+
" pop.w {r4, r5, r6, lr}\n"
201+
" movs r1, #1\n"
202+
" b.w _PostLogicalEventToUI\n"
203+
"loc_e00fdd34:\n"
204+
" pop {r4, r5, r6, pc}\n"
205+
);
206+
}
207+
158208
/**
159209
* @see main startup
160210
*/
@@ -239,13 +289,33 @@ void __attribute__((naked,noinline)) boot() {
239289
" it lo\n"
240290
" strlo r2, [r3], #4\n"
241291
" blo loc_e002009e\n"
292+
293+
// install CreateTask patch
294+
// use half words in case source or destination not word aligned
295+
" adr r0, patch_CreateTask\n"// src: patch data
296+
" ldr r1, =hook_CreateTask\n"// dest: address to patch
297+
" add r2, r0, #10\n"// 2.5 words as target is not word aligned
298+
"patch_hook_loop:\n"
299+
" ldrh r3, [r0],#2\n"
300+
" strh r3, [r1],#2\n"
301+
" cmp r0,r2\n"
302+
" blo patch_hook_loop\n"
303+
242304
" ldr r0, =0xdffc4900\n"
243305
" ldr r1, =0x000152a0\n"
244306
" bl _dcache_clean_by_mva\n"
245307
" ldr r0, =0xdffc4900\n"
246308
" ldr r1, =0x000152a0\n"
247309
" bl _icache_branchpr_invalidate\n"
248-
" b loc_e0020032\n" // +
310+
" b loc_e0020032\n"// +
311+
312+
" .align 2\n"
313+
" .short 0\n"// added for alignment
314+
"patch_CreateTask:\n"
315+
" ldr.w pc, _createtask_my\n"// jump to absolute address CreateTask_my
316+
" .short 0\n"// added for alignment
317+
"_createtask_my:\n"
318+
" .long CreateTask_my + 1\n"// has to be a thumb address
249319
);
250320

251321
}

platform/m6/sub/101a/boot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
extern void _set_canon_mmu_tables_to(unsigned addr);
55
extern void _make_copy_of_canon_mmutables(unsigned dest_addr);
66
extern int _CreateTask(char *name, int prio, int stack_size, void *entry, int parm);
7+
extern int _PostLogicalEventToUI(int event, int unk);
8+
extern void task_InitFileModules(void);
79

810
#endif

platform/m6/sub/101a/stubs_auto.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ STUB(E010E954)
77
STUB(E02796AE)
88
STUB(e007006e)
99
STUB(e007a49c)
10+
STUB(e011ce98)
11+
STUB(e011cec0)
12+
STUB(e0362f64)

0 commit comments

Comments
 (0)