more rtfm'ing with encoding, 25 bytes of free code space in vbr now
This commit is contained in:
@@ -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
|
||||||
@@ -100,23 +100,17 @@ main:
|
|||||||
mov word [bp - 4], si ; part_offset
|
mov word [bp - 4], si ; part_offset
|
||||||
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