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

x86_64 virtio:get irqnum support for x86_64 virtio dev #97

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
83 changes: 83 additions & 0 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions modules/axconfig/src/platform/pc-x86.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ mmio-regions = [
["0xfec0_0000", "0x1000"], # IO APIC
["0xfed0_0000", "0x1000"], # HPET
["0xfee0_0000", "0x1000"], # Local APIC
["0xe_0000", "0x2_0000"], # ACPI
]
# VirtIO MMIO regions with format (`base_paddr`, `size`).
virtio-mmio-regions = []
# Base physical address of the PCIe ECAM space (should read from ACPI 'MCFG' table).
pci-ecam-base = "0xb000_0000"
# End PCI bus number.
pci-bus-end = "0xff"
# PCI device memory ranges (not used on x86).
Expand Down
11 changes: 9 additions & 2 deletions modules/axdriver/src/bus/pci.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{prelude::*, AllDevices};
use axhal::mem::phys_to_virt;
use axhal::mem::{phys_to_virt, PhysAddr};
use driver_pci::{
BarInfo, Cam, Command, DeviceFunction, HeaderType, MemoryBarType, PciRangeAllocator, PciRoot,
};
Expand Down Expand Up @@ -84,7 +84,14 @@ fn config_pci_device(

impl AllDevices {
pub(crate) fn probe_bus_devices(&mut self) {
let base_vaddr = phys_to_virt(axconfig::PCI_ECAM_BASE.into());
cfg_if::cfg_if! {
if #[cfg(target_arch = "x86_64")] {
let pci_ecam_base = PhysAddr::from(axhal::get_ecam_address().unwrap() as usize);
} else {
let pci_ecam_base = axconfig::PCI_ECAM_BASE.into();
}
}
let base_vaddr = phys_to_virt(pci_ecam_base);
let mut root = unsafe { PciRoot::new(base_vaddr.as_mut_ptr(), Cam::Ecam) };

// PCI 32-bit MMIO space
Expand Down
2 changes: 2 additions & 0 deletions modules/axhal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ x86 = "0.52"
x86_64 = "0.14"
x2apic = "0.4"
raw-cpuid = "11.0"
acpi = "4.1.1"
aml = "0.16.4"

[target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies]
riscv = "0.10"
Expand Down
1 change: 1 addition & 0 deletions modules/axhal/src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use x86_64::instructions::interrupts;
pub use self::context::{ExtendedState, FxsaveArea, TaskContext, TrapFrame};
pub use self::gdt::GdtStruct;
pub use self::idt::IdtStruct;
pub use self::trap::{IRQ_VECTOR_END, IRQ_VECTOR_START};
pub use x86_64::structures::tss::TaskStateSegment;

/// Allows the current CPU to respond to interrupts.
Expand Down
6 changes: 4 additions & 2 deletions modules/axhal/src/arch/x86_64/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use super::context::TrapFrame;

core::arch::global_asm!(include_str!("trap.S"));

const IRQ_VECTOR_START: u8 = 0x20;
const IRQ_VECTOR_END: u8 = 0xff;
/// start value of irq vector
pub const IRQ_VECTOR_START: u8 = 0x20;
/// end value of irq vector
pub const IRQ_VECTOR_END: u8 = 0xff;

#[no_mangle]
fn x86_trap_handler(tf: &mut TrapFrame) {
Expand Down
3 changes: 3 additions & 0 deletions modules/axhal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ pub use self::platform::platform_init;

#[cfg(feature = "smp")]
pub use self::platform::platform_init_secondary;

#[cfg(target_arch = "x86_64")]
pub use self::platform::acpi::get_ecam_address;
Loading
Loading