rust setup stuff

This commit is contained in:
Jack Halford 2018-02-04 18:57:20 +00:00
parent b77dcc8ee3
commit b347842b8d
5 changed files with 42 additions and 3 deletions

7
kernel-rs/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "kfs"
version = "0.1.0"
authors = ["Jack Halford <jack@crans.org>"]
[lib]
crate-type = ["staticlib"]

View file

@ -2,12 +2,16 @@ arch ?= x86_64
kernel := build/kernel-$(arch).bin
iso := build/os-$(arch).iso
target ?= $(arch)-KFS
rust_os := target/$(target)/debug/libkfs.a
linker_script := src/arch/$(arch)/linker.ld
grub.cfg := src/arch/$(arch)/grub.cfg
asm_source_files := $(wildcard src/arch/$(arch)/*.asm)
asm_object_files := $(patsubst src/arch/$(arch)/%.asm, \
build/arch/$(arch)/%.o, $(asm_source_files))
.PHONY: all clean run iso
.PHONY: all clean run iso kernel
all: $(kernel)
@ -26,8 +30,12 @@ $(iso): $(kernel) $(grub.cfg)
grub-mkrescue -o $(iso) build/isofiles 2>/dev/null
rm -r build/isofiles
$(kernel): $(asm_object_files) $(linker_script)
@ld -n -T $(linker_script) -o $(kernel) $(asm_object_files)
$(kernel): kernel $(asm_object_files) $(linker_script)
@ld -n -T $(linker_script) -o $(kernel) \
$(asm_object_files) $(rust_os)
kernel:
@xargo build --target $(target)
# compile asm files
build/arch/$(arch)/%.o: src/arch/$(arch)/%.asm

View file

@ -10,6 +10,10 @@ long_mode_start:
mov es, ax
mov fs, ax
mov gs, ax
extern rust_main
call rust_main
;print 'OKAY' to screen
mov rax, 0x2f592f412f4b2f4f
mov qword [0xb8000], rax

8
kernel-rs/src/lib.rs Executable file
View file

@ -0,0 +1,8 @@
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub extern fn rust_main() {}
#[lang = "eh_personality"] #[no_mangle] pub extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}

12
kernel-rs/x86_64-KFS.json Normal file
View file

@ -0,0 +1,12 @@
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"arch": "x86_64",
"os": "none",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}