qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>, Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH 21/24] linux/bsd-user: drop cpu_init() and use cpu_create() instead
Date: Wed, 17 Jan 2018 16:43:33 +0100	[thread overview]
Message-ID: <1516203816-19374-22-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1516203816-19374-1-git-send-email-imammedo@redhat.com>

*-user were the last users of cpu_init() macro, which were
used to create a cpu instance using cpu_model name.

Now since all targets provide TARGET_DEFAULT_CPU_TYPE,
cpu_init() can be replaced with one call:
   cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model)
when '-cpu' CLI option is parsed and
   cpu = create_cpu(cpu_type)
whenever a cpu instance needs to be created.

Also drop ifdef-ed definitions of default cpu_model and use
target provided TARGET_DEFAULT_CPU_TYPE for it, this way
linux/bsd-user targets will become consistent in handling
defaults and won't go out off sync as it happened current
code.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
---
 bsd-user/main.c   | 26 ++++----------------------
 linux-user/main.c | 46 +++++-----------------------------------------
 2 files changed, 9 insertions(+), 63 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index efef5ff..d52ff22 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -722,7 +722,7 @@ void init_task_state(TaskState *ts)
 int main(int argc, char **argv)
 {
     const char *filename;
-    const char *cpu_model;
+    const char *cpu_type = TARGET_DEFAULT_CPU_TYPE;
     const char *log_file = NULL;
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
@@ -752,8 +752,6 @@ int main(int argc, char **argv)
         (void) envlist_setenv(envlist, *wrk);
     }
 
-    cpu_model = NULL;
-
     qemu_add_opts(&qemu_trace_opts);
 
     optind = 1;
@@ -811,7 +809,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "r")) {
             qemu_uname_release = argv[optind++];
         } else if (!strcmp(r, "cpu")) {
-            cpu_model = argv[optind++];
+            const char *cpu_model = argv[optind++];
             if (is_help_option(cpu_model)) {
 /* XXX: implement xxx_cpu_list for targets that still miss it */
 #if defined(cpu_list)
@@ -819,6 +817,7 @@ int main(int argc, char **argv)
 #endif
                 exit(1);
             }
+            cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model);
         } else if (!strcmp(r, "B")) {
            guest_base = strtol(argv[optind++], NULL, 0);
            have_guest_base = 1;
@@ -880,27 +879,10 @@ int main(int argc, char **argv)
     /* Scan interp_prefix dir for replacement files. */
     init_paths(interp_prefix);
 
-    if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#else
-        cpu_model = "any";
-#endif
-    }
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+    cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
     cpu_reset(cpu);
diff --git a/linux-user/main.c b/linux-user/main.c
index 1cd5033..4624cc9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -43,7 +43,7 @@ static const char *filename;
 static const char *argv0;
 static int gdbstub_port;
 static envlist_t *envlist;
-static const char *cpu_model;
+static const char *cpu_type = TARGET_DEFAULT_CPU_TYPE;
 unsigned long mmap_min_addr;
 unsigned long guest_base;
 int have_guest_base;
@@ -3847,7 +3847,7 @@ void init_task_state(TaskState *ts)
 CPUArchState *cpu_copy(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
-    CPUState *new_cpu = cpu_init(cpu_model);
+    CPUState *new_cpu = cpu_create(cpu_type);
     CPUArchState *new_env = new_cpu->env_ptr;
     CPUBreakpoint *bp;
     CPUWatchpoint *wp;
@@ -3982,7 +3982,7 @@ static void handle_arg_uname(const char *arg)
 
 static void handle_arg_cpu(const char *arg)
 {
-    cpu_model = strdup(arg);
+    const char *cpu_model = strdup(arg);
     if (cpu_model == NULL || is_help_option(cpu_model)) {
         /* XXX: implement xxx_cpu_list for targets that still miss it */
 #if defined(cpu_list)
@@ -3990,6 +3990,7 @@ static void handle_arg_cpu(const char *arg)
 #endif
         exit(EXIT_FAILURE);
     }
+    cpu_type = cpu_parse_cpu_model(TARGET_DEFAULT_CPU_TYPE, cpu_model);
 }
 
 static void handle_arg_guest_base(const char *arg)
@@ -4292,8 +4293,6 @@ int main(int argc, char **argv, char **envp)
         }
     }
 
-    cpu_model = NULL;
-
     srand(time(NULL));
 
     qemu_add_opts(&qemu_trace_opts);
