root/platform/sx230hs/sub/100c/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FF2E4C78_my
  3. sub_FF2E520C_my
  4. sub_FF2E4DB8_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 @ 0xFF2E4F2C - 0xFF2E500C, length=57
  31 void __attribute__((naked,noinline)) filewritetask() {
  32 asm volatile (
  33 "    STMFD   SP!, {R1-R5,LR} \n"
  34 "    LDR     R5, =0xD1BC \n"
  35 
  36 "loc_FF2E4F34:\n"
  37 "    MOV     R2, #0 \n"
  38 "    LDR     R0, [R5, #0x10] \n"
  39 "    ADD     R1, SP, #8 \n"
  40 "    BL      sub_FF02B17C /*_ReceiveMessageQueue*/ \n"
  41 "    CMP     R0, #0 \n"
  42 "    MOVNE   R1, #0x348 \n"
  43 "    LDRNE   R0, =0xFF2E502C /*'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_FF2E4F34 \n"
  50 "    B       loc_FF2E5000 \n"
  51 "    B       loc_FF2E5000 \n"
  52 "    B       loc_FF2E5000 \n"
  53 "    B       loc_FF2E5000 \n"
  54 "    B       loc_FF2E5000 \n"
  55 "    B       loc_FF2E5000 \n"
  56 "    B       loc_FF2E5000 \n"
  57 "    B       loc_FF2E5008 \n"
  58 "    B       loc_FF2E4F90 \n"
  59 "    B       loc_FF2E4FF8 \n"
  60 
  61 "loc_FF2E4F90:\n"
  62 "    MOV     R0, #0 \n"
  63 "    MOV     R4, R5 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FF2E4F9C:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF02B3C0 /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FF2E4FC8 \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF02B17C /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FF2E4F9C \n"
  78 
  79 "loc_FF2E4FC8:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FF2E4FEC \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x118B70 \n"
  87 "    BL      sub_FF06C4A8 \n"
  88 "    BL      sub_FF06A6CC \n"
  89 
  90 "loc_FF2E4FEC:\n"
  91 "    LDR     R0, [R4, #0xC] \n"
  92 "    BL      _GiveSemaphore \n"
  93 "    B       loc_FF2E4F34 \n"
  94 
  95 "loc_FF2E4FF8:\n"
  96 "    BL      sub_FF2E4C78_my \n"  // --> Patched. Old value = 0xFF2E4C78.
  97 "    B       loc_FF2E4F34 \n"
  98 
  99 "loc_FF2E5000:\n"
 100 "    BL      sub_FF2E520C_my \n"  // --> Patched. Old value = 0xFF2E520C.
 101 "    B       loc_FF2E4F34 \n"
 102 
 103 "loc_FF2E5008:\n"
 104 "    BL      sub_FF2E4DB8_my \n"  // --> Patched. Old value = 0xFF2E4DB8.
 105 "    B       loc_FF2E4F34 \n"
 106 );
 107 }
 108 
 109 /*************************************************************/
 110 //** sub_FF2E4C78_my @ 0xFF2E4C78 - 0xFF2E4CD0, length=23
 111 void __attribute__((naked,noinline)) sub_FF2E4C78_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_FF06C4A8 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF06A664 \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_FF1925A8 \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, =0xFF2E4CD4 \n"  // Continue in firmware
 143 );
 144 }
 145 
 146 /*************************************************************/
 147 //** sub_FF2E520C_my @ 0xFF2E520C - 0xFF2E528C, length=33
 148 void __attribute__((naked,noinline)) sub_FF2E520C_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_FF2E5238 \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_FF2E5250 \n"
 160 "    B       loc_FF2E5244 \n"
 161 
 162 "loc_FF2E5238:\n"
 163 "    LDR     R1, =0x2A2 \n"
 164 "    LDR     R0, =0xFF2E502C /*'dwFWrite.c'*/ \n"
 165 "    BL      _DebugAssert \n"
 166 
 167 "loc_FF2E5244:\n"
 168 "    MOV     R1, R5 \n"
 169 "    MOV     R0, #7 \n"
 170 "    B       sub_FF2E52E4 \n"
 171 
 172 "loc_FF2E5250:\n"
 173 "    LDR     R9, =0xD1BC \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, =0xFF2E5290 \n"  // Continue in firmware
 190 );
 191 }
 192 
 193 /*************************************************************/
 194 //** sub_FF2E4DB8_my @ 0xFF2E4DB8 - 0xFF2E4DEC, length=14
 195 void __attribute__((naked,noinline)) sub_FF2E4DB8_my() {
 196 asm volatile (
 197 "    STMFD   SP!, {R4-R6,LR} \n"
 198 "    LDR     R5, =0xD1BC \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_FF2E4E00 \n"
 204 "    LDR     R1, [R4, #8] \n"
 205 "    LDR     R6, =0x9200003 \n"
 206 "    TST     R1, #0x8000 \n"
 207 "    BEQ     loc_FF2E4DEC \n"
 208 "    BL      sub_FF02750C \n"
 209 "    B       sub_FF2E4DF0 \n"
 210 
 211 "loc_FF2E4DEC:\n"
 212 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 213 "    LDR     PC, =0xFF2E4DF0 \n"  // Continue in firmware
 214 );
 215 }

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