Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ sbi-rt = "0.0.3"
[target.'cfg(target_arch = "x86_64")'.dependencies]
linux-boot-params = { version = "0.17", optional = true }
multiboot = { version = "0.8", optional = true }
# xen-hvm = { path = "../xen/xen-hvm" }
xen-hvm = { git = "https://github.com/hermit-os/xen.git", branch = "xen-hvm" }
uart_16550 = "0.4"
x86_64 = { version = "0.15", default-features = false, features = ["instructions"] }

Expand All @@ -46,7 +48,7 @@ built = { version = "0.8", features = ["git2", "chrono"] }
# FIXME: When target-specific features exist, remove the workaround features.
# https://github.com/rust-lang/cargo/issues/1197
[features]
default = []
default = ["multiboot"]
elf = []
linux = []
multiboot = []
Expand Down
21 changes: 1 addition & 20 deletions src/arch/x86_64/platform/multiboot/entry.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,11 @@
.extern loader_start # defined in linker script
.extern loader_end

# We use a special name to map this section at the begin of our kernel
# => Multiboot expects its magic number at the beginning of the kernel.
.section .mboot, "a"

# This part MUST be 4 byte aligned, so we solve that issue using '.align 4'.
.align 4
mboot:
# Multiboot macros to make a few lines more readable later
.set MULTIBOOT_PAGE_ALIGN, (1 << 0)
.set MULTIBOOT_MEMORY_INFO, (1 << 1)
.set MULTIBOOT_HEADER_MAGIC, 0x1BADB002
.set MULTIBOOT_HEADER_FLAGS, MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
.set MULTIBOOT_CHECKSUM, -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

# This is the GRUB Multiboot header. A boot signature
.4byte MULTIBOOT_HEADER_MAGIC
.4byte MULTIBOOT_HEADER_FLAGS
.4byte MULTIBOOT_CHECKSUM
.4byte 0, 0, 0, 0, 0 # address fields

.section .text
.align 4
.global _start
_start:
mov edi, ebx
cli # avoid any interrupt

# Initialize stack pointer
Expand Down
15 changes: 13 additions & 2 deletions src/arch/x86_64/platform/multiboot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use alloc::borrow::ToOwned;
use core::ptr::write_bytes;
use core::sync::atomic::{AtomicPtr, Ordering};
use core::{mem, ptr, slice};
use xen_hvm::start_info::StartInfo;

use align_address::Align;
use hermit_entry::boot_info::{
Expand All @@ -18,6 +19,12 @@ use crate::arch::x86_64::physicalmem::PhysAlloc;
use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, paging};
use crate::fdt::Fdt;

unsafe extern "C" {
fn _start(start_info: &'static StartInfo) -> !;
}

xen_hvm::phys32_entry!(_start);

unsafe extern "C" {
static mut loader_end: u8;
}
Expand All @@ -38,9 +45,13 @@ mod entry {

static MB_INFO: AtomicPtr<MultibootInfo> = AtomicPtr::new(ptr::null_mut());

unsafe extern "C" fn rust_start(mb_info: *mut MultibootInfo) -> ! {
unsafe extern "C" fn rust_start(start_info: &'static StartInfo) -> ! {
crate::log::init();
MB_INFO.store(mb_info, Ordering::Relaxed);

paging::map::<Size4KiB>(0x2000, 0x2000, 1, PageTableFlags::empty());
dbg!(start_info);
loop {}

unsafe {
crate::os::loader_main();
}
Expand Down
8 changes: 4 additions & 4 deletions xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ impl Build {
sh.create_dir(dist_object.as_ref().parent().unwrap())?;
sh.copy_file(&build_object, &dist_object)?;

if self.artifact.target == Target::X86_64Multiboot {
eprintln!("Converting object to elf32-i386");
dist_object.convert_to_elf32_i386()?;
}
// if self.artifact.target == Target::X86_64Multiboot {
// eprintln!("Converting object to elf32-i386");
// dist_object.convert_to_elf32_i386()?;
// }

eprintln!("Loader available at {}", dist_object.as_ref().display());
Ok(())
Expand Down
Loading