1033 struct buf *bp;
1034 struct tgdk_iob *iobp;
1035 size_t rlen;
1036
1037 iobp = kmem_zalloc(sizeof (*iobp), kmsflg);
1038 if (iobp == NULL)
1039 return (NULL);
1040 if ((bp = getrbuf(kmsflg)) == NULL) {
1041 kmem_free(iobp, sizeof (*iobp));
1042 return (NULL);
1043 }
1044
1045 iobp->b_psec = LBLK2SEC(blkno, dadkp->dad_blkshf);
1046 iobp->b_pbyteoff = (blkno & ((1<<dadkp->dad_blkshf) - 1)) << SCTRSHFT;
1047 iobp->b_pbytecnt = ((iobp->b_pbyteoff + xfer + dadkp->DAD_SECSIZ - 1)
1048 >> dadkp->dad_secshf) << dadkp->dad_secshf;
1049
1050 bp->b_un.b_addr = 0;
1051 /*
1052 * use i_ddi_mem_alloc() for now until we have an interface to allocate
1053 * memory for DMA which doesn't require a DMA handle. ddi_iopb_alloc()
1054 * is obsolete and we want more flexibility in controlling the DMA
1055 * address constraints..
1056 */
1057 if (i_ddi_mem_alloc((dadkp->dad_sd)->sd_dev, &dadk_alloc_attr,
1058 (size_t)iobp->b_pbytecnt, ((kmsflg == KM_SLEEP) ? 1 : 0), 0, NULL,
1059 &bp->b_un.b_addr, &rlen, NULL) != DDI_SUCCESS) {
1060 freerbuf(bp);
1061 kmem_free(iobp, sizeof (*iobp));
1062 return (NULL);
1063 }
1064 iobp->b_flag |= IOB_BPALLOC | IOB_BPBUFALLOC;
1065 iobp->b_bp = bp;
1066 iobp->b_lblk = blkno;
1067 iobp->b_xfer = xfer;
1068 iobp->b_lblk = blkno;
1069 iobp->b_xfer = xfer;
1070 return (iobp);
1071 }
1072
1073 /* ARGSUSED */
1074 int
1075 dadk_iob_free(opaque_t objp, struct tgdk_iob *iobp)
|
1033 struct buf *bp;
1034 struct tgdk_iob *iobp;
1035 size_t rlen;
1036
1037 iobp = kmem_zalloc(sizeof (*iobp), kmsflg);
1038 if (iobp == NULL)
1039 return (NULL);
1040 if ((bp = getrbuf(kmsflg)) == NULL) {
1041 kmem_free(iobp, sizeof (*iobp));
1042 return (NULL);
1043 }
1044
1045 iobp->b_psec = LBLK2SEC(blkno, dadkp->dad_blkshf);
1046 iobp->b_pbyteoff = (blkno & ((1<<dadkp->dad_blkshf) - 1)) << SCTRSHFT;
1047 iobp->b_pbytecnt = ((iobp->b_pbyteoff + xfer + dadkp->DAD_SECSIZ - 1)
1048 >> dadkp->dad_secshf) << dadkp->dad_secshf;
1049
1050 bp->b_un.b_addr = 0;
1051 /*
1052 * use i_ddi_mem_alloc() for now until we have an interface to allocate
1053 * memory for DMA which doesn't require a DMA handle.
1054 */
1055 if (i_ddi_mem_alloc((dadkp->dad_sd)->sd_dev, &dadk_alloc_attr,
1056 (size_t)iobp->b_pbytecnt, ((kmsflg == KM_SLEEP) ? 1 : 0), 0, NULL,
1057 &bp->b_un.b_addr, &rlen, NULL) != DDI_SUCCESS) {
1058 freerbuf(bp);
1059 kmem_free(iobp, sizeof (*iobp));
1060 return (NULL);
1061 }
1062 iobp->b_flag |= IOB_BPALLOC | IOB_BPBUFALLOC;
1063 iobp->b_bp = bp;
1064 iobp->b_lblk = blkno;
1065 iobp->b_xfer = xfer;
1066 iobp->b_lblk = blkno;
1067 iobp->b_xfer = xfer;
1068 return (iobp);
1069 }
1070
1071 /* ARGSUSED */
1072 int
1073 dadk_iob_free(opaque_t objp, struct tgdk_iob *iobp)
|