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
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,23 @@ jobs:
if: matrix.arch == 'x86_64' || matrix.arch == 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package httpd --features ci,hermit/dhcpv4,hermit/rtl8139 qemu ${{ matrix.qemu_flags }} --devices rtl8139
if: matrix.arch != 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package httpd --no-default-features --features ci,hermit/dhcpv4,hermit/tcp,hermit/gem-net qemu ${{ matrix.qemu_flags }} --devices cadence-gem
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package httpd --no-default-features --features ci,hermit/dhcpv4,hermit/tcp,hermit/gem-net,hermit/riscv-plic qemu ${{ matrix.qemu_flags }} --devices cadence-gem
if: matrix.arch == 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package hello_world qemu ${{ matrix.qemu_flags }} --machine virt-aia-aplic
if: matrix.arch == 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package hello_world --features hermit/riscv-plic qemu ${{ matrix.qemu_flags }} --machine virt
if: matrix.arch == 'riscv64'
- run: cargo clean
working-directory: .
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package testudp --features hermit/udp,hermit/dhcpv4,hermit/virtio-net qemu ${{ matrix.qemu_flags }} --devices virtio-net-pci
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package testudp --features hermit/udp,hermit/dhcpv4,hermit/rtl8139 qemu ${{ matrix.qemu_flags }} --devices rtl8139
if: matrix.arch != 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package testudp --no-default-features --features hermit/udp,hermit/dhcpv4,hermit/gem-net qemu ${{ matrix.qemu_flags }} --devices cadence-gem
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package testudp --no-default-features --features hermit/udp,hermit/dhcpv4,hermit/gem-net,hermit/riscv-plic qemu ${{ matrix.qemu_flags }} --devices cadence-gem
if: matrix.arch == 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package miotcp --features hermit/dhcpv4,hermit/virtio-net qemu ${{ matrix.qemu_flags }} --devices virtio-net-pci
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package miotcp --features hermit/dhcpv4,hermit/rtl8139 qemu ${{ matrix.qemu_flags }} --devices rtl8139
if: matrix.arch != 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package miotcp --no-default-features --features hermit/dhcpv4,hermit/tcp,hermit/gem-net qemu ${{ matrix.qemu_flags }} --devices cadence-gem
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package miotcp --no-default-features --features hermit/dhcpv4,hermit/tcp,hermit/gem-net,hermit/riscv-plic qemu ${{ matrix.qemu_flags }} --devices cadence-gem
if: matrix.arch == 'riscv64'
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package poll --features hermit/dhcpv4,hermit/virtio-net qemu ${{ matrix.qemu_flags }} --devices virtio-net-pci
- run: cargo xtask ci rs --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.rs_flags }} --package poll --features hermit/dhcpv4,hermit/rtl8139 qemu ${{ matrix.qemu_flags }} --devices rtl8139
Expand Down
23 changes: 16 additions & 7 deletions Cargo.lock

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

12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ semihosting = ["dep:semihosting"]
## _application processor_s (AP) from the _boot-strap processor_ (BSP).
smp = ["acpi"]

## Enable drivers for legacy platform level interrupt controller (PLIC).
##
## If this flag is not set, the advanced platform level interrupt controller (APLIC)
## and the incoming message signaled interrupt controller (IMSIC) will be used.
##
## This flag is only evaluated for riscv64.
riscv-plic = []

#! ### Network Features

## Enables TCP support.
Expand Down Expand Up @@ -421,9 +429,11 @@ memory_addresses = { version = "0.4", default-features = false, features = ["aar
semihosting = { version = "0.1", optional = true }

[target.'cfg(target_arch = "riscv64")'.dependencies]
bitfield-struct = "0.13.0"
fdt = { version = "0.1", features = ["pretty-printing"] }
memory_addresses = { version = "0.4", default-features = false, features = ["riscv64"] }
riscv = "0.16"
#TODO: use upstream version once changes merged and published
riscv = { version = "0.16", git = "https://github.com/rust-embedded/riscv", branch = "master" }
sbi-rt = "0.0.4"
semihosting = { version = "0.1", optional = true }
tock-registers = { version = "0.10", optional = true }
Expand Down
14 changes: 14 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use llvm_tools::LlvmTools;
fn main() -> Result<()> {
built::write_built_file().unwrap();

configure_msix_support();

if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64"
&& env::var_os("CARGO_FEATURE_SMP").is_some()
{
Expand All @@ -19,6 +21,18 @@ fn main() -> Result<()> {
Ok(())
}

fn configure_msix_support() {
println!("cargo:rustc-check-cfg=cfg(msix_supported)");

let has_pci = env::var_os("CARGO_FEATURE_PCI").is_some();
let has_plic = env::var_os("CARGO_FEATURE_RISCV_PLIC").is_some();
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();

if has_pci && (target_arch == "x86_64" || (target_arch == "riscv64" && !has_plic)) {
println!("cargo:rustc-cfg=msix_supported");
}
}

fn assemble_x86_64_smp_boot() -> Result<()> {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());

Expand Down
16 changes: 16 additions & 0 deletions src/arch/riscv64/kernel/core_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use hermit_sync::InterruptTicketMutex;
use hermit_sync::{RawRwSpinLock, RawSpinMutex};

use crate::arch::kernel::CPU_ONLINE;
#[cfg(not(feature = "riscv-plic"))]
use crate::arch::kernel::interrupts::MsiController;
#[cfg(feature = "smp")]
use crate::scheduler::SchedulerInput;
use crate::scheduler::{CoreId, PerCoreScheduler};
Expand All @@ -26,6 +28,8 @@ pub struct CoreLocal {
/// Queues to handle incoming requests from the other cores
#[cfg(feature = "smp")]
pub scheduler_input: InterruptTicketMutex<SchedulerInput>,
#[cfg(not(feature = "riscv-plic"))]
msi_controller: Cell<*mut MsiController>,
}

impl CoreLocal {
Expand All @@ -44,6 +48,8 @@ impl CoreLocal {
ex: StaticLocalExecutor::new(),
#[cfg(feature = "smp")]
scheduler_input: InterruptTicketMutex::new(SchedulerInput::new()),
#[cfg(not(feature = "riscv-plic"))]
msi_controller: Cell::new(ptr::null_mut()),
};
let this = if core_id == 0 {
take_static::take_static! {
Expand Down Expand Up @@ -87,3 +93,13 @@ pub fn set_core_scheduler(scheduler: *mut PerCoreScheduler) {
pub(crate) fn ex() -> &'static StaticLocalExecutor<RawSpinMutex, RawRwSpinLock> {
&CoreLocal::get().ex
}

#[cfg(not(feature = "riscv-plic"))]
pub(crate) fn msi_controller() -> Option<&'static mut MsiController> {
unsafe { CoreLocal::get().msi_controller.get().as_mut() }
}

#[cfg(not(feature = "riscv-plic"))]
pub(crate) fn set_msi_controller(msi_controller: *mut MsiController) {
CoreLocal::get().msi_controller.set(msi_controller);
}
Loading
Loading