Skip to content

Commit

Permalink
monitor: Add port write command
Browse files Browse the repository at this point in the history
Useful for testing hardware emulations or manipulating its state to
stress guest drivers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
jan-kiszka authored and Anthony Liguori committed Jul 16, 2009
1 parent ef74679 commit f114784
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,25 @@ static void do_ioport_read(Monitor *mon, int count, int format, int size,
suffix, addr, size * 2, val);
}

static void do_ioport_write(Monitor *mon, int count, int format, int size,
int addr, int val)
{
addr &= IOPORTS_MASK;

switch (size) {
default:
case 1:
cpu_outb(NULL, addr, val);
break;
case 2:
cpu_outw(NULL, addr, val);
break;
case 4:
cpu_outl(NULL, addr, val);
break;
}
}

static void do_boot_set(Monitor *mon, const char *bootdevice)
{
int res;
Expand Down
5 changes: 5 additions & 0 deletions qemu-monitor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ STEXI
Read I/O port.
ETEXI

{ "o", "/ii", do_ioport_write,
"/fmt addr value", "I/O port write" },
STEXI
Write to I/O port.
ETEXI

{ "sendkey", "si?", do_sendkey,
"keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" },
Expand Down

0 comments on commit f114784

Please sign in to comment.