Subversion Repositories Kolibri OS

Rev

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

Rev 1379 Rev 1410
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 1379 $
8
$Revision: 1410 $
-
 
9
 
9
 
10
 
10
 
11
;*************************************************************
11
;*************************************************************
12
;* 13.02.2010 Find all partition and check supported FS
12
;* 12.07.2007 Check all 4 entry of MBR and EMBR
13
;* 12.07.2007 Check all 4 entry of MBR and EMBR
13
;* 29.04.2006 Elimination of hangup after the
14
;* 29.04.2006 Elimination of hangup after the
Line 24... Line 25...
24
; Mario79
25
; Mario79
25
; START place
26
; START place
26
;******************************************************
27
;******************************************************
27
PARTITION_START      dd 0x3f
28
PARTITION_START      dd 0x3f
28
PARTITION_END        dd 0
29
PARTITION_END        dd 0
29
fs_type              db 0       ; 0=none, 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
30
fs_type              db 0       ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
30
align 4
31
align 4
Line 31... Line 32...
31
 
32
 
32
fs_dependent_data_start:
33
fs_dependent_data_start:
Line 148... Line 149...
148
; |-> PARTITION3
149
; |-> PARTITION3
149
; |-> PARTITION4
150
; |-> PARTITION4
Line 150... Line 151...
150
 
151
 
151
set_PARTITION_variables:
152
set_PARTITION_variables:
152
set_FAT32_variables:        ;deprecated
153
set_FAT32_variables:        ;deprecated
153
    mov   [problem_partition],0
154
    and   [problem_partition], 0
154
    call  reserve_hd1
155
    call  reserve_hd1
Line 155... Line 156...
155
    call  reserve_hd_channel
156
    call  reserve_hd_channel
Line 156... Line 157...
156
 
157
 
157
    pushad
158
    pushad
Line 158... Line 159...
158
 
159
 
159
    cmp   dword [hdpos],0
160
    cmp   dword [hdpos],0
160
    je    problem_hd
161
    je    problem_hd
161
 
162
 
Line 162... Line 163...
162
    xor   ecx,ecx               ; partition count
163
    xor   ecx,ecx               ; partition count
163
    or    edx,-1                ; flag for partition
164
    ;or    edx,-1                ; flag for partition
Line 176... Line 177...
176
    cmp  [hd_error],0
177
    cmp  [hd_error],0
177
    jne  problem_hd
178
    jne  problem_hd
Line 178... Line 179...
178
 
179
 
179
    cmp   word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
180
    cmp   word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
-
 
181
    jnz   end_partition_chain
180
    jnz   end_partition_chain
182
    push  eax                      ; push only one time
181
    cmp   dword [ebx+0x1be+0xc],0 ; skip over empty partition
183
    cmp   dword [ebx+0x1be+0xc],0 ; skip over empty partition
182
    jnz    test_primary_partition_0
184
    jnz    test_primary_partition_0
183
    cmp   dword [ebx+0x1be+0xc+16],0
185
    cmp   dword [ebx+0x1be+0xc+16],0
184
    jnz    test_primary_partition_1
186
    jnz    test_primary_partition_1
185
    cmp   dword [ebx+0x1be+0xc+16+16],0
187
    cmp   dword [ebx+0x1be+0xc+16+16],0
186
    jnz    test_primary_partition_2
188
    jnz    test_primary_partition_2
187
    cmp   dword [ebx+0x1be+0xc+16+16+16],0
189
    cmp   dword [ebx+0x1be+0xc+16+16+16],0
-
 
190
    jnz    test_primary_partition_3
188
    jnz    test_primary_partition_3
191
    pop   eax
Line 189... Line 192...
189
    jmp   end_partition_chain
192
    jmp   end_partition_chain
190
 
-
 
191
test_primary_partition_0:
193
 
192
    push  eax
194
test_primary_partition_0:
193
    mov   al,[ebx+0x1be+4]      ; get primary partition type
-
 
194
    call  scan_partition_types
195
    mov   al,[ebx+0x1be+4]      ; get primary partition type
Line 195... Line 196...
195
    pop   eax
196
    call  scan_partition_types
196
    jnz   test_primary_partition_1      ; no. skip over
197
    jnz   test_primary_partition_1      ; no. skip over
197
 
198
 
Line -... Line 199...
-
 
199
    inc   ecx
198
    inc   ecx
200
    cmp   ecx,[known_part]       ; is it wanted partition?
