initial APIC support (only for x86_64 target now)
[qemu] / monitor.c
index 15b54d3..bb21246 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -101,6 +101,15 @@ void term_printf(const char *fmt, ...)
     va_end(ap);
 }
 
+static int monitor_fprintf(FILE *stream, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    term_vprintf(fmt, ap);
+    va_end(ap);
+    return 0;
+}
+
 static int compare_cmd(const char *name, const char *list)
 {
     const char *p, *pstart;
@@ -181,6 +190,11 @@ static void do_info(const char *item)
     cmd->handler();
 }
 
+static void do_info_version(void)
+{
+  term_printf("%s\n", QEMU_VERSION);
+}
+
 static void do_info_network(void)
 {
     int i, j;
@@ -206,9 +220,11 @@ static void do_info_block(void)
 static void do_info_registers(void)
 {
 #ifdef TARGET_I386
-    cpu_dump_state(cpu_single_env, stdout, X86_DUMP_FPU | X86_DUMP_CCOP);
+    cpu_dump_state(cpu_single_env, stdout, monitor_fprintf,
+                   X86_DUMP_FPU | X86_DUMP_CCOP);
 #else
-    cpu_dump_state(cpu_single_env, stdout, 0);
+    cpu_dump_state(cpu_single_env, stdout, monitor_fprintf, 
+                   0);
 #endif
 }
 
@@ -223,6 +239,7 @@ static void do_info_history (void)
         if (!str)
             break;
        term_printf("%d: '%s'\n", i, str);
+        i++;
     }
 }
 
@@ -747,13 +764,15 @@ static void tlb_info(void)
 static void mem_print(uint32_t *pstart, int *plast_prot, 
                       uint32_t end, int prot)
 {
-    if (prot != *plast_prot) {
+    int prot1;
+    prot1 = *plast_prot;
+    if (prot != prot1) {
         if (*pstart != -1) {
             term_printf("%08x-%08x %08x %c%c%c\n",
                         *pstart, end, end - *pstart, 
-                        prot & PG_USER_MASK ? 'u' : '-',
+                        prot1 & PG_USER_MASK ? 'u' : '-',
                         'r',
-                        prot & PG_RW_MASK ? 'w' : '-');
+                        prot1 & PG_RW_MASK ? 'w' : '-');
         }
         if (prot != 0)
             *pstart = end;
@@ -852,6 +871,8 @@ static term_cmd_t term_cmds[] = {
 };
 
 static term_cmd_t info_cmds[] = {
+    { "version", "", do_info_version,
+      "", "show the version of qemu" },
     { "network", "", do_info_network,
       "", "show the network state" },
     { "block", "", do_info_block,
@@ -952,11 +973,7 @@ static int monitor_get_tbl (struct MonitorDef *md, int val)
 #if defined(TARGET_SPARC)
 static int monitor_get_psr (struct MonitorDef *md, int val)
 {
-    return (0<<28) | (4<<24) | cpu_single_env->psr     \
-       | (cpu_single_env->psrs? PSR_S : 0)             \
-       | (cpu_single_env->psrs? PSR_PS : 0)            \
-       | (cpu_single_env->psret? PSR_ET : 0)           \
-       | cpu_single_env->cwp;
+    return GET_PSR(cpu_single_env);
 }
 
 static int monitor_get_reg(struct MonitorDef *md, int val)
@@ -1855,6 +1872,15 @@ void readline_find_completion(const char *cmdline)
             completion_index = strlen(str);
             bdrv_iterate(block_completion_it, (void *)str);
             break;
+        case 's':
+            /* XXX: more generic ? */
+            if (!strcmp(cmd->name, "info")) {
+                completion_index = strlen(str);
+                for(cmd = info_cmds; cmd->name != NULL; cmd++) {
+                    cmd_completion(str, cmd->name);
+                }
+            }
+            break;
         default:
             break;
         }