Skip to content

Commit c707ae9

Browse files
committed
Change semihosting to conditional compilation
1 parent 409913f commit c707ae9

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

kernel/src/arch/aarch64/virt/exit.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use super::{guest, hyper, vcpu::Vcpu, vgic};
1616
use core::arch::asm;
17+
#[cfg(test)]
1718
use semihosting::println;
1819

1920
static mut GUEST_SHUTDOWN: bool = false;
@@ -78,7 +79,6 @@ pub fn handle_vm_exit(vcpu: &mut Vcpu) -> bool {
7879
VmExitReason::Hvc => handle_hvc(vcpu, &exit_info),
7980
VmExitReason::Svc => handle_svc(vcpu, &exit_info),
8081
VmExitReason::DataAbortLowerEL => {
81-
semihosting::println!("[EXIT] Data Abort from Guest (Stage-2 Fault)");
8282
let iss = esr & 0x1FFFFFF;
8383
let dfsc = iss & 0x3F;
8484
let is_write = (iss & (1 << 6)) != 0;
@@ -106,6 +106,7 @@ pub fn handle_vm_exit(vcpu: &mut Vcpu) -> bool {
106106
vgic::flush(vcpu.id());
107107
return true;
108108
} else {
109+
#[cfg(test)]
109110
semihosting::println!("[EXIT] Unhandled Stage-2 Address!");
110111
}
111112
}
@@ -142,6 +143,7 @@ pub fn handle_vm_exit(vcpu: &mut Vcpu) -> bool {
142143
}
143144
}
144145
VmExitReason::Unknown(ec) => {
146+
#[cfg(test)]
145147
semihosting::println!("[EXIT] Unknown Exit Reason: EC = {:#x}", ec);
146148
false
147149
}
@@ -184,6 +186,7 @@ fn handle_hvc(vcpu: &mut Vcpu, info: &VmExitInfo) -> bool {
184186
}
185187
}
186188
_ => {
189+
#[cfg(test)]
187190
semihosting::println!("[EXIT] HVC#0: Ignored PSCI call: {:#x}", psci_func_id);
188191
context.regs[0] = 0xFFFF_FFFF;
189192
}
@@ -196,6 +199,7 @@ fn handle_hvc(vcpu: &mut Vcpu, info: &VmExitInfo) -> bool {
196199
true
197200
}
198201
_ => {
202+
#[cfg(test)]
199203
semihosting::println!("[EXIT] Unknown HVC Number");
200204
true
201205
}

kernel/src/arch/aarch64/virt/mmu_s2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
use crate::arch::aarch64::registers::{vtcr_el2::VTCR_EL2, vttbr_el2::VTTBR_EL2};
16-
use semihosting::println;
1716
use tock_registers::interfaces::*;
1817

1918
// Structure of Page Table.

kernel/src/arch/aarch64/virt/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ pub use crate::arch::aarch64::psci::hvc_call;
2525
use blueos_hal::PlatPeri;
2626
pub use exit::{VmExitInfo, VmExitReason};
2727
pub use hyper::{get_current_el, hyp_init};
28-
use semihosting::println;
2928
pub use vcpu::{Vcpu, VcpuManager, VcpuState};
3029
pub use vgic::init;
3130

31+
#[cfg(test)]
32+
use semihosting::println;
33+
3234
// PL011 UART addresses for QEMU Virt
3335
const UART0_DR: *mut u32 = 0x0900_0000 as *mut u32;
3436
const UART0_FR: *mut u32 = 0x0900_0018 as *mut u32;
@@ -84,6 +86,7 @@ pub extern "C" fn hyper_trap_irq(_context: &mut crate::arch::aarch64::Context) -
8486
core::arch::asm!("msr ICC_EOIR1_EL1, {}", in(reg) iar);
8587
}
8688
} else {
89+
#[cfg(test)]
8790
semihosting::println!("[EL2] Unhandled Guest IRQ: {}", intid);
8891
// For uninterruptible/unknown interrupts,
8992
// we must manually downgrade and deactivate them;
@@ -150,6 +153,7 @@ pub fn virt_boot_linux() {
150153
if result == 0 {
151154
let uart = crate::boards::get_device!(console_uart);
152155
uart.enable();
156+
#[cfg(test)]
153157
semihosting::println!("Linux shutdown!!!");
154158
}
155159
}

0 commit comments

Comments
 (0)