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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA2B740_my
  3. sub_FFA2B87C_my
  4. sub_FFA2B978_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 3 //model specific
  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_FWT];
  24     char name[32];
  25 } fwt_data_struct;
  26 
  27 #include "../../../generic/filewrite.c"
  28 
  29 /*************************************************************/
  30 //** filewritetask @ 0xFFA2B4A0 - 0xFFA2B580, length=57
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R4, =0xC2A0 \n"
  35 
  36 "loc_FFA2B4A8:\n"
  37 "    LDR     R0, [R4, #0x10] \n"
  38 "    MOV     R2, #0 \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF82746C /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    BNE     loc_FFA2B4D8 \n"
  43 "    LDR     R0, [SP, #8] \n"
  44 "    LDR     R1, [R0] \n"
  45 "    CMP     R1, #1 \n"
  46 "    BNE     loc_FFA2B4E0 \n"
  47 "    LDR     R0, [R4, #8] \n"
  48 "    BL      _GiveSemaphore \n"
  49 
  50 "loc_FFA2B4D8:\n"
  51 "    BL      _ExitTask \n"
  52 "    LDMFD   SP!, {R1-R5,PC} \n"
  53 
  54 "loc_FFA2B4E0:\n"
  55 "    SUB     R1, R1, #2 \n"
  56 "    CMP     R1, #5 \n"
  57 "    ADDLS   PC, PC, R1, LSL#2 \n"
  58 "    B       loc_FFA2B4A8 \n"
  59 "    B       loc_FFA2B508 \n"
  60 "    B       loc_FFA2B56C \n"
  61 "    B       loc_FFA2B574 \n"
  62 "    B       loc_FFA2B574 \n"
  63 "    B       loc_FFA2B574 \n"
  64 "    B       loc_FFA2B57C \n"
  65 
  66 "loc_FFA2B508:\n"
  67 "    MOV     R0, #0 \n"
  68 "    STR     R0, [SP] \n"
  69 
  70 "loc_FFA2B510:\n"
  71 "    LDR     R0, [R4, #0x10] \n"
  72 "    MOV     R1, SP \n"
  73 "    BL      sub_FF8276B0 /*_GetNumberOfPostedMessages*/ \n"
  74 "    LDR     R0, [SP] \n"
  75 "    CMP     R0, #0 \n"
  76 "    BEQ     loc_FFA2B53C \n"
  77 "    LDR     R0, [R4, #0x10] \n"
  78 "    MOV     R2, #0 \n"
  79 "    ADD     R1, SP, #4 \n"
  80 "    BL      sub_FF82746C /*_ReceiveMessageQueue*/ \n"
  81 "    B       loc_FFA2B510 \n"
  82 
  83 "loc_FFA2B53C:\n"
  84 "    LDR     R0, [R4] \n"
  85 "    CMN     R0, #1 \n"
  86 "    BEQ     loc_FFA2B560 \n"
  87 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  88 "    MVN     R0, #0 \n"
  89 "    STR     R0, [R4] \n"
  90 "    LDR     R0, =0xBC25C \n"
  91 "    BL      sub_FF85974C \n"
  92 "    BL      sub_FF857DF4 \n"
  93 
  94 "loc_FFA2B560:\n"
  95 "    LDR     R0, [R4, #0xC] \n"
  96 "    BL      _GiveSemaphore \n"
  97 "    B       loc_FFA2B4A8 \n"
  98 
  99 "loc_FFA2B56C:\n"
 100 "    BL      sub_FFA2B740_my \n"  // --> Patched. Old value = 0xFFA2B740. Open stage
 101 "    B       loc_FFA2B4A8 \n"
 102 
 103 "loc_FFA2B574:\n"
 104 "    BL      sub_FFA2B87C_my \n"  // --> Patched. Old value = 0xFFA2B87C. Write stage
 105 "    B       loc_FFA2B4A8 \n"
 106 
 107 "loc_FFA2B57C:\n"
 108 "    BL      sub_FFA2B978_my \n"  // --> Patched. Old value = 0xFFA2B978. Close stage
 109 "    B       loc_FFA2B4A8 \n"
 110 "    .ltorg\n"    //+
 111 );
 112 }
 113 
 114 /*************************************************************/
 115 //** sub_FFA2B740_my @ 0xFFA2B740 - 0xFFA2B780, length=17
 116 void __attribute__((naked,noinline)) sub_FFA2B740_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_FF85974C \n"
 123 "    MOV     R1, #0 \n"
 124 "    BL      sub_FF857DA4 \n"
 125 "    LDR     R0, [R4, #0xC] \n"
 126 "    BL      sub_FF8560B4 \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, =0xFFA2B784 \n"  // Continue in firmware
 142 );
 143 }
 144 
 145 /*************************************************************/
 146 //** sub_FFA2B87C_my @ 0xFFA2B87C - 0xFFA2B974, length=63
 147 void __attribute__((naked,noinline)) sub_FFA2B87C_my() {
 148 asm volatile (
 149 "    STMFD   SP!, {R4-R10,LR} \n"
 150 "    MOV     R4, R0 \n"
 151 "    LDR     R0, [R0] \n"
 152 "    CMP     R0, #4 \n"
 153 "    LDREQ   R6, [R4, #0x18] \n"
 154 "    LDREQ   R7, [R4, #0x14] \n"
 155 "    BEQ     loc_FFA2B8B8 \n"
 156 "    CMP     R0, #5 \n"
 157 "    LDREQ   R6, [R4, #0x20] \n"
 158 "    LDREQ   R7, [R4, #0x1C] \n"
 159 "    BEQ     loc_FFA2B8B8 \n"
 160 "    CMP     R0, #6 \n"
 161 "    BNE     loc_FFA2B8CC \n"
 162 "    LDR     R6, [R4, #0x28] \n"
 163 "    LDR     R7, [R4, #0x24] \n"
 164 
 165 "loc_FFA2B8B8:\n"
 166 "    CMP     R6, #0 \n"
 167 "    BNE     loc_FFA2B8DC \n"
 168 
 169 "loc_FFA2B8C0:\n"
 170 "    MOV     R1, R4 \n"
 171 "    MOV     R0, #7 \n"
 172 "    B       loc_FFA2B970 \n"
 173 
 174 "loc_FFA2B8CC:\n"
 175 "    LDR     R1, =0x205 \n"
 176 "    LDR     R0, =0xFFA2B85C /*'dwFWrite.c'*/ \n"
 177 "    BL      _DebugAssert \n"
 178 "    B       loc_FFA2B8C0 \n"
 179 
 180 "loc_FFA2B8DC:\n"
 181 "    LDR     R9, =0xC2A0 \n"
 182 "    MOV     R5, R6 \n"
 183 
 184 "loc_FFA2B8E4:\n"
 185 "    LDR     R0, [R4, #4] \n"
 186 "    CMP     R5, #0x1000000 \n"
 187 "    MOVLS   R8, R5 \n"
 188 "    MOVHI   R8, #0x1000000 \n"
 189 "    BIC     R1, R0, #0xFF000000 \n"
 190 "    CMP     R1, #0 \n"
 191 "    BICNE   R0, R0, #0xFF000000 \n"
 192 "    RSBNE   R0, R0, #0x1000000 \n"
 193 "    CMPNE   R8, R0 \n"
 194 "    MOVHI   R8, R0 \n"
 195 "    LDR     R0, [R9] \n"
 196 "    MOV     R2, R8 \n"
 197 "    MOV     R1, R7 \n"
 198 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 199 "    LDR     R1, [R4, #4] \n"
 200 "    CMP     R8, R0 \n"
 201 "    ADD     R1, R1, R0 \n"
 202 "    STR     R1, [R4, #4] \n"
 203 "    BEQ     loc_FFA2B944 \n"
 204 "    LDR     R0, =0x10B1 \n"
 205 "    BL      sub_FF87D75C /*_IsControlEventActive_FW*/ \n"
 206 "    LDR     R1, =0x9200005 \n"
 207 "    STR     R1, [R4, #0x10] \n"
 208 "    B       loc_FFA2B8C0 \n"
 209 
 210 "loc_FFA2B944:\n"
 211 "    SUB     R5, R5, R0 \n"
 212 "    CMP     R5, R6 \n"
 213 "    ADD     R7, R7, R0 \n"
 214 "    LDRCS   R0, =0xFFA2B85C /*'dwFWrite.c'*/ \n"
 215 "    MOVCS   R1, #0x234 \n"
 216 "    BLCS    _DebugAssert \n"
 217 "    CMP     R5, #0 \n"
 218 "    BNE     loc_FFA2B8E4 \n"
 219 "    LDR     R0, [R4] \n"
 220 "    MOV     R1, R4 \n"
 221 "    ADD     R0, R0, #1 \n"
 222 
 223 "loc_FFA2B970:\n"
 224 "    LDMFD   SP!, {R4-R10,LR} \n"
 225 "    B       sub_FFA2B3F8 \n"
 226 );
 227 }
 228 
 229 /*************************************************************/
 230 //** sub_FFA2B978_my @ 0xFFA2B978 - 0xFFA2B994, length=8
 231 void __attribute__((naked,noinline)) sub_FFA2B978_my() {
 232 asm volatile (
 233 "    STMFD   SP!, {R4,R5,LR} \n"
 234 "    LDR     R5, =0xC2A0 \n"
 235 "    MOV     R4, R0 \n"
 236 "    LDR     R0, [R5] \n"
 237 "    SUB     SP, SP, #0x1C \n"
 238 "    CMN     R0, #1 \n"
 239 "    BEQ     sub_FFA2B9AC \n"
 240 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 241 "    LDR     PC, =0xFFA2B998 \n"  // Continue in firmware
 242 );
 243 }

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