@@ -4318,45 +4317,10 @@ int main(int argc, char **argv, char **envp)
 
     init_qemu_uname_release();
 
-    if (cpu_model == NULL) {
-#if defined(TARGET_I386)
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-#elif defined(TARGET_SPARC)
-#ifdef TARGET_SPARC64
-        cpu_model = "TI UltraSparc II";
-#else
-        cpu_model = "Fujitsu MB86904";
-#endif
-#elif defined(TARGET_MIPS)
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
-        cpu_model = "5KEf";
-#else
-        cpu_model = "24Kf";
-#endif
-#elif defined TARGET_OPENRISC
-        cpu_model = "or1200";
-#elif defined(TARGET_PPC)
-# ifdef TARGET_PPC64
-        cpu_model = "power8_v2.0";
-# else
-        cpu_model = "750_v3.1";
-# endif
-#elif defined TARGET_SH4
-        cpu_model = "sh7785";
-#elif defined TARGET_S390X
-        cpu_model = "qemu";
-#else
-        cpu_model = "any";
-#endif
-    }
     tcg_exec_init(0);
     /* NOTE: we need to init the CPU at this stage to get
        qemu_host_page_size */
-    cpu = cpu_init(cpu_model);
+    cpu = cpu_create(cpu_type);
     env = cpu->env_ptr;
     cpu_reset(cpu);
 
-- 
2.7.4

  parent reply	other threads:[~2018-01-17 15:46 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 15:43 [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 01/24] arm: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 02/24] alpha: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 03/24] cris: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 04/24] lm32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 05/24] m68k: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 06/24] microblaze: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 07/24] mips: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 08/24] moxie: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 09/24] nios2: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 10/24] openrisc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 11/24] ppc: " Igor Mammedov
2018-01-18  0:30   ` David Gibson
2018-01-17 15:43 ` [Qemu-devel] [PATCH 12/24] s390x: " Igor Mammedov
2018-01-17 16:04   ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2018-01-17 19:20     ` Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 13/24] sh4: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 14/24] sparc: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 15/24] tricore: " Igor Mammedov
2018-01-17 16:34   ` Bastian Koppelmann
2018-01-17 15:43 ` [Qemu-devel] [PATCH 16/24] unicore32: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 17/24] xtensa: cpu: rename XTENSA_DEFAULT_CPU_TYPE to TARGET_DEFAULT_CPU_TYPE Igor Mammedov
2018-01-17 17:35   ` Max Filippov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 18/24] hppa: cpu: add TARGET_DEFAULT_CPU_TYPE macro Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 19/24] tilegx: " Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 20/24] machine: drop MachineState::cpu_model Igor Mammedov
2018-01-18  1:48   ` Eduardo Habkost
2018-01-18 10:10     ` Igor Mammedov
2018-01-18 19:18       ` Eduardo Habkost
2018-01-19 10:14         ` Igor Mammedov
2018-01-19 13:14           ` Eduardo Habkost
2018-01-19 13:39             ` Igor Mammedov
2018-01-19 14:23               ` Eduardo Habkost
2018-01-17 15:43 ` Igor Mammedov [this message]
2018-01-17 15:43 ` [Qemu-devel] [PATCH 22/24] cpu: get rid of unused cpu_init() defines Igor Mammedov
2018-01-18  0:28   ` David Gibson
2018-01-18  1:50   ` Eduardo Habkost
2018-01-17 15:43 ` [Qemu-devel] [PATCH 23/24] nios2: 10m50_devboard: replace cpu_model with cpu_type Igor Mammedov
2018-01-17 15:43 ` [Qemu-devel] [PATCH 24/24] cpu: get rid of cpu_generic_init() Igor Mammedov
2018-01-17 16:12 ` [Qemu-devel] [PATCH 00/24] generalize parsing of cpu_model (part 4) Peter Maydell
2018-01-17 19:15   ` Igor Mammedov
2018-01-17 20:30     ` Peter Maydell
2018-01-18 10:43       ` Igor Mammedov
2018-01-18 10:50         ` Peter Maydell
2018-01-18 13:06           ` Igor Mammedov
2018-01-18 13:10             ` Peter Maydell
2018-01-18 13:34               ` Igor Mammedov
2018-01-18 13:36                 ` Peter Maydell
2018-01-18 13:45                   ` Igor Mammedov
2018-01-18 13:49                     ` Peter Maydell
2018-01-18 14:02                       ` Igor Mammedov
2018-01-18 15:31               ` Philippe Mathieu-Daudé
2018-01-18 15:41                 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516203816-19374-22-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).