199
    cmp   ecx,[known_part]       ; is it wanted partition?
201
    jnz   test_primary_partition_1      ; no
-
 
202
 
200
    jnz   test_primary_partition_1      ; no
203
        pop     eax
201
 
204
        ;mov     edx, eax                ; start sector
-
 
205
        add     eax, [ebx+0x1be+8]      ; add relative start
202
        mov     edx, eax                ; start sector
206
        ;mov     [PARTITON_START],edx
203
        add     edx, [ebx+0x1be+8]      ; add relative start
207
        ;push    edx
204
        push    edx
208
        mov     edx, [ebx+0x1be+12]     ; length
205
        add     edx, [ebx+0x1be+12]     ; add length
209
        ;add     edx, eax                ; add length
206
        dec     edx                     ; PARTITION_END is inclusive
210
        ;dec     edx                     ; PARTITION_END is inclusive
207
        mov     [PARTITION_END], edx    ; note that this can be changed
211
        ;mov     [PARTITION_END], edx    ; note that this can be changed
-
 
212
                                        ; when file system data will be available
Line 208... Line 213...
208
                                        ; when file system data will be available
213
        mov     cl, [ebx+0x1be+4]       ; fs_type
209
        mov     dl, [ebx+0x1be+4]
-
 
210
        mov     [fs_type], dl           ; save for FS recognizer (separate FAT vs NTFS)
214
        ;mov     [fs_type], dl           ; save for FS recognizer (separate FAT vs NTFS)
211
        pop     edx
215
        ;pop     edx
212
 
-
 
213
test_primary_partition_1:
216
        jmp     hd_and_partition_ok
Line 214... Line 217...
214
    push  eax
217
 
215
    mov   al,[ebx+0x1be+4+16]      ; get primary partition type
218
test_primary_partition_1:
216
    call  scan_partition_types
219
    mov   al,[ebx+0x1be+4+16]      ; get primary partition type
Line -... Line 220...
-
 
220
    call  scan_partition_types
-
 
221
    jnz   test_primary_partition_2        ; no. skip over
-
 
222
 
-
 
223
    inc   ecx
-
 
224
    cmp   ecx,[known_part]       ; is it wanted partition?
-
 
225
    jnz   test_primary_partition_2        ; no
217
    pop   eax
226
 
218
    jnz   test_primary_partition_2        ; no. skip over
227
        pop     eax
219
 
228
        add     eax, [ebx+0x1be+8+16]
220
    inc   ecx
229
        mov     edx, [ebx+0x1be+12+16]
221
    cmp   ecx,[known_part]       ; is it wanted partition?
230
        mov     cl, [ebx+0x1be+4+16]
222
    jnz   test_primary_partition_2        ; no
231
        jmp     hd_and_partition_ok
223
 
232
 
224
        mov     edx, eax
233
        ;mov     edx, eax
225
        add     edx, [ebx+0x1be+8+16]
234
        ;add     edx, [ebx+0x1be+8+16]
Line 226... Line 235...
226
        push    edx
235
        ;push    edx
227
        add     edx, [ebx+0x1be+12+16]
-
 
228
        dec     edx
236
        ;add     edx, [ebx+0x1be+12+16]
229
        mov     [PARTITION_END], edx
237
        ;dec     edx
230
        mov     dl, [ebx+0x1be+4+16]
-
 
231
        mov     [fs_type], dl
238
        ;mov     [PARTITION_END], edx
Line 232... Line 239...
232
        pop     edx
239
        ;mov     al, [ebx+0x1be+4+16]
233
 
240
        ;mov     [fs_type], dl
234
test_primary_partition_2:
241
        ;pop     edx
Line -... Line 242...
-
 
242
 
-
 
243
test_primary_partition_2:
-
 
244
    mov   al,[ebx+0x1be+4+16+16]      ; get primary partition type
-
 
245
    call  scan_partition_types
-
 
246
    jnz   test_primary_partition_3        ; no. skip over
235
    push  eax
247
 
236
    mov   al,[ebx+0x1be+4+16+16]      ; get primary partition type
248
    inc   ecx
237
    call  scan_partition_types
249
    cmp   ecx,[known_part]       ; is it wanted partition?
238
    pop   eax
250
    jnz   test_primary_partition_3        ; no
239
    jnz   test_primary_partition_3        ; no. skip over
251
 
240
 
252
        pop     eax
241
    inc   ecx
