Subversion Repositories Kolibri OS

Rev

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

Rev 380 Rev 381
Line 217... Line 217...
217
frfl7_1:
217
frfl7_1:
218
    dec    dword [esp+16]
218
    dec    dword [esp+16]
219
frfl8_1:
219
frfl8_1:
220
    mov    edi,[n_sector]
220
    mov    edi,[n_sector]
221
    shl    edi,1            ;find next cluster from FAT
221
    shl    edi,1            ;find next cluster from FAT
222
    add    edi,0x282000
222
    add    edi,FLOPPY_FAT
223
    mov    eax,[edi]
223
    mov    eax,[edi]
224
    and    eax,4095
224
    and    eax,4095
225
    mov    edi,eax
225
    mov    edi,eax
226
    mov    [n_sector],edi
226
    mov    [n_sector],edi
227
    cmp    edi,4095         ;eof  - cluster
227
    cmp    edi,4095         ;eof  - cluster
Line 331... Line 331...
331
 
331
 
332
calculatefatchain_flp:
332
calculatefatchain_flp:
Line 333... Line 333...
333
   pushad
333
   pushad
334
 
334
 
Line 335... Line 335...
335
   mov  esi,FLOPPY_BUFF
335
   mov  esi,FLOPPY_BUFF
336
   mov  edi,0x282000
336
   mov  edi,FLOPPY_FAT
337
 
337
 
338
 fcnew_1:
338
 fcnew_1:
Line 359... Line 359...
359
   add  edi,4
359
   add  edi,4
360
   mov dword [edi],edx
360
   mov dword [edi],edx
361
   add  edi,4
361
   add  edi,4
362
   add  esi,12
362
   add  esi,12
Line 363... Line 363...
363
 
363
 
364
   cmp  edi,0x282000+2856*2   ;2849 clusters
364
   cmp  edi,FLOPPY_FAT+2856*2   ;2849 clusters
Line 365... Line 365...
365
   jnz  fcnew_1
365
   jnz  fcnew_1
366
 
366
 
Line 469... Line 469...
469
 
469
 
470
 
470
 
Line 471... Line 471...
471
restorefatchain_flp:   ; restore fat chain
471
restorefatchain_flp:   ; restore fat chain
472
   pushad
472
   pushad
Line 473... Line 473...
473
 
473
 
474
   mov  esi,0x282000
474
   mov  esi,FLOPPY_FAT
475
   mov  edi,FLOPPY_BUFF
475
   mov  edi,FLOPPY_BUFF
Line 572... Line 572...
572
fifoundd_2_1:
572
fifoundd_2_1:
573
    mov    [edi-11],byte 0xE5    ;mark filename deleted
573
    mov    [edi-11],byte 0xE5    ;mark filename deleted
574
        movzx   edi, word [edi+0xf] ;edi = cluster
574
        movzx   edi, word [edi+0xf] ;edi = cluster
575
frnewd_1:
575
frnewd_1:
576
    shl    edi,1            ;find next cluster from FAT
576
    shl    edi,1            ;find next cluster from FAT
577
    add    edi,0x282000
577
    add    edi,FLOPPY_FAT
578
    mov    eax,[edi]
578
    mov    eax,[edi]
579
    mov    [edi],word 0x0        ;clear fat chain cluster
579
    mov    [edi],word 0x0        ;clear fat chain cluster
580
    and    eax,4095
580
    and    eax,4095
581
    mov    edi,eax
581
    mov    edi,eax
582
    cmp    edi,dword 4095        ;last cluster ?
582
    cmp    edi,dword 4095        ;last cluster ?
Line 781... Line 781...
781
 
781
 
782
frnewds_2:
782
frnewds_2:
783
    add    ebx,1
783
    add    ebx,1
784
    mov    edi,ebx            ; find free cluster in FAT
784
    mov    edi,ebx            ; find free cluster in FAT
785
    shl    edi,1
785
    shl    edi,1
786
    add    edi,0x282000
786
    add    edi,FLOPPY_FAT
787
    mov    eax,[edi]
787
    mov    eax,[edi]
788
    and    eax,4095
788
    and    eax,4095
789
    jnz    frnewds_2
