Rust kernel

Following  this post:
http://blog.phil-opp.com/rust-os/multiboot-kernel.html#fn2
This commit is contained in:
greg
2015-10-25 23:25:15 -07:00
parent c5fcd73499
commit 90655746ca
10 changed files with 74 additions and 0 deletions

7
rust_boot.asm Normal file
View File

@@ -0,0 +1,7 @@
global start
section .text
bits 32
start:
mov dword [0xb800], 0x2f4b2f4f
hlt

0
rust_kernel.rs Normal file
View File

20
rust_kernel/Makefile Normal file
View File

@@ -0,0 +1,20 @@
all: run_kernel
kernel.bin: multiboot2_header.asm rust_boot.asm linker.ld
nasm -f elf64 multiboot2_header.asm
nasm -f elf64 rust_boot.asm
ld -n -o kernel.bin -T linker.ld multiboot2_header.o rust_boot.o
os.iso: kernel.bin
cp kernel.bin isofiles/
grub-mkrescue -o os.iso isofiles
run_kernel: os.iso
qemu-system-x86_64 -hda os.iso
.PHONY: clean
clean:
rm -f *.o
rm -f kernel.bin
rm -f os.iso

View File

@@ -0,0 +1,8 @@
set timeout=2
set default=0
menuentry "my os" {
multiboot2 /boot/kernel.bin
boot
}

Binary file not shown.

BIN
rust_kernel/isofiles/kernel.bin Executable file

Binary file not shown.

16
rust_kernel/linker.ld Normal file
View File

@@ -0,0 +1,16 @@
ENTRY(start)
SECTIONS {
. = 10K; /* load into memory at 1M */
.boot :
{
/* ensure that the multiboot header is at the beginning */
*(.multiboot2_header)
}
.text :
{
*(.text)
}
}

View File

@@ -0,0 +1,14 @@
section .multiboot2_header
header_start:
dd 0xe85250d6 ;multiboot 2 magic number
dd 0 ; architecture 0 (protected i386)
dd header_end - header_start ;header length
;checksum
dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start))
dw 0 ;type
dw 0 ;flags
dd 8 ;size
header_end:

View File

@@ -0,0 +1,9 @@
global start
section .text
bits 32
start:
mov edi, 0xb8000
mov dword [edi], 0x2f4b2f4f
hlt

View File