summaryrefslogtreecommitdiff
path: root/boot/stage2.asm
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-10-24 13:59:06 +0200
committerMichal Idziorek <m.i@gmx.at>2014-10-24 13:59:06 +0200
commit55b3af4989e7908472d1dbfb3fe1bdd6e43262e1 (patch)
tree98bc925761d5b75380b0f5e0d87f286d964d720f /boot/stage2.asm
parent831df8bcb2717442a41464533bacf0a58a4af0ce (diff)
moved kernel and ramimage to 0x100000 successfully
chs is broken however and only the first chunk seems to get loaded properly :(
Diffstat (limited to 'boot/stage2.asm')
-rw-r--r--boot/stage2.asm63
1 files changed, 43 insertions, 20 deletions
diff --git a/boot/stage2.asm b/boot/stage2.asm
index 3fde5c1..9dd00bc 100644
--- a/boot/stage2.asm
+++ b/boot/stage2.asm
@@ -47,8 +47,15 @@ VESA_MODE_SELECT equ 0x4114
jmp boot_16 ;start boot process
;;SOME Global Data, mainly info/error strings
+FILL:
+ times 32 db 0x66
+
BOOT_DRIVE:
db 0xff
+
+LOADER_TARGET:
+ dd 0x100000 ;here we will put our image
+
KERNEL_CHUNK:
dw 0x1
STR_VERSION:
@@ -124,13 +131,21 @@ boot_16:
call BiosGetMemoryMap ; this will also put the number of entries
; of the memory map at MEMMAP_SIZE_OFFSET
-kernel_load:
; Load the KERNEL Image
mov bx, STR_LOAD
call print_string
call print_nextline
+
+kernel_load:
+
call disk_load_16
+ ; init vesa on last iteration!
+ mov ax,[KERNEL_CHUNK]
+ cmp ax,0x5
+ jne skip_vesa_init
+ call VesaSetup
+ skip_vesa_init:
call switch_to_pm
;
@@ -140,53 +155,61 @@ boot_32_pm:
;Fast A20 Gate:
;http://wiki.osdev.org/A20_Line
-
in al, 0x92
or al, 2
out 0x92, al
-
; tell the world we are protected
- mov ebx,STR_PM
- mov ecx,2*23*80
- call print_string_pm
+ ;mov ebx,STR_PM
+ ;mov ecx,2*23*80
+ ;call print_string_pm
+
+ ;increment chunk number
+ mov ax,[KERNEL_CHUNK]
+ add ax,1
+ mov [KERNEL_CHUNK],ax
- push edx ; persist edx for some reason!?
+ ;check if all chunkgs loaded (hardcoded to 0x6 for a start)
+ cmp ax,0x6
+ je finish_load
+ ; show KERNEL CHUNK value
+ push edx ; persist edx for some reason!?
mov edx,0
mov dx,[KERNEL_CHUNK]
mov ecx,2*24*80
call print_hex_pm
+ pop edx
+ ; here we actually do copy the chunk into ext mem!
+ mov eax,[LOADER_TARGET]
+ mov ebx,0x18000
- ; here we should move the chunk away or stop the loop if everything loaded.
- mov ax,[KERNEL_CHUNK]
- add ax,1
- mov [KERNEL_CHUNK],ax
+ copy_next_byte:
- ; here we should copy the chunk into ext mem!
+ mov ecx,[ebx]
+ mov [eax],ecx
+ inc eax
+ inc ebx
+ cmp ebx, 0x90000
+ jne copy_next_byte
+ mov [LOADER_TARGET],eax ;persist next target address
; and now go back to real! (first 16bit protected!)
- cmp edx,0x20
- je finish_load
- pop edx
-
-
-
jmp CODE16_SEG:reinit_16
+
finish_load:
;
- call VesaSetup
; call kernel!
mov eax,0 ;tell the kernel
; we are the booting processor
- call 0x18000 ;jump into our Kernel!
+ call 0x100000 ;jump into our Kernel!
[bits 16]