1 /* 2 * Compat shims for use of 3rd party consumers of libxenctrl 3 * functionality which has been split into separate libraries. 4 * 5 * New code should use the separate libraries. 6 * 7 * Each interface must be opted-into separately by defining: 8 * 9 * XC_WANT_COMPAT_EVTCHN_API 10 * - Functions relating to /dev/xen/evtchn 11 */ 12 #ifndef XENCTRL_COMPAT_H 13 #define XENCTRL_COMPAT_H 14 15 #ifdef XC_WANT_COMPAT_MAP_FOREIGN_API 16 /** 17 * Memory maps a range within one domain to a local address range. Mappings 18 * should be unmapped with munmap and should follow the same rules as mmap 19 * regarding page alignment. Returns NULL on failure. 20 * 21 * @parm xch a handle on an open hypervisor interface 22 * @parm dom the domain to map memory from 23 * @parm size the amount of memory to map (in multiples of page size) 24 * @parm prot same flag as in mmap(). 25 * @parm mfn the frame address to map. 26 */ 27 void *xc_map_foreign_range(xc_interface *xch, uint32_t dom, 28 int size, int prot, 29 unsigned long mfn ); 30 31 void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot, 32 const xen_pfn_t *arr, int num ); 33 34 /* Nothing within the library itself other than the compat wrapper 35 * itself should be using this, everything inside has access to 36 * xenforeignmemory_map(). 37 */ 38 #if !defined(XC_INTERNAL_COMPAT_MAP_FOREIGN_API) || \ 39 defined(XC_BUILDING_COMPAT_MAP_FOREIGN_API) 40 /** 41 * Like xc_map_foreign_pages(), except it can succeed partially. 42 * When a page cannot be mapped, its respective field in @err is 43 * set to the corresponding errno value. 44 */ 45 void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot, 46 const xen_pfn_t *arr, int *err, unsigned int num); 47 #endif 48 49 #endif 50 51 #ifdef XC_WANT_COMPAT_EVTCHN_API 52 53 typedef struct xenevtchn_handle xc_evtchn; 54 typedef xc_evtchn_port_or_error_t evtchn_port_or_error_t; 55 56 xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, 57 unsigned open_flags); 58 int xc_evtchn_close(xc_evtchn *xce); 59 int xc_evtchn_fd(xc_evtchn *xce); 60 int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port); 61 xc_evtchn_port_or_error_t 62 xc_evtchn_bind_unbound_port(xc_evtchn *xce, uint32_t domid); 63 xc_evtchn_port_or_error_t 64 xc_evtchn_bind_interdomain(xc_evtchn *xce, uint32_t domid, 65 evtchn_port_t remote_port); 66 xc_evtchn_port_or_error_t 67 xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq); 68 int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port); 69 xc_evtchn_port_or_error_t 70 xc_evtchn_pending(xc_evtchn *xce); 71 int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port); 72 73 #endif /* XC_WANT_COMPAT_EVTCHN_API */ 74 75 #ifdef XC_WANT_COMPAT_GNTTAB_API 76 77 typedef struct xengntdev_handle xc_gnttab; 78 79 xc_gnttab *xc_gnttab_open(xentoollog_logger *logger, 80 unsigned open_flags); 81 int xc_gnttab_close(xc_gnttab *xcg); 82 void *xc_gnttab_map_grant_ref(xc_gnttab *xcg, 83 uint32_t domid, 84 uint32_t ref, 85 int prot); 86 void *xc_gnttab_map_grant_refs(xc_gnttab *xcg, 87 uint32_t count, 88 uint32_t *domids, 89 uint32_t *refs, 90 int prot); 91 void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg, 92 uint32_t count, 93 uint32_t domid, 94 uint32_t *refs, 95 int prot); 96 void *xc_gnttab_map_grant_ref_notify(xc_gnttab *xcg, 97 uint32_t domid, 98 uint32_t ref, 99 int prot, 100 uint32_t notify_offset, 101 evtchn_port_t notify_port); 102 int xc_gnttab_munmap(xc_gnttab *xcg, 103 void *start_address, 104 uint32_t count); 105 int xc_gnttab_set_max_grants(xc_gnttab *xcg, 106 uint32_t count); 107 108 typedef struct xengntdev_handle xc_gntshr; 109 110 xc_gntshr *xc_gntshr_open(xentoollog_logger *logger, 111 unsigned open_flags); 112 int xc_gntshr_close(xc_gntshr *xcg); 113 void *xc_gntshr_share_pages(xc_gntshr *xcg, uint32_t domid, 114 int count, uint32_t *refs, int writable); 115 void *xc_gntshr_share_page_notify(xc_gntshr *xcg, uint32_t domid, 116 uint32_t *ref, int writable, 117 uint32_t notify_offset, 118 evtchn_port_t notify_port); 119 int xc_gntshr_munmap(xc_gntshr *xcg, void *start_address, uint32_t count); 120 121 #endif /* XC_WANT_COMPAT_GNTTAB_API */ 122 123 #ifdef XC_WANT_COMPAT_DEVICEMODEL_API 124 125 int xc_hvm_create_ioreq_server( 126 xc_interface *xch, uint32_t domid, int handle_bufioreq, 127 ioservid_t *id); 128 int xc_hvm_get_ioreq_server_info( 129 xc_interface *xch, uint32_t domid, ioservid_t id, xen_pfn_t *ioreq_pfn, 130 xen_pfn_t *bufioreq_pfn, evtchn_port_t *bufioreq_port); 131 int xc_hvm_map_io_range_to_ioreq_server( 132 xc_interface *xch, uint32_t domid, ioservid_t id, int is_mmio, 133 uint64_t start, uint64_t end); 134 int xc_hvm_unmap_io_range_from_ioreq_server( 135 xc_interface *xch, uint32_t domid, ioservid_t id, int is_mmio, 136 uint64_t start, uint64_t end); 137 int xc_hvm_map_pcidev_to_ioreq_server( 138 xc_interface *xch, uint32_t domid, ioservid_t id, uint16_t segment, 139 uint8_t bus, uint8_t device, uint8_t function); 140 int xc_hvm_unmap_pcidev_from_ioreq_server( 141 xc_interface *xch, uint32_t domid, ioservid_t id, uint16_t segment, 142 uint8_t bus, uint8_t device, uint8_t function); 143 int xc_hvm_destroy_ioreq_server( 144 xc_interface *xch, uint32_t domid, ioservid_t id); 145 int xc_hvm_set_ioreq_server_state( 146 xc_interface *xch, uint32_t domid, ioservid_t id, int enabled); 147 int xc_hvm_set_pci_intx_level( 148 xc_interface *xch, uint32_t domid, uint16_t segment, uint8_t bus, 149 uint8_t device, uint8_t intx, unsigned int level); 150 int xc_hvm_set_isa_irq_level( 151 xc_interface *xch, uint32_t domid, uint8_t irq, unsigned int level); 152 int xc_hvm_set_pci_link_route( 153 xc_interface *xch, uint32_t domid, uint8_t link, uint8_t irq); 154 int xc_hvm_inject_msi( 155 xc_interface *xch, uint32_t domid, uint64_t msi_addr, uint32_t msi_data); 156 int xc_hvm_track_dirty_vram( 157 xc_interface *xch, uint32_t domid, uint64_t first_pfn, uint32_t nr, 158 unsigned long *dirty_bitmap); 159 int xc_hvm_modified_memory( 160 xc_interface *xch, uint32_t domid, uint64_t first_pfn, uint32_t nr); 161 int xc_hvm_set_mem_type( 162 xc_interface *xch, uint32_t domid, hvmmem_type_t type, 163 uint64_t first_pfn, uint32_t nr); 164 int xc_hvm_inject_trap( 165 xc_interface *xch, uint32_t domid, int vcpu, uint8_t vector, 166 uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2); 167 int xc_domain_pin_memory_cacheattr( 168 xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end, 169 uint32_t type); 170 171 #endif /* XC_WANT_COMPAT_DEVICEMODEL_API */ 172 173 #endif 174 175 /* 176 * Local variables: 177 * mode: C 178 * c-file-style: "BSD" 179 * c-basic-offset: 4 180 * tab-width: 4 181 * indent-tabs-mode: nil 182 * End: 183 */ 184