2 #include "cache-utils.h"
5 struct qemu_cache_conf qemu_cache_conf
= {
11 #include <sys/systemcfg.h>
13 static void ppc_init_cacheline_sizes(void)
15 qemu_cache_conf
.icache_bsize
= _system_configuration
.icache_line
;
16 qemu_cache_conf
.dcache_bsize
= _system_configuration
.dcache_line
;
19 #elif defined __linux__
21 #define QEMU_AT_NULL 0
22 #define QEMU_AT_DCACHEBSIZE 19
23 #define QEMU_AT_ICACHEBSIZE 20
25 static void ppc_init_cacheline_sizes(char **envp
)
31 for (auxv
= (unsigned long *) envp
; *auxv
!= QEMU_AT_NULL
; auxv
+= 2) {
33 case QEMU_AT_DCACHEBSIZE
: qemu_cache_conf
.dcache_bsize
= auxv
[1]; break;
34 case QEMU_AT_ICACHEBSIZE
: qemu_cache_conf
.icache_bsize
= auxv
[1]; break;
40 #elif defined __APPLE__
42 #include <sys/types.h>
43 #include <sys/sysctl.h>
45 static void ppc_init_cacheline_sizes(void)
49 int name
[2] = { CTL_HW
, HW_CACHELINE
};
51 len
= sizeof(cacheline
);
52 if (sysctl(name
, 2, &cacheline
, &len
, NULL
, 0)) {
53 perror("sysctl CTL_HW HW_CACHELINE failed");
55 qemu_cache_conf
.dcache_bsize
= cacheline
;
56 qemu_cache_conf
.icache_bsize
= cacheline
;
62 void qemu_cache_utils_init(char **envp
)
64 ppc_init_cacheline_sizes(envp
);
67 void qemu_cache_utils_init(char **envp
)
70 ppc_init_cacheline_sizes();
74 #endif /* _ARCH_PPC */