Nyanix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit e01bb116a7ac98ab4ee5e93a346be5c934400096
parent ec78209dfde3d806de2339a661a06ccf2e13af3e
Author: Dani Frisk <dani@silverskin.fi>
Date:   Mon, 27 Aug 2018 12:12:28 +0300

Kernel load from 0x10000 works.

Diffstat:
src/boot_early/second_stage.s | 3++-
src/main/main_loader.s | 31++++++++++++++++++-------------
2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/boot_early/second_stage.s b/src/boot_early/second_stage.s @@ -38,7 +38,7 @@ msg_panic db "[!] Panic: ", 0 ; =========================================================================== ; ; boot device backup ; ; =========================================================================== ; -boot_device_db db 0 +boot_device_db db 0, 0 ; =========================================================================== ; ; Main function of second stage entry. ; @@ -47,6 +47,7 @@ main: xor ebp, ebp mov esp, 0x9c00 + xor eax, eax mov al, [BOOT_DEVICE] mov [boot_device_db], al diff --git a/src/main/main_loader.s b/src/main/main_loader.s @@ -13,6 +13,8 @@ %ifndef __LOADER_MAIN_S__ %define __LOADER_MAIN_S__ 1 +%include "src/drivers/framebuffer.s" + ; Kernel entry signature: ; ; bytes 0 - 7 : "Nyan_hed" @@ -34,11 +36,14 @@ main_loader: push ebp mov ebp, esp + xor eax, eax + xor ebx, ebx + xor ecx, ecx ; loading 1 sector from 0x10000 -> ; to see if we have a valid kernel at disk. mov eax, kernel_entry_address mov byte [kernel_sector_count], 1 - mov bl, boot_device_db + mov bl, byte [boot_device_db] mov cl, 1 call load_sectors @@ -55,9 +60,9 @@ main_loader: pop ebp ret -.fail: - mov esi, msg_kernel_not_found - call panic + .fail: + mov esi, msg_kernel_not_found + call panic msg_kernel_not_found db "Kernel not found.", 0x0A, 0 @@ -87,7 +92,7 @@ load_sectors: mov cl, 0x02 xor eax, eax .read_start: - mov di, 5 + mov di, 15 .read: mov ah, 0x02 mov al, [.sectors_left] @@ -143,19 +148,19 @@ search_kernel_header: ; we found the header :) add ecx, 8 ; stepping over kenrel_entry_signature. - xor ebx, ebx mov bx, word [eax + ecx] add ecx, 3 add eax, ecx jmp .ret -.not_found: - xor ebx, ebx - xor eax, eax -.ret: - mov esp, ebp - pop ebp - ret + + .not_found: + xor ebx, ebx + xor eax, eax + .ret: + mov esp, ebp + pop ebp + ret %endif