1 #ifndef XENCALL_PRIVATE_H 2 #define XENCALL_PRIVATE_H 3 4 #include <xentoollog.h> 5 #include <xentoolcore_internal.h> 6 7 #include <xencall.h> 8 9 #include <xen/xen.h> 10 #include <xen/sys/privcmd.h> 11 12 #ifndef PAGE_SHIFT /* Mini-os, Yukk */ 13 #define PAGE_SHIFT 12 14 #endif 15 #ifndef __MINIOS__ /* Yukk */ 16 #define PAGE_SIZE (1UL << PAGE_SHIFT) 17 #define PAGE_MASK (~(PAGE_SIZE-1)) 18 #endif 19 20 struct xencall_handle { 21 xentoollog_logger *logger, *logger_tofree; 22 unsigned flags; 23 int fd; 24 Xentoolcore__Active_Handle tc_ah; 25 26 /* 27 * A simple cache of unused, single page, hypercall buffers 28 * 29 * Protected by a global lock. 30 */ 31 #define BUFFER_CACHE_SIZE 4 32 int buffer_cache_nr; 33 void *buffer_cache[BUFFER_CACHE_SIZE]; 34 35 /* 36 * Hypercall buffer statistics. All protected by the global 37 * buffer_cache lock. 38 */ 39 int buffer_total_allocations; 40 int buffer_total_releases; 41 int buffer_current_allocations; 42 int buffer_maximum_allocations; 43 int buffer_cache_hits; 44 int buffer_cache_misses; 45 int buffer_cache_toobig; 46 }; 47 48 int osdep_xencall_open(xencall_handle *xcall); 49 int osdep_xencall_close(xencall_handle *xcall); 50 51 int osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall); 52 53 void *osdep_alloc_pages(xencall_handle *xcall, size_t nr_pages); 54 void osdep_free_pages(xencall_handle *xcall, void *p, size_t nr_pages); 55 56 void buffer_release_cache(xencall_handle *xcall); 57 58 #define PERROR(_f...) xtl_log(xcall->logger, XTL_ERROR, errno, "xencall", _f) 59 60 #endif 61 62 /* 63 * Local variables: 64 * mode: C 65 * c-file-style: "BSD" 66 * c-basic-offset: 4 67 * tab-width: 4 68 * indent-tabs-mode: nil 69 * End: 70 */ 71