blob: cc713e6553a1dc958c33611c2c30c82690393a30 [file] [log] [blame]
Loïc Minierda790302009-12-29 22:06:13 +01001/*
2 * cpu to uname machine name map
3 *
Peter Maydell7ff60e12011-12-02 19:30:44 +00004 * Copyright (c) 2009 Loïc Minier
Loïc Minierda790302009-12-29 22:06:13 +01005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <stdio.h>
21
22#include "qemu.h"
23//#include "qemu-common.h"
24#include "cpu-uname.h"
25
26/* return highest utsname machine name for emulated instruction set
27 *
28 * NB: the default emulated CPU ("any") might not match any existing CPU, e.g.
29 * on ARM it has all features turned on, so there is no perfect arch string to
30 * return here */
31const char *cpu_to_uname_machine(void *cpu_env)
32{
33#ifdef TARGET_ARM
34 /* utsname machine name on linux arm is CPU arch name + endianness, e.g.
35 * armv7l; to get a list of CPU arch names from the linux source, use:
36 * grep arch_name: -A1 linux/arch/arm/mm/proc-*.S
37 * see arch/arm/kernel/setup.c: setup_processor()
Peter Maydellb2d06f92012-06-20 11:57:23 +000038 */
Loïc Minierda790302009-12-29 22:06:13 +010039
40 /* in theory, endianness is configurable on some ARM CPUs, but this isn't
41 * used in user mode emulation */
42#ifdef TARGET_WORDS_BIGENDIAN
43#define utsname_suffix "b"
44#else
45#define utsname_suffix "l"
46#endif
47 if (arm_feature(cpu_env, ARM_FEATURE_V7))
48 return "armv7" utsname_suffix;
49 if (arm_feature(cpu_env, ARM_FEATURE_V6))
50 return "armv6" utsname_suffix;
51 /* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its
52 * Jazelle support */
53 return "armv5te" utsname_suffix;
54#elif defined(TARGET_X86_64)
55 return "x86-64";
56#elif defined(TARGET_I386)
57 /* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */
Andreas Färber6f152e92012-05-18 00:01:58 +020058 CPUState *cpu = ENV_GET_CPU((CPUX86State *)cpu_env);
59 int family = object_property_get_int(OBJECT(cpu), "family", NULL);
60 if (family == 4) {
Loïc Minierda790302009-12-29 22:06:13 +010061 return "i486";
Andreas Färber6f152e92012-05-18 00:01:58 +020062 }
63 if (family == 5) {
Loïc Minierda790302009-12-29 22:06:13 +010064 return "i586";
Andreas Färber6f152e92012-05-18 00:01:58 +020065 }
Loïc Minierda790302009-12-29 22:06:13 +010066 return "i686";
67#else
68 /* default is #define-d in each arch/ subdir */
69 return UNAME_MACHINE;
70#endif
71}