]> git.proxmox.com Git - qemu.git/blobdiff - monitor.c
64 bit support
[qemu.git] / monitor.c
index 9befd82b06eb0607f9ef34678a10c5f24c6589b0..9a18639c4b2fa0f2574bf9e1241a6fb9b3e7c90f 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -255,6 +255,14 @@ static void do_info_cpus(void)
         term_printf(" pc=0x" TARGET_FMT_lx, env->eip + env->segs[R_CS].base);
         if (env->hflags & HF_HALTED_MASK)
             term_printf(" (halted)");
+#elif defined(TARGET_PPC)
+        term_printf(" nip=0x" TARGET_FMT_lx, env->nip);
+        if (env->halted)
+            term_printf(" (halted)");
+#elif defined(TARGET_SPARC)
+        term_printf(" pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx, env->pc, env->npc);
+        if (env->halted)
+            term_printf(" (halted)");
 #endif
         term_printf("\n");
     }
@@ -288,9 +296,6 @@ static void do_info_history (void)
 
 static void do_quit(void)
 {
-#ifdef USE_KQEMU
-    kqemu_record_dump();
-#endif
     exit(0);
 }
 
@@ -351,7 +356,7 @@ static void do_change(const char *device, const char *filename)
 
 static void do_screen_dump(const char *filename)
 {
-    vga_screen_dump(filename);
+    vga_hw_screen_dump(filename);
 }
 
 static void do_log(const char *items)
@@ -452,10 +457,18 @@ static void memory_dump(int count, int format, int wsize,
         } else if (wsize == 4) {
             flags = 0;
         } else {
-                /* as default we use the current CS size */
+            /* as default we use the current CS size */
             flags = 0;
-            if (env && !(env->segs[R_CS].flags & DESC_B_MASK))
-                flags = 1;
+            if (env) {
+#ifdef TARGET_X86_64
+                if ((env->efer & MSR_EFER_LMA) && 
+                    (env->segs[R_CS].flags & DESC_L_MASK))
+                    flags = 2;
+                else
+#endif
+                if (!(env->segs[R_CS].flags & DESC_B_MASK))
+                    flags = 1;
+            }
         }
 #endif
         monitor_disas(env, addr, count, is_physical, flags);
