cap bss, clean up some padding issues and clean up sign section
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
%ifndef __INC_STEVIA_CONFIG
|
%ifndef __INC_STEVIA_CONFIG
|
||||||
|
|
||||||
%define SECTOR_SIZE 512
|
%define SECTOR_SIZE 0x200
|
||||||
%define STAGE2_SECTOR_COUNT 0x20
|
%define STAGE2_SECTOR_COUNT 0x20
|
||||||
; 16 KiB
|
; 16 KiB
|
||||||
%define MAX_STAGE2_BYTES (SECTOR_SIZE * STAGE2_SECTOR_COUNT)
|
%define MAX_STAGE2_BYTES (SECTOR_SIZE * STAGE2_SECTOR_COUNT)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
section .text
|
section .text
|
||||||
begin_text:
|
begin_text:
|
||||||
; dl = byte boot_drive
|
; dl = byte boot_drive
|
||||||
ALIGN 4, db 0x90
|
ALIGN 16, db 0x90
|
||||||
init:
|
init:
|
||||||
cli ; We do not want to be interrupted
|
cli ; We do not want to be interrupted
|
||||||
mov [boot_drive], dl ; copy boot_drive to globals
|
mov [boot_drive], dl ; copy boot_drive to globals
|
||||||
@@ -375,7 +375,8 @@ EnterUnrealMode:
|
|||||||
end_text:
|
end_text:
|
||||||
|
|
||||||
section .data follows=.text
|
section .data follows=.text
|
||||||
align 512
|
align 16, db 0
|
||||||
|
|
||||||
begin_data:
|
begin_data:
|
||||||
; #############
|
; #############
|
||||||
;
|
;
|
||||||
@@ -410,19 +411,15 @@ define_info MaybeFound_Boot, "Maybe found a file...checking..."
|
|||||||
|
|
||||||
define_cstr BootTarget, "BOOT BIN"
|
define_cstr BootTarget, "BOOT BIN"
|
||||||
|
|
||||||
align 16, db 0
|
|
||||||
BootTarget:
|
|
||||||
db 'BOOT BIN'
|
|
||||||
|
|
||||||
;
|
|
||||||
; pre-bss init globals
|
|
||||||
;
|
|
||||||
|
|
||||||
; set to boot_drive passed from BIOS almost first thing in init
|
; set to boot_drive passed from BIOS almost first thing in init
|
||||||
align 4, db 0
|
align 4, db 0
|
||||||
boot_drive:
|
boot_drive:
|
||||||
db 0x00
|
db 0x00
|
||||||
|
|
||||||
|
align 16, db 0
|
||||||
|
BootTarget:
|
||||||
|
db 'BOOT BIN'
|
||||||
|
|
||||||
align 16, db 0
|
align 16, db 0
|
||||||
IntToHex_table:
|
IntToHex_table:
|
||||||
db '0123456789ABCDEF'
|
db '0123456789ABCDEF'
|
||||||
@@ -504,15 +501,20 @@ BUILD_GIT_HASH:
|
|||||||
db __GIT_HASH__, 00h
|
db __GIT_HASH__, 00h
|
||||||
end_data:
|
end_data:
|
||||||
|
|
||||||
%assign bytes_remaining ((MAX_STAGE2_BYTES - 512) - (($ - $$) + (end_text - begin_text)))
|
%define SIG_BYTES 0x4
|
||||||
%warning STAGE2 has bytes_remaining bytes remaining for code/data (MAX: MAX_STAGE2_BYTES)
|
|
||||||
|
; Optional: fail fast if we overflowed
|
||||||
|
%if ((MAX_STAGE2_BYTES - 512) - (($ - $$) + (end_text - begin_text))) < 0
|
||||||
|
%error "Stage2 overflow: code+data exceed MAX_STAGE2_BYTES - SIG_BYTES"
|
||||||
|
%endif
|
||||||
|
|
||||||
; section start location needs to be a 'critical expression'
|
; section start location needs to be a 'critical expression'
|
||||||
; i.e resolvable at build time, we are setting 0x0500 as the offset since
|
; i.e resolvable at build time, we are setting 0x0500 as the offset since
|
||||||
section .sign start=((MAX_STAGE2_BYTES - 512) + 0x0500)
|
section .sign start=((MAX_STAGE2_BYTES - 512) + 0x0500)
|
||||||
times ((512 - 4) - ($ -$$) ) db 0x90 ; nop
|
times ((512 - 4) - ($ -$$) ) db 0x90 ; nop
|
||||||
STAGE2_SIG: dd 0xDEADBEEF ; Signature to mark the end of the stage2
|
STAGE2_SIG: dd 0xDEADBEEF ; Signature to mark the end of the stage2
|
||||||
|
; !!! END Stage2 .text/.data !!!
|
||||||
|
align 16, resb 1
|
||||||
section .bss follows=.sign
|
section .bss follows=.sign
|
||||||
begin_bss:
|
begin_bss:
|
||||||
|
|
||||||
@@ -595,4 +597,12 @@ align 16, resb 1
|
|||||||
stack_bottom:
|
stack_bottom:
|
||||||
resb 1024
|
resb 1024
|
||||||
stack_top:
|
stack_top:
|
||||||
end_bss:
|
end_bss:
|
||||||
|
|
||||||
|
; Pad to the cap (emits nothing in the file; only increases .bss virtual size).
|
||||||
|
; If BSS_SIZE > BSS_MAX_BYTES, this becomes negative and NASM errors out.
|
||||||
|
%define BSS_MAX_BYTES 0x3000
|
||||||
|
resb (BSS_MAX_BYTES - (end_bss - begin_bss))
|
||||||
|
|
||||||
|
; Optional: keep a label for later math:
|
||||||
|
bss_cap_end:
|
||||||
Reference in New Issue
Block a user