Rev 1191 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1191 | Rev 1378 | ||
---|---|---|---|
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: 1191 $ |
8 | $Revision: 1378 $ |
9 | 9 | ||
10 | 10 | ||
Line 24... | Line 24... | ||
24 | ; Mario79 |
24 | ; Mario79 |
25 | ; START place |
25 | ; START place |
26 | ;****************************************************** |
26 | ;****************************************************** |
27 | PARTITION_START dd 0x3f |
27 | PARTITION_START dd 0x3f |
28 | PARTITION_END dd 0 |
28 | PARTITION_END dd 0 |
29 | fs_type db 0 ; 0=none, 1=NTFS, 16=FAT16, 32=FAT32 |
29 | fs_type db 0 ; 0=none, 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32 |
30 | align 4 |
30 | align 4 |
Line 31... | Line 31... | ||
31 | 31 | ||
32 | fs_dependent_data_start: |
32 | fs_dependent_data_start: |
Line 76... | Line 76... | ||
76 | if $ > fs_dependent_data_end |
76 | if $ > fs_dependent_data_end |
77 | ERROR: increase sizeof(fs_dependent_data)! |
77 | ERROR: increase sizeof(fs_dependent_data)! |
78 | end if |
78 | end if |
79 | end virtual |
79 | end virtual |
Line -... | Line 80... | ||
- | 80 | ||
- | 81 | virtual at fs_dependent_data_start |
|
- | 82 | ; EXT2 data |
|
- | 83 | ext2_data: |
|
- | 84 | .log_block_size dd ? |
|
- | 85 | .block_size dd ? |
|
- | 86 | .count_block_in_block dd ? |
|
- | 87 | .blocks_per_group dd ? |
|
- | 88 | .inodes_per_group dd ? |
|
- | 89 | .global_desc_table dd ? |
|
- | 90 | .root_inode dd ? ; pointer to root inode in memory |
|
- | 91 | .inode_size dd ? |
|
- | 92 | .count_pointer_in_block dd ? ; block_size / 4 |
|
- | 93 | .count_pointer_in_block_square dd ? ; (block_size / 4)**2 |
|
- | 94 | .ext2_save_block dd ? ; ¡«®ª £«®¡ «ìãî 1 ¯à®æ¥¤ãàã |
|
- | 95 | .ext2_temp_block dd ? ; ¡«®ª ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà |
|
- | 96 | .ext2_save_inode dd ? ; inode £«®¡ «ìãî ¯à®æ¥¤ãàã |
|
- | 97 | .ext2_temp_inode dd ? ; inode ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà |
|
- | 98 | if $ > fs_dependent_data_end |
|
- | 99 | ERROR: increase sizeof(fs_dependent_data)! |
|
- | 100 | end if |
|
- | 101 | end virtual |
|
80 | 102 | ||
81 | ;*************************************************************************** |
103 | ;*************************************************************************** |
82 | ; End place |
104 | ; End place |
83 | ; Mario79 |
105 | ; Mario79 |
84 | ;*************************************************************************** |
106 | ;*************************************************************************** |
Line 102... | Line 124... | ||
102 | db 0xcc ; DRDOS/secured: fat32, LBA-mapped |
124 | db 0xcc ; DRDOS/secured: fat32, LBA-mapped |
103 | db 0xce ; DRDOS/secured: fat16, LBA-mapped |
125 | db 0xce ; DRDOS/secured: fat16, LBA-mapped |
104 | db 0xd4 ; Old Multiuser DOS secured: fat16 <32M |
126 | db 0xd4 ; Old Multiuser DOS secured: fat16 <32M |
105 | db 0xd6 ; Old Multiuser DOS secured: fat16 >32M |
127 | db 0xd6 ; Old Multiuser DOS secured: fat16 >32M |
106 | db 0x07 ; NTFS |
128 | db 0x07 ; NTFS |
107 | db 0x27 ; NTFS, hidden |
129 | db 0x17 ; NTFS, hidden |
- | 130 | db 0x83 ; Linux native file system (ext2fs) |
|
108 | partition_types_end: |
131 | partition_types_end: |
Line 109... | Line 132... | ||
109 | 132 | ||
110 | 133 | ||
Line 116... | Line 139... | ||
116 | extended_types_end: |
139 | extended_types_end: |
Line 117... | Line 140... | ||
117 | 140 | ||
Line 118... | Line 141... | ||
118 | endg |
141 | endg |
119 | - | ||
120 | ; Partition chain used: |
- | |
121 | ; MBR ; PARTITION2 ; PARTITION3 ; PARTITION4 |
142 | |
122 | ;========================================================== |
143 | ; Partition chain used: |
123 | ; fat16/32 +-- fat16/32 +-- fat16/32 +-- fat16/32 +-- |
144 | ; MBR <--------------------- |
124 | ; extended --+ extended --+ extended --+ extended --+ |
145 | ; | | |
125 | ; 0 0 0 0 |
146 | ; |-> PARTITION1 | |
126 | ; 0 0 0 0 |
- | |
127 | ; Notes: |
147 | ; |-> EXTENDED PARTITION - ;not need be second partition |
Line 128... | Line 148... | ||
128 | ; - extended partition need to be in second entry on table |
148 | ; |-> PARTITION3 |
- | 149 | ; |-> PARTITION4 |
|
129 | ; - it will skip over removed partitions |
150 | |
130 | 151 | set_PARTITION_variables: |
|
131 | set_FAT32_variables: |
152 | set_FAT32_variables: ;deprecated |
Line 132... | Line 153... | ||
132 | mov [problem_partition],0 |
153 | mov [problem_partition],0 |
Line 133... | Line 154... | ||
133 | call reserve_hd1 |
154 | call reserve_hd1 |
134 | call reserve_hd_channel |
155 | call reserve_hd_channel |
Line 135... | Line 156... | ||
135 | 156 | ||
136 | pushad |
157 | pushad |
137 | 158 | ||
138 | cmp dword [hdpos],0 |
159 | cmp dword [hdpos],0 |
Line 139... | Line 160... | ||
139 | je problem_hd |
160 | je problem_hd |
140 | 161 | ||
141 | xor ecx,ecx ; partition count |
162 | xor ecx,ecx ; partition count |
142 | mov edx,-1 ; flag for partition |
163 | or edx,-1 ; flag for partition |
Line 143... | Line 164... | ||
143 | xor eax,eax ; read MBR |
164 | xor eax,eax ; address MBR |
144 | xor ebp,ebp ; extended partition start |
165 | xor ebp,ebp ; extended partition start |
Line 156... | Line 177... | ||
156 | jne problem_hd |
177 | jne problem_hd |
Line 157... | Line 178... | ||
157 | 178 | ||
158 | cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? |
179 | cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? |
159 | jnz end_partition_chain |
180 | jnz end_partition_chain |
160 | cmp dword [ebx+0x1be+0xc],0 ; skip over empty partition |
- | |
161 | ; jz next_partition |
181 | cmp dword [ebx+0x1be+0xc],0 ; skip over empty partition |
162 | jnz .next_primary_partition |
182 | jnz test_primary_partition_0 |
163 | cmp dword [ebx+0x1be+0xc+16],0 |
183 | cmp dword [ebx+0x1be+0xc+16],0 |
164 | jnz next_primary_partition |
184 | jnz test_primary_partition_1 |
165 | cmp dword [ebx+0x1be+0xc+16+16],0 |
185 | cmp dword [ebx+0x1be+0xc+16+16],0 |
166 | jnz next_primary_partition_1 |
186 | jnz test_primary_partition_2 |
167 | cmp dword [ebx+0x1be+0xc+16+16+16],0 |
187 | cmp dword [ebx+0x1be+0xc+16+16+16],0 |
168 | jnz next_primary_partition_2 |
188 | jnz test_primary_partition_3 |
Line 169... | Line 189... | ||
169 | jmp next_partition |
189 | jmp end_partition_chain |
170 | 190 | ||
171 | .next_primary_partition: |
191 | test_primary_partition_0: |
172 | push eax |
192 | push eax |
173 | mov al,[ebx+0x1be+4] ; get primary partition type |
193 | mov al,[ebx+0x1be+4] ; get primary partition type |
174 | call scan_partition_types |
194 | call scan_partition_types |
Line 175... | Line 195... | ||
175 | pop eax |
195 | pop eax |
176 | jnz next_primary_partition ; no. skip over |
196 | jnz test_primary_partition_1 ; no. skip over |
177 | 197 | ||
Line 178... | Line 198... | ||
178 | inc ecx |
198 | inc ecx |
179 | cmp ecx,[fat32part] ; is it wanted partition? |
199 | cmp ecx,[known_part] ; is it wanted partition? |
180 | jnz next_primary_partition ; no |
200 | jnz test_primary_partition_1 ; no |
181 | 201 | ||
Line 188... | Line 208... | ||
188 | ; when file system data will be available |
208 | ; when file system data will be available |
189 | mov dl, [ebx+0x1be+4] |
209 | mov dl, [ebx+0x1be+4] |
190 | mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS) |
210 | mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS) |
191 | pop edx |
211 | pop edx |
Line 192... | Line 212... | ||
192 | 212 | ||
193 | next_primary_partition: |
213 | test_primary_partition_1: |
194 | push eax |
214 | push eax |
195 | mov al,[ebx+0x1be+4+16] ; get primary partition type |
215 | mov al,[ebx+0x1be+4+16] ; get primary partition type |
196 | call scan_partition_types |
216 | call scan_partition_types |
197 | pop eax |
217 | pop eax |
Line 198... | Line 218... | ||
198 | jnz next_primary_partition_1 ; no. skip over |
218 | jnz test_primary_partition_2 ; no. skip over |
199 | 219 | ||
200 | inc ecx |
220 | inc ecx |
Line 201... | Line 221... | ||
201 | cmp ecx,[fat32part] ; is it wanted partition? |
221 | cmp ecx,[known_part] ; is it wanted partition? |
202 | jnz next_primary_partition_1 ; no |
222 | jnz test_primary_partition_2 ; no |
203 | 223 | ||
204 | mov edx, eax |
224 | mov edx, eax |
Line 209... | Line 229... | ||
209 | mov [PARTITION_END], edx |
229 | mov [PARTITION_END], edx |
210 | mov dl, [ebx+0x1be+4+16] |
230 | mov dl, [ebx+0x1be+4+16] |
211 | mov [fs_type], dl |
231 | mov [fs_type], dl |
212 | pop edx |
232 | pop edx |
Line 213... | Line 233... | ||
213 | 233 | ||
214 | next_primary_partition_1: |
234 | test_primary_partition_2: |
215 | push eax |
235 | push eax |
216 | mov al,[ebx+0x1be+4+16+16] ; get primary partition type |
236 | mov al,[ebx+0x1be+4+16+16] ; get primary partition type |
217 | call scan_partition_types |
237 | call scan_partition_types |
218 | pop eax |
238 | pop eax |
Line 219... | Line 239... | ||
219 | jnz next_primary_partition_2 ; no. skip over |
239 | jnz test_primary_partition_3 ; no. skip over |
220 | 240 | ||
221 | inc ecx |
241 | inc ecx |
Line 222... | Line 242... | ||
222 | cmp ecx,[fat32part] ; is it wanted partition? |
242 | cmp ecx,[known_part] ; is it wanted partition? |
223 | jnz next_primary_partition_2 ; no |
243 | jnz test_primary_partition_3 ; no |
224 | 244 | ||
225 | mov edx, eax |
245 | mov edx, eax |
Line 230... | Line 250... | ||
230 | mov [PARTITION_END], edx |
250 | mov [PARTITION_END], edx |
231 | mov dl, [ebx+0x1be+4+16+16] |
251 | mov dl, [ebx+0x1be+4+16+16] |
232 | mov [fs_type], dl |
252 | mov [fs_type], dl |
233 | pop edx |
253 | pop edx |
Line 234... | Line 254... | ||
234 | 254 | ||
235 | next_primary_partition_2: |
255 | test_primary_partition_3: |
236 | push eax |
256 | push eax |
237 | mov al,[ebx+0x1be+4+16+16+16] ; get primary partition type |
257 | mov al,[ebx+0x1be+4+16+16+16] ; get primary partition type |
238 | call scan_partition_types |
258 | call scan_partition_types |
239 | pop eax |
259 | pop eax |
Line 240... | Line 260... | ||
240 | jnz next_partition ; no. skip over |
260 | jnz test_ext_partition_0 ; no. skip over |
241 | 261 | ||
242 | inc ecx |
262 | inc ecx |
Line 243... | Line 263... | ||
243 | cmp ecx,[fat32part] ; is it wanted partition? |
263 | cmp ecx,[known_part] ; is it wanted partition? |
244 | jnz next_partition ; no |
264 | jnz test_ext_partition_0 ; no |
245 | 265 | ||
246 | mov edx, eax |
266 | mov edx, eax |
Line 251... | Line 271... | ||
251 | mov [PARTITION_END], edx |
271 | mov [PARTITION_END], edx |
252 | mov dl, [ebx+0x1be+4+16+16+16] |
272 | mov dl, [ebx+0x1be+4+16+16+16] |
253 | mov [fs_type], dl |
273 | mov [fs_type], dl |
254 | pop edx |
274 | pop edx |
Line 255... | Line 275... | ||
255 | 275 | ||
256 | next_partition: |
276 | test_ext_partition_0: |
257 | push eax |
277 | push eax |
258 | mov al,[ebx+0x1be+4] ; get extended partition type |
278 | mov al,[ebx+0x1be+4] ; get extended partition type |
259 | call scan_extended_types |
279 | call scan_extended_types |
260 | pop eax |
280 | pop eax |
Line 261... | Line 281... | ||
261 | jnz next_partition_1 |
281 | jnz test_ext_partition_1 |
262 | 282 | ||
263 | mov eax,[ebx+0x1be+8] ; add relative start |
283 | mov eax,[ebx+0x1be+8] ; add relative start |
Line 264... | Line 284... | ||
264 | test eax,eax ; is there extended partition? |
284 | test eax,eax ; is there extended partition? |
265 | jnz new_partition ; yes. read it |
285 | jnz new_mbr ; yes. read it |
266 | 286 | ||
267 | next_partition_1: |
287 | test_ext_partition_1: |
268 | push eax |
288 | push eax |
269 | mov al,[ebx+0x1be+4+16] ; get extended partition type |
289 | mov al,[ebx+0x1be+4+16] ; get extended partition type |
Line 270... | Line 290... | ||
270 | call scan_extended_types |
290 | call scan_extended_types |
271 | pop eax |
291 | pop eax |
272 | jnz next_partition_2 |
292 | jnz test_ext_partition_2 |
Line 273... | Line 293... | ||
273 | 293 | ||
274 | mov eax,[ebx+0x1be+8+16] ; add relative start |
294 | mov eax,[ebx+0x1be+8+16] ; add relative start |
275 | test eax,eax ; is there extended partition? |
295 | test eax,eax ; is there extended partition? |
276 | jnz new_partition ; yes. read it |
296 | jnz new_mbr ; yes. read it |
277 | 297 | ||
278 | next_partition_2: |
298 | test_ext_partition_2: |
Line 279... | Line 299... | ||
279 | push eax |
299 | push eax |
280 | mov al,[ebx+0x1be+4+16+16] ; get extended partition type |
300 | mov al,[ebx+0x1be+4+16+16] ; get extended partition type |
281 | call scan_extended_types |
301 | call scan_extended_types |
Line 282... | Line 302... | ||
282 | pop eax |
302 | pop eax |
283 | jnz next_partition_3 |
303 | jnz test_ext_partition_3 |
284 | 304 | ||
285 | mov eax,[ebx+0x1be+8+16+16] ; add relative start |
305 | mov eax,[ebx+0x1be+8+16+16] ; add relative start |
286 | test eax,eax ; is there extended partition? |
306 | test eax,eax ; is there extended partition? |
287 | jnz new_partition ; yes. read it |
307 | jnz new_mbr ; yes. read it |
Line 288... | Line 308... | ||
288 | 308 | ||
289 | next_partition_3: |
309 | test_ext_partition_3: |
290 | push eax |
310 | push eax |
Line 291... | Line 311... | ||
291 | mov al,[ebx+0x1be+4+16+16+16] ; get extended partition type |
311 | mov al,[ebx+0x1be+4+16+16+16] ; get extended partition type |
292 | call scan_extended_types |
312 | call scan_extended_types |
Line 293... | Line 313... | ||
293 | pop eax |
313 | pop eax |
Line 364... | Line 384... | ||
364 | mov eax, edx |
384 | mov eax, edx |
365 | shr eax, 1 |
385 | shr eax, 1 |
366 | add eax, [PARTITION_START] |
386 | add eax, [PARTITION_START] |
367 | call hd_read |
387 | call hd_read |
368 | cmp [hd_error], 0 |
388 | cmp [hd_error], 0 |
369 | jnz problem_fat_dec_count ; ¥ áã¤ì¡ ... |
389 | jnz problem_fat_dec_count ; no chance... |
370 | boot_read_ok: |
390 | boot_read_ok: |
371 | ; mov [hd_setup], 0 |
- | |
- | 391 | ||
372 | ; if we are running on NTFS, check bootsector |
392 | ; if we are running on NTFS, check bootsector |
373 | ; cmp [fs_type], 7 |
- | |
374 | ; jz ntfs_setup |
- | |
- | 393 | ||
375 | call ntfs_test_bootsec |
394 | call ntfs_test_bootsec ; test ntfs |
376 | jnc ntfs_setup |
395 | jnc ntfs_setup |
Line -... | Line 396... | ||
- | 396 | ||
- | 397 | call ext2_test_superblock ; test ext2fs |
|
- | 398 | jnc ext2_setup |
|
- | 399 | ||
- | 400 | mov eax, [PARTITION_START] ;ext2 test changes [buffer] |
|
- | 401 | call hd_read |
|
- | 402 | cmp [hd_error], 0 |
|
- | 403 | jnz problem_fat_dec_count |
|
377 | 404 | ||
378 | cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? |
405 | cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? |
Line 379... | Line 406... | ||
379 | jnz problem_fat_dec_count |
406 | jnz problem_fat_dec_count |
380 | 407 | ||
Line 477... | Line 504... | ||
477 | mov [fatMASK],0x0000FFFF |
504 | mov [fatMASK],0x0000FFFF |
478 | mov [fs_type],16 ; Fat16 |
505 | mov [fs_type],16 ; Fat16 |
479 | call free_hd_channel |
506 | call free_hd_channel |
480 | mov [hd1_status],0 ; free |
507 | mov [hd1_status],0 ; free |
481 | ret65536 |
508 | ret65536 |
- | 509 | >65536 |