root/platform/a410/sub/100f/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFC5236C_my
  3. sub_FFC5221C_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 
   4 typedef struct {
   5     unsigned int address;
   6     unsigned int length;
   7 } cam_ptp_data_chunk; //camera specific structure
   8 
   9 #define MAX_CHUNKS_FOR_JPEG 3 //model specific
  10 /*
  11  * fwt_data_struct: defined here as it's camera dependent
  12  * unneeded members are designated with unkn
  13  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  14  * pdc is always required
  15  * name is not currently used
  16  */
  17 typedef struct
  18 {
  19     int unkn1;
  20     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  21     char name[32];
  22 } fwt_data_struct;
  23 #define CAM_HAS_COMPLETEFILEWRITE_REPLACEMENT 1
  24 
  25 #include "../../../generic/filewrite.c"
  26 
  27 // *** filewritetask ***
  28 
  29 void __attribute__((naked,noinline)) filewritetask(  ) { //0xFFC52424
  30 asm volatile (
  31       "    STMFD   SP!, {R4,LR} \n" 
  32       "    LDR     R4, =0x1D47C \n" 
  33       "    SUB     SP, SP, #4 \n" 
  34       "    B       loc_FFC52458 \n" 
  35 "loc_FFC52434:\n"
  36       "    TST     R3, #4 \n" 
  37       "    BEQ     loc_FFC52454 \n" 
  38       "    LDR     R0, [R4] \n" 
  39       "    BL      sub_FFC10974 \n" 
  40       "    LDR     R0, [R4] \n" 
  41       "    MOV     R1, #8 \n" 
  42       "    BL      sub_FFC107D8 \n" 
  43       "    B       loc_FFC52458 \n" 
  44 "loc_FFC52454:\n"
  45       "    BL      sub_FFC5236C_my \n" //replaced routine, see below
  46 "loc_FFC52458:\n"
  47       "    MOV     R1, #7 \n" 
  48       "    LDR     R0, [R4] \n" 
  49       "    MOV     R2, #0 \n" 
  50       "    BL      sub_FFC107B8 \n" 
  51       "    CMP     R0, #0 \n" 
  52       "    MOV     R1, SP \n" 
  53       "    BEQ     loc_FFC52488 \n" 
  54       "    MOV     R1, #0x268 \n"
  55       "    LDR     R0, =0xFFC522C4 \n" 
  56       "    ADD     R1, R1, #3 \n" 
  57       "    BL      sub_FFC03B58 \n" 
  58       "    B       loc_FFC524A0 \n" 
  59 "loc_FFC52488:\n"
  60       "    LDR     R0, [R4] \n" 
  61       "    BL      sub_FFC109C4 \n" 
  62       "    LDR     R3, [SP] \n" 
  63       "    TST     R3, #2 \n" 
  64       "    MOV     R1, #5 \n" 
  65       "    BEQ     loc_FFC52434 \n" 
  66 "loc_FFC524A0:\n"
  67       "    LDR     R3, =0x1D480 \n" 
  68       "    LDR     R0, [R3] \n" 
  69       "    BL      sub_FFC11D68 \n" 
  70       "    BL      sub_FFC12724 \n" 
  71       "    ADD     SP, SP, #4 \n" 
  72       "    LDMFD   SP!, {R4,PC} \n" 
  73       "    MOV     PC, LR \n"
  74     );
  75 }
  76 
  77 void __attribute__((naked,noinline)) sub_FFC5236C_my(  ) {
  78 asm volatile (
  79 "loc_FFC5236C:\n"
  80       "    STMFD   SP!, {R4,R5,LR} \n"              // rom:ffc5236c  0xE92D4030 
  81       "    LDR     R2, =0x1D460 \n"                 // rom:ffc52370  0xE59F2094 
  82       "    LDRH    R3, [R2] \n"                     // rom:ffc52374  0xE1D230B0 
  83       "    SUB     R3, R3, #1 \n"                   // rom:ffc52378  0xE2433001 
  84       "    CMP     R3, #3 \n"                       // rom:ffc5237c  0xE3530003 
  85       "    LDRLS   PC, [PC, R3, LSL #2] \n"         // rom:ffc52380  0x979FF103 
  86       "    B       loc_FFC523B8 \n"                 // rom:ffc52384  0xEA00000B 
  87       "    .long loc_FFC52398\n"
  88       "    .long loc_FFC523A8\n" 
  89       "    .long loc_FFC523A8\n"
  90       "    .long loc_FFC523A8\n"
  91 "loc_FFC52398:\n"
  92       "    LDR     R0, =0x1D420 \n" //location of the data block
  93       "    BL      sub_FFC5221C_my \n" //->"Open", replaced routine
  94       "    MOV     R4, R0 \n"                       // rom:ffc523a0  0xE1A04000 
  95       "    B       loc_FFC523BC \n"                 // rom:ffc523a4  0xEA000004 
  96 "loc_FFC523A8:\n"
  97       "    LDR     R0, =0x1D420 \n"                 // rom:ffc523a8  0xE59F0060 
  98       "    BL      sub_FFC522D0 \n"                 // rom:ffc523ac  0xEBFFFFC7 
  99       "    MOV     R4, R0 \n"                       // rom:ffc523b0  0xE1A04000 
 100       "    B       loc_FFC523BC \n"                 // rom:ffc523b4  0xEA000000 
 101 "loc_FFC523B8:\n"
 102       "    MOV     R4, #1 \n"                       // rom:ffc523b8  0xE3A04001 
 103 "loc_FFC523BC:\n"
 104       "    CMP     R4, #0 \n"                       // rom:ffc523bc  0xE3540000 
 105       "    MOV     R1, #1 \n"                       // rom:ffc523c0  0xE3A01001 
 106       "    LDMEQFD SP!, {R4,R5,PC} \n"              // rom:ffc523c4  0x08BD8030 
 107       "    LDR     R3, =0x1D47C \n"                 // rom:ffc523c8  0xE59F3044 
 108       "    LDR     R0, [R3] \n"                     // rom:ffc523cc  0xE5930000 
 109       "    BL      sub_FFC10974 \n"                 // rom:ffc523d0  0xEBFEF967 
 110       "    LDR     R3, =0x1D488 \n"                 // rom:ffc523d4  0xE59F303C 
 111       "    LDR     R5, [R3] \n"                     // rom:ffc523d8  0xE5935000 
 112       "    LDR     R1, =0x1D484 \n"                 // rom:ffc523dc  0xE59F1038 
 113       "    LDR     R12, =0x24E0 \n"                 // rom:ffc523e0  0xE59FC038 
 114       "    MOV     R3, #1 \n"                       // rom:ffc523e4  0xE3A03001 
 115       "    MOV     R2, #0 \n"                       // rom:ffc523e8  0xE3A02000 
 116       "    CMP     R5, #0 \n"                       // rom:ffc523ec  0xE3550000 
 117       "    STR     R3, [R1] \n"                     // rom:ffc523f0  0xE5813000 
 118       "    MOV     R0, R4 \n"                       // rom:ffc523f4  0xE1A00004 
 119       "    STR     R2, [R12] \n"                    // rom:ffc523f8  0xE58C2000 
 120       "    LDMEQFD SP!, {R4,R5,PC} \n"              // rom:ffc523fc  0x08BD8030 
 121       "    MOV     LR, PC \n"                       // rom:ffc52400  0xE1A0E00F 
 122       "    MOV     PC, R5 \n" //end of save, sends signal to filesheduletask
 123       "    BL      fwt_after_close\n" //+
 124       "    LDMFD   SP!, {R4,R5,PC} \n"              // rom:ffc52408  0xE8BD8030 
 125     );
 126 }
 127 
 128 void __attribute__((naked,noinline)) sub_FFC5221C_my(  ) {
 129 asm volatile (
 130 "loc_FFC5221C:\n"
 131       "    STMFD   SP!, {R4-R6,LR} \n"              // rom:ffc5221c  0xE92D4070 
 132       "    MOV     R4, R0 \n"                       // rom:ffc52220  0xE1A04000 
 133       "    ADD     R5, R4, #0x1C \n"                // rom:ffc52224  0xE284501C 
 134       "    MOV     R0, R5 \n"                       // rom:ffc52228  0xE1A00005 
 135       "    BL      sub_FFC51EF4 \n"                 // rom:ffc5222c  0xEBFFFF30 
 136       "    LDR     R0, [R4, #0x3C] \n"              // rom:ffc52230  0xE594003C 
 137       "    BL      sub_FFC5B244 \n"                 // rom:ffc52234  0xEB002402 
 138       "    LDR     R3, [R4] \n"                     // rom:ffc52238  0xE5943000 
 139       "    MOV     R1, #0x600 \n"                   // rom:ffc5223c  0xE3A01C06 
 140       "    TST     R3, #0x10000 \n"                 // rom:ffc52240  0xE3130801 
 141       "    ADD     R1, R1, #1 \n"                   // rom:ffc52244  0xE2811001 
 142       "    MOV     R2, #0x1B4 \n"                   // rom:ffc52248  0xE3A02F6D 
 143       "    ORRNE   R1, R1, #0x8000 \n"              // rom:ffc5224c  0x13811902 
 144       "    LDR     R3, [R4, #0x3C] \n"              // rom:ffc52250  0xE594303C 
 145       "    ADD     R2, R2, #2 \n" // 0x1b6 = 666 octal (file permission)
 146 //place hook here
 147 //the task's data block is at [r4] at this point, filename starts at [r4+0x1c]
 148 //the block can be captured here for a (new) camera with unknown data block structure
 149 //for ptp remote capture, pass '/null' as filename
 150 //if writing does not need to be prevented, just continue
 151       "STMFD SP!, {R1-R12,LR}\n"
 152       "MOV R0, R4\n"
 153       "BL filewrite_main_hook\n"
 154       "BL filewrite_jpeg_complete\n"
 155       "CMP R0, #0\n"
 156       "LDRNE R0, =loc_mynull\n" // /null as file name (works only on VxWorks)
 157       "LDMFD SP!, {R1-R12,LR}\n"
 158       "MOVEQ R0, R5\n" //canon file name
 159 //hook end
 160       //"    MOV     R0, R5 \n" //- file name
 161       "    BL      sub_FFC51FF8 \n" // Open
 162       "    MOV     R1, R4 \n"                       // rom:ffc52260  0xE1A01004 
 163       "    MOV     R2, R0 \n"                       // rom:ffc52264  0xE1A02000 
 164       "    MOV     R4, #0 \n"                       // rom:ffc52268  0xE3A04000 
 165       "    LDR     R3, =0x1D464 \n"                 // rom:ffc5226c  0xE59F3044 
 166       "    CMP     R2, R4 \n"                       // rom:ffc52270  0xE1520004 
 167       "    LDR     R6, =0x1D460 \n"                 // rom:ffc52274  0xE59F6040 
 168       "    MOV     R0, R5 \n"                       // rom:ffc52278  0xE1A00005 
 169       "    STR     R2, [R3] \n"                     // rom:ffc5227c  0xE5832000 
 170       "    BGT     loc_FFC5229C \n"                 // rom:ffc52280  0xCA000005 
 171       "    BL      sub_FFC51F08 \n"                 // rom:ffc52284  0xEBFFFF1F 
 172       "    MOV     R0, #0x8000001 \n"               // rom:ffc52288  0xE3A00342 
 173       "    ADD     R0, R0, #0x1200000 \n"           // rom:ffc5228c  0xE2800612 
 174       "    BL      sub_FFC4FA70 \n"                 // rom:ffc52290  0xEBFFF5F6 
 175       "    MOV     R0, #2 \n"                       // rom:ffc52294  0xE3A00002 
 176       "    LDMFD   SP!, {R4-R6,PC} \n"              // rom:ffc52298  0xE8BD8070 
 177 "loc_FFC5229C:\n"
 178       "    LDR     R3, =0x1D468 \n"                 // rom:ffc5229c  0xE59F301C 
 179       "    LDRH    R0, [R6] \n"                     // rom:ffc522a0  0xE1D600B0 
 180       "    STR     R4, [R3] \n"                     // rom:ffc522a4  0xE5834000 
 181       "    BL      sub_FFC5216C \n"                 // rom:ffc522a8  0xEBFFFFAF 
 182       "    STRH    R0, [R6] \n"                     // rom:ffc522ac  0xE1C600B0 
 183       "    MOV     R0, R4 \n"                       // rom:ffc522b0  0xE1A00004 
 184       "    LDMFD   SP!, {R4-R6,PC} \n"              // rom:ffc522b4  0xE8BD8070 
 185 //mod start
 186 "loc_mynull:\n"
 187 ".long   0x6c756e2f\n" // "/null"
 188 ".long   0x0000006c\n"
 189 //mod end
 190     );
 191 }

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