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

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFDE3C08_my
  3. sub_FFDE3D3C_my
  4. sub_FFDE37A4_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 4 // 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  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  17  * cameras with possible multipass JPEG writes need oflags
  18  * pdc is always required
  19  * name is not currently used
  20  */
  21 typedef struct
  22 {
  23     int unkn1[2];
  24     int oflags;
  25     int unkn2[2];
  26     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  27     int unkn6;
  28     char name[32];                               // open stage: sub_FFDE3C0C (1.00f) --> "ADD     R0, R0, #0x38"
  29                                                  // offset of 'name' from start = 0x38 = 56 bytes = 14 words
  30 } fwt_data_struct;
  31 
  32 #define OFLAG_NOFLUSH 0x8000
  33 
  34 #include "../../../generic/filewrite.c"
  35 
  36 /*************************************************************/
  37 //** filewritetask @ 0xFFDE3918 - 0xFFDE39FC, length=58
  38 void __attribute__((naked,noinline)) filewritetask() {
  39 asm volatile (
  40 "    STMFD   SP!, {R1-R5,LR} \n"
  41 "    LDR     R4, =0x8388 \n"
  42 
  43 "loc_FFDE3920:\n"
  44 "    LDR     R0, [R4, #0x10] \n"
  45 "    MOV     R2, #0 \n"
  46 "    ADD     R1, SP, #8 \n"
  47 "    BL      sub_FFC28AA4 /*_ReceiveMessageQueue*/ \n"
  48 "    CMP     R0, #0 \n"
  49 "    BNE     loc_FFDE3950 \n"
  50 "    LDR     R0, [SP, #8] \n"
  51 "    LDR     R1, [R0] \n"
  52 "    CMP     R1, #1 \n"
  53 "    BNE     loc_FFDE3958 \n"
  54 "    LDR     R0, [R4, #8] \n"
  55 "    BL      _GiveSemaphore \n"
  56 
  57 "loc_FFDE3950:\n"
  58 "    BL      _ExitTask \n"
  59 "    LDMFD   SP!, {R1-R5,PC} \n"
  60 
  61 "loc_FFDE3958:\n"
  62 "    SUB     R1, R1, #2 \n"
  63 "    CMP     R1, #6 \n"
  64 "    ADDLS   PC, PC, R1, LSL#2 \n"
  65 "    B       loc_FFDE3920 \n"
  66 "    B       loc_FFDE3984 \n"
  67 "    B       loc_FFDE39E8 \n"
  68 "    B       loc_FFDE39F0 \n"
  69 "    B       loc_FFDE39F0 \n"
  70 "    B       loc_FFDE39F0 \n"
  71 "    B       loc_FFDE39F0 \n"
  72 "    B       loc_FFDE39F8 \n"
  73 
  74 "loc_FFDE3984:\n"
  75 "    MOV     R0, #0 \n"
  76 "    STR     R0, [SP] \n"
  77 
  78 "loc_FFDE398C:\n"
  79 "    LDR     R0, [R4, #0x10] \n"
  80 "    MOV     R1, SP \n"
  81 "    BL      sub_FFC28CE8 /*_GetNumberOfPostedMessages*/ \n"
  82 "    LDR     R0, [SP] \n"
  83 "    CMP     R0, #0 \n"
  84 "    BEQ     loc_FFDE39B8 \n"
  85 "    LDR     R0, [R4, #0x10] \n"
  86 "    MOV     R2, #0 \n"
  87 "    ADD     R1, SP, #4 \n"
  88 "    BL      sub_FFC28AA4 /*_ReceiveMessageQueue*/ \n"
  89 "    B       loc_FFDE398C \n"
  90 
  91 "loc_FFDE39B8:\n"
  92 "    LDR     R0, [R4] \n"
  93 "    CMN     R0, #1 \n"
  94 "    BEQ     loc_FFDE39DC \n"
  95 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  96 "    MVN     R0, #0 \n"
  97 "    STR     R0, [R4] \n"
  98 "    LDR     R0, =0xBF5E4 \n"
  99 "    BL      sub_FFC514A8 \n"
 100 "    BL      sub_FFC4F744 \n"
 101 
 102 "loc_FFDE39DC:\n"
 103 "    LDR     R0, [R4, #0xC] \n"
 104 "    BL      _GiveSemaphore \n"
 105 "    B       loc_FFDE3920 \n"
 106 
 107 "loc_FFDE39E8:\n"
 108 "    BL      sub_FFDE3C08_my \n"  // --> Patched. Old value = 0xFFDE3C08. Open stage
 109 "    B       loc_FFDE3920 \n"
 110 
 111 "loc_FFDE39F0:\n"
 112 "    BL      sub_FFDE3D3C_my \n"  // --> Patched. Old value = 0xFFDE3D3C. Write stage
 113 "    B       loc_FFDE3920 \n"
 114 
 115 "loc_FFDE39F8:\n"
 116 "    BL      sub_FFDE37A4_my \n"  // --> Patched. Old value = 0xFFDE37A4. Close stage
 117 "    B       loc_FFDE3920 \n"
 118 );
 119 }
 120 
 121 /*************************************************************/
 122 //** sub_FFDE3C08_my @ 0xFFDE3C08 - 0xFFDE3C48, length=17
 123 void __attribute__((naked,noinline)) sub_FFDE3C08_my() {
 124 asm volatile (
 125 "    STMFD   SP!, {R4-R8,LR} \n"
 126 "    MOV     R4, R0 \n"
 127 "    ADD     R0, R0, #0x38 \n"
 128 "    SUB     SP, SP, #0x38 \n"
 129 "    BL      sub_FFC514A8 \n"
 130 "    MOV     R1, #0 \n"
 131 "    BL      sub_FFC4F6F4 \n"
 132 "    LDR     R0, [R4, #0xC] \n"
 133 "    BL      sub_FFC0033C \n"
 134 "    LDR     R7, [R4, #8] \n"
 135 "    LDR     R8, =0x1B6 \n"
 136 "    ADD     R6, R4, #0x38 \n"
 137 "    LDR     R5, [R4, #0xC] \n"
 138 //hook start
 139 // "    STMFD SP!, {R4-R12,LR}\n"
 140 "    MOV R0, R4\n"
 141 "    BL filewrite_main_hook\n"
 142 // "    LDMFD SP!, {R4-R12,LR}\n"
 143 //hook end
 144 "    MOV     R0, R6 \n"
 145 "    MOV     R1, R7 \n"
 146 "    MOV     R2, R8 \n"
 147 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 148 "    LDR     PC, =0xFFDE3C4C \n"  // Continue in firmware
 149 );
 150 }
 151 
 152 /*************************************************************/
 153 //** sub_FFDE3D3C_my @ 0xFFDE3D3C - 0xFFDE3E44, length=67
 154 void __attribute__((naked,noinline)) sub_FFDE3D3C_my() {
 155 asm volatile (
 156 "    STMFD   SP!, {R4-R10,LR} \n"
 157 "    MOV     R4, R0 \n"
 158 "    LDR     R0, [R0] \n"
 159 "    CMP     R0, #4 \n"
 160 "    LDREQ   R6, [R4, #0x18] \n"
 161 "    LDREQ   R7, [R4, #0x14] \n"
 162 "    BEQ     loc_FFDE3D88 \n"
 163 "    CMP     R0, #5 \n"
 164 "    LDREQ   R6, [R4, #0x20] \n"
 165 "    LDREQ   R7, [R4, #0x1C] \n"
 166 "    BEQ     loc_FFDE3D88 \n"
 167 "    CMP     R0, #6 \n"
 168 "    LDREQ   R6, [R4, #0x28] \n"
 169 "    LDREQ   R7, [R4, #0x24] \n"
 170 "    BEQ     loc_FFDE3D88 \n"
 171 "    CMP     R0, #7 \n"
 172 "    BNE     loc_FFDE3D9C \n"
 173 "    LDR     R6, [R4, #0x30] \n"
 174 "    LDR     R7, [R4, #0x2C] \n"
 175 
 176 "loc_FFDE3D88:\n"
 177 "    CMP     R6, #0 \n"
 178 "    BNE     loc_FFDE3DAC \n"
 179 
 180 "loc_FFDE3D90:\n"
 181 "    MOV     R1, R4 \n"
 182 "    MOV     R0, #8 \n"
 183 "    B       loc_FFDE3E40 \n"
 184 
 185 "loc_FFDE3D9C:\n"
 186 "    LDR     R1, =0x29F \n"
 187 "    LDR     R0, =0xFFDE3A10 /*'dwFWrite.c'*/ \n"
 188 "    BL      _DebugAssert \n"
 189 "    B       loc_FFDE3D90 \n"
 190 
 191 "loc_FFDE3DAC:\n"
 192 "    LDR     R9, =0x8388 \n"
 193 "    MOV     R5, R6 \n"
 194 
 195 "loc_FFDE3DB4:\n"
 196 "    LDR     R0, [R4, #4] \n"
 197 "    CMP     R5, #0x1000000 \n"
 198 "    MOVLS   R8, R5 \n"
 199 "    MOVHI   R8, #0x1000000 \n"
 200 "    BIC     R1, R0, #0xFF000000 \n"
 201 "    CMP     R1, #0 \n"
 202 "    BICNE   R0, R0, #0xFF000000 \n"
 203 "    RSBNE   R0, R0, #0x1000000 \n"
 204 "    CMPNE   R8, R0 \n"
 205 "    MOVHI   R8, R0 \n"
 206 "    LDR     R0, [R9] \n"
 207 "    MOV     R2, R8 \n"
 208 "    MOV     R1, R7 \n"
 209 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 210 "    LDR     R1, [R4, #4] \n"
 211 "    CMP     R8, R0 \n"
 212 "    ADD     R1, R1, R0 \n"
 213 "    STR     R1, [R4, #4] \n"
 214 "    BEQ     loc_FFDE3E14 \n"
 215 "    CMN     R0, #1 \n"
 216 "    LDRNE   R0, =0x9200015 \n"
 217 "    LDREQ   R0, =0x9200005 \n"
 218 "    STR     R0, [R4, #0x10] \n"
 219 "    B       loc_FFDE3D90 \n"
 220 
 221 "loc_FFDE3E14:\n"
 222 "    SUB     R5, R5, R0 \n"
 223 "    CMP     R5, R6 \n"
 224 "    ADD     R7, R7, R0 \n"
 225 "    LDRCS   R0, =0xFFDE3A10 /*'dwFWrite.c'*/ \n"
 226 "    LDRCS   R1, =0x2CA \n"
 227 "    BLCS    _DebugAssert \n"
 228 "    CMP     R5, #0 \n"
 229 "    BNE     loc_FFDE3DB4 \n"
 230 "    LDR     R0, [R4] \n"
 231 "    MOV     R1, R4 \n"
 232 "    ADD     R0, R0, #1 \n"
 233 
 234 "loc_FFDE3E40:\n"
 235 "    LDMFD   SP!, {R4-R10,LR} \n"
 236 "    B       sub_FFDE36E4 \n"
 237 );
 238 }
 239 
 240 /*************************************************************/
 241 //** sub_FFDE37A4_my @ 0xFFDE37A4 - 0xFFDE37D8, length=14
 242 void __attribute__((naked,noinline)) sub_FFDE37A4_my() {
 243 asm volatile (
 244 "    STMFD   SP!, {R4-R6,LR} \n"
 245 "    LDR     R5, =0x8388 \n"
 246 "    MOV     R4, R0 \n"
 247 "    LDR     R0, [R5] \n"
 248 "    SUB     SP, SP, #0x38 \n"
 249 "    CMN     R0, #1 \n"
 250 "    BEQ     sub_FFDE37EC \n"
 251 "    LDR     R1, [R4, #8] \n"
 252 "    LDR     R6, =0x9200003 \n"
 253 "    TST     R1, #0x8000 \n"
 254 "    BEQ     loc_FFDE37D8 \n"
 255 //mod start
 256 "    LDR R3, =current_write_ignored\n"
 257 "    LDR R3, [R3]\n"
 258 "    CMP R3, #0\n"
 259 "    BNE loc_D\n" // jump over the next block
 260 //mod end
 261 
 262 "    BL      sub_FFC4E7A0 \n"
 263 "    B       sub_FFDE37DC \n"
 264 
 265 "loc_FFDE37D8:\n"
 266 "loc_D:\n"
 267 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 268 "    LDR     PC, =0xFFDE37DC \n"  // Continue in firmware
 269 );
 270 }

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