Detect muliple active partitions
This commit is contained in:
1 parent
259be82bc8
commit
fd3ca4c4e3
1 file changed
+76
-6
+76
-6
@@ -32,18 +32,86 @@ relocated:
|
|||||||
mov si, message ; Put address of the null-terminated string to output into 'si'
|
mov si, message ; Put address of the null-terminated string to output into 'si'
|
||||||
call print ; Call our string-printing routine
|
call print ; Call our string-printing routine
|
||||||
|
|
||||||
mov bx, [partition_1.start_LBA]
|
; Check for more than one active partition that we can start from.
|
||||||
|
xor bx, bx
|
||||||
|
xor cx, cx
|
||||||
|
mov ax, [partition_1.active_partition]
|
||||||
|
call dumpax
|
||||||
|
cli
|
||||||
|
hlt
|
||||||
|
cmp ax, 0x80
|
||||||
|
jne check_p_2
|
||||||
|
mov bx, 0x01 ; Partion 1 active
|
||||||
|
inc cx
|
||||||
|
|
||||||
|
check_p_2:
|
||||||
|
mov ax, [partition_2.active_partition]
|
||||||
|
cmp ax, 0x80
|
||||||
|
jne check_p_3
|
||||||
|
inc cx
|
||||||
|
mov bx, 0x02 ; Partion 2 active
|
||||||
|
|
||||||
|
check_p_3:
|
||||||
|
mov ax, [partition_3.active_partition]
|
||||||
|
cmp ax, 0x80
|
||||||
|
jne check_p_4
|
||||||
|
inc cx
|
||||||
|
mov bx, 0x03 ; Partion 3 active
|
||||||
|
|
||||||
|
check_p_4:
|
||||||
|
mov ax, [partition_4.active_partition]
|
||||||
|
cmp ax, 0x80
|
||||||
|
jne eval_active_partion_number
|
||||||
|
inc cx
|
||||||
|
mov bx, 0x04 ; Partion 4 active
|
||||||
|
|
||||||
|
eval_active_partion_number:
|
||||||
|
cmp cx, 1
|
||||||
|
je boot_partition:
|
||||||
|
; here goes wait call, for the user to enter debug mode.
|
||||||
|
; Wating for 2 seconds:
|
||||||
|
mov ah, 0x86 ; code for waiting interupt call
|
||||||
|
mov cx, 0x001e ; high count of microseconds
|
||||||
|
mov dx, 0x8480 ; low count
|
||||||
|
int 0x15
|
||||||
|
.busy_wait_for_key:
|
||||||
|
xor ax, ax
|
||||||
|
mov ah, 0x01 ; BIOS call to wait for key
|
||||||
|
int 0x16
|
||||||
|
|
||||||
|
mov bx, 1
|
||||||
|
|
||||||
|
boot_partition:
|
||||||
|
; IMPORTANT bx, has to hold the value 1-4 for the partiotion that wanted to be booted.
|
||||||
|
|
||||||
|
|
||||||
|
mov ax, partition_1
|
||||||
|
.loop:
|
||||||
|
cmp bx, 1
|
||||||
|
je break
|
||||||
|
add ax, 0x10
|
||||||
|
dec bx
|
||||||
|
jmp .loop
|
||||||
|
break:
|
||||||
|
|
||||||
|
add ax, 7 ; This is the offset to fetch the LBA start adress of the partition record
|
||||||
|
|
||||||
|
mov bx, [ax] ; first part of LBA
|
||||||
mov WORD [DAPACK.lba_addr_dw_low], bx
|
mov WORD [DAPACK.lba_addr_dw_low], bx
|
||||||
mov bx, [partition_1.start_LBA + 1]
|
inc ax ; next part
|
||||||
|
mov bx, [ax]
|
||||||
mov WORD [DAPACK.lba_addr_dw_low + 1], bx
|
mov WORD [DAPACK.lba_addr_dw_low + 1], bx
|
||||||
mov bx, [partition_1.start_LBA + 2]
|
inc ax ; next part
|
||||||
|
mov bx, [ax]
|
||||||
mov WORD [DAPACK.lba_addr_dw_low + 2], bx
|
mov WORD [DAPACK.lba_addr_dw_low + 2], bx
|
||||||
mov bx, [partition_1.start_LBA + 3]
|
inc ax ; next part
|
||||||
|
mov bx, [ax]
|
||||||
mov WORD [DAPACK.lba_addr_dw_low + 3], bx
|
mov WORD [DAPACK.lba_addr_dw_low + 3], bx
|
||||||
mov WORD [DAPACK.blkcnt], 0x01
|
mov WORD [DAPACK.blkcnt], 0x01
|
||||||
mov WORD [DAPACK.db_addr_segment], 0x0000
|
mov WORD [DAPACK.db_addr_segment], 0x0000
|
||||||
mov WORD [DAPACK.db_addr_offset], 0x7c00
|
mov WORD [DAPACK.db_addr_offset], 0x7c00
|
||||||
mov si, DAPACK ; address of "disk address packet"
|
mov si, DAPACK ; address of "disk address packet"
|
||||||
|
xor ax, ax
|
||||||
mov ah, 0x42 ; READ
|
mov ah, 0x42 ; READ
|
||||||
mov dl, [disk_identifier]
|
mov dl, [disk_identifier]
|
||||||
int 0x13
|
int 0x13
|
||||||
@@ -194,8 +262,10 @@ message db 'SLRboot for SingOS! v0.2.0.3-exp',13,10,0
|
|||||||
;boot_system db 'Read SingOS from disk', 13, 10, 0
|
;boot_system db 'Read SingOS from disk', 13, 10, 0
|
||||||
;error_str db 'Error', 0
|
;error_str db 'Error', 0
|
||||||
;success_str db 'Success', 0
|
;success_str db 'Success', 0
|
||||||
|
boot_this_partition: dw 0
|
||||||
disk_identifier db 0
|
disk_identifier db 0
|
||||||
|
|
||||||
|
|
||||||
DAPACK:
|
DAPACK:
|
||||||
.dap_Size: db 0x10 ; This is always 16 bytes (0x10)
|
.dap_Size: db 0x10 ; This is always 16 bytes (0x10)
|
||||||
.rev_byte: db 0x0 ; reserved byte, should always be zero
|
.rev_byte: db 0x0 ; reserved byte, should always be zero
|
||||||
@@ -217,7 +287,7 @@ partition_1:
|
|||||||
.size db 0x00, 0xC8, 0x03, 0x00
|
.size db 0x00, 0xC8, 0x03, 0x00
|
||||||
|
|
||||||
partition_2:
|
partition_2:
|
||||||
.active_partition db 0x00
|
.active_partition db 0x80
|
||||||
.start_CHS db 0x8C, 0x3E, 0x0F
|
.start_CHS db 0x8C, 0x3E, 0x0F
|
||||||
.disk_type db 0x83
|
.disk_type db 0x83
|
||||||
.end_CHS db 0xFF, 0xFF, 0xFF
|
.end_CHS db 0xFF, 0xFF, 0xFF
|
||||||
|
|||||||
Reference in new issue
Block a user