root/platform/ixus310_elph500hs/sub/100a/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF2E2258_my
  3. sub_FF2E27E8_my
  4. sub_FF2E2398_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 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_JPEG];
  23     int unkn2;
  24     char name[32];
  25 } fwt_data_struct;
  26 
  27 #include "../../../generic/filewrite.c"
  28 
  29 /*************************************************************/
  30 //** filewritetask @ 0xFF2E250C - 0xFF2E25EC, length=57
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xC20C \n"
  35 
  36 "loc_FF2E2514:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF02ADD8 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    MOVNE   R1, #0x348 \n"
  43 "    LDRNE   R0, =0xFF2E260C /*'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_FF2E2514 \n"
  50 "    B       loc_FF2E25E0 \n"
  51 "    B       loc_FF2E25E0 \n"
  52 "    B       loc_FF2E25E0 \n"
  53 "    B       loc_FF2E25E0 \n"
  54 "    B       loc_FF2E25E0 \n"
  55 "    B       loc_FF2E25E0 \n"
  56 "    B       loc_FF2E25E0 \n"
  57 "    B       loc_FF2E25E8 \n"
  58 "    B       loc_FF2E2570 \n"
  59 "    B       loc_FF2E25D8 \n"
  60 
  61 "loc_FF2E2570:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF2E257C:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02B01C /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF2E25A8 \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF02ADD8 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF2E257C \n"
  78 
  79 "loc_FF2E25A8:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF2E25CC \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x116DEC \n"
  87 "    BL      sub_FF0682A4 \n"
  88 "    BL      sub_FF06649C \n"
  89 
  90 "loc_FF2E25CC:\n"
  91 "    LDR     R0, [R4, #0xC] \n"
  92 "    BL      _GiveSemaphore \n"
  93 "    B       loc_FF2E2514 \n"
  94 
  95 "loc_FF2E25D8:\n"
  96 "    BL      sub_FF2E2258_my \n"  // --> Patched. Old value = 0xFF2E2258.
  97 "    B       loc_FF2E2514 \n"
  98 
  99 "loc_FF2E25E0:\n"
 100 "    BL      sub_FF2E27E8_my \n"  // --> Patched. Old value = 0xFF2E27E8.
 101 "    B       loc_FF2E2514 \n"
 102 
 103 "loc_FF2E25E8:\n"
 104 "    BL      sub_FF2E2398_my \n"  // --> Patched. Old value = 0xFF2E2398.
 105 "    B       loc_FF2E2514 \n"
 106 );
 107 }
 108 
 109 /*************************************************************/
 110 //** sub_FF2E2258_my @ 0xFF2E2258 - 0xFF2E2324, length=52
 111 void __attribute__((naked,noinline)) sub_FF2E2258_my() {
 112 asm volatile (
 113 "    STMFD   SP!, {R4-R9,LR} \n"
 114 "    MOV     R4, R0 \n"
 115 "    SUB     SP, SP, #0x3C \n"
 116 "    ADD     R0, R0, #0x50 \n"
 117 "    BL      sub_FF0682A4 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF066434 \n"
 120 "    LDR     R0, [R4, #0xC] \n"
 121 "    BL      sub_FF00033C \n"
 122 "    LDR     R0, [R4, #0x4C] \n"
 123 "    ADD     R7, R4, #0x50 \n"
 124 "    CMP     R0, #1 \n"
 125 "    LDREQ   R0, [R4, #8] \n"
 126 "    ORREQ   R0, R0, #0x8000 \n"
 127 "    STREQ   R0, [R4, #8] \n"
 128 "    LDR     R5, [R4, #0xC] \n"
 129 "    LDR     R8, [R4, #8] \n"
 130 "    BL      sub_FF1846F0 \n"
 131 //hook start
 132 "    STMFD   SP!, {R2,R4-R12,LR} \n"
 133 "    MOV     R0, R4 \n"
 134 "    BL      filewrite_main_hook \n"
 135 "    LDMFD   SP!, {R2,R4-R12,LR} \n"
 136 //hook end
 137 "    LDR     R9, =0x1B6 \n"
 138 "    MOV     R1, R8 \n"
 139 "    MOV     R2, R9 \n"
 140 "    MOV     R0, R7 \n"
 141 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 142 "    MOV     R6, R0 \n"
 143 "    BL      sub_FF1847C0 \n"
 144 "    CMN     R6, #1 \n"
 145 "    MOVNE   R5, R6 \n"
 146 "    BNE     sub_FF2E2330 \n"
 147 "    BL      sub_FF1846F0 \n"
 148 "    MOV     R0, R7 \n"
 149 "    BL      sub_FF027D1C \n"
 150 "    MOV     R2, #0xF \n"
 151 "    MOV     R1, R7 \n"
 152 "    ADD     R0, SP, #4 \n"
 153 "    BL      sub_FF3CA078 \n"
 154 "    MOV     R0, #0 \n"
 155 "    LDR     R1, =0x41FF \n"
 156 "    STRB    R0, [SP, #0x13] \n"
 157 "    STR     R1, [SP, #0x24] \n"
 158 "    MOV     R1, #0x10 \n"
 159 "    STR     R0, [SP, #0x2C] \n"
 160 "    STR     R1, [SP, #0x28] \n"
 161 "    ADD     R1, SP, #0x24 \n"
 162 "    ADD     R0, SP, #4 \n"
 163 "    STR     R5, [SP, #0x30] \n"
 164 "    STR     R5, [SP, #0x34] \n"
 165 "    STR     R5, [SP, #0x38] \n"
 166 "    BL      sub_FF065DA8 \n"
 167 "    MOV     R2, R9 \n"
 168 "    MOV     R1, R8 \n"
 169 "    MOV     R0, R7 \n"
 170 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 171 "    LDR     PC, =0xFF2E2328 \n"  // Continue in firmware
 172 );
 173 }
 174 
 175 /*************************************************************/
 176 //** sub_FF2E27E8_my @ 0xFF2E27E8 - 0xFF2E28B0, length=51
 177 void __attribute__((naked,noinline)) sub_FF2E27E8_my() {
 178 asm volatile (
 179 "    STMFD   SP!, {R4-R10,LR} \n"
 180 "    MOV     R5, R0 \n"
 181 "    LDR     R0, [R0] \n"
 182 "    CMP     R0, #6 \n"
 183 "    BHI     loc_FF2E2814 \n"
 184 "    ADD     R0, R5, R0, LSL#3 \n"
 185 "    LDR     R8, [R0, #0x14]! \n"
 186 "    LDR     R7, [R0, #4] \n"
 187 "    CMP     R7, #0 \n"
 188 "    BNE     loc_FF2E282C \n"
 189 "    B       loc_FF2E2820 \n"
 190 
 191 "loc_FF2E2814:\n"
 192 "    LDR     R1, =0x2A2 \n"
 193 "    LDR     R0, =0xFF2E260C /*'dwFWrite.c'*/ \n"
 194 "    BL      _DebugAssert \n"
 195 
 196 "loc_FF2E2820:\n"
 197 "    MOV     R1, R5 \n"
 198 "    MOV     R0, #7 \n"
 199 "    B       sub_FF2E28C0 \n"
 200 
 201 "loc_FF2E282C:\n"
 202 "    LDR     R9, =0xC20C \n"
 203 "    MOV     R4, R7 \n"
 204 
 205 "loc_FF2E2834:\n"
 206 "    LDR     R0, [R5, #4] \n"
 207 "    CMP     R4, #0x1000000 \n"
 208 "    MOVLS   R6, R4 \n"
 209 "    MOVHI   R6, #0x1000000 \n"
 210 "    BIC     R1, R0, #0xFF000000 \n"
 211 "    CMP     R1, #0 \n"
 212 "    BICNE   R0, R0, #0xFF000000 \n"
 213 "    RSBNE   R0, R0, #0x1000000 \n"
 214 "    CMPNE   R6, R0 \n"
 215 "    MOVHI   R6, R0 \n"
 216 "    LDR     R0, [R9, #4] \n"
 217 "    MOV     R2, R6 \n"
 218 "    MOV     R1, R8 \n"
 219 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 220 "    LDR     R1, [R5, #4] \n"
 221 "    CMP     R6, R0 \n"
 222 "    ADD     R1, R1, R0 \n"
 223 "    STR     R1, [R5, #4] \n"
 224 "    BEQ     loc_FF2E2894 \n"
 225 "    CMN     R0, #1 \n"
 226 "    LDRNE   R0, =0x9200015 \n"
 227 "    LDREQ   R0, =0x9200005 \n"
 228 "    STR     R0, [R5, #0x10] \n"
 229 "    B       loc_FF2E2820 \n"
 230 
 231 "loc_FF2E2894:\n"
 232 "    SUB     R4, R4, R0 \n"
 233 "    CMP     R4, R7 \n"
 234 "    LDRCS   R1, =0x2CD \n"
 235 "    ADD     R8, R8, R0 \n"
 236 "    LDRCS   R0, =0xFF2E260C /*'dwFWrite.c'*/ \n"
 237 "    BLCS    _DebugAssert \n"
 238 "    CMP     R4, #0 \n"
 239 "    BNE     loc_FF2E2834 \n"
 240 "    LDR     PC, =0xFF2E28B4 \n"  // Continue in firmware
 241 );
 242 }
 243 
 244 /*************************************************************/
 245 //** sub_FF2E2398_my @ 0xFF2E2398 - 0xFF2E23CC, length=14
 246 void __attribute__((naked,noinline)) sub_FF2E2398_my() {
 247 asm volatile (
 248 "    STMFD   SP!, {R4-R6,LR} \n"
 249 "    LDR     R5, =0xC20C \n"
 250 "    MOV     R4, R0 \n"
 251 "    LDR     R0, [R5, #4] \n"
 252 "    SUB     SP, SP, #0x38 \n"
 253 "    CMN     R0, #1 \n"
 254 "    BEQ     sub_FF2E23E0 \n"
 255 "    LDR     R1, [R4, #8] \n"
 256 "    LDR     R6, =0x9200003 \n"
 257 "    TST     R1, #0x8000 \n"
 258 "    BEQ     loc_FF2E23CC \n"
 259 //mod start
 260 "    LDR R3, =current_write_ignored\n"
 261 "    LDR R3, [R3]\n"
 262 "    CMP R3, #0\n"
 263 "    BNE loc_D\n" // jump over the next block
 264 //mod end
 265 "    BL      sub_FF027740 \n"
 266 "    B       sub_FF2E23D0 \n"
 267 
 268 "loc_FF2E23CC:\n"
 269 "loc_D:\n"
 270 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 271 "    LDR     PC, =0xFF2E23D0 \n"  // Continue in firmware
 272 );
 273 }

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