diff --git a/kernel-rs/.gdbinit b/kernel-rs/.gdbinit index 12181178..77d679cf 100644 --- a/kernel-rs/.gdbinit +++ b/kernel-rs/.gdbinit @@ -1,2 +1,2 @@ -set arch i386:x86-64 -symbol-file build/bluesnow-x86.bin +set arch i386 +file build/bluesnow-x86.bin diff --git a/kernel-rs/Cargo.toml b/kernel-rs/Cargo.toml index 45bb02ea..824d95b2 100644 --- a/kernel-rs/Cargo.toml +++ b/kernel-rs/Cargo.toml @@ -25,3 +25,7 @@ path = "x86" [dependencies.lazy_static] version = "1.0.0" features = ["spin_no_std"] + +[dependencies.compiler_builtins] +#I'm waiting for somebody to port i386/udivdi3.S ... :((( +git = "https://github.com/rust-lang-nursery/compiler-builtins" diff --git a/kernel-rs/Makefile b/kernel-rs/Makefile index 67f3aee6..5a421239 100644 --- a/kernel-rs/Makefile +++ b/kernel-rs/Makefile @@ -12,7 +12,7 @@ all: ## COMPILE ASM (nasm) asm_source := $(wildcard src/arch/$(ARCH)/*.asm) asm_object := $(patsubst src/arch/$(ARCH)/%.asm, build/arch/$(ARCH)/%.o, $(asm_source)) -NASM := /usr/bin/nasm -f elf -g +NASM := /usr/bin/nasm -f elf -gdwarf build/arch/$(ARCH)/%.o: src/arch/$(ARCH)/%.asm Makefile @mkdir -p $(shell dirname $@) $(NASM) $< -o $@ diff --git a/kernel-rs/mk/qemu.mk b/kernel-rs/mk/qemu.mk index 4ff0c2c3..db0f170c 100644 --- a/kernel-rs/mk/qemu.mk +++ b/kernel-rs/mk/qemu.mk @@ -6,7 +6,7 @@ else PORTG := 4344 endif -QEMU := qemu-system-x86_64\ +QEMU := qemu-system-i386\ -gdb tcp::$(PORTG)\ -S\ -enable-kvm\ diff --git a/kernel-rs/src/arch/x86/boot.asm b/kernel-rs/src/arch/x86/boot.asm index 3c24d67d..045dc35a 100644 --- a/kernel-rs/src/arch/x86/boot.asm +++ b/kernel-rs/src/arch/x86/boot.asm @@ -42,7 +42,7 @@ set_up_page_tables: or eax, 0b10000011 ; huge + present + writable mov [p2_table + 4], eax - mov eax, 0x800000 ; 8MB -> 12Mb (second page) + mov eax, 0x800000 ; 8MB -> 12Mb (third page) or eax, 0b10000011 ; huge + present + writable mov [p2_table + 8], eax diff --git a/kernel-rs/src/arch/x86/linker.ld b/kernel-rs/src/arch/x86/linker.ld index df7fd06a..4b3004c1 100644 --- a/kernel-rs/src/arch/x86/linker.ld +++ b/kernel-rs/src/arch/x86/linker.ld @@ -2,10 +2,6 @@ ENTRY(start) OUTPUT_FORMAT(elf32-i386) SECTIONS { - /* GDT for the win */ - /* . = 0x800; */ - /* .gdt : {KEEP(*(.gdt))} */ - /* VGA, cannot use section for this */ VGA_PTR = 0xb8000; . = 0xb8000; @@ -15,6 +11,7 @@ SECTIONS { /* ensure that the multiboot header is at the beginning */ .multiboot : { + /* KEEP otherwise it gets garbage collected by linker */ KEEP(*(.multiboot)) . = ALIGN(4K); } @@ -37,12 +34,6 @@ SECTIONS { . = ALIGN(4K); } - .debug : - { - *(.debug_*) - . = ALIGN(4K); - } - .gdt : { *(.gdt) @@ -67,15 +58,15 @@ SECTIONS { . = ALIGN(4K); } - .stab : - { - *(.stab) - . = ALIGN(4K); - } + /* .stab : */ + /* { */ + /* KEEP(*(.stab)) */ + /* . = ALIGN(4K); */ + /* } */ - .stabstr : - { - *(.stabstr) - . = ALIGN(4K); - } + /* .stabstr : */ + /* { */ + /* KEEP(*(.stabstr)) */ + /* . = ALIGN(4K); */ + /* } */ } diff --git a/kernel-rs/src/lib.rs b/kernel-rs/src/lib.rs index afe88457..b9686b90 100644 --- a/kernel-rs/src/lib.rs +++ b/kernel-rs/src/lib.rs @@ -46,8 +46,6 @@ pub mod memory; pub mod arch; pub use arch::x86::consts::*; -// use core::mem; -// use x86::structures::idt::*; /// kernel entry point. arch module is responsible for /// calling this once the core has loaded pub fn kmain() -> ! { @@ -78,11 +76,11 @@ pub fn kmain() -> ! { // } let ip = self::init as *const () as u32; - unsafe { - arch::x86::usermode(ip, sp, 0); - } - unreachable!() - // loop {} + // unsafe { + // arch::x86::usermode(ip, sp, 0); + // } + // unreachable!() + loop {} } pub fn init() { diff --git a/kernel-rs/x86-bluesnow.json b/kernel-rs/x86-bluesnow.json index 22f12e60..36bdde97 100644 --- a/kernel-rs/x86-bluesnow.json +++ b/kernel-rs/x86-bluesnow.json @@ -4,14 +4,14 @@ "_comment": "http://llvm.org/docs/LangRef.html#data-layout", "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", - "llvm-target": "i686-unknown-none", + "llvm-target": "i386-unknown-none", "linker-flavor": "gcc", - "no-compiler-rt": true, - "os": "bluesnow", + "os": "none", "target-endian": "little", "target-pointer-width": "32", "target-c-int-width": "32", "features": "-mmx,-fxsr,-sse,-sse2,+soft-float", "eliminate-frame-pointer": false, + "disable-redzone": true, "panic-strategy": "abort" }