Skip to content

Commit f8deebe

Browse files
authored
Merge pull request #204 from bjorn3/new_asm_for_0_9
Use new inline assembly syntax for the 0.9 series
2 parents cc055a7 + da73392 commit f8deebe

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/e820.s

+1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ do_e820:
5151
stc # "function unsupported" error exit
5252
ret
5353

54+
.global mmap_ent
5455
mmap_ent: .word 0

src/main.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(lang_items)]
22
#![feature(global_asm)]
3-
#![feature(llvm_asm)]
3+
#![feature(asm)]
44
#![no_std]
55
#![no_main]
66

@@ -10,6 +10,7 @@ compile_error!("The bootloader crate must be compiled for the `x86_64-bootloader
1010
extern crate rlibc;
1111

1212
use bootloader::bootinfo::{BootInfo, FrameRange};
13+
use core::arch::asm;
1314
use core::{arch::global_asm, convert::TryInto, panic::PanicInfo};
1415
use core::{mem, slice};
1516
use fixedvec::alloc_stack;
@@ -41,8 +42,8 @@ global_asm!(include_str!("video_mode/vga_320x200.s"));
4142
global_asm!(include_str!("video_mode/vga_text_80x25.s"));
4243

4344
unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! {
44-
llvm_asm!("call $1; ${:private}.spin.${:uid}: jmp ${:private}.spin.${:uid}" ::
45-
"{rsp}"(stack_pointer), "r"(entry_point), "{rdi}"(boot_info) :: "intel");
45+
asm!("mov rsp, {1}; call {0}; 2: jmp 2b",
46+
in(reg) entry_point.as_u64(), in(reg) stack_pointer.as_u64(), in("rdi") boot_info.as_u64());
4647
::core::hint::unreachable_unchecked()
4748
}
4849

@@ -87,8 +88,12 @@ extern "C" {
8788
#[no_mangle]
8889
pub unsafe extern "C" fn stage_4() -> ! {
8990
// Set stack segment
90-
llvm_asm!("mov bx, 0x0
91-
mov ss, bx" ::: "bx" : "intel");
91+
asm!(
92+
"push rbx
93+
mov bx, 0x0
94+
mov ss, bx
95+
pop rbx"
96+
);
9297

9398
let kernel_start = 0x400000;
9499
let kernel_size = &_kernel_size as *const _ as u64;

0 commit comments

Comments
 (0)