File tree Expand file tree Collapse file tree 3 files changed +21
-36
lines changed Expand file tree Collapse file tree 3 files changed +21
-36
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,6 @@ pub mod task;
18
18
pub use crate :: arch:: x86_64:: kernel:: syscall:: syscall_handler;
19
19
use core:: ptr:: read_volatile;
20
20
21
- global_asm ! ( include_str!( "user_land.s" ) , options( att_syntax) ) ;
22
-
23
21
#[ repr( C ) ]
24
22
struct KernelHeader {
25
23
magic_number : u32 ,
@@ -49,8 +47,27 @@ pub fn register_task() {
49
47
}
50
48
}
51
49
52
- extern "C" {
53
- pub fn jump_to_user_land ( func : extern "C" fn ( ) ) -> !;
50
+ pub unsafe fn jump_to_user_land ( func : extern "C" fn ( ) ) -> ! {
51
+ let ds = 0x23u64 ;
52
+ let cs = 0x2bu64 ;
53
+
54
+ asm ! (
55
+ "push {0}" ,
56
+ "push rsp" ,
57
+ "add QWORD PTR [rsp], 16" ,
58
+ "pushf" ,
59
+ "push {1}" ,
60
+ "push {2}" ,
61
+ "iretq" ,
62
+ in( reg) ds,
63
+ in( reg) cs,
64
+ in( reg) func as u64 ,
65
+ options( nostack)
66
+ ) ;
67
+
68
+ loop {
69
+ processor:: halt ( ) ;
70
+ }
54
71
}
55
72
56
73
/// This macro can be used to call system functions from user-space
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
#![ feature( const_ptr_offset, asm, lang_items) ]
2
2
#![ feature( allocator_api) ]
3
- #![ feature( global_asm) ]
4
3
#![ feature( panic_info_message) ]
5
4
#![ feature( naked_functions) ]
6
5
#![ feature( abi_x86_interrupt) ]
You can’t perform that action at this time.
0 commit comments