[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH] plat/kvm: Option for serial baudrate (x86)



Adds an option to select the baudrate for the serial port that is used
for kernel and/or debug output. This is a useful for running the KVM
port as bare-metal x86 instance.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 plat/kvm/Config.uk            | 22 ++++++++++++++++++++++
 plat/kvm/x86/serial_console.c | 18 ++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk
index 9aa8a632..3372b6c5 100644
--- a/plat/kvm/Config.uk
+++ b/plat/kvm/Config.uk
@@ -41,6 +41,28 @@ config KVM_DEBUG_VGA_CONSOLE
         depends on ARCH_X86_64
         help
           Choose VGA console for the debug printing
+
+if (KVM_KVM_KERNEL_SERIAL_CONSOLE || KVM_DEBUG_SERIAL_CONSOLE) && ARCH_X86_64
+menu "Serial console configuration"
+       choice
+               prompt "Baudrate"
+               default KVM_SERIAL_BAUD_115200
+
+               config KVM_SERIAL_BAUD_115200
+                       bool "115200"
+
+               config KVM_SERIAL_BAUD_57600
+                       bool "57600"
+
+               config KVM_SERIAL_BAUD_38400
+                       bool "38400"
+
+               config KVM_SERIAL_BAUD_19200
+                       bool "19200"
+       endchoice
+endmenu
+endif
+
 endmenu
 
 config KVM_PCI
diff --git a/plat/kvm/x86/serial_console.c b/plat/kvm/x86/serial_console.c
index dc9eafa0..f46c69a2 100644
--- a/plat/kvm/x86/serial_console.c
+++ b/plat/kvm/x86/serial_console.c
@@ -25,6 +25,7 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <uk/config.h>
 #include <kvm-x86/serial_console.h>
 #include <x86/cpu.h>
 
@@ -39,6 +40,19 @@
 #define COM1_DIV_LO (COM1 + 0)
 #define COM1_DIV_HI (COM1 + 1)
 
+/* baudrate divisor */
+#define COM1_BAUDDIV_HI 0x00
+
+#if CONFIG_KVM_SERIAL_BAUD_19200
+#define COM1_BAUDDIV_LO 0x04
+#elif CONFIG_KVM_SERIAL_BAUD_38400
+#define COM1_BAUDDIV_LO 0x03
+#elif CONFIG_KVM_SERIAL_BAUD_57600
+#define COM1_BAUDDIV_LO 0x02
+#else /* default, CONFIG_KVM_SERIAL_BAUD_115200 */
+#define COM1_BAUDDIV_LO 0x01
+#endif
+
 #define DLAB 0x80
 #define PROT 0x03 /* 8N1 (8 bits, no parity, one stop bit) */
 
@@ -46,8 +60,8 @@ void _libkvmplat_init_serial_console(void)
 {
        outb(COM1_INTR, 0x00);  /* Disable all interrupts */
        outb(COM1_CTRL, DLAB);  /* Enable DLAB (set baudrate divisor) */
-       outb(COM1_DIV_LO, 0x01);/* Set div to 1 (lo byte) 115200 baud */
-       outb(COM1_DIV_HI, 0x00);/*              (hi byte) */
+       outb(COM1_DIV_LO, COM1_BAUDDIV_LO);/* Div (lo byte) */
+       outb(COM1_DIV_HI, COM1_BAUDDIV_HI);/*     (hi byte) */
        outb(COM1_CTRL, PROT);  /* Set 8N1, clear DLAB */
 }
 
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.