Subversion Repositories Kolibri OS

Rev

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

Rev 1419 Rev 2288
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 1419 $
8
$Revision: 2288 $
9
 
9
 
10
 
10
 
11
;*************************************************************
11
;*************************************************************
12
;* 13.02.2010 Find all partition and check supported FS
12
;* 13.02.2010 Find all partition and check supported FS
13
;* 12.07.2007 Check all 4 entry of MBR and EMBR
13
;* 12.07.2007 Check all 4 entry of MBR and EMBR
14
;* 29.04.2006 Elimination of hangup after the
14
;* 29.04.2006 Elimination of hangup after the
15
;*             expiration hd_wait_timeout -  Mario79
15
;*             expiration hd_wait_timeout -  Mario79
16
;* 28.01.2006 find all Fat16/32 partition in all input point
16
;* 28.01.2006 find all Fat16/32 partition in all input point
17
;*            to MBR - Mario79
17
;*            to MBR - Mario79
18
;*************************************************************
18
;*************************************************************
19
 
19
 
20
uglobal
20
uglobal
21
align 4
21
align 4
22
 
22
 
23
;******************************************************
23
;******************************************************
24
; Please do not change this place - variables  in text
24
; Please do not change this place - variables  in text
25
; Mario79
25
; Mario79
26
; START place
26
; START place
27
;******************************************************
27
;******************************************************
28
PARTITION_START      dd 0x3f
28
PARTITION_START      dd 0x3f
29
PARTITION_END        dd 0
29
PARTITION_END        dd 0
30
fs_type              db 0       ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
30
fs_type              db 0       ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
31
align 4
31
align 4
32
 
32
 
33
fs_dependent_data_start:
33
fs_dependent_data_start:
34
; FATxx data
34
; FATxx data
35
 
35
 
36
SECTORS_PER_FAT      dd 0x1f3a
36
SECTORS_PER_FAT      dd 0x1f3a
37
NUMBER_OF_FATS       dd 0x2
37
NUMBER_OF_FATS       dd 0x2
38
SECTORS_PER_CLUSTER  dd 0x8
38
SECTORS_PER_CLUSTER  dd 0x8
39
BYTES_PER_SECTOR     dd 0x200   ; Note: if BPS <> 512 need lots of changes
39
BYTES_PER_SECTOR     dd 0x200   ; Note: if BPS <> 512 need lots of changes
40
ROOT_CLUSTER         dd 2       ; first rootdir cluster
40
ROOT_CLUSTER         dd 2       ; first rootdir cluster
41
FAT_START            dd 0       ; start of fat table
41
FAT_START            dd 0       ; start of fat table
42
ROOT_START           dd 0       ; start of rootdir (only fat16)
42
ROOT_START           dd 0       ; start of rootdir (only fat16)
43
ROOT_SECTORS         dd 0       ; count of rootdir sectors (only fat16)
43
ROOT_SECTORS         dd 0       ; count of rootdir sectors (only fat16)
44
DATA_START           dd 0       ; start of data area (=first cluster 2)
44
DATA_START           dd 0       ; start of data area (=first cluster 2)
45
LAST_CLUSTER         dd 0       ; last availabe cluster
45
LAST_CLUSTER         dd 0       ; last availabe cluster
46
ADR_FSINFO           dd 0       ; used only by fat32
46
ADR_FSINFO           dd 0       ; used only by fat32
47
 
47
 
48
fatRESERVED          dd 0x0FFFFFF6
48
fatRESERVED          dd 0x0FFFFFF6
49
fatBAD               dd 0x0FFFFFF7
49
fatBAD               dd 0x0FFFFFF7
50
fatEND               dd 0x0FFFFFF8
50
fatEND               dd 0x0FFFFFF8
51
fatMASK              dd 0x0FFFFFFF
51
fatMASK              dd 0x0FFFFFFF
52
 
52
 
53
fatStartScan         dd 2
53
fatStartScan         dd 2
54
 
54
 
55
fs_dependent_data_end:
55
fs_dependent_data_end:
56
file_system_data_size = $ - PARTITION_START
56
file_system_data_size = $ - PARTITION_START
57
if file_system_data_size > 96
57
if file_system_data_size > 96
-
 
58
ERROR:
58
ERROR: sizeof(file system data) too big!
59
       sizeof(file system data) too big!
59
end if
60
end if
60
 
61
 
61
virtual at fs_dependent_data_start
62
virtual at fs_dependent_data_start
62
; NTFS data
63
; NTFS data
63
ntfs_data:
64
ntfs_data:
64
.sectors_per_cluster    dd      ?
65
.sectors_per_cluster    dd      ?
65
.mft_cluster            dd      ?
66
.mft_cluster            dd      ?
66
.mftmirr_cluster        dd      ?
67
.mftmirr_cluster        dd      ?
67
.frs_size               dd      ?       ; FRS size in bytes
68
.frs_size               dd      ?       ; FRS size in bytes
68
.iab_size               dd      ?       ; IndexAllocationBuffer size in bytes
69
.iab_size               dd      ?       ; IndexAllocationBuffer size in bytes
69
.frs_buffer             dd      ?
70
.frs_buffer             dd      ?
70
.iab_buffer             dd      ?
71
.iab_buffer             dd      ?
71
.mft_retrieval          dd      ?
72
.mft_retrieval          dd      ?
72
.mft_retrieval_size     dd      ?
73
.mft_retrieval_size     dd      ?
73
.mft_retrieval_alloc    dd      ?
74
.mft_retrieval_alloc    dd      ?
74
.mft_retrieval_end      dd      ?
75
.mft_retrieval_end      dd      ?
75
.cur_index_size         dd      ?
76
.cur_index_size         dd      ?
76
.cur_index_buf          dd      ?
77
.cur_index_buf          dd      ?
77
if $ > fs_dependent_data_end
78
if $ > fs_dependent_data_end
-
 
79
ERROR:
78
ERROR: increase sizeof(fs_dependent_data)!
80
       increase sizeof(fs_dependent_data)!
79
end if
81
end if
80
end virtual
82
end virtual
81
 
83
 
82
virtual at fs_dependent_data_start
84
virtual at fs_dependent_data_start
83
; EXT2 data
85
; EXT2 data
84
ext2_data:
86
ext2_data:
85
    .log_block_size                 dd ?
87
    .log_block_size                 dd ?
86
    .block_size                     dd ?
88
    .block_size                     dd ?
87
    .count_block_in_block           dd ?
89
    .count_block_in_block           dd ?
88
    .blocks_per_group               dd ?
90
    .blocks_per_group               dd ?
89
    .inodes_per_group               dd ?
91
    .inodes_per_group               dd ?
90
    .global_desc_table              dd ?
92
    .global_desc_table              dd ?
91
    .root_inode                     dd ?	; pointer to root inode in memory
93
    .root_inode                     dd ?        ; pointer to root inode in memory
92
    .inode_size                     dd ?
94
    .inode_size                     dd ?
93
    .count_pointer_in_block         dd ?	;  block_size / 4
95
    .count_pointer_in_block         dd ?        ;  block_size / 4
94
    .count_pointer_in_block_square  dd ?	; (block_size / 4)**2
96
    .count_pointer_in_block_square  dd ?        ; (block_size / 4)**2
95
    .ext2_save_block                dd ?    ; ¡«®ª ­  £«®¡ «ì­ãî 1 ¯à®æ¥¤ãàã
97
    .ext2_save_block                dd ?    ; ¡«®ª ­  £«®¡ «ì­ãî 1 ¯à®æ¥¤ãàã
96
    .ext2_temp_block                dd ?    ; ¡«®ª ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
98
    .ext2_temp_block                dd ?    ; ¡«®ª ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
97
    .ext2_save_inode                dd ?    ; inode ­  £«®¡ «ì­ãî ¯à®æ¥¤ãàã
99
    .ext2_save_inode                dd ?    ; inode ­  £«®¡ «ì­ãî ¯à®æ¥¤ãàã
98
    .ext2_temp_inode                dd ?    ; inode ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