@@ -520,16 +533,16 @@ static void memory_dump(int count, int format, int wsize,
             term_printf(" ");
             switch(format) {
             case 'o':
-                term_printf("%#*llo", max_digits, v);
+                term_printf("%#*" PRIo64, max_digits, v);
                 break;
             case 'x':
-                term_printf("0x%0*llx", max_digits, v);
+                term_printf("0x%0*" PRIx64, max_digits, v);
                 break;
             case 'u':
-                term_printf("%*llu", max_digits, v);
+                term_printf("%*" PRIu64, max_digits, v);
                 break;
             case 'd':
-                term_printf("%*lld", max_digits, v);
+                term_printf("%*" PRId64, max_digits, v);
                 break;
             case 'c':
                 term_printc(v);
@@ -589,17 +602,17 @@ static void do_print(int count, int format, int size, unsigned int valh, unsigne
 #else
     switch(format) {
     case 'o':
-        term_printf("%#llo", val);
+        term_printf("%#" PRIo64, val);
         break;
     case 'x':
-        term_printf("%#llx", val);
+        term_printf("%#" PRIx64, val);
         break;
     case 'u':
-        term_printf("%llu", val);
+        term_printf("%" PRIu64, val);
         break;
     default:
     case 'd':
-        term_printf("%lld", val);
+        term_printf("%" PRId64, val);
         break;
     case 'c':
         term_printc(val);
@@ -653,6 +666,8 @@ static const KeyDef key_defs[] = {
     { 0x09, "8" },
     { 0x0a, "9" },
     { 0x0b, "0" },
+    { 0x0c, "minus" },
+    { 0x0d, "equal" },
     { 0x0e, "backspace" },
 
     { 0x0f, "tab" },
@@ -702,6 +717,24 @@ static const KeyDef key_defs[] = {
     { 0x45, "num_lock" },
     { 0x46, "scroll_lock" },
 
+    { 0xb5, "kp_divide" },
+    { 0x37, "kp_multiply" },
+    { 0x4a, "kp_substract" },
+    { 0x4e, "kp_add" },
+    { 0x9c, "kp_enter" },
+    { 0x53, "kp_decimal" },
+
+    { 0x52, "kp_0" },
+    { 0x4f, "kp_1" },
+    { 0x50, "kp_2" },
+    { 0x51, "kp_3" },
+    { 0x4b, "kp_4" },
+    { 0x4c, "kp_5" },
+    { 0x4d, "kp_6" },
+    { 0x47, "kp_7" },
+    { 0x48, "kp_8" },
+    { 0x49, "kp_9" },
+    
     { 0x56, "<" },
 
     { 0x57, "f11" },
@@ -727,11 +760,18 @@ static const KeyDef key_defs[] = {
 static int get_keycode(const char *key)
 {
     const KeyDef *p;
+    char *endp;
+    int ret;
 
     for(p = key_defs; p->name != NULL; p++) {
         if (!strcmp(key, p->name))
             return p->keycode;
     }
+    if (strstart(key, "0x", NULL)) {
+        ret = strtoul(key, &endp, 0);
+        if (*endp == '\0' && ret >= 0x01 && ret <= 0xff)
+            return ret;
+    }
     return -1;
 }
 
@@ -952,12 +992,69 @@ static void do_info_kqemu(void)
         return;
     }
     val = env->kqemu_enabled;
-    term_printf("kqemu is %s\n", val ? "enabled" : "disabled");
+    term_printf("kqemu support: ");
+    switch(val) {
+    default:
+    case 0:
+        term_printf("disabled\n");
+        break;
+    case 1:
+        term_printf("enabled for user code\n");
+        break;
+    case 2:
+        term_printf("enabled for user and kernel code\n");
+        break;
+    }
 #else
-    term_printf("kqemu support is not compiled\n");
+    term_printf("kqemu support: not compiled\n");
 #endif
 } 
 
+#ifdef CONFIG_PROFILER
+
+int64_t kqemu_time;
+int64_t qemu_time;
+int64_t kqemu_exec_count;
+int64_t dev_time;
+int64_t kqemu_ret_int_count;
+int64_t kqemu_ret_excp_count;
+int64_t kqemu_ret_intr_count;
+
+static void do_info_profile(void)
+{
+    int64_t total;
+    total = qemu_time;
+    if (total == 0)
+        total = 1;
+    term_printf("async time  %" PRId64 " (%0.3f)\n",
+                dev_time, dev_time / (double)ticks_per_sec);
+    term_printf("qemu time   %" PRId64 " (%0.3f)\n",
+                qemu_time, qemu_time / (double)ticks_per_sec);
+    term_printf("kqemu time  %" PRId64 " (%0.3f %0.1f%%) count=%" PRId64 " int=%" PRId64 " excp=%" PRId64 " intr=%" PRId64 "\n",
+                kqemu_time, kqemu_time / (double)ticks_per_sec,
+                kqemu_time / (double)total * 100.0,
+                kqemu_exec_count,
+                kqemu_ret_int_count,
+                kqemu_ret_excp_count,
+                kqemu_ret_intr_count);
+    qemu_time = 0;
+    kqemu_time = 0;
+    kqemu_exec_count = 0;
+    dev_time = 0;
+    kqemu_ret_int_count = 0;
+    kqemu_ret_excp_count = 0;
+    kqemu_ret_intr_count = 0;
+#ifdef USE_KQEMU
+    kqemu_record_dump();
+#endif
+}
+#else
+static void do_info_profile(void)
+{
+    term_printf("Internal profiler not compiled\n");
+}
+#endif
+
 static term_cmd_t term_cmds[] = {
     { "help|?", "s?", do_help, 
       "[cmd]", "show the help" },
@@ -1046,6 +1143,8 @@ static term_cmd_t info_cmds[] = {
       "", "show guest USB devices", },
     { "usbhost", "", usb_host_info,
       "", "show host USB devices", },
+    { "profile", "", do_info_profile,
+      "", "show profiling information", },
     { NULL, NULL, },
 };
 
@@ -1485,7 +1584,11 @@ static target_long expr_unary(void)
         n = 0;
         break;
     default:
+#if TARGET_LONG_BITS == 64
+        n = strtoull(pch, &p, 0);
+#else
         n = strtoul(pch, &p, 0);
+#endif
         if (pch == p) {
             expr_error("invalid char in expression");
         }
@@ -2079,6 +2182,7 @@ void readline_find_completion(const char *cmdline)
     int nb_args, i, len;
     const char *ptype, *str;
     term_cmd_t *cmd;
+    const KeyDef *key;
 
     parse_cmdline(cmdline, &nb_args, args);
 #ifdef DEBUG_COMPLETION
@@ -2140,6 +2244,11 @@ void readline_find_completion(const char *cmdline)
                 for(cmd = info_cmds; cmd->name != NULL; cmd++) {
                     cmd_completion(str, cmd->name);
                 }
+            } else if (!strcmp(cmd->name, "sendkey")) {
+                completion_index = strlen(str);
+                for(key = key_defs; key->name != NULL; key++) {
+                    cmd_completion(str, key->name);
+                }
             }
             break;
         default: