Skip to content

Commit ecaf5eb

Browse files
committed
remove global_asm support
- using "Rust assembly" to jump in the user space
1 parent a26d7e4 commit ecaf5eb

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/arch/x86_64/mod.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,28 @@ pub mod task;
1010

1111
pub use crate::arch::x86_64::syscall::syscall_handler;
1212

13-
global_asm!(include_str!("user_land.s"), options(att_syntax));
13+
pub unsafe fn jump_to_user_land(func: extern "C" fn()) -> ! {
14+
let ds = 0x23u64;
15+
let cs = 0x2bu64;
16+
17+
asm!(
18+
"push {0}",
19+
"push rsp",
20+
"add QWORD PTR [rsp], 16",
21+
"pushf",
22+
"push {1}",
23+
"push {2}",
24+
"iretq",
25+
in(reg) ds,
26+
in(reg) cs,
27+
in(reg) func as u64,
28+
options(nostack)
29+
);
30+
31+
loop {
32+
processor::halt();
33+
}
34+
}
1435

1536
pub fn register_task() {
1637
let sel: u16 = 6u16 << 3;
@@ -20,10 +41,6 @@ pub fn register_task() {
2041
}
2142
}
2243

23-
extern "C" {
24-
pub fn jump_to_user_land(func: extern "C" fn()) -> !;
25-
}
26-
2744
#[macro_export]
2845
macro_rules! syscall {
2946
($arg0:expr) => {

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(const_ptr_offset, asm, lang_items)]
22
#![feature(allocator_api)]
3-
#![feature(global_asm)]
43
#![feature(naked_functions)]
54
#![feature(abi_x86_interrupt)]
65
#![feature(const_fn_fn_ptr_basics)]

0 commit comments

Comments
 (0)