head 1.3; access; symbols pkgsrc-2013Q2:1.3.0.26 pkgsrc-2013Q2-base:1.3 pkgsrc-2012Q4:1.3.0.24 pkgsrc-2012Q4-base:1.3 pkgsrc-2011Q4:1.3.0.22 pkgsrc-2011Q4-base:1.3 pkgsrc-2011Q2:1.3.0.20 pkgsrc-2011Q2-base:1.3 pkgsrc-2009Q4:1.3.0.18 pkgsrc-2009Q4-base:1.3 pkgsrc-2008Q4:1.3.0.16 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.14 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.12 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.3.0.10 pkgsrc-2008Q2-base:1.3 pkgsrc-2008Q1:1.3.0.8 pkgsrc-2008Q1-base:1.3 pkgsrc-2007Q4:1.3.0.6 pkgsrc-2007Q4-base:1.3 pkgsrc-2007Q3:1.3.0.4 pkgsrc-2007Q3-base:1.3 pkgsrc-2007Q2:1.3.0.2 pkgsrc-2007Q2-base:1.3 pkgsrc-2007Q1:1.2.0.4 pkgsrc-2007Q1-base:1.2 pkgsrc-2006Q4:1.2.0.2 pkgsrc-2006Q4-base:1.2 pkgsrc-2006Q3:1.1.1.1.0.2 pkgsrc-2006Q3-base:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.3 date 2007.06.14.19.44.49; author bouyer; state dead; branches; next 1.2; 1.2 date 2006.10.19.22.57.13; author bouyer; state Exp; branches; next 1.1; 1.1 date 2006.07.02.16.49.31; author bouyer; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2006.07.02.16.49.31; author bouyer; state Exp; branches; next ; desc @@ 1.3 log @Renamed xen*30 to xen*3 @ text @$NetBSD: patch-ab,v 1.2 2006/10/19 22:57:13 bouyer Exp $ --- /dev/null 2006-10-17 00:01:34.000000000 +0200 +++ libxc/xc_netbsd.c 2006-10-17 00:05:12.000000000 +0200 @@@@ -0,0 +1,264 @@@@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + */ + +#include "xc_private.h" + +#include +#include +#include +#include + +int xc_interface_open(void) +{ + int flags, saved_errno; + int fd = open("/kern/xen/privcmd", O_RDWR); + + if ( fd == -1 ) + { + PERROR("Could not obtain handle on privileged command interface"); + return -1; + } + + /* Although we return the file handle as the 'xc handle' the API + does not specify / guarentee that this integer is in fact + a file handle. Thus we must take responsiblity to ensure + it doesn't propagate (ie leak) outside the process */ + if ( (flags = fcntl(fd, F_GETFD)) < 0 ) + { + PERROR("Could not get file handle flags"); + goto error; + } + flags |= FD_CLOEXEC; + if ( fcntl(fd, F_SETFD, flags) < 0 ) + { + PERROR("Could not set file handle flags"); + goto error; + } + + return fd; + + error: + saved_errno = errno; + close(fd); + errno = saved_errno; + return -1; +} + +int xc_interface_close(int xc_handle) +{ + return close(xc_handle); +} + +void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, + xen_pfn_t *arr, int num) +{ + privcmd_mmapbatch_t ioctlx; + void *addr; + addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0); + if ( addr == MAP_FAILED ) + return NULL; + + ioctlx.num=num; + ioctlx.dom=dom; + ioctlx.addr=(unsigned long)addr; + ioctlx.arr=arr; + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 ) + { + int saved_errno = errno; + perror("XXXXXXXX"); + (void)munmap(addr, num*PAGE_SIZE); + errno = saved_errno; + return NULL; + } + return addr; + +} + +void *xc_map_foreign_range(int xc_handle, uint32_t dom, + int size, int prot, + unsigned long mfn) +{ + privcmd_mmap_t ioctlx; + privcmd_mmap_entry_t entry; + void *addr; + addr = mmap(NULL, size, prot, MAP_ANON | MAP_SHARED, -1, 0); + if ( addr == MAP_FAILED ) + return NULL; + + ioctlx.num=1; + ioctlx.dom=dom; + ioctlx.entry=&entry; + entry.va=(unsigned long) addr; + entry.mfn=mfn; + entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 ) + { + int saved_errno = errno; + (void)munmap(addr, size); + errno = saved_errno; + return NULL; + } + return addr; +} + +int xc_map_foreign_ranges(int xc_handle, uint32_t dom, + privcmd_mmap_entry_t *entries, int nr) +{ + privcmd_mmap_t ioctlx; + int err; + + ioctlx.num = nr; + ioctlx.dom = dom; + ioctlx.entry = entries; + + err = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx); + if (err == 0) + return 0; + else + return -errno; +} + +static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data) +{ + int err = ioctl(xc_handle, cmd, data); + if (err == 0) + return 0; + else + return -errno; +} + +int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall) +{ + return do_privcmd(xc_handle, + IOCTL_PRIVCMD_HYPERCALL, + (unsigned long)hypercall); +} + +#ifdef __NetBSD__ +#define EVTCHN_DEV_NAME "/dev/xenevt" +#else +#define EVTCHN_DEV_NAME "/dev/xen/evtchn" +#define EVTCHN_DEV_MAJOR 10 +#define EVTCHN_DEV_MINOR 201 +#endif + +int xc_evtchn_open(void) +{ + return open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); +} + +int xc_evtchn_close(int xce_handle) +{ + return close(xce_handle); +} + +int xc_evtchn_fd(int xce_handle) +{ + return xce_handle; +} + +int xc_evtchn_notify(int xce_handle, evtchn_port_t port) +{ + struct ioctl_evtchn_notify notify; + + notify.port = port; + + return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid, + evtchn_port_t remote_port) +{ + struct ioctl_evtchn_bind_interdomain bind; + int ret; + + bind.remote_domain = domid; + bind.remote_port = remote_port; + + ret = ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); + if (ret == 0) + return bind.port; + else + return -1; +} + +int xc_evtchn_unbind(int xce_handle, evtchn_port_t port) +{ + struct ioctl_evtchn_unbind unbind; + + unbind.port = port; + + return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind); +} + +evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq) +{ + struct ioctl_evtchn_bind_virq bind; + int err; + + bind.virq = virq; + + err = ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind); + if (err) + return -1; + else + return bind.port; +} + +static int dorw(int fd, char *data, size_t size, int do_write) +{ + size_t offset = 0; + ssize_t len; + + while ( offset < size ) + { + if (do_write) + len = write(fd, data + offset, size - offset); + else + len = read(fd, data + offset, size - offset); + + if ( len == -1 ) + { + if ( errno == EINTR ) + continue; + return -1; + } + + offset += len; + } + + return 0; +} + +evtchn_port_t xc_evtchn_pending(int xce_handle) +{ + evtchn_port_t port; + + if ( dorw(xce_handle, (char *)&port, sizeof(port), 0) == -1 ) + return -1; + + return port; +} + +int xc_evtchn_unmask(int xce_handle, evtchn_port_t port) +{ + return dorw(xce_handle, (char *)&port, sizeof(port), 1); +} + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ @ 1.2 log @Update to 3.0.3. I don't have a comprehensive list of changes, only "many new features". One looks promising: - a new easy-to-use CPU scheduler which includes weights, caps, and automatic SMP load-balancing; pkgsrc changes: - remove patches against unused files - add a netbsd-specific example with verbose comments - add a vif script for ip-routing based setups @ text @d1 1 a1 1 $NetBSD: $ @ 1.1 log @Initial revision @ text @d1 1 a1 1 $NetBSD$ d3 267 a269 26 --- blktap/Makefile.orig 2006-01-31 17:09:20.000000000 +0100 +++ blktap/Makefile @@@@ -48,10 +48,10 @@@@ all: mk-symlinks libblktap.so #blkdump done install: all - $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR) - $(INSTALL_DIR) -p $(DESTDIR)/usr/include - $(INSTALL_PROG) $(LIB) $(DESTDIR)/usr/$(LIBDIR) - $(INSTALL_PROG) blktaplib.h $(DESTDIR)/usr/include + $(BSD_INSTALL_LIB_DIR) $(PREFIX)/lib + $(BSD_INSTALL_DATA_DIR) $(PREFIX)/include + $(BSD_INSTALL_LIB) $(LIB) $(PREFIX)/lib + $(BSD_INSTALL_DATA) blktaplib.h $(PREFIX)/include #$(INSTALL_PROG) $(IBINS) $(DESTDIR)$(BLKTAP_INSTALL_DIR) @@set -e; for subdir in $(SUBDIRS); do \ $(MAKE) -C $$subdir $@@; \ @@@@ -80,7 +80,7 @@@@ libblktap.so: $(OBJS) ln -sf libblktap.so.$(MAJOR) $@@ blkdump: libblktap.so - $(CC) $(CFLAGS) -o blkdump -L$(XEN_LIBXC) -L. \ + $(CC) $(CFLAGS) -o blkdump $(LDFLAGS) -L$(XEN_LIBXC) -L. \ -l blktap blkdump.c .PHONY: TAGS clean install mk-symlinks rpm @ 1.1.1.1 log @Initial import of a packages for Xen 3.0 domain0 tools. @ text @@