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