Subversion Repositories Kolibri OS

Rev

Rev 131 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 131 Rev 133
Line 47... Line 47...
47
;---------------------------------------------
47
;---------------------------------------------
48
    push   eax ebx ecx
48
    push   eax ebx ecx
49
    call   read_flp_fat
49
    call   read_flp_fat
50
    cmp    [FDC_Status],0
50
    cmp    [FDC_Status],0
51
    jne    fdc_status_error_2
51
    jne    fdc_status_error_2
52
    mov    eax,0x282000
52
    mov    eax,0x282004
53
    xor    edi,edi
53
    xor    edi,edi
54
    mov    ecx,2847   ;1448000/512
54
    mov    ecx,2847   ;1448000/512
55
rdfs1_1:
55
rdfs1_1:
56
    mov    ebx,[eax]
56
    mov    ebx,[eax]
57
    and    ebx,4095
57
    and    ebx,4095
Line 1826... Line 1826...
1826
.doit:
1826
.doit:
1827
        lea     eax, [esp+8]
1827
        lea     eax, [esp+8]
1828
        call    dword [eax+12]  ; flush directory
1828
        call    dword [eax+12]  ; flush directory
1829
        push    ecx
1829
        push    ecx
1830
        push    edi
1830
        push    edi
1831
        add     edi, 26         ; edi points to low word of cluster
-
 
1832
        push    edi
1831
        push    0
1833
        mov     esi, edx
1832
        mov     esi, edx
1834
        jecxz   .done
1833
        jecxz   .done
1835
        mov     ecx, 2849
1834
        mov     ecx, 2849
1836
        mov     edi, 0x282000
1835
        mov     edi, 0x282000
1837
        push    0       ; first cluster
1836
        push    0       ; first cluster
Line 1844... Line 1843...
1844
        dec     edi
1843
        dec     edi
1845
        dec     edi
1844
        dec     edi
1846
        lea     eax, [edi-0x282000]
1845
        lea     eax, [edi-0x282000]
1847
        shr     eax, 1                  ; eax = cluster
1846
        shr     eax, 1                  ; eax = cluster
1848
        mov     word [edi], 0xFFF       ; mark as last cluster
1847
        mov     word [edi], 0xFFF       ; mark as last cluster
-
 
1848
        xchg    edi, [esp+4]
1849
        cmp     dword [esp], 0
1849
        cmp     dword [esp], 0
1850
        jz      .first
1850
        jz      .first
1851
        xchg    edi, [esp+4]
-
 
1852
        stosw
1851
        stosw
1853
        mov     edi, [esp+4]
-
 
1854
        jmp     @f
1852
        jmp     @f
1855
.first:
1853
.first:
1856
        mov     [esp], eax
1854
        mov     [esp], eax
1857
@@:
1855
@@:
-
 
1856
        mov     edi, [esp+4]
1858
        inc     ecx
1857
        inc     ecx
1859
; write data
1858
; write data
1860
        push    ecx edi
1859
        push    ecx edi
1861
        mov     ecx, 512
1860
        mov     ecx, 512
1862
        cmp     dword [esp+20], ecx
1861
        cmp     dword [esp+20], ecx
Line 2131... Line 2130...
2131
        xor     eax, eax
2130
        xor     eax, eax
2132
        jmp     floppy_extend_file.start_extend
2131
        jmp     floppy_extend_file.start_extend
Line 2133... Line 2132...
2133
 
2132
 
2134
; extends file on floppy to given size (new data area is undefined)
2133
; extends file on floppy to given size (new data area is undefined)
2135
; in: edi->direntry, ecx=new size
2134
; in: edi->direntry, ecx=new size
2136
; out: CF=0 => OK, eax destroyed
2135
; out: CF=0 => OK, eax=0
2137
;      CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL)
2136
;      CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL)
2138
floppy_extend_file:
2137
floppy_extend_file:
2139
        push    ecx
2138
        push    ecx
2140
; find the last cluster of file
2139
; find the last cluster of file
Line 2206... Line 2205...
2206
        add     dword [edi+28], 0x200
2205
        add     dword [edi+28], 0x200
2207
        jmp     .extend_loop
2206
        jmp     .extend_loop
2208
.extend_done:
2207
.extend_done:
2209
        mov     [edi+28], ecx
2208
        mov     [edi+28], ecx
2210
        pop     esi edx
2209
        pop     esi edx
2211
        clc
2210
        xor     eax, eax        ; CF=0
2212
        ret
2211
        ret
2213
.disk_full:
2212
.disk_full:
2214
        pop     edi ecx
2213
        pop     edi ecx
2215
        pop     esi edx
2214
        pop     esi edx
2216
        stc
2215
        stc
2217
        push    ERROR_DISK_FULL
2216
        push    ERROR_DISK_FULL
2218
        pop     eax
2217
        pop     eax
2219
        ret
2218
        ret
Line -... Line 2219...
-
 
2219
 
-
 
2220
;----------------------------------------------------------------
-
 
2221
;
-
 
2222
;  fs_FloppySetFileEnd - set end of file on floppy
-
 
2223
;
-
 
2224
;  esi  points to filename
-
 
2225
;  ebx  points to 64-bit number = new file size
-
 
2226
;  ecx  ignored (reserved)
-
 
2227
;  edx  ignored (reserved)
-
 
2228
;
-
 
2229
;  ret eax = 0 ok or other = errormsg
-
 
2230
;
-
 
2231
;--------------------------------------------------------------
-
 
2232
fs_FloppySetFileEnd:
-
 
2233
        call    read_flp_fat
-
 
2234
        cmp     [FDC_Status], 0
-
 
2235
        jnz     ret11
-
 
2236
        cmp     byte [esi], 0
-
 
2237
        jnz     @f
-
 
2238
.access_denied:
-
 
2239
        push    ERROR_ACCESS_DENIED
-
 
2240
        jmp     .ret
-
 
2241
@@:
-
 
2242
        push    edi
-
 
2243
        call    fd_find_lfn
-
 
2244
        jnc     @f
-
 
2245
        pop     edi
-
 
2246
        push    ERROR_FILE_NOT_FOUND
-
 
2247
.ret:
-
 
2248
        pop     eax
-
 
2249
        jmp     .doret
-
 
2250
@@:
-
 
2251
; must not be directory
-
 
2252
        test    byte [edi+11], 10h
-
 
2253
        jz      @f
-
 
2254
        pop     edi
-
 
2255
        jmp     .access_denied
-
 
2256
@@:
-
 
2257
; file size must not exceed 4 Gb
-
 
2258
        cmp     dword [ebx+4], 0
-
 
2259
        jz      @f
-
 
2260
        pop     edi
-
 
2261
        push    ERROR_END_OF_FILE
-
 
2262
        jmp     .ret
-
 
2263
@@:
-
 
2264
        push    eax
-
 
2265
; set file modification date/time to current
-
 
2266
        call    fat_update_datetime
-
 
2267
        mov     eax, [ebx]
-
 
2268
        cmp     eax, [edi+28]
-
 
2269
        jb      .truncate
-
 
2270
        ja      .expand
-
 
2271
        pop     eax
-
 
2272
        pushad
-
 
2273
        call    save_chs_sector
-
 
2274
        popad
-
 
2275
        pop     edi
-
 
2276
        xor     eax, eax
-
 
2277
        cmp     [FDC_Status], 0
-
 
2278
        jz      @f
-
 
2279
        mov     al, 11
-
 
2280
@@:
-
 
2281
.doret:
-
 
2282
        mov     [fdc_irq_func], fdc_null
-
 
2283
        ret
-
 
2284
.expand:
-
 
2285
        push    ecx
-
 
2286
        push    dword [edi+28]  ; save old size
-
 
2287
        mov     ecx, eax
-
 
2288
        call    floppy_extend_file
-
 
2289
        push    eax     ; return code
-
 
2290
        jnc     .expand_ok
-
 
2291
        cmp     al, ERROR_DISK_FULL
-
 
2292
        jz      .disk_full
-
 
2293
        pop     eax ecx ecx edi edi
-
 
2294
        jmp     .doret
-
 
2295
.device_err:
-
 
2296
        pop     eax
-
 
2297
.device_err2:
-
 
2298
        pop     ecx ecx eax edi
-
 
2299
        push    11
-
 
2300
        jmp     .ret
-
 
2301
.disk_full:
-
 
2302
.expand_ok:
-
 
2303
; save directory & FAT
-
 
2304
        mov     eax, [edi+28]
-
 
2305
        xchg    eax, [esp+12]
-
 
2306
        movzx   edi, word [edi+26]
-
 
2307
        pusha
-
 
2308
        call    save_chs_sector
-
 
2309
        popa
-
 
2310
        cmp     [FDC_Status], 0
-
 
2311
        jnz     .device_err
-
 
2312
        call    save_flp_fat
-
 
2313
        cmp     [FDC_Status], 0
-
 
2314
        jnz     .device_err
-
 
2315
        call    SetUserInterrupts
-
 
2316
; now zero new data
-
 
2317
; edi = current cluster, [esp+12]=new size, [esp+4]=old size, [esp]=return code
-
 
2318
.zero_loop:
-
 
2319
        sub     dword [esp+4], 0x200
-
 
2320
        jae     .next_cluster
-
 
2321
        cmp     dword [esp+4], -0x200
-
 
2322
        jz      .noread
-
 
2323
        lea     eax, [edi+31]
-
 
2324
        pusha
-
 
