Skip to content
Merged
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
2 changes: 1 addition & 1 deletion guest_image/guest.dts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
};

chosen {
bootargs = "root=/dev/vda locale.LANG=en_US.UTF-8";
bootargs = "root=/dev/sda locale.LANG=en_US.UTF-8";
stdout-path = "/soc/serial@10000000";
rng-seed = <0x9775b34d 0xe39158f2 0x3e9d10b1 0x73692dfd 0x13c15814 0xa4ad203f 0x8b0d62f7 0x6bf8a79d>;
};
Expand Down
19 changes: 8 additions & 11 deletions hikami_core/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,28 +271,25 @@ impl Devices {
self.clint.memmap(),
]);

if let Some(pci) = &self.pci {
device_mapping.push(pci.memmap());
device_mapping.extend_from_slice(pci.pci_memory_maps());
}
if let Some(rtc) = &self.rtc {
device_mapping.push(rtc.memmap());
}
if let Some(initrd) = &self.initrd {
device_mapping.push(initrd.memmap());
}

// disable drive emulation if `identity_map` feature is enabled
if let Some(pci) = &self.pci {
device_mapping.push(pci.memmap());

if cfg!(feature = "identity_map") {
// mapping whole memory mapped register region of block divices.
device_mapping.extend_from_slice(pci.pci_memory_maps());
}
}
if cfg!(feature = "identity_map") {
if let Some(mmc) = &self.mmc {
device_mapping.push(mmc.memmap());
}
if let Some(pci) = &self.pci {
if let Some(sata) = &pci.pci_devices.sata {
use pci::PciDevice;
device_mapping.push(sata.memmap());
}
}
}

device_mapping
Expand Down
11 changes: 4 additions & 7 deletions hikami_core/src/device/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub trait PciDevice {
device_id: u32,
pci_config_space_base_addr: HostPhysicalAddress,
pci_addr_space: &PciAddressSpace,
memory_maps: &mut Vec<MemoryMap>,
) -> Self;

/// Initialize pci device.
Expand All @@ -87,7 +86,6 @@ impl PciDevices {
device_tree: &Fdt,
pci_config_space_base_addr: HostPhysicalAddress,
pci_addr_space: &PciAddressSpace,
memory_maps: &mut Vec<MemoryMap>,
) -> Self {
/// Max PCI bus size.
const PCI_MAX_BUS: u8 = 255;
Expand Down Expand Up @@ -143,7 +141,6 @@ impl PciDevices {
device_id.into(),
pci_config_space_base_addr,
pci_addr_space,
memory_maps,
));
}

Expand Down Expand Up @@ -299,18 +296,17 @@ impl MmioDevice for Pci {
let mut memory_maps = Vec::new();
let base_address = HostPhysicalAddress(region.starting_address as usize);
let pci_addr_space = PciAddressSpace::new(device_tree, compatibles);
let pci_devices =
PciDevices::new(device_tree, base_address, &pci_addr_space, &mut memory_maps);
let pci_devices = PciDevices::new(device_tree, base_address, &pci_addr_space);

// 32 bit memory map
// 32 bit reserved memory map
memory_maps.push(MemoryMap::new(
GuestPhysicalAddress(pci_addr_space.bit32_memory_space.start.raw())
..GuestPhysicalAddress(pci_addr_space.bit32_memory_space.end.raw()),
pci_addr_space.bit32_memory_space.clone(),
&PTE_FLAGS_FOR_DEVICE,
));

// 64 bit memory map
// 64 bit reserved memory map
memory_maps.push(MemoryMap::new(
GuestPhysicalAddress(pci_addr_space.bit64_memory_space.start.raw())
..GuestPhysicalAddress(pci_addr_space.bit64_memory_space.end.raw()),
Expand All @@ -335,6 +331,7 @@ impl MmioDevice for Pci {
self.base_addr
}

/// mapping sata register region.
fn memmap(&self) -> MemoryMap {
let vaddr = GuestPhysicalAddress(self.paddr().raw());
MemoryMap::new(
Expand Down
2 changes: 0 additions & 2 deletions hikami_core/src/device/pci/iommu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::h_extension::csrs::hgatp;
use crate::memmap::{HostPhysicalAddress, MemoryMap, page_table::constants::PAGE_SIZE};
use register_map::{IoMmuMode, IoMmuRegisters};

use alloc::vec::Vec;
use core::ops::Range;
use fdt::Fdt;

Expand Down Expand Up @@ -137,7 +136,6 @@ impl PciDevice for IoMmu {
_device_id: u32,
_pci_config_space_base_addr: HostPhysicalAddress,
_pci_addr_space: &PciAddressSpace,
_memory_maps: &mut Vec<MemoryMap>,
) -> Self {
unreachable!("use `IoMmu::new_from_dtb` instead.");
}
Expand Down
2 changes: 0 additions & 2 deletions hikami_core/src/device/pci/sata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use command::{

use alloc::boxed::Box;
use alloc::vec;
use alloc::vec::Vec;
use core::ops::Range;

/// Number of SATA port.
Expand Down Expand Up @@ -406,7 +405,6 @@ impl PciDevice for Sata {
device_id: u32,
pci_config_space_base_addr: HostPhysicalAddress,
pci_addr_space: &PciAddressSpace,
_memory_maps: &mut Vec<MemoryMap>,
) -> Self {
let config_space_header_addr =
pci_config_space_base_addr.0 | bdf.calc_config_space_header_offset();
Expand Down
2 changes: 1 addition & 1 deletion hikami_core/src/guest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Guest {
fn map_guest_dtb(
_hart_id: usize,
page_table_addr: HostPhysicalAddress,
guest_dtb: &'static [u8; include_bytes!("../guest_image/guest.dtb").len()],
guest_dtb: &'static [u8],
) -> GuestPhysicalAddress {
use PteFlag::{Accessed, Dirty, Read, User, Valid, Write};

Expand Down
Loading