253
        add     eax, [ebx+0x1be+8+16+16]
242
    cmp   ecx,[known_part]       ; is it wanted partition?
254
        mov     edx, [ebx+0x1be+12+16+16]
243
    jnz   test_primary_partition_3        ; no
255
        mov     cl, [ebx+0x1be+4+16+16]
Line 244... Line 256...
244
 
256
        jmp     hd_and_partition_ok
245
        mov     edx, eax
-
 
246
        add     edx, [ebx+0x1be+8+16+16]
257
        ;mov     edx, eax
247
        push    edx
258
        ;add     edx, [ebx+0x1be+8+16+16]
248
        add     edx, [ebx+0x1be+12+16+16]
-
 
249
        dec     edx
259
        ;push    edx
Line 250... Line 260...
250
        mov     [PARTITION_END], edx
260
        ;add     edx, [ebx+0x1be+12+16+16]
251
        mov     dl, [ebx+0x1be+4+16+16]
261
        ;dec     edx
252
        mov     [fs_type], dl
262
        ;mov     [PARTITION_END], edx
Line -... Line 263...
-
 
263
        ;mov     al, [ebx+0x1be+4+16+16]
-
 
264
        ;mov     [fs_type], dl
-
 
265
        ;pop     edx
-
 
266
 
-
 
267
test_primary_partition_3:
-
 
268
    mov   al,[ebx+0x1be+4+16+16+16]      ; get primary partition type
253
        pop     edx
269
    call  scan_partition_types
254
 
270
    jnz   test_ext_partition_0        ; no. skip over
255
test_primary_partition_3:
271
 
256
    push  eax
272
    inc   ecx
257
    mov   al,[ebx+0x1be+4+16+16+16]      ; get primary partition type
273
    cmp   ecx,[known_part]       ; is it wanted partition?
258
    call  scan_partition_types
274
    jnz   test_ext_partition_0  ; no
259
    pop   eax
275
 
260
    jnz   test_ext_partition_0        ; no. skip over
276
        pop     eax
261
 
277
        add     eax, [ebx+0x1be+8+16+16+16]
Line 262... Line 278...
262
    inc   ecx
278
        mov     edx, [ebx+0x1be+12+16+16+16]
263
    cmp   ecx,[known_part]       ; is it wanted partition?
279
        mov     cl, [ebx+0x1be+4+16+16+16]
264
    jnz   test_ext_partition_0  ; no
280
        jmp     hd_and_partition_ok
265
 
281
 
266
        mov     edx, eax
-
 
267
        add     edx, [ebx+0x1be+8+16+16+16]
282
        ;mov     edx, eax
Line 268... Line 283...
268
        push    edx
283
        ;add     edx, [ebx+0x1be+8+16+16+16]
269
        add     edx, [ebx+0x1be+12+16+16+16]
284
        ;push    edx
270
        dec     edx
285
        ;add     edx, [ebx+0x1be+12+16+16+16]
Line 271... Line 286...
271
        mov     [PARTITION_END], edx
286
        ;dec     edx
272
        mov     dl, [ebx+0x1be+4+16+16+16]
-
 
273
        mov     [fs_type], dl
287
        ;mov     [PARTITION_END], edx
274
        pop     edx
288
        ;mov     al, [ebx+0x1be+4+16+16+16]
275
 
-
 
276
test_ext_partition_0:
289
        ;mov     [fs_type], dl
Line 277... Line 290...
277
    push  eax
290
        ;pop     edx
278
    mov   al,[ebx+0x1be+4]   ; get extended partition type
291
 
279
    call  scan_extended_types
292
test_ext_partition_0:
Line 280... Line 293...
280
    pop   eax
293
    pop   eax               ; ¯à®áâ® ¢ëª¨¤ë¢ ¥¬ ¨§ á⥪ 
281
    jnz   test_ext_partition_1
-
 
282
 
294
    mov   al,[ebx+0x1be+4]   ; get extended partition type
283
    mov   eax,[ebx+0x1be+8]     ; add relative start
295
    call  scan_extended_types
284
    test  eax,eax               ; is there extended partition?
-
 
285
    jnz   new_mbr               ; yes. read it
296
    jnz   test_ext_partition_1
Line 286... Line 297...
286
 
297
 
287
test_ext_partition_1:
298
    mov   eax,[ebx+0x1be+8]     ; add relative start
288
    push  eax
299
    test  eax,eax               ; is there extended partition?
Line 289... Line 300...
289
    mov   al,[ebx+0x1be+4+16]   ; get extended partition type
300
    jnz   new_mbr               ; yes. read it
290
    call  scan_extended_types
-
 
291
    pop   eax
301
 
292
    jnz   test_ext_partition_2
302
test_ext_partition_1:
293
 
-
 
294
    mov   eax,[ebx+0x1be+8+16]  ; add relative start
303
    mov   al,[ebx+0x1be+4+16]   ; get extended partition type
Line 295... Line 304...
295
    test  eax,eax               ; is there extended partition?
304
    call  scan_extended_types
296
    jnz   new_mbr               ; yes. read it
305
    jnz   test_ext_partition_2
297
 
306
 
Line 298... Line 307...
298
test_ext_partition_2:
307
    mov   eax,[ebx+0x1be+8+16]  ; add relative start
299
    push  eax
308
    test  eax,eax               ; is there extended partition?
-
 
309
    jnz   new_mbr               ; yes. read it
-
 
310
 
-
 
311
test_ext_partition_2:
-
 
312
    mov   al,[ebx+0x1be+4+16+16]   ; get extended partition type
-
 
313
    call  scan_extended_types
-
 
314
    jnz   test_ext_partition_3
-
 
315
 
Line 300... Line -...
300
    mov   al,[ebx+0x1be+4+16+16]   ; get extended partition type
-
 
301
    call  scan_extended_types
-
 
302
    pop   eax
-
 
Line 303... Line 316...
303
    jnz   test_ext_partition_3
316
    mov   eax,[ebx+0x1be+8+16+16]     ; add relative start
304
 
317
    test  eax,eax               ; is there extended partition?
305
    mov   eax,[ebx+0x1be+8+16+16]     ; add relative start
318
    jnz   new_mbr               ; yes. read it
306
    test  eax,eax               ; is there extended partition?
319
 
Line 341... Line 354...
341
    repne scasb                 ; is it extended partition?
354
    repne scasb                 ; is it extended partition?
342
    pop   ecx
355
    pop   ecx
343
    ret
356
    ret
Line 344... Line 357...
344
 
357
 
345
problem_fat_dec_count:          ; bootsector is missing or another problem
358
problem_fat_dec_count:          ; bootsector is missing or another problem
Line 346... Line 359...
346
    dec   [partition_count]     ; remove it from partition_count
359
;    dec   [partition_count]     ; remove it from partition_count
347
 
360
 
348
problem_partition_or_fat:
-
 
Line -... Line 361...
-
 
361
problem_partition_or_fat:
-
 
362
    or    [problem_partition],1
349
problem_hd:
363
 
350
    popad
364
return_from_part_set:
351
 
365
    popad
352
    mov   [fs_type],0
-
 
353
    call  free_hd_channel
366
    ;mov   [fs_type],0
Line 354... Line 367...
354
    mov   [hd1_status],0        ; free
367
    call  free_hd_channel
-
 
368
    mov   [hd1_status],0        ; free
-
 
369
    ret
-
 
370
 
355
    mov   [problem_partition],1
371
hd_and_partition_ok:
356
    ret
372
 
-
 
373
;eax = PARTITION_START edx=PARTITION_LENGTH cl=fs_type
-
 
374
    mov   [fs_type], cl
-
 
375
    ;mov   eax,edx
-
 
376
    mov   [PARTITION_START],eax
357
 
377
    add   edx, eax
358
hd_and_partition_ok:
378
    dec   edx
359
    mov   eax,edx
379
    mov   [PARTITION_END], edx
Line 360... Line 380...
360
    mov   [PARTITION_START],eax
380
 
361
        mov     edx, [PARTITION_END]
381
   ;     mov     edx, [PARTITION_END]
362
        sub     edx, eax
382
   ;     sub     edx, eax
363
        inc     edx     ; edx = length of partition
383
   ;     inc     edx     ; edx = length of partition § ç¥¬ ®­® ­ ¬??
Line 504... Line 524...
504
    mov   [fatMASK],0x0000FFFF
524
    mov   [fatMASK],0x0000FFFF
505
    mov   [fs_type],16         ; Fat16
525
    mov   [fs_type],16         ; Fat16
506
    call  free_hd_channel
526
    call  free_hd_channel
507
    mov   [hd1_status],0        ; free
527
    mov   [hd1_status],0        ; free
508
    ret
528
    ret
-
 
529
>