789
    jnz    frnewds_2
790
    mov    [edx],bx         ; save next cluster pos. to prev cl.
790
    mov    [edx],bx         ; save next cluster pos. to prev cl.
Line 935... Line 935...
935
   add ebx,32
935
   add ebx,32
936
   loop adr1_analyze_flp
936
   loop adr1_analyze_flp
Line 937... Line 937...
937
 
937
 
938
    mov eax,[clust_tmp_flp]
938
    mov eax,[clust_tmp_flp]
939
    shl    eax,1            ;find next cluster from FAT
939
    shl    eax,1            ;find next cluster from FAT
940
    add    eax,0x282000
940
    add    eax,FLOPPY_FAT
941
    mov    eax,[eax]
941
    mov    eax,[eax]
942
    and    eax,4095
942
    and    eax,4095
943
    cmp eax,0x0ff8
943
    cmp eax,0x0ff8
944
    jb  adr56_flp
944
    jb  adr56_flp
Line 997... Line 997...
997
   add ebx,32
997
   add ebx,32
998
   loop adr1_analyze1
998
   loop adr1_analyze1
Line 999... Line 999...
999
 
999
 
1000
   mov eax,[clust_tmp_flp]
1000
   mov eax,[clust_tmp_flp]
1001
   shl    eax,1            ;find next cluster from FAT
1001
   shl    eax,1            ;find next cluster from FAT
1002
   add    eax,0x282000
1002
   add    eax,FLOPPY_FAT
1003
   mov    eax,[eax]
1003
   mov    eax,[eax]
1004
   and    eax,4095
1004
   and    eax,4095
1005
   cmp eax,0x0ff8
1005
   cmp eax,0x0ff8
Line 1011... Line 1011...
1011
 
1011
 
Line 1012... Line 1012...
1012
   mov [edi],word 0x0fff
1012
   mov [edi],word 0x0fff
1013
 
1013
 
1014
   mov eax,[clust_tmp_flp]
1014
   mov eax,[clust_tmp_flp]
1015
   shl    eax,1            ;find next cluster from FAT
1015
   shl    eax,1            ;find next cluster from FAT
1016
   add    eax,0x282000
1016
   add    eax,FLOPPY_FAT
Line 1017... Line 1017...
1017
   sub    edi,0x282000
1017
   sub    edi,FLOPPY_FAT
1018
   mov    [eax],di
1018
   mov    [eax],di
1019
 
1019
 
Line 1059... Line 1059...
1059
    mov    ebx,1
1059
    mov    ebx,1
1060
check_new_flp:
1060
check_new_flp:
1061
    add    ebx,1
1061
    add    ebx,1
1062
    mov    edi,ebx            ; find free cluster in FAT
1062
    mov    edi,ebx            ; find free cluster in FAT
1063
    shl    edi,1
1063
    shl    edi,1
1064
    add    edi,0x282000
1064
    add    edi,FLOPPY_FAT
1065
    mov    eax,[edi]
1065
    mov    eax,[edi]
1066
    and    eax,4095
1066
    and    eax,4095
1067
    cmp    eax,0x0
1067
    cmp    eax,0x0
1068
    jnz    check_new_flp
1068
    jnz    check_new_flp
Line 1177... Line 1177...
1177
        mov     ecx, [eax]
1177
        mov     ecx, [eax]
1178
        push    [fd_prev_sector]
1178
        push    [fd_prev_sector]
1179
        pop     [fd_prev_prev_sector]
1179
        pop     [fd_prev_prev_sector]
1180
        add     ecx, 31
1180
        add     ecx, 31
1181
        mov     [fd_prev_sector], ecx
1181
        mov     [fd_prev_sector], ecx
1182
        mov     ecx, [(ecx-31)*2+0x282000]
1182
        mov     ecx, [(ecx-31)*2+FLOPPY_FAT]
1183
        and     ecx, 0xFFF
1183
        and     ecx, 0xFFF
1184
        cmp     ecx, 2849
1184
        cmp     ecx, 2849
1185
        jae     flp_notroot_first.err2
1185
        jae     flp_notroot_first.err2
1186
        mov     [eax], ecx
1186
        mov     [eax], ecx
