[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/3] linux-user: Emulate /proc/cpuinfo for Alpha
From: |
Helge Deller |
Subject: |
[PATCH v2 3/3] linux-user: Emulate /proc/cpuinfo for Alpha |
Date: |
Wed, 2 Aug 2023 01:08:42 +0200 |
Add emulation for /proc/cpuinfo for the alpha architecture.
alpha output example:
(alpha-chroot)root@p100:/# cat /proc/cpuinfo
cpu : Alpha
cpu model : ev67
cpu variation : 7
cpu revision : 0
cpu serial number : JA00000000
system type : QEMU
system variation : 8.0.91
system revision : 0
system serial number : AY00000000
cycle frequency [Hz] : 250000000
timer frequency [Hz] : 250.00
page size [bytes] : 8192
phys. address bits : 44
max. addr. space # : 255
BogoMIPS : 2500.00
platform string : AlphaServer QEMU virtual machine
cpus detected : 8
cpus active : 8
cpu active mask : 00000000000000ff
L1 Icache : n/a
L1 Dcache : n/a
L2 cache : n/a
L3 cache : n/a
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Michael Cree <mcree@orcon.net.nz>
---
linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 51ce81cefb..548eaea3a0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8324,7 +8324,7 @@ void target_exception_dump(CPUArchState *env, const char
*fmt, int code)
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN || \
defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) || \
defined(TARGET_RISCV) || defined(TARGET_S390X) || defined(TARGET_ARM) || \
- defined(TARGET_AARCH64)
+ defined(TARGET_AARCH64) || defined(TARGET_ALPHA)
static int is_proc(const char *filename, const char *entry)
{
return strcmp(filename, entry) == 0;
@@ -8376,6 +8376,51 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
}
#endif
+#if defined(TARGET_ALPHA)
+static int open_cpuinfo(CPUArchState *cpu_env, int fd)
+{
+ int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ char model[32];
+ char *p;
+ AlphaCPU *cpu = env_archcpu(cpu_env);
+ CPUAlphaState *env = &cpu->env;
+
+ g_strlcpy(model, object_class_get_name(
+ OBJECT_CLASS(CPU_GET_CLASS(env_cpu(cpu_env)))),
+ sizeof(model));
+ p = strchr(model, '-');
+ if (p) {
+ *p = '\0';
+ }
+
+ dprintf(fd, "cpu\t\t\t: Alpha\n");
+ dprintf(fd, "cpu model\t\t: %s\n", model);
+ // object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(env_cpu(cpu_env)))));
+ dprintf(fd, "cpu variation\t\t: %d\n", env->implver + 5);
+ dprintf(fd, "cpu revision\t\t: 0\n");
+ dprintf(fd, "cpu serial number\t: JA00000000\n");
+ dprintf(fd, "system type\t\t: QEMU\n");
+ dprintf(fd, "system variation\t: %s\n", QEMU_VERSION);
+ dprintf(fd, "system revision\t\t: 0\n");
+ dprintf(fd, "system serial number\t: AY00000000\n");
+ dprintf(fd, "cycle frequency [Hz]\t: 250000000\n");
+ dprintf(fd, "timer frequency [Hz]\t: 250.00\n");
+ dprintf(fd, "page size [bytes]\t: %d\n", TARGET_PAGE_SIZE);
+ dprintf(fd, "phys. address bits\t: %d\n", TARGET_PHYS_ADDR_SPACE_BITS);
+ dprintf(fd, "max. addr. space #\t: 255\n");
+ dprintf(fd, "BogoMIPS\t\t: 2500.00\n");
+ dprintf(fd, "platform string\t\t: AlphaServer QEMU virtual machine\n");
+ dprintf(fd, "cpus detected\t\t: %d\n", num_cpus);
+ dprintf(fd, "cpus active\t\t: %d\n", num_cpus);
+ dprintf(fd, "cpu active mask\t\t: %016llx\n", (1ULL << num_cpus) - 1);
+ dprintf(fd, "L1 Icache\t\t: n/a\n");
+ dprintf(fd, "L1 Dcache\t\t: n/a\n");
+ dprintf(fd, "L2 cache\t\t: n/a\n");
+ dprintf(fd, "L3 cache\t\t: n/a\n");
+ return 0;
+}
+#endif
+
#if defined(TARGET_SPARC)
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
@@ -8624,7 +8669,8 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd,
const char *fname,
#endif
#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || \
defined(TARGET_RISCV) || defined(TARGET_S390X) || \
- defined(TARGET_ARM) || defined(TARGET_AARCH64)
+ defined(TARGET_ARM) || defined(TARGET_AARCH64) || \
+ defined(TARGET_ALPHA)
{ "/proc/cpuinfo", open_cpuinfo, is_proc },
#endif
#if defined(TARGET_M68K)
--
2.41.0