100
    .ext2_temp_inode                dd ?    ; inode ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
99
    .sb                             dd ?    ; superblock
101
    .sb                             dd ?    ; superblock
100
    .groups_count                   dd ?
102
    .groups_count                   dd ?
101
if $ > fs_dependent_data_end
103
if $ > fs_dependent_data_end
-
 
104
ERROR:
102
ERROR: increase sizeof(fs_dependent_data)!
105
       increase sizeof(fs_dependent_data)!
103
end if
106
end if
104
end virtual
107
end virtual
105
 
108
 
106
;***************************************************************************
109
;***************************************************************************
107
; End place
110
; End place
108
; Mario79
111
; Mario79
109
;***************************************************************************
112
;***************************************************************************
110
endg
113
endg
111
iglobal
114
iglobal
112
 
115
 
113
  partition_types:              ; list of fat16/32 partitions
116
  partition_types:              ; list of fat16/32 partitions
114
    db    0x04                  ; DOS: fat16 <32M
117
    db    0x04                  ; DOS: fat16 <32M
115
    db    0x06                  ; DOS: fat16 >32M
118
    db    0x06                  ; DOS: fat16 >32M
116
    db    0x0b                  ; WIN95: fat32
119
    db    0x0b                  ; WIN95: fat32
117
    db    0x0c                  ; WIN95: fat32, LBA-mapped
120
    db    0x0c                  ; WIN95: fat32, LBA-mapped
118
    db    0x0e                  ; WIN95: fat16, LBA-mapped
121
    db    0x0e                  ; WIN95: fat16, LBA-mapped
119
    db    0x14                  ; Hidden DOS: fat16 <32M
122
    db    0x14                  ; Hidden DOS: fat16 <32M
120
    db    0x16                  ; Hidden DOS: fat16 >32M
123
    db    0x16                  ; Hidden DOS: fat16 >32M
121
    db    0x1b                  ; Hidden WIN95: fat32
124
    db    0x1b                  ; Hidden WIN95: fat32
122
    db    0x1c                  ; Hidden WIN95: fat32, LBA-mapped
125
    db    0x1c                  ; Hidden WIN95: fat32, LBA-mapped
123
    db    0x1e                  ; Hidden WIN95: fat16, LBA-mapped
126
    db    0x1e                  ; Hidden WIN95: fat16, LBA-mapped
124
    db    0xc4                  ; DRDOS/secured: fat16 <32M
127
    db    0xc4                  ; DRDOS/secured: fat16 <32M
125
    db    0xc6                  ; DRDOS/secured: fat16 >32M
128
    db    0xc6                  ; DRDOS/secured: fat16 >32M
126
    db    0xcb                  ; DRDOS/secured: fat32
129
    db    0xcb                  ; DRDOS/secured: fat32
127
    db    0xcc                  ; DRDOS/secured: fat32, LBA-mapped
130
    db    0xcc                  ; DRDOS/secured: fat32, LBA-mapped
128
    db    0xce                  ; DRDOS/secured: fat16, LBA-mapped
131
    db    0xce                  ; DRDOS/secured: fat16, LBA-mapped
129
    db    0xd4                  ; Old Multiuser DOS secured: fat16 <32M
132
    db    0xd4                  ; Old Multiuser DOS secured: fat16 <32M
130
    db    0xd6                  ; Old Multiuser DOS secured: fat16 >32M
133
    db    0xd6                  ; Old Multiuser DOS secured: fat16 >32M
131
    db    0x07                  ; NTFS
134
    db    0x07                  ; NTFS
132
    db    0x27                  ; NTFS, hidden
135
    db    0x27                  ; NTFS, hidden
133
    db    0x83                  ; Linux native file system (ext2fs)
136
    db    0x83                  ; Linux native file system (ext2fs)
134
  partition_types_end:
137
  partition_types_end:
135
 
138
 
136
 
139
 
137
  extended_types:               ; list of extended partitions
140
  extended_types:               ; list of extended partitions
138
    db    0x05                  ; DOS: extended partition
