From patchwork Sun Dec 9 01:40:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 204685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 856872C0134 for ; Sun, 9 Dec 2012 12:41:55 +1100 (EST) Received: from localhost ([::1]:41482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThVtx-0008D0-PU for incoming@patchwork.ozlabs.org; Sat, 08 Dec 2012 20:41:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThVsg-0004D7-9Y for qemu-devel@nongnu.org; Sat, 08 Dec 2012 20:40:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ThVsf-0003YT-1u for qemu-devel@nongnu.org; Sat, 08 Dec 2012 20:40:34 -0500 Received: from cantor2.suse.de ([195.135.220.15]:55595 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThVse-0003YL-Oa for qemu-devel@nongnu.org; Sat, 08 Dec 2012 20:40:32 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 3F0DBA4EB7; Sun, 9 Dec 2012 02:40:32 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2012 02:40:16 +0100 Message-Id: <1355017216-22962-6-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355017216-22962-1-git-send-email-afaerber@suse.de> References: <1355017216-22962-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , rth@twiddle.net Subject: [Qemu-devel] [PATCH qom-cpu v2 5/5] target-alpha: Add support for -cpu ? X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Implement alphabetical listing of CPU subclasses. Signed-off-by: Andreas Färber --- target-alpha/cpu.c | 41 +++++++++++++++++++++++++++++++++++++++++ target-alpha/cpu.h | 2 ++ 2 Dateien geändert, 43 Zeilen hinzugefügt(+) diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c index 11df753..d065085 100644 --- a/target-alpha/cpu.c +++ b/target-alpha/cpu.c @@ -33,6 +33,47 @@ static void alpha_cpu_realize(Object *obj, Error **err) #endif } +typedef struct AlphaCPUListState { + fprintf_function cpu_fprintf; + FILE *file; +} AlphaCPUListState; + +/* Sort alphabetically by type name. */ +static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b) +{ + ObjectClass *class_a = (ObjectClass *)a; + ObjectClass *class_b = (ObjectClass *)b; + const char *name_a, *name_b; + + name_a = object_class_get_name(class_a); + name_b = object_class_get_name(class_b); + return strcmp(name_a, name_b); +} + +static void alpha_cpu_list_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + AlphaCPUListState *s = user_data; + + (*s->cpu_fprintf)(s->file, " %s\n", + object_class_get_name(oc)); +} + +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf) +{ + AlphaCPUListState s = { + .file = f, + .cpu_fprintf = cpu_fprintf, + }; + GSList *list; + + list = object_class_get_list(TYPE_ALPHA_CPU, false); + list = g_slist_sort(list, alpha_cpu_list_compare); + (*cpu_fprintf)(f, "Available CPUs:\n"); + g_slist_foreach(list, alpha_cpu_list_entry, &s); + g_slist_free(list); +} + /* Models */ #define TYPE(model) model "-" TYPE_ALPHA_CPU diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index a5eb449..867ee32 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -296,6 +296,7 @@ struct CPUAlphaState { int implver; }; +#define cpu_list alpha_cpu_list #define cpu_exec cpu_alpha_exec #define cpu_gen_code cpu_alpha_gen_code #define cpu_signal_handler cpu_alpha_signal_handler @@ -445,6 +446,7 @@ static inline CPUAlphaState *cpu_init(const char *cpu_model) return &cpu->env; } +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf); int cpu_alpha_exec(CPUAlphaState *s); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero