[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] xencomm: Remove xencomm



Being a feature that has only been used by ia64 and/or ppc it
doesn't seem like we need to keep it any longer in the tree.

So remove it.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
 xen/common/Makefile          |    2 -
 xen/common/xencomm.c         |  621 ------------------------------------------
 xen/include/Makefile         |    1 -
 xen/include/public/xencomm.h |   41 ---
 xen/include/xen/xencomm.h    |  170 ------------
 5 files changed, 0 insertions(+), 835 deletions(-)
 delete mode 100644 xen/common/xencomm.c
 delete mode 100644 xen/include/public/xencomm.h
 delete mode 100644 xen/include/xen/xencomm.h

diff --git a/xen/common/Makefile b/xen/common/Makefile
index 3683ae3..b9ed767 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -58,8 +58,6 @@ obj-$(perfc)       += perfc.o
 obj-$(crash_debug) += gdbstub.o
 obj-$(xenoprof)    += xenoprof.o
 
-obj-$(CONFIG_XENCOMM) += xencomm.o
-
 subdir-$(CONFIG_COMPAT) += compat
 
 subdir-$(x86_64) += hvm
diff --git a/xen/common/xencomm.c b/xen/common/xencomm.c
deleted file mode 100644
index 2604ac0..0000000
--- a/xen/common/xencomm.c
+++ /dev/null
@@ -1,621 +0,0 @@
-/******************************************************************************
- * xencomm.c
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Copyright (C) IBM Corp. 2006
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          Tristan Gingold <tristan.gingold@xxxxxxxx>
- *          Isaku Yamahata <yamahata@xxxxxxxxxxxxx> multiple page support
- */
-
-#include <xen/config.h>
-#include <xen/mm.h>
-#include <xen/sched.h>
-#include <xen/xencomm.h>
-#include <public/xen.h>
-#include <public/xencomm.h>
-
-#undef DEBUG
-#ifdef DEBUG
-#define xc_dprintk(f, a...) printk("[xencomm]" f , ## a)
-#else
-#define xc_dprintk(f, a...) ((void)0)
-#endif
-
-static void *
-xencomm_vaddr(unsigned long paddr, struct page_info *page)
-{
-    return (void*)((paddr & ~PAGE_MASK) | (unsigned long)page_to_virt(page));
-}
-
-/* get_page() to prevent another vcpu freeing the page. */
-static int
-xencomm_get_page(unsigned long paddr, struct page_info **page)
-{
-    unsigned long maddr = paddr_to_maddr(paddr);
-    if ( maddr == 0 )
-        return -EFAULT;
-        
-    *page = maddr_to_page(maddr);
-    if ( !get_page(*page, current->domain) )
-    {
-        /*
-         * This page might be a page granted by another domain, or this page 
-         * is freed with decrease reservation hypercall at the same time.
-         */
-        gdprintk(XENLOG_WARNING,
-                 "bad page is passed. paddr %#lx maddr %#lx\n",
-                 paddr, maddr);
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-/* check if struct desc doesn't cross page boundry */
-static int
-xencomm_desc_cross_page_boundary(unsigned long paddr)
-{
-    unsigned long offset = paddr & ~PAGE_MASK;
-    if ( offset > PAGE_SIZE - sizeof(struct xencomm_desc) )
-        return 1;
-    return 0;
-}
-
-struct xencomm_ctxt {
-    struct xencomm_desc __user *desc_in_paddr;
-    uint32_t nr_addrs;
-
-    struct page_info *page;
-    unsigned long *address;
-};
-
-static uint32_t
-xencomm_ctxt_nr_addrs(const struct xencomm_ctxt *ctxt)
-{
-    return ctxt->nr_addrs;
-}
-
-static unsigned long*
-xencomm_ctxt_address(struct xencomm_ctxt *ctxt)
-{
-    return ctxt->address;
-}
-
-static int
-xencomm_ctxt_init(const void *handle, struct xencomm_ctxt *ctxt)
-{
-    struct page_info *page;
-    struct xencomm_desc *desc;
-    int ret;
-
-    /* Avoid unaligned access. */
-    if ( ((unsigned long)handle % __alignof__(*desc)) != 0 )
-        return -EINVAL;
-    if ( xencomm_desc_cross_page_boundary((unsigned long)handle) )
-        return -EINVAL;
-
-    /* First we need to access the descriptor. */
-    ret = xencomm_get_page((unsigned long)handle, &page);
-    if ( ret )
-        return ret;
-
-    desc = xencomm_vaddr((unsigned long)handle, page);
-    if ( desc->magic != XENCOMM_MAGIC )
-    {
-        printk("%s: error: %p magic was %#x\n", __func__, desc, desc->magic);
-        put_page(page);
-        return -EINVAL;
-    }
-
-    /* Copy before use: It is possible for a guest to modify concurrently. */
-    ctxt->nr_addrs = desc->nr_addrs;
-    ctxt->desc_in_paddr = (struct xencomm_desc*)handle;
-    ctxt->page = page;
-    ctxt->address = &desc->address[0];
-    return 0;
-}
-
-/*
- * Calculate the vaddr of &ctxt->desc_in_paddr->address[i] and get_page().
- * And put the results in ctxt->page and ctxt->address.
- * If there is the previous page, put_page().
- *
- * A guest domain passes the array, ctxt->desc_in_paddr->address[].
- * It is gpaddr-contiguous, but not maddr-contiguous so that
- * we can't obtain the vaddr by simple offsetting.
- * We need to convert gpaddr, &ctxt->desc_in_paddr->address[i],
- * into maddr and then convert it to the xen virtual address in order
- * to access there.
- * The conversion can be optimized out by using the last result of
- * ctxt->address because we access the array sequentially.
- * The conversion, gpaddr -> maddr -> vaddr, is necessary only when
- * crossing page boundary.
- */
-static int
-xencomm_ctxt_next(struct xencomm_ctxt *ctxt, int i)
-{
-    unsigned long paddr;
-    struct page_info *page;
-    int ret;
-
-    BUG_ON(i >= ctxt->nr_addrs);
-
-    /* For i == 0 case we already calculated it in xencomm_ctxt_init(). */
-    if ( i != 0 )
-        ctxt->address++;
-
-    if ( ((unsigned long)ctxt->address & ~PAGE_MASK) != 0 )
-        return 0;
-
-    /* Crossing page boundary: machine address must be calculated. */
-    paddr = (unsigned long)&ctxt->desc_in_paddr->address[i];
-    ret = xencomm_get_page(paddr, &page);
-    if ( ret )
-        return ret;
-
-    put_page(ctxt->page);
-    ctxt->page = page;
-    ctxt->address = xencomm_vaddr(paddr, page);
-
-    return 0;
-}
-
-static void
-xencomm_ctxt_done(struct xencomm_ctxt *ctxt)
-{
-    put_page(ctxt->page);
-}
-
-static int
-xencomm_copy_chunk_from(
-    unsigned long to, unsigned long paddr, unsigned int  len)
-{
-    struct page_info *page;
-    int res;
-
-    do {
-        res = xencomm_get_page(paddr, &page);
-    } while ( res == -EAGAIN );
-
-    if ( res )
-        return res;
-
-    xc_dprintk("%lx[%d] -> %lx\n",
-               (unsigned long)xencomm_vaddr(paddr, page), len, to);
-
-    memcpy((void *)to, xencomm_vaddr(paddr, page), len);
-    put_page(page);
-
-    return 0;
-}
-
-static unsigned long
-xencomm_inline_from_guest(
-    void *to, const void *from, unsigned int n, unsigned int skip)
-{
-    unsigned long src_paddr = xencomm_inline_addr(from) + skip;
-
-    while ( n > 0 )
-    {
-        unsigned int chunksz, bytes;
-
-        chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE);
-        bytes   = min(chunksz, n);
-
-        if ( xencomm_copy_chunk_from((unsigned long)to, src_paddr, bytes) )
-            return n;
-        src_paddr += bytes;
-        to += bytes;
-        n -= bytes;
-    }
-
-    /* Always successful. */
-    return 0;
-}
-
-/**
- * xencomm_copy_from_guest: Copy a block of data from domain space.
- * @to:   Machine address.
- * @from: Physical address to a xencomm buffer descriptor.
- * @n:    Number of bytes to copy.
- * @skip: Number of bytes from the start to skip.
- *
- * Copy data from domain to hypervisor.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-unsigned long
-xencomm_copy_from_guest(
-    void *to, const void *from, unsigned int n, unsigned int skip)
-{
-    struct xencomm_ctxt ctxt;
-    unsigned int from_pos = 0;
-    unsigned int to_pos = 0;
-    unsigned int i = 0;
-
-    if ( xencomm_is_inline(from) )
-        return xencomm_inline_from_guest(to, from, n, skip);
-
-    if ( xencomm_ctxt_init(from, &ctxt) )
-        return n;
-
-    /* Iterate through the descriptor, copying up to a page at a time */
-    while ( (to_pos < n) && (i < xencomm_ctxt_nr_addrs(&ctxt)) )
-    {
-        unsigned long src_paddr;
-        unsigned int pgoffset, chunksz, chunk_skip;
-
-        if ( xencomm_ctxt_next(&ctxt, i) )
-            goto out;
-        src_paddr = *xencomm_ctxt_address(&ctxt);
-        if ( src_paddr == XENCOMM_INVALID )
-        {
-            i++;
-            continue;
-        }
-
-        pgoffset = src_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, skip);
-        from_pos += chunk_skip;
-        chunksz -= chunk_skip;
-        skip -= chunk_skip;
-
-        if ( skip == 0 && chunksz > 0 )
-        {
-            unsigned int bytes = min(chunksz, n - to_pos);
-
-            if ( xencomm_copy_chunk_from((unsigned long)to + to_pos,
-                                         src_paddr + chunk_skip, bytes) )
-                goto out;
-            from_pos += bytes;
-            to_pos += bytes;
-        }
-
-        i++;
-    }
-
-out:
-    xencomm_ctxt_done(&ctxt);
-    return n - to_pos;
-}
-
-static int
-xencomm_copy_chunk_to(
-    unsigned long paddr, unsigned long from, unsigned int  len)
-{
-    struct page_info *page;
-    int res;
-
-    do {
-        res = xencomm_get_page(paddr, &page);
-    } while ( res == -EAGAIN );
-
-    if ( res )
-        return res;
-
-    xc_dprintk("%lx[%d] -> %lx\n", from, len,
-               (unsigned long)xencomm_vaddr(paddr, page));
-
-    memcpy(xencomm_vaddr(paddr, page), (void *)from, len);
-    xencomm_mark_dirty((unsigned long)xencomm_vaddr(paddr, page), len);
-    put_page(page);
-
-    return 0;
-}
-
-static unsigned long
-xencomm_inline_to_guest(
-    void *to, const void *from, unsigned int n, unsigned int skip)
-{
-    unsigned long dest_paddr = xencomm_inline_addr(to) + skip;
-
-    while ( n > 0 )
-    {
-        unsigned int chunksz, bytes;
-
-        chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
-        bytes   = min(chunksz, n);
-
-        if ( xencomm_copy_chunk_to(dest_paddr, (unsigned long)from, bytes) )
-            return n;
-        dest_paddr += bytes;
-        from += bytes;
-        n -= bytes;
-    }
-
-    /* Always successful. */
-    return 0;
-}
-
-/**
- * xencomm_copy_to_guest: Copy a block of data to domain space.
- * @to:     Physical address to xencomm buffer descriptor.
- * @from:   Machine address.
- * @n:      Number of bytes to copy.
- * @skip: Number of bytes from the start to skip.
- *
- * Copy data from hypervisor to domain.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-unsigned long
-xencomm_copy_to_guest(
-    void *to, const void *from, unsigned int n, unsigned int skip)
-{
-    struct xencomm_ctxt ctxt;
-    unsigned int from_pos = 0;
-    unsigned int to_pos = 0;
-    unsigned int i = 0;
-
-    if ( xencomm_is_inline(to) )
-        return xencomm_inline_to_guest(to, from, n, skip);
-
-    if ( xencomm_ctxt_init(to, &ctxt) )
-        return n;
-
-    /* Iterate through the descriptor, copying up to a page at a time */
-    while ( (from_pos < n) && (i < xencomm_ctxt_nr_addrs(&ctxt)) )
-    {
-        unsigned long dest_paddr;
-        unsigned int pgoffset, chunksz, chunk_skip;
-
-        if ( xencomm_ctxt_next(&ctxt, i) )
-            goto out;
-        dest_paddr = *xencomm_ctxt_address(&ctxt);
-        if ( dest_paddr == XENCOMM_INVALID )
-        {
-            i++;
-            continue;
-        }
-
-        pgoffset = dest_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, skip);
-        to_pos += chunk_skip;
-        chunksz -= chunk_skip;
-        skip -= chunk_skip;
-
-        if ( skip == 0 && chunksz > 0 )
-        {
-            unsigned int bytes = min(chunksz, n - from_pos);
-
-            if ( xencomm_copy_chunk_to(dest_paddr + chunk_skip,
-                                      (unsigned long)from + from_pos, bytes) )
-                goto out;
-            from_pos += bytes;
-            to_pos += bytes;
-        }
-
-        i++;
-    }
-
-out:
-    xencomm_ctxt_done(&ctxt);
-    return n - from_pos;
-}
-
-static int
-xencomm_clear_chunk(
-    unsigned long paddr, unsigned int  len)
-{
-    struct page_info *page;
-    int res;
-
-    do {
-        res = xencomm_get_page(paddr, &page);
-    } while ( res == -EAGAIN );
-
-    if ( res )
-        return res;
-
-    memset(xencomm_vaddr(paddr, page), 0x00, len);
-    xencomm_mark_dirty((unsigned long)xencomm_vaddr(paddr, page), len);
-    put_page(page);
-
-    return 0;
-}
-
-static unsigned long
-xencomm_inline_clear_guest(
-    void *to, unsigned int n, unsigned int skip)
-{
-    unsigned long dest_paddr = xencomm_inline_addr(to) + skip;
-
-    while ( n > 0 )
-    {
-        unsigned int chunksz, bytes;
-
-        chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
-        bytes   = min(chunksz, n);
-
-        if ( xencomm_clear_chunk(dest_paddr, bytes) )
-            return n;
-        dest_paddr += bytes;
-        n -= bytes;
-    }
-
-    /* Always successful. */
-    return 0;
-}
-
-/**
- * xencomm_clear_guest: Clear a block of data in domain space.
- * @to:     Physical address to xencomm buffer descriptor.
- * @n:      Number of bytes to copy.
- * @skip: Number of bytes from the start to skip.
- *
- * Clear domain data
- *
- * Returns number of bytes that could not be cleared
- * On success, this will be zero.
- */
-unsigned long
-xencomm_clear_guest(
-    void *to, unsigned int n, unsigned int skip)
-{
-    struct xencomm_ctxt ctxt;
-    unsigned int from_pos = 0;
-    unsigned int to_pos = 0;
-    unsigned int i = 0;
-
-    if ( xencomm_is_inline(to) )
-        return xencomm_inline_clear_guest(to, n, skip);
-
-    if ( xencomm_ctxt_init(to, &ctxt) )
-        return n;
-
-    /* Iterate through the descriptor, copying up to a page at a time */
-    while ( (from_pos < n) && (i < xencomm_ctxt_nr_addrs(&ctxt)) )
-    {
-        unsigned long dest_paddr;
-        unsigned int pgoffset, chunksz, chunk_skip;
-
-        if ( xencomm_ctxt_next(&ctxt, i) )
-            goto out;
-        dest_paddr = *xencomm_ctxt_address(&ctxt);
-        if ( dest_paddr == XENCOMM_INVALID )
-        {
-            i++;
-            continue;
-        }
-
-        pgoffset = dest_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, skip);
-        to_pos += chunk_skip;
-        chunksz -= chunk_skip;
-        skip -= chunk_skip;
-
-        if ( skip == 0 && chunksz > 0 )
-        {
-            unsigned int bytes = min(chunksz, n - from_pos);
-
-            if ( xencomm_clear_chunk(dest_paddr + chunk_skip, bytes) )
-                goto out;
-            from_pos += bytes;
-            to_pos += bytes;
-        }
-
-        i++;
-    }
-
-out:
-    xencomm_ctxt_done(&ctxt);
-    return n - from_pos;
-}
-
-static int xencomm_inline_add_offset(void **handle, unsigned int bytes)
-{
-    *handle += bytes;
-    return 0;
-}
-
-/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
- * exhausted pages to XENCOMM_INVALID. */
-int xencomm_add_offset(void **handle, unsigned int bytes)
-{
-    struct xencomm_ctxt ctxt;
-    int i = 0;
-    int res = 0;
-
-    if ( xencomm_is_inline(*handle) )
-        return xencomm_inline_add_offset(handle, bytes);
-
-    res = xencomm_ctxt_init(handle, &ctxt);
-    if ( res != 0 )
-        return res;
-
-    /* Iterate through the descriptor incrementing addresses */
-    while ( (bytes > 0) && (i < xencomm_ctxt_nr_addrs(&ctxt)) )
-    {
-        unsigned long *address;
-        unsigned long dest_paddr;
-        unsigned int pgoffset, chunksz, chunk_skip;
-
-        res = xencomm_ctxt_next(&ctxt, i);
-        if ( res )
-            goto out;
-        address = xencomm_ctxt_address(&ctxt);
-        dest_paddr = *address;
-        if ( dest_paddr == XENCOMM_INVALID )
-        {
-            i++;
-            continue;
-        }
-
-        pgoffset = dest_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, bytes);
-        if ( chunk_skip == chunksz )
-            *address = XENCOMM_INVALID; /* exhausted this page */
-        else
-            *address += chunk_skip;
-        bytes -= chunk_skip;
-
-        i++;
-    }
-
-out:
-    xencomm_ctxt_done(&ctxt);
-    return res;
-}
-
-int xencomm_handle_is_null(void *handle)
-{
-    struct xencomm_ctxt ctxt;
-    int i;
-    int res = 1;
-
-    if ( xencomm_is_inline(handle) )
-        return xencomm_inline_addr(handle) == 0;
-
-    if ( xencomm_ctxt_init(handle, &ctxt) )
-        return 1;
-
-    for ( i = 0; i < xencomm_ctxt_nr_addrs(&ctxt); i++ )
-    {
-        if ( xencomm_ctxt_next(&ctxt, i) )
-            goto out;
-        if ( *xencomm_ctxt_address(&ctxt) != XENCOMM_INVALID )
-        {
-            res = 0;
-            goto out;
-        }
-    }
-
-out:
-    xencomm_ctxt_done(&ctxt);
-    return res;
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/Makefile b/xen/include/Makefile
index d6f0cf7..fd2d51f 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -21,7 +21,6 @@ headers-y := \
     compat/vcpu.h \
     compat/version.h \
     compat/xen.h \
-    compat/xencomm.h \
     compat/xenoprof.h
 headers-$(CONFIG_X86)     += compat/arch-x86/xen-mca.h
 headers-$(CONFIG_X86)     += compat/arch-x86/xen.h
diff --git a/xen/include/public/xencomm.h b/xen/include/public/xencomm.h
deleted file mode 100644
index ac45e07..0000000
--- a/xen/include/public/xencomm.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Copyright (C) IBM Corp. 2006
- */
-
-#ifndef _XEN_XENCOMM_H_
-#define _XEN_XENCOMM_H_
-
-/* A xencomm descriptor is a scatter/gather list containing physical
- * addresses corresponding to a virtually contiguous memory area. The
- * hypervisor translates these physical addresses to machine addresses to copy
- * to and from the virtually contiguous area.
- */
-
-#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
-#define XENCOMM_INVALID (~0UL)
-
-struct xencomm_desc {
-    uint32_t magic;
-    uint32_t nr_addrs; /* the number of entries in address[] */
-    uint64_t address[0];
-};
-
-#endif /* _XEN_XENCOMM_H_ */
diff --git a/xen/include/xen/xencomm.h b/xen/include/xen/xencomm.h
deleted file mode 100644
index 3426b8a..0000000
--- a/xen/include/xen/xencomm.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Copyright (C) IBM Corp. 2006
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- */
-
-#ifndef __XENCOMM_H__
-#define __XENCOMM_H__
-
-#include <public/xen.h>
-
-unsigned long xencomm_copy_to_guest(
-    void *to, const void *from, unsigned int len, unsigned int skip); 
-unsigned long xencomm_copy_from_guest(
-    void *to, const void *from, unsigned int len, unsigned int skip); 
-unsigned long xencomm_clear_guest(
-    void *to, unsigned int n, unsigned int skip);
-int xencomm_add_offset(void **handle, unsigned int bytes);
-int xencomm_handle_is_null(void *ptr);
-
-static inline int xencomm_is_inline(const void *handle)
-{
-    unsigned long addr = (unsigned long)handle;
-    return (addr & XENCOMM_INLINE_FLAG) == XENCOMM_INLINE_FLAG;
-}
-
-static inline unsigned long xencomm_inline_addr(const void *handle)
-{
-    return (unsigned long)handle & ~XENCOMM_INLINE_FLAG;
-}
-
-#define raw_copy_to_guest(dst, src, len)       \
-    xencomm_copy_to_guest(dst, src, len, 0)
-#define raw_copy_from_guest(dst, src, len)     \
-    xencomm_copy_from_guest(dst, src, nr, 0)
-#define raw_clear_guest(dst, len)              \
-    xencomm_clear_guest(dst, len, 0)
-#define __raw_copy_to_guest raw_copy_to_guest
-#define __raw_copy_from_guest raw_copy_from_guest
-#define __raw_clear_guest raw_clear_guest
-
-/* Is the guest handle a NULL reference? */
-#define guest_handle_is_null(hnd) \
-    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
-
-/* Offset the given guest handle into the array it refers to. */
-#define guest_handle_add_offset(hnd, nr) ({                             \
-    const typeof((hnd).p) _ptr;                                         \
-    xencomm_add_offset((void **)&((hnd).p), nr * sizeof(*_ptr));        \
-})
-
-/* Cast a guest handle to the specified type of handle. */
-#define guest_handle_cast(hnd, type) ({         \
-    type *_x = (hnd).p;                         \
-    XEN_GUEST_HANDLE_PARAM(type) _y;            \
-    set_xen_guest_handle(_y, _x);               \
-    _y;                                         \
-})
-
-/* Cast a XEN_GUEST_HANDLE to XEN_GUEST_HANDLE_PARAM */
-#define guest_handle_to_param(hnd, type) ({                  \
-    /* type checking: make sure that the pointers inside     \
-     * XEN_GUEST_HANDLE and XEN_GUEST_HANDLE_PARAM are of    \
-     * the same type, then return hnd */                     \
-    (void)((typeof(&(hnd).p)) 0 ==                           \
-        (typeof(&((XEN_GUEST_HANDLE_PARAM(type)) {}).p)) 0); \
-    (hnd);                                                   \
-})
-
-/* Cast a XEN_GUEST_HANDLE_PARAM to XEN_GUEST_HANDLE */
-#define guest_handle_from_param(hnd, type) ({                \
-    /* type checking: make sure that the pointers inside     \
-     * XEN_GUEST_HANDLE and XEN_GUEST_HANDLE_PARAM are of    \
-     * the same type, then return hnd */                     \
-    (void)((typeof(&(hnd).p)) 0 ==                           \
-        (typeof(&((XEN_GUEST_HANDLE_PARAM(type)) {}).p)) 0); \
-    (hnd);                                                   \
-})
-
-/* Since we run in real mode, we can safely access all addresses. That also
- * means our __routines are identical to our "normal" routines. */
-#define guest_handle_okay(hnd, nr) 1
-#define guest_handle_subrange_okay(hnd, first, last) 1
-
-/*
- * Copy an array of objects to guest context via a guest handle.
- * Optionally specify an offset into the guest array.
- */
-#define copy_to_guest_offset(hnd, idx, ptr, nr) \
-    __copy_to_guest_offset(hnd, idx, ptr, nr)
-
-/* Copy sub-field of a structure to guest context via a guest handle. */
-#define copy_field_to_guest(hnd, ptr, field) \
-    __copy_field_to_guest(hnd, ptr, field)
-
-/*
- * Copy an array of objects from guest context via a guest handle.
- * Optionally specify an offset into the guest array.
- */
-#define copy_from_guest_offset(ptr, hnd, idx, nr) \
-    __copy_from_guest_offset(ptr, hnd, idx, nr)
-
-/*
- * Clear an array of objects in guest context via a guest handle.
- * Optionally specify an offset into the guest array.
- */
-#define clear_guest_offset(hnd, idx, nr) \
-    __clear_guest_offset(hnd, idx, nr)
-
-/* Copy sub-field of a structure from guest context via a guest handle. */
-#define copy_field_from_guest(ptr, hnd, field) \
-    __copy_field_from_guest(ptr, hnd, field)
-
-#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                \
-    const typeof(*(ptr)) *_s = (ptr);                               \
-    void *_d = (hnd).p;                                             \
-    ((void)((hnd).p == (ptr)));                                     \
-    xencomm_copy_to_guest(_d, _s, sizeof(*_s)*(nr), sizeof(*_s)*(idx)); \
-})
-
-#define __copy_field_to_guest(hnd, ptr, field) ({                   \
-    unsigned int _off = offsetof(typeof(*(hnd).p), field);          \
-    const typeof(&(ptr)->field) _s = &(ptr)->field;                 \
-    void *_d = (hnd).p;                                             \
-    ((void)(&(hnd).p->field == &(ptr)->field));                     \
-    xencomm_copy_to_guest(_d, _s, sizeof(*_s), _off);               \
-})
-
-#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({              \
-    const typeof(*(ptr)) *_s = (hnd).p;                             \
-    typeof(*(ptr)) *_d = (ptr);                                     \
-    xencomm_copy_from_guest(_d, _s, sizeof(*_d)*(nr), sizeof(*_d)*(idx)); \
-})
-
-#define __copy_field_from_guest(ptr, hnd, field) ({                 \
-    unsigned int _off = offsetof(typeof(*(hnd).p), field);          \
-    const void *_s = (hnd).p;                                       \
-    typeof(&(ptr)->field) _d = &(ptr)->field;                       \
-    ((void)(&(hnd).p->field == &(ptr)->field));                     \
-    xencomm_copy_from_guest(_d, _s, sizeof(*_d), _off);             \
-})
-
-#define __clear_guest_offset(hnd, idx, nr) ({                \
-    void *_d = (hnd).p;                                             \
-    xencomm_clear_guest(_d, nr, idx); \
-})
-
-#ifdef CONFIG_XENCOMM_MARK_DIRTY
-extern void xencomm_mark_dirty(unsigned long addr, unsigned int len);
-#else
-static inline void xencomm_mark_dirty(unsigned long addr, unsigned int len)
-{
-}
-#endif
-
-#endif /* __XENCOMM_H__ */
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.