FreeBSD/sys/x86/xen/hvm.c
/*
 * Tell the hypervisor how to contact us for event channel callbacks.
 */
Tell the hypervisor how to contact us for event channel callbacks.
Tell the hypervisor how to contact us for event channel callbacks .
void
xen_hvm_set_callback(device_t dev)
{
	struct xen_hvm_param xhp;
	int irq;
	if (xen_vector_callback_enabled)
		return;
	xhp.domid = DOMID_SELF;
	xhp.index = HVM_PARAM_CALLBACK_IRQ;
	if (xen_feature(XENFEAT_hvm_callback_vector) != 0) {
		int error;
		xhp.value = HVM_CALLBACK_VECTOR(IDT_EVTCHN);
		error = HYPERVISOR_hvm_op(HVMOP_set_param, &xhp);
		if (error == 0) {
			xen_vector_callback_enabled = 1;
			return;
		}
		printf("Xen HVM callback vector registration failed (%d). "
		    "Falling back to emulated device interrupt\n", error);
	}
	xen_vector_callback_enabled = 0;
	if (dev == NULL) {
		return;
	}
	irq = pci_get_irq(dev);
	if (irq < 16) {
		xhp.value = HVM_CALLBACK_GSI(irq);
	} else {
		u_int slot;
		u_int pin;
		slot = pci_get_slot(dev);
		pin = pci_get_intpin(dev) - 1;
		xhp.value = HVM_CALLBACK_PCI_INTX(slot, pin);
	}
	if (HYPERVISOR_hvm_op(HVMOP_set_param, &xhp) != 0)
		panic("Can't set evtchn callback");
}
void xen_hvm_set_callback ( device_t dev ) { struct xen_hvm_param xhp ; int irq ; if ( xen_vector_callback_enabled ) return ; xhp . domid = DOMID_SELF ; xhp . index = HVM_PARAM_CALLBACK_IRQ ; if ( xen_feature ( XENFEAT_hvm_callback_vector ) != 0 ) { int error ; xhp . value = HVM_CALLBACK_VECTOR ( IDT_EVTCHN ) ; error = HYPERVISOR_hvm_op ( HVMOP_set_param , & xhp ) ; if ( error == 0 ) { xen_vector_callback_enabled = 1 ; return ; } printf ( " " " \n " , error ) ; } xen_vector_callback_enabled = 0 ; if ( dev == NULL ) { return ; } irq = pci_get_irq ( dev ) ; if ( irq < 16 ) { xhp . value = HVM_CALLBACK_GSI ( irq ) ; } else { u_int slot ; u_int pin ; slot = pci_get_slot ( dev ) ; pin = pci_get_intpin ( dev ) - 1 ; xhp . value = HVM_CALLBACK_PCI_INTX ( slot , pin ) ; } if ( HYPERVISOR_hvm_op ( HVMOP_set_param , & xhp ) != 0 ) panic ( " " ) ; }
Tell the hypervisor how to contact us for event channel callbacks.
Tell the hypervisor how to contact us for event channel callbacks .
/*
		 * Called from early boot or resume.
		 * xenpci will invoke us again later.
		 */