diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-09-04 23:38:33 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-09-04 23:38:33 +0200 |
| commit | 467e19b262d435f1820539bc0c85ed4fa31b9687 (patch) | |
| tree | c3ee7690b089713614309857ecfc046d6a13d160 /boot/mbr.asm | |
| parent | 487ecc1615ccc0368f1520c1146b2b43cdab6577 (diff) | |
Finally we have a 2 stage bootloader !
This one can load the ramdis up to 0xfffff :)
Diffstat (limited to 'boot/mbr.asm')
| -rw-r--r-- | boot/mbr.asm | 178 |
1 files changed, 0 insertions, 178 deletions
diff --git a/boot/mbr.asm b/boot/mbr.asm deleted file mode 100644 index a854615..0000000 --- a/boot/mbr.asm +++ /dev/null @@ -1,178 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; THE FOOL-BOOT-LOADER -; -; So we have just been loaded by the BIOS and are in 16-bits real mode! -; Now the following work will bee accomplished (chronologically): -; -; NOTE: this should not exceed 446 bytes -; (otherwise it does not work on my Acer Aspire) -; -; * BOOT_DRIVE set -; -; * X sectors of our kernel loaded at KERNEL_OFFSET from floppy -; -; * memory map made available at MEMMAP_OFFSET -; (check at MEMMEP_SIZE_OFFSET for number of entries) -; -; * the VESA mode specified by VESA_MODE_SELECT will be set up -; (check at VESA_MODES, and VESA_MODE_INFO -; for additional information) -; -; * interrupts disabled -; -; * 32-bit protected mode set up. -; -; * esp set to 0x90000 -; -; * A20 gate opened -; -; * and finally we will jump into the C world to kernel_main() ! -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -;we want 16-bit instructions, before we switch to 32-bit protected mode. -[bits 16] - -;define origin of boot record in memory: 0x7c00 -;this is where the BIOS per definition will put the first -;512 bytes of data from the boot device -;The Boot record is identified by the last 2 magic bytes: 0xaa55 (?) -[org 0x7c00] - -;;define some constants -;;where we will load our kernel into memory and some -;;other memory locations -; -KERNEL_SECTOR equ 0x1000 -KERNEL_OFFSET equ 0x0000 - -MEMMAP_SIZE_OFFSET equ 0x7c00+0x600 -MEMMAP_OFFSET equ 0x7c00+0x400 -VESA_MODES equ 0x8300 -VESA_MODE_INFO equ 0x8400 -VESA_MODE_SELECT equ 0x4114 - -; -jmp boot_16 ;start boot process - db 'X' -jmp $ ;entry for other processors ;) - db 'X' -; -;;SOME Global Data, mainly info/error strings -BOOT_DRIVE: - db 0xff -STR_VERSION: - db "v0.5",0 -VESA_CHECK1: - db "1",0 -VESA_CHECK2: - db "2",0 -VESA_CHECK3: - db "3",0 -CHECK_A20: - db "A",0 -; -;;lets put our temporary GDT (Global Descriptor Table) here -;;kernel should move this away -%include "boot/GDT.asm" -; -;;include 16-bit real mode routines (print_string, disk_load, vesa_setup,check_a20) -%include "boot/disk_load_16.asm" -;%include "boot/check_a20_16.asm" -%include "boot/print_string_16.asm" -%include "boot/vesa_setup_16.asm" -; -;;include our routines for switching to 32-bit protected mode -%include "boot/pm.asm" -; -; -;;get memory map routine -%include "boot/memmap.asm" -; -;;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -;;lets start -[bits 16] -; -boot_16: - - - - ;first of allsetup the stack (Right under mbr) - ;guaranteed ~30KB space - mov bp,0x07bff - mov sp,bp -; -; - mov bx, STR_VERSION - call print_string -; -; ;remember BOOT_DRIVE (as was set by BIOS) - mov [BOOT_DRIVE],dl - -; ;Load the IMAGE - call disk_load_16 - -; -; ;get memory map from bios before we enter 32 bit protected mode - mov ax,0 ; set target address in es:di (0:offset) - mov es,ax - mov di,MEMMAP_OFFSET - call BiosGetMemoryMap ; this will also put the number of entries -; ; of the memory map at MEMMAP_SIZE_OFFSET - -;a20check: -; -; mov bx, CHECK_A20 -; call print_string -; -; call check_a20 -; cmp ax,0 -; je a20check ;hang if a20 is disabled! - -; ;VESA: also setup vesa stuff before entering 32 bit protected mode -; call VesaSetup -; -; ;finally lets enter Protected mode!!! - call switch_to_pm -; -;;;;;;;;; BOOT 32-bit protected mode;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -[bits 32] -boot_32_pm: -; - -; ;enable A20 -; ;http://www.brokenthorn.com/Resources/OSDev9.html -; ;Method 3.1: Enables A20 through keyboard controller -; ;Not all keyboard controllers support this -; ; does not work in virtual box (with VT-x accerleration?) - -; mov al, 0xdd ; command 0xdd: enable a20 -; mov al, 0xdf ; command 0xdf: disable a20 -; out 0x64, al ; send command to controller - - ;Fast A20 Gate: - ;http://wiki.osdev.org/A20_Line - - in al, 0x92 - or al, 2 - out 0x92, al - - ; call kernel! - mov eax,0 ;booting processor - call 0x10000 ;KERNEL_SECTOR:KERNEL_OFFSET ;jump into our Kernel! -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; - -;fill partition table (4x16byte) with zeroes. -;(otherwise my Acer Aspire will not boot) -;times 64 db 0x0 - -;so we get identified as MBR -times 510-($-$$) db 0x0 -;dw 0x0 -dw 0xaa55 - |