141
    db    0x05                  ; DOS: extended partition
139
    db    0x0f                  ; WIN95: extended partition, LBA-mapped
142
    db    0x0f                  ; WIN95: extended partition, LBA-mapped
140
    db    0xc5                  ; DRDOS/secured: extended partition
143
    db    0xc5                  ; DRDOS/secured: extended partition
141
    db    0xd5                  ; Old Multiuser DOS secured: extended partition
144
    db    0xd5                  ; Old Multiuser DOS secured: extended partition
142
  extended_types_end:
145
  extended_types_end:
143
 
146
 
144
endg
147
endg
145
 
148
 
146
; Partition chain used:
149
; Partition chain used:
147
; MBR <---------------------
150
; MBR <---------------------
148
; |                         |
151
; |                         |
149
; |-> PARTITION1          |
152
; |-> PARTITION1          |
150
; |-> EXTENDED PARTITION -        ;not need be second partition
153
; |-> EXTENDED PARTITION -        ;not need be second partition
151
; |-> PARTITION3
154
; |-> PARTITION3
152
; |-> PARTITION4
155
; |-> PARTITION4
153
 
156
 
154
set_PARTITION_variables:
157
set_PARTITION_variables:
155
set_FAT32_variables:        ;deprecated
158
set_FAT32_variables:        ;deprecated
156
    and   [problem_partition], 0
159
        and     [problem_partition], 0
157
    call  reserve_hd1
160
        call    reserve_hd1
158
    call  reserve_hd_channel
161
        call    reserve_hd_channel
159
 
162
 
160
    pushad
163
        pushad
161
 
-
 
162
    cmp   dword [hdpos],0
-
 
163
    je    problem_hd
-
 
164
 
-
 
165
    xor   ecx,ecx               ; partition count
-
 
166
    ;or    edx,-1                ; flag for partition
-
 
167
    xor   eax,eax               ; address MBR
-
 
168
    xor   ebp,ebp               ; extended partition start
-
 
169
 
-
 
170
new_mbr:
-
 
171
    test  ebp,ebp               ; is there extended partition? (MBR or EMBR)
-
 
172
    jnz   extended_already_set  ; yes
-
 
173
    xchg  ebp,eax               ; no. set it now
-
 
174
 
-
 
175
extended_already_set:
-
 
176
    add   eax,ebp               ; mbr=mbr+0, ext_part=ext_start+relat_start
-
 
177
    mov   ebx,buffer
-
 
178
    call  hd_read
-
 
179
    cmp  [hd_error],0
-
 
180
    jne  problem_hd
-
 
181
 
-
 
182
    cmp   word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
-
 
183
    jnz   end_partition_chain
-
 
184
    push  eax                      ; push only one time
-
 
185
    cmp   dword [ebx+0x1be+0xc],0 ; skip over empty partition
-
 
186
    jnz    test_primary_partition_0
-
 
187
    cmp   dword [ebx+0x1be+0xc+16],0
-
 
188
    jnz    test_primary_partition_1
-
 
189
    cmp   dword [ebx+0x1be+0xc+16+16],0
-
 
190
    jnz    test_primary_partition_2
-
 
191
    cmp   dword [ebx+0x1be+0xc+16+16+16],0
-
 
192
    jnz    test_primary_partition_3
-
 
193
    pop   eax
-
 
194
    jmp   end_partition_chain
-
 
195
 
-
 
196
test_primary_partition_0:
-
 
197
    mov   al,[ebx+0x1be+4]      ; get primary partition type
-
 
198
    call  scan_partition_types
-
 
199
    jnz   test_primary_partition_1      ; no. skip over
-
 
200
 
-
 
201
    inc   ecx
-
 
202
    cmp   ecx,[known_part]       ; is it wanted partition?
-
 
203
    jnz   test_primary_partition_1      ; no
-
 
Line -... Line 164...
-
 
164
 
-
 
165
        cmp     dword [hdpos], 0
-
 
166
        je      problem_hd
-
 
167
 
-
 
168
        xor     ecx, ecx        ; partition count
-
 
169
    ;or    edx,-1                ; flag for partition
-
 
170
        xor     eax, eax        ; address MBR
-
 
171
        xor     ebp, ebp        ; extended partition start
-
 
172
 
-
 
173
new_mbr:
-
 
174
        test    ebp, ebp        ; is there extended partition? (MBR or EMBR)
-
 
175
        jnz     extended_already_set; yes
-
 
176
        xchg    ebp, eax        ; no. set it now
-
 
177
 
-
 
178
extended_already_set:
-
 
179
        add     eax, ebp        ; mbr=mbr+0, ext_part=ext_start+relat_start
-
 
180
        mov     ebx, buffer
-
 
181
        call    hd_read
-
 
182
        cmp     [hd_error], 0
-
 
183
        jne     problem_hd
-
 
184
 
-
 
185
        cmp     word [ebx+0x1fe], 0xaa55; is it valid boot sector?
-
 
186
        jnz     end_partition_chain
-
 
187
        push    eax                ; push only one time
-
 
188
        cmp     dword [ebx+0x1be+0xc], 0; skip over empty partition
-
 
189
        jnz     test_primary_partition_0
-
 
190
        cmp     dword [ebx+0x1be+0xc+16], 0
-
 
191
        jnz     test_primary_partition_1
-
 
192
        cmp     dword [ebx+0x1be+0xc+16+16], 0
-
 
193
        jnz     test_primary_partition_2
-
 
194
        cmp     dword [ebx+0x1be+0xc+16+16+16], 0
-
 
195
        jnz     test_primary_partition_3
-
 
196
        pop     eax
-
 
197
        jmp     end_partition_chain
-
 
198
 
-
 
199
test_primary_partition_0:
-
 
200
        mov     al, [ebx+0x1be+4]; get primary partition type
-
 
201
        call    scan_partition_types
-
 
202
        jnz     test_primary_partition_1; no. skip over
-
 
203
 
-
 
204
        inc     ecx
-
 
205
        cmp     ecx, [known_part]; is it wanted partition?
-
 
206
        jnz     test_primary_partition_1; no
204
 
207
 
205
        pop     eax
208
        pop     eax
206
        ;mov     edx, eax                ; start sector
209
        ;mov     edx, eax                ; start sector
207
        add     eax, [ebx+0x1be+8]      ; add relative start
210
        add     eax, [ebx+0x1be+8]      ; add relative start
208
        ;mov     [PARTITON_START],edx
211
        ;mov     [PARTITON_START],edx
209
        ;push    edx
212
        ;push    edx
210
        mov     edx, [ebx+0x1be+12]     ; length
213
        mov     edx, [ebx+0x1be+12]     ; length
211
        ;add     edx, eax                ; add length
214
        ;add     edx, eax                ; add length
212
        ;dec     edx                     ; PARTITION_END is inclusive
215
        ;dec     edx                     ; PARTITION_END is inclusive
213
        ;mov     [PARTITION_END], edx    ; note that this can be changed
216
        ;mov     [PARTITION_END], edx    ; note that this can be changed
214
                                        ; when file system data will be available
217
                                        ; when file system data will be available
215
        mov     cl, [ebx+0x1be+4]       ; fs_type
218
        mov     cl, [ebx+0x1be+4]       ; fs_type
216
        ;mov     [fs_type], dl           ; save for FS recognizer (separate FAT vs NTFS)
219
        ;mov     [fs_type], dl           ; save for FS recognizer (separate FAT vs NTFS)
217
        ;pop     edx
220
        ;pop     edx
218
        jmp     hd_and_partition_ok
221
        jmp     hd_and_partition_ok
219
 
222
 
220
test_primary_partition_1:
223
test_primary_partition_1:
221
    mov   al,[ebx+0x1be+4+16]      ; get primary partition type
224
        mov     al, [ebx+0x1be+4+16]; get primary partition type
222
    call  scan_partition_types
225
        call    scan_partition_types
223
    jnz   test_primary_partition_2        ; no. skip over
226
        jnz     test_primary_partition_2  ; no. skip over
224
 
227
 
225
    inc   ecx
228
        inc     ecx
226
    cmp   ecx,[known_part]       ; is it wanted partition?
229
        cmp     ecx, [known_part]; is it wanted partition?
Line 227... Line 230...
227
    jnz   test_primary_partition_2        ; no
230
        jnz     test_primary_partition_2  ; no
228
 
231
 
229
        pop     eax
232
        pop     eax
230
        add     eax, [ebx+0x1be+8+16]
233
        add     eax, [ebx+0x1be+8+16]
231
        mov     edx, [ebx+0x1be+12+16]
234
        mov     edx, [ebx+0x1be+12+16]
232
        mov     cl, [ebx+0x1be+4+16]
235
        mov     cl, [ebx+0x1be+4+16]
233
        jmp     hd_and_partition_ok
236
        jmp     hd_and_partition_ok
234
 
237
 
235
        ;mov     edx, eax
238
        ;mov     edx, eax
236
        ;add     edx, [ebx+0x1be+8+16]
239
        ;add     edx, [ebx+0x1be+8+16]
237
        ;push    edx
240
        ;push    edx
238
        ;add     edx, [ebx+0x1be+12+16]
241
        ;add     edx, [ebx+0x1be+12+16]
239
        ;dec     edx
242
        ;dec     edx
240
        ;mov     [PARTITION_END], edx
243
        ;mov     [PARTITION_END], edx
241
        ;mov     al, [ebx+0x1be+4+16]
244
        ;mov     al, [ebx+0x1be+4+16]
242
        ;mov     [fs_type], dl
245
        ;mov     [fs_type], dl
243
        ;pop     edx
246
        ;pop     edx
244
 
247
 
245
test_primary_partition_2:
248
test_primary_partition_2:
246
    mov   al,[ebx+0x1be+4+16+16]      ; get primary partition type
249
        mov     al, [ebx+0x1be+4+16+16]; get primary partition type
247
    call  scan_partition_types
250
        call    scan_partition_types
248
    jnz   test_primary_partition_3        ; no. skip over
251
        jnz     test_primary_partition_3  ; no. skip over
249
 
252
 
250
    inc   ecx
253
        inc     ecx
Line 251... Line 254...
251
    cmp   ecx,[known_part]       ; is it wanted partition?
254
        cmp     ecx, [known_part]; is it wanted partition?
252
    jnz   test_primary_partition_3        ; no
255
        jnz     test_primary_partition_3  ; no
253
 
256
 
254
        pop     eax
257
        pop     eax
255
        add     eax, [ebx+0x1be+8+16+16]
258
        add     eax, [ebx+0x1be+8+16+16]
256
        mov     edx, [ebx+0x1be+12+16+16]
259
        mov     edx, [ebx+0x1be+12+16+16]
257
        mov     cl, [ebx+0x1be+4+16+16]
260
        mov     cl, [ebx+0x1be+4+16+16]
258
        jmp     hd_and_partition_ok
261
        jmp     hd_and_partition_ok
259
        ;mov     edx, eax
262
        ;mov     edx, eax
260
        ;add     edx, [ebx+0x1be+8+16+16]
263
        ;add     edx, [ebx+0x1be+8+16+16]
261
        ;push    edx
264
        ;push    edx
262
        ;add     edx, [ebx+0x1be+12+16+16]
265
        ;add     edx, [ebx+0x1be+12+16+16]
263
        ;dec     edx
266
        ;dec     edx
264
        ;mov     [PARTITION_END], edx
267
        ;mov     [PARTITION_END], edx
265
        ;mov     al, [ebx+0x1be+4+16+16]
268
        ;mov     al, [ebx+0x1be+4+16+16]
266
        ;mov     [fs_type], dl
269
        ;mov     [fs_type], dl
267
        ;pop     edx
270
        ;pop     edx
268
 
271
 
269
test_primary_partition_3:
272
test_primary_partition_3:
270
    mov   al,[ebx+0x1be+4+16+16+16]      ; get primary partition type
273
        mov     al, [ebx+0x1be+4+16+16+16]; get primary partition type
271
    call  scan_partition_types
274
        call    scan_partition_types
272
    jnz   test_ext_partition_0        ; no. skip over
275
        jnz     test_ext_partition_0  ; no. skip over
273
 
276
 
Line 274... Line 277...
274
    inc   ecx
277
        inc     ecx
275
    cmp   ecx,[known_part]       ; is it wanted partition?
278
        cmp     ecx, [known_part]; is it wanted partition?
276
    jnz   test_ext_partition_0  ; no
279
        jnz     test_ext_partition_0; no
277
 
280
 
278
        pop     eax
281
        pop     eax
279
        add     eax, [ebx+0x1be+8+16+16+16]
282
        add     eax, [ebx+0x1be+8+16+16+16]
280
        mov     edx, [ebx+0x1be+12+16+16+16]
283
        mov     edx, [ebx+0x1be+12+16+16+16]
281
        mov     cl, [ebx+0x1be+4+16+16+16]
284
        mov     cl, [ebx+0x1be+4+16+16+16]
282
        jmp     hd_and_partition_ok
285
        jmp     hd_and_partition_ok
283
 
286
 
284
        ;mov     edx, eax
287
        ;mov     edx, eax
285
        ;add     edx, [ebx+0x1be+8+16+16+16]
288
        ;add     edx, [ebx+0x1be+8+16+16+16]
286
        ;push    edx
289
        ;push    edx
287
        ;add     edx, [ebx+0x1be+12+16+16+16]
290
        ;add     edx, [ebx+0x1be+12+16+16+16]
288
        ;dec     edx
291
        ;dec     edx
289
        ;mov     [PARTITION_END], edx
292
        ;mov     [PARTITION_END], edx
290
        ;mov     al, [ebx+0x1be+4+16+16+16]
293
        ;mov     al, [ebx+0x1be+4+16+16+16]
291
        ;mov     [fs_type], dl
294
        ;mov     [fs_type], dl
292
        ;pop     edx
295
        ;pop     edx
293
 
296
 
294
test_ext_partition_0:
297
test_ext_partition_0:
295
    pop   eax               ; ¯à®áâ® ¢ëª¨¤ë¢ ¥¬ ¨§ á⥪ 
298
        pop     eax         ; ¯à®áâ® ¢ëª¨¤ë¢ ¥¬ ¨§ á⥪ 
296
    mov   al,[ebx+0x1be+4]   ; get extended partition type
299
        mov     al, [ebx+0x1be+4]; get extended partition type
297
    call  scan_extended_types
300
        call    scan_extended_types
298
    jnz   test_ext_partition_1
301
        jnz     test_ext_partition_1
299
 
302
 
300
    mov   eax,[ebx+0x1be+8]     ; add relative start
303
        mov     eax, [ebx+0x1be+8]; add relative start
301
    test  eax,eax               ; is there extended partition?
304
        test    eax, eax        ; is there extended partition?
302
    jnz   new_mbr               ; yes. read it
305
        jnz     new_mbr         ; yes. read it
303
 
306
 
304
test_ext_partition_1:
307
test_ext_partition_1:
305
    mov   al,[ebx+0x1be+4+16]   ; get extended partition type
308
        mov     al, [ebx+0x1be+4+16]; get extended partition type
306
    call  scan_extended_types
309
        call    scan_extended_types
307
    jnz   test_ext_partition_2
310
        jnz     test_ext_partition_2
308
 
311
 
309
    mov   eax,[ebx+0x1be+8+16]  ; add relative start
312
        mov     eax, [ebx+0x1be+8+16]; add relative start
310
    test  eax,eax               ; is there extended partition?
313
        test    eax, eax        ; is there extended partition?
311
    jnz   new_mbr               ; yes. read it
314
        jnz     new_mbr         ; yes. read it
312
 
315
 
313
test_ext_partition_2:
316
test_ext_partition_2:
314
    mov   al,[ebx+0x1be+4+16+16]   ; get extended partition type
317
        mov     al, [ebx+0x1be+4+16+16]; get extended partition type
