Commit 3440557b6d979e0dddddb8c2440d7bf4375e80a7
1 parent
d329a6fb
ioport read command
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@912 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
51 additions
and
5 deletions
monitor.c
... | ... | @@ -630,6 +630,35 @@ static void do_send_key(const char *string) |
630 | 630 | } |
631 | 631 | } |
632 | 632 | |
633 | +static void do_ioport_read(int count, int format, int size, int addr, int has_index, int index) | |
634 | +{ | |
635 | + uint32_t val; | |
636 | + int suffix; | |
637 | + | |
638 | + if (has_index) { | |
639 | + cpu_outb(NULL, addr & 0xffff, index & 0xff); | |
640 | + addr++; | |
641 | + } | |
642 | + addr &= 0xffff; | |
643 | + | |
644 | + switch(size) { | |
645 | + default: | |
646 | + case 1: | |
647 | + val = cpu_inb(NULL, addr); | |
648 | + suffix = 'b'; | |
649 | + break; | |
650 | + case 2: | |
651 | + val = cpu_inw(NULL, addr); | |
652 | + suffix = 'w'; | |
653 | + break; | |
654 | + case 4: | |
655 | + val = cpu_inl(NULL, addr); | |
656 | + suffix = 'l'; | |
657 | + break; | |
658 | + } | |
659 | + term_printf("port%c[0x%04x] = %#0*x\n", | |
660 | + suffix, addr, size * 2, val); | |
661 | +} | |
633 | 662 | |
634 | 663 | static term_cmd_t term_cmds[] = { |
635 | 664 | { "help|?", "s?", do_help, |
... | ... | @@ -666,6 +695,9 @@ static term_cmd_t term_cmds[] = { |
666 | 695 | "/fmt addr", "physical memory dump starting at 'addr'", }, |
667 | 696 | { "p|print", "/i", do_print, |
668 | 697 | "/fmt expr", "print expression value (use $reg for CPU register access)", }, |
698 | + { "i", "/ii.", do_ioport_read, | |
699 | + "/fmt addr", "I/O port read" }, | |
700 | + | |
669 | 701 | { "sendkey", "s", do_send_key, |
670 | 702 | "keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, |
671 | 703 | { NULL, NULL, }, |
... | ... | @@ -1285,12 +1317,23 @@ static void term_handle_command(const char *cmdline) |
1285 | 1317 | int val; |
1286 | 1318 | while (isspace(*p)) |
1287 | 1319 | p++; |
1288 | - if (*typestr == '?') { | |
1320 | + if (*typestr == '?' || *typestr == '.') { | |
1289 | 1321 | typestr++; |
1290 | - if (*p == '\0') | |
1291 | - has_arg = 0; | |
1292 | - else | |
1293 | - has_arg = 1; | |
1322 | + if (*typestr == '?') { | |
1323 | + if (*p == '\0') | |
1324 | + has_arg = 0; | |
1325 | + else | |
1326 | + has_arg = 1; | |
1327 | + } else { | |
1328 | + if (*p == '.') { | |
1329 | + p++; | |
1330 | + while (isspace(*p)) | |
1331 | + p++; | |
1332 | + has_arg = 1; | |
1333 | + } else { | |
1334 | + has_arg = 0; | |
1335 | + } | |
1336 | + } | |
1294 | 1337 | if (nb_args >= MAX_ARGS) |
1295 | 1338 | goto error_args; |
1296 | 1339 | args[nb_args++] = (void *)has_arg; |
... | ... | @@ -1369,6 +1412,9 @@ static void term_handle_command(const char *cmdline) |
1369 | 1412 | case 5: |
1370 | 1413 | cmd->handler(args[0], args[1], args[2], args[3], args[4]); |
1371 | 1414 | break; |
1415 | + case 6: | |
1416 | + cmd->handler(args[0], args[1], args[2], args[3], args[4], args[5]); | |
1417 | + break; | |
1372 | 1418 | default: |
1373 | 1419 | term_printf("unsupported number of arguments: %d\n", nb_args); |
1374 | 1420 | goto fail; | ... | ... |