get partition start from MBR if available

git-svn-id: svn://kolibrios.org@4299 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2013-11-27 10:41:18 +00:00
parent 27356bb991
commit 418e448f59
2 changed files with 19 additions and 13 deletions

View File

@ -9,34 +9,40 @@
nop nop
times 57h db 0 times 57h db 0
; file 'bt2.dat':3,57h ; file 'bt2.dat':3,57h
@@:
cmp byte [si], 80h
jnz @f
mov eax, [si+8]
mov [cs:7C1Ch], eax
@@: @@:
xor eax, eax xor eax, eax
mov ds, ax mov ds, ax
mov ss, ax mov ss, ax
mov sp, 7C00h mov sp, 7C00h
mov bp, sp
mov [boot_drive], dl mov [boot_drive], dl
cld cld
sti sti
push 800h push 800h
pop es pop es
movzx ebx, word [7C0Eh] ; reserved_sect movzx ebx, word [bp+0Eh] ; reserved_sect
mov [fat_start], ebx mov [fat_start], ebx
mov al, byte [7C10h] ; num_fats mov al, byte [bp+10h] ; num_fats
mul dword [7C24h] ; sect_fat mul dword [bp+24h] ; sect_fat
add eax, ebx add eax, ebx
; cluster 2 begins from sector eax ; cluster 2 begins from sector eax
movzx ebx, byte [7C0Dh] ; sects_per_clust movzx ebx, byte [bp+0Dh] ; sects_per_clust
add bx, bx add bx, bx
sub eax, ebx sub eax, ebx
mov [data_start], eax mov [data_start], eax
mov eax, [7C2Ch] ; root_cluster mov eax, [bp+2Ch] ; root_cluster
and eax, 0FFFFFFFh and eax, 0FFFFFFFh
fat32_parse_dir: fat32_parse_dir:
xor bx, bx xor bx, bx
mov di, bx mov di, bx
push eax push eax
call read_cluster call read_cluster
movzx cx, byte [7C0Dh] ; sects_per_clust movzx cx, byte [bp+0Dh] ; sects_per_clust
shl cx, 4 ; *0x200/0x20 shl cx, 4 ; *0x200/0x20
scan_cluster: scan_cluster:
cmp byte [es:di], 0 cmp byte [es:di], 0
@ -65,7 +71,7 @@ file_found:
push eax push eax
call read_cluster call read_cluster
mov ax, es mov ax, es
movzx cx, byte [7C0Dh] movzx cx, byte [bp+0Dh]
shl cx, 5 shl cx, 5
add ax, cx add ax, cx
mov es, ax mov es, ax
@ -82,7 +88,7 @@ sayerr:
read_cluster: read_cluster:
; in: eax = cluster, bx->buffer ; in: eax = cluster, bx->buffer
movzx ecx, byte [7C0Dh] movzx ecx, byte [bp+0Dh]
mul ecx mul ecx
add eax, [data_start] add eax, [data_start]
@ -91,7 +97,7 @@ read_cluster:
; cx = number of sectors ; cx = number of sectors
; es:bx -> buffer ; es:bx -> buffer
read: read:
add eax, [7C1Ch] ; hidden sectors add eax, [bp+1Ch] ; hidden sectors
push es push es
read_loop: read_loop:
pushad pushad

View File

@ -5,10 +5,10 @@
format binary format binary
use16 use16
out_string = 0x7DA2 out_string = 0x7DAB
read_cluster = 0x7D0A read_cluster = 0x7D15
relative_read = 0x7D18 relative_read = 0x7D22
next_cluster = 0x7D5C next_cluster = 0x7D65
org 0x8000 org 0x8000
start: start: