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