1187
        pop     ecx
1187
        pop     ecx
Line 1227... Line 1227...
1227
        jmp     flp_notroot_next_sector
1227
        jmp     flp_notroot_next_sector
1228
flp_notroot_extend_dir:
1228
flp_notroot_extend_dir:
1229
; find free cluster in FAT
1229
; find free cluster in FAT
1230
        pusha
1230
        pusha
1231
        xor     eax, eax
1231
        xor     eax, eax
1232
        mov     edi, 0x282000
1232
        mov     edi, FLOPPY_FAT
1233
        mov     ecx, 2849
1233
        mov     ecx, 2849
1234
        repnz   scasw
1234
        repnz   scasw
1235
        jnz     .notfound
1235
        jnz     .notfound
1236
        mov     word [edi-2], 0xFFF     ; mark as last cluster
1236
        mov     word [edi-2], 0xFFF     ; mark as last cluster
1237
        sub     edi, 0x282000
1237
        sub     edi, FLOPPY_FAT
1238
        shr     edi, 1
1238
        shr     edi, 1
1239
        dec     edi
1239
        dec     edi
1240
        mov     eax, [esp+28]
1240
        mov     eax, [esp+28]
1241
        mov     ecx, [eax]
1241
        mov     ecx, [eax]
1242
        mov     [0x282000+ecx*2], di
1242
        mov     [FLOPPY_FAT+ecx*2], di
1243
        mov     [eax], edi
1243
        mov     [eax], edi
1244
        xor     eax, eax
1244
        xor     eax, eax
1245
        mov     edi, FDD_BUFF
1245
        mov     edi, FDD_BUFF
1246
        mov     ecx, 128
1246
        mov     ecx, 128
1247
        rep     stosd
1247
        rep     stosd
Line 1370... Line 1370...
1370
        add     edx, ecx
1370
        add     edx, ecx
1371
        sub     [esp], ecx
1371
        sub     [esp], ecx
1372
        pop     ecx
1372
        pop     ecx
1373
        xor     ebx, ebx
1373
        xor     ebx, ebx
1374
.skip:
1374
.skip:
1375
        movzx   edi, word [edi*2+0x282000]
1375
        movzx   edi, word [edi*2+FLOPPY_FAT]
1376
        jmp     .new
1376
        jmp     .new
1377
.done:
1377
.done:
1378
        mov     ebx, edx
1378
        mov     ebx, edx
1379
        pop     eax edx ecx edi
1379
        pop     eax edx ecx edi
1380
        sub     ebx, edx
1380
        sub     ebx, edx
Line 1466... Line 1466...
1466
        inc     eax
1466
        inc     eax
1467
        dec     byte [esp+262*2+12]
1467
        dec     byte [esp+262*2+12]
1468
        jz      .done
1468
        jz      .done
1469
        jns     @f
1469
        jns     @f
1470
; read next sector from FAT
1470
; read next sector from FAT
1471
        mov     eax, [(eax-31-1)*2+0x282000]
1471
        mov     eax, [(eax-31-1)*2+FLOPPY_FAT]
1472
        and     eax, 0xFFF
1472
        and     eax, 0xFFF
1473
        cmp     eax, 0xFF8
1473
        cmp     eax, 0xFF8
1474
        jae     .done
1474
        jae     .done
1475
        add     eax, 31
1475
        add     eax, 31
1476
        mov     byte [esp+262*2+12], 0
1476
        mov     byte [esp+262*2+12], 0
Line 1498... Line 1498...
1498
        inc     eax
1498
        inc     eax
1499
        dec     byte [esp+262*2+12]
1499
        dec     byte [esp+262*2+12]
1500
        jz      .done
1500
        jz      .done
1501
        jns     @f
1501
        jns     @f
1502
; read next sector from FAT
1502
; read next sector from FAT
1503
        mov     eax, [(eax-31-1)*2+0x282000]
1503
        mov     eax, [(eax-31-1)*2+FLOPPY_FAT]
1504
        and     eax, 0xFFF
1504
        and     eax, 0xFFF
1505
        cmp     eax, 0xFF8
1505
        cmp     eax, 0xFF8
1506
        jae     .done
1506
        jae     .done
