root/platform/g1x/sub/101a/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF34AC30_my
  3. sub_FF34ADD0_my
  4. sub_FF34ACF0_my
  5. sub_FF34A7E0_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 @ 0xFF34A94C - 0xFF34AA30, length=58
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xFEBC \n"
  35 
  36 "loc_FF34A954:\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, =0xFF34AA44 /*'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_FF34A954 \n"
  50 "    B       loc_FF34AA24 \n"
  51 "    B       loc_FF34AA24 \n"
  52 "    B       loc_FF34AA24 \n"
  53 "    B       loc_FF34AA24 \n"
  54 "    B       loc_FF34AA24 \n"
  55 "    B       loc_FF34AA24 \n"
  56 "    B       loc_FF34AA24 \n"
  57 "    B       loc_FF34AA2C \n"
  58 "    B       loc_FF34A9B0 \n"
  59 "    B       loc_FF34AA1C \n"
  60 
  61 "loc_FF34A9B0:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF34A9BC:\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_FF34A9E8 \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_FF34A9BC \n"
  78 
  79 "loc_FF34A9E8:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF34AA10 \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_FF06CDB8 \n"
  88 "    MOV     R1, #0 \n"
  89 "    BL      sub_FF06B034 \n"
  90 
  91 "loc_FF34AA10:\n"
  92 "    LDR     R0, [R4, #0xC] \n"
  93 "    BL      _GiveSemaphore \n"
  94 "    B       loc_FF34A954 \n"
  95 
  96 "loc_FF34AA1C:\n"
  97 "    BL      sub_FF34AC30_my \n"  // --> Patched. Old value = 0xFF34AC30.
  98 "    B       loc_FF34A954 \n"
  99 
 100 "loc_FF34AA24:\n"
 101 "    BL      sub_FF34ACF0_my \n"  // --> Patched. Old value = 0xFF34ACF0.
 102 "    B       loc_FF34A954 \n"
 103 
 104 "loc_FF34AA2C:\n"
 105 "    BL      sub_FF34A7E0_my \n"  // --> Patched. Old value = 0xFF34A7E0.
 106 "    B       loc_FF34A954 \n"
 107 );
 108 }
 109 
 110 /*************************************************************/
 111 //** sub_FF34AC30_my @ 0xFF34AC30 - 0xFF34AC74, length=18
 112 void __attribute__((naked,noinline)) sub_FF34AC30_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_FF06CDB8 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF06AEF8 \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_FF34ADD0_my \n"  // --> Patched. Old value = 0xFF34ADD0.
 138 "    LDR     PC, =0xFF34AC78 \n"  // Continue in firmware
 139 );
 140 }
 141 
 142 /*************************************************************/
 143 //** sub_FF34ADD0_my @ 0xFF34ADD0 - 0xFF34AEA8, length=55
 144 void __attribute__((naked,noinline)) sub_FF34ADD0_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_FF205AD4 /*_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_FF1D0BF8 \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_FF1D0C44 \n"
 168 "    CMN     R10, #1 \n"
 169 "    MOVNE   R0, R10 \n"
 170 "    BNE     loc_FF34AEA4 \n"
 171 "    CMP     R4, #1 \n"
 172 "    BLEQ    sub_FF1D0BF8 \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_FF45F638 \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_FF06A86C \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_FF1D0C44 \n"
 198 "    MOV     R0, R5 \n"
 199 
 200 "loc_FF34AEA4:\n"
 201 "    ADD     SP, SP, #0x38 \n"
 202 "    LDMFD   SP!, {R4-R10,PC} \n"
 203 );
 204 }
 205 
 206 /*************************************************************/
 207 //** sub_FF34ACF0_my @ 0xFF34ACF0 - 0xFF34ADB8, length=51
 208 void __attribute__((naked,noinline)) sub_FF34ACF0_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_FF34AD1C \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_FF34AD34 \n"
 220 "    B       loc_FF34AD28 \n"
 221 
 222 "loc_FF34AD1C:\n"
 223 "    LDR     R1, =0x2BB \n"
 224 "    LDR     R0, =0xFF34AA44 /*'dwFWrite.c'*/ \n"
 225 "    BL      _DebugAssert \n"
 226 
 227 "loc_FF34AD28:\n"
 228 "    MOV     R1, R5 \n"
 229 "    MOV     R0, #7 \n"
 230 "    B       sub_FF34ADC8 \n"
 231 
 232 "loc_FF34AD34:\n"
 233 "    LDR     R9, =0xFEBC \n"
 234 "    MOV     R4, R7 \n"
 235 
 236 "loc_FF34AD3C:\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_FF34AD9C \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_FF34AD28 \n"
 261 
 262 "loc_FF34AD9C:\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, =0xFF34AA44 /*'dwFWrite.c'*/ \n"
 268 "    BLCS    _DebugAssert \n"
 269 "    CMP     R4, #0 \n"
 270 "    BNE     loc_FF34AD3C \n"
 271 "    LDR     PC, =0xFF34ADBC \n"  // Continue in firmware
 272 );
 273 }
 274 
 275 /*************************************************************/
 276 //** sub_FF34A7E0_my @ 0xFF34A7E0 - 0xFF34A814, length=14
 277 void __attribute__((naked,noinline)) sub_FF34A7E0_my() {
 278 asm volatile (
 279 "    STMFD   SP!, {R4-R6,LR} \n"
 280 "    LDR     R5, =0xFEBC \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_FF34A828 \n"
 286 "    LDR     R1, [R4, #8] \n"
 287 "    LDR     R6, =0x9200003 \n"
 288 "    TST     R1, #0x8000 \n"
 289 "    BEQ     loc_FF34A814 \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_FF34A818 \n"
 298 
 299 "loc_FF34A814:\n"
 300 "loc_D:\n"
 301 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 302 "    LDR     PC, =0xFF34A818 \n"  // Continue in firmware
 303 );
 304 }

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