Compare commits
2 Commits
d5cd8d6c45
...
507a05949f
| Author | SHA1 | Date | |
|---|---|---|---|
| 507a05949f | |||
| caed66a243 |
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
%ifndef __INC_ENTRY
|
%ifndef __INC_ENTRY
|
||||||
|
|
||||||
%define MBR_ENTRY 0x8C00
|
%define MBR_ENTRY 0x6C00
|
||||||
%define VBR_ENTRY 0x7C00
|
%define VBR_ENTRY 0x7C00
|
||||||
%define STAGE2_ENTRY 0x0500
|
%define STAGE2_ENTRY 0x0500
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
[BITS 16]
|
[BITS 16]
|
||||||
[ORG 0x8C00]
|
[ORG 0x6C00]
|
||||||
[CPU KATMAI]
|
[CPU KATMAI]
|
||||||
[WARNING -reloc-abs-byte]
|
[WARNING -reloc-abs-byte]
|
||||||
[WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings.
|
[WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings.
|
||||||
@@ -36,6 +36,7 @@ nop
|
|||||||
|
|
||||||
%undef __STEVIA_DEV_DEBUG
|
%undef __STEVIA_DEV_DEBUG
|
||||||
|
|
||||||
|
; BIOS will load 1st sector of boot drive to 0x7c00, init and relocate
|
||||||
ALIGN 4
|
ALIGN 4
|
||||||
init:
|
init:
|
||||||
cli ; We do not want to be interrupted
|
cli ; We do not want to be interrupted
|
||||||
@@ -64,7 +65,7 @@ init:
|
|||||||
mov ch, 0x02 ; 0x0200 in cx
|
mov ch, 0x02 ; 0x0200 in cx
|
||||||
mov si, 0x7C00 ; Current MBR Address (loaded here by BIOS)
|
mov si, 0x7C00 ; Current MBR Address (loaded here by BIOS)
|
||||||
mov di, MBR_ENTRY ; New MBR Address (our new relocation address)
|
mov di, MBR_ENTRY ; New MBR Address (our new relocation address)
|
||||||
rep movsb ; copy 512 bytes from 0x0000:7c00 to 0x0000:MBR_ENTRY (7A00 as of writing)
|
rep movsb ; copy 512 bytes from 0x0000:7c00 to 0x0000:MBR_ENTRY (6C00 as of writing)
|
||||||
|
|
||||||
sti
|
sti
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ main:
|
|||||||
mov dword eax, dword [bx + PartEntry_t.lba_start]
|
mov dword eax, dword [bx + PartEntry_t.lba_start]
|
||||||
push dword eax ; lba (4)
|
push dword eax ; lba (4)
|
||||||
|
|
||||||
push word VBR_ENTRY ; offset = 0x7c00 (2)
|
push word 0x7C00 ; offset = 0x7c00 (2)
|
||||||
push 0x00 ; segment = 0 (2)
|
push 0x00 ; segment = 0 (2)
|
||||||
|
|
||||||
; 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,
|
||||||
@@ -176,7 +177,7 @@ PartEntry4:
|
|||||||
times 16 db 0x00
|
times 16 db 0x00
|
||||||
BootSig:
|
BootSig:
|
||||||
dw 0xAA55 ; Add boot signature at the end of bootloader
|
dw 0xAA55 ; Add boot signature at the end of bootloader
|
||||||
|
; !!! end of MBR !!!
|
||||||
section .bss follows=.text
|
section .bss follows=.text
|
||||||
begin_bss:
|
begin_bss:
|
||||||
|
|
||||||
|
|||||||
@@ -430,11 +430,11 @@ BUILD_GIT_HASH:
|
|||||||
db __GIT_HASH__, 00h
|
db __GIT_HASH__, 00h
|
||||||
end_data:
|
end_data:
|
||||||
|
|
||||||
%assign bytes_remaining ((MAX_STAGE2_BYTES - 4) - (($ - $$) + (end_text - begin_text)))
|
%assign bytes_remaining ((MAX_STAGE2_BYTES - 512) - (($ - $$) + (end_text - begin_text)))
|
||||||
%warning STAGE2 has bytes_remaining bytes remaining for code/data (MAX: MAX_STAGE2_BYTES)
|
%warning STAGE2 has bytes_remaining bytes remaining for code/data (MAX: MAX_STAGE2_BYTES)
|
||||||
|
|
||||||
; 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 0x7E00 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
|
||||||
|
|||||||
Reference in New Issue
Block a user