1 #include "cache-utils.h"
4 struct qemu_cache_conf qemu_cache_conf
= {
10 #include <sys/systemcfg.h>
12 static void ppc_init_cacheline_sizes(void)
14 qemu_cache_conf
.icache_bsize
= _system_configuration
.icache_line
;
15 qemu_cache_conf
.dcache_bsize
= _system_configuration
.dcache_line
;
18 #elif defined __linux__
20 #define QEMU_AT_NULL 0
21 #define QEMU_AT_DCACHEBSIZE 19
22 #define QEMU_AT_ICACHEBSIZE 20
24 static void ppc_init_cacheline_sizes(char **envp
)
30 for (auxv
= (unsigned long *) envp
; *auxv
!= QEMU_AT_NULL
; auxv
+= 2) {
32 case QEMU_AT_DCACHEBSIZE
: qemu_cache_conf
.dcache_bsize
= auxv
[1]; break;
33 case QEMU_AT_ICACHEBSIZE
: qemu_cache_conf
.icache_bsize
= auxv
[1]; break;
39 #elif defined __APPLE__
41 #include <sys/types.h>
42 #include <sys/sysctl.h>
44 static void ppc_init_cacheline_sizes(void)
48 int name
[2] = { CTL_HW
, HW_CACHELINE
};
50 len
= sizeof(cacheline
);
51 if (sysctl(name
, 2, &cacheline
, &len
, NULL
, 0)) {
52 perror("sysctl CTL_HW HW_CACHELINE failed");
54 qemu_cache_conf
.dcache_bsize
= cacheline
;
55 qemu_cache_conf
.icache_bsize
= cacheline
;
60 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
65 #include <sys/types.h>
66 #include <sys/sysctl.h>
68 static void ppc_init_cacheline_sizes(void)
73 if (sysctlbyname ("machdep.cacheline_size", &cacheline
, &len
, NULL
, 0)) {
74 fprintf(stderr
, "sysctlbyname machdep.cacheline_size failed: %s\n",
79 qemu_cache_conf
.dcache_bsize
= cacheline
;
80 qemu_cache_conf
.icache_bsize
= cacheline
;
85 void qemu_cache_utils_init(char **envp
)
87 ppc_init_cacheline_sizes(envp
);
90 void qemu_cache_utils_init(char **envp
)
93 ppc_init_cacheline_sizes();
97 #endif /* _ARCH_PPC */