From 5cb6816715968dc08486307bd1894dc91e22342c Mon Sep 17 00:00:00 2001 From: Pranavkumar Sawargaonkar Date: Tue, 8 Oct 2013 19:19:07 +0530 Subject: [PATCH] AArch64: CPU Support for AArch64 (ARMv8 64bit). Adding CPU encoder/decoder for AArch64. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar (crobinso: fix for recent libvirt Ptr refactoring) --- src/Makefile.am | 1 + src/cpu/cpu.c | 2 ++ src/cpu/cpu_aarch64.c | 79 +++++++++++++++++++++++++++++++++++++++++++ src/cpu/cpu_aarch64.h | 31 +++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 src/cpu/cpu_aarch64.c create mode 100644 src/cpu/cpu_aarch64.h diff --git a/src/Makefile.am b/src/Makefile.am index e58d4086c8..a9b6d587a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -900,6 +900,7 @@ CPU_SOURCES = \ cpu/cpu_x86.h cpu/cpu_x86.c cpu/cpu_x86_data.h \ cpu/cpu_s390.h cpu/cpu_s390.c \ cpu/cpu_arm.h cpu/cpu_arm.c \ + cpu/cpu_aarch64.h cpu/cpu_aarch64.c \ cpu/cpu_map.h cpu/cpu_map.c cpu/cpu_powerpc.h \ cpu/cpu_powerpc.c cpu/cpu_ppc_data.h diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 548edc79cb..677bb088fb 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -32,6 +32,7 @@ #include "cpu_powerpc.h" #include "cpu_s390.h" #include "cpu_arm.h" +#include "cpu_aarch64.h" #include "cpu_generic.h" #include "util/virstring.h" @@ -44,6 +45,7 @@ static struct cpuArchDriver *drivers[] = { &cpuDriverPowerPC, &cpuDriverS390, &cpuDriverArm, + &cpuDriverAARCH64, /* generic driver must always be the last one */ &cpuDriverGeneric }; diff --git a/src/cpu/cpu_aarch64.c b/src/cpu/cpu_aarch64.c new file mode 100644 index 0000000000..3959deb4cc --- /dev/null +++ b/src/cpu/cpu_aarch64.c @@ -0,0 +1,79 @@ +/* + * cpu_aarch64.c: CPU driver for AArch64 CPUs + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Authors: + * Anup Patel + * Pranavkumar Sawargaonkar + */ + +#include + +#include "viralloc.h" +#include "cpu.h" + +#define VIR_FROM_THIS VIR_FROM_CPU + +static const virArch archs[] = { VIR_ARCH_AARCH64 }; + +static virCPUDataPtr +AArch64NodeData(virArch arch) +{ + virCPUDataPtr data; + + if (VIR_ALLOC(data) < 0) + return NULL; + + data->arch = arch; + + return data; +} + +static int +AArch64Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, + const virCPUData *data ATTRIBUTE_UNUSED, + const char **models ATTRIBUTE_UNUSED, + unsigned int nmodels ATTRIBUTE_UNUSED, + const char *preferred ATTRIBUTE_UNUSED, + unsigned int flags) +{ + + virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, -1); + + return 0; +} + +static void +AArch64DataFree(virCPUDataPtr data) +{ + VIR_FREE(data); +} + +struct cpuArchDriver cpuDriverAARCH64 = { + .name = "aarch64", + .arch = archs, + .narch = ARRAY_CARDINALITY(archs), + .compare = NULL, + .decode = AArch64Decode, + .encode = NULL, + .free = AArch64DataFree, + .nodeData = AArch64NodeData, + .guestData = NULL, + .baseline = NULL, + .update = NULL, + .hasFeature = NULL, +}; diff --git a/src/cpu/cpu_aarch64.h b/src/cpu/cpu_aarch64.h new file mode 100644 index 0000000000..8e48368b95 --- /dev/null +++ b/src/cpu/cpu_aarch64.h @@ -0,0 +1,31 @@ +/* + * cpu_aarch64.h: CPU driver for AArch64 CPUs + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Authors: + * Anup Patel + * Pravakumar Sawargaonkar + */ + +#ifndef __VIR_CPU_AARCH64_H__ +# define __VIR_CPU_AARCH64_H__ + +# include "cpu.h" + +extern struct cpuArchDriver cpuDriverAARCH64; + +#endif /* __VIR_CPU_AARCH64_H__ */ -- 2.47.2