root/platform/sx40hs/sub/100i/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF33780C_my
  3. sub_FF337968_my
  4. sub_FF3373BC_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_FWT 7   // 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  * pdc is required, everything after that is optional (DryOS < R50)
  17  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  18  */
  19 typedef struct
  20 {
  21     int unkn1[5];
  22     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  23     int unkn2;
  24     char name[32];
  25 } fwt_data_struct;
  26 
  27 #include "../../../generic/filewrite.c"
  28 
  29 /*************************************************************/
  30 //** filewritetask @ 0xFF337528 - 0xFF33760C, length=58
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xF12C \n"
  35 
  36 "loc_FF337530:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF02B0F4 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    LDRNE   R1, =0x33E \n"
  43 "    LDRNE   R0, =0xFF33761C /*'dwFWrite.c'*/ \n"
  44 "    BLNE    _DebugAssert \n"
  45 "    LDR     R0, [SP, #8] \n"
  46 "    LDR     R1, [R0] \n"
  47 "    CMP     R1, #0xA \n"
  48 "    ADDCC   PC, PC, R1, LSL#2 \n"
  49 "    B       loc_FF337530 \n"
  50 "    B       loc_FF337600 \n"
  51 "    B       loc_FF337600 \n"
  52 "    B       loc_FF337600 \n"
  53 "    B       loc_FF337600 \n"
  54 "    B       loc_FF337600 \n"
  55 "    B       loc_FF337600 \n"
  56 "    B       loc_FF337600 \n"
  57 "    B       loc_FF337608 \n"
  58 "    B       loc_FF33758C \n"
  59 "    B       loc_FF3375F8 \n"
  60 
  61 "loc_FF33758C:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF337598:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02B338 /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF3375C4 \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF02B0F4 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF337598 \n"
  78 
  79 "loc_FF3375C4:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF3375EC \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x173944 \n"
  87 "    BL      sub_FF06A7D8 \n"
  88 "    MOV     R1, #0 \n"
  89 "    BL      sub_FF068A54 \n"
  90 
  91 "loc_FF3375EC:\n"
  92 "    LDR     R0, [R4, #0xC] \n"
  93 "    BL      _GiveSemaphore \n"
  94 "    B       loc_FF337530 \n"
  95 
  96 "loc_FF3375F8:\n"
  97 "    BL      sub_FF33780C_my \n"  // --> Patched. Old value = 0xFF33780C.
  98 "    B       loc_FF337530 \n"
  99 
 100 "loc_FF337600:\n"
 101 "    BL      sub_FF337968_my \n"  // --> Patched. Old value = 0xFF337968.
 102 "    B       loc_FF337530 \n"
 103 
 104 "loc_FF337608:\n"
 105 "    BL      sub_FF3373BC_my \n"  // --> Patched. Old value = 0xFF3373BC.
 106 "    B       loc_FF337530 \n"
 107 );
 108 }
 109 
 110 /*************************************************************/
 111 //** sub_FF33780C_my @ 0xFF33780C - 0xFF3378D8, length=52
 112 void __attribute__((naked,noinline)) sub_FF33780C_my() {
 113 asm volatile (
 114 "    STMFD   SP!, {R4-R9,LR} \n"
 115 "    MOV     R4, R0 \n"
 116 "    SUB     SP, SP, #0x3C \n"
 117 "    ADD     R0, R0, #0x50 \n"
 118 "    BL      sub_FF06A7D8 \n"
 119 "    MOV     R1, #0 \n"
 120 "    BL      sub_FF068918 \n"
 121 "    LDR     R0, [R4, #0xC] \n"
 122 "    BL      sub_FF000348 \n"
 123 "    LDR     R0, [R4, #0x4C] \n"
 124 "    ADD     R7, R4, #0x50 \n"
 125 "    CMP     R0, #1 \n"
 126 "    LDREQ   R0, [R4, #8] \n"
 127 "    ORREQ   R0, R0, #0x8000 \n"
 128 "    STREQ   R0, [R4, #8] \n"
 129 "    LDR     R5, [R4, #0xC] \n"
 130 "    LDR     R8, [R4, #8] \n"
 131 "    BL      sub_FF1D4D90 \n"
 132 //hook start
 133 "    STMFD   SP!, {R4-R12,LR} \n"
 134 "    MOV     R0, R4 \n"
 135 "    BL      filewrite_main_hook \n"
 136 "    LDMFD   SP!, {R4-R12,LR} \n"
 137 //hook end
 138 "    LDR     R9, =0x1B6 \n"
 139 "    MOV     R1, R8 \n"
 140 "    MOV     R2, R9 \n"
 141 "    MOV     R0, R7 \n"
 142 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 143 "    MOV     R6, R0 \n"
 144 "    BL      sub_FF1D4DE0 \n"
 145 "    CMN     R6, #1 \n"
 146 "    MOVNE   R5, R6 \n"
 147 "    BNE     sub_FF3378E4 \n"
 148 "    BL      sub_FF1D4D90 \n"
 149 "    MOV     R0, R7 \n"
 150 "    BL      sub_FF027C70 \n"
 151 "    MOV     R2, #0xF \n"
 152 "    MOV     R1, R7 \n"
 153 "    ADD     R0, SP, #4 \n"
 154 "    BL      sub_FF42FAB4 \n"
 155 "    MOV     R0, #0 \n"
 156 "    LDR     R1, =0x41FF \n"
 157 "    STRB    R0, [SP, #0x13] \n"
 158 "    STR     R1, [SP, #0x24] \n"
 159 "    MOV     R1, #0x10 \n"
 160 "    STR     R0, [SP, #0x2C] \n"
 161 "    STR     R1, [SP, #0x28] \n"
 162 "    ADD     R1, SP, #0x24 \n"
 163 "    ADD     R0, SP, #4 \n"
 164 "    STR     R5, [SP, #0x30] \n"
 165 "    STR     R5, [SP, #0x34] \n"
 166 "    STR     R5, [SP, #0x38] \n"
 167 "    BL      sub_FF06828C \n"
 168 "    MOV     R2, R9 \n"
 169 "    MOV     R1, R8 \n"
 170 "    MOV     R0, R7 \n"
 171 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 172 "    LDR     PC, =0xFF3378DC \n"  // Continue in firmware
 173 );
 174 }
 175 
 176 /*************************************************************/
 177 //** sub_FF337968_my @ 0xFF337968 - 0xFF337A30, length=51
 178 void __attribute__((naked,noinline)) sub_FF337968_my() {
 179 asm volatile (
 180 "    STMFD   SP!, {R4-R10,LR} \n"
 181 "    MOV     R5, R0 \n"
 182 "    LDR     R0, [R0] \n"
 183 "    CMP     R0, #6 \n"
 184 "    BHI     loc_FF337994 \n"
 185 "    ADD     R0, R5, R0, LSL#3 \n"
 186 "    LDR     R8, [R0, #0x14]! \n"
 187 "    LDR     R7, [R0, #4] \n"
 188 "    CMP     R7, #0 \n"
 189 "    BNE     loc_FF3379AC \n"
 190 "    B       loc_FF3379A0 \n"
 191 
 192 "loc_FF337994:\n"
 193 "    LDR     R1, =0x29E \n"
 194 "    LDR     R0, =0xFF33761C /*'dwFWrite.c'*/ \n"
 195 "    BL      _DebugAssert \n"
 196 
 197 "loc_FF3379A0:\n"
 198 "    MOV     R1, R5 \n"
 199 "    MOV     R0, #7 \n"
 200 "    B       sub_FF337A40 \n"
 201 
 202 "loc_FF3379AC:\n"
 203 "    LDR     R9, =0xF12C \n"
 204 "    MOV     R4, R7 \n"
 205 
 206 "loc_FF3379B4:\n"
 207 "    LDR     R0, [R5, #4] \n"
 208 "    CMP     R4, #0x1000000 \n"
 209 "    MOVLS   R6, R4 \n"
 210 "    MOVHI   R6, #0x1000000 \n"
 211 "    BIC     R1, R0, #0xFF000000 \n"
 212 "    CMP     R1, #0 \n"
 213 "    BICNE   R0, R0, #0xFF000000 \n"
 214 "    RSBNE   R0, R0, #0x1000000 \n"
 215 "    CMPNE   R6, R0 \n"
 216 "    MOVHI   R6, R0 \n"
 217 "    LDR     R0, [R9, #4] \n"
 218 "    MOV     R2, R6 \n"
 219 "    MOV     R1, R8 \n"
 220 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 221 "    LDR     R1, [R5, #4] \n"
 222 "    CMP     R6, R0 \n"
 223 "    ADD     R1, R1, R0 \n"
 224 "    STR     R1, [R5, #4] \n"
 225 "    BEQ     loc_FF337A14 \n"
 226 "    CMN     R0, #1 \n"
 227 "    LDRNE   R0, =0x9200015 \n"
 228 "    LDREQ   R0, =0x9200005 \n"
 229 "    STR     R0, [R5, #0x10] \n"
 230 "    B       loc_FF3379A0 \n"
 231 
 232 "loc_FF337A14:\n"
 233 "    SUB     R4, R4, R0 \n"
 234 "    CMP     R4, R7 \n"
 235 "    ADD     R8, R8, R0 \n"
 236 "    LDRCS   R1, =0x2C9 \n"
 237 "    LDRCS   R0, =0xFF33761C /*'dwFWrite.c'*/ \n"
 238 "    BLCS    _DebugAssert \n"
 239 "    CMP     R4, #0 \n"
 240 "    BNE     loc_FF3379B4 \n"
 241 "    LDR     PC, =0xFF337A34 \n"  // Continue in firmware
 242 );
 243 }
 244 
 245 /*************************************************************/
 246 //** sub_FF3373BC_my @ 0xFF3373BC - 0xFF3373F0, length=14
 247 void __attribute__((naked,noinline)) sub_FF3373BC_my() {
 248 asm volatile (
 249 "    STMFD   SP!, {R4-R6,LR} \n"
 250 "    LDR     R5, =0xF12C \n"
 251 "    MOV     R4, R0 \n"
 252 "    LDR     R0, [R5, #4] \n"
 253 "    SUB     SP, SP, #0x38 \n"
 254 "    CMN     R0, #1 \n"
 255 "    BEQ     sub_FF337404 \n"
 256 "    LDR     R1, [R4, #8] \n"
 257 "    LDR     R6, =0x9200003 \n"
 258 "    TST     R1, #0x8000 \n"
 259 "    BEQ     loc_FF3373F0 \n"
 260 //mod start
 261 "    LDR R3, =current_write_ignored\n"
 262 "    LDR R3, [R3]\n"
 263 "    CMP R3, #0\n"
 264 "    BNE loc_D\n" // jump over the next block
 265 //mod end
 266 "    BL      sub_FF027694 \n"
 267 "    B       sub_FF3373F4 \n"
 268 
 269 "loc_FF3373F0:\n"
 270 "loc_D:\n"
 271 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 272 "    LDR     PC, =0xFF3373F4 \n"  // Continue in firmware
 273 );
 274 }

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