Rust kernel
Following this post: http://blog.phil-opp.com/rust-os/multiboot-kernel.html#fn2
This commit is contained in:
7
rust_boot.asm
Normal file
7
rust_boot.asm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
global start
|
||||||
|
|
||||||
|
section .text
|
||||||
|
bits 32
|
||||||
|
start:
|
||||||
|
mov dword [0xb800], 0x2f4b2f4f
|
||||||
|
hlt
|
||||||
0
rust_kernel.rs
Normal file
0
rust_kernel.rs
Normal file
20
rust_kernel/Makefile
Normal file
20
rust_kernel/Makefile
Normal 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
|
||||||
8
rust_kernel/isofiles/boot/grub/grub.cfg
Normal file
8
rust_kernel/isofiles/boot/grub/grub.cfg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
set timeout=2
|
||||||
|
set default=0
|
||||||
|
|
||||||
|
menuentry "my os" {
|
||||||
|
multiboot2 /boot/kernel.bin
|
||||||
|
boot
|
||||||
|
}
|
||||||
BIN
rust_kernel/isofiles/boot/kernel.bin
Executable file
BIN
rust_kernel/isofiles/boot/kernel.bin
Executable file
Binary file not shown.
BIN
rust_kernel/isofiles/kernel.bin
Executable file
BIN
rust_kernel/isofiles/kernel.bin
Executable file
Binary file not shown.
16
rust_kernel/linker.ld
Normal file
16
rust_kernel/linker.ld
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
14
rust_kernel/multiboot2_header.asm
Normal file
14
rust_kernel/multiboot2_header.asm
Normal 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:
|
||||||
|
|
||||||
9
rust_kernel/rust_boot.asm
Normal file
9
rust_kernel/rust_boot.asm
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
global start
|
||||||
|
|
||||||
|
section .text
|
||||||
|
bits 32
|
||||||
|
|
||||||
|
start:
|
||||||
|
mov edi, 0xb8000
|
||||||
|
mov dword [edi], 0x2f4b2f4f
|
||||||
|
hlt
|
||||||
0
rust_kernel/rust_kernel.rs
Normal file
0
rust_kernel/rust_kernel.rs
Normal file
Reference in New Issue
Block a user