From f40b1bd8f9f6e8ae7089dfbfdc47acff42aa487a Mon Sep 17 00:00:00 2001 From: Alexander Kudryavtsev Date: Mon, 26 Sep 2011 12:21:06 +0400 Subject: [PATCH 14/32] Experimental serial passthrough feature --- palacios/src/devices/Kconfig | 6 +++ palacios/src/devices/Makefile | 1 + palacios/src/devices/apic.c | 2 +- palacios/src/devices/serial_passthrough.c | 57 +++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletions(-) create mode 100644 palacios/src/devices/serial_passthrough.c diff --git a/palacios/src/devices/Kconfig b/palacios/src/devices/Kconfig index 39334ea..b6543a6 100644 --- a/palacios/src/devices/Kconfig +++ b/palacios/src/devices/Kconfig @@ -292,6 +292,12 @@ config PASSTHROUGH_PCI help Enables hardware devices to be passed through to the VM +config SERIAL_PASSTHROUGH + bool "Passthrough serial port IRQ" + default n + depends on EXPERIMENTAL + help + Passes through IRQ 4. With ports 0x3f8 being passed through in configuration, it allows to expose real serial interface to guest. config DEBUG_PCI bool "PCI debugging" diff --git a/palacios/src/devices/Makefile b/palacios/src/devices/Makefile index 8db8c3f..70c9be1 100644 --- a/palacios/src/devices/Makefile +++ b/palacios/src/devices/Makefile @@ -39,6 +39,7 @@ obj-$(V3_CONFIG_TELNET_CONSOLE) += telnet_cons.o obj-$(V3_CONFIG_CURSES_CONSOLE) += curses_cons.o obj-$(V3_CONFIG_PASSTHROUGH_PCI) += pci_passthrough.o +obj-$(V3_CONFIG_SERIAL_PASSTHROUGH) += serial_passthrough.o obj-$(V3_CONFIG_SYMMOD) += lnx_virtio_symmod.o obj-$(V3_CONFIG_CHAR_STREAM) += char_stream.o diff --git a/palacios/src/devices/apic.c b/palacios/src/devices/apic.c index 7095dbf..dc7c2d1 100644 --- a/palacios/src/devices/apic.c +++ b/palacios/src/devices/apic.c @@ -1438,7 +1438,7 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u } case INT_CMD_HI_OFFSET: { apic->int_cmd.hi = op_val; - V3_Print("apic %u: core %u: writing command high=0x%x\n", apic->lapic_id.val, core->vcpu_id,apic->int_cmd.hi); + //V3_Print("apic %u: core %u: writing command high=0x%x\n", apic->lapic_id.val, core->vcpu_id,apic->int_cmd.hi); break; } diff --git a/palacios/src/devices/serial_passthrough.c b/palacios/src/devices/serial_passthrough.c new file mode 100644 index 0000000..d4d0998 --- /dev/null +++ b/palacios/src/devices/serial_passthrough.c @@ -0,0 +1,57 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2008, Jack Lange + * Copyright (c) 2008, The V3VEE Project + * All rights reserved. + * + * Author: Alexander Kudryavtsev + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + +#include +#include +#include +#include +#include +#include + +static struct v3_device_ops dev_ops = { + .free = NULL, +}; + + +static int irq_handler(struct v3_vm_info * info, struct v3_interrupt * intr, void * private_data) { + + v3_raise_irq(info, 4); + + V3_ACK_IRQ(intr->irq); + + return 0; +} + + +static int serial_init(struct v3_vm_info * info, v3_cfg_tree_t * cfg) { + char * name = v3_cfg_val(cfg, "name"); + + if (v3_add_device(info, "serial", &dev_ops, NULL) == NULL) { + PrintError("Could not attach device %s\n", name); + return -1; + } + + v3_hook_irq(info, atoi(v3_cfg_val(cfg, "irq")), irq_handler, NULL); + + return 0; +} + + +device_register("SERIAL_PASSTHROUGH", serial_init); -- 1.7.5.4