convert MBR, VBR, & Stage2 to use a BSS section. #3
@@ -25,14 +25,11 @@
|
|||||||
[WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings.
|
[WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings.
|
||||||
[map all mbr.map]
|
[map all mbr.map]
|
||||||
%define __STEVIA_MBR
|
%define __STEVIA_MBR
|
||||||
|
|
||||||
jmp short (init - $$)
|
jmp short (init - $$)
|
||||||
nop
|
nop
|
||||||
|
|
||||||
; ###############
|
; ###############
|
||||||
;
|
|
||||||
; Headers/Includes/Definitions
|
; Headers/Includes/Definitions
|
||||||
;
|
|
||||||
; ###############
|
; ###############
|
||||||
|
|
||||||
%include "util/bochs_magic.inc"
|
%include "util/bochs_magic.inc"
|
||||||
@@ -43,11 +40,7 @@ nop
|
|||||||
%include "error_codes.inc"
|
%include "error_codes.inc"
|
||||||
%include "partition_table.inc"
|
%include "partition_table.inc"
|
||||||
|
|
||||||
; ###############
|
ALIGN 4
|
||||||
; End Section
|
|
||||||
; ###############
|
|
||||||
|
|
||||||
ALIGN 4, db 0x90
|
|
||||||
init:
|
init:
|
||||||
cli ; We do not want to be interrupted
|
cli ; We do not want to be interrupted
|
||||||
|
|
||||||
@@ -69,23 +62,15 @@ init:
|
|||||||
jmp 0:main
|
jmp 0:main
|
||||||
|
|
||||||
; ###############
|
; ###############
|
||||||
;
|
|
||||||
; Extra/Shared Functions
|
; Extra/Shared Functions
|
||||||
;
|
|
||||||
; ###############
|
; ###############
|
||||||
|
|
||||||
%include "util/kmem_func.nasm"
|
%include "util/kmem_func.nasm"
|
||||||
%include "util/error_func.nasm"
|
%include "util/error_func.nasm"
|
||||||
|
|
||||||
; ###############
|
|
||||||
; End Section
|
|
||||||
; ###############
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; bp - 2 : uint8_t boot_drive
|
; bp - 2 : uint8_t boot_drive
|
||||||
; bp - 4 : uint16_t part_offset
|
; bp - 4 : uint16_t part_offset
|
||||||
;
|
|
||||||
|
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
main:
|
main:
|
||||||
mov byte [bp - 2], dl ; BIOS passes drive number in DL
|
mov byte [bp - 2], dl ; BIOS passes drive number in DL
|
||||||
@@ -158,7 +143,7 @@ main:
|
|||||||
|
|
||||||
mov si, word [bp - 4]
|
mov si, word [bp - 4]
|
||||||
mov dl, byte [bp - 2]
|
mov dl, byte [bp - 2]
|
||||||
jmp 0:0x7C00
|
jmp word 0x0000:0x7C00
|
||||||
|
|
||||||
; ###############
|
; ###############
|
||||||
;
|
;
|
||||||
@@ -168,10 +153,6 @@ main:
|
|||||||
|
|
||||||
%include 'BIOS/func/ext_read.nasm'
|
%include 'BIOS/func/ext_read.nasm'
|
||||||
|
|
||||||
; ###############
|
|
||||||
; End Section
|
|
||||||
; ###############
|
|
||||||
|
|
||||||
%assign bytes_remaining (440 - ($ - $$))
|
%assign bytes_remaining (440 - ($ - $$))
|
||||||
%warning MBR has bytes_remaining bytes remaining for code (MAX: 440 bytes)
|
%warning MBR has bytes_remaining bytes remaining for code (MAX: 440 bytes)
|
||||||
times ((512 - 72) - ($ - $$)) nop ; Fill the rest of sector with nop
|
times ((512 - 72) - ($ - $$)) nop ; Fill the rest of sector with nop
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
[WARNING -reloc-abs-word]
|
[WARNING -reloc-abs-word]
|
||||||
[map all vbr.map] ; Yes, we use absolute addresses. surpress these warnings.
|
[map all vbr.map] ; Yes, we use absolute addresses. surpress these warnings.
|
||||||
%define __STEVIA_VBR
|
%define __STEVIA_VBR
|
||||||
|
section .text
|
||||||
__ENTRY:
|
__ENTRY:
|
||||||
jmp short (init - $$)
|
jmp short (init - $$)
|
||||||
nop
|
nop
|
||||||
@@ -51,11 +51,8 @@ times 54 db 0x00
|
|||||||
%include "error_codes.inc"
|
%include "error_codes.inc"
|
||||||
%include "fat32/bpb_offset_bx.inc"
|
%include "fat32/bpb_offset_bx.inc"
|
||||||
|
|
||||||
; ###############
|
|
||||||
; End Section
|
|
||||||
; ###############
|
|
||||||
|
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4
|
||||||
init:
|
init:
|
||||||
cli ; We do not want to be interrupted
|
cli ; We do not want to be interrupted
|
||||||
|
|
||||||
@@ -85,6 +82,9 @@ init:
|
|||||||
; End Section
|
; End Section
|
||||||
; ###############
|
; ###############
|
||||||
|
|
||||||
|
;
|
||||||
|
; byte boot_drive @ bp - 2
|
||||||
|
; word part_offset @ bp - 4
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
main:
|
main:
|
||||||
mov byte [bp - 2], dl ; boot_drive
|
mov byte [bp - 2], dl ; boot_drive
|
||||||
@@ -101,7 +101,7 @@ main:
|
|||||||
push ax
|
push ax
|
||||||
mov ax, fat32_bpb ; defined in memory.inc, destination
|
mov ax, fat32_bpb ; defined in memory.inc, destination
|
||||||
push ax
|
push ax
|
||||||
call kmemcpy ; copy bpb to memory
|
call kmemcpy ; copy bpb & ebpb to memory
|
||||||
add sp, 0x6
|
add sp, 0x6
|
||||||
|
|
||||||
mov bx, fat32_bpb ; bx now points to aligned memory structure
|
mov bx, fat32_bpb ; bx now points to aligned memory structure
|
||||||
@@ -130,6 +130,8 @@ main:
|
|||||||
add sp, 0xC
|
add sp, 0xC
|
||||||
|
|
||||||
.check_sig:
|
.check_sig:
|
||||||
|
; BUG: this is hard coded to check @ ((0x7E0 << 4) + 0x7FFC)...i.e (STAGE2_ENTRY + (STAGE2_MAX_BYTES - 4))
|
||||||
|
; this should be removed or done properly
|
||||||
mov ax, 0x7E0
|
mov ax, 0x7E0
|
||||||
mov fs, ax
|
mov fs, ax
|
||||||
cmp dword [fs:0x7FFC], 0xDEADBEEF
|
cmp dword [fs:0x7FFC], 0xDEADBEEF
|
||||||
@@ -140,7 +142,7 @@ main:
|
|||||||
.sig_ok:
|
.sig_ok:
|
||||||
mov si, word [bp - 4]
|
mov si, word [bp - 4]
|
||||||
mov dl, byte [bp - 2]
|
mov dl, byte [bp - 2]
|
||||||
jmp 0:0x7E00
|
jmp word 0x0000:0x7E00
|
||||||
|
|
||||||
; ###############
|
; ###############
|
||||||
; Required BIOS function(s)
|
; Required BIOS function(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user