root/platform/s5is/sub/101b/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA25DA8_my
  3. sub_FFA25ED4_my
  4. sub_FFA25FA4_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 3 //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 typedef struct
  21 {
  22     int unkn1[5];                                //
  23     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  24     char name[32];                               // open stage: sub_FFDBFF20 --> "ADD     R0, R0, #0x2C"
  25                                                  // offset of 'name' from start = 0x2C = 44 bytes = 11 words
  26 } fwt_data_struct;
  27 
  28 #include "../../../generic/filewrite.c"
  29 
  30 /*************************************************************/
  31 //** filewritetask @ 0xFFA25B10 - 0xFFA25BF0, length=57
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R1-R5,LR} \n"
  35 "    LDR     R4, =0xE3C4 \n"
  36 
  37 "loc_FFA25B18:\n"
  38 "    LDR     R0, [R4, #0x10] \n"
  39 "    MOV     R2, #0 \n"
  40 "    ADD     R1, SP, #8 \n"
  41 "    BL      sub_FF82A4F8 /*_ReceiveMessageQueue*/ \n"
  42 "    CMP     R0, #0 \n"
  43 "    BNE     loc_FFA25B48 \n"
  44 "    LDR     R0, [SP, #8] \n"
  45 "    LDR     R1, [R0] \n"
  46 "    CMP     R1, #1 \n"
  47 "    BNE     loc_FFA25B50 \n"
  48 "    LDR     R0, [R4, #8] \n"
  49 "    BL      _GiveSemaphore \n"
  50 
  51 "loc_FFA25B48:\n"
  52 "    BL      _ExitTask \n"
  53 "    LDMFD   SP!, {R1-R5,PC} \n"
  54 
  55 "loc_FFA25B50:\n"
  56 "    SUB     R1, R1, #2 \n"
  57 "    CMP     R1, #5 \n"
  58 "    ADDLS   PC, PC, R1, LSL#2 \n"
  59 "    B       loc_FFA25B18 \n"
  60 "    B       loc_FFA25B78 \n"
  61 "    B       loc_FFA25BDC \n"
  62 "    B       loc_FFA25BE4 \n"
  63 "    B       loc_FFA25BE4 \n"
  64 "    B       loc_FFA25BE4 \n"
  65 "    B       loc_FFA25BEC \n"
  66 
  67 "loc_FFA25B78:\n"
  68 "    MOV     R0, #0 \n"
  69 "    STR     R0, [SP] \n"
  70 
  71 "loc_FFA25B80:\n"
  72 "    LDR     R0, [R4, #0x10] \n"
  73 "    MOV     R1, SP \n"
  74 "    BL      sub_FF82A6FC /*_GetNumberOfPostedMessages*/ \n"
  75 "    LDR     R0, [SP] \n"
  76 "    CMP     R0, #0 \n"
  77 "    BEQ     loc_FFA25BAC \n"
  78 "    LDR     R0, [R4, #0x10] \n"
  79 "    MOV     R2, #0 \n"
  80 "    ADD     R1, SP, #4 \n"
  81 "    BL      sub_FF82A4F8 /*_ReceiveMessageQueue*/ \n"
  82 "    B       loc_FFA25B80 \n"
  83 
  84 "loc_FFA25BAC:\n"
  85 "    LDR     R0, [R4] \n"
  86 "    CMN     R0, #1 \n"
  87 "    BEQ     loc_FFA25BD0 \n"
  88 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  89 "    MVN     R0, #0 \n"
  90 "    STR     R0, [R4] \n"
  91 "    LDR     R0, =0x88B20 \n"
  92 "    BL      sub_FF856E44 \n"
  93 "    BL      sub_FF85845C \n"
  94 
  95 "loc_FFA25BD0:\n"
  96 "    LDR     R0, [R4, #0xC] \n"
  97 "    BL      _GiveSemaphore \n"
  98 "    B       loc_FFA25B18 \n"
  99 
 100 "loc_FFA25BDC:\n"
 101 "    BL      sub_FFA25DA8_my \n"  // --> Patched. Old value = 0xFFA25DA8. Open stage
 102 "    B       loc_FFA25B18 \n"
 103 
 104 "loc_FFA25BE4:\n"
 105 "    BL      sub_FFA25ED4_my \n"  // --> Patched. Old value = 0xFFA25ED4. Write stage
 106 "    B       loc_FFA25B18 \n"
 107 
 108 "loc_FFA25BEC:\n"
 109 "    BL      sub_FFA25FA4_my \n"  // --> Patched. Old value = 0xFFA25FA4. Close stage
 110 "    B       loc_FFA25B18 \n"
 111 );
 112 }
 113 
 114 /*************************************************************/
 115 //** sub_FFA25DA8_my @ 0xFFA25DA8 - 0xFFA25DE8, length=17
 116 void __attribute__((naked,noinline)) sub_FFA25DA8_my() {
 117 asm volatile (
 118 "    STMFD   SP!, {R4-R8,LR} \n"
 119 "    MOV     R4, R0 \n"
 120 "    ADD     R0, R0, #0x2C \n"
 121 "    SUB     SP, SP, #0x38 \n"
 122 "    BL      sub_FF856E44 \n"
 123 "    MOV     R1, #0 \n"
 124 "    BL      sub_FF858414 \n"
 125 "    LDR     R0, [R4, #0xC] \n"
 126 "    BL      sub_FF858CF0 \n"
 127 "    LDR     R7, [R4, #8] \n"
 128 "    LDR     R8, =0x1B6 \n"
 129 "    ADD     R6, R4, #0x2C \n"
 130 "    LDR     R5, [R4, #0xC] \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 "    MOV     R0, R6 \n"
 138 "    MOV     R1, R7 \n"
 139 "    MOV     R2, R8 \n"
 140 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 141 "    LDR     PC, =0xFFA25DEC \n"  // Continue in firmware
 142 );
 143 }
 144 
 145 /*************************************************************/
 146 //** sub_FFA25ED4_my @ 0xFFA25ED4 - 0xFFA25FA0, length=52
 147 void __attribute__((naked,noinline)) sub_FFA25ED4_my() {
 148 asm volatile (
 149 "    STMFD   SP!, {R4-R6,LR} \n"
 150 "    MOV     R4, R0 \n"
 151 "    LDR     R0, [R0] \n"
 152 "    CMP     R0, #4 \n"
 153 "    LDREQ   R1, [R4, #0x14] \n"
 154 "    LDREQ   R5, [R4, #0x18] \n"
 155 "    BEQ     loc_FFA25F10 \n"
 156 "    CMP     R0, #5 \n"
 157 "    LDREQ   R1, [R4, #0x1C] \n"
 158 "    LDREQ   R5, [R4, #0x20] \n"
 159 "    BEQ     loc_FFA25F10 \n"
 160 "    CMP     R0, #6 \n"
 161 "    BNE     loc_FFA25F24 \n"
 162 "    LDR     R1, [R4, #0x24] \n"
 163 "    LDR     R5, [R4, #0x28] \n"
 164 
 165 "loc_FFA25F10:\n"
 166 "    CMP     R5, #0 \n"
 167 "    BNE     loc_FFA25F34 \n"
 168 
 169 "loc_FFA25F18:\n"
 170 "    MOV     R1, R4 \n"
 171 "    MOV     R0, #7 \n"
 172 "    B       loc_FFA25F9C \n"
 173 
 174 "loc_FFA25F24:\n"
 175 "    MOV     R1, #0x1D4 \n"
 176 "    LDR     R0, =0xFFA26044 /*'dwFWrite.c'*/ \n"
 177 "    BL      _DebugAssert \n"
 178 "    B       loc_FFA25F18 \n"
 179 
 180 "loc_FFA25F34:\n"
 181 "    LDR     R0, [R4, #4] \n"
 182 "    CMP     R5, #0x1000000 \n"
 183 "    MOVHI   R5, #0x1000000 \n"
 184 "    BIC     R2, R0, #0xFF000000 \n"
 185 "    CMP     R2, #0 \n"
 186 "    BICNE   R0, R0, #0xFF000000 \n"
 187 "    RSBNE   R0, R0, #0x1000000 \n"
 188 "    CMPNE   R5, R0 \n"
 189 "    MOVHI   R5, R0 \n"
 190 "    LDR     R0, =0xE3C4 \n"
 191 "    MOV     R2, R5 \n"
 192 "    LDR     R0, [R0] \n"
 193 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 194 "    LDR     R1, [R4, #4] \n"
 195 "    CMP     R5, R0 \n"
 196 "    ADD     R1, R1, R0 \n"
 197 "    STR     R1, [R4, #4] \n"
 198 "    BEQ     loc_FFA25F90 \n"
 199 "    LDR     R0, =0x10B1 \n"
 200 "    BL      sub_FF877A7C /*_IsControlEventActive_FW*/ \n"
 201 "    LDR     R1, =0x9200005 \n"
 202 "    STR     R1, [R4, #0x10] \n"
 203 "    B       loc_FFA25F18 \n"
 204 
 205 "loc_FFA25F90:\n"
 206 "    LDR     R0, [R4] \n"
 207 "    MOV     R1, R4 \n"
 208 "    ADD     R0, R0, #1 \n"
 209 
 210 "loc_FFA25F9C:\n"
 211 "    LDMFD   SP!, {R4-R6,LR} \n"
 212 "    B       sub_FFA25A68 \n"
 213 );
 214 }
 215 
 216 /*************************************************************/
 217 //** sub_FFA25FA4_my @ 0xFFA25FA4 - 0xFFA25FC0, length=8
 218 void __attribute__((naked,noinline)) sub_FFA25FA4_my() {
 219 asm volatile (
 220 "    STMFD   SP!, {R4,R5,LR} \n"
 221 "    LDR     R5, =0xE3C4 \n"
 222 "    MOV     R4, R0 \n"
 223 "    LDR     R0, [R5] \n"
 224 "    SUB     SP, SP, #0x1C \n"
 225 "    CMN     R0, #1 \n"
 226 "    BEQ     sub_FFA25FD8 \n"
 227 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 228 "    LDR     PC, =0xFFA25FC4 \n"  // Continue in firmware
 229 );
 230 }

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