aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_netbsd.c
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@amd.com>2011-01-27 19:03:42 +0000
committerChristoph Egger <Christoph.Egger@amd.com>2011-01-27 19:03:42 +0000
commite46432026803ad6f750db3b448d962dc20c656e9 (patch)
tree2610b0faf51f482de46c85cb623076ff65bee2d7 /tools/libxc/xc_netbsd.c
parent921fb156d4bd70020211e377207f52e06cb12e16 (diff)
downloadxen-e46432026803ad6f750db3b448d962dc20c656e9.tar.gz
xen-e46432026803ad6f750db3b448d962dc20c656e9.tar.bz2
xen-e46432026803ad6f750db3b448d962dc20c656e9.zip
libxc: break xc_get_physmem out into os-dependent files
NetBSD doesn't have sysconf(_SC_PHYS_PAGES). Factor physmem() out into os-dependent files and rename it to xc_get_physmem() so as not to pollute the namespace. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_netbsd.c')
-rw-r--r--tools/libxc/xc_netbsd.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c
index 8c82e36645..76d80595e8 100644
--- a/tools/libxc/xc_netbsd.c
+++ b/tools/libxc/xc_netbsd.c
@@ -23,6 +23,9 @@
#include <xen/sys/evtchn.h>
#include <unistd.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/sysctl.h>
static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch)
{
@@ -351,6 +354,24 @@ void discard_file_cache(xc_interface *xch, int fd, int flush)
errno = saved_errno;
}
+uint64_t xc_get_physmem(void)
+{
+ int mib[2], rc;
+ size_t len;
+ uint64_t physmem;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_PHYSMEM64;
+ rc = sysctl(mib, 2, &physmem, &len, NULL, 0);
+
+ if (rc == -1) {
+ /* PERROR("%s: Failed to get hw.physmem64: %s\n", strerror(errno)); */
+ return 0;
+ }
+
+ return physmem;
+}
+
static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_type type)
{
switch ( type )