diff --git a/Makefile b/Makefile index 0307c99a1..542305936 100644 --- a/Makefile +++ b/Makefile @@ -37,17 +37,17 @@ # - `MUSL`: Link C app with musl libc # General options -ARCH ?= x86_64 +ARCH ?= aarch64 PLATFORM ?= SMP ?= 1 -MODE ?= release -LOG ?= warn +MODE ?= reldebug +LOG ?= info V ?= # App options -A ?= apps/c/helloworld +A ?= apps/fs/shell APP ?= $(A) -FEATURES ?= +FEATURES ?= virtio_console irq APP_FEATURES ?= # QEMU options diff --git a/modules/ruxhal/src/platform/aarch64_common/gic.rs b/modules/ruxhal/src/platform/aarch64_common/gic.rs index 1df2ef11e..5f86ac33b 100644 --- a/modules/ruxhal/src/platform/aarch64_common/gic.rs +++ b/modules/ruxhal/src/platform/aarch64_common/gic.rs @@ -19,9 +19,6 @@ pub const MAX_IRQ_COUNT: usize = 1024; /// The timer IRQ number. pub const TIMER_IRQ_NUM: usize = translate_irq(14, InterruptType::PPI).unwrap(); -/// The UART IRQ number. -pub const UART_IRQ_NUM: usize = translate_irq(ruxconfig::UART_IRQ, InterruptType::SPI).unwrap(); - const GICD_BASE: PhysAddr = PhysAddr::from(ruxconfig::GICD_PADDR); const GICC_BASE: PhysAddr = PhysAddr::from(ruxconfig::GICC_PADDR); diff --git a/modules/ruxhal/src/platform/dummy/mod.rs b/modules/ruxhal/src/platform/dummy/mod.rs index f1138132c..164f9b6a8 100644 --- a/modules/ruxhal/src/platform/dummy/mod.rs +++ b/modules/ruxhal/src/platform/dummy/mod.rs @@ -82,8 +82,6 @@ pub mod irq { /// The timer IRQ number. pub const TIMER_IRQ_NUM: usize = 0; - pub const UART_IRQ_NUM: usize = 0; - /// Enables or disables the given IRQ. pub fn set_enable(irq_num: usize, enabled: bool) {} diff --git a/modules/ruxhal/src/virtio/virtio_console.rs b/modules/ruxhal/src/virtio/virtio_console.rs index 626dd1d91..2ebcaa814 100644 --- a/modules/ruxhal/src/virtio/virtio_console.rs +++ b/modules/ruxhal/src/virtio/virtio_console.rs @@ -101,13 +101,7 @@ pub fn putchar(c: u8) { warn!("######################### The above content is printed from buffer! #########################"); } let mut uart = uart_inner.lock(); - match c { - b'\n' => { - uart.putchar(b'\r'); - uart.putchar(b'\n'); - } - c => uart.putchar(c), - } + uart.putchar(c); } else { UART.buffer[UART.pointer] = c; UART.pointer += 1; @@ -133,14 +127,12 @@ pub fn getchar() -> Option { /// probe virtio console directly pub fn directional_probing() { info!("Initiating VirtIO Console ..."); - for reg in ruxconfig::VIRTIO_MMIO_REGIONS { - { - if let Some(dev) = probe_mmio(reg.0, reg.1) { - unsafe { - UART.inner = Some(SpinNoIrq::new(dev)); - UART.addr = reg.0; - } - } + let uart_base: usize = ruxconfig::VIRTIO_CONSOLE_PADDR; + let uart_reg: usize = 0x200; + if let Some(dev) = probe_mmio(uart_base, uart_reg) { + unsafe { + UART.inner = Some(SpinNoIrq::new(dev)); + UART.addr = uart_base; } } info!("Output now redirected to VirtIO Console!"); @@ -150,10 +142,11 @@ pub fn directional_probing() { pub fn enable_interrupt() { #[cfg(all(feature = "irq", target_arch = "aarch64"))] { + let virtio_console_irq_num = ruxconfig::VIRTIO_CONSOLE_IRQ + 32; info!("Initiating VirtIO Console interrupt ..."); - info!("IRQ ID: {}", crate::platform::irq::UART_IRQ_NUM); - crate::irq::register_handler(crate::platform::irq::UART_IRQ_NUM, irq_handler); - crate::irq::set_enable(crate::platform::irq::UART_IRQ_NUM, true); + info!("IRQ ID: {}", virtio_console_irq_num); + crate::irq::register_handler(virtio_console_irq_num, irq_handler); + crate::irq::set_enable(virtio_console_irq_num, true); ack_interrupt(); info!("Interrupt enabled!"); } diff --git a/platforms/aarch64-qemu-virt.toml b/platforms/aarch64-qemu-virt.toml index 06c579c58..8d713e0fa 100644 --- a/platforms/aarch64-qemu-virt.toml +++ b/platforms/aarch64-qemu-virt.toml @@ -82,7 +82,11 @@ pci-ranges = [ ] # UART Address uart-paddr = "0x9000000" -uart-irq = "47" +uart-irq = "1" + +# Virtio console +virtio-console-paddr = "0xa003e00" +virtio-console-irq = "47" # GICC Address gicc-paddr = "0x0801_0000" diff --git a/scripts/make/qemu.mk b/scripts/make/qemu.mk index 0611f6d7a..7d99e4dff 100644 --- a/scripts/make/qemu.mk +++ b/scripts/make/qemu.mk @@ -31,7 +31,7 @@ qemu_args-aarch64 := \ qemu_args-y := -m 2G -smp $(SMP) $(qemu_args-$(ARCH)) \ - -append ";$(ARGS);$(ENVS)" \ + -append ";$(ARGS);$(ENVS)" qemu_args-$(CONSOLE) += \ -global virtio-mmio.force-legacy=false \