Nyanix

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

commit b03518967468038d2cd74088a8785715f94deb66
parent 196c66ddc72a144e5fabee3480b7854c7a2157a9
Author: Dani Frisk <dani@silverskin.fi>
Date:   Thu,  1 Nov 2018 17:28:54 +0200

15-sector kernel load & relocate to 0x10000 added

Diffstat:
src/main/main_loader.s | 66++++++++++++++----------------------------------------------------
1 file changed, 14 insertions(+), 52 deletions(-)

diff --git a/src/main/main_loader.s b/src/main/main_loader.s @@ -39,26 +39,27 @@ main_loader: 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 byte [kernel_sector_count], 15 mov bl, byte [boot_device_db] mov cl, 1 call load_sectors - mov eax, 0x10000 - call search_kernel_header - cmp eax, 0 - je .fail - mov eax, 0xbeef - cli - hlt + ; relocate kernel to address 0x10000 + mov esi, kernel_entry_address + mov edi, 0x10000 + mov ecx, (1024 * 15) + + .relocate_loop: + mov al, byte [esi+ecx] + mov byte [edi+ecx], al + loop .relocate_loop + + mov al, byte [esi] + mov byte [edi], al + jmp edi - mov esp, ebp - pop ebp - ret .fail: mov esi, msg_kernel_not_found @@ -123,44 +124,5 @@ load_sectors: .sectors_left db 0 -; Function to find kernel header. -; kernel entrypoint address at EAX -; Returns: -; code entry: EAX -; sector count: EBX -; on success or : -; EAX = 0, EBX = 0 -; on error. -search_kernel_header: - push ebp - mov ebp, esp - - xor ecx, ecx - xor edx, edx - mov esi, kernel_entry_signature - .search_loop: - inc ecx - cmp ecx, 0xff - jge .not_found - mov edx, dword [eax + ecx] - cmp edx, dword [esi] - jne .search_loop - - ; 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 - %endif