2325
        call    read_chs_sector
-
 
2326
        popa
-
 
2327
        cmp     [FDC_Status], 0
-
 
2328
        jnz     .err_next
-
 
2329
.noread:
-
 
2330
        mov     ecx, [esp+4]
-
 
2331
        neg     ecx
-
 
2332
        push    edi
-
 
2333
        mov     edi, 0xD000+0x200
-
 
2334
        add     edi, [esp+8]
-
 
2335
        xor     eax, eax
-
 
2336
        mov     [esp+8], eax
-
 
2337
        rep     stosb
-
 
2338
        pop     edi
-
 
2339
        lea     eax, [edi+31]
-
 
2340
        pusha
-
 
2341
        call    save_chs_sector
-
 
2342
        popa
-
 
2343
        cmp     [FDC_Status], 0
-
 
2344
        jz      .next_cluster
-
 
2345
.err_next:
-
 
2346
        mov     byte [esp], 11
-
 
2347
.next_cluster:
-
 
2348
        sub     dword [esp+12], 0x200
-
 
2349
        jbe     .expand_done
-
 
2350
        movzx   edi, word [0x282000+edi*2]
-
 
2351
        jmp     .zero_loop
-
 
2352
.expand_done:
-
 
2353
        pop     eax ecx ecx edi edi
-
 
2354
        jmp     .doret
-
 
2355
.truncate:
-
 
2356
        mov     [edi+28], eax
-
 
2357
        push    ecx
-
 
2358
        movzx   ecx, word [edi+26]
-
 
2359
        test    eax, eax
-
 
2360
        jz      .zero_size
-
 
2361
; find new last sector
-
 
2362
@@:
-
 
2363
        sub     eax, 0x200
-
 
2364
        jbe     @f
-
 
2365
        movzx   ecx, word [0x282000+ecx*2]
-
 
2366
        jmp     @b
-
 
2367
@@:
-
 
2368
; we will zero data at the end of last sector - remember it
-
 
2369
        push    ecx
-
 
2370
; terminate FAT chain
-
 
2371
        lea     ecx, [0x282000+ecx+ecx]
-
 
2372
        push    dword [ecx]
-
 
2373
        mov     word [ecx], 0xFFF
-
 
2374
        pop     ecx
-
 
2375
        and     ecx, 0xFFF
-
 
2376
        jmp     .delete
-
 
2377
.zero_size:
-
 
2378
        and     word [edi+26], 0
-
 
2379
        push    0
-
 
2380
.delete:
-
 
2381
; delete FAT chain starting with ecx
-
 
2382
; mark all clusters as free
-
 
2383
        cmp     ecx, 0xFF8
-
 
2384
        jae     .deleted
-
 
2385
        lea     ecx, [0x282000+ecx+ecx]
-
 
2386
        push    dword [ecx]
-
 
2387
        and     word [ecx], 0
-
 
2388
        pop     ecx
-
 
2389
        and     ecx, 0xFFF
-
 
2390
        jmp     .delete
-
 
2391
.deleted:
-
 
2392
        mov     edi, [edi+28]
-
 
2393
; save directory & FAT
-
 
2394
        mov     eax, [esp+8]
-
 
2395
        pusha
-
 
2396
        call    save_chs_sector
-
 
2397
        popa
-
 
2398
        cmp     [FDC_Status], 0
-
 
2399
        jnz     .device_err2
-
 
2400
        call    save_flp_fat
-
 
2401
        cmp     [FDC_Status], 0
-
 
2402
        jnz     .device_err2
-
 
2403
; zero last sector, ignore errors
-
 
2404
        pop     eax
-
 
2405
        add     eax, 31
-
 
2406
        and     edi, 0x1FF
-
 
2407
        jz      .truncate_done
-
 
2408
        call    SetUserInterrupts
-
 
2409
        pusha
-
 
2410
        call    read_chs_sector
-
 
2411
        popa
-
 
2412
        add     edi, 0xD000
-
 
2413
        mov     ecx, 0xD000+0x200
-
 
2414
        sub     ecx, edi
-
 
2415
        push    eax
-
 
2416
        xor     eax, eax
-
 
2417
        rep     stosb
-
 
2418
        pop     eax
-
 
2419
        pusha
-
 
2420
        call    save_chs_sector
-
 
2421
        popa
-
 
2422
.truncate_done:
-
 
2423
        pop     ecx eax edi
-
 
2424
        xor     eax, eax
-
 
2425
        jmp     .doret
2220
 
2426
 
2221
fs_FloppyGetFileInfo:
2427
fs_FloppyGetFileInfo:
2222
        call    read_flp_fat
2428
        call    read_flp_fat
2223
        cmp     [FDC_Status], 0
2429
        cmp     [FDC_Status], 0
2224
        jnz     ret11
2430
        jnz     ret11