Skip to content

Commit 629255c

Browse files
strakephil-opp
authored andcommitted
rustify context_switch (rust-osdev#39)
1 parent 549873e commit 629255c

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/context_switch.s

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ global_asm!(include_str!("stage_1.s"));
3030
global_asm!(include_str!("stage_2.s"));
3131
global_asm!(include_str!("e820.s"));
3232
global_asm!(include_str!("stage_3.s"));
33-
global_asm!(include_str!("context_switch.s"));
3433

3534
#[cfg(feature = "vga_320x200")]
3635
global_asm!(include_str!("video_mode/vga_320x200.s"));
3736
#[cfg(not(feature = "vga_320x200"))]
3837
global_asm!(include_str!("video_mode/vga_text_80x25.s"));
3938

40-
extern "C" {
41-
fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> !;
39+
unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! {
40+
asm!("jmp $1; .spin: jmp spin" :: "{rsp}"(stack_pointer), "r"(entry_point), "{rdi}"(boot_info) :: "intel");
41+
::core::hint::unreachable_unchecked()
4242
}
4343

4444
mod boot_info;

0 commit comments

Comments
 (0)