315
    call  scan_extended_types
318
        call    scan_extended_types
316
    jnz   test_ext_partition_3
319
        jnz     test_ext_partition_3
317
 
320
 
318
    mov   eax,[ebx+0x1be+8+16+16]     ; add relative start
321
        mov     eax, [ebx+0x1be+8+16+16]; add relative start
319
    test  eax,eax               ; is there extended partition?
322
        test    eax, eax        ; is there extended partition?
320
    jnz   new_mbr               ; yes. read it
323
        jnz     new_mbr         ; yes. read it
321
 
324
 
322
test_ext_partition_3:
325
test_ext_partition_3:
323
    mov   al,[ebx+0x1be+4+16+16+16]   ; get extended partition type
326
        mov     al, [ebx+0x1be+4+16+16+16]; get extended partition type
324
    call  scan_extended_types
327
        call    scan_extended_types
325
    jnz   end_partition_chain   ; no. end chain
328
        jnz     end_partition_chain; no. end chain
326
 
329
 
327
    mov   eax,[ebx+0x1be+8+16+16+16]  ; get start of extended partition
330
        mov     eax, [ebx+0x1be+8+16+16+16]; get start of extended partition
328
    test  eax,eax               ; is there extended partition?
331
        test    eax, eax        ; is there extended partition?
329
    jnz   new_mbr               ; yes. read it
332
        jnz     new_mbr         ; yes. read it
330
 
333
 
331
end_partition_chain:
334
end_partition_chain:
332
    ;mov   [partition_count],ecx
335
    ;mov   [partition_count],ecx
333
 
336
 
334
    ;cmp   edx,-1                ; found wanted partition?
337
    ;cmp   edx,-1                ; found wanted partition?
335
    ;jnz   hd_and_partition_ok   ; yes. install it
338
    ;jnz   hd_and_partition_ok   ; yes. install it
336
    ;jmp   problem_partition_or_fat
339
    ;jmp   problem_partition_or_fat
337
problem_hd:
340
problem_hd:
338
    or    [problem_partition], 2
341
        or      [problem_partition], 2
339
    jmp   return_from_part_set
342
        jmp     return_from_part_set
340
 
343
 
341
 
344
 
342
scan_partition_types:
345
scan_partition_types:
343
    push  ecx
346
        push    ecx
344
    mov   edi,partition_types
347
        mov     edi, partition_types
345
    mov   ecx,partition_types_end-partition_types
348
        mov     ecx, partition_types_end-partition_types
346
    cld
349
        cld
347
    repne scasb                 ; is partition type ok?
350
        repne scasb             ; is partition type ok?
348
    pop   ecx
351
        pop     ecx
349
    ret
352
        ret
350
 
353
 
351
scan_extended_types:
354
scan_extended_types:
352
    push  ecx
355
        push    ecx
353
    mov   edi,extended_types
356
        mov     edi, extended_types
354
    mov   ecx,extended_types_end-extended_types
357
        mov     ecx, extended_types_end-extended_types
355
    cld
358
        cld
356
    repne scasb                 ; is it extended partition?
359
        repne scasb             ; is it extended partition?
357
    pop   ecx
360
        pop     ecx
358
    ret
361
        ret
359
 
362
 
360
problem_fat_dec_count:          ; bootsector is missing or another problem
363
problem_fat_dec_count:          ; bootsector is missing or another problem
361
;    dec   [partition_count]     ; remove it from partition_count
364
;    dec   [partition_count]     ; remove it from partition_count
362
 
365
 
363
problem_partition_or_fat:
366
problem_partition_or_fat:
364
    or    [problem_partition],1
367
        or      [problem_partition], 1
365
 
368
 
366
return_from_part_set:
369
return_from_part_set:
367
    popad
370
        popad
368
    ;mov   [fs_type],0
371
    ;mov   [fs_type],0
369
    call  free_hd_channel
372
        call    free_hd_channel
Line 370... Line 373...
370
    mov   [hd1_status],0        ; free
373
        mov     [hd1_status], 0 ; free