1507
        add     eax, 31
1507
        add     eax, 31
1508
        mov     byte [esp+262*2+12], 0
1508
        mov     byte [esp+262*2+12], 0
Line 2193... Line 2193...
2193
        sub     [esp], ecx
2193
        sub     [esp], ecx
2194
        pop     ecx
2194
        pop     ecx
2195
        jz      .done
2195
        jz      .done
2196
.skip:
2196
.skip:
2197
.next_cluster:
2197
.next_cluster:
2198
        movzx   edi, word [edi*2+0x282000]
2198
        movzx   edi, word [edi*2+FLOPPY_FAT]
2199
        sub     esi, 0x200
2199
        sub     esi, 0x200
2200
        jae     @f
2200
        jae     @f
2201
        xor     esi, esi
2201
        xor     esi, esi
2202
@@:
2202
@@:
2203
        sub     dword [esp], 0x200
2203
        sub     dword [esp], 0x200
Line 2223... Line 2223...
2223
        mov     ecx, [edi+28]
2223
        mov     ecx, [edi+28]
2224
        jecxz   .zero_size
2224
        jecxz   .zero_size
2225
@@:
2225
@@:
2226
        sub     ecx, 0x200
2226
        sub     ecx, 0x200
2227
        jbe     @f
2227
        jbe     @f
2228
        mov     eax, [eax*2+0x282000]
2228
        mov     eax, [eax*2+FLOPPY_FAT]
2229
        and     eax, 0xFFF
2229
        and     eax, 0xFFF
2230
        jz      .fat_err
2230
        jz      .fat_err
2231
        cmp     eax, 0xFF8
2231
        cmp     eax, 0xFF8
2232
        jb      @b
2232
        jb      @b
2233
.fat_err:
2233
.fat_err:
Line 2236... Line 2236...
2236
        pop     eax
2236
        pop     eax
2237
        stc
2237
        stc
2238
        ret
2238
        ret
2239
@@:
2239
@@:
2240
        push    eax
2240
        push    eax
2241
        mov     eax, [eax*2+0x282000]
2241
        mov     eax, [eax*2+FLOPPY_FAT]
2242
        and     eax, 0xFFF
2242
        and     eax, 0xFFF
2243
        cmp     eax, 0xFF8
2243
        cmp     eax, 0xFF8
2244
        pop     eax
2244
        pop     eax
2245
        jb      .fat_err
2245
        jb      .fat_err
2246
; set length to full number of sectors
2246
; set length to full number of sectors
2247
        sub     [edi+28], ecx
2247
        sub     [edi+28], ecx
2248
.start_extend:
2248
.start_extend:
2249
        pop     ecx
2249
        pop     ecx
2250
; now do extend
2250
; now do extend
2251
        push    edx esi
2251
        push    edx esi
2252
        mov     esi, 0x282000+2*2       ; start scan from cluster 2
2252
        mov     esi, FLOPPY_FAT+2*2       ; start scan from cluster 2
2253
        mov     edx, 2847               ; number of clusters to scan
2253
        mov     edx, 2847               ; number of clusters to scan
2254
.extend_loop:
2254
.extend_loop:
2255
        cmp     [edi+28], ecx
2255
        cmp     [edi+28], ecx
2256
        jae     .extend_done
2256
        jae     .extend_done
2257
; add new sector
2257
; add new sector
Line 2267... Line 2267...
2267
        pop     eax
2267
        pop     eax
2268
        jnz     .disk_full
2268
        jnz     .disk_full
2269
        mov     word [edi-2], 0xFFF
2269
        mov     word [edi-2], 0xFFF
2270
        mov     esi, edi
2270
        mov     esi, edi
2271
        mov     edx, ecx
2271
        mov     edx, ecx
2272
        sub     edi, 0x282000
2272
        sub     edi, FLOPPY_FAT
2273
        shr     edi, 1
2273
        shr     edi, 1
2274
        dec     edi     ; now edi=new cluster
2274
        dec     edi     ; now edi=new cluster
2275
        test    eax, eax
2275
        test    eax, eax
2276
        jz      .first_cluster
2276
        jz      .first_cluster
2277
        mov     [0x282000+eax*2], di
