2013-06-10 16:05:09 +00:00
|
|
|
#include "qemu-common.h"
|
2012-12-17 17:20:00 +00:00
|
|
|
#include "qemu/cache-utils.h"
|
2008-12-10 19:18:40 +00:00
|
|
|
|
2009-01-14 18:39:49 +00:00
|
|
|
#if defined(_ARCH_PPC)
|
2008-12-10 19:18:40 +00:00
|
|
|
struct qemu_cache_conf qemu_cache_conf = {
|
|
|
|
.dcache_bsize = 16,
|
|
|
|
.icache_bsize = 16
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined _AIX
|
|
|
|
#include <sys/systemcfg.h>
|
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
void qemu_cache_utils_init(void)
|
2008-12-10 19:18:40 +00:00
|
|
|
{
|
|
|
|
qemu_cache_conf.icache_bsize = _system_configuration.icache_line;
|
|
|
|
qemu_cache_conf.dcache_bsize = _system_configuration.dcache_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined __linux__
|
2013-06-10 16:05:09 +00:00
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "elf.h"
|
2008-12-11 19:12:59 +00:00
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
void qemu_cache_utils_init(void)
|
2008-12-10 19:18:40 +00:00
|
|
|
{
|
2013-06-10 16:05:09 +00:00
|
|
|
unsigned long dsize = qemu_getauxval(AT_DCACHEBSIZE);
|
|
|
|
unsigned long isize = qemu_getauxval(AT_ICACHEBSIZE);
|
2008-12-10 19:18:40 +00:00
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
if (dsize == 0 || isize == 0) {
|
|
|
|
if (dsize == 0) {
|
|
|
|
fprintf(stderr, "getauxval AT_DCACHEBSIZE failed\n");
|
|
|
|
}
|
|
|
|
if (isize == 0) {
|
|
|
|
fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
|
2008-12-10 19:18:40 +00:00
|
|
|
}
|
2013-06-10 16:05:09 +00:00
|
|
|
exit(1);
|
|
|
|
|
2008-12-10 19:18:40 +00:00
|
|
|
}
|
2013-06-10 16:05:09 +00:00
|
|
|
qemu_cache_conf.dcache_bsize = dsize;
|
|
|
|
qemu_cache_conf.icache_bsize = isize;
|
2008-12-10 19:18:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined __APPLE__
|
2009-02-04 20:39:09 +00:00
|
|
|
#include <stdio.h>
|
2008-12-10 19:18:40 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
void qemu_cache_utils_init(void)
|
2008-12-10 19:18:40 +00:00
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
unsigned cacheline;
|
|
|
|
int name[2] = { CTL_HW, HW_CACHELINE };
|
|
|
|
|
2009-02-04 20:39:09 +00:00
|
|
|
len = sizeof(cacheline);
|
2008-12-10 19:18:40 +00:00
|
|
|
if (sysctl(name, 2, &cacheline, &len, NULL, 0)) {
|
|
|
|
perror("sysctl CTL_HW HW_CACHELINE failed");
|
|
|
|
} else {
|
|
|
|
qemu_cache_conf.dcache_bsize = cacheline;
|
|
|
|
qemu_cache_conf.icache_bsize = cacheline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2010-03-12 21:50:15 +00:00
|
|
|
#include <errno.h>
|
2010-02-19 18:28:23 +00:00
|
|
|
#include <stdio.h>
|
2010-03-12 21:50:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-02-19 18:28:23 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
2013-06-10 16:05:09 +00:00
|
|
|
void qemu_cache_utils_init(void)
|
2010-02-19 18:28:23 +00:00
|
|
|
{
|
|
|
|
size_t len = 4;
|
|
|
|
unsigned cacheline;
|
|
|
|
|
|
|
|
if (sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0)) {
|
|
|
|
fprintf(stderr, "sysctlbyname machdep.cacheline_size failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_cache_conf.dcache_bsize = cacheline;
|
|
|
|
qemu_cache_conf.icache_bsize = cacheline;
|
|
|
|
}
|
2010-10-31 21:53:19 +00:00
|
|
|
#endif
|
2010-02-19 18:28:23 +00:00
|
|
|
|
2009-01-14 18:39:49 +00:00
|
|
|
#endif /* _ARCH_PPC */
|