Home | History | Annotate | Download | only in ic

Lines Matching defs:scb

232 static __inline void	*ahd_sg_setup(struct ahd_softc *, struct scb *,
234 static __inline void ahd_setup_scb_common(struct ahd_softc *, struct scb *);
235 static __inline void ahd_setup_data_scb(struct ahd_softc *, struct scb *);
236 static __inline void ahd_setup_noxfer_scb(struct ahd_softc *, struct scb *);
239 ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
242 scb->sg_count++;
263 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
266 scb->crc_retry_count = 0;
267 if ((scb->flags & SCB_PACKETIZED) != 0) {
269 scb->hscb->task_attribute = scb->hscb->control & SCB_TAG_TYPE;
271 if (ahd_get_transfer_length(scb) & 0x01)
272 scb->hscb->task_attribute = SCB_XFERLEN_ODD;
274 scb->hscb->task_attribute = 0;
277 if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR
278 || (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0)
279 scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr =
280 ahd_htole32(scb->sense_busaddr);
284 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
292 sg = (struct ahd_dma64_seg *)scb->sg_list;
293 scb->hscb->dataptr = sg->addr;
294 scb->hscb->datacnt = sg->len;
299 sg = (struct ahd_dma_seg *)scb->sg_list;
300 dataptr_words = (uint32_t*)&scb->hscb->dataptr;
307 scb->hscb->dataptr |= ahd_htole64(high_addr << 8);
309 scb->hscb->datacnt = sg->len;
317 scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
321 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
323 scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
324 scb->hscb->dataptr = 0;
325 scb->hscb->datacnt = 0;
331 ahd_sg_bus_to_virt(struct ahd_softc *, struct scb *,
334 ahd_sg_virt_to_bus(struct ahd_softc *, struct scb *,
336 static __inline void ahd_sync_scb(struct ahd_softc *, struct scb *, int);
337 static __inline void ahd_sync_sglist(struct ahd_softc *, struct scb *, int);
338 static __inline void ahd_sync_sense(struct ahd_softc *, struct scb *, int);
351 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
356 sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd));
357 return ((uint8_t *)scb->sg_list + sg_offset);
361 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
366 sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
369 return (scb->sg_list_busaddr + sg_offset);
373 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
375 ahd_dmamap_sync(ahd, ahd->parent_dmat, scb->hscb_map->dmamap,
376 /*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr,
377 /*len*/sizeof(*scb->hscb), op);
381 ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
383 if (scb->sg_count == 0)
386 ahd_dmamap_sync(ahd, ahd->parent_dmat, scb->sg_map->dmamap,
387 /*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd),
388 /*len*/ahd_sg_size(ahd) * scb->sg_count, op);
392 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
395 scb->sense_map->dmamap,
396 /*offset*/scb->sense_busaddr - scb->sense_map->physaddr,
408 static __inline void ahd_complete_scb(struct ahd_softc *, struct scb *);
409 static __inline void ahd_update_residual(struct ahd_softc *, struct scb *);
441 struct scb *);
442 static __inline void ahd_queue_scb(struct ahd_softc *, struct scb *);
444 ahd_get_sense_buf(struct ahd_softc *, struct scb *);
446 ahd_get_sense_bufaddr(struct ahd_softc *, struct scb *);
447 static __inline void ahd_post_scb(struct ahd_softc *, struct scb *);
451 ahd_post_scb(struct ahd_softc *ahd, struct scb *scb)
455 sgptr = ahd_le32toh(scb->hscb->sgptr);
457 ahd_handle_scb_status(ahd, scb);
459 ahd_done(ahd, scb);
463 ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
467 sgptr = ahd_le32toh(scb->hscb->sgptr);
469 ahd_handle_scb_status(ahd, scb);
471 ahd_done(ahd, scb);
476 * for this SCB/transaction.
479 ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
483 sgptr = ahd_le32toh(scb->hscb->sgptr);
485 ahd_calc_residual(ahd, scb);
666 * After a host read of SCB memory, the chip
705 static __inline struct scb *
708 struct scb* scb;
712 scb = ahd->scb_data.scbindex[tag];
713 if (scb != NULL)
714 ahd_sync_scb(ahd, scb,
716 return (scb);
720 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
731 * When we are called to queue "an arbitrary scb",
734 * finally assign the SCB to the tag indexed location
736 * locate the correct SCB by SCB_TAG.
741 memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
743 q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
746 ahd->next_queued_hscb = scb->hscb;
747 ahd->next_queued_hscb_map = scb->hscb_map;
748 scb->hscb = q_hscb;
749 scb->hscb_map = q_hscb_map;
751 KASSERT((vaddr_t)scb->hscb >= (vaddr_t)scb->hscb_map->vaddr &&
752 (vaddr_t)scb->hscb < (vaddr_t)scb->hscb_map->vaddr + PAGE_SIZE);
754 /* Now define the mapping from tag to SCB in the scbindex */
755 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
762 ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
764 ahd_swap_with_next_hscb(ahd, scb);
766 if (SCBID_IS_NULL(SCB_GET_TAG(scb)))
767 panic("Attempt to queue invalid SCB tag %x\n",
768 SCB_GET_TAG(scb));
773 ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
776 if (scb->sg_count != 0)
777 ahd_setup_data_scb(ahd, scb);
779 ahd_setup_noxfer_scb(ahd, scb);
780 ahd_setup_scb_common(ahd, scb);
786 ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
792 host_dataptr = ahd_le64toh(scb->hscb->dataptr);
793 printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
795 SCB_GET_TAG(scb), ahd_le32toh(scb->hscb->hscb_busaddr),
798 ahd_le32toh(scb->hscb->datacnt));
801 /* Tell the adapter about the newly queued SCB */
806 ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
808 return (scb->sense_data);
812 ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
814 return (scb->sense_busaddr);