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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFC548A4_my
  3. sub_FFC54750_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 @ 0xFFC5495C - 0xFFC549E8, length=36
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    LDR     R4, =0x1C8FC \n"
  36 "    SUB     SP, SP, #4 \n"
  37 "    B       loc_FFC54990 \n"
  38 
  39 "loc_FFC5496C:\n"
  40 "    TST     R3, #4 \n"
  41 "    BEQ     loc_FFC5498C \n"
  42 "    LDR     R0, [R4] \n"
  43 "    BL      sub_FFC0FA60 /*_ClearEventFlag*/ \n"
  44 "    LDR     R0, [R4] \n"
  45 "    MOV     R1, #8 \n"
  46 "    BL      sub_FFC0F8C4 /*_SetEventFlag*/ \n"
  47 "    B       loc_FFC54990 \n"
  48 
  49 "loc_FFC5498C:\n"
  50 "    BL      sub_FFC548A4_my \n"  // --> Patched. Old value = 0xFFC548A4.
  51 
  52 "loc_FFC54990:\n"
  53 "    MOV     R1, #7 \n"
  54 "    LDR     R0, [R4] \n"
  55 "    MOV     R2, #0 \n"
  56 "    BL      sub_FFC0F8A4 /*_WaitForAnyEventFlag*/ \n"
  57 "    CMP     R0, #0 \n"
  58 "    MOV     R1, SP \n"
  59 "    BEQ     loc_FFC549BC \n"
  60 "    LDR     R0, =0xFFC547F8 /*'dwFWrite.c'*/ \n"
  61 "    MOV     R1, #0x274 \n"
  62 "    BL      _DebugAssert \n"
  63 "    B       loc_FFC549D4 \n"
  64 
  65 "loc_FFC549BC:\n"
  66 "    LDR     R0, [R4] \n"
  67 "    BL      sub_FFC0FAB0 /*_GetEventFlagValue*/ \n"
  68 "    LDR     R3, [SP] \n"
  69 "    TST     R3, #2 \n"
  70 "    MOV     R1, #5 \n"
  71 "    BEQ     loc_FFC5496C \n"
  72 
  73 "loc_FFC549D4:\n"
  74 "    LDR     R3, =0x1C900 \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_FFC548A4_my @ 0xFFC548A4 - 0xFFC54940, length=40
  85 void __attribute__((naked,noinline)) sub_FFC548A4_my() {
  86 asm volatile (
  87 "    STMFD   SP!, {R4,R5,LR} \n"
  88 "    LDR     R2, =0x1C8E0 \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_FFC548F0 \n"
  94 "    .long   loc_FFC548D0 \n"
  95 "    .long   loc_FFC548E0 \n"
  96 "    .long   loc_FFC548E0 \n"
  97 "    .long   loc_FFC548E0 \n"
  98 
  99 "loc_FFC548D0:\n"
 100 "    LDR     R0, =0x1C8A0 \n"
 101 "    BL      sub_FFC54750_my \n"  // --> Patched. Old value = 0xFFC54750.
 102 "    MOV     R4, R0 \n"
 103 "    B       loc_FFC548F4 \n"
 104 
 105 "loc_FFC548E0:\n"
 106 "    LDR     R0, =0x1C8A0 \n"
 107 "    BL      sub_FFC54804 \n"
 108 "    MOV     R4, R0 \n"
 109 "    B       loc_FFC548F4 \n"
 110 
 111 "loc_FFC548F0:\n"
 112 "    MOV     R4, #1 \n"
 113 
 114 "loc_FFC548F4:\n"
 115 "    CMP     R4, #0 \n"
 116 "    MOV     R1, #1 \n"
 117 "    LDMEQFD SP!, {R4,R5,PC} \n"
 118 "    LDR     R3, =0x1C8FC \n"
 119 "    LDR     R0, [R3] \n"
 120 "    BL      sub_FFC0FA60 /*_ClearEventFlag*/ \n"
 121 "    LDR     R3, =0x1C908 \n"
 122 "    LDR     R5, [R3] \n"
 123 "    LDR     R1, =0x1C904 \n"
 124 "    LDR     R12, =0x27D4 \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_FFC54750_my @ 0xFFC54750 - 0xFFC547E8, length=39
 141 void __attribute__((naked,noinline)) sub_FFC54750_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_FFC54428 \n"
 148 "    LDR     R0, [R4, #0x3C] \n"
 149 "    BL      sub_FFC5D304 \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_file_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_FFC5452C \n"
 174 "    MOV     R1, R4 \n"
 175 "    MOV     R2, R0 \n"
 176 "    MOV     R4, #0 \n"
 177 "    LDR     R3, =0x1C8E4 \n"
 178 "    CMP     R2, R4 \n"
 179 "    LDR     R6, =0x1C8E0 \n"
 180 "    MOV     R0, R5 \n"
 181 "    STR     R2, [R3] \n"
 182 "    BGT     loc_FFC547D0 \n"
 183 "    BL      sub_FFC5443C \n"
 184 "    MOV     R0, #0x8000001 \n"
 185 "    ADD     R0, R0, #0x1200000 \n"
 186 "    BL      sub_FFC51F98 \n"
 187 "    MOV     R0, #2 \n"
 188 "    LDMFD   SP!, {R4-R6,PC} \n"
 189 
 190 "loc_FFC547D0:\n"
 191 "    LDR     R3, =0x1C8E8 \n"
 192 "    LDRH    R0, [R6] \n"
 193 "    STR     R4, [R3] \n"
 194 "    BL      sub_FFC546A0 \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 ".long   0x6c756e2f\n" // "/null"
 201 ".long   0x0000006c\n"
 202 //mod end
 203 );
 204 }

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