static struct virtqueue *FindVirtualQueue(PADAPTER_EXTENSION adaptExt, ULONG index, ULONG vector) { struct virtqueue *vq = NULL; if (adaptExt->uncachedExtensionVa) { ULONG len; PHYSICAL_ADDRESS pa = ScsiPortGetPhysicalAddress(adaptExt, NULL, adaptExt->uncachedExtensionVa, &len); if (pa.QuadPart) vq = VirtIODevicePrepareQueue(&adaptExt->vdev, index, pa, adaptExt->uncachedExtensionVa, len, NULL); } if (vq && vector) { unsigned res; ScsiPortWritePortUshort((PUSHORT)(adaptExt->vdev.addr + VIRTIO_MSI_QUEUE_VECTOR),(USHORT)vector); res = ScsiPortReadPortUshort((PUSHORT)(adaptExt->vdev.addr + VIRTIO_MSI_QUEUE_VECTOR)); RhelDbgPrint(TRACE_LEVEL_FATAL, ("%s>> VIRTIO_MSI_QUEUE_VECTOR vector = %d, res = 0x%x\n", __FUNCTION__, vector, res)); if(res == VIRTIO_MSI_NO_VECTOR) { VirtIODeviceDeleteQueue(vq, NULL); vq = NULL; RhelDbgPrint(TRACE_LEVEL_FATAL, ("%s>> Cannot create vq vector\n", __FUNCTION__)); return NULL; } } return vq; }
static void WriteVirtIODeviceWord(ULONG_PTR ulRegister, u16 wValue) { if (ulRegister & ~PORT_MASK) { ScsiPortWriteRegisterUshort((PUSHORT)(ulRegister), (USHORT)(wValue)); } else { ScsiPortWritePortUshort((PUSHORT)(ulRegister), (USHORT)(wValue)); } }
VOID RhelShutDown( IN PVOID DeviceExtension ) { PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; VirtIODeviceReset(&adaptExt->vdev); ScsiPortWritePortUshort((PUSHORT)(adaptExt->vdev.addr + VIRTIO_PCI_GUEST_FEATURES), 0); if (adaptExt->vq) { adaptExt->vq->vq_ops->shutdown(adaptExt->vq); VirtIODeviceDeleteQueue(adaptExt->vq, NULL); adaptExt->vq = NULL; } }