load remaining boot1 sectors
This commit is contained in:
1 parent
76c6d5c355
commit
592826e8cd
4 files changed
+302
-47
No files matched your search
@@ -3,7 +3,8 @@
|
||||
; --------------------------------------------------------------------
|
||||
; R | 0x000000 - 0x000400: real-mode interrupt vector table
|
||||
; R | 0x000400 - 0x000500: bios data area
|
||||
; U | 0x000500 - 0x007c00: stack
|
||||
; U | 0x000500 - 0x007000: stack
|
||||
; U | 0x007000 - 0x007c00: globals
|
||||
; U | 0x007c00 - 0x007e00: boot sector
|
||||
; U | 0x007e00 - 0x080000: conventional usable memory
|
||||
; R | 0x080000 - 0x0a0000: extended bios data area (maximum possible size)
|
||||
@@ -12,33 +13,12 @@
|
||||
; R | 0x0c8000 - 0x0f0000: bios expansiosn
|
||||
; R | 0x0f0000 - 0x100000: motherboard bios
|
||||
|
||||
; BIOS puts our boot sector at 0000:7c00
|
||||
org 0x7c00
|
||||
; We're (probably) in real mode
|
||||
bits 16
|
||||
%include "defines.s"
|
||||
|
||||
; BASE STACK FRAME VARIABLE OFFSETS
|
||||
; --------------------------------------------------------------------
|
||||
; The boot drive number given to us by the BIOS.
|
||||
BOOT_DRIVE equ 0x02
|
||||
; Boot drive geometry
|
||||
SECTORS_PER_TRACK equ 0x04
|
||||
N_HEADS equ 0x06
|
||||
; Starting LBA of the GPT partition entries array.
|
||||
GPT_ENTRIES_START_LBA equ 0x08
|
||||
; Number of GPT entries, saturated to 16 bits.
|
||||
GPT_N_ENTRIES_16 equ 0x0a
|
||||
; Number of sectors to advance by once we've read every GPT entry in the current sector.
|
||||
GPT_SECTOR_STRIDE equ 0x0c
|
||||
; Number of bytes to advance by in the current sector once we've read a GPT entry.
|
||||
GPT_BYTE_STRIDE equ 0x0e
|
||||
; Number of GPT entries which can fit in a single sector.
|
||||
GPT_ENTRIES_PER_SECTOR equ 0x10
|
||||
GPT_CURRENT_ENTRY_IDX equ 0x12
|
||||
GPT_SECTOR_ENTRY_IDX equ 0x14
|
||||
GPT_SECTORS_LOADED equ 0x16
|
||||
GPT_CURRENT_LBA equ 0x18
|
||||
STAGE2_GPT_ENTRY_ADDR equ 0x1a
|
||||
; BIOS puts our boot sector at 0000:7c00
|
||||
[org BOOT0_LOADPOINT]
|
||||
; We're (probably) in real mode
|
||||
[bits 16]
|
||||
|
||||
main:
|
||||
; Disable interrupts
|
||||
@@ -49,10 +29,10 @@ main:
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
; Put the stack base at 0x7c00.
|
||||
; Stack grows high->low, so we'll grow away from our program text at 0x7c00.
|
||||
; Put the stack base at 0x7000.
|
||||
; Stack grows high->low, so we'll grow away from our globals and program text.
|
||||
mov ss, ax
|
||||
mov bp, 0x7c00
|
||||
mov bp, STACK_BASE
|
||||
mov sp, bp
|
||||
|
||||
; Segment for VGA (0xb800 * 16 = 0xb8000)
|
||||
@@ -237,7 +217,7 @@ main:
|
||||
ja panic
|
||||
.stage2_end_lba_ok:
|
||||
|
||||
mov bx, 0x8200
|
||||
mov bx, BOOT1_LOADPOINT
|
||||
call read_lba
|
||||
jmp bx
|
||||
|
||||
@@ -252,8 +232,6 @@ read_lba:
|
||||
; head = temp % n_heads
|
||||
; cylinder = temp / n_heads
|
||||
xor dx, dx
|
||||
; FIXME: we should probably get our globals from somewhere else, in case we want to change bp for
|
||||
; a function call
|
||||
; Divide by sectors per track. dx = mod (sector - 1), ax = div (temp)
|
||||
div word [bp - SECTORS_PER_TRACK]
|
||||
; Put the sector into cx (the bios call will use cl)
|
||||
|
||||
Reference in new issue
Block a user