summaryrefslogtreecommitdiff
path: root/boot/mbr.asm
diff options
context:
space:
mode:
Diffstat (limited to 'boot/mbr.asm')
-rw-r--r--boot/mbr.asm99
1 files changed, 55 insertions, 44 deletions
diff --git a/boot/mbr.asm b/boot/mbr.asm
index 3406b55..32f1a6f 100644
--- a/boot/mbr.asm
+++ b/boot/mbr.asm
@@ -21,6 +21,12 @@
;define where we will load our kernel into memory
KERNEL_OFFSET equ 0x1000
+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
+;VESA_MODE_SELECT equ 0x411A
[bits 16]
jmp boot_16 ;start boot process
@@ -32,6 +38,9 @@ BOOT_DRIVE:
STR_VERSION:
db "v0.2~",0
+VESA_CHECK:
+ db "vesa check.",0
+
;STR_PROT:
; db "32-bit PM",0
;STR_LOADED:
@@ -40,8 +49,9 @@ STR_VERSION:
;lets put our temporary GDT (Global Descriptor Table) here
%include "boot/GDT.asm"
-;include 16-bit real mode routines (print_string, print_hex, disk_load)
+;include 16-bit real mode routines (print_string, disk_load)
%include "boot/common.asm"
+%include "boot/print16.asm"
;include 32-bit Protected Mode routines (print_string_pm,print_hex_pm)
;%include "boot/common_pm.asm"
@@ -60,35 +70,6 @@ STR_VERSION:
;lets start
[bits 16]
-;print_string routine ([bx])
-;this routine will print a null terminated string at [bx] to the screen.
-print_string:
-
- pusha ;push all registers
- mov ah,0x0e
-
- print_string_loop:
-
- ;check if value at [bx] is "\0" (end of string)
- mov cl,[bx]
- cmp cl,0
- je print_string_finish
-
- ;otherwise instruct BIOS to print the current char
- mov al,cl
- int 0x10
-
- ;proceed with next char
- inc bx
- jmp print_string_loop
-
- print_string_finish:
-
- popa ;pop all registers
- ret ;return to caller
-
-
-
boot_16:
mov bx, STR_VERSION
@@ -107,7 +88,7 @@ boot_16:
;Load the KERNEL
mov bx,KERNEL_OFFSET
- mov dh, 50
+ mov dh, 50 ;50 sectors!
mov dl, [BOOT_DRIVE]
call disk_load
@@ -116,11 +97,47 @@ boot_16:
; call print_string
- ;get memory map from biso before we enter 32 bit protected mode
- ; todo: how to set es!?!?
- ;mov es,0
- mov di,MEMMAP
- call BiosGetMemoryMap
+ ;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
+
+ ;get vesa modes!
+ mov ax,0 ; set target address in es:di (0:offset)
+ mov es,ax
+ mov di,VESA_MODES
+ mov ax,0x4f00 ;vesa function: Get Controller Info
+ int 0x10 ; call the interrupt to get the data from the bios!
+ vesa_err:
+ mov bx, VESA_CHECK
+ call print_string
+ cmp ax,0x004f
+ je vesa_ok
+ jmp vesa_err
+ vesa_ok:
+ ;
+
+ ;get info on mode of interest
+ mov ax,0 ; set target address in es:di (0:offset)
+ mov es,ax
+ mov di,VESA_MODE_INFO
+ mov ax,0x4f01 ;vesa function: Get Mode Info
+ mov cx,VESA_MODE_SELECT
+ int 0x10 ; call the interrupt to get the data from the bios!
+ vesa_err2:
+ mov bx, VESA_CHECK
+ call print_string
+ cmp ax,0x004f
+ je vesa_ok2
+ jmp vesa_err2
+ vesa_ok2:
+
+ ;finally switch to the mode of choice!
+ mov ax,0x4f02 ;vesa function: Set Mode
+ mov bx,VESA_MODE_SELECT
+ int 0x10
;finally lets enter Protected mode!!!
call switch_to_pm
@@ -129,7 +146,7 @@ boot_16:
[bits 32]
boot_32_pm:
-; we could do ALL This inside the kernel!!!
+; we could do ALL This inside the kernel!!!!!! TODO
;print info message that we are in protected mode!
; mov ecx,160
@@ -145,15 +162,8 @@ boot_32_pm:
;pic setup
call pic_setup
-
call KERNEL_OFFSET ;jump into our Kernel it
-db 'X'
-db 'X'
-MEMMAP:
-
-
-
;idt_descriptor:
; dw idt_end-idt_start-1
; dd KERNEL_OFFSET
@@ -166,6 +176,7 @@ MEMMAP:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;so we get identified as MBR
times 510-($-$$) db 0
dw 0xaa55