Jump to kernel
This commit is contained in:
parent
b308617ac8
commit
984ef385f1
4 changed files with 23 additions and 13 deletions
7
Makefile
7
Makefile
|
@ -2,13 +2,12 @@ run_kernel: compile_kernel
|
|||
qemu-system-i386 -kernel target/kernel.bin
|
||||
|
||||
compile_kernel:
|
||||
nasm -f bin kernel/boot.asm -o target/kernel_boot.o
|
||||
nasm -felf32 kernel/boot.asm -o target/boot.o
|
||||
i686-elf-gcc -c kernel/kernel.c -o target/kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
|
||||
i686-elf-gcc -T kernel/linker.ld -o target/kernel.bin -ffreestanding -O2 -nostdlib target/kernel_boot.o target/kernel.o -lgcc
|
||||
i686-elf-gcc -T kernel/linker.ld -o target/kernel.bin -ffreestanding -O2 -nostdlib target/boot.o target/kernel.o -lgcc
|
||||
|
||||
compile_bootloader:
|
||||
compile_bootloader: compile_kernel
|
||||
rm -rf target/boot.bin
|
||||
nasm -f bin bootloader/test_kernel.asm -o target/kernel.bin
|
||||
nasm -f bin -o target/boot.bin bootloader/main.asm
|
||||
|
||||
run_bootloader: compile_bootloader
|
||||
|
|
|
@ -219,7 +219,19 @@ mov ss, ax
|
|||
; set up stack
|
||||
mov esp, 0x090000
|
||||
|
||||
jmp 0x08:0x8000
|
||||
; load offset from ELF file
|
||||
; mind the differing endian
|
||||
mov edx, 0x8018
|
||||
mov ah, [ds:edx+2]
|
||||
mov al, [ds:edx+3]
|
||||
shl eax, 16
|
||||
mov ah, [ds:edx]
|
||||
mov al, [ds:edx+1]
|
||||
|
||||
; add the beginning 0x8000
|
||||
add eax, 0x8000
|
||||
|
||||
jmp eax
|
||||
|
||||
.end:
|
||||
jmp .end
|
||||
|
|
|
@ -110,9 +110,9 @@ void kernel_main(void)
|
|||
terminal_initialize();
|
||||
|
||||
/* Newline support is left as an exercise. */
|
||||
terminal_writestring("Hello, ");
|
||||
terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK));
|
||||
terminal_writestring("kernel");
|
||||
terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK));
|
||||
terminal_writestring(" World!\n");
|
||||
// terminal_writestring("Hello, ");
|
||||
// terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK));
|
||||
// terminal_writestring("kernel");
|
||||
// terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK));
|
||||
// terminal_writestring(" World!\n");
|
||||
}
|
|
@ -6,9 +6,8 @@ ENTRY(_start)
|
|||
kernel image. */
|
||||
SECTIONS
|
||||
{
|
||||
/* Begin putting sections at 1 MiB, a conventional place for kernels to be
|
||||
loaded at by the bootloader. */
|
||||
. = 1M;
|
||||
/* Set this to 0, so the program entry is the relative position to the start of the kernel */
|
||||
. = 0;
|
||||
|
||||
/* First put the multiboot header, as it is required to be put very early
|
||||
early in the image or the bootloader won't recognize the file format.
|
||||
|
|
Loading…
Reference in a new issue