root/platform/sx20/sub/102b/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA79060_my
  3. sub_FFA79194_my
  4. sub_FFA78C0C_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 4 //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  * cameras with possible multipass JPEG writes need oflags
  18  * pdc is always required
  19  * name is not currently used
  20  */
  21 typedef struct
  22 {
  23     int unkn1[2];
  24     int oflags;
  25     int unkn2[2];
  26     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  27     int unkn6;
  28     char name[32];
  29 } fwt_data_struct;
  30 
  31 #include "../../../generic/filewrite.c"
  32 
  33 /*************************************************************/
  34 //** filewritetask @ 0xFFA78D74 - 0xFFA78E58, length=58
  35 void __attribute__((naked,noinline)) filewritetask() {
  36 asm volatile (
  37 "    STMFD   SP!, {R1-R5,LR} \n"
  38 "    LDR     R4, =0xAB3C \n"
  39 
  40 "loc_FFA78D7C:\n"
  41 "    LDR     R0, [R4, #0x10] \n"
  42 "    MOV     R2, #0 \n"
  43 "    ADD     R1, SP, #8 \n"
  44 "    BL      sub_FF838318 /*_ReceiveMessageQueue*/ \n"
  45 "    CMP     R0, #0 \n"
  46 "    BNE     loc_FFA78DAC \n"
  47 "    LDR     R0, [SP, #8] \n"
  48 "    LDR     R1, [R0] \n"
  49 "    CMP     R1, #1 \n"
  50 "    BNE     loc_FFA78DB4 \n"
  51 "    LDR     R0, [R4, #8] \n"
  52 "    BL      _GiveSemaphore \n"
  53 
  54 "loc_FFA78DAC:\n"
  55 "    BL      _ExitTask \n"
  56 "    LDMFD   SP!, {R1-R5,PC} \n"
  57 
  58 "loc_FFA78DB4:\n"
  59 "    SUB     R1, R1, #2 \n"
  60 "    CMP     R1, #6 \n"
  61 "    ADDLS   PC, PC, R1, LSL#2 \n"
  62 "    B       loc_FFA78D7C \n"
  63 "    B       loc_FFA78DE0 \n"
  64 "    B       loc_FFA78E44 \n"
  65 "    B       loc_FFA78E4C \n"
  66 "    B       loc_FFA78E4C \n"
  67 "    B       loc_FFA78E4C \n"
  68 "    B       loc_FFA78E4C \n"
  69 "    B       loc_FFA78E54 \n"
  70 
  71 "loc_FFA78DE0:\n"
  72 "    MOV     R0, #0 \n"
  73 "    STR     R0, [SP] \n"
  74 
  75 "loc_FFA78DE8:\n"
  76 "    LDR     R0, [R4, #0x10] \n"
  77 "    MOV     R1, SP \n"
  78 "    BL      sub_FF83855C /*_GetNumberOfPostedMessages*/ \n"
  79 "    LDR     R0, [SP] \n"
  80 "    CMP     R0, #0 \n"
  81 "    BEQ     loc_FFA78E14 \n"
  82 "    LDR     R0, [R4, #0x10] \n"
  83 "    MOV     R2, #0 \n"
  84 "    ADD     R1, SP, #4 \n"
  85 "    BL      sub_FF838318 /*_ReceiveMessageQueue*/ \n"
  86 "    B       loc_FFA78DE8 \n"
  87 
  88 "loc_FFA78E14:\n"
  89 "    LDR     R0, [R4] \n"
  90 "    CMN     R0, #1 \n"
  91 "    BEQ     loc_FFA78E38 \n"
  92 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  93 "    MVN     R0, #0 \n"
  94 "    STR     R0, [R4] \n"
  95 "    LDR     R0, =0xC1FA4 \n"
  96 "    BL      sub_FF86F388 \n"
  97 "    BL      sub_FF86D76C \n"
  98 
  99 "loc_FFA78E38:\n"
 100 "    LDR     R0, [R4, #0xC] \n"
 101 "    BL      _GiveSemaphore \n"
 102 "    B       loc_FFA78D7C \n"
 103 
 104 "loc_FFA78E44:\n"
 105 "    BL      sub_FFA79060_my \n"  // --> Patched. Old value = 0xFFA79060. Open stage
 106 "    B       loc_FFA78D7C \n"
 107 
 108 "loc_FFA78E4C:\n"
 109 "    BL      sub_FFA79194_my \n"  // --> Patched. Old value = 0xFFA79194. Write stage
 110 "    B       loc_FFA78D7C \n"
 111 
 112 "loc_FFA78E54:\n"
 113 "    BL      sub_FFA78C0C_my \n"  // --> Patched. Old value = 0xFFA78C0C. Close stage
 114 "    B       loc_FFA78D7C \n"
 115 );
 116 }
 117 
 118 /*************************************************************/
 119 //** sub_FFA79060_my @ 0xFFA79060 - 0xFFA790A0, length=17
 120 void __attribute__((naked,noinline)) sub_FFA79060_my() {
 121 asm volatile (
 122 "    STMFD   SP!, {R4-R8,LR} \n"
 123 "    MOV     R4, R0 \n"
 124 "    ADD     R0, R0, #0x38 \n"
 125 "    SUB     SP, SP, #0x38 \n"
 126 "    BL      sub_FF86F388 \n"
 127 "    MOV     R1, #0 \n"
 128 "    BL      sub_FF86D71C \n"
 129 "    LDR     R0, [R4, #0xC] \n"
 130 "    BL      sub_FF810338 \n"
 131 "    LDR     R7, [R4, #8] \n"
 132 "    LDR     R8, =0x1B6 \n"
 133 "    ADD     R6, R4, #0x38 \n"
 134 "    LDR     R5, [R4, #0xC] \n"
 135 //hook start
 136 "    MOV     R0, R4\n"
 137 "    BL      filewrite_main_hook\n"
 138 //hook end
 139 "    MOV     R0, R6 \n"
 140 "    MOV     R1, R7 \n"
 141 "    MOV     R2, R8 \n"
 142 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 143 "    LDR     PC, =0xFFA790A4 \n"  // Continue in firmware
 144 );
 145 }
 146 
 147 /*************************************************************/
 148 //** sub_FFA79194_my @ 0xFFA79194 - 0xFFA7929C, length=67
 149 void __attribute__((naked,noinline)) sub_FFA79194_my() {
 150 asm volatile (
 151 "    STMFD   SP!, {R4-R10,LR} \n"
 152 "    MOV     R4, R0 \n"
 153 "    LDR     R0, [R0] \n"
 154 "    CMP     R0, #4 \n"
 155 "    LDREQ   R6, [R4, #0x18] \n"
 156 "    LDREQ   R7, [R4, #0x14] \n"
 157 "    BEQ     loc_FFA791E0 \n"
 158 "    CMP     R0, #5 \n"
 159 "    LDREQ   R6, [R4, #0x20] \n"
 160 "    LDREQ   R7, [R4, #0x1C] \n"
 161 "    BEQ     loc_FFA791E0 \n"
 162 "    CMP     R0, #6 \n"
 163 "    LDREQ   R6, [R4, #0x28] \n"
 164 "    LDREQ   R7, [R4, #0x24] \n"
 165 "    BEQ     loc_FFA791E0 \n"
 166 "    CMP     R0, #7 \n"
 167 "    BNE     loc_FFA791F4 \n"
 168 "    LDR     R6, [R4, #0x30] \n"
 169 "    LDR     R7, [R4, #0x2C] \n"
 170 
 171 "loc_FFA791E0:\n"
 172 "    CMP     R6, #0 \n"
 173 "    BNE     loc_FFA79204 \n"
 174 
 175 "loc_FFA791E8:\n"
 176 "    MOV     R1, R4 \n"
 177 "    MOV     R0, #8 \n"
 178 "    B       loc_FFA79298 \n"
 179 
 180 "loc_FFA791F4:\n"
 181 "    LDR     R1, =0x297 \n"
 182 "    LDR     R0, =0xFFA78E68 /*'dwFWrite.c'*/ \n"
 183 "    BL      _DebugAssert \n"
 184 "    B       loc_FFA791E8 \n"
 185 
 186 "loc_FFA79204:\n"
 187 "    LDR     R9, =0xAB3C \n"
 188 "    MOV     R5, R6 \n"
 189 
 190 "loc_FFA7920C:\n"
 191 "    LDR     R0, [R4, #4] \n"
 192 "    CMP     R5, #0x1000000 \n"
 193 "    MOVLS   R8, R5 \n"
 194 "    MOVHI   R8, #0x1000000 \n"
 195 "    BIC     R1, R0, #0xFF000000 \n"
 196 "    CMP     R1, #0 \n"
 197 "    BICNE   R0, R0, #0xFF000000 \n"
 198 "    RSBNE   R0, R0, #0x1000000 \n"
 199 "    CMPNE   R8, R0 \n"
 200 "    MOVHI   R8, R0 \n"
 201 "    LDR     R0, [R9] \n"
 202 "    MOV     R2, R8 \n"
 203 "    MOV     R1, R7 \n"
 204 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 205 "    LDR     R1, [R4, #4] \n"
 206 "    CMP     R8, R0 \n"
 207 "    ADD     R1, R1, R0 \n"
 208 "    STR     R1, [R4, #4] \n"
 209 "    BEQ     loc_FFA7926C \n"
 210 "    CMN     R0, #1 \n"
 211 "    LDRNE   R0, =0x9200015 \n"
 212 "    LDREQ   R0, =0x9200005 \n"
 213 "    STR     R0, [R4, #0x10] \n"
 214 "    B       loc_FFA791E8 \n"
 215 
 216 "loc_FFA7926C:\n"
 217 "    SUB     R5, R5, R0 \n"
 218 "    CMP     R5, R6 \n"
 219 "    ADD     R7, R7, R0 \n"
 220 "    LDRCS   R0, =0xFFA78E68 /*'dwFWrite.c'*/ \n"
 221 "    LDRCS   R1, =0x2C2 \n"
 222 "    BLCS    _DebugAssert \n"
 223 "    CMP     R5, #0 \n"
 224 "    BNE     loc_FFA7920C \n"
 225 "    LDR     R0, [R4] \n"
 226 "    MOV     R1, R4 \n"
 227 "    ADD     R0, R0, #1 \n"
 228 
 229 "loc_FFA79298:\n"
 230 "    LDMFD   SP!, {R4-R10,LR} \n"
 231 "    B       sub_FFA78B4C \n"
 232 );
 233 }
 234 
 235 /*************************************************************/
 236 //** sub_FFA78C0C_my @ 0xFFA78C0C - 0xFFA78C40, length=14
 237 void __attribute__((naked,noinline)) sub_FFA78C0C_my() {
 238 asm volatile (
 239 "    STMFD   SP!, {R4-R6,LR} \n"
 240 "    LDR     R5, =0xAB3C \n"
 241 "    MOV     R4, R0 \n"
 242 "    LDR     R0, [R5] \n"
 243 "    SUB     SP, SP, #0x38 \n"
 244 "    CMN     R0, #1 \n"
 245 "    BEQ     sub_FFA78C54 \n"
 246 "    LDR     R1, [R4, #8] \n"
 247 "    LDR     R6, =0x9200003 \n"
 248 "    TST     R1, #0x8000 \n"
 249 "    BEQ     loc_FFA78C40 \n"
 250 //mod start
 251 "    LDR R3, =current_write_ignored\n"
 252 "    LDR R3, [R3]\n"
 253 "    CMP R3, #0\n"
 254 "    BNE loc_D\n" // jump over the next block
 255 //mod end
 256 
 257 "    BL      sub_FF86C7CC \n"
 258 "    B       sub_FFA78C44 \n"
 259 
 260 "loc_FFA78C40:\n"
 261 "loc_D:\n"
 262 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 263 "    LDR     PC, =0xFFA78C44 \n"  // Continue in firmware
 264 );
 265 }

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