2277
        mov     [FLOPPY_FAT+eax*2], di
2278
        jmp     @f
2278
        jmp     @f
2279
.first_cluster:
2279
.first_cluster:
2280
        pop     eax             ; eax->direntry
2280
        pop     eax             ; eax->direntry
2281
        push    eax
2281
        push    eax
2282
        mov     [eax+26], di
2282
        mov     [eax+26], di
Line 2427... Line 2427...
2427
.err_next:
2427
.err_next:
2428
        mov     byte [esp], 11
2428
        mov     byte [esp], 11
2429
.next_cluster:
2429
.next_cluster:
2430
        sub     dword [esp+12], 0x200
2430
        sub     dword [esp+12], 0x200
2431
        jbe     .expand_done
2431
        jbe     .expand_done
2432
        movzx   edi, word [0x282000+edi*2]
2432
        movzx   edi, word [FLOPPY_FAT+edi*2]
2433
        jmp     .zero_loop
2433
        jmp     .zero_loop
2434
.expand_done:
2434
.expand_done:
2435
        pop     eax ecx ecx edi edi
2435
        pop     eax ecx ecx edi edi
2436
        jmp     .doret
2436
        jmp     .doret
2437
.truncate:
2437
.truncate:
Line 2442... Line 2442...
2442
        jz      .zero_size
2442
        jz      .zero_size
2443
; find new last sector
2443
; find new last sector
2444
@@:
2444
@@:
2445
        sub     eax, 0x200
2445
        sub     eax, 0x200
2446
        jbe     @f
2446
        jbe     @f
2447
        movzx   ecx, word [0x282000+ecx*2]
2447
        movzx   ecx, word [FLOPPY_FAT+ecx*2]
2448
        jmp     @b
2448
        jmp     @b
2449
@@:
2449
@@:
2450
; we will zero data at the end of last sector - remember it
2450
; we will zero data at the end of last sector - remember it
2451
        push    ecx
2451
        push    ecx
2452
; terminate FAT chain
2452
; terminate FAT chain
2453
        lea     ecx, [0x282000+ecx+ecx]
2453
        lea     ecx, [FLOPPY_FAT+ecx+ecx]
2454
        push    dword [ecx]
2454
        push    dword [ecx]
2455
        mov     word [ecx], 0xFFF
2455
        mov     word [ecx], 0xFFF
2456
        pop     ecx
2456
        pop     ecx
2457
        and     ecx, 0xFFF
2457
        and     ecx, 0xFFF
2458
        jmp     .delete
2458
        jmp     .delete
Line 2462... Line 2462...
2462
.delete:
2462
.delete:
2463
; delete FAT chain starting with ecx
2463
; delete FAT chain starting with ecx
2464
; mark all clusters as free
2464
; mark all clusters as free
2465
        cmp     ecx, 0xFF8
2465
        cmp     ecx, 0xFF8
2466
        jae     .deleted
2466
        jae     .deleted
2467
        lea     ecx, [0x282000+ecx+ecx]
2467
        lea     ecx, [FLOPPY_FAT+ecx+ecx]
2468
        push    dword [ecx]
2468
        push    dword [ecx]
2469
        and     word [ecx], 0
2469
        and     word [ecx], 0
2470
        pop     ecx
2470
        pop     ecx
2471
        and     ecx, 0xFFF
2471
        and     ecx, 0xFFF
2472
        jmp     .delete
2472
        jmp     .delete
Line 2640... Line 2640...
2640
        rep     stosb
2640
        rep     stosb
2641
        pop     eax
2641
        pop     eax
2642
@@:
2642
@@:
2643
        mov     [eax], ecx
2643
        mov     [eax], ecx
2644
        mov     edx, [eax+4]
2644
        mov     edx, [eax+4]
2645
        mov     dx, [edx*2+0x282000]
2645
        mov     dx, [edx*2+FLOPPY_FAT]
2646
        mov     [eax+4], dx     ; high word is already zero
2646
        mov     [eax+4], dx     ; high word is already zero
2647
        popad
2647
        popad
2648
        xor     eax, eax
2648
        xor     eax, eax
2649
        ret
2649
        ret
2650
.eof:
2650
.eof: