root/platform/tx1/sub/101b/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFAA5F08_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[5];    
  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 @ 0xFFAA61A0 - 0xFFAA6234, length=38
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R4,LR} \n"
  35 "    SUB     SP, SP, #4 \n"
  36 "    MOV     R4, SP \n"
  37 "    B       loc_FFAA61F0 \n"
  38 
  39 "loc_FFAA61B0:\n"
  40 "    CMP     R2, #5 \n"
  41 "    LDRLS   PC, [PC, R2, LSL#2] \n"
  42 "    B       loc_FFAA61F0 \n"
  43 "    .long   loc_FFAA61D4 \n"
  44 "    .long   loc_FFAA61DC \n"
  45 "    .long   loc_FFAA61E4 \n"
  46 "    .long   loc_FFAA61E4 \n"
  47 "    .long   loc_FFAA61E4 \n"
  48 "    .long   loc_FFAA61EC \n"
  49 
  50 "loc_FFAA61D4:\n"
  51 "    BL      sub_FFAA5DE0 \n"
  52 "    B       loc_FFAA61F0 \n"
  53 
  54 "loc_FFAA61DC:\n"
  55 "    BL      sub_FFAA5F08_my \n"  // --> Patched. Old value = 0xFFAA5F08. Open Stage
  56 "    B       loc_FFAA61F0 \n"
  57 
  58 "loc_FFAA61E4:\n"
  59 "    BL      sub_FFAA5FE4 \n"
  60 "    B       loc_FFAA61F0 \n"
  61 
  62 "loc_FFAA61EC:\n"
  63 "    BL      sub_FFAA60DC \n"
  64 "    BL      fwt_after_close\n" //+
  65 
  66 "loc_FFAA61F0:\n"
  67 "    LDR     R3, =0x74A58 \n"
  68 "    MOV     R1, R4 \n"
  69 "    LDR     R0, [R3] \n"
  70 "    MOV     R2, #0 \n"
  71 "    BL      sub_FFB40944 /*_ReceiveMessageQueue*/ \n"
  72 "    CMP     R0, #0 \n"
  73 "    BNE     loc_FFAA622C \n"
  74 "    LDR     R0, [SP] \n"
  75 "    LDR     R3, [R0] \n"
  76 "    CMP     R3, #1 \n"
  77 "    SUB     R2, R3, #2 \n"
  78 "    BNE     loc_FFAA61B0 \n"
  79 "    LDR     R3, =0x74A50 \n"
  80 "    LDR     R0, [R3] \n"
  81 "    BL      _GiveSemaphore \n"
  82 
  83 "loc_FFAA622C:\n"
  84 "    BL      _ExitTask \n"
  85 "    ADD     SP, SP, #4 \n"
  86 "    LDMFD   SP!, {R4,PC} \n"
  87 );
  88 }
  89 
  90 /*************************************************************/
  91 //** sub_FFAA5F08_my @ 0xFFAA5F08 - 0xFFAA5FA4, length=40
  92 void __attribute__((naked,noinline)) sub_FFAA5F08_my() {
  93 asm volatile (
  94 "    STMFD   SP!, {R4,R5,LR} \n"
  95 "    MOV     R5, R0 \n"
  96 "    ADD     R4, R5, #0x2C \n"
  97 "    MOV     R0, R4 \n"
  98 "    BL      sub_FFAAE5F4 \n"
  99 "    MOV     R1, #0 \n"
 100 "    BL      sub_FFAB143C \n"
 101 "    LDR     R0, [R5, #0xC] \n"
 102 "    BL      sub_FFAB2070 \n"
 103 "    MOV     R2, #0x1B4 \n"
 104 "    LDR     R1, [R5, #8] \n"
 105 "    ADD     R2, R2, #2 \n"
 106 "    LDR     R3, [R5, #0xC] \n"
 107 //place hook here
 108 //the task's data block is at [R5] at this point, filename starts at [R5+0x2C]
 109 //the block can be captured here for a (new) camera with unknown data block structure
 110 //for ptp remote capture, pass '/null' as filename
 111 //if writing does not need to be prevented, just continue
 112 "    STMFD   SP!, {R1-R12,LR}\n"
 113 "    MOV     R0, R5\n"
 114 "    BL      filewrite_main_hook\n"
 115 "    BL      filewrite_file_complete\n"
 116 "    CMP     R0, #0\n"
 117 "    LDRNE   R0, =loc_mynull\n" // /null as file name (works only on VxWorks)
 118 "    LDMFD   SP!, {R1-R12,LR}\n"
 119 "    MOVEQ   R0, R4\n" //canon file name
 120 //hook end
 121 //"  MOV     R0, R4 \n"  // - file name
 122 "    BL      sub_FFAA5E74 \n"
 123 "    LDR     R3, =0x74A48 \n"
 124 "    MOV     R12, R0 \n"
 125 "    CMN     R12, #1 \n"
 126 "    MOV     R1, R4 \n"
 127 "    MOV     R2, #0x20 \n"
 128 "    MOV     R0, R4 \n"
 129 "    STR     R12, [R3] \n"
 130 "    BNE     loc_FFAA5F90 \n"
 131 "    BL      sub_FFAAE5F4 \n"
 132 "    BL      sub_FFAB14A4 \n"
 133 "    LDR     R3, =0x74B68 \n"
 134 "    LDR     R3, [R3] \n"
 135 "    MOV     R0, #0x8000001 \n"
 136 "    CMP     R3, #0 \n"
 137 "    ADD     R0, R0, #0x1200000 \n"
 138 "    LDMEQFD SP!, {R4,R5,PC} \n"
 139 "    MOV     LR, PC \n"
 140 "    MOV     PC, R3 \n"
 141 "    LDMFD   SP!, {R4,R5,PC} \n"
 142 
 143 "loc_FFAA5F90:\n"
 144 "    LDR     R0, =0x74B48 \n"
 145 "    BL      _memcpy \n"
 146 "    MOV     R0, #4 \n"
 147 "    MOV     R1, R5 \n"
 148 "    LDMFD   SP!, {R4,R5,LR} \n"
 149 "    B       sub_FFAA5CF0 \n"
 150 //mod start
 151 "loc_mynull:\n"
 152 ".asciz     \"/null\" \n"
 153 //mod end
 154 );
 155 }

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