Compare commits
3 Commits
aa0efe5ff8
...
3c654b1be0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c654b1be0 | |||
| 0d90b3efd6 | |||
| b08605f295 |
@@ -33,7 +33,6 @@ nop
|
||||
%include "config.inc"
|
||||
%include "error_codes.inc"
|
||||
%include "partition_table.inc"
|
||||
%include "fat32/fat32_structures.inc"
|
||||
|
||||
%undef __STEVIA_DEV_DEBUG
|
||||
|
||||
@@ -58,7 +57,7 @@ init:
|
||||
cld
|
||||
rep stosb ; zero bss section
|
||||
|
||||
sub sp, 0x20 ; local varible space (32 bytes)
|
||||
sub sp, 0x10 ; local varible space (32 bytes)
|
||||
push bp ; setup top of stack frame
|
||||
|
||||
xor cx, cx
|
||||
@@ -121,19 +120,14 @@ main:
|
||||
mov word [bp - 4], ax ; update part_offset
|
||||
.read_data:
|
||||
movzx ax, byte [bp - 2]
|
||||
push ax ; drive_num
|
||||
|
||||
mov ax, 0x1
|
||||
push ax ; count
|
||||
push ax ; drive_num (2)
|
||||
push 0x01 ; count (2)
|
||||
|
||||
mov dword eax, dword [bx + PartEntry_t.lba_start]
|
||||
push dword eax ; lba
|
||||
push dword eax ; lba (4)
|
||||
|
||||
mov ax, VBR_ENTRY
|
||||
push ax ; offset = 0x7c00
|
||||
|
||||
xor ax, ax
|
||||
push ax ; segment = 0
|
||||
push word VBR_ENTRY ; offset = 0x7c00 (2)
|
||||
push 0x00 ; segment = 0 (2)
|
||||
|
||||
; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset,
|
||||
; uint32_t lba,
|
||||
@@ -143,14 +137,11 @@ main:
|
||||
.goto_vbr:
|
||||
cmp word [VBR_ENTRY + 0x1FE], 0xAA55
|
||||
je main.sig_ok
|
||||
ERROR MBR_ERROR_NO_VBR_SIG ; no signature present
|
||||
.sig_ok:
|
||||
mov ax, PartTable_t_size
|
||||
push ax
|
||||
mov ax, DiskSig ; start of partition table
|
||||
push ax
|
||||
mov ax, partition_table
|
||||
push ax
|
||||
ERROR MBR_ERROR_NO_VBR_SIG ; no signature present
|
||||
.sig_ok:
|
||||
push PartTable_t_size ; len
|
||||
push DiskSig ; src -> start of partition table
|
||||
push partition_table ; dst -> addr in bss
|
||||
call kmemcpy ; copy partition table to bss
|
||||
add sp, 0x6
|
||||
|
||||
@@ -196,7 +187,7 @@ align 16, resb 1
|
||||
lba_packet resb LBAPkt_t_size
|
||||
|
||||
align 512, resb 1
|
||||
stack_bottom resb 512 ; 512 byte stack early on
|
||||
stack_bottom resb 512 - 16 ; 512 byte stack early on
|
||||
stack_top:
|
||||
mbr_redzone resb 32
|
||||
mbr_redzone resb 16
|
||||
end_bss:
|
||||
@@ -72,7 +72,7 @@ init:
|
||||
cld
|
||||
rep stosb
|
||||
|
||||
sub sp, 0x20 ; local varible space (32 bytes)
|
||||
sub sp, 0x10 ; local varible space (32 bytes)
|
||||
push bp
|
||||
|
||||
sti ; all done with inital setup and relocation, reenable interupts
|
||||
@@ -100,23 +100,17 @@ main:
|
||||
mov word [bp - 4], si ; part_offset
|
||||
mov word [bp - 6], bx ; partition_table
|
||||
|
||||
.load_fs_data:
|
||||
mov ax, PartTable_t_size ; count=
|
||||
push ax
|
||||
mov ax, [bp - 6] ; src= ptr partition_table
|
||||
push ax
|
||||
mov ax, partition_table ; dst=
|
||||
push ax
|
||||
call kmemcpy ; copy partition table data
|
||||
.load_fs_data:
|
||||
push PartTable_t_size ; count=
|
||||
push word [bp - 6] ; src= ptr partition_table
|
||||
push partition_table ; dst=
|
||||
call kmemcpy ; copy partition table data to bss
|
||||
add sp, 0x6
|
||||
|
||||
mov ax, (FAT32_bpb_t_size + FAT32_ebpb_t_size) ; size in byte, should be 90 bytes
|
||||
push ax
|
||||
mov ax, __ENTRY
|
||||
push ax
|
||||
mov ax, fat32_bpb ;
|
||||
push ax
|
||||
call kmemcpy ; copy bpb & ebpb to memory
|
||||
|
||||
push (FAT32_bpb_t_size + FAT32_ebpb_t_size) ; size in byte, should be 90 bytes
|
||||
push __ENTRY ; src
|
||||
push fat32_bpb ; dst
|
||||
call kmemcpy ; copy bpb & ebpb to bss
|
||||
add sp, 0x6
|
||||
|
||||
.check_FAT_size: ; we only support a very specific setup of FAT32
|
||||
@@ -129,17 +123,13 @@ main:
|
||||
movzx ax, byte [bp - 2]
|
||||
push ax ; drive_num
|
||||
|
||||
mov ax, STAGE2_SECTOR_COUNT
|
||||
push ax ; count
|
||||
push STAGE2_SECTOR_COUNT ; count
|
||||
|
||||
mov dword eax, 0x1
|
||||
push dword eax ; lba
|
||||
|
||||
mov ax, STAGE2_ENTRY
|
||||
push ax ; offset
|
||||
|
||||
xor ax, ax
|
||||
push ax ; segment = 0
|
||||
push STAGE2_ENTRY ; offset
|
||||
push 0x00 ; segment = 0
|
||||
|
||||
; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset,
|
||||
; uint32_t lba,
|
||||
@@ -166,6 +156,7 @@ times (510 - ($ - $$)) nop ; Fill the rest of sector with nop
|
||||
|
||||
BootSig:
|
||||
dw 0xAA55 ; Add boot signature at the end of bootloader
|
||||
; !!! END VBR !!!
|
||||
|
||||
section .bss follows=.text
|
||||
begin_bss:
|
||||
@@ -177,14 +168,11 @@ align 16, resb 1
|
||||
fat32_bpb resb FAT32_bpb_t_size
|
||||
fat32_ebpb resb FAT32_ebpb_t_size
|
||||
|
||||
align 16, resb 1
|
||||
fat32_nc_data resb 16
|
||||
|
||||
align 16, resb 1
|
||||
lba_packet resb LBAPkt_t_size
|
||||
|
||||
align 512, resb 1
|
||||
stack_bottom resb 512 ; 512b stack early on
|
||||
stack_bottom resb (512 - 16) ; 512b stack early on
|
||||
stack_top:
|
||||
vbr_redzone resb 32
|
||||
vbr_redzone resb 16
|
||||
end_bss:
|
||||
Reference in New Issue
Block a user