Files
xen/tools/libs/call/private.h
T
Ian Campbell 3e9b0d5408 tools: Refactor hypercall calling wrappers into libxencall.
libxencall will provide a stable API and ABI for calling hypercalls
(although those hypercalls themselves may not have a stable API). As
well as the hypercall buffer infrastructure needed in order to safely
provide pointer arguments to hypercalls.

libxenctrl encapsulates a instance of this interface, so users of that
library are not currently subjected to any actual changes. However all
hypercalls made internally by libxc now use the correct interface. It
is expected that most users of this library will be other libraries
providing a higher level interface, rather than applications directly.

Only the basic functionality to allocate hypercall safe memory is
moved, the type safe stuff and bounce buffers remain in libxc.

Note that the functionality to map foreign pages using privcmd is not
yet moved, meaning that an xc_interface will now contain two open
privcmd file descriptors. Foreign memory mapping is logically separate
functionality and will be moved into its own library.

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ ijc -- updated MINIOS_UPSTREAM_REVISION and QEMU_TRADITIONAL_REVISION ]
2016-01-22 12:23:30 +00:00

69 lines
1.6 KiB
C

#ifndef XENCALL_PRIVATE_H
#define XENCALL_PRIVATE_H
#include <xentoollog.h>
#include <xencall.h>
#include <xen/xen.h>
#include <xen/sys/privcmd.h>
#ifndef PAGE_SHIFT /* Mini-os, Yukk */
#define PAGE_SHIFT 12
#endif
#ifndef __MINIOS__ /* Yukk */
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#endif
struct xencall_handle {
xentoollog_logger *logger, *logger_tofree;
unsigned flags;
int fd;
/*
* A simple cache of unused, single page, hypercall buffers
*
* Protected by a global lock.
*/
#define BUFFER_CACHE_SIZE 4
int buffer_cache_nr;
void *buffer_cache[BUFFER_CACHE_SIZE];
/*
* Hypercall buffer statistics. All protected by the global
* buffer_cache lock.
*/
int buffer_total_allocations;
int buffer_total_releases;
int buffer_current_allocations;
int buffer_maximum_allocations;
int buffer_cache_hits;
int buffer_cache_misses;
int buffer_cache_toobig;
};
int osdep_xencall_open(xencall_handle *xcall);
int osdep_xencall_close(xencall_handle *xcall);
int osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall);
void *osdep_alloc_pages(xencall_handle *xcall, size_t nr_pages);
void osdep_free_pages(xencall_handle *xcall, void *p, size_t nr_pages);
void buffer_release_cache(xencall_handle *xcall);
#define PERROR(_f...) xtl_log(xcall->logger, XTL_ERROR, errno, "xencall", _f)
#endif
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/