Revert "relocating file during load to allow for use of more memory"

This reverts commit 24d85843ac.
This commit is contained in:
notsomeidiot123 2024-10-03 14:21:33 -04:00
parent 24d85843ac
commit 79a77ed150
5 changed files with 20 additions and 112 deletions

View File

@ -1,35 +0,0 @@
ENTRY(_start)
/* OUTPUT_FORMAT(elf32-i386) */
OUTPUT_FORMAT(binary)
OUTPUT(kernel.elf)
SEARCH_DIR(bin/kernel)
SECTIONS{
. = 0xc0000000;
.text : AT(ADDR(.text) - 0xc0000000){
_code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(ADDR(.data) - 0xc0000000){
_data = .;
*(.data)
}
.eh_frame : AT(ADDR(.eh_frame) - 0xc0000000){
_eh_frame = .;
*(.eh_frame)
. = ALIGN(4096);
}
.bss : AT(ADDR(.bss) - 0xc0000000){
_bss = .;
*(.bss)
*(.COMMON)
. = ALIGN(4096);
}
_end = .;
/DISCARD/ :
{
*(.comment)
}
}

View File

@ -1,14 +1,11 @@
CC := gcc
AS := nasm
CFLAGS := -c -mno-sse -mno-sse2 -mno-red-zone -ffreestanding -fno-pie -fno-stack-protector -mno-mmx
BL_ASFLAGS := -f bin
SRCS := $(wildcard src/kernel/*.c)
OBJS := $(patsubst src/kernel/%.c, bin/kernel/%.o, $(SRCS))
all: bootloader tools kernel
all: bootloader tools
cp bin/bootloader.bin image.bin
qemu-img resize -f raw image.bin 512M
./diskwrite -v kernel.elf -o image.bin
./diskwrite -v kernel.elf -o image.bin
qemu-system-i386 -hda image.bin --no-reboot --no-shutdown -m 32m -smp 2 -serial mon:stdio
tools:
@ -16,14 +13,6 @@ tools:
bootloader:
$(AS) src/bootloader/main.s $(BL_ASFLAGS) -o bin/bootloader.bin
kernel: $(OBJS)
nasm src/kernel/entry.s -o bin/kernel/entry.o -f elf32
ld -T linker.ld bin/kernel/entry.o -melf_i386
%.o: $(SRCS)
$(CC) $(CFLAGS) $< -o $@
init:
@mkdir mount
@mkdir bin

View File

@ -202,7 +202,7 @@ load_part2:
push 0
pop ds
mov si, DAP
; jmp $
int 0x13
jc load_fail
jmp part_2
@ -305,7 +305,7 @@ part_2:
mov edi, kernel_file
call open_file
mov esi, eax
mov edi, 0x10000
mov edi, file_buffer
call read_file
jc load_fail
@ -449,8 +449,9 @@ read_file:
xor edx, edx
mov eax, esi
mov cl, [fat_bpb.sectors_per_cluster]
; jmp $
mul ecx; eax = offset from file table
; jmp $
push eax
xor eax, eax
xor ecx, ecx
@ -470,13 +471,11 @@ read_file:
xor ecx, ecx
mov cl, [fat_bpb.sectors_per_cluster]
mov [DAP.read_count], cx
; push edi
; shr edi, 16
; mov [DAP.segment], di
; pop edi
; mov [DAP.offset], di
mov word [DAP.segment], 0
mov word [DAP.offset], file_buffer
push edi
shr edi, 16
mov [DAP.segment], di
pop edi
mov [DAP.offset], di
mov ah, 0x42
mov dl, [data.boot_disc]
@ -484,7 +483,11 @@ read_file:
int 0x13
jc .exit_err
; debug
pop esi
call read_fat
cmp eax, 0xffffffff
je .exit_success
; debug
xor eax, eax
mov al, [fat_bpb.sectors_per_cluster]
@ -493,17 +496,6 @@ read_file:
mov cx, [fat_bpb.bytes_per_sector]
mul ecx
mov esi, file_buffer
mov ebx, eax
call mmove
pop esi
call read_fat
cmp eax, 0xffffffff
je .exit_success
add edi, eax
jmp read_file
@ -525,19 +517,19 @@ read_fat:
shr esi, 12
cmp esi, [loaded_fat_block]
mov eax, [loaded_fat_block]
; jmp $
je .read
call cache_file_table
; mov eax, [loaded_fat_block]
; mov esi, [file_table + 0x4 * 3]
; jmp $
.read:
pop esi
and esi, 0xfff
; jmp $
mov eax, [esi * 0x4 + file_table]
; jmp $
ret
cache_file_table:
;args:
@ -577,30 +569,6 @@ cache_file_table:
pop edx
ret
jmp $
mmove:
;esi = src
;edi = dest
;ebx = count
push eax
push ecx
; debug
xor ecx, ecx
.mlp:
cmp ecx, ebx
jge .ret
mov al, [ds:esi + ecx]
mov [ds:edi + ecx], al
inc ecx
jmp .mlp
.ret:
; debug
pop ecx
pop eax
ret
load_elf:
;parse elf and relocate each section to it's appropriate location
;kernel info
@ -620,7 +588,6 @@ k_info:
;.type: db 0
kernel_file: db "kernel", 0x0, 0x0, "elf"
loaded_fat_block: dd 0
kload_paddr: dd 0x10000
file_buffer EQU 0xa000
root_dir EQU 0x1000
file_table EQU 0xf000

View File

@ -1,10 +0,0 @@
bits 16
global _start
_start:
mov ebx, 0xb8000
mov word [ds:ebx], 0x0f41
cli
hlt
jmp $

View File

@ -1,3 +0,0 @@
void kmain(){
return;
}