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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF34A47C_my
  3. sub_FF34A61C_my
  4. sub_FF34A53C_my
  5. sub_FF34A02C_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 @ 0xFF34A198 - 0xFF34A27C, length=58
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xFEA4 \n"
  35 
  36 "loc_FF34A1A0:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF029EA8 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    LDRNE   R1, =0x35B \n"
  43 "    LDRNE   R0, =0xFF34A290 /*'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_FF34A1A0 \n"
  50 "    B       loc_FF34A270 \n"
  51 "    B       loc_FF34A270 \n"
  52 "    B       loc_FF34A270 \n"
  53 "    B       loc_FF34A270 \n"
  54 "    B       loc_FF34A270 \n"
  55 "    B       loc_FF34A270 \n"
  56 "    B       loc_FF34A270 \n"
  57 "    B       loc_FF34A278 \n"
  58 "    B       loc_FF34A1FC \n"
  59 "    B       loc_FF34A268 \n"
  60 
  61 "loc_FF34A1FC:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF34A208:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02A0EC /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF34A234 \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF029EA8 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF34A208 \n"
  78 
  79 "loc_FF34A234:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF34A25C \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x162874 \n"
  87 "    BL      sub_FF06CD84 \n"
  88 "    MOV     R1, #0 \n"
  89 "    BL      sub_FF06B000 \n"
  90 
  91 "loc_FF34A25C:\n"
  92 "    LDR     R0, [R4, #0xC] \n"
  93 "    BL      _GiveSemaphore \n"
  94 "    B       loc_FF34A1A0 \n"
  95 
  96 "loc_FF34A268:\n"
  97 "    BL      sub_FF34A47C_my \n"  // --> Patched. Old value = 0xFF34A47C.
  98 "    B       loc_FF34A1A0 \n"
  99 
 100 "loc_FF34A270:\n"
 101 "    BL      sub_FF34A53C_my \n"  // --> Patched. Old value = 0xFF34A53C.
 102 "    B       loc_FF34A1A0 \n"
 103 
 104 "loc_FF34A278:\n"
 105 "    BL      sub_FF34A02C_my \n"  // --> Patched. Old value = 0xFF34A02C.
 106 "    B       loc_FF34A1A0 \n"
 107 );
 108 }
 109 
 110 /*************************************************************/
 111 //** sub_FF34A47C_my @ 0xFF34A47C - 0xFF34A4C0, length=18
 112 void __attribute__((naked,noinline)) sub_FF34A47C_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_FF06CD84 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF06AEC4 \n"
 120 "    LDR     R0, [R4, #0xC] \n"
 121 "    BL      sub_FF000348 \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_FF34A61C_my \n"  // --> Patched. Old value = 0xFF34A61C.
 138 "    LDR     PC, =0xFF34A4C4 \n"  // Continue in firmware
 139 );
 140 }
 141 
 142 /*************************************************************/
 143 //** sub_FF34A61C_my @ 0xFF34A61C - 0xFF34A6F4, length=55
 144 void __attribute__((naked,noinline)) sub_FF34A61C_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_FF205A78 /*_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_FF1D0BAC \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_FF1D0BFC \n"
 168 "    CMN     R10, #1 \n"
 169 "    MOVNE   R0, R10 \n"
 170 "    BNE     loc_FF34A6F0 \n"
 171 "    CMP     R4, #1 \n"
 172 "    BLEQ    sub_FF1D0BAC \n"
 173 "    MOV     R0, R7 \n"
 174 "    BL      sub_FF026AE4 \n"
 175 "    MOV     R2, #0xF \n"
 176 "    MOV     R1, R7 \n"
 177 "    MOV     R0, SP \n"
 178 "    BL      sub_FF45EA8C \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_FF06A838 \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_FF1D0BFC \n"
 198 "    MOV     R0, R5 \n"
 199 
 200 "loc_FF34A6F0:\n"
 201 "    ADD     SP, SP, #0x38 \n"
 202 "    LDMFD   SP!, {R4-R10,PC} \n"
 203 );
 204 }
 205 
 206 /*************************************************************/
 207 //** sub_FF34A53C_my @ 0xFF34A53C - 0xFF34A604, length=51
 208 void __attribute__((naked,noinline)) sub_FF34A53C_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_FF34A568 \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_FF34A580 \n"
 220 "    B       loc_FF34A574 \n"
 221 
 222 "loc_FF34A568:\n"
 223 "    LDR     R1, =0x2BB \n"
 224 "    LDR     R0, =0xFF34A290 /*'dwFWrite.c'*/ \n"
 225 "    BL      _DebugAssert \n"
 226 
 227 "loc_FF34A574:\n"
 228 "    MOV     R1, R5 \n"
 229 "    MOV     R0, #7 \n"
 230 "    B       sub_FF34A614 \n"
 231 
 232 "loc_FF34A580:\n"
 233 "    LDR     R9, =0xFEA4 \n"
 234 "    MOV     R4, R7 \n"
 235 
 236 "loc_FF34A588:\n"
 237 "    LDR     R0, [R5, #4] \n"
 238 "    CMP     R4, #0x1000000 \n"
 239 "    MOVLS   R6, R4 \n"
 240 "    MOVHI   R6, #0x1000000 \n"
 241 "    BIC     R1, R0, #0xFF000000 \n"
 242 "    CMP     R1, #0 \n"
 243 "    BICNE   R0, R0, #0xFF000000 \n"
 244 "    RSBNE   R0, R0, #0x1000000 \n"
 245 "    CMPNE   R6, R0 \n"
 246 "    MOVHI   R6, R0 \n"
 247 "    LDR     R0, [R9, #4] \n"
 248 "    MOV     R2, R6 \n"
 249 "    MOV     R1, R8 \n"
 250 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 251 "    LDR     R1, [R5, #4] \n"
 252 "    CMP     R6, R0 \n"
 253 "    ADD     R1, R1, R0 \n"
 254 "    STR     R1, [R5, #4] \n"
 255 "    BEQ     loc_FF34A5E8 \n"
 256 "    CMN     R0, #1 \n"
 257 "    LDRNE   R0, =0x9200015 \n"
 258 "    LDREQ   R0, =0x9200005 \n"
 259 "    STR     R0, [R5, #0x10] \n"
 260 "    B       loc_FF34A574 \n"
 261 
 262 "loc_FF34A5E8:\n"
 263 "    SUB     R4, R4, R0 \n"
 264 "    CMP     R4, R7 \n"
 265 "    LDRCS   R1, =0x2E6 \n"
 266 "    ADD     R8, R8, R0 \n"
 267 "    LDRCS   R0, =0xFF34A290 /*'dwFWrite.c'*/ \n"
 268 "    BLCS    _DebugAssert \n"
 269 "    CMP     R4, #0 \n"
 270 "    BNE     loc_FF34A588 \n"
 271 "    LDR     PC, =0xFF34A608 \n"  // Continue in firmware
 272 );
 273 }
 274 
 275 /*************************************************************/
 276 //** sub_FF34A02C_my @ 0xFF34A02C - 0xFF34A060, length=14
 277 void __attribute__((naked,noinline)) sub_FF34A02C_my() {
 278 asm volatile (
 279 "    STMFD   SP!, {R4-R6,LR} \n"
 280 "    LDR     R5, =0xFEA4 \n"
 281 "    MOV     R4, R0 \n"
 282 "    LDR     R0, [R5, #4] \n"
 283 "    SUB     SP, SP, #0x38 \n"
 284 "    CMN     R0, #1 \n"
 285 "    BEQ     sub_FF34A074 \n"
 286 "    LDR     R1, [R4, #8] \n"
 287 "    LDR     R6, =0x9200003 \n"
 288 "    TST     R1, #0x8000 \n"
 289 "    BEQ     loc_FF34A060 \n"
 290 //mod start
 291 "    LDR R3, =current_write_ignored\n"
 292 "    LDR R3, [R3]\n"
 293 "    CMP R3, #0\n"
 294 "    BNE loc_D\n" // jump over the next block
 295 //mod end
 296 "    BL      sub_FF026508 \n"
 297 "    B       sub_FF34A064 \n"
 298 
 299 "loc_FF34A060:\n"
 300 "loc_D:\n"
 301 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 302 "    LDR     PC, =0xFF34A064 \n"  // Continue in firmware
 303 );
 304 }

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