summaryrefslogtreecommitdiff
path: root/cache-utils.c
diff options
context:
space:
mode:
authorJuergen Lock <nox@jelal.kn-bremen.de>2010-02-19 19:28:23 +0100
committermalc <av1474@comtv.ru>2010-02-20 01:37:33 +0300
commite4ee916d3f9a93df06bd498c92767c1558d59a0b (patch)
treed0e348c6c468c3eca4f339f1744a85e6b678e165 /cache-utils.c
parent584771e6b6cba9f1571264645e15272d0ce9fe8e (diff)
Add FreeBSD/ppc host ppc_init_cacheline_sizes() implementation.
New version after malc's comments. (Added error handling.) Submitted by: Andreas Tobler <andreast@fgznet.ch> Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'cache-utils.c')
-rw-r--r--cache-utils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/cache-utils.c b/cache-utils.c
index 45d62c91c..8bbd68054 100644
--- a/cache-utils.c
+++ b/cache-utils.c
@@ -57,6 +57,27 @@ static void ppc_init_cacheline_sizes(void)
}
#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static void ppc_init_cacheline_sizes(void)
+{
+ 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;
+}
+#endif
+
#ifdef __linux__
void qemu_cache_utils_init(char **envp)
{