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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA891A0_my
  3. sub_FFA892E8_my
  4. sub_FFA88D50_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 @ 0xFFA88EC4 - 0xFFA88FA4, length=57
  33 void __attribute__((naked,noinline)) filewritetask() {
  34 asm volatile (
  35 "    STMFD   SP!, {R1-R5,LR} \n"
  36 "    LDR     R5, =0xAA98 \n"
  37 
  38 "loc_FFA88ECC:\n"
  39 "    MOV     R2, #0 \n"
  40 "    LDR     R0, [R5, #0x10] \n"
  41 "    ADD     R1, SP, #8 \n"
  42 "    BL      sub_FF839B6C /*_ReceiveMessageQueue*/ \n"
  43 "    CMP     R0, #0 \n"
  44 "    LDRNE   R1, =0x33F \n"
  45 "    LDRNE   R0, =0xFFA88FB8 /*'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_FFA88ECC \n"
  52 "    B       loc_FFA88F98 \n"
  53 "    B       loc_FFA88F98 \n"
  54 "    B       loc_FFA88F98 \n"
  55 "    B       loc_FFA88F98 \n"
  56 "    B       loc_FFA88F98 \n"
  57 "    B       loc_FFA88F98 \n"
  58 "    B       loc_FFA88F98 \n"
  59 "    B       loc_FFA88FA0 \n"
  60 "    B       loc_FFA88F28 \n"
  61 "    B       loc_FFA88F90 \n"
  62 
  63 "loc_FFA88F28:\n"
  64 "    MOV     R0, #0 \n"
  65 "    MOV     R4, R5 \n"
  66 "    STR     R0, [SP] \n"
  67 
  68 "loc_FFA88F34:\n"
  69 "    LDR     R0, [R4, #0x10] \n"
  70 "    MOV     R1, SP \n"
  71 "    BL      sub_FF839DB0 /*_GetNumberOfPostedMessages*/ \n"
  72 "    LDR     R0, [SP] \n"
  73 "    CMP     R0, #0 \n"
  74 "    BEQ     loc_FFA88F60 \n"
  75 "    LDR     R0, [R4, #0x10] \n"
  76 "    MOV     R2, #0 \n"
  77 "    ADD     R1, SP, #4 \n"
  78 "    BL      sub_FF839B6C /*_ReceiveMessageQueue*/ \n"
  79 "    B       loc_FFA88F34 \n"
  80 
  81 "loc_FFA88F60:\n"
  82 "    LDR     R0, [R4, #4] \n"
  83 "    CMN     R0, #1 \n"
  84 "    BEQ     loc_FFA88F84 \n"
  85 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  86 "    MVN     R0, #0 \n"
  87 "    STR     R0, [R4, #4] \n"
  88 "    LDR     R0, =0xF8A40 \n"
  89 "    BL      sub_FF86FE74 \n"
  90 "    BL      sub_FF86E0A0 \n"
  91 
  92 "loc_FFA88F84:\n"
  93 "    LDR     R0, [R4, #0xC] \n"
  94 "    BL      _GiveSemaphore \n"
  95 "    B       loc_FFA88ECC \n"
  96 
  97 "loc_FFA88F90:\n"
  98 "    BL      sub_FFA891A0_my \n"  // --> Patched. Old value = 0xFFA891A0. Open stage
  99 "    B       loc_FFA88ECC \n"
 100 
 101 "loc_FFA88F98:\n"
 102 "    BL      sub_FFA892E8_my \n"  // --> Patched. Old value = 0xFFA892E8. Write stage
 103 "    B       loc_FFA88ECC \n"
 104 
 105 "loc_FFA88FA0:\n"
 106 "    BL      sub_FFA88D50_my \n"  // --> Patched. Old value = 0xFFA88D50. Close stage
 107 "    B       loc_FFA88ECC \n"
 108 );
 109 }
 110 
 111 /*************************************************************/
 112 //** sub_FFA891A0_my @ 0xFFA891A0 - 0xFFA891F4, length=22
 113 void __attribute__((naked,noinline)) sub_FFA891A0_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_FF86FE74 \n"
 120 "    MOV     R1, #0 \n"
 121 "    BL      sub_FF86E038 \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, =0xFFA891F8 \n"  // Continue in firmware
 144 );
 145 }
 146 
 147 /*************************************************************/
 148 //** sub_FFA892E8_my @ 0xFFA892E8 - 0xFFA893F0, length=67
 149 void __attribute__((naked,noinline)) sub_FFA892E8_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_FFA89314 \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_FFA8932C \n"
 161 "    B       loc_FFA89320 \n"
 162 
 163 "loc_FFA89314:\n"
 164 "    LDR     R1, =0x299 \n"
 165 "    LDR     R0, =0xFFA88FB8 /*'dwFWrite.c'*/ \n"
 166 "    BL      _DebugAssert \n"
 167 
 168 "loc_FFA89320:\n"
 169 "    MOV     R1, R5 \n"
 170 "    MOV     R0, #7 \n"
 171 "    B       loc_FFA893C0 \n"
 172 
 173 "loc_FFA8932C:\n"
 174 "    LDR     R9, =0xAA98 \n"
 175 "    MOV     R4, R7 \n"
 176 
 177 "loc_FFA89334:\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_FFA89394 \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_FFA89320 \n"
 202 
 203 "loc_FFA89394:\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, =0xFFA88FB8 /*'dwFWrite.c'*/ \n"
 209 "    BLCS    _DebugAssert \n"
 210 "    CMP     R4, #0 \n"
 211 "    BNE     loc_FFA89334 \n"
 212 "    LDR     R0, [R5] \n"
 213 "    MOV     R1, R5 \n"
 214 "    ADD     R0, R0, #1 \n"
 215 
 216 "loc_FFA893C0:\n"
 217 "    LDMFD   SP!, {R4-R10,LR} \n"
 218 "    B       sub_FFA88CA0 \n"
 219 );
 220 }
 221 
 222 /*************************************************************/
 223 //** sub_FFA88D50_my @ 0xFFA88D50 - 0xFFA88D84, length=14
 224 void __attribute__((naked,noinline)) sub_FFA88D50_my() {
 225 asm volatile (
 226 "    STMFD   SP!, {R4-R6,LR} \n"
 227 "    LDR     R5, =0xAA98 \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_FFA88D98 \n"
 233 "    LDR     R1, [R4, #8] \n"
 234 "    LDR     R6, =0x9200003 \n"
 235 "    TST     R1, #0x8000 \n"
 236 "    BEQ     loc_FFA88D84 \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 "    BL      sub_FF836E2C \n"
 244 "    B       sub_FFA88D88 \n"
 245 
 246 "loc_FFA88D84:\n"
 247 "loc_D:\n"
 248 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 249 "    LDR     PC, =0xFFA88D88 \n"  // Continue in firmware
 250 );
 251 }

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