Skip to content

Commit

Permalink
reply review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ForeverYolo committed Oct 31, 2024
1 parent e96d66f commit 2e942b4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 30 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions modules/ruxhal/src/platform/aarch64_common/gic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions modules/ruxhal/src/platform/dummy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
29 changes: 11 additions & 18 deletions modules/ruxhal/src/virtio/virtio_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -133,14 +127,12 @@ pub fn getchar() -> Option<u8> {
/// 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!");
Expand All @@ -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!");
}
Expand Down
6 changes: 5 additions & 1 deletion platforms/aarch64-qemu-virt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/make/qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 2e942b4

Please sign in to comment.