root/platform/a700/sub/100b/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFC55B34_my
  3. sub_FFC559E0_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 @ 0xFFC55BEC - 0xFFC55C7C, length=37
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    LDR     R4, =0x1994C \n"
  36 "    SUB     SP, SP, #4 \n"
  37 "    B       loc_FFC55C20 \n"
  38 
  39 "loc_FFC55BFC:\n"
  40 "    TST     R3, #4 \n"
  41 "    BEQ     loc_FFC55C1C \n"
  42 "    LDR     R0, [R4] \n"
  43 "    BL      sub_FFC0FB44 /*_ClearEventFlag*/ \n"
  44 "    LDR     R0, [R4] \n"
  45 "    MOV     R1, #8 \n"
  46 "    BL      sub_FFC0F9A8 /*_SetEventFlag*/ \n"
  47 "    B       loc_FFC55C20 \n"
  48 
  49 "loc_FFC55C1C:\n"
  50 "    BL      sub_FFC55B34_my \n"  // --> Patched. Old value = 0xFFC55B34.
  51 
  52 "loc_FFC55C20:\n"
  53 "    MOV     R1, #7 \n"
  54 "    LDR     R0, [R4] \n"
  55 "    MOV     R2, #0 \n"
  56 "    BL      sub_FFC0F988 /*_WaitForAnyEventFlag*/ \n"
  57 "    CMP     R0, #0 \n"
  58 "    MOV     R1, SP \n"
  59 "    BEQ     loc_FFC55C50 \n"
  60 "    MOV     R1, #0x2B0 \n"
  61 "    LDR     R0, =0xFFC55A88 /*'dwFWrite.c'*/ \n"
  62 "    ADD     R1, R1, #1 \n"
  63 "    BL      _DebugAssert \n"
  64 "    B       loc_FFC55C68 \n"
  65 
  66 "loc_FFC55C50:\n"
  67 "    LDR     R0, [R4] \n"
  68 "    BL      sub_FFC0FB94 /*_GetEventFlagValue*/ \n"
  69 "    LDR     R3, [SP] \n"
  70 "    TST     R3, #2 \n"
  71 "    MOV     R1, #5 \n"
  72 "    BEQ     loc_FFC55BFC \n"
  73 
  74 "loc_FFC55C68:\n"
  75 "    LDR     R3, =0x19950 \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_FFC55B34_my @ 0xFFC55B34 - 0xFFC55BD0, length=40
  86 void __attribute__((naked,noinline)) sub_FFC55B34_my() {
  87 asm volatile (
  88 "    STMFD   SP!, {R4,R5,LR} \n"
  89 "    LDR     R2, =0x19930 \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_FFC55B80 \n"
  95 "    .long   loc_FFC55B60 \n"
  96 "    .long   loc_FFC55B70 \n"
  97 "    .long   loc_FFC55B70 \n"
  98 "    .long   loc_FFC55B70 \n"
  99 
 100 "loc_FFC55B60:\n"
 101 "    LDR     R0, =0x198F0 \n"
 102 "    BL      sub_FFC559E0_my \n"  // --> Patched. Old value = 0xFFC559E0.
 103 "    MOV     R4, R0 \n"
 104 "    B       loc_FFC55B84 \n"
 105 
 106 "loc_FFC55B70:\n"
 107 "    LDR     R0, =0x198F0 \n"
 108 "    BL      sub_FFC55A94 \n"
 109 "    MOV     R4, R0 \n"
 110 "    B       loc_FFC55B84 \n"
 111 
 112 "loc_FFC55B80:\n"
 113 "    MOV     R4, #1 \n"
 114 
 115 "loc_FFC55B84:\n"
 116 "    CMP     R4, #0 \n"
 117 "    MOV     R1, #1 \n"
 118 "    LDMEQFD SP!, {R4,R5,PC} \n"
 119 "    LDR     R3, =0x1994C \n"
 120 "    LDR     R0, [R3] \n"
 121 "    BL      sub_FFC0FB44 /*_ClearEventFlag*/ \n"
 122 "    LDR     R3, =0x19958 \n"
 123 "    LDR     R5, [R3] \n"
 124 "    LDR     R1, =0x19954 \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_FFC559E0_my @ 0xFFC559E0 - 0xFFC55A78, length=39
 142 void __attribute__((naked,noinline)) sub_FFC559E0_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_FFC556B8 \n"
 149 "    LDR     R0, [R4, #0x3C] \n"
 150 "    BL      sub_FFC5E6D0 \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_FFC557BC \n"
 175 "    MOV     R1, R4 \n"
 176 "    MOV     R2, R0 \n"
 177 "    MOV     R4, #0 \n"
 178 "    LDR     R3, =0x19934 \n"
 179 "    CMP     R2, R4 \n"
 180 "    LDR     R6, =0x19930 \n"
 181 "    MOV     R0, R5 \n"
 182 "    STR     R2, [R3] \n"
 183 "    BGT     loc_FFC55A60 \n"
 184 "    BL      sub_FFC556CC \n"
 185 "    MOV     R0, #0x8000001 \n"
 186 "    ADD     R0, R0, #0x1200000 \n"
 187 "    BL      sub_FFC533C0 \n"
 188 "    MOV     R0, #2 \n"
 189 "    LDMFD   SP!, {R4-R6,PC} \n"
 190 
 191 "loc_FFC55A60:\n"
 192 "    LDR     R3, =0x19938 \n"
 193 "    LDRH    R0, [R6] \n"
 194 "    STR     R4, [R3] \n"
 195 "    BL      sub_FFC55930 \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 ".long   0x6c756e2f\n" // "/null"
 202 ".long   0x0000006c\n"
 203 //mod end
 204 );
 205 }

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