FreeBSD/sys/dev/xen/blkback/blkback.c
/**
 * Size KVA and pseudo-physical address allocations based on negotiated
 * values for the size and number of I/O requests, and the size of our
 * communication ring.
 *
 * \param xbb  Per-instance xbb configuration structure.
 *
 * These address spaces are used to dynamically map pages in the
 * front-end's domain into our own.
 */
Size KVA and pseudo-physical address allocations based on negotiated
values for the size and number of I/O requests, and the size of our
communication ring.

\param xbb  Per-instance xbb configuration structure.

These address spaces are used to dynamically map pages in the
front-end's domain into our own.
Size KVA and pseudo - physical address allocations based on negotiated values for the size and number of I / O requests and the size of our communication ring . \ param xbb Per - instance xbb configuration structure . These address spaces are used to dynamically map pages in the front - end ' s domain into our own .
static int
xbb_alloc_communication_mem(struct xbb_softc *xbb)
{
	xbb->reqlist_kva_pages = xbb->max_requests * xbb->max_request_segments;
	xbb->reqlist_kva_size = xbb->reqlist_kva_pages * PAGE_SIZE;
	xbb->kva_size = xbb->reqlist_kva_size +
			(xbb->ring_config.ring_pages * PAGE_SIZE);
	xbb->kva_free = bit_alloc(xbb->reqlist_kva_pages, M_XENBLOCKBACK, M_NOWAIT);
	if (xbb->kva_free == NULL)
		return (ENOMEM);
	DPRINTF("%s: kva_size = %d, reqlist_kva_size = %d\n",
		device_get_nameunit(xbb->dev), xbb->kva_size,
		xbb->reqlist_kva_size);
	xbb->pseudo_phys_res_id = 0;
	xbb->pseudo_phys_res = xenmem_alloc(xbb->dev, &xbb->pseudo_phys_res_id,
	    xbb->kva_size);
	if (xbb->pseudo_phys_res == NULL) {
		xbb->kva = 0;
		return (ENOMEM);
	}
	xbb->kva = (vm_offset_t)rman_get_virtual(xbb->pseudo_phys_res);
	xbb->gnt_base_addr = rman_get_start(xbb->pseudo_phys_res);
	DPRINTF("%s: kva: %#jx, gnt_base_addr: %#jx\n",
		device_get_nameunit(xbb->dev), (uintmax_t)xbb->kva,
		(uintmax_t)xbb->gnt_base_addr); 
	return (0);
}
static int xbb_alloc_communication_mem ( struct xbb_softc * xbb ) { xbb -> reqlist_kva_pages = xbb -> max_requests * xbb -> max_request_segments ; xbb -> reqlist_kva_size = xbb -> reqlist_kva_pages * PAGE_SIZE ; xbb -> kva_size = xbb -> reqlist_kva_size + ( xbb -> ring_config . ring_pages * PAGE_SIZE ) ; xbb -> kva_free = bit_alloc ( xbb -> reqlist_kva_pages , M_XENBLOCKBACK , M_NOWAIT ) ; if ( xbb -> kva_free == NULL ) return ( ENOMEM ) ; DPRINTF ( " \n " , device_get_nameunit ( xbb -> dev ) , xbb -> kva_size , xbb -> reqlist_kva_size ) ; xbb -> pseudo_phys_res_id = 0 ; xbb -> pseudo_phys_res = xenmem_alloc ( xbb -> dev , & xbb -> pseudo_phys_res_id , xbb -> kva_size ) ; if ( xbb -> pseudo_phys_res == NULL ) { xbb -> kva = 0 ; return ( ENOMEM ) ; } xbb -> kva = ( vm_offset_t ) rman_get_virtual ( xbb -> pseudo_phys_res ) ; xbb -> gnt_base_addr = rman_get_start ( xbb -> pseudo_phys_res ) ; DPRINTF ( " \n " , device_get_nameunit ( xbb -> dev ) , ( uintmax_t ) xbb -> kva , ( uintmax_t ) xbb -> gnt_base_addr ) ; return ( 0 ) ; }
Size KVA and pseudo-physical address allocations based on negotiated
 values for the size and number of I/O requests, and the size of our
 communication ring.
Size KVA and pseudo - physical address allocations based on negotiated values for the size and number of I / O requests and the size of our communication ring .
/*
	 * Reserve a range of pseudo physical memory that we can map
	 * into kva.  These pages will only be backed by machine
	 * pages ("real memory") during the lifetime of front-end requests
	 * via grant table operations.
	 */