diff --git a/.gitmodules b/.gitmodules index 0964bae..c38b4a5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "rust"] path = rust - url = https://github.com/rust-lang/rust.git + url = https://github.com/redox-os/rust.git diff --git a/Makefile b/Makefile index 0b0ba17..9101b60 100644 --- a/Makefile +++ b/Makefile @@ -82,4 +82,5 @@ qemu: build/harddrive.bin endif clean: - rm -rf build/* target/* + cargo clean + rm -rf build/* diff --git a/arch/x86_64/src/start.rs b/arch/x86_64/src/start.rs index d382f28..5b0823f 100644 --- a/arch/x86_64/src/start.rs +++ b/arch/x86_64/src/start.rs @@ -202,23 +202,26 @@ pub unsafe extern fn kstart_ap(stack_start: usize, stack_end: usize) -> ! { kmain_ap(ap_number); } -pub unsafe fn usermode(ip: usize, sp: usize) { - // Test usermode - asm!("mov rax, 0x2B +pub unsafe fn usermode(ip: usize, sp: usize) -> ! { + // Go to usermode + asm!("mov rax, 0x2B # Set segment pointers mov ds, ax mov es, ax mov fs, ax mov gs, ax - push rax - push rbx - pushfq + push rax # Push stack segment + push rbx # Push stack pointer + mov rax, 3 << 12 | 1 << 9 # Set IOPL and interrupt enable flag + push rax # Push rflags mov rax, 0x23 - push rax - push rcx + push rax # Push code segment + push rcx # Push rip + xchg bx, bx iretq" : : "{rbx}"(sp), "{rcx}"(ip) - : "rax", "rbx", "rcx", "sp" + : "rax", "sp" : "intel", "volatile"); + unreachable!(); } diff --git a/init/src/lib.rs b/init/src/lib.rs index dd8be37..47c6e5f 100644 --- a/init/src/lib.rs +++ b/init/src/lib.rs @@ -11,7 +11,7 @@ use syscall::{exit, write}; pub unsafe extern fn _start() { let string = b"Hello, World!\n"; write(1, string); - exit(1); + exit(0); } #[cfg(not(test))] @@ -22,6 +22,8 @@ extern "C" fn eh_personality() {} /// Required to handle panics #[lang = "panic_fmt"] extern "C" fn panic_fmt(_fmt: ::core::fmt::Arguments, _file: &str, _line: u32) -> ! { + write(2, b"panic\n"); + exit(127); loop {} } diff --git a/rust b/rust index a23064a..46a90c6 160000 --- a/rust +++ b/rust @@ -1 +1 @@ -Subproject commit a23064af5ec7f52b287e2c60823fed92a4763502 +Subproject commit 46a90c60ab79d65a09330448becd01c78511ea77