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;
1818pub use crate :: arch:: x86_64:: kernel:: syscall:: syscall_handler;
1919use core:: ptr:: read_volatile;
2020
21- global_asm ! ( include_str!( "user_land.s" ) , options( att_syntax) ) ;
22-
2321#[ repr( C ) ]
2422struct KernelHeader {
2523 magic_number : u32 ,
@@ -49,8 +47,27 @@ pub fn register_task() {
4947 }
5048}
5149
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+ }
5471}
5572
5673/// 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 11#![ feature( const_ptr_offset, asm, lang_items) ]
22#![ feature( allocator_api) ]
3- #![ feature( global_asm) ]
43#![ feature( panic_info_message) ]
54#![ feature( naked_functions) ]
65#![ feature( abi_x86_interrupt) ]
You can’t perform that action at this time.
0 commit comments