summaryrefslogtreecommitdiff
path: root/boot/mbr16.asm
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-08-27 03:20:16 +0200
committerMichal Idziorek <m.i@gmx.at>2014-08-27 03:20:16 +0200
commit50c7bdbe826b5b425748a11273d14e3aed2ce851 (patch)
tree8fc2bec5576aad366b6f9f3f1fcc406f6a3eeb33 /boot/mbr16.asm
parentfc7022286a14e7325907fb4e77aa44330037229b (diff)
many changes and adaptions and VESA mode !!
Diffstat (limited to 'boot/mbr16.asm')
-rw-r--r--boot/mbr16.asm79
1 files changed, 79 insertions, 0 deletions
diff --git a/boot/mbr16.asm b/boot/mbr16.asm
new file mode 100644
index 0000000..1abc97d
--- /dev/null
+++ b/boot/mbr16.asm
@@ -0,0 +1,79 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; FoolOS Boot Loader for 16bit entry in C
+;
+; Copyright 2014 M.Idziorek <m.i@gmx.at>
+;
+; we have just been loaded by the BIOS and are in 16-bits real mode!
+;
+; THIS IS THE CENTRAL FILE OF THE 16bit BOOTLOADER, after we finished we
+; are inside 16bit C code!
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;we want 16-bit instructions, before we switch to 32-bit protected mode.
+
+;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 where we will load our "C binary"
+BOOT_OFFSET equ 0x1000
+
+[bits 16]
+jmp boot_16 ;start boot process
+
+BOOT_DRIVE:
+ db 0xff
+
+;SOME Global Data, mainly strings
+STR_VERSION:
+ db "~ Fool Loader 16-bit, v0.1 ~",0
+
+;include 16-bit real mode routines (print_string, print_hex, disk_load)
+%include "boot/common.asm"
+%include "boot/print16.asm"
+
+;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;lets start
+
+boot_16:
+
+ ;print version info
+ mov bx, STR_VERSION
+ call print_string
+
+ ;setup the stack
+ mov bp,0x8000
+ mov sp,bp
+
+ ;remember BOOT_DRIVE (as was set by BIOS)
+ mov [BOOT_DRIVE],dl
+
+ ;Load BOOT LOADER from second sector (max 50 sectors)
+ mov bx,BOOT_OFFSET ;destination in ram
+ mov dh, 50 ;50 sectors
+ mov dl, [BOOT_DRIVE] ;source drive
+ call disk_load
+
+ call BOOT_OFFSET ;jump into our C code
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;so we get identified as MBR
+times 510-($-$$) db 0
+dw 0xaa55
+
+;interrupt descriptor table (hardcoded address of interrupts:)
+;idt_start:
+;times 33 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;db 0x59,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;times 253 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;idt_end:
+
+
+
+