Commit f114784f69ec3b9af342148025de14dbd1b429a5

Authored by Jan Kiszka
Committed by Anthony Liguori
1 parent ef74679a

monitor: Add port write command

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>
Showing 2 changed files with 24 additions and 0 deletions
monitor.c
... ... @@ -1185,6 +1185,25 @@ static void do_ioport_read(Monitor *mon, int count, int format, int size,
1185 1185 suffix, addr, size * 2, val);
1186 1186 }
1187 1187  
  1188 +static void do_ioport_write(Monitor *mon, int count, int format, int size,
  1189 + int addr, int val)
  1190 +{
  1191 + addr &= IOPORTS_MASK;
  1192 +
  1193 + switch (size) {
  1194 + default:
  1195 + case 1:
  1196 + cpu_outb(NULL, addr, val);
  1197 + break;
  1198 + case 2:
  1199 + cpu_outw(NULL, addr, val);
  1200 + break;
  1201 + case 4:
  1202 + cpu_outl(NULL, addr, val);
  1203 + break;
  1204 + }
  1205 +}
  1206 +
1188 1207 static void do_boot_set(Monitor *mon, const char *bootdevice)
1189 1208 {
1190 1209 int res;
... ...
qemu-monitor.hx
... ... @@ -306,6 +306,11 @@ STEXI
306 306 Read I/O port.
307 307 ETEXI
308 308  
  309 + { "o", "/ii", do_ioport_write,
  310 + "/fmt addr value", "I/O port write" },
  311 +STEXI
  312 +Write to I/O port.
  313 +ETEXI
309 314  
310 315 { "sendkey", "si?", do_sendkey,
311 316 "keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" },
... ...