gasp_map_host_contig()
Map a guest-physical address range into the qvm process address space and obtain host-physical address information
Synopsis:
#include <qvm/gasp.h>errno_t gasp_map_host_contig(const vdev_t *vdev,
uint64_t *ppaddr,
size_t *plength,
gasp_map_flags_t prot,
gasp_map_handle_t *h)Arguments:
- vdev
- A pointer to a structure for a vdev that will make a DMA-like transaction.
- ppaddr
- On entry, a pointer to the guest-physical address to map; on exit, the corresponding host-physical address.
- plength
- On entry, the maximum number of bytes to be mapped in; on exit, the actual number of bytes that were mapped.
- prot
- A bitfield of GMF_* constants specifying the access protection bits for the mapping, including possibly GMF_MAP_ANY.
- h
- A pointer to a gasp_map_handle_t object that is initialized upon a successful return.
Description:
Use the gasp_map_host_contig() function to emulate a device accessing memory when you need to use contiguous host-physical addresses. This function attempts to map length bytes from guest-physical memory beginning at the address pointed to by guest_ppaddr into the address space of the current qvm process to provide access to virtual hardware in the VM. This function also provides information about the host-physical address range.
If successful, the function fills in the object pointed to by h with a handle for this new mapping. You can then use this handle to obtain the virtual address for the mapped address range by calling gasp_get_vaddr().
When you're done using the address range, call gasp_unmap_handle() to unmap it.
Returns:
EOK on success, an error code on failure.
Errors:
- EFAULT
- The mapping isn't allowed for one of the following reasons:
- the guest-physical address range indicated by guest_paddr and length isn't available for allocation based on the guest IOMMU configuration
- the access type requested by prot isn't allowed for the vdev based on the guest IOMMU configuration
- ENXIO
- One of the following is true:
- The guest-physical address is invalid
- The prot flag combination is invalid
- There's no contiguous guest-physical address range that can accommodate the requested mapping
In addition to the errors listed above, this function may return any error returned by mmap(). For more information, refer to the mmap() entry in the C Library Reference.
