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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFE15364_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[5];    
  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 @ 0xFFE155FC - 0xFFE15688, length=36
  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_FFE1564C \n"
  38 
  39 "loc_FFE1560C:\n"
  40 "    CMP     R2, #5 \n"
  41 "    LDRLS   PC, [PC, R2, LSL#2] \n"
  42 "    B       loc_FFE1564C \n"
  43 "    .long   loc_FFE15630 \n"
  44 "    .long   loc_FFE15638 \n"
  45 "    .long   loc_FFE15640 \n"
  46 "    .long   loc_FFE15640 \n"
  47 "    .long   loc_FFE15640 \n"
  48 "    .long   loc_FFE15648 \n"
  49 
  50 "loc_FFE15630:\n"
  51 "    BL      sub_FFE1523C \n"
  52 "    B       loc_FFE1564C \n"
  53 
  54 "loc_FFE15638:\n"
  55 "    BL      sub_FFE15364_my \n"  // --> Patched. Old value = 0xFFE15364. Open Stage
  56 "    B       loc_FFE1564C \n"
  57 
  58 "loc_FFE15640:\n"
  59 "    BL      sub_FFE15440 \n"
  60 "    B       loc_FFE1564C \n"
  61 
  62 "loc_FFE15648:\n"
  63 "    BL      sub_FFE15538 \n"
  64 "    BL      fwt_after_close\n" //+
  65 
  66 "loc_FFE1564C:\n"
  67 "    LDR     R3, =0x54718 \n"
  68 "    MOV     R1, R4 \n"
  69 "    LDR     R0, [R3] \n"
  70 "    MOV     R2, #0 \n"
  71 "    BL      sub_FFE82334 /*_ReceiveMessageQueue*/ \n"
  72 "    CMP     R0, #0 \n"
  73 "    BNE     loc_FFE15688 \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_FFE1560C \n"
  79 "    LDR     R3, =0x54710 \n"
  80 "    LDR     R0, [R3] \n"
  81 "    BL      _GiveSemaphore \n"
  82 
  83 "loc_FFE15688:\n"
  84 "    BL      _ExitTask \n"
  85 );
  86 }
  87 
  88 /*************************************************************/
  89 //** sub_FFE15364_my @ 0xFFE15364 - 0xFFE15400, length=40
  90 void __attribute__((naked,noinline)) sub_FFE15364_my() {
  91 asm volatile (
  92 "    STMFD   SP!, {R4,R5,LR} \n"
  93 "    MOV     R5, R0 \n"
  94 "    ADD     R4, R5, #0x2C \n"
  95 "    MOV     R0, R4 \n"
  96 "    BL      sub_FFE1D0E8 \n"
  97 "    MOV     R1, #0 \n"
  98 "    BL      sub_FFE1FF08 \n"
  99 "    LDR     R0, [R5, #0xC] \n"
 100 "    BL      sub_FFE20B3C \n"
 101 "    MOV     R2, #0x1B4 \n"
 102 "    LDR     R1, [R5, #8] \n"
 103 "    ADD     R2, R2, #2 \n"
 104 "    LDR     R3, [R5, #0xC] \n"
 105 //place hook here
 106 //the task's data block is at [R5] at this point, filename starts at [R5+0x2C]
 107 //the block can be captured here for a (new) camera with unknown data block structure
 108 //for ptp remote capture, pass '/null' as filename
 109 //if writing does not need to be prevented, just continue
 110 "    STMFD   SP!, {R1-R12,LR}\n"
 111 "    MOV     R0, R5\n"
 112 "    BL      filewrite_main_hook\n"
 113 "    BL      filewrite_jpeg_complete\n"
 114 "    CMP     R0, #0\n"
 115 "    LDRNE   R0, =loc_mynull\n" // /null as file name (works only on VxWorks)
 116 "    LDMFD   SP!, {R1-R12,LR}\n"
 117 "    MOVEQ   R0, R4\n" //canon file name
 118 //hook end
 119 //"  MOV     R0, R4 \n"  // - file name
 120 "    BL      sub_FFE152D0 \n"
 121 "    LDR     R3, =0x54708 \n"
 122 "    MOV     R12, R0 \n"
 123 "    CMN     R12, #1 \n"
 124 "    MOV     R1, R4 \n"
 125 "    MOV     R2, #0x20 \n"
 126 "    MOV     R0, R4 \n"
 127 "    STR     R12, [R3] \n"
 128 "    BNE     loc_FFE153EC \n"
 129 "    BL      sub_FFE1D0E8 \n"
 130 "    BL      sub_FFE1FF70 \n"
 131 "    LDR     R3, =0x54828 \n"
 132 "    LDR     R3, [R3] \n"
 133 "    MOV     R0, #0x8000001 \n"
 134 "    CMP     R3, #0 \n"
 135 "    ADD     R0, R0, #0x1200000 \n"
 136 "    LDMEQFD SP!, {R4,R5,PC} \n"
 137 "    MOV     LR, PC \n"
 138 "    MOV     PC, R3 \n"
 139 "    LDMFD   SP!, {R4,R5,PC} \n"
 140 
 141 "loc_FFE153EC:\n"
 142 "    LDR     R0, =0x54808 \n"
 143 "    BL      _memcpy \n"
 144 "    MOV     R0, #4 \n"
 145 "    MOV     R1, R5 \n"
 146 "    LDMFD   SP!, {R4,R5,LR} \n"
 147 "    B       sub_FFE1514C \n"
 148 //mod start
 149 "loc_mynull:\n"
 150 ".asciz     \"/null\" \n"
 151 //mod end
 152 );
 153 }

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