Lines Matching refs:in

4  * you may not use this file except in compliance with the License.
9 * Unless required by applicable law or agreed to in writing, software
112 static void PopulateEventQ(const struct Virtin *in)
114 const struct Virtq *q = &in->dev.vq[0];
118 q->desc[i].pAddr = u32_to_u64(VMM_TO_DMA_ADDR((VADDR_T)&in->ev[i]));
125 in->dev.vq[0].avail->index += in->dev.vq[0].qsz;
126 OSAL_WRITEL(0, in->dev.base + VIRTMMIO_REG_QUEUENOTIFY);
155 static void VirtinHandleEv(struct Virtin *in)
157 struct Virtq *q = &in->dev.vq[0];
166 if (VirtinGrabbed(&in->ev[idx])) {
167 struct VirtinEvent *ev = &in->ev[idx];
179 OSAL_WRITEL(0, in->dev.base + VIRTMMIO_REG_QUEUENOTIFY);
181 OSAL_WRITEL(VIRTMMIO_IRQ_NOTIFY_USED, in->dev.base + VIRTMMIO_REG_INTERRUPTACK);
186 struct Virtin *in = (struct Virtin *)param;
188 if (!(OSAL_READL(in->dev.base + VIRTMMIO_REG_INTERRUPTSTATUS) & VIRTMMIO_IRQ_NOTIFY_USED)) {
191 osSemaphoreRelease(in->sem);
248 static bool VirtinFillHidInfo(const struct Virtin *in, HidInfo *devInfo)
250 struct VirtinConfig *conf = (struct VirtinConfig *)(in->dev.base + VIRTMMIO_REG_CONFIG);
257 before = OSAL_READL(in->dev.base + VIRTMMIO_REG_CONFIGGENERATION);
265 after = OSAL_READL(in->dev.base + VIRTMMIO_REG_CONFIGGENERATION);
271 static int32_t HdfVirtinInitHid(struct Virtin *in)
281 if (!VirtinFillHidInfo(in, devInfo)) {
299 static void VirtinDeInit(struct Virtin *in)
301 if (in->sem) {
302 osSemaphoreDelete(in->sem);
303 in->sem = NULL;
306 if (in->tid) {
307 osThreadTerminate(in->tid);
308 in->tid = NULL;
311 if (in->dev.irq) {
312 LOS_HwiDelete(in->dev.irq, NULL);
315 LOS_MemFree(OS_SYS_MEM_ADDR, in);
320 struct Virtin *in = NULL;
326 in = LOS_MemAlloc(OS_SYS_MEM_ADDR, len * sizeof(void *));
327 if (in != NULL) {
328 (void)memset_s(in, len * sizeof(void *), 0, len * sizeof(void *));
334 if (!VirtmmioDiscover(VIRTMMIO_DEVICE_ID_INPUT, &in->dev)) {
338 VirtmmioInitBegin(&in->dev);
340 if (!VirtmmioNegotiate(&in->dev, Feature0, Feature1, in)) {
344 base = ALIGN((VADDR_T)in + sizeof(struct Virtin), VIRTQ_ALIGN_DESC);
347 if (VirtmmioConfigQueue(&in->dev, base, qsz, VIRTQ_NUM) == 0) {
351 if (!VirtmmioRegisterIRQ(&in->dev, (HWI_PROC_FUNC)VirtinIRQhandle, in, VIRTMMIO_INPUT_NAME)) {
356 return in;
359 VirtmmioInitFailed(&in->dev);
361 VirtinDeInit(in);
367 struct Virtin *in = (struct Virtin *)arg;
370 int32_t r = osSemaphoreAcquire(in->sem, osWaitForever);
374 VirtinHandleEv(in);
381 struct Virtin *in = NULL;
389 if ((in = VirtinInitDev()) == NULL) {
392 device->priv = in;
394 if ((ret = HdfVirtinInitHid(in)) != HDF_SUCCESS) {
395 VirtinDeInit(in);
399 in->sem = osSemaphoreNew(1, 0, NULL);
400 if (in->sem == NULL) {
402 VirtinDeInit(in);
410 in->tid = osThreadNew((osThreadFunc_t)InputWorkTask, in, &attr);
411 if (in->tid == NULL) {
413 VirtinDeInit(in);
417 PopulateEventQ(in);
418 VritmmioInitEnd(&in->dev); /* now virt queue can be used */
428 struct Virtin *in = deviceObject->priv;
429 if (in == NULL) {
436 VirtinDeInit(in);