Skip to content

Commit

Permalink
Merge pull request #204 from bjorn3/new_asm_for_0_9
Browse files Browse the repository at this point in the history
Use new inline assembly syntax for the 0.9 series
  • Loading branch information
phil-opp committed Jan 9, 2022
2 parents cc055a7 + da73392 commit f8deebe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/e820.s
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ do_e820:
stc # "function unsupported" error exit
ret

.global mmap_ent
mmap_ent: .word 0
15 changes: 10 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(lang_items)]
#![feature(global_asm)]
#![feature(llvm_asm)]
#![feature(asm)]
#![no_std]
#![no_main]

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

use bootloader::bootinfo::{BootInfo, FrameRange};
use core::arch::asm;
use core::{arch::global_asm, convert::TryInto, panic::PanicInfo};
use core::{mem, slice};
use fixedvec::alloc_stack;
Expand Down Expand Up @@ -41,8 +42,8 @@ global_asm!(include_str!("video_mode/vga_320x200.s"));
global_asm!(include_str!("video_mode/vga_text_80x25.s"));

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

Expand Down Expand Up @@ -87,8 +88,12 @@ extern "C" {
#[no_mangle]
pub unsafe extern "C" fn stage_4() -> ! {
// Set stack segment
llvm_asm!("mov bx, 0x0
mov ss, bx" ::: "bx" : "intel");
asm!(
"push rbx
mov bx, 0x0
mov ss, bx
pop rbx"
);

let kernel_start = 0x400000;
let kernel_size = &_kernel_size as *const _ as u64;
Expand Down

0 comments on commit f8deebe

Please sign in to comment.