Lines Matching refs:blk
87 struct Virtblk *blk = dev; in Feature0() local
88 struct VirtblkConfig *conf = (void *)(blk->dev.base + VIRTMMIO_REG_CONFIG); in Feature0()
96 blk->blkSize = VIRTBLK_DEF_BLK_SIZE; in Feature0()
101 blk->blkSize = bs; in Feature0()
106 blk->capacity = conf->capacity; in Feature0()
123 static void PopulateRequestQ(const struct Virtblk *blk) in PopulateRequestQ() argument
125 const struct Virtq *q = &blk->dev.vq[0]; in PopulateRequestQ()
128 q->desc[i].pAddr = VMM_TO_DMA_ADDR((VADDR_T)&blk->req); in PopulateRequestQ()
137 q->desc[i].pAddr = VMM_TO_DMA_ADDR((VADDR_T)&blk->resp); in PopulateRequestQ()
142 static uint8_t VirtblkIO(struct Virtblk *blk, uint32_t cmd, uint64_t startSector, in VirtblkIO() argument
146 struct Virtq *q = &blk->dev.vq[0]; in VirtblkIO()
149 blk->req.type = cmd; in VirtblkIO()
150 blk->req.startSector = startSector; in VirtblkIO()
161 OSAL_WRITEL(0, blk->dev.base + VIRTMMIO_REG_QUEUENOTIFY); in VirtblkIO()
164 if ((ret = DmaEventWait(&blk->event, 1, HDF_WAIT_FOREVER)) != 1) { in VirtblkIO()
169 return blk->resp; in VirtblkIO()
175 struct Virtblk *blk = dev; in VirtblkIRQhandle() local
176 struct Virtq *q = &blk->dev.vq[0]; in VirtblkIRQhandle()
178 if (!(OSAL_READL(blk->dev.base + VIRTMMIO_REG_INTERRUPTSTATUS) & VIRTMMIO_IRQ_NOTIFY_USED)) { in VirtblkIRQhandle()
182 (void)DmaEventSignal(&blk->event, 1); in VirtblkIRQhandle()
185 OSAL_WRITEL(VIRTMMIO_IRQ_NOTIFY_USED, blk->dev.base + VIRTMMIO_REG_INTERRUPTACK); in VirtblkIRQhandle()
189 static void VirtblkDeInit(struct Virtblk *blk) in VirtblkDeInit() argument
191 if (blk->dev.irq & ~_IRQ_MASK) { in VirtblkDeInit()
192 OsalUnregisterIrq(blk->dev.irq & _IRQ_MASK, blk); in VirtblkDeInit()
194 LOS_DmaMemFree(blk); in VirtblkDeInit()
199 struct Virtblk *blk = NULL; in VirtblkInitDev() local
205 if ((blk = LOS_DmaMemAlloc(NULL, len, sizeof(void *), DMA_CACHE)) == NULL) { in VirtblkInitDev()
209 memset_s(blk, len, 0, len); in VirtblkInitDev()
211 if (!VirtmmioDiscover(VIRTMMIO_DEVICE_ID_BLK, &blk->dev)) { in VirtblkInitDev()
215 VirtmmioInitBegin(&blk->dev); in VirtblkInitDev()
216 if (!VirtmmioNegotiate(&blk->dev, Feature0, Feature1, blk)) { in VirtblkInitDev()
219 base = ALIGN((VADDR_T)blk + sizeof(struct Virtblk), VIRTQ_ALIGN_DESC); in VirtblkInitDev()
221 if (VirtmmioConfigQueue(&blk->dev, base, &qsz, 1) == 0) { in VirtblkInitDev()
225 if ((ret = DmaEventInit(&blk->event)) != HDF_SUCCESS) { in VirtblkInitDev()
229 ret = OsalRegisterIrq(blk->dev.irq, OSAL_IRQF_TRIGGER_NONE, (OsalIRQHandle)VirtblkIRQhandle, in VirtblkInitDev()
230 VIRTMMIO_BLK_NAME, blk); in VirtblkInitDev()
235 blk->dev.irq |= ~_IRQ_MASK; in VirtblkInitDev()
237 PopulateRequestQ(blk); in VirtblkInitDev()
238 VritmmioInitEnd(&blk->dev); /* now virt queue can be used */ in VirtblkInitDev()
239 return blk; in VirtblkInitDev()
242 VirtmmioInitFailed(&blk->dev); in VirtblkInitDev()
244 VirtblkDeInit(blk); in VirtblkInitDev()
297 static void VirtMmcFillRespCid(struct MmcCmd *cmd, const struct Virtblk *blk) in VirtMmcFillRespCid() argument
305 *(uint32_t *)&b[MMC_CID_PSN_SBYTE] = (uint32_t)blk; /* unique sn */ in VirtMmcFillRespCid()
353 static void VirtMmcFillRespCsd(struct MmcCmd *cmd, const struct Virtblk *blk) in VirtMmcFillRespCsd() argument
363 if (blk->capacity > CAPACITY_2G) { in VirtMmcFillRespCsd()
364 uint32_t e = U32_BITS - __builtin_clz(blk->blkSize) - 1; in VirtMmcFillRespCsd()
371 uint32_t size = blk->capacity*MMC_SEC_SIZE / (1<<READ_BL_LEN) / (1<<(C_SIZE_MULT+2)) - 1; in VirtMmcFillRespCsd()
387 static void VirtMmcFillDataExtCsd(const struct MmcCmd *cmd, const struct Virtblk *blk) in VirtMmcFillDataExtCsd() argument
392 b[EMMC_EXT_CSD_ACC_SIZE] = blk->blkSize / MMC_SEC_SIZE; in VirtMmcFillDataExtCsd()
393 b[EMMC_EXT_CSD_REL_WR_SEC_C] = blk->blkSize / MMC_SEC_SIZE; in VirtMmcFillDataExtCsd()
394 *(uint32_t*)&b[EMMC_EXT_CSD_SEC_CNT] = blk->capacity; in VirtMmcFillDataExtCsd()
413 struct Virtblk *blk = cntlr->priv; in VirtMmcIO() local
427 ret = VirtblkIO(blk, io, startSector, cmd->data->dataBuffer, cmd->data->blockNum); in VirtMmcIO()
443 struct Virtblk *blk = cntlr->priv; in VirtMmcDoRequest() local
450 if (blk->capacity > CAPACITY_2G) { in VirtMmcDoRequest()
458 VirtMmcFillRespCid(cmd, blk); in VirtMmcDoRequest()
461 VirtMmcFillDataExtCsd(cmd, blk); in VirtMmcDoRequest()
470 VirtMmcFillRespCsd(cmd, blk); in VirtMmcDoRequest()
510 struct Virtblk *blk = cntlr->priv; in HdfVirtblkRelease() local
512 if (blk) { in HdfVirtblkRelease()
513 VirtblkDeInit(blk); in HdfVirtblkRelease()
527 struct Virtblk *blk = NULL; in HdfVirtblkBind() local
541 if ((blk = VirtblkInitDev()) == NULL) { in HdfVirtblkBind()
548 cntlr->priv = blk; in HdfVirtblkBind()