File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,28 @@ pub mod task;
1010
1111pub 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
1536pub 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]
2845macro_rules! syscall {
2946 ( $arg0: expr) => {
Original file line number Diff line number Diff line change 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) ]
You can’t perform that action at this time.
0 commit comments