Revision c4ab7899

b/Makefile.target
95 95

  
96 96
QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
97 97
obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
98
      elfload.o linuxload.o uaccess.o gdbstub.o
98
      elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
99 99

  
100 100
obj-$(TARGET_HAS_BFLT) += flatload.o
101 101
obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o
b/linux-user/cpu-uname.c
1
/*
2
 *  cpu to uname machine name map
3
 *
4
 *  Copyright (c) 2009 Lo?c Minier
5
 *
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 */
31
const 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()
38
     *
39
     * to test by CPU id, compare cpu_env->cp15.c0_cpuid to ARM_CPUID_*
40
     * defines and to test by CPU feature, use arm_feature(cpu_env,
41
     * ARM_FEATURE_*) */
42

  
43
    /* in theory, endianness is configurable on some ARM CPUs, but this isn't
44
     * used in user mode emulation */
45
#ifdef TARGET_WORDS_BIGENDIAN
46
#define utsname_suffix "b"
47
#else
48
#define utsname_suffix "l"
49
#endif
50
    if (arm_feature(cpu_env, ARM_FEATURE_V7))
51
        return "armv7" utsname_suffix;
52
    if (arm_feature(cpu_env, ARM_FEATURE_V6))
53
        return "armv6" utsname_suffix;
54
    /* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its
55
     * Jazelle support */
56
    return "armv5te" utsname_suffix;
57
#elif defined(TARGET_X86_64)
58
    return "x86-64";
59
#elif defined(TARGET_I386)
60
    /* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */
61
    uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version;
62
    int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff);
63
    if (family == 4)
64
        return "i486";
65
    if (family == 5)
66
        return "i586";
67
    return "i686";
68
#else
69
    /* default is #define-d in each arch/ subdir */
70
    return UNAME_MACHINE;
71
#endif
72
}
b/linux-user/cpu-uname.h
1
const char *cpu_to_uname_machine(void *cpu_env);
b/linux-user/syscall.c
82 82
#include <linux/fb.h>
83 83
#include <linux/vt.h>
84 84
#include "linux_loop.h"
85
#include "cpu-uname.h"
85 86

  
86 87
#include "qemu.h"
87 88
#include "qemu-common.h"
......
5739 5740
            if (!is_error(ret)) {
5740 5741
                /* Overrite the native machine name with whatever is being
5741 5742
                   emulated. */
5742
                strcpy (buf->machine, UNAME_MACHINE);
5743
                strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
5743 5744
                /* Allow the user to override the reported release.  */
5744 5745
                if (qemu_uname_release && *qemu_uname_release)
5745 5746
                  strcpy (buf->release, qemu_uname_release);

Also available in: Unified diff