summaryrefslogtreecommitdiffstats
path: root/tools/lguest/lguest.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2015-02-11 15:23:01 +1030
committerRusty Russell <rusty@rustcorp.com.au>2015-02-11 16:47:43 +1030
commite8330d9bc1f7af7737500aebd3fc1f488e3dbb71 (patch)
treecd969719b32d065937524a733eb06c90d5496419 /tools/lguest/lguest.c
parentb3e28b65de254570140832cf7c95255ab4d501bb (diff)
downloadop-kernel-dev-e8330d9bc1f7af7737500aebd3fc1f488e3dbb71.zip
op-kernel-dev-e8330d9bc1f7af7737500aebd3fc1f488e3dbb71.tar.gz
lguest: support emerg_wr in console device in example launcher.
This is a magic register which causes a character to be outputted: it can be used even before the device is configured. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'tools/lguest/lguest.c')
-rw-r--r--tools/lguest/lguest.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c
index b5ac735..8959ac2 100644
--- a/tools/lguest/lguest.c
+++ b/tools/lguest/lguest.c
@@ -71,7 +71,7 @@ typedef uint8_t u8;
#include "../../include/uapi/linux/virtio_config.h"
#include "../../include/uapi/linux/virtio_net.h"
#include "../../include/uapi/linux/virtio_blk.h"
-#include <linux/virtio_console.h>
+#include "../../include/uapi/linux/virtio_console.h"
#include "../../include/uapi/linux/virtio_rng.h"
#include <linux/virtio_ring.h>
#include "../../include/uapi/linux/virtio_pci.h"
@@ -1687,6 +1687,15 @@ static void emulate_mmio_write(struct device *d, u32 off, u32 val, u32 mask)
goto write_through16;
case offsetof(struct virtio_pci_mmio, isr):
errx(1, "%s: Unexpected write to isr", d->name);
+ /* Weird corner case: write to emerg_wr of console */
+ case sizeof(struct virtio_pci_mmio)
+ + offsetof(struct virtio_console_config, emerg_wr):
+ if (strcmp(d->name, "console") == 0) {
+ char c = val;
+ write(STDOUT_FILENO, &c, 1);
+ goto write_through32;
+ }
+ /* Fall through... */
default:
errx(1, "%s: Unexpected write to offset %u", d->name, off);
}
@@ -2048,6 +2057,7 @@ static struct device *new_pci_device(const char *name, u16 type,
static void setup_console(void)
{
struct device *dev;
+ struct virtio_console_config conf;
/* If we can save the initial standard input settings... */
if (tcgetattr(STDIN_FILENO, &orig_term) == 0) {
@@ -2075,8 +2085,9 @@ static void setup_console(void)
add_pci_virtqueue(dev, console_input);
add_pci_virtqueue(dev, console_output);
- /* There's no configuration area for this device. */
- no_device_config(dev);
+ /* We need a configuration area for the emerg_wr early writes. */
+ add_pci_feature(dev, VIRTIO_CONSOLE_F_EMERG_WRITE);
+ set_device_config(dev, &conf, sizeof(conf));
verbose("device %u: console\n", devices.device_num);
}
OpenPOWER on IntegriCloud