aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-06-08 00:55:58 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-06-08 00:55:58 +0000
commit3440557b6d979e0dddddb8c2440d7bf4375e80a7 (patch)
treec1cbe72b9dd41247fd0acf96b9a6039db5cd2c8e /monitor.c
parentd329a6fb2213e53008a9b1cd186fe2ff258fa272 (diff)
ioport read command
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@912 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/monitor.c b/monitor.c
index b7ce550cf5..d3c51e6574 100644
--- a/monitor.c
+++ b/monitor.c
@@ -630,6 +630,35 @@ static void do_send_key(const char *string)
}
}
+static void do_ioport_read(int count, int format, int size, int addr, int has_index, int index)
+{
+ uint32_t val;
+ int suffix;
+
+ if (has_index) {
+ cpu_outb(NULL, addr & 0xffff, index & 0xff);
+ addr++;
+ }
+ addr &= 0xffff;
+
+ switch(size) {
+ default:
+ case 1:
+ val = cpu_inb(NULL, addr);
+ suffix = 'b';
+ break;
+ case 2:
+ val = cpu_inw(NULL, addr);
+ suffix = 'w';
+ break;
+ case 4:
+ val = cpu_inl(NULL, addr);
+ suffix = 'l';
+ break;
+ }
+ term_printf("port%c[0x%04x] = %#0*x\n",
+ suffix, addr, size * 2, val);
+}
static term_cmd_t term_cmds[] = {
{ "help|?", "s?", do_help,
@@ -666,6 +695,9 @@ static term_cmd_t term_cmds[] = {
"/fmt addr", "physical memory dump starting at 'addr'", },
{ "p|print", "/i", do_print,
"/fmt expr", "print expression value (use $reg for CPU register access)", },
+ { "i", "/ii.", do_ioport_read,
+ "/fmt addr", "I/O port read" },
+
{ "sendkey", "s", do_send_key,
"keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" },
{ NULL, NULL, },
@@ -1285,12 +1317,23 @@ static void term_handle_command(const char *cmdline)
int val;
while (isspace(*p))
p++;
- if (*typestr == '?') {
+ if (*typestr == '?' || *typestr == '.') {
typestr++;
- if (*p == '\0')
- has_arg = 0;
- else
- has_arg = 1;
+ if (*typestr == '?') {
+ if (*p == '\0')
+ has_arg = 0;
+ else
+ has_arg = 1;
+ } else {
+ if (*p == '.') {
+ p++;
+ while (isspace(*p))
+ p++;
+ has_arg = 1;
+ } else {
+ has_arg = 0;
+ }
+ }
if (nb_args >= MAX_ARGS)
goto error_args;
args[nb_args++] = (void *)has_arg;
@@ -1369,6 +1412,9 @@ static void term_handle_command(const char *cmdline)
case 5:
cmd->handler(args[0], args[1], args[2], args[3], args[4]);
break;
+ case 6:
+ cmd->handler(args[0], args[1], args[2], args[3], args[4], args[5]);
+ break;
default:
term_printf("unsupported number of arguments: %d\n", nb_args);
goto fail;