root/platform/g7/sub/100i/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF8740F0_my
  3. sub_FF873F9C_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 @ 0xFF8741A8 - 0xFF874238, length=37
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    LDR     R4, =0x1CC8C \n"
  36 "    SUB     SP, SP, #4 \n"
  37 "    B       loc_FF8741DC \n"
  38 
  39 "loc_FF8741B8:\n"
  40 "    TST     R3, #4 \n"
  41 "    BEQ     loc_FF8741D8 \n"
  42 "    LDR     R0, [R4] \n"
  43 "    BL      sub_FF820E7C /*_ClearEventFlag*/ \n"
  44 "    LDR     R0, [R4] \n"
  45 "    MOV     R1, #8 \n"
  46 "    BL      sub_FF820CE0 /*_SetEventFlag*/ \n"
  47 "    B       loc_FF8741DC \n"
  48 
  49 "loc_FF8741D8:\n"
  50 "    BL      sub_FF8740F0_my \n"  // --> Patched. Old value = 0xFF8740F0.
  51 
  52 "loc_FF8741DC:\n"
  53 "    MOV     R1, #7 \n"
  54 "    LDR     R0, [R4] \n"
  55 "    MOV     R2, #0 \n"
  56 "    BL      sub_FF820CC0 /*_WaitForAnyEventFlag*/ \n"
  57 "    CMP     R0, #0 \n"
  58 "    MOV     R1, SP \n"
  59 "    BEQ     loc_FF87420C \n"
  60 "    MOV     R1, #0x2B0 \n"
  61 "    LDR     R0, =0xFF874044 /*'dwFWrite.c'*/ \n"
  62 "    ADD     R1, R1, #1 \n"
  63 "    BL      _DebugAssert \n"
  64 "    B       loc_FF874224 \n"
  65 
  66 "loc_FF87420C:\n"
  67 "    LDR     R0, [R4] \n"
  68 "    BL      sub_FF820ECC /*_GetEventFlagValue*/ \n"
  69 "    LDR     R3, [SP] \n"
  70 "    TST     R3, #2 \n"
  71 "    MOV     R1, #5 \n"
  72 "    BEQ     loc_FF8741B8 \n"
  73 
  74 "loc_FF874224:\n"
  75 "    LDR     R3, =0x1CC90 \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_FF8740F0_my @ 0xFF8740F0 - 0xFF87418C, length=40
  86 void __attribute__((naked,noinline)) sub_FF8740F0_my() {
  87 asm volatile (
  88 "    STMFD   SP!, {R4,R5,LR} \n"
  89 "    LDR     R2, =0x1CC70 \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_FF87413C \n"
  95 "    .long   loc_FF87411C \n"
  96 "    .long   loc_FF87412C \n"
  97 "    .long   loc_FF87412C \n"
  98 "    .long   loc_FF87412C \n"
  99 
 100 "loc_FF87411C:\n"
 101 "    LDR     R0, =0x1CC30 \n"
 102 "    BL      sub_FF873F9C_my \n"  // --> Patched. Old value = 0xFF873F9C.
 103 "    MOV     R4, R0 \n"
 104 "    B       loc_FF874140 \n"
 105 
 106 "loc_FF87412C:\n"
 107 "    LDR     R0, =0x1CC30 \n"
 108 "    BL      sub_FF874050 \n"
 109 "    MOV     R4, R0 \n"
 110 "    B       loc_FF874140 \n"
 111 
 112 "loc_FF87413C:\n"
 113 "    MOV     R4, #1 \n"
 114 
 115 "loc_FF874140:\n"
 116 "    CMP     R4, #0 \n"
 117 "    MOV     R1, #1 \n"
 118 "    LDMEQFD SP!, {R4,R5,PC} \n"
 119 "    LDR     R3, =0x1CC8C \n"
 120 "    LDR     R0, [R3] \n"
 121 "    BL      sub_FF820E7C /*_ClearEventFlag*/ \n"
 122 "    LDR     R3, =0x1CC98 \n"
 123 "    LDR     R5, [R3] \n"
 124 "    LDR     R1, =0x1CC94 \n"
 125 "    LDR     R12, =0x291C \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_FF873F9C_my @ 0xFF873F9C - 0xFF874034, length=39
 142 void __attribute__((naked,noinline)) sub_FF873F9C_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_FF873C74 \n"
 149 "    LDR     R0, [R4, #0x3C] \n"
 150 "    BL      sub_FF87D7C4 \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_jpeg_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_FF873D78 \n"
 175 "    MOV     R1, R4 \n"
 176 "    MOV     R2, R0 \n"
 177 "    MOV     R4, #0 \n"
 178 "    LDR     R3, =0x1CC74 \n"
 179 "    CMP     R2, R4 \n"
 180 "    LDR     R6, =0x1CC70 \n"
 181 "    MOV     R0, R5 \n"
 182 "    STR     R2, [R3] \n"
 183 "    BGT     loc_FF87401C \n"
 184 "    BL      sub_FF873C88 \n"
 185 "    MOV     R0, #0x8000001 \n"
 186 "    ADD     R0, R0, #0x1200000 \n"
 187 "    BL      sub_FF871924 \n"
 188 "    MOV     R0, #2 \n"
 189 "    LDMFD   SP!, {R4-R6,PC} \n"
 190 
 191 "loc_FF87401C:\n"
 192 "    LDR     R3, =0x1CC78 \n"
 193 "    LDRH    R0, [R6] \n"
 194 "    STR     R4, [R3] \n"
 195 "    BL      sub_FF873EEC \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] */