root/platform/sx220hs/sub/101a/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF2DB12C_my
  3. sub_FF2DB6BC_my
  4. sub_FF2DB26C_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 7   // filewritetask is prepared for this many chunks
  13 /*
  14  * fwt_data_struct: defined here as it's camera dependent
  15  * unneeded members are designated with unkn
  16  * pdc is required, everything after that is optional (DryOS < R50)
  17  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  18  */
  19 typedef struct
  20 {
  21     int unkn1[5];
  22     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  23     int unkn2;
  24     char name[32];
  25 } fwt_data_struct;
  26 
  27 #include "../../../generic/filewrite.c"
  28 
  29 /*************************************************************/
  30 //** filewritetask @ 0xFF2DB3E0 - 0xFF2DB4C0, length=57
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xD0C8 \n"
  35 
  36 "loc_FF2DB3E8:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF02AD50 /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    MOVNE   R1, #0x348 \n"
  43 "    LDRNE   R0, =0xFF2DB4E0 /*'dwFWrite.c'*/ \n"
  44 "    BLNE    _DebugAssert \n"
  45 "    LDR     R0, [SP, #8] \n"
  46 "    LDR     R1, [R0] \n"
  47 "    CMP     R1, #0xA \n"
  48 "    ADDCC   PC, PC, R1, LSL#2 \n"
  49 "    B       loc_FF2DB3E8 \n"
  50 "    B       loc_FF2DB4B4 \n"
  51 "    B       loc_FF2DB4B4 \n"
  52 "    B       loc_FF2DB4B4 \n"
  53 "    B       loc_FF2DB4B4 \n"
  54 "    B       loc_FF2DB4B4 \n"
  55 "    B       loc_FF2DB4B4 \n"
  56 "    B       loc_FF2DB4B4 \n"
  57 "    B       loc_FF2DB4BC \n"
  58 "    B       loc_FF2DB444 \n"
  59 "    B       loc_FF2DB4AC \n"
  60 
  61 "loc_FF2DB444:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF2DB450:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02AF94 /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF2DB47C \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF02AD50 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF2DB450 \n"
  78 
  79 "loc_FF2DB47C:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF2DB4A0 \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x114E58 \n"
  87 "    BL      sub_FF06AF88 \n"
  88 "    BL      sub_FF069180 \n"
  89 
  90 "loc_FF2DB4A0:\n"
  91 "    LDR     R0, [R4, #0xC] \n"
  92 "    BL      _GiveSemaphore \n"
  93 "    B       loc_FF2DB3E8 \n"
  94 
  95 "loc_FF2DB4AC:\n"
  96 "    BL      sub_FF2DB12C_my \n"  // --> Patched. Old value = 0xFF2DB12C.
  97 "    B       loc_FF2DB3E8 \n"
  98 
  99 "loc_FF2DB4B4:\n"
 100 "    BL      sub_FF2DB6BC_my \n"  // --> Patched. Old value = 0xFF2DB6BC.
 101 "    B       loc_FF2DB3E8 \n"
 102 
 103 "loc_FF2DB4BC:\n"
 104 "    BL      sub_FF2DB26C_my \n"  // --> Patched. Old value = 0xFF2DB26C.
 105 "    B       loc_FF2DB3E8 \n"
 106 );
 107 }
 108 
 109 /*************************************************************/
 110 //** sub_FF2DB12C_my @ 0xFF2DB12C - 0xFF2DB184, length=23
 111 void __attribute__((naked,noinline)) sub_FF2DB12C_my() {
 112 asm volatile (
 113 "    STMFD   SP!, {R4-R9,LR} \n"
 114 "    MOV     R4, R0 \n"
 115 "    SUB     SP, SP, #0x3C \n"
 116 "    ADD     R0, R0, #0x50 \n"
 117 "    BL      sub_FF06AF88 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF069118 \n"
 120 "    LDR     R0, [R4, #0xC] \n"
 121 "    BL      sub_FF00033C \n"
 122 "    LDR     R0, [R4, #0x4C] \n"
 123 "    ADD     R7, R4, #0x50 \n"
 124 "    CMP     R0, #1 \n"
 125 "    LDREQ   R0, [R4, #8] \n"
 126 "    ORREQ   R0, R0, #0x8000 \n"
 127 "    STREQ   R0, [R4, #8] \n"
 128 "    LDR     R5, [R4, #0xC] \n"
 129 "    LDR     R8, [R4, #8] \n"
 130 "    BL      sub_FF18D07C \n"
 131 //hook start
 132 "    STMFD   SP!, {R2,R4-R12,LR} \n"
 133 "    MOV     R0, R4 \n"
 134 "    BL      filewrite_main_hook \n"
 135 "    LDMFD   SP!, {R2,R4-R12,LR} \n"
 136 //hook end
 137 "    LDR     R9, =0x1B6 \n"
 138 "    MOV     R1, R8 \n"
 139 "    MOV     R2, R9 \n"
 140 "    MOV     R0, R7 \n"
 141 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 142 "    LDR     PC, =0xFF2DB188 \n"  // Continue in firmware
 143 );
 144 }
 145 
 146 /*************************************************************/
 147 //** sub_FF2DB6BC_my @ 0xFF2DB6BC - 0xFF2DB73C, length=33
 148 void __attribute__((naked,noinline)) sub_FF2DB6BC_my() {
 149 asm volatile (
 150 "    STMFD   SP!, {R4-R10,LR} \n"
 151 "    MOV     R5, R0 \n"
 152 "    LDR     R0, [R0] \n"
 153 "    CMP     R0, #6 \n"
 154 "    BHI     loc_FF2DB6E8 \n"
 155 "    ADD     R0, R5, R0, LSL#3 \n"
 156 "    LDR     R8, [R0, #0x14]! \n"
 157 "    LDR     R7, [R0, #4] \n"
 158 "    CMP     R7, #0 \n"
 159 "    BNE     loc_FF2DB700 \n"
 160 "    B       loc_FF2DB6F4 \n"
 161 
 162 "loc_FF2DB6E8:\n"
 163 "    LDR     R1, =0x2A2 \n"
 164 "    LDR     R0, =0xFF2DB4E0 /*'dwFWrite.c'*/ \n"
 165 "    BL      _DebugAssert \n"
 166 
 167 "loc_FF2DB6F4:\n"
 168 "    MOV     R1, R5 \n"
 169 "    MOV     R0, #7 \n"
 170 "    B       sub_FF2DB794 \n"
 171 
 172 "loc_FF2DB700:\n"
 173 "    LDR     R9, =0xD0C8 \n"
 174 "    MOV     R4, R7 \n"
 175 "    LDR     R0, [R5, #4] \n"
 176 "    CMP     R4, #0x1000000 \n"
 177 "    MOVLS   R6, R4 \n"
 178 "    MOVHI   R6, #0x1000000 \n"
 179 "    BIC     R1, R0, #0xFF000000 \n"
 180 "    CMP     R1, #0 \n"
 181 "    BICNE   R0, R0, #0xFF000000 \n"
 182 "    RSBNE   R0, R0, #0x1000000 \n"
 183 "    CMPNE   R6, R0 \n"
 184 "    MOVHI   R6, R0 \n"
 185 "    LDR     R0, [R9, #4] \n"
 186 "    MOV     R2, R6 \n"
 187 "    MOV     R1, R8 \n"
 188 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 189 "    LDR     PC, =0xFF2DB740 \n"  // Continue in firmware
 190 );
 191 }
 192 
 193 /*************************************************************/
 194 //** sub_FF2DB26C_my @ 0xFF2DB26C - 0xFF2DB2A0, length=14
 195 void __attribute__((naked,noinline)) sub_FF2DB26C_my() {
 196 asm volatile (
 197 "    STMFD   SP!, {R4-R6,LR} \n"
 198 "    LDR     R5, =0xD0C8 \n"
 199 "    MOV     R4, R0 \n"
 200 "    LDR     R0, [R5, #4] \n"
 201 "    SUB     SP, SP, #0x38 \n"
 202 "    CMN     R0, #1 \n"
 203 "    BEQ     sub_FF2DB2B4 \n"
 204 "    LDR     R1, [R4, #8] \n"
 205 "    LDR     R6, =0x9200003 \n"
 206 "    TST     R1, #0x8000 \n"
 207 "    BEQ     loc_FF2DB2A0 \n"
 208 "    BL      sub_FF027134 \n"
 209 "    B       sub_FF2DB2A4 \n"
 210 
 211 "loc_FF2DB2A0:\n"
 212 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 213 "    LDR     PC, =0xFF2DB2A4 \n"  // Continue in firmware
 214 );
 215 }

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