root/platform/d10/sub/100a/filewrite.c

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

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFA26268_my
  3. sub_FFA263B4_my
  4. sub_FFA264B0_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 
   4 // ifdef allows easy building with/without filewrite support for testing
   5 #ifdef CAM_HAS_FILEWRITETASK_HOOK
   6 typedef struct {
   7     unsigned int address;
   8     unsigned int length;
   9 } cam_ptp_data_chunk; //camera specific structure
  10 
  11 #define MAX_CHUNKS_FOR_JPEG 3 //model specific
  12 /*
  13  * fwt_data_struct: defined here as it's camera dependent
  14  * unneeded members are designated with unkn
  15  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  16  * pdc is always required
  17  * name is not currently used
  18  */
  19 typedef struct
  20 {
  21     int unkn1, unkn2, unkn3, unkn4, unkn5;
  22     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_JPEG];
  23     char name[32];
  24 } fwt_data_struct;
  25 
  26 #include "../../../generic/filewrite.c"
  27 
  28 void __attribute__((naked,noinline)) filewritetask() { // FFA25FB4 "FileWriteTask"
  29 asm volatile (
  30 "                STMFD   SP!, {R1-R5,LR}\n"
  31 "                LDR     R4, =0x9314\n"
  32 "loc_FFA25FBC:\n"
  33 // jumptable FFA25FFC default entry
  34 "                LDR     R0, [R4,#0x10]\n"
  35 "                MOV     R2, #0\n"
  36 "                ADD     R1, SP, #8\n"
  37 "                BL      sub_FF826C30\n" // KerQueue.c 0
  38 "                CMP     R0, #0\n"
  39 "                BNE     loc_FFA25FEC\n"
  40 "                LDR     R0, [SP,#8]\n"
  41 "                LDR     R1, [R0]\n"
  42 "                CMP     R1, #1\n"
  43 "                BNE     loc_FFA25FF4\n"
  44 "                LDR     R0, [R4,#8]\n"
  45 "                BL      sub_FF82711C\n" // GiveSemaphore
  46 "loc_FFA25FEC:\n"
  47 "                BL      _ExitTask\n"
  48 "                LDMFD   SP!, {R1-R5,PC}\n"
  49 "loc_FFA25FF4:\n"
  50 "                SUB     R1, R1, #2\n"
  51 "                CMP     R1, #5\n"
  52 "                ADDLS   PC, PC, R1,LSL#2\n"
  53 "                B       loc_FFA25FBC\n"
  54 "                B       loc_FFA2601C\n"
  55 "                B       loc_FFA26080\n"
  56 "                B       loc_FFA26088\n"
  57 "                B       loc_FFA26088\n"
  58 "                B       loc_FFA26088\n"
  59 "                B       loc_FFA26090\n"
  60 "loc_FFA2601C:\n"
  61 // jumptable FFA25FFC entry 0
  62 "                MOV     R0, #0\n"
  63 "                STR     R0, [SP]\n"
  64 "loc_FFA26024:\n"
  65 "                LDR     R0, [R4,#0x10]\n"
  66 "                MOV     R1, SP\n"
  67 "                BL      sub_FF826E74\n" // KerQueue.c 0
  68 "                LDR     R0, [SP]\n"
  69 "                CMP     R0, #0\n"
  70 "                BEQ     loc_FFA26050\n"
  71 "                LDR     R0, [R4,#0x10]\n"
  72 "                MOV     R2, #0\n"
  73 "                ADD     R1, SP, #4\n"
  74 "                BL      sub_FF826C30\n" // KerQueue.c 0
  75 "                B       loc_FFA26024\n"
  76 "loc_FFA26050:\n"
  77 "                LDR     R0, [R4]\n"
  78 "                CMN     R0, #1\n"
  79 "                BEQ     loc_FFA26074\n"
  80 //"                BL      _Close\n"
  81 "                BL      fwt_close\n" //+
  82 "                MVN     R0, #0\n"
  83 "                STR     R0, [R4]\n"
  84 "                LDR     R0, =0xCD788\n"
  85 "                BL      sub_FF855E18\n" // Mounter.c 0
  86 "                BL      sub_FF8543A4\n" // FileSem.c 136
  87 "loc_FFA26074:\n"
  88 "                LDR     R0, [R4,#0xC]\n"
  89 "                BL      sub_FF82711C\n" // GiveSemaphore
  90 "                B       loc_FFA25FBC\n"
  91 "loc_FFA26080:\n"
  92 // jumptable FFA25FFC entry 1
  93 "                BL      sub_FFA26268_my\n" //->
  94 "                B       loc_FFA25FBC\n"
  95 "loc_FFA26088:\n"
  96 // jumptable FFA25FFC entries 2-4
  97 "                BL      sub_FFA263B4_my\n" // dwFWrite.c 4 ->
  98 "                B       loc_FFA25FBC\n"
  99 "loc_FFA26090:\n"
 100 // jumptable FFA25FFC entry 5
 101 "                BL      sub_FFA264B0_my\n"
 102 "                B       loc_FFA25FBC\n"
 103 
 104     );
 105 }
 106 
 107 void __attribute__((naked,noinline)) sub_FFA26268_my( ) {
 108 asm volatile (
 109 "                STMFD   SP!, {R4-R8,LR}\n"
 110 "                MOV     R4, R0\n"
 111 "                ADD     R0, R0, #0x2C\n"
 112 "                SUB     SP, SP, #0x38\n"
 113 "                BL      sub_FF855E18\n" // Mounter.c 0
 114 "                MOV     R1, #0\n"
 115 "                BL      sub_FF854354\n"
 116 "                LDR     R0, [R4,#0xC]\n"
 117 "                BL      sub_FF8527FC\n"
 118 "                LDR     R7, [R4,#8]\n"
 119 "                LDR     R8, =0x1B6\n"
 120 "                ADD     R6, R4, #0x2C\n"
 121 "                LDR     R5, [R4,#0xC]\n"
 122 //hook start
 123       "STMFD SP!, {R4-R12,LR}\n"
 124       "MOV R0, R4\n"
 125       "BL filewrite_main_hook\n"
 126       "LDMFD SP!, {R4-R12,LR}\n"
 127 //hook end
 128 
 129 "                MOV     R0, R6\n"
 130 "                MOV     R1, R7\n"
 131 "                MOV     R2, R8\n"
 132 //"                BL      _Open\n"
 133 "                BL      fwt_open\n"
 134 "                LDR     PC,=0xFFA262AC\n" // jump back to ROM
 135 /*
 136 "                CMN     R0, #1\n"
 137 "                BNE     loc_FFA2630C\n"
 138 "                MOV     R0, R6\n"
 139 "                BL      sub_FF824190\n"
 140 "                MOV     R2, #0xF\n"
 141 "                MOV     R1, R6\n"
 142 "                MOV     R0, SP\n"
 143 "                BL      sub_FFACBD60\n"
 144 "                LDR     R0, =0x41FF\n"
 145 "                MOV     R1, #0\n"
 146 "                STRB    R1, [SP,#0xF]\n"
 147 "                STR     R0, [SP,#0x20]\n"
 148 "                MOV     R0, #0x10\n"
 149 "                ADD     R2, SP, #0x24\n"
 150 "                STMIA   R2, {R0,R1,R5}\n"
 151 "                ADD     R1, SP, #0x20\n"
 152 "                MOV     R0, SP\n"
 153 "                STR     R5, [SP,#0x30]\n"
 154 "                STR     R5, [SP,#0x34]\n"
 155 "                BL      sub_FF853C68\n"
 156 "                MOV     R2, R8\n"
 157 "                MOV     R1, R7\n"
 158 "                MOV     R0, R6\n"
 159 "                BL      _Open\n"
 160 "loc_FFA2630C:\n"
 161 "                LDR     R5, =0x9314\n"
 162 "                CMN     R0, #1\n"
 163 "                STR     R0, [R5]\n"
 164 "                BNE     loc_FFA26354\n"
 165 "                LDR     R0, [R5,#0x18]\n"
 166 "                CMP     R0, #0\n"
 167 "                BLXNE   R0\n"
 168 "                ADD     R0, R4, #0x2C\n"
 169 "                BL      sub_FF855E18\n" // Mounter.c 0
 170 "                BL      sub_FF8543A4\n" // FileSem.c 136
 171 "                LDR     R1, [R5,#0x14]\n"
 172 "                CMP     R1, #0\n"
 173 "                ADDNE   SP, SP, #0x38\n"
 174 "                LDMNEFD SP!, {R4-R8,LR}\n"
 175 "                LDRNE   R0, =0x9200001\n"
 176 "                BXNE    R1\n"
 177 "loc_FFA2634C:\n"
 178 "                ADD     SP, SP, #0x38\n"
 179 "                LDMFD   SP!, {R4-R8,PC}\n"
 180 "loc_FFA26354:\n"
 181 "                LDR     R0, =0xCD788\n"
 182 "                MOV     R2, #0x20\n"
 183 "                ADD     R1, R4, #0x2C\n"
 184 "                BL      sub_FFACBEC8\n"
 185 "                MOV     R1, R4\n"
 186 "                MOV     R0, #4\n"
 187 "                BL      sub_FFA25F0C\n"
 188 "                B       loc_FFA2634C\n"
 189 */
 190     );
 191 }
 192 
 193 void __attribute__((naked,noinline)) sub_FFA263B4_my( ) {
 194 asm volatile (
 195 "                STMFD   SP!, {R4-R10,LR}\n"
 196 "                MOV     R4, R0\n"
 197 "                LDR     R0, [R0]\n"
 198 "                CMP     R0, #4\n"
 199 "                LDREQ   R6, [R4,#0x18]\n"
 200 "                LDREQ   R7, [R4,#0x14]\n"
 201 "                BEQ     loc_FFA263F0\n"
 202 "                CMP     R0, #5\n"
 203 "                LDREQ   R6, [R4,#0x20]\n"
 204 "                LDREQ   R7, [R4,#0x1C]\n"
 205 "                BEQ     loc_FFA263F0\n"
 206 "                CMP     R0, #6\n"
 207 "                BNE     loc_FFA26404\n"
 208 "                LDR     R6, [R4,#0x28]\n"
 209 "                LDR     R7, [R4,#0x24]\n"
 210 "loc_FFA263F0:\n"
 211 "                CMP     R6, #0\n"
 212 "                BNE     loc_FFA26414\n"
 213 "loc_FFA263F8:\n"
 214 "                MOV     R1, R4\n"
 215 "                MOV     R0, #7\n"
 216 "                B       loc_FFA264A8\n"
 217 "loc_FFA26404:\n"
 218 "                LDR     R1, =0x20D\n"
 219 "                LDR     R0, =0xFFA26394\n" // "dwFWrite.c"
 220 "                BL      sub_FF81B284\n" // DebugAssert
 221 "                B       loc_FFA263F8\n"
 222 "loc_FFA26414:\n"
 223 "                LDR     R9, =0x9314\n"
 224 "                MOV     R5, R6\n"
 225 "loc_FFA2641C:\n"
 226 "                LDR     R0, [R4,#4]\n"
 227 "                CMP     R5, #0x1000000\n"
 228 "                MOVLS   R8, R5\n"
 229 "                MOVHI   R8, #0x1000000\n"
 230 "                BIC     R1, R0, #0xFF000000\n"
 231 "                CMP     R1, #0\n"
 232 "                BICNE   R0, R0, #0xFF000000\n"
 233 "                RSBNE   R0, R0, #0x1000000\n"
 234 "                CMPNE   R8, R0\n"
 235 "                MOVHI   R8, R0\n"
 236 "                LDR     R0, [R9]\n"
 237 "                MOV     R2, R8\n"
 238 "                MOV     R1, R7\n"
 239 //"                BL      _Write\n"
 240 "                BL      fwt_write\n"
 241 "                LDR     R1, [R4,#4]\n"
 242 "                CMP     R8, R0\n"
 243 "                ADD     R1, R1, R0\n"
 244 "                STR     R1, [R4,#4]\n"
 245 "                BEQ     loc_FFA2647C\n"
 246 "                LDR     R0, =0x10B1\n"
 247 "                BL      sub_FF877A6C\n" // IsControlEventActive
 248 "                LDR     R1, =0x9200005\n"
 249 "                STR     R1, [R4,#0x10]\n"
 250 "                B       loc_FFA263F8\n"
 251 "loc_FFA2647C:\n"
 252 "                SUB     R5, R5, R0\n"
 253 "                CMP     R5, R6\n"
 254 "                ADD     R7, R7, R0\n"
 255 "                LDRCS   R0, =0xFFA26394\n" // "dwFWrite.c"
 256 "                MOVCS   R1, #0x23C\n"
 257 "                BLCS    sub_FF81B284\n" // DebugAssert
 258 "                CMP     R5, #0\n"
 259 "                BNE     loc_FFA2641C\n"
 260 "                LDR     R0, [R4]\n"
 261 "                MOV     R1, R4\n"
 262 "                ADD     R0, R0, #1\n"
 263 "loc_FFA264A8:\n"
 264 "                LDMFD   SP!, {R4-R10,LR}\n"
 265 "                B       sub_FFA25F0C\n"
 266     );
 267 }
 268 
 269 void __attribute__((naked,noinline)) sub_FFA264B0_my( ) {
 270 asm volatile (
 271 "                STMFD   SP!, {R4,R5,LR}\n"
 272 "                LDR     R5, =0x9314\n"
 273 "                MOV     R4, R0\n"
 274 "                LDR     R0, [R5]\n"
 275 "                SUB     SP, SP, #0x1C\n"
 276 "                CMN     R0, #1\n"
 277 "                BEQ     loc_FFA264E4\n"
 278 //"                BL      _Close\n"
 279 "                BL      fwt_close\n"
 280 "                CMP     R0, #0\n"
 281 "                LDRNE   R0, =0x9200003\n"
 282 "                STRNE   R0, [R4,#0x10]\n"
 283 "                MVN     R0, #0\n"
 284 "                STR     R0, [R5]\n"
 285 "loc_FFA264E4:\n"
 286 "                LDR     PC, =0xFFA264E4\n" // jump back to firmware
 287 /*
 288 "                LDR     R0, [R4,#0x10]\n"
 289 "                TST     R0, #1\n"
 290 "                BNE     loc_FFA2652C\n"
 291 "                LDR     R0, =0x81FF\n"
 292 "                ADD     R1, SP, #4\n"
 293 "                STR     R0, [SP,#4]\n"
 294 "                MOV     R0, #0x20\n"
 295 "                STR     R0, [SP,#8]\n"
 296 "                LDR     R0, [R4,#4]\n"
 297 "                STR     R0, [SP,#0xC]\n"
 298 "                LDR     R0, [R4,#0xC]\n"
 299 "                STR     R0, [SP,#0x10]\n"
 300 "                LDR     R0, [R4,#0xC]\n"
 301 "                STR     R0, [SP,#0x14]\n"
 302 "                LDR     R0, [R4,#0xC]\n"
 303 "                STR     R0, [SP,#0x18]\n"
 304 "                ADD     R0, R4, #0x2C\n"
 305 "                BL      sub_FF853C68\n"
 306 "loc_FFA2652C:\n"
 307 "                LDR     R0, [R5,#0x18]\n"
 308 "                CMP     R0, #0\n"
 309 "                BLXNE   R0\n"
 310 "                ADD     R0, R4, #0x2C\n"
 311 "                BL      sub_FF855E18\n" // Mounter.c 0
 312 "                BL      sub_FF8543A4\n" // FileSem.c 136
 313 "                LDR     R1, [R5,#0x14]\n"
 314 "                CMP     R1, #0\n"
 315 "                LDRNE   R0, [R4,#0x10]\n"
 316 "                BLXNE   R1\n"
 317 "                ADD     SP, SP, #0x1C\n"
 318 "                LDMFD   SP!, {R4,R5,PC}\n"
 319 */
 320     );
 321 }
 322 #endif
 323 

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