This source file includes following definitions.
- log_fwt_msg
- filewritetask
- sub_FFA26268_my
- sub_FFA263B4_my
- sub_FFA264B0_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4
5 #ifdef CAM_HAS_FILEWRITETASK_HOOK
6
7
8
9 extern void _LogCameraEvent(int id,const char *fmt,...);
10
11 typedef struct {
12 unsigned int address;
13 unsigned int length;
14 } cam_ptp_data_chunk;
15
16 #define MAX_CHUNKS_FOR_FWT 3
17
18
19
20
21
22
23
24 typedef struct
25 {
26 int unkn1[5];
27 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
28 char name[32];
29 } fwt_data_struct;
30
31 #include "../../../generic/filewrite.c"
32
33 #ifdef FILEWRITE_DEBUG_LOG
34 void log_fwt_msg(fwt_data_struct *fwd)
35 {
36 int m=fwd->unkn1[0];
37 _LogCameraEvent(0x20,"fw m:%d",m);
38 _LogCameraEvent(0x20,"fw %s",fwd->name);
39
40 if(m >= 4 && m < (4+MAX_CHUNKS_FOR_FWT)) {
41 _LogCameraEvent(0x20,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m-4].address,fwd->pdc[m-4].length);
42 }
43 _LogCameraEvent(0x20,"fw u %08x %08x %08x %08x",fwd->unkn1[1],fwd->unkn1[2],fwd->unkn1[3],fwd->unkn1[4]);
44 }
45 #endif
46
47
48 void __attribute__((naked,noinline)) filewritetask() {
49 asm volatile (
50 " STMFD SP!, {R1-R5,LR}\n"
51 " LDR R4, =0x9314\n"
52 "loc_FFA25FBC:\n"
53
54 " LDR R0, [R4,#0x10]\n"
55 " MOV R2, #0\n"
56 " ADD R1, SP, #8\n"
57 " BL sub_FF826C30\n"
58 " CMP R0, #0\n"
59 " BNE loc_FFA25FEC\n"
60 #ifdef FILEWRITE_DEBUG_LOG
61 "ldr r0, [sp,#8]\n"
62 "bl log_fwt_msg\n"
63 #endif
64 " LDR R0, [SP,#8]\n"
65 " LDR R1, [R0]\n"
66 " CMP R1, #1\n"
67 " BNE loc_FFA25FF4\n"
68 " LDR R0, [R4,#8]\n"
69 " BL sub_FF82711C\n"
70 "loc_FFA25FEC:\n"
71 " BL _ExitTask\n"
72 " LDMFD SP!, {R1-R5,PC}\n"
73 "loc_FFA25FF4:\n"
74 " SUB R1, R1, #2\n"
75 " CMP R1, #5\n"
76 " ADDLS PC, PC, R1,LSL#2\n"
77 " B loc_FFA25FBC\n"
78 " B loc_FFA2601C\n"
79 " B loc_FFA26080\n"
80 " B loc_FFA26088\n"
81 " B loc_FFA26088\n"
82 " B loc_FFA26088\n"
83 " B loc_FFA26090\n"
84 "loc_FFA2601C:\n"
85
86 " MOV R0, #0\n"
87 " STR R0, [SP]\n"
88 "loc_FFA26024:\n"
89 " LDR R0, [R4,#0x10]\n"
90 " MOV R1, SP\n"
91 " BL sub_FF826E74\n"
92 " LDR R0, [SP]\n"
93 " CMP R0, #0\n"
94 " BEQ loc_FFA26050\n"
95 " LDR R0, [R4,#0x10]\n"
96 " MOV R2, #0\n"
97 " ADD R1, SP, #4\n"
98 " BL sub_FF826C30\n"
99 " B loc_FFA26024\n"
100 "loc_FFA26050:\n"
101 " LDR R0, [R4]\n"
102 " CMN R0, #1\n"
103 " BEQ loc_FFA26074\n"
104
105 " BL fwt_close\n"
106 " MVN R0, #0\n"
107 " STR R0, [R4]\n"
108 " LDR R0, =0xCD788\n"
109 " BL sub_FF855E18\n"
110 " BL sub_FF8543A4\n"
111 "loc_FFA26074:\n"
112 " LDR R0, [R4,#0xC]\n"
113 " BL sub_FF82711C\n"
114 " B loc_FFA25FBC\n"
115 "loc_FFA26080:\n"
116
117 " BL sub_FFA26268_my\n"
118 " B loc_FFA25FBC\n"
119 "loc_FFA26088:\n"
120
121 " BL sub_FFA263B4_my\n"
122 " B loc_FFA25FBC\n"
123 "loc_FFA26090:\n"
124
125 " BL sub_FFA264B0_my\n"
126 " B loc_FFA25FBC\n"
127
128 );
129 }
130
131 void __attribute__((naked,noinline)) sub_FFA26268_my( ) {
132 asm volatile (
133 " STMFD SP!, {R4-R8,LR}\n"
134 " MOV R4, R0\n"
135 " ADD R0, R0, #0x2C\n"
136 " SUB SP, SP, #0x38\n"
137 " BL sub_FF855E18\n"
138 " MOV R1, #0\n"
139 " BL sub_FF854354\n"
140 " LDR R0, [R4,#0xC]\n"
141 " BL sub_FF8527FC\n"
142 " LDR R7, [R4,#8]\n"
143 " LDR R8, =0x1B6\n"
144 " ADD R6, R4, #0x2C\n"
145 " LDR R5, [R4,#0xC]\n"
146
147 "STMFD SP!, {R4-R12,LR}\n"
148 "MOV R0, R4\n"
149 "BL filewrite_main_hook\n"
150 "LDMFD SP!, {R4-R12,LR}\n"
151
152
153 " MOV R0, R6\n"
154 " MOV R1, R7\n"
155 " MOV R2, R8\n"
156
157 " BL fwt_open\n"
158 " LDR PC,=0xFFA262AC\n"
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 );
215 }
216
217 void __attribute__((naked,noinline)) sub_FFA263B4_my( ) {
218 asm volatile (
219 " STMFD SP!, {R4-R10,LR}\n"
220 " MOV R4, R0\n"
221 " LDR R0, [R0]\n"
222 " CMP R0, #4\n"
223 " LDREQ R6, [R4,#0x18]\n"
224 " LDREQ R7, [R4,#0x14]\n"
225 " BEQ loc_FFA263F0\n"
226 " CMP R0, #5\n"
227 " LDREQ R6, [R4,#0x20]\n"
228 " LDREQ R7, [R4,#0x1C]\n"
229 " BEQ loc_FFA263F0\n"
230 " CMP R0, #6\n"
231 " BNE loc_FFA26404\n"
232 " LDR R6, [R4,#0x28]\n"
233 " LDR R7, [R4,#0x24]\n"
234 "loc_FFA263F0:\n"
235 " CMP R6, #0\n"
236 " BNE loc_FFA26414\n"
237 "loc_FFA263F8:\n"
238 " MOV R1, R4\n"
239 " MOV R0, #7\n"
240 " B loc_FFA264A8\n"
241 "loc_FFA26404:\n"
242 " LDR R1, =0x20D\n"
243 " LDR R0, =0xFFA26394\n"
244 " BL sub_FF81B284\n"
245 " B loc_FFA263F8\n"
246 "loc_FFA26414:\n"
247 " LDR R9, =0x9314\n"
248 " MOV R5, R6\n"
249 "loc_FFA2641C:\n"
250 " LDR R0, [R4,#4]\n"
251 " CMP R5, #0x1000000\n"
252 " MOVLS R8, R5\n"
253 " MOVHI R8, #0x1000000\n"
254 " BIC R1, R0, #0xFF000000\n"
255 " CMP R1, #0\n"
256 " BICNE R0, R0, #0xFF000000\n"
257 " RSBNE R0, R0, #0x1000000\n"
258 " CMPNE R8, R0\n"
259 " MOVHI R8, R0\n"
260 " LDR R0, [R9]\n"
261 " MOV R2, R8\n"
262 " MOV R1, R7\n"
263
264 " BL fwt_write\n"
265 " LDR R1, [R4,#4]\n"
266 " CMP R8, R0\n"
267 " ADD R1, R1, R0\n"
268 " STR R1, [R4,#4]\n"
269 " BEQ loc_FFA2647C\n"
270 " LDR R0, =0x10B1\n"
271 " BL sub_FF877A6C\n"
272 " LDR R1, =0x9200005\n"
273 " STR R1, [R4,#0x10]\n"
274 " B loc_FFA263F8\n"
275 "loc_FFA2647C:\n"
276 " SUB R5, R5, R0\n"
277 " CMP R5, R6\n"
278 " ADD R7, R7, R0\n"
279 " LDRCS R0, =0xFFA26394\n"
280 " MOVCS R1, #0x23C\n"
281 " BLCS sub_FF81B284\n"
282 " CMP R5, #0\n"
283 " BNE loc_FFA2641C\n"
284 " LDR R0, [R4]\n"
285 " MOV R1, R4\n"
286 " ADD R0, R0, #1\n"
287 "loc_FFA264A8:\n"
288 " LDMFD SP!, {R4-R10,LR}\n"
289 " B sub_FFA25F0C\n"
290 );
291 }
292
293 void __attribute__((naked,noinline)) sub_FFA264B0_my( ) {
294 asm volatile (
295 " STMFD SP!, {R4,R5,LR}\n"
296 " LDR R5, =0x9314\n"
297 " MOV R4, R0\n"
298 " LDR R0, [R5]\n"
299 " SUB SP, SP, #0x1C\n"
300 " CMN R0, #1\n"
301 " BEQ loc_FFA264E4\n"
302
303 " BL fwt_close\n"
304 " CMP R0, #0\n"
305 " LDRNE R0, =0x9200003\n"
306 " STRNE R0, [R4,#0x10]\n"
307 " MVN R0, #0\n"
308 " STR R0, [R5]\n"
309 "loc_FFA264E4:\n"
310 " LDR PC, =0xFFA264E4\n"
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344 );
345 }
346 #endif
347