root/platform/ixus230_elph310hs/sub/100e/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF2C7AD4_my
  3. sub_FF2C7C74_my
  4. sub_FF2C7B94_my
  5. sub_FF2C7684_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 @ 0xFF2C77F0 - 0xFF2C78D4, length=58
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xB7E8 \n"
  35 
  36 "loc_FF2C77F8:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF02B314 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    LDRNE   R1, =0x35B \n"
  43 "    LDRNE   R0, =0xFF2C78E8 /*'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_FF2C77F8 \n"
  50 "    B       loc_FF2C78C8 \n"
  51 "    B       loc_FF2C78C8 \n"
  52 "    B       loc_FF2C78C8 \n"
  53 "    B       loc_FF2C78C8 \n"
  54 "    B       loc_FF2C78C8 \n"
  55 "    B       loc_FF2C78C8 \n"
  56 "    B       loc_FF2C78C8 \n"
  57 "    B       loc_FF2C78D0 \n"
  58 "    B       loc_FF2C7854 \n"
  59 "    B       loc_FF2C78C0 \n"
  60 
  61 "loc_FF2C7854:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF2C7860:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02B558 /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF2C788C \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF02B314 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF2C7860 \n"
  78 
  79 "loc_FF2C788C:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF2C78B4 \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x15A8F0 \n"
  87 "    BL      sub_FF069E7C \n"
  88 "    MOV     R1, #0 \n"
  89 "    BL      sub_FF0680F8 \n"
  90 
  91 "loc_FF2C78B4:\n"
  92 "    LDR     R0, [R4, #0xC] \n"
  93 "    BL      _GiveSemaphore \n"
  94 "    B       loc_FF2C77F8 \n"
  95 
  96 "loc_FF2C78C0:\n"
  97 "    BL      sub_FF2C7AD4_my \n"  // --> Patched. Old value = 0xFF2C7AD4.
  98 "    B       loc_FF2C77F8 \n"
  99 
 100 "loc_FF2C78C8:\n"
 101 "    BL      sub_FF2C7B94_my \n"  // --> Patched. Old value = 0xFF2C7B94.
 102 "    B       loc_FF2C77F8 \n"
 103 
 104 "loc_FF2C78D0:\n"
 105 "    BL      sub_FF2C7684_my \n"  // --> Patched. Old value = 0xFF2C7684.
 106 "    B       loc_FF2C77F8 \n"
 107 );
 108 }
 109 
 110 /*************************************************************/
 111 //** sub_FF2C7AD4_my @ 0xFF2C7AD4 - 0xFF2C7B18, length=18
 112 void __attribute__((naked,noinline)) sub_FF2C7AD4_my() {
 113 asm volatile (
 114 "    STMFD   SP!, {R4-R6,LR} \n"
 115 "    MOV     R4, R0 \n"
 116 "    ADD     R0, R0, #0x50 \n"
 117 "    BL      sub_FF069E7C \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF067FBC \n"
 120 "    LDR     R0, [R4, #0xC] \n"
 121 "    BL      sub_FF00033C \n"
 122 "    LDR     R0, [R4, #0x4C] \n"
 123 "    LDR     R2, =0x1B6 \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 //hook start
 129 "    STMFD   SP!, {R2-R12,LR} \n"
 130 "    MOV     R0, R4 \n"
 131 "    BL      filewrite_main_hook \n"
 132 "    LDMFD   SP!, {R2-R12,LR} \n"
 133 //hook end
 134 "    LDR     R1, [R4, #8] \n"
 135 "    LDR     R3, [R4, #0xC] \n"
 136 "    ADD     R0, R4, #0x50 \n"
 137 "    BL      sub_FF2C7C74_my \n"  // --> Patched. Old value = 0xFF2C7C74.
 138 "    LDR     PC, =0xFF2C7B1C \n"  // Continue in firmware
 139 );
 140 }
 141 
 142 /*************************************************************/
 143 //** sub_FF2C7C74_my @ 0xFF2C7C74 - 0xFF2C7D4C, length=55
 144 void __attribute__((naked,noinline)) sub_FF2C7C74_my() {
 145 asm volatile (
 146 "    STMFD   SP!, {R4-R10,LR} \n"
 147 "    SUB     SP, SP, #0x38 \n"
 148 "    MOV     R7, R0 \n"
 149 "    MOV     R8, R1 \n"
 150 "    MOV     R9, R2 \n"
 151 "    MOV     R5, R3 \n"
 152 "    BL      sub_FF1B41F0 /*_PTM_GetWorkingCaptureMode_FW*/ \n"
 153 "    AND     R0, R0, #0x7F \n"
 154 "    CMP     R0, #8 \n"
 155 "    CMPNE   R0, #0x22 \n"
 156 "    MOV     R6, #0 \n"
 157 "    MOVEQ   R4, #1 \n"
 158 "    MOVNE   R4, R6 \n"
 159 "    CMP     R4, #1 \n"
 160 "    BLEQ    sub_FF18C33C \n"
 161 "    MOV     R2, R9 \n"
 162 "    MOV     R1, R8 \n"
 163 "    MOV     R0, R7 \n"
 164 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 165 "    CMP     R4, #1 \n"
 166 "    MOV     R10, R0 \n"
 167 "    BLEQ    sub_FF18C38C \n"
 168 "    CMN     R10, #1 \n"
 169 "    MOVNE   R0, R10 \n"
 170 "    BNE     loc_FF2C7D48 \n"
 171 "    CMP     R4, #1 \n"
 172 "    BLEQ    sub_FF18C33C \n"
 173 "    MOV     R0, R7 \n"
 174 "    BL      sub_FF0286B0 \n"
 175 "    MOV     R2, #0xF \n"
 176 "    MOV     R1, R7 \n"
 177 "    MOV     R0, SP \n"
 178 "    BL      sub_FF3A2ACC \n"
 179 "    LDR     R0, =0x41FF \n"
 180 "    STRB    R6, [SP, #0xF] \n"
 181 "    STR     R0, [SP, #0x20] \n"
 182 "    MOV     R0, #0x10 \n"
 183 "    STR     R0, [SP, #0x24] \n"
 184 "    ADD     R1, SP, #0x20 \n"
 185 "    MOV     R0, SP \n"
 186 "    STR     R6, [SP, #0x28] \n"
 187 "    STR     R5, [SP, #0x2C] \n"
 188 "    STR     R5, [SP, #0x30] \n"
 189 "    STR     R5, [SP, #0x34] \n"
 190 "    BL      sub_FF067930 \n"
 191 "    MOV     R2, R9 \n"
 192 "    MOV     R1, R8 \n"
 193 "    MOV     R0, R7 \n"
 194 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 195 "    CMP     R4, #1 \n"
 196 "    MOV     R5, R0 \n"
 197 "    BLEQ    sub_FF18C38C \n"
 198 "    MOV     R0, R5 \n"
 199 
 200 "loc_FF2C7D48:\n"
 201 "    ADD     SP, SP, #0x38 \n"
 202 "    LDMFD   SP!, {R4-R10,PC} \n"
 203 );
 204 }
 205 
 206 /*************************************************************/
 207 //** sub_FF2C7B94_my @ 0xFF2C7B94 - 0xFF2C7C14, length=33
 208 void __attribute__((naked,noinline)) sub_FF2C7B94_my() {
 209 asm volatile (
 210 "    STMFD   SP!, {R4-R10,LR} \n"
 211 "    MOV     R5, R0 \n"
 212 "    LDR     R0, [R0] \n"
 213 "    CMP     R0, #6 \n"
 214 "    BHI     loc_FF2C7BC0 \n"
 215 "    ADD     R0, R5, R0, LSL#3 \n"
 216 "    LDR     R8, [R0, #0x14]! \n"
 217 "    LDR     R7, [R0, #4] \n"
 218 "    CMP     R7, #0 \n"
 219 "    BNE     loc_FF2C7BD8 \n"
 220 "    B       loc_FF2C7BCC \n"
 221 
 222 "loc_FF2C7BC0:\n"
 223 "    LDR     R1, =0x2BB \n"
 224 "    LDR     R0, =0xFF2C78E8 /*'dwFWrite.c'*/ \n"
 225 "    BL      _DebugAssert \n"
 226 
 227 "loc_FF2C7BCC:\n"
 228 "    MOV     R1, R5 \n"
 229 "    MOV     R0, #7 \n"
 230 "    B       sub_FF2C7C6C \n"
 231 
 232 "loc_FF2C7BD8:\n"
 233 "    LDR     R9, =0xB7E8 \n"
 234 "    MOV     R4, R7 \n"
 235 "    LDR     R0, [R5, #4] \n"
 236 "    CMP     R4, #0x1000000 \n"
 237 "    MOVLS   R6, R4 \n"
 238 "    MOVHI   R6, #0x1000000 \n"
 239 "    BIC     R1, R0, #0xFF000000 \n"
 240 "    CMP     R1, #0 \n"
 241 "    BICNE   R0, R0, #0xFF000000 \n"
 242 "    RSBNE   R0, R0, #0x1000000 \n"
 243 "    CMPNE   R6, R0 \n"
 244 "    MOVHI   R6, R0 \n"
 245 "    LDR     R0, [R9, #4] \n"
 246 "    MOV     R2, R6 \n"
 247 "    MOV     R1, R8 \n"
 248 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 249 "    LDR     PC, =0xFF2C7C18 \n"  // Continue in firmware
 250 );
 251 }
 252 
 253 /*************************************************************/
 254 //** sub_FF2C7684_my @ 0xFF2C7684 - 0xFF2C76B8, length=14
 255 void __attribute__((naked,noinline)) sub_FF2C7684_my() {
 256 asm volatile (
 257 "    STMFD   SP!, {R4-R6,LR} \n"
 258 "    LDR     R5, =0xB7E8 \n"
 259 "    MOV     R4, R0 \n"
 260 "    LDR     R0, [R5, #4] \n"
 261 "    SUB     SP, SP, #0x38 \n"
 262 "    CMN     R0, #1 \n"
 263 "    BEQ     sub_FF2C76CC \n"
 264 "    LDR     R1, [R4, #8] \n"
 265 "    LDR     R6, =0x9200003 \n"
 266 "    TST     R1, #0x8000 \n"
 267 "    BEQ     loc_FF2C76B8 \n"
 268 "    BL      sub_FF0280D4 \n"
 269 "    B       sub_FF2C76BC \n"
 270 
 271 "loc_FF2C76B8:\n"
 272 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 273 "    LDR     PC, =0xFF2C76BC \n"  // Continue in firmware
 274 );
 275 }

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