root/platform/ixus60_sd600/sub/100d/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF8676AC_my
  3. sub_FF867558_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;
  23     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  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 @ 0xFF867764 - 0xFF8677F4, length=37
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    LDR     R4, =0x19C74 \n"
  36 "    SUB     SP, SP, #4 \n"
  37 "    B       loc_FF867798 \n"
  38 
  39 "loc_FF867774:\n"
  40 "    TST     R3, #4 \n"
  41 "    BEQ     loc_FF867794 \n"
  42 "    LDR     R0, [R4] \n"
  43 "    BL      sub_FF81FE80 /*_ClearEventFlag*/ \n"
  44 "    LDR     R0, [R4] \n"
  45 "    MOV     R1, #8 \n"
  46 "    BL      sub_FF81FCE4 /*_SetEventFlag*/ \n"
  47 "    B       loc_FF867798 \n"
  48 
  49 "loc_FF867794:\n"
  50 "    BL      sub_FF8676AC_my \n"  // --> Patched. Old value = 0xFF8676AC.
  51 
  52 "loc_FF867798:\n"
  53 "    MOV     R1, #7 \n"
  54 "    LDR     R0, [R4] \n"
  55 "    MOV     R2, #0 \n"
  56 "    BL      sub_FF81FCC4 /*_WaitForAnyEventFlag*/ \n"
  57 "    CMP     R0, #0 \n"
  58 "    MOV     R1, SP \n"
  59 "    BEQ     loc_FF8677C8 \n"
  60 "    MOV     R1, #0x2B0 \n"
  61 "    LDR     R0, =0xFF867600 /*'dwFWrite.c'*/ \n"
  62 "    ADD     R1, R1, #1 \n"
  63 "    BL      _DebugAssert \n"
  64 "    B       loc_FF8677E0 \n"
  65 
  66 "loc_FF8677C8:\n"
  67 "    LDR     R0, [R4] \n"
  68 "    BL      sub_FF81FED0 /*_GetEventFlagValue*/ \n"
  69 "    LDR     R3, [SP] \n"
  70 "    TST     R3, #2 \n"
  71 "    MOV     R1, #5 \n"
  72 "    BEQ     loc_FF867774 \n"
  73 
  74 "loc_FF8677E0:\n"
  75 "    LDR     R3, =0x19C78 \n"
  76 "    LDR     R0, [R3] \n"
  77 "    BL      _GiveSemaphore \n"
  78 "    BL      _ExitTask \n"
  79 "    ADD     SP, SP, #4 \n"
  80 "    LDMFD   SP!, {R4,PC} \n"
  81 );
  82 }
  83 
  84 /*************************************************************/
  85 //** sub_FF8676AC_my @ 0xFF8676AC - 0xFF867748, length=40
  86 void __attribute__((naked,noinline)) sub_FF8676AC_my() {
  87 asm volatile (
  88 "    STMFD   SP!, {R4,R5,LR} \n"
  89 "    LDR     R2, =0x19C58 \n"
  90 "    LDRH    R3, [R2] \n"
  91 "    SUB     R3, R3, #1 \n"
  92 "    CMP     R3, #3 \n"
  93 "    LDRLS   PC, [PC, R3, LSL#2] \n"
  94 "    B       loc_FF8676F8 \n"
  95 "    .long   loc_FF8676D8 \n"
  96 "    .long   loc_FF8676E8 \n"
  97 "    .long   loc_FF8676E8 \n"
  98 "    .long   loc_FF8676E8 \n"
  99 
 100 "loc_FF8676D8:\n"
 101 "    LDR     R0, =0x19C18 \n"
 102 "    BL      sub_FF867558_my \n"  // --> Patched. Old value = 0xFF867558.
 103 "    MOV     R4, R0 \n"
 104 "    B       loc_FF8676FC \n"
 105 
 106 "loc_FF8676E8:\n"
 107 "    LDR     R0, =0x19C18 \n"
 108 "    BL      sub_FF86760C \n"
 109 "    MOV     R4, R0 \n"
 110 "    B       loc_FF8676FC \n"
 111 
 112 "loc_FF8676F8:\n"
 113 "    MOV     R4, #1 \n"
 114 
 115 "loc_FF8676FC:\n"
 116 "    CMP     R4, #0 \n"
 117 "    MOV     R1, #1 \n"
 118 "    LDMEQFD SP!, {R4,R5,PC} \n"
 119 "    LDR     R3, =0x19C74 \n"
 120 "    LDR     R0, [R3] \n"
 121 "    BL      sub_FF81FE80 /*_ClearEventFlag*/ \n"
 122 "    LDR     R3, =0x19C80 \n"
 123 "    LDR     R5, [R3] \n"
 124 "    LDR     R1, =0x19C7C \n"
 125 "    LDR     R12, =0x2774 \n"
 126 "    MOV     R3, #1 \n"
 127 "    MOV     R2, #0 \n"
 128 "    CMP     R5, #0 \n"
 129 "    STR     R3, [R1] \n"
 130 "    MOV     R0, R4 \n"
 131 "    STR     R2, [R12] \n"
 132 "    LDMEQFD SP!, {R4,R5,PC} \n"
 133 "    MOV     LR, PC \n"
 134 "    MOV     PC, R5 \n"
 135 "    BL      fwt_after_close\n" //+
 136 "    LDMFD   SP!, {R4,R5,PC} \n"
 137 );
 138 }
 139 
 140 /*************************************************************/
 141 //** sub_FF867558_my @ 0xFF867558 - 0xFF8675F0, length=39
 142 void __attribute__((naked,noinline)) sub_FF867558_my() {
 143 asm volatile (
 144 "    STMFD   SP!, {R4-R6,LR} \n"
 145 "    MOV     R4, R0 \n"
 146 "    ADD     R5, R4, #0x1C \n"
 147 "    MOV     R0, R5 \n"
 148 "    BL      sub_FF867230 \n"
 149 "    LDR     R0, [R4, #0x3C] \n"
 150 "    BL      sub_FF8702A8 \n"
 151 "    LDR     R3, [R4] \n"
 152 "    MOV     R1, #0x600 \n"
 153 "    TST     R3, #0x10000 \n"
 154 "    ADD     R1, R1, #1 \n"
 155 "    MOV     R2, #0x1B4 \n"
 156 "    ORRNE   R1, R1, #0x8000 \n"
 157 "    LDR     R3, [R4, #0x3C] \n"
 158 "    ADD     R2, R2, #2 \n"
 159 //place hook here
 160 //the task's data block is at [r4] at this point, filename starts at [r4+0x1c]
 161 //the block can be captured here for a (new) camera with unknown data block structure
 162 //for ptp remote capture, pass '/null' as filename
 163 //if writing does not need to be prevented, just continue
 164 "    STMFD   SP!, {R1-R12,LR}\n"
 165 "    MOV     R0, R4\n"
 166 "    BL      filewrite_main_hook\n"
 167 "    BL      filewrite_file_complete\n"
 168 "    CMP     R0, #0\n"
 169 "    LDRNE   R0, =loc_mynull\n" // /null as file name (works only on VxWorks)
 170 "    LDMFD   SP!, {R1-R12,LR}\n"
 171 "    MOVEQ   R0, R5\n" //canon file name
 172 //hook end
 173 //"  MOV     R0, R5 \n"  // - file name
 174 "    BL      sub_FF867334 \n"
 175 "    MOV     R1, R4 \n"
 176 "    MOV     R2, R0 \n"
 177 "    MOV     R4, #0 \n"
 178 "    LDR     R3, =0x19C5C \n"
 179 "    CMP     R2, R4 \n"
 180 "    LDR     R6, =0x19C58 \n"
 181 "    MOV     R0, R5 \n"
 182 "    STR     R2, [R3] \n"
 183 "    BGT     loc_FF8675D8 \n"
 184 "    BL      sub_FF867244 \n"
 185 "    MOV     R0, #0x8000001 \n"
 186 "    ADD     R0, R0, #0x1200000 \n"
 187 "    BL      sub_FF864F38 \n"
 188 "    MOV     R0, #2 \n"
 189 "    LDMFD   SP!, {R4-R6,PC} \n"
 190 
 191 "loc_FF8675D8:\n"
 192 "    LDR     R3, =0x19C60 \n"
 193 "    LDRH    R0, [R6] \n"
 194 "    STR     R4, [R3] \n"
 195 "    BL      sub_FF8674A8 \n"
 196 "    STRH    R0, [R6] \n"
 197 "    MOV     R0, R4 \n"
 198 "    LDMFD   SP!, {R4-R6,PC} \n"
 199 //mod start
 200 "loc_mynull:\n"
 201 ".asciz     \"/null\" \n"
 202 //mod end
 203 );
 204 }

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