root/platform/ixus55_sd450/sub/100c/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF8665EC_my
  3. sub_FF866498_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 //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;
  23     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  24     char name[32];
  25 } fwt_data_struct;
  26 #define CAM_HAS_COMPLETEFILEWRITE_REPLACEMENT 1
  27 
  28 #include "../../../generic/filewrite.c"
  29 
  30 /*************************************************************/
  31 //** filewritetask @ 0xFF8666A4 - 0xFF866730, length=36
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    LDR     R4, =0x1CB44 \n"
  36 "    SUB     SP, SP, #4 \n"
  37 "    B       loc_FF8666D8 \n"
  38 
  39 "loc_FF8666B4:\n"
  40 "    TST     R3, #4 \n"
  41 "    BEQ     loc_FF8666D4 \n"
  42 "    LDR     R0, [R4] \n"
  43 "    BL      sub_FF81FD18 /*_ClearEventFlag*/ \n"
  44 "    LDR     R0, [R4] \n"
  45 "    MOV     R1, #8 \n"
  46 "    BL      sub_FF81FB7C /*_SetEventFlag*/ \n"
  47 "    B       loc_FF8666D8 \n"
  48 
  49 "loc_FF8666D4:\n"
  50 "    BL      sub_FF8665EC_my \n"  // --> Patched. Old value = 0xFF8665EC.
  51 
  52 "loc_FF8666D8:\n"
  53 "    MOV     R1, #7 \n"
  54 "    LDR     R0, [R4] \n"
  55 "    MOV     R2, #0 \n"
  56 "    BL      sub_FF81FB5C /*_WaitForAnyEventFlag*/ \n"
  57 "    CMP     R0, #0 \n"
  58 "    MOV     R1, SP \n"
  59 "    BEQ     loc_FF866704 \n"
  60 "    LDR     R0, =0xFF866540 /*'dwFWrite.c'*/ \n"
  61 "    MOV     R1, #0x274 \n"
  62 "    BL      _DebugAssert \n"
  63 "    B       loc_FF86671C \n"
  64 
  65 "loc_FF866704:\n"
  66 "    LDR     R0, [R4] \n"
  67 "    BL      sub_FF81FD68 /*_GetEventFlagValue*/ \n"
  68 "    LDR     R3, [SP] \n"
  69 "    TST     R3, #2 \n"
  70 "    MOV     R1, #5 \n"
  71 "    BEQ     loc_FF8666B4 \n"
  72 
  73 "loc_FF86671C:\n"
  74 "    LDR     R3, =0x1CB48 \n"
  75 "    LDR     R0, [R3] \n"
  76 "    BL      _GiveSemaphore \n"
  77 "    BL      _ExitTask \n"
  78 "    ADD     SP, SP, #4 \n"
  79 "    LDMFD   SP!, {R4,PC} \n"
  80 );
  81 }
  82 
  83 /*************************************************************/
  84 //** sub_FF8665EC_my @ 0xFF8665EC - 0xFF866688, length=40
  85 void __attribute__((naked,noinline)) sub_FF8665EC_my() {
  86 asm volatile (
  87 "    STMFD   SP!, {R4,R5,LR} \n"
  88 "    LDR     R2, =0x1CB28 \n"
  89 "    LDRH    R3, [R2] \n"
  90 "    SUB     R3, R3, #1 \n"
  91 "    CMP     R3, #3 \n"
  92 "    LDRLS   PC, [PC, R3, LSL#2] \n"
  93 "    B       loc_FF866638 \n"
  94 "    .long   loc_FF866618 \n"
  95 "    .long   loc_FF866628 \n"
  96 "    .long   loc_FF866628 \n"
  97 "    .long   loc_FF866628 \n"
  98 
  99 "loc_FF866618:\n"
 100 "    LDR     R0, =0x1CAE8 \n"
 101 "    BL      sub_FF866498_my \n"  // --> Patched. Old value = 0xFF866498.
 102 "    MOV     R4, R0 \n"
 103 "    B       loc_FF86663C \n"
 104 
 105 "loc_FF866628:\n"
 106 "    LDR     R0, =0x1CAE8 \n"
 107 "    BL      sub_FF86654C \n"
 108 "    MOV     R4, R0 \n"
 109 "    B       loc_FF86663C \n"
 110 
 111 "loc_FF866638:\n"
 112 "    MOV     R4, #1 \n"
 113 
 114 "loc_FF86663C:\n"
 115 "    CMP     R4, #0 \n"
 116 "    MOV     R1, #1 \n"
 117 "    LDMEQFD SP!, {R4,R5,PC} \n"
 118 "    LDR     R3, =0x1CB44 \n"
 119 "    LDR     R0, [R3] \n"
 120 "    BL      sub_FF81FD18 /*_ClearEventFlag*/ \n"
 121 "    LDR     R3, =0x1CB50 \n"
 122 "    LDR     R5, [R3] \n"
 123 "    LDR     R1, =0x1CB4C \n"
 124 "    LDR     R12, =0x27EC \n"
 125 "    MOV     R3, #1 \n"
 126 "    MOV     R2, #0 \n"
 127 "    CMP     R5, #0 \n"
 128 "    STR     R3, [R1] \n"
 129 "    MOV     R0, R4 \n"
 130 "    STR     R2, [R12] \n"
 131 "    LDMEQFD SP!, {R4,R5,PC} \n"
 132 "    MOV     LR, PC \n"
 133 "    MOV     PC, R5 \n"
 134 "    BL      fwt_after_close\n" //+
 135 "    LDMFD   SP!, {R4,R5,PC} \n"
 136 );
 137 }
 138 
 139 /*************************************************************/
 140 //** sub_FF866498_my @ 0xFF866498 - 0xFF866530, length=39
 141 void __attribute__((naked,noinline)) sub_FF866498_my() {
 142 asm volatile (
 143 "    STMFD   SP!, {R4-R6,LR} \n"
 144 "    MOV     R4, R0 \n"
 145 "    ADD     R5, R4, #0x1C \n"
 146 "    MOV     R0, R5 \n"
 147 "    BL      sub_FF866170 \n"
 148 "    LDR     R0, [R4, #0x3C] \n"
 149 "    BL      sub_FF86EEB8 \n"
 150 "    LDR     R3, [R4] \n"
 151 "    MOV     R1, #0x600 \n"
 152 "    TST     R3, #0x10000 \n"
 153 "    ADD     R1, R1, #1 \n"
 154 "    MOV     R2, #0x1B4 \n"
 155 "    ORRNE   R1, R1, #0x8000 \n"
 156 "    LDR     R3, [R4, #0x3C] \n"
 157 "    ADD     R2, R2, #2 \n"
 158 //place hook here
 159 //the task's data block is at [r4] at this point, filename starts at [r4+0x1c]
 160 //the block can be captured here for a (new) camera with unknown data block structure
 161 //for ptp remote capture, pass '/null' as filename
 162 //if writing does not need to be prevented, just continue
 163 "    STMFD   SP!, {R1-R12,LR}\n"
 164 "    MOV     R0, R4\n"
 165 "    BL      filewrite_main_hook\n"
 166 "    BL      filewrite_jpeg_complete\n"
 167 "    CMP     R0, #0\n"
 168 "    LDRNE   R0, =loc_mynull\n" // /null as file name (works only on VxWorks)
 169 "    LDMFD   SP!, {R1-R12,LR}\n"
 170 "    MOVEQ   R0, R5\n" //canon file name
 171 //hook end
 172 //"  MOV     R0, R5 \n"  // - file name
 173 "    BL      sub_FF866274 \n"
 174 "    MOV     R1, R4 \n"
 175 "    MOV     R2, R0 \n"
 176 "    MOV     R4, #0 \n"
 177 "    LDR     R3, =0x1CB2C \n"
 178 "    CMP     R2, R4 \n"
 179 "    LDR     R6, =0x1CB28 \n"
 180 "    MOV     R0, R5 \n"
 181 "    STR     R2, [R3] \n"
 182 "    BGT     loc_FF866518 \n"
 183 "    BL      sub_FF866184 \n"
 184 "    MOV     R0, #0x8000001 \n"
 185 "    ADD     R0, R0, #0x1200000 \n"
 186 "    BL      sub_FF863CE8 \n"
 187 "    MOV     R0, #2 \n"
 188 "    LDMFD   SP!, {R4-R6,PC} \n"
 189 
 190 "loc_FF866518:\n"
 191 "    LDR     R3, =0x1CB30 \n"
 192 "    LDRH    R0, [R6] \n"
 193 "    STR     R4, [R3] \n"
 194 "    BL      sub_FF8663E8 \n"
 195 "    STRH    R0, [R6] \n"
 196 "    MOV     R0, R4 \n"
 197 "    LDMFD   SP!, {R4-R6,PC} \n"
 198 //mod start
 199 "loc_mynull:\n"
 200 ".asciz     \"/null\" \n"
 201 //mod end
 202 );
 203 }

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