| 1 | /* |
| 2 | * Alpha specific proc functions for linux-user |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | */ |
| 6 | #ifndef ALPHA_TARGET_PROC_H |
| 7 | #define ALPHA_TARGET_PROC_H |
| 8 | |
| 9 | #include "target/alpha/cpu.h" |
| 10 | |
| 11 | static uint8_t alpha_phys_addr_space_bits(CPUAlphaState *env) |
| 12 | { |
| 13 | switch (env->implver) { |
| 14 | case IMPLVER_2106x: |
| 15 | /* EV4 */ |
| 16 | return 34; |
| 17 | case IMPLVER_21164: |
| 18 | /* EV5 */ |
| 19 | return 40; |
| 20 | case IMPLVER_21264: |
| 21 | case IMPLVER_21364: |
| 22 | /* EV6 and EV7*/ |
| 23 | return 44; |
| 24 | default: |
| 25 | g_assert_not_reached(); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | static int open_cpuinfo(CPUArchState *cpu_env, int fd) |
| 30 | { |
| 31 | int max_cpus = sysconf(_SC_NPROCESSORS_CONF); |
| 32 | int num_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
| 33 | unsigned long cpu_mask; |
| 34 | char model[32]; |
| 35 | const char *p, *q; |
| 36 | int t; |
| 37 | |
| 38 | p = object_class_get_name(OBJECT_CLASS(env_cpu(cpu_env)->cc)); |
| 39 | q = strchr(p, '-'); |
| 40 | t = q - p; |
| 41 | assert(t < sizeof(model)); |
| 42 | memcpy(model, p, t); |
| 43 | model[t] = 0; |
| 44 | |
| 45 | t = sched_getaffinity(getpid(), sizeof(cpu_mask), (cpu_set_t *)&cpu_mask); |
| 46 | if (t < 0) { |
| 47 | if (num_cpus >= sizeof(cpu_mask) * 8) { |
| 48 | cpu_mask = -1; |
| 49 | } else { |
| 50 | cpu_mask = (1UL << num_cpus) - 1; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | dprintf(fd, |
| 55 | "cpu\t\t\t: Alpha\n" |
| 56 | "cpu model\t\t: %s\n" |
| 57 | "cpu variation\t\t: 0\n" |
| 58 | "cpu revision\t\t: 0\n" |
| 59 | "cpu serial number\t: JA00000000\n" |
| 60 | "system type\t\t: QEMU\n" |
| 61 | "system variation\t: QEMU_v" QEMU_VERSION "\n" |
| 62 | "system revision\t\t: 0\n" |
| 63 | "system serial number\t: AY00000000\n" |
| 64 | "cycle frequency [Hz]\t: 250000000\n" |
| 65 | "timer frequency [Hz]\t: 250.00\n" |
| 66 | "page size [bytes]\t: %d\n" |
| 67 | "phys. address bits\t: %d\n" |
| 68 | "max. addr. space #\t: 255\n" |
| 69 | "BogoMIPS\t\t: 2500.00\n" |
| 70 | "kernel unaligned acc\t: 0 (pc=0,va=0)\n" |
| 71 | "user unaligned acc\t: 0 (pc=0,va=0)\n" |
| 72 | "platform string\t\t: AlphaServer QEMU user-mode VM\n" |
| 73 | "cpus detected\t\t: %d\n" |
| 74 | "cpus active\t\t: %d\n" |
| 75 | "cpu active mask\t\t: %016lx\n" |
| 76 | "L1 Icache\t\t: n/a\n" |
| 77 | "L1 Dcache\t\t: n/a\n" |
| 78 | "L2 cache\t\t: n/a\n" |
| 79 | "L3 cache\t\t: n/a\n", |
| 80 | model, TARGET_PAGE_SIZE, alpha_phys_addr_space_bits(cpu_env), |
| 81 | max_cpus, num_cpus, cpu_mask); |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | #define HAVE_ARCH_PROC_CPUINFO |
| 86 | |
| 87 | #endif /* ALPHA_TARGET_PROC_H */ |