Subversion Repositories Kolibri OS

Rev

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

Rev 6827 Rev 6828
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2011-2015. 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: 6827 $
8
$Revision: 6828 $
9
 
9
 
10
; =============================================================================
10
; =============================================================================
11
; ================================= Constants =================================
11
; ================================= Constants =================================
Line 225... Line 225...
225
        HeaderSize               dd ?
225
        HeaderSize               dd ?
226
; Size of this header in bytes, must fit to one sector.
226
; Size of this header in bytes, must fit to one sector.
227
        HeaderCRC32              dd ?
227
        HeaderCRC32              dd ?
228
; Set this field to zero, compute CRC32 via 0xEDB88320, compare.
228
; Set this field to zero, compute CRC32 via 0xEDB88320, compare.
229
        Reserved                 dd ?
229
        Reserved                 dd ?
230
; Myst be zero.
230
; Must be zero.
231
        MyLBA                    dq ?
231
        MyLBA                    dq ?
232
; LBA of the sector containing this GPT header.
232
; LBA of the sector containing this GPT header.
233
        AlternateLBA             dq ?
233
        AlternateLBA             dq ?
234
; LBA of the sector containing the other GPT header.
234
; LBA of the sector containing the other GPT header.
235
; AlternateLBA of Primary GPTH points to Backup one and vice versa.
235
; AlternateLBA of Primary GPTH points to Backup one and vice versa.
Line 844... Line 844...
844
 
844
 
845
 
845
 
846
; This function is called from disk_scan_partitions to validate and parse
846
; This function is called from disk_scan_partitions to validate and parse
-
 
847
; primary and backup GPTs.
847
; primary and backup GPTs.
848
proc disk_scan_gpt
848
proc disk_scan_gpt
849
        push    ecx
849
; Scan primary GPT (second sector)
850
; Scan primary GPT (second sector)
850
        stdcall scan_gpt, 1, 0
851
        stdcall scan_gpt, 1, 0
851
        test    eax, eax
852
        test    eax, eax
Line 862... Line 863...
862
        test    eax, eax
863
        test    eax, eax
863
        jz      .exit
864
        jz      .exit
864
        DEBUGF  1, 'K : Backup GPT is also corrupt, fallback to legacy MBR\n'
865
        DEBUGF  1, 'K : Backup GPT is also corrupt, fallback to legacy MBR\n'
865
.exit:
866
.exit:
866
; Return value is ZF
867
; Return value is ZF
-
 
868
        pop     ecx
867
        ret
869
        ret
868
endp
870
endp
Line 869... Line 871...
869
 
871
 
Line 953... Line 955...
953
        div     [esi+DISK.MediaInfo.SectorSize]
955
        div     [esi+DISK.MediaInfo.SectorSize]
954
        push    eax     ; esp = pointer to the number of sectors
956
        push    eax     ; esp = pointer to the number of sectors
955
        mov     al, DISKFUNC.read
957
        mov     al, DISKFUNC.read
956
        stdcall disk_call_driver, edi, dword[ebx+GPTH.PartitionEntryLBA+0], \
958
        stdcall disk_call_driver, edi, dword[ebx+GPTH.PartitionEntryLBA+0], \
957
                dword[ebx+GPTH.PartitionEntryLBA+4], esp
959
                dword[ebx+GPTH.PartitionEntryLBA+4], esp
958
        pop     ecx
-
 
959
        test    eax, eax
960
        test    eax, eax
-
 
961
        pop     eax
960
        jnz     .fail_free_gpea_gpt
962
        jnz     .fail_free_gpea_gpt
961
; Compute and check CRC32 of GPEA
963
; Compute and check CRC32 of GPEA
962
        mov     edx, [ebx+GPTH.PartitionEntryArrayCRC32]
964
        mov     edx, [ebx+GPTH.PartitionEntryArrayCRC32]
963
        mov     eax, -1
965
        mov     eax, -1
964
        stdcall crc_32, 0xEDB88320, edi, [GPEA_len]
966
        stdcall crc_32, 0xEDB88320, edi, [GPEA_len]
Line 1007... Line 1009...
1007
 
1009
 
1008
; ecx = pointer to partition records array (MBR + 446)
1010
; ecx = pointer to partition records array (MBR + 446)
1009
is_protective_mbr:
1011
is_protective_mbr:
1010
        push    ecx edi
1012
        push    ecx edi
1011
        xor     eax, eax
1013
        xor     eax, eax
1012
        cmp     [ecx-6], eax
1014
;        cmp     [ecx-6], eax
1013
        jnz     .exit
1015
;        jnz     .exit
1014
        cmp     [ecx-2], eax
1016
        cmp     [ecx-2], ax
1015
        jnz     .exit
1017
        jnz     .exit
1016
; Partition record 0 has specific fields
1018
; Partition record 0 has specific fields
1017
        cmp     dword[ecx+0], 0x00020000
1019
        cmp     [ecx+0], al
1018
        jnz     .exit
1020
        jnz     .exit
1019
        cmp     byte[ecx+4], 0xEE
1021
        cmp     byte[ecx+4], 0xEE
1020
        jnz     .exit
1022
        jnz     .exit
1021
        cmp     dword[ecx+8], 1
1023
        cmp     dword[ecx+8], 1