root/platform/g10/sub/102a/filewrite.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA46D70_my
  3. sub_FFA46E70_my
  4. sub_FFA46F7C_my

   1 /*
   2  * filewrite.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 
   7 typedef struct {
   8     unsigned int address;
   9     unsigned int length;
  10 } cam_ptp_data_chunk; //camera specific structure
  11 
  12 #define MAX_CHUNKS_FOR_JPEG 3 //filewritetask is prepared for this many chunks
  13 /*
  14  * fwt_data_struct: defined here as it's camera dependent
  15  * unneeded members are designated with unkn
  16  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  17  * pdc is always required
  18  * name is not currently used
  19  */
  20 typedef struct
  21 {
  22     int unkn1[5];                                //
  23     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  24     char name[32];
  25 } fwt_data_struct;
  26 
  27 #include "../../../generic/filewrite.c"
  28 
  29 /*************************************************************/
  30 //** filewritetask @ 0xFFA46A18 - 0xFFA46AFC, length=58
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R4, =0xC8F4 \n"
  35 
  36 "loc_FFA46A20:\n"
  37 "    LDR     R0, [R4, #0x10] \n"
  38 "    MOV     R2, #0 \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF827D30 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    BNE     loc_FFA46A50 \n"
  43 "    LDR     R0, [SP, #8] \n"
  44 "    LDR     R1, [R0] \n"
  45 "    CMP     R1, #1 \n"
  46 "    BNE     loc_FFA46A58 \n"
  47 "    LDR     R0, [R4, #8] \n"
  48 "    BL      _GiveSemaphore \n"
  49 
  50 "loc_FFA46A50:\n"
  51 "    BL      _ExitTask \n"
  52 "    LDMFD   SP!, {R1-R5,PC} \n"
  53 
  54 "loc_FFA46A58:\n"
  55 "    SUB     R1, R1, #2 \n"
  56 "    CMP     R1, #6 \n"
  57 "    ADDLS   PC, PC, R1, LSL#2 \n"
  58 "    B       loc_FFA46A20 \n"
  59 "    B       loc_FFA46A84 \n"
  60 "    B       loc_FFA46AE8 \n"
  61 "    B       loc_FFA46AF0 \n"
  62 "    B       loc_FFA46AF0 \n"
  63 "    B       loc_FFA46AF0 \n"
  64 "    B       loc_FFA46AF0 \n"
  65 "    B       loc_FFA46AF8 \n"
  66 
  67 "loc_FFA46A84:\n"
  68 "    MOV     R0, #0 \n"
  69 "    STR     R0, [SP] \n"
  70 
  71 "loc_FFA46A8C:\n"
  72 "    LDR     R0, [R4, #0x10] \n"
  73 "    MOV     R1, SP \n"
  74 "    BL      sub_FF827F74 /*_GetNumberOfPostedMessages*/ \n"
  75 "    LDR     R0, [SP] \n"
  76 "    CMP     R0, #0 \n"
  77 "    BEQ     loc_FFA46AB8 \n"
  78 "    LDR     R0, [R4, #0x10] \n"
  79 "    MOV     R2, #0 \n"
  80 "    ADD     R1, SP, #4 \n"
  81 "    BL      sub_FF827D30 /*_ReceiveMessageQueue*/ \n"
  82 "    B       loc_FFA46A8C \n"
  83 
  84 "loc_FFA46AB8:\n"
  85 "    LDR     R0, [R4] \n"
  86 "    CMN     R0, #1 \n"
  87 "    BEQ     loc_FFA46ADC \n"
  88 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  89 "    MVN     R0, #0 \n"
  90 "    STR     R0, [R4] \n"
  91 "    LDR     R0, =0xC03F0 \n"
  92 "    BL      sub_FF85A094 \n"
  93 "    BL      sub_FF85873C \n"
  94 
  95 "loc_FFA46ADC:\n"
  96 "    LDR     R0, [R4, #0xC] \n"
  97 "    BL      _GiveSemaphore \n"
  98 "    B       loc_FFA46A20 \n"
  99 
 100 "loc_FFA46AE8:\n"
 101 "    BL      sub_FFA46D70_my \n"  // --> Patched. Old value = 0xFFA46D70. Open stage
 102 "    B       loc_FFA46A20 \n"
 103 
 104 "loc_FFA46AF0:\n"
 105 "    BL      sub_FFA46E70_my \n"  // --> Patched. Old value = 0xFFA46E70. Write stage
 106 "    B       loc_FFA46A20 \n"
 107 
 108 "loc_FFA46AF8:\n"
 109 "    BL      sub_FFA46F7C_my \n"  // --> Patched. Old value = 0xFFA46F7C. Close stage
 110 "    B       loc_FFA46A20 \n"
 111 );
 112 }
 113 
 114 /*************************************************************/
 115 //** sub_FFA46D70_my @ 0xFFA46D70 - 0xFFA46DB0, length=17
 116 void __attribute__((naked,noinline)) sub_FFA46D70_my() {
 117 asm volatile (
 118 "    STMFD   SP!, {R4-R8,LR} \n"
 119 "    MOV     R4, R0 \n"
 120 "    ADD     R0, R0, #0x34 \n"
 121 "    SUB     SP, SP, #0x38 \n"
 122 "    BL      sub_FF85A094 \n"
 123 "    MOV     R1, #0 \n"
 124 "    BL      sub_FF8586EC \n"
 125 "    LDR     R0, [R4, #0xC] \n"
 126 "    BL      sub_FF8569FC \n"
 127 "    LDR     R7, [R4, #8] \n"
 128 "    LDR     R8, =0x1B6 \n"
 129 "    ADD     R6, R4, #0x34 \n"
 130 "    LDR     R5, [R4, #0xC] \n"
 131 //hook start
 132 "    STMFD SP!, {R4-R12,LR}\n"
 133 "    MOV R0, R4\n"
 134 "    BL filewrite_main_hook\n"
 135 "    LDMFD SP!, {R4-R12,LR}\n"
 136 //hook end
 137 "    MOV     R0, R6 \n"
 138 "    MOV     R1, R7 \n"
 139 "    MOV     R2, R8 \n"
 140 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 141 "    LDR     PC, =0xFFA46DB4 \n"  // Continue in firmware
 142 );
 143 }
 144 
 145 /*************************************************************/
 146 //** sub_FFA46E70_my @ 0xFFA46E70 - 0xFFA46F78, length=67
 147 void __attribute__((naked,noinline)) sub_FFA46E70_my() {
 148 asm volatile (
 149 "    STMFD   SP!, {R4-R10,LR} \n"
 150 "    MOV     R4, R0 \n"
 151 "    LDR     R0, [R0] \n"
 152 "    CMP     R0, #4 \n"
 153 "    LDREQ   R6, [R4, #0x18] \n"
 154 "    LDREQ   R7, [R4, #0x14] \n"
 155 "    BEQ     loc_FFA46EBC \n"
 156 "    CMP     R0, #5 \n"
 157 "    LDREQ   R6, [R4, #0x20] \n"
 158 "    LDREQ   R7, [R4, #0x1C] \n"
 159 "    BEQ     loc_FFA46EBC \n"
 160 "    CMP     R0, #6 \n"
 161 "    LDREQ   R6, [R4, #0x28] \n"
 162 "    LDREQ   R7, [R4, #0x24] \n"
 163 "    BEQ     loc_FFA46EBC \n"
 164 "    CMP     R0, #7 \n"
 165 "    BNE     loc_FFA46ED0 \n"
 166 "    LDR     R6, [R4, #0x30] \n"
 167 "    LDR     R7, [R4, #0x2C] \n"
 168 
 169 "loc_FFA46EBC:\n"
 170 "    CMP     R6, #0 \n"
 171 "    BNE     loc_FFA46EE0 \n"
 172 
 173 "loc_FFA46EC4:\n"
 174 "    MOV     R1, R4 \n"
 175 "    MOV     R0, #8 \n"
 176 "    B       loc_FFA46F74 \n"
 177 
 178 "loc_FFA46ED0:\n"
 179 "    LDR     R1, =0x205 \n"
 180 "    LDR     R0, =0xFFA46D5C /*'dwFWrite.c'*/ \n"
 181 "    BL      _DebugAssert \n"
 182 "    B       loc_FFA46EC4 \n"
 183 
 184 "loc_FFA46EE0:\n"
 185 "    LDR     R9, =0xC8F4 \n"
 186 "    MOV     R5, R6 \n"
 187 
 188 "loc_FFA46EE8:\n"
 189 "    LDR     R0, [R4, #4] \n"
 190 "    CMP     R5, #0x1000000 \n"
 191 "    MOVLS   R8, R5 \n"
 192 "    MOVHI   R8, #0x1000000 \n"
 193 "    BIC     R1, R0, #0xFF000000 \n"
 194 "    CMP     R1, #0 \n"
 195 "    BICNE   R0, R0, #0xFF000000 \n"
 196 "    RSBNE   R0, R0, #0x1000000 \n"
 197 "    CMPNE   R8, R0 \n"
 198 "    MOVHI   R8, R0 \n"
 199 "    LDR     R0, [R9] \n"
 200 "    MOV     R2, R8 \n"
 201 "    MOV     R1, R7 \n"
 202 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 203 "    LDR     R1, [R4, #4] \n"
 204 "    CMP     R8, R0 \n"
 205 "    ADD     R1, R1, R0 \n"
 206 "    STR     R1, [R4, #4] \n"
 207 "    BEQ     loc_FFA46F48 \n"
 208 "    LDR     R0, =0x10B1 \n"
 209 "    BL      sub_FF87EC08 /*_IsControlEventActive_FW*/ \n"
 210 "    LDR     R1, =0x9200005 \n"
 211 "    STR     R1, [R4, #0x10] \n"
 212 "    B       loc_FFA46EC4 \n"
 213 
 214 "loc_FFA46F48:\n"
 215 "    SUB     R5, R5, R0 \n"
 216 "    CMP     R5, R6 \n"
 217 "    ADD     R7, R7, R0 \n"
 218 "    LDRCS   R0, =0xFFA46D5C /*'dwFWrite.c'*/ \n"
 219 "    MOVCS   R1, #0x234 \n"
 220 "    BLCS    _DebugAssert \n"
 221 "    CMP     R5, #0 \n"
 222 "    BNE     loc_FFA46EE8 \n"
 223 "    LDR     R0, [R4] \n"
 224 "    MOV     R1, R4 \n"
 225 "    ADD     R0, R0, #1 \n"
 226 
 227 "loc_FFA46F74:\n"
 228 "    LDMFD   SP!, {R4-R10,LR} \n"
 229 "    B       sub_FFA46960 \n"
 230 );
 231 }
 232 
 233 /*************************************************************/
 234 //** sub_FFA46F7C_my @ 0xFFA46F7C - 0xFFA47018, length=40
 235 void __attribute__((naked,noinline)) sub_FFA46F7C_my() {
 236 asm volatile (
 237 "    STMFD   SP!, {R4,R5,LR} \n"
 238 "    LDR     R5, =0xC8F4 \n"
 239 "    MOV     R4, R0 \n"
 240 "    LDR     R0, [R5] \n"
 241 "    SUB     SP, SP, #0x1C \n"
 242 "    CMN     R0, #1 \n"
 243 "    BEQ     loc_FFA46FB0 \n"
 244 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 245 "    CMP     R0, #0 \n"
 246 "    LDRNE   R0, =0x9200003 \n"
 247 "    STRNE   R0, [R4, #0x10] \n"
 248 "    MVN     R0, #0 \n"
 249 "    STR     R0, [R5] \n"
 250 
 251 "loc_FFA46FB0:\n"
 252 "    LDR     R0, [R4, #0x10] \n"
 253 "    TST     R0, #1 \n"
 254 "    BNE     loc_FFA46FF8 \n"
 255 "    LDR     R0, =0x81FF \n"
 256 "    ADD     R1, SP, #4 \n"
 257 "    STR     R0, [SP, #4] \n"
 258 "    MOV     R0, #0x20 \n"
 259 "    STR     R0, [SP, #8] \n"
 260 "    LDR     R0, [R4, #4] \n"
 261 "    STR     R0, [SP, #0xC] \n"
 262 "    LDR     R0, [R4, #0xC] \n"
 263 "    STR     R0, [SP, #0x10] \n"
 264 "    LDR     R0, [R4, #0xC] \n"
 265 "    STR     R0, [SP, #0x14] \n"
 266 "    LDR     R0, [R4, #0xC] \n"
 267 "    STR     R0, [SP, #0x18] \n"
 268 "    ADD     R0, R4, #0x34 \n"
 269 "    BL      sub_FF858000 \n"
 270 
 271 "loc_FFA46FF8:\n"
 272 "    ADD     R0, R4, #0x34 \n"
 273 "    BL      sub_FF85A094 \n"
 274 "    BL      sub_FF85873C \n"
 275 "    LDR     R1, [R5, #0x14] \n"
 276 "    CMP     R1, #0 \n"
 277 "    LDRNE   R0, [R4, #0x10] \n"
 278 "    BLXNE   R1 \n"
 279 "    ADD     SP, SP, #0x1C \n"
 280 "    LDMFD   SP!, {R4,R5,PC} \n"
 281 );
 282 }

/* [<][>][^][v][top][bottom][index][help] */