FreeBSD/sys/dev/xen/pcifront/pcifront.c
/* Write to the xenbus info needed by backend */
Write to the xenbus info needed by backend
Write to the xenbus info needed by backend
static int
pcifront_publish_info(struct pcifront_device *pdev)
{
	int err = 0;
	struct xenbus_transaction *trans;
	err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
	if (err < 0) {
		WPRINTF("error granting access to ring page\n");
		goto out;
	}
	pdev->gnt_ref = err;
	err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
	if (err)
		goto out;
 do_publish:
	trans = xenbus_transaction_start();
	if (IS_ERR(trans)) {
		xenbus_dev_fatal(pdev->xdev, err,
						 "Error writing configuration for backend "
						 "(start transaction)");
		goto out;
	}
	err = xenbus_printf(trans, pdev->xdev->nodename,
						"pci-op-ref", "%u", pdev->gnt_ref);
	if (!err)
		err = xenbus_printf(trans, pdev->xdev->nodename,
							"event-channel", "%u", pdev->evtchn);
	if (!err)
		err = xenbus_printf(trans, pdev->xdev->nodename,
							"magic", XEN_PCI_MAGIC);
	if (!err)
		err = xenbus_switch_state(pdev->xdev, trans,
								  XenbusStateInitialised);
	if (err) {
		xenbus_transaction_end(trans, 1);
		xenbus_dev_fatal(pdev->xdev, err,
						 "Error writing configuration for backend");
		goto out;
	} else {
		err = xenbus_transaction_end(trans, 0);
		if (err == -EAGAIN)
			goto do_publish;
		else if (err) {
			xenbus_dev_fatal(pdev->xdev, err,
							 "Error completing transaction for backend");
			goto out;
		}
	}
 out:
	return err;
}
static int pcifront_publish_info ( struct pcifront_device * pdev ) { int err = 0 ; struct xenbus_transaction * trans ; err = xenbus_grant_ring ( pdev -> xdev , virt_to_mfn ( pdev -> sh_info ) ) ; if ( err < 0 ) { WPRINTF ( " \n " ) ; goto out ; } pdev -> gnt_ref = err ; err = xenbus_alloc_evtchn ( pdev -> xdev , & pdev -> evtchn ) ; if ( err ) goto out ; do_publish : trans = xenbus_transaction_start ( ) ; if ( IS_ERR ( trans ) ) { xenbus_dev_fatal ( pdev -> xdev , err , " " " " ) ; goto out ; } err = xenbus_printf ( trans , pdev -> xdev -> nodename , " " , " " , pdev -> gnt_ref ) ; if ( ! err ) err = xenbus_printf ( trans , pdev -> xdev -> nodename , " " , " " , pdev -> evtchn ) ; if ( ! err ) err = xenbus_printf ( trans , pdev -> xdev -> nodename , " " , XEN_PCI_MAGIC ) ; if ( ! err ) err = xenbus_switch_state ( pdev -> xdev , trans , XenbusStateInitialised ) ; if ( err ) { xenbus_transaction_end ( trans , 1 ) ; xenbus_dev_fatal ( pdev -> xdev , err , " " ) ; goto out ; } else { err = xenbus_transaction_end ( trans , 0 ) ; if ( err == - EAGAIN ) goto do_publish ; else if ( err ) { xenbus_dev_fatal ( pdev -> xdev , err , " " ) ; goto out ; } } out : return err ; }
Write to the xenbus info needed by backend
Write to the xenbus info needed by backend