Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new inline assembly syntax for the 0.9 series #204

Merged
merged 5 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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::convert::TryInto;
use core::panic::PanicInfo;
use core::{mem, slice};
Expand Down Expand Up @@ -42,8 +43,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 @@ -88,8 +89,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