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__
19 #include <linux/auxvec.h>
21 static void ppc_init_cacheline_sizes(char **envp
)
27 for (auxv
= (unsigned long *) envp
; *auxv
!= AT_NULL
; auxv
+= 2) {
29 case AT_DCACHEBSIZE
: qemu_cache_conf
.dcache_bsize
= auxv
[1]; break;
30 case AT_ICACHEBSIZE
: qemu_cache_conf
.icache_bsize
= auxv
[1]; break;
36 #elif defined __APPLE__
37 #include <sys/types.h>
38 #include <sys/sysctl.h>
40 static void ppc_init_cacheline_sizes(void)
44 int name
[2] = { CTL_HW
, HW_CACHELINE
};
46 if (sysctl(name
, 2, &cacheline
, &len
, NULL
, 0)) {
47 perror("sysctl CTL_HW HW_CACHELINE failed");
49 qemu_cache_conf
.dcache_bsize
= cacheline
;
50 qemu_cache_conf
.icache_bsize
= cacheline
;
56 void qemu_cache_utils_init(char **envp
)
58 ppc_init_cacheline_sizes(envp
);
61 void qemu_cache_utils_init(char **envp
)
64 ppc_init_cacheline_sizes();
68 #endif /* __powerpc__ */