loading ELF

This commit is contained in:
notsomeidiot123 2024-10-08 13:16:24 -04:00
parent ba550f2f07
commit 7d6b3a7b67
1 changed files with 14 additions and 6 deletions

View File

@ -308,7 +308,7 @@ part_2:
mov edi, kload_paddr mov edi, kload_paddr
call read_file call read_file
jc load_fail jc load_fail
; debug
mov esi, kload_paddr mov esi, kload_paddr
call load_elf call load_elf
@ -478,6 +478,7 @@ read_file:
; mov [DAP.segment], di ; mov [DAP.segment], di
; pop edi ; pop edi
; mov [DAP.offset], di ; mov [DAP.offset], di
; jmp $
mov word [DAP.segment], 0 mov word [DAP.segment], 0
mov word [DAP.offset], file_buffer mov word [DAP.offset], file_buffer
@ -495,19 +496,22 @@ read_file:
xor ecx, ecx xor ecx, ecx
mov cx, [fat_bpb.bytes_per_sector] mov cx, [fat_bpb.bytes_per_sector]
mul ecx mul ecx
; push eax
mov esi, file_buffer mov esi, file_buffer
mov ebx, eax mov ebx, eax
call mmove call mmove
; debug
pop esi pop esi
call read_fat call read_fat
; jmp $
; debug
cmp eax, 0xffffffff cmp eax, 0xffffffff
je .exit_success je .exit_success
; jmp $
add edi, eax mov esi, eax
add edi, ebx
jmp read_file jmp read_file
.exit_err: .exit_err:
@ -517,6 +521,7 @@ read_file:
.exit_success: .exit_success:
mov eax, 0 mov eax, 0
clc clc
; debug
ret ret
jmp $ jmp $
@ -585,12 +590,14 @@ mmove:
;esi = src ;esi = src
;edi = dest ;edi = dest
;ebx = count ;ebx = count
; jmp $
push eax push eax
push ecx push ecx
; debug ; debug
xor ecx, ecx xor ecx, ecx
.mlp: .mlp:
; jmp $
cmp ecx, ebx cmp ecx, ebx
jge .ret jge .ret
mov al, [ds:esi + ecx] mov al, [ds:esi + ecx]
@ -601,12 +608,13 @@ mmove:
; debug ; debug
pop ecx pop ecx
pop eax pop eax
; jmp $
ret ret
load_elf: load_elf:
;parse elf and relocate each section to it's appropriate location ;parse elf and relocate each section to it's appropriate location
;esi: address of loaded kernel; ;esi: address of loaded kernel;
debug
;kernel info ;kernel info
k_info: k_info:
.memory_map_ptr: dd 0x2000 .memory_map_ptr: dd 0x2000