root/platform/a1200/sub/100b/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA895CC_my
  3. sub_FFA89714_my
  4. sub_FFA8917C_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  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  17  * pdc is always required
  18  * name is not currently used
  19  */
  20 
  21 typedef struct
  22 {
  23     int unkn1[5];
  24     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  25     int unkn6;
  26     char name[32];
  27 } fwt_data_struct;
  28 
  29 #include "../../../generic/filewrite.c"
  30 
  31 /*************************************************************/
  32 //** filewritetask @ 0xFFA892F0 - 0xFFA893D0, length=57
  33 void __attribute__((naked,noinline)) filewritetask() {
  34 asm volatile (
  35 "    STMFD   SP!, {R1-R5,LR} \n"
  36 "    LDR     R5, =0xA9C8 \n"
  37 
  38 "loc_FFA892F8:\n"
  39 "    MOV     R2, #0 \n"
  40 "    LDR     R0, [R5, #0x10] \n"
  41 "    ADD     R1, SP, #8 \n"
  42 "    BL      sub_FF8397A4 /*_ReceiveMessageQueue*/ \n"
  43 "    CMP     R0, #0 \n"
  44 "    LDRNE   R1, =0x33F \n"
  45 "    LDRNE   R0, =0xFFA893E4 /*'dwFWrite.c'*/ \n"
  46 "    BLNE    _DebugAssert \n"
  47 "    LDR     R0, [SP, #8] \n"
  48 "    LDR     R1, [R0] \n"
  49 "    CMP     R1, #0xA \n"
  50 "    ADDCC   PC, PC, R1, LSL#2 \n"
  51 "    B       loc_FFA892F8 \n"
  52 "    B       loc_FFA893C4 \n"
  53 "    B       loc_FFA893C4 \n"
  54 "    B       loc_FFA893C4 \n"
  55 "    B       loc_FFA893C4 \n"
  56 "    B       loc_FFA893C4 \n"
  57 "    B       loc_FFA893C4 \n"
  58 "    B       loc_FFA893C4 \n"
  59 "    B       loc_FFA893CC \n"
  60 "    B       loc_FFA89354 \n"
  61 "    B       loc_FFA893BC \n"
  62 
  63 "loc_FFA89354:\n"
  64 "    MOV     R0, #0 \n"
  65 "    MOV     R4, R5 \n"
  66 "    STR     R0, [SP] \n"
  67 
  68 "loc_FFA89360:\n"
  69 "    LDR     R0, [R4, #0x10] \n"
  70 "    MOV     R1, SP \n"
  71 "    BL      sub_FF8399E8 /*_GetNumberOfPostedMessages*/ \n"
  72 "    LDR     R0, [SP] \n"
  73 "    CMP     R0, #0 \n"
  74 "    BEQ     loc_FFA8938C \n"
  75 "    LDR     R0, [R4, #0x10] \n"
  76 "    MOV     R2, #0 \n"
  77 "    ADD     R1, SP, #4 \n"
  78 "    BL      sub_FF8397A4 /*_ReceiveMessageQueue*/ \n"
  79 "    B       loc_FFA89360 \n"
  80 
  81 "loc_FFA8938C:\n"
  82 "    LDR     R0, [R4, #4] \n"
  83 "    CMN     R0, #1 \n"
  84 "    BEQ     loc_FFA893B0 \n"
  85 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  86 "    MVN     R0, #0 \n"
  87 "    STR     R0, [R4, #4] \n"
  88 "    LDR     R0, =0xF83A8 \n"
  89 "    BL      sub_FF86F498 \n"
  90 "    BL      sub_FF86D6C4 \n"
  91 
  92 "loc_FFA893B0:\n"
  93 "    LDR     R0, [R4, #0xC] \n"
  94 "    BL      _GiveSemaphore \n"
  95 "    B       loc_FFA892F8 \n"
  96 
  97 "loc_FFA893BC:\n"
  98 "    BL      sub_FFA895CC_my \n"  // --> Patched. Old value = 0xFFA895CC. Open stage
  99 "    B       loc_FFA892F8 \n"
 100 
 101 "loc_FFA893C4:\n"
 102 "    BL      sub_FFA89714_my \n"  // --> Patched. Old value = 0xFFA89714. Write stage
 103 "    B       loc_FFA892F8 \n"
 104 
 105 "loc_FFA893CC:\n"
 106 "    BL      sub_FFA8917C_my \n"  // --> Patched. Old value = 0xFFA8917C. Close stage
 107 "    B       loc_FFA892F8 \n"
 108 );
 109 }
 110 
 111 /*************************************************************/
 112 //** sub_FFA895CC_my @ 0xFFA895CC - 0xFFA89620, length=22
 113 void __attribute__((naked,noinline)) sub_FFA895CC_my() {
 114 asm volatile (
 115 "    STMFD   SP!, {R4-R8,LR} \n"
 116 "    MOV     R4, R0 \n"
 117 "    SUB     SP, SP, #0x38 \n"
 118 "    ADD     R0, R0, #0x50 \n"
 119 "    BL      sub_FF86F498 \n"
 120 "    MOV     R1, #0 \n"
 121 "    BL      sub_FF86D65C \n"
 122 "    LDR     R0, [R4, #0xC] \n"
 123 "    BL      sub_FF81033C \n"
 124 "    LDR     R0, [R4, #0x4C] \n"
 125 "    LDR     R8, =0x1B6 \n"
 126 "    CMP     R0, #1 \n"
 127 "    LDREQ   R0, [R4, #8] \n"
 128 "    ADD     R6, R4, #0x50 \n"
 129 "    ORREQ   R0, R0, #0x8000 \n"
 130 "    STREQ   R0, [R4, #8] \n"
 131 //hook start
 132 "    STMFD SP!, {R4-R12,LR}\n"
 133 "    MOV R0, R4\n"
 134 "    BL filewrite_main_hook\n"
 135 "    LDMFD SP!, {R4-R12,LR}\n"
 136 //hook end
 137 "    LDR     R7, [R4, #8] \n"
 138 "    LDR     R5, [R4, #0xC] \n"
 139 "    MOV     R2, R8 \n"
 140 "    MOV     R1, R7 \n"
 141 "    MOV     R0, R6 \n"
 142 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 143 "    LDR     PC, =0xFFA89624 \n"  // Continue in firmware
 144 );
 145 }
 146 
 147 /*************************************************************/
 148 //** sub_FFA89714_my @ 0xFFA89714 - 0xFFA8981C, length=67
 149 void __attribute__((naked,noinline)) sub_FFA89714_my() {
 150 asm volatile (
 151 "    STMFD   SP!, {R4-R10,LR} \n"
 152 "    MOV     R5, R0 \n"
 153 "    LDR     R0, [R0] \n"
 154 "    CMP     R0, #6 \n"
 155 "    BHI     loc_FFA89740 \n"
 156 "    ADD     R0, R5, R0, LSL#3 \n"
 157 "    LDR     R8, [R0, #0x14]! \n"
 158 "    LDR     R7, [R0, #4] \n"
 159 "    CMP     R7, #0 \n"
 160 "    BNE     loc_FFA89758 \n"
 161 "    B       loc_FFA8974C \n"
 162 
 163 "loc_FFA89740:\n"
 164 "    LDR     R1, =0x299 \n"
 165 "    LDR     R0, =0xFFA893E4 /*'dwFWrite.c'*/ \n"
 166 "    BL      _DebugAssert \n"
 167 
 168 "loc_FFA8974C:\n"
 169 "    MOV     R1, R5 \n"
 170 "    MOV     R0, #7 \n"
 171 "    B       loc_FFA897EC \n"
 172 
 173 "loc_FFA89758:\n"
 174 "    LDR     R9, =0xA9C8 \n"
 175 "    MOV     R4, R7 \n"
 176 
 177 "loc_FFA89760:\n"
 178 "    LDR     R0, [R5, #4] \n"
 179 "    CMP     R4, #0x1000000 \n"
 180 "    MOVLS   R6, R4 \n"
 181 "    MOVHI   R6, #0x1000000 \n"
 182 "    BIC     R1, R0, #0xFF000000 \n"
 183 "    CMP     R1, #0 \n"
 184 "    BICNE   R0, R0, #0xFF000000 \n"
 185 "    RSBNE   R0, R0, #0x1000000 \n"
 186 "    CMPNE   R6, R0 \n"
 187 "    MOVHI   R6, R0 \n"
 188 "    LDR     R0, [R9, #4] \n"
 189 "    MOV     R2, R6 \n"
 190 "    MOV     R1, R8 \n"
 191 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 192 "    LDR     R1, [R5, #4] \n"
 193 "    CMP     R6, R0 \n"
 194 "    ADD     R1, R1, R0 \n"
 195 "    STR     R1, [R5, #4] \n"
 196 "    BEQ     loc_FFA897C0 \n"
 197 "    CMN     R0, #1 \n"
 198 "    LDRNE   R0, =0x9200015 \n"
 199 "    LDREQ   R0, =0x9200005 \n"
 200 "    STR     R0, [R5, #0x10] \n"
 201 "    B       loc_FFA8974C \n"
 202 
 203 "loc_FFA897C0:\n"
 204 "    SUB     R4, R4, R0 \n"
 205 "    CMP     R4, R7 \n"
 206 "    ADD     R8, R8, R0 \n"
 207 "    MOVCS   R1, #0x2C4 \n"
 208 "    LDRCS   R0, =0xFFA893E4 /*'dwFWrite.c'*/ \n"
 209 "    BLCS    _DebugAssert \n"
 210 "    CMP     R4, #0 \n"
 211 "    BNE     loc_FFA89760 \n"
 212 "    LDR     R0, [R5] \n"
 213 "    MOV     R1, R5 \n"
 214 "    ADD     R0, R0, #1 \n"
 215 
 216 "loc_FFA897EC:\n"
 217 "    LDMFD   SP!, {R4-R10,LR} \n"
 218 "    B       sub_FFA890CC \n"
 219 );
 220 }
 221 
 222 /*************************************************************/
 223 //** sub_FFA8917C_my @ 0xFFA8917C - 0xFFA891B0, length=14
 224 void __attribute__((naked,noinline)) sub_FFA8917C_my() {
 225 asm volatile (
 226 "    STMFD   SP!, {R4-R6,LR} \n"
 227 "    LDR     R5, =0xA9C8 \n"
 228 "    MOV     R4, R0 \n"
 229 "    LDR     R0, [R5, #4] \n"
 230 "    SUB     SP, SP, #0x38 \n"
 231 "    CMN     R0, #1 \n"
 232 "    BEQ     sub_FFA891C4 \n"
 233 "    LDR     R1, [R4, #8] \n"
 234 "    LDR     R6, =0x9200003 \n"
 235 "    TST     R1, #0x8000 \n"
 236 "    BEQ     loc_FFA891B0 \n"
 237 //mod start
 238 "    LDR R3, =current_write_ignored\n"
 239 "    LDR R3, [R3]\n"
 240 "    CMP R3, #0\n"
 241 "    BNE loc_D\n" // jump over the next block
 242 //mod end
 243 
 244 "    BL      sub_FF836AE4 \n"
 245 "    B       sub_FFA891B4 \n"
 246 
 247 "loc_FFA891B0:\n"
 248 "loc_D:\n"
 249 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 250 "    LDR     PC, =0xFFA891B4 \n"  // Continue in firmware
 251 );
 252 }

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