From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH XEN v5 09/23] tools: Refactor hypercall calling wrappers into libxencall. Date: Fri, 13 Nov 2015 15:35:14 +0000 Message-ID: <56460332.7060504@citrix.com> References: <1447070397.27774.11.camel@citrix.com> <1447070458-31104-1-git-send-email-ian.campbell@citrix.com> <1447070458-31104-10-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1447070458-31104-10-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 09/11/15 12:00, Ian Campbell wrote: > diff --git a/tools/libs/call/include/xencall.h b/tools/libs/call/include/xencall.h > new file mode 100644 > index 0000000..a0b3591 > --- /dev/null > +++ b/tools/libs/call/include/xencall.h > @@ -0,0 +1,84 @@ > +/* > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library 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 > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; If not, see . > + */ > +#ifndef XENCALL_H > +#define XENCALL_H > + > +/* > + * This library allows you to make arbitrary hypercalls (subject to > + * sufficient permission for the process and the domain itself). Note > + * that while the library interface is stable the hypercalls are > + * subject to their own rules. > + */ > + > +#include > +#include > + > +/* Callers who don't care don't need to #include */ > +typedef struct xentoollog_logger xentoollog_logger; > + > +typedef struct xencall_handle xencall_handle; > + > +/* > + */ > +#define XENCALL_OPENFLAG_NON_REENTRANT (1U<<0) > + > +/* > + * Return a handle onto the hypercall driver. Logs errors. > + */ > +xencall_handle *xencall_open(xentoollog_logger *logger, unsigned open_flags); > + > +/* > + * Close a handle previously allocated with xencall_open(). > + */ > +int xencall_close(xencall_handle *xcall); > + > +/* > + * Call hypercalls with varying numbers of arguments. > + */ > +int xencall0(xencall_handle *xcall, unsigned int op); > +int xencall1(xencall_handle *xcall, unsigned int op, > + uint64_t arg1); > +int xencall2(xencall_handle *xcall, unsigned int op, > + uint64_t arg1, uint64_t arg2); > +int xencall3(xencall_handle *xcall, unsigned int op, > + uint64_t arg1, uint64_t arg2, uint64_t arg3); > +int xencall4(xencall_handle *xcall, unsigned int op, > + uint64_t arg1, uint64_t arg2, uint64_t arg3, > + uint64_t arg4); > +int xencall5(xencall_handle *xcall, unsigned int op, > + uint64_t arg1, uint64_t arg2, uint64_t arg3, > + uint64_t arg4, uint64_t arg5); > + > +/* > + * Allocate and free memory which is suitable for use as a pointer > + * argument to a hypercall. > + */ > +void *xencall_alloc_buffer_pages(xencall_handle *xcall, int nr_pages); > +void xencall_free_buffer_pages(xencall_handle *xcall, void *p, int nr_pages); size_t nr_pages. (The osdep internals appear to use unsigned nr_pages, just to be different). ~Andrew