From patchwork Fri Jan 11 02:10:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 211200 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 4EB2F2C0168 for ; Fri, 11 Jan 2013 13:47:57 +1100 (EST) Received: from localhost ([::1]:54858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtU7N-0007GQ-Er for incoming@patchwork.ozlabs.org; Thu, 10 Jan 2013 21:13:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtU6W-00054M-I6 for qemu-devel@nongnu.org; Thu, 10 Jan 2013 21:12:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtU6U-0000Vw-EZ for qemu-devel@nongnu.org; Thu, 10 Jan 2013 21:12:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtU6U-0000Vo-77 for qemu-devel@nongnu.org; Thu, 10 Jan 2013 21:12:18 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0B2CHDG014821 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Jan 2013 21:12:17 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0B2CAdw021266; Thu, 10 Jan 2013 21:12:16 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2013 03:10:18 +0100 Message-Id: <1357870231-26762-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1357870231-26762-1-git-send-email-imammedo@redhat.com> References: <1357870231-26762-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id r0B2CHDG014821 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 04/17] target-i386: add x86_cpu_vendor_words2str() 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 Make for() cycle reusable for the next patch Signed-off-by: Igor Mammedov --- v4: - rename x86cpu_vendor_words2str() to x86_cpu_vendor_words2str() Suggested-By: Andreas Färber v3: -replace e[bcd]x arguments naming with vendor[123] -fix/swap vendor2 and vendor3 order Spotted-By: Eduardo Habkost v2: -place x86cpu_vendor_words2str() a bit earlier, before feature arrays to avoid compile error when vendor property is converted static property. --- target-i386/cpu.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c4ff761..64cc88f 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -45,6 +45,18 @@ #include "hw/apic_internal.h" #endif +static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, + uint32_t vendor2, uint32_t vendor3) +{ + int i; + for (i = 0; i < 4; i++) { + dst[i] = vendor1 >> (8 * i); + dst[i + 4] = vendor2 >> (8 * i); + dst[i + 8] = vendor3 >> (8 * i); + } + dst[CPUID_VENDOR_SZ] = '\0'; +} + /* feature flags taken from "Intel Processor Identification and the CPUID * Instruction" and AMD's "CPUID Specification". In cases of disagreement * between feature naming conventions, aliases may be added. @@ -1213,15 +1225,10 @@ static char *x86_cpuid_get_vendor(Object *obj, Error **errp) X86CPU *cpu = X86_CPU(obj); CPUX86State *env = &cpu->env; char *value; - int i; value = (char *)g_malloc(CPUID_VENDOR_SZ + 1); - for (i = 0; i < 4; i++) { - value[i ] = env->cpuid_vendor1 >> (8 * i); - value[i + 4] = env->cpuid_vendor2 >> (8 * i); - value[i + 8] = env->cpuid_vendor3 >> (8 * i); - } - value[CPUID_VENDOR_SZ] = '\0'; + x86_cpu_vendor_words2str(value, env->cpuid_vendor1, env->cpuid_vendor2, + env->cpuid_vendor3); return value; }