From: Waldemar Kozaczuk <
jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <
jwkoz...@gmail.com>
Branch: master
arm: add memory-mapped isa console
This patch adds the mmio (memory-mapped IO) isa
console class to be used on firecracker. Next patches
will add logic to detect and enable this console.
Signed-off-by: Waldemar Kozaczuk <
jwkoz...@gmail.com>
---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -817,6 +817,7 @@ drivers += drivers/xenplatform-pci.o
endif # x64
ifeq ($(arch),aarch64)
+drivers += drivers/mmio-isa-serial.o
drivers += drivers/pl011.o
drivers += drivers/xenconsole.o
drivers += drivers/virtio.o
diff --git a/drivers/mmio-isa-serial.cc b/drivers/mmio-isa-serial.cc
--- a/drivers/mmio-isa-serial.cc
+++ b/drivers/mmio-isa-serial.cc
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 Cloudius Systems, Ltd.
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#include "mmio-isa-serial.hh"
+
+namespace console {
+
+mmioaddr_t mmio_isa_serial_console::_addr_mmio;
+u64 mmio_isa_serial_console::_phys_mmio_address;
+
+u8 isa_serial_console_base::read_byte(int reg) {
+ return mmio_getb(mmio_isa_serial_console::_addr_mmio + reg);
+};
+
+void isa_serial_console_base::write_byte(u8 val, int reg) {
+ mmio_setb(mmio_isa_serial_console::_addr_mmio + reg, val);
+};
+
+void mmio_isa_serial_console::early_init(u64 mmio_phys_address)
+{
+ _phys_mmio_address = mmio_phys_address;
+ _addr_mmio = reinterpret_cast<char*>(mmio_phys_address);
+
+ common_early_init();
+}
+
+void mmio_isa_serial_console::memory_map()
+{
+ if (_phys_mmio_address) {
+ _addr_mmio = mmio_map(_phys_mmio_address, mmu::page_size);
+ }
+}
+
+void mmio_isa_serial_console::dev_start() {
+ _irq.reset(new spi_interrupt(gic::irq_type::IRQ_TYPE_EDGE, 64,
+ [&] { return true; },
+ [&] { _thread->wake(); }));
+ enable_interrupt();
+}
+
+}
diff --git a/drivers/mmio-isa-serial.hh b/drivers/mmio-isa-serial.hh
--- a/drivers/mmio-isa-serial.hh
+++ b/drivers/mmio-isa-serial.hh
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2013 Cloudius Systems, Ltd.
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#ifndef DRIVERS_MMIO_ISA_SERIAL_HH
+#define DRIVERS_MMIO_ISA_SERIAL_HH
+
+#include "isa-serial-base.hh"
+
+namespace console {
+
+class mmio_isa_serial_console : public isa_serial_console_base {
+public:
+ void set_irqid(int irqid) { this->irqid = irqid; }
+ static void early_init(u64 mmio_phys_address);
+ static void memory_map();
+ static mmioaddr_t _addr_mmio;
+ static u64 _phys_mmio_address;
+private:
+ unsigned int irqid;
+ std::unique_ptr<spi_interrupt> _irq;
+ virtual void dev_start();
+ virtual const char *thread_name() { return "mmio-isa-serial-input"; }
+};
+
+}
+
+#endif