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;
10
10
11
11
pub use crate :: arch:: x86_64:: syscall:: syscall_handler;
12
12
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
+ }
14
35
15
36
pub fn register_task ( ) {
16
37
let sel: u16 = 6u16 << 3 ;
@@ -20,10 +41,6 @@ pub fn register_task() {
20
41
}
21
42
}
22
43
23
- extern "C" {
24
- pub fn jump_to_user_land ( func : extern "C" fn ( ) ) -> !;
25
- }
26
-
27
44
#[ macro_export]
28
45
macro_rules! syscall {
29
46
( $arg0: expr) => {
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( naked_functions) ]
5
4
#![ feature( abi_x86_interrupt) ]
6
5
#![ feature( const_fn_fn_ptr_basics) ]
You can’t perform that action at this time.
0 commit comments