Revert "relocating file during load to allow for use of more memory"
This reverts commit 24d85843ac.
This commit is contained in:
parent
24d85843ac
commit
79a77ed150
35
linker.ld
35
linker.ld
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
makefile
13
makefile
|
|
@ -1,11 +1,8 @@
|
||||||
CC := gcc
|
CC := gcc
|
||||||
AS := nasm
|
AS := nasm
|
||||||
CFLAGS := -c -mno-sse -mno-sse2 -mno-red-zone -ffreestanding -fno-pie -fno-stack-protector -mno-mmx
|
|
||||||
BL_ASFLAGS := -f bin
|
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
|
cp bin/bootloader.bin image.bin
|
||||||
qemu-img resize -f raw image.bin 512M
|
qemu-img resize -f raw image.bin 512M
|
||||||
./diskwrite -v kernel.elf -o image.bin
|
./diskwrite -v kernel.elf -o image.bin
|
||||||
|
|
@ -16,14 +13,6 @@ tools:
|
||||||
|
|
||||||
bootloader:
|
bootloader:
|
||||||
$(AS) src/bootloader/main.s $(BL_ASFLAGS) -o bin/bootloader.bin
|
$(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:
|
init:
|
||||||
@mkdir mount
|
@mkdir mount
|
||||||
@mkdir bin
|
@mkdir bin
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ load_part2:
|
||||||
push 0
|
push 0
|
||||||
pop ds
|
pop ds
|
||||||
mov si, DAP
|
mov si, DAP
|
||||||
|
; jmp $
|
||||||
int 0x13
|
int 0x13
|
||||||
jc load_fail
|
jc load_fail
|
||||||
jmp part_2
|
jmp part_2
|
||||||
|
|
@ -305,7 +305,7 @@ part_2:
|
||||||
mov edi, kernel_file
|
mov edi, kernel_file
|
||||||
call open_file
|
call open_file
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
mov edi, 0x10000
|
mov edi, file_buffer
|
||||||
call read_file
|
call read_file
|
||||||
jc load_fail
|
jc load_fail
|
||||||
|
|
||||||
|
|
@ -449,8 +449,9 @@ read_file:
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov eax, esi
|
mov eax, esi
|
||||||
mov cl, [fat_bpb.sectors_per_cluster]
|
mov cl, [fat_bpb.sectors_per_cluster]
|
||||||
|
; jmp $
|
||||||
mul ecx; eax = offset from file table
|
mul ecx; eax = offset from file table
|
||||||
|
; jmp $
|
||||||
push eax
|
push eax
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
|
|
@ -470,13 +471,11 @@ read_file:
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
mov cl, [fat_bpb.sectors_per_cluster]
|
mov cl, [fat_bpb.sectors_per_cluster]
|
||||||
mov [DAP.read_count], cx
|
mov [DAP.read_count], cx
|
||||||
; push edi
|
push edi
|
||||||
; shr edi, 16
|
shr edi, 16
|
||||||
; mov [DAP.segment], di
|
mov [DAP.segment], di
|
||||||
; pop edi
|
pop edi
|
||||||
; mov [DAP.offset], di
|
mov [DAP.offset], di
|
||||||
mov word [DAP.segment], 0
|
|
||||||
mov word [DAP.offset], file_buffer
|
|
||||||
|
|
||||||
mov ah, 0x42
|
mov ah, 0x42
|
||||||
mov dl, [data.boot_disc]
|
mov dl, [data.boot_disc]
|
||||||
|
|
@ -484,7 +483,11 @@ read_file:
|
||||||
int 0x13
|
int 0x13
|
||||||
jc .exit_err
|
jc .exit_err
|
||||||
|
|
||||||
|
; debug
|
||||||
|
pop esi
|
||||||
|
call read_fat
|
||||||
|
cmp eax, 0xffffffff
|
||||||
|
je .exit_success
|
||||||
; debug
|
; debug
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov al, [fat_bpb.sectors_per_cluster]
|
mov al, [fat_bpb.sectors_per_cluster]
|
||||||
|
|
@ -493,17 +496,6 @@ read_file:
|
||||||
mov cx, [fat_bpb.bytes_per_sector]
|
mov cx, [fat_bpb.bytes_per_sector]
|
||||||
mul ecx
|
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
|
add edi, eax
|
||||||
jmp read_file
|
jmp read_file
|
||||||
|
|
||||||
|
|
@ -525,19 +517,19 @@ read_fat:
|
||||||
shr esi, 12
|
shr esi, 12
|
||||||
cmp esi, [loaded_fat_block]
|
cmp esi, [loaded_fat_block]
|
||||||
mov eax, [loaded_fat_block]
|
mov eax, [loaded_fat_block]
|
||||||
|
; jmp $
|
||||||
je .read
|
je .read
|
||||||
|
|
||||||
call cache_file_table
|
call cache_file_table
|
||||||
; mov eax, [loaded_fat_block]
|
; mov eax, [loaded_fat_block]
|
||||||
; mov esi, [file_table + 0x4 * 3]
|
; mov esi, [file_table + 0x4 * 3]
|
||||||
|
; jmp $
|
||||||
.read:
|
.read:
|
||||||
pop esi
|
pop esi
|
||||||
and esi, 0xfff
|
and esi, 0xfff
|
||||||
|
; jmp $
|
||||||
mov eax, [esi * 0x4 + file_table]
|
mov eax, [esi * 0x4 + file_table]
|
||||||
|
; jmp $
|
||||||
ret
|
ret
|
||||||
cache_file_table:
|
cache_file_table:
|
||||||
;args:
|
;args:
|
||||||
|
|
@ -577,30 +569,6 @@ cache_file_table:
|
||||||
pop edx
|
pop edx
|
||||||
ret
|
ret
|
||||||
jmp $
|
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:
|
load_elf:
|
||||||
;parse elf and relocate each section to it's appropriate location
|
;parse elf and relocate each section to it's appropriate location
|
||||||
;kernel info
|
;kernel info
|
||||||
|
|
@ -620,7 +588,6 @@ k_info:
|
||||||
;.type: db 0
|
;.type: db 0
|
||||||
kernel_file: db "kernel", 0x0, 0x0, "elf"
|
kernel_file: db "kernel", 0x0, 0x0, "elf"
|
||||||
loaded_fat_block: dd 0
|
loaded_fat_block: dd 0
|
||||||
kload_paddr: dd 0x10000
|
|
||||||
file_buffer EQU 0xa000
|
file_buffer EQU 0xa000
|
||||||
root_dir EQU 0x1000
|
root_dir EQU 0x1000
|
||||||
file_table EQU 0xf000
|
file_table EQU 0xf000
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
bits 16
|
|
||||||
|
|
||||||
global _start
|
|
||||||
|
|
||||||
_start:
|
|
||||||
mov ebx, 0xb8000
|
|
||||||
mov word [ds:ebx], 0x0f41
|
|
||||||
cli
|
|
||||||
hlt
|
|
||||||
jmp $
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
void kmain(){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue