vmm: AArch64: Use PL011 for AArch64 device tree

This commit switches the default serial device from 16550 to the
Arm dedicated UART controller PL011. The `ttyAMA0` can be enabled.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
Henry Wang 2021-03-12 13:18:52 +08:00 committed by Michael
parent fd95acc60f
commit a8cde12b14
2 changed files with 16 additions and 9 deletions

View File

@ -487,11 +487,12 @@ fn create_serial_node<T: DeviceInfoForFDT + Clone + Debug>(
fdt: &mut Vec<u8>,
dev_info: &T,
) -> Result<()> {
let compatible = b"arm,pl011\0arm,primecell\0";
let serial_reg_prop = generate_prop64(&[dev_info.addr(), dev_info.length()]);
let irq = generate_prop32(&[GIC_FDT_IRQ_TYPE_SPI, dev_info.irq(), IRQ_TYPE_EDGE_RISING]);
append_begin_node(fdt, &format!("U6_16550A@{:x}", dev_info.addr()))?;
append_property_string(fdt, "compatible", "ns16550a")?;
append_begin_node(fdt, &format!("pl011@{:x}", dev_info.addr()))?;
append_property(fdt, "compatible", compatible)?;
append_property(fdt, "reg", &serial_reg_prop)?;
append_property_u32(fdt, "clocks", CLOCK_PHANDLE)?;
append_property_string(fdt, "clock-names", "apb_pclk")?;

View File

@ -47,9 +47,12 @@ use block_util::{
use devices::gic;
#[cfg(target_arch = "x86_64")]
use devices::ioapic;
#[cfg(target_arch = "x86_64")]
use devices::legacy::Serial;
#[cfg(target_arch = "aarch64")]
use devices::legacy::PL011;
use devices::{
interrupt_controller, interrupt_controller::InterruptController, legacy::Serial,
AcpiNotificationFlags,
interrupt_controller, interrupt_controller::InterruptController, AcpiNotificationFlags,
};
#[cfg(feature = "kvm")]
use hypervisor::kvm_ioctls::*;
@ -494,8 +497,11 @@ enum ConsoleInput {
}
#[derive(Default)]
pub struct Console {
#[cfg(target_arch = "x86_64")]
// Serial port on 0x3f8
serial: Option<Arc<Mutex<Serial>>>,
#[cfg(target_arch = "aarch64")]
serial: Option<Arc<Mutex<PL011>>>,
virtio_console_input: Option<Arc<virtio_devices::ConsoleInput>>,
input: Option<ConsoleInput>,
}
@ -1598,7 +1604,7 @@ impl DeviceManager {
&mut self,
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>>,
serial_writer: Option<Box<dyn io::Write + Send>>,
) -> DeviceManagerResult<Arc<Mutex<Serial>>> {
) -> DeviceManagerResult<Arc<Mutex<devices::legacy::PL011>>> {
let id = String::from(SERIAL_DEVICE_NAME_PREFIX);
let serial_irq = self
@ -1615,7 +1621,7 @@ impl DeviceManager {
})
.map_err(DeviceManagerError::CreateInterruptGroup)?;
let serial = Arc::new(Mutex::new(Serial::new(
let serial = Arc::new(Mutex::new(devices::legacy::PL011::new(
id.clone(),
interrupt_group,
serial_writer,
@ -1628,20 +1634,20 @@ impl DeviceManager {
self.address_manager
.mmio_bus
.insert(serial.clone(), addr.0, 0x8)
.insert(serial.clone(), addr.0, MMIO_LEN)
.map_err(DeviceManagerError::BusError)?;
self.id_to_dev_info.insert(
(DeviceType::Serial, DeviceType::Serial.to_string()),
MMIODeviceInfo {
addr: addr.0,
len: 0x8,
len: MMIO_LEN,
irq: serial_irq,
},
);
self.cmdline_additions
.push(format!("earlycon=uart,mmio,0x{:08x}", addr.0));
.push(format!("earlycon=pl011,mmio,0x{:08x}", addr.0));
// Fill the device tree with a new node. In case of restore, we
// know there is nothing to do, so we can simply override the