⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aic79xx_inline.h

📁 linux-2.6.15.6
💻 H
📖 第 1 页 / 共 2 页
字号:
 * for this SCB/transaction. */static __inline voidahd_update_residual(struct ahd_softc *ahd, struct scb *scb){	uint32_t sgptr;	sgptr = ahd_le32toh(scb->hscb->sgptr);	if ((sgptr & SG_STATUS_VALID) != 0)		ahd_calc_residual(ahd, scb);}/* * Return pointers to the transfer negotiation information * for the specified our_id/remote_id pair. */static __inline struct ahd_initiator_tinfo *ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id,		    u_int remote_id, struct ahd_tmode_tstate **tstate){	/*	 * Transfer data structures are stored from the perspective	 * of the target role.  Since the parameters for a connection	 * in the initiator role to a given target are the same as	 * when the roles are reversed, we pretend we are the target.	 */	if (channel == 'B')		our_id += 8;	*tstate = ahd->enabled_targets[our_id];	return (&(*tstate)->transinfo[remote_id]);}#define AHD_COPY_COL_IDX(dst, src)				\do {								\	dst->hscb->scsiid = src->hscb->scsiid;			\	dst->hscb->lun = src->hscb->lun;			\} while (0)static __inline uint16_tahd_inw(struct ahd_softc *ahd, u_int port){	return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port));}static __inline voidahd_outw(struct ahd_softc *ahd, u_int port, u_int value){	ahd_outb(ahd, port, value & 0xFF);	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);}static __inline uint32_tahd_inl(struct ahd_softc *ahd, u_int port){	return ((ahd_inb(ahd, port))	      | (ahd_inb(ahd, port+1) << 8)	      | (ahd_inb(ahd, port+2) << 16)	      | (ahd_inb(ahd, port+3) << 24));}static __inline voidahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value){	ahd_outb(ahd, port, (value) & 0xFF);	ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF);	ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF);	ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF);}static __inline uint64_tahd_inq(struct ahd_softc *ahd, u_int port){	return ((ahd_inb(ahd, port))	      | (ahd_inb(ahd, port+1) << 8)	      | (ahd_inb(ahd, port+2) << 16)	      | (ahd_inb(ahd, port+3) << 24)	      | (((uint64_t)ahd_inb(ahd, port+4)) << 32)	      | (((uint64_t)ahd_inb(ahd, port+5)) << 40)	      | (((uint64_t)ahd_inb(ahd, port+6)) << 48)	      | (((uint64_t)ahd_inb(ahd, port+7)) << 56));}static __inline voidahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value){	ahd_outb(ahd, port, value & 0xFF);	ahd_outb(ahd, port+1, (value >> 8) & 0xFF);	ahd_outb(ahd, port+2, (value >> 16) & 0xFF);	ahd_outb(ahd, port+3, (value >> 24) & 0xFF);	ahd_outb(ahd, port+4, (value >> 32) & 0xFF);	ahd_outb(ahd, port+5, (value >> 40) & 0xFF);	ahd_outb(ahd, port+6, (value >> 48) & 0xFF);	ahd_outb(ahd, port+7, (value >> 56) & 0xFF);}static __inline u_intahd_get_scbptr(struct ahd_softc *ahd){	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));	return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8));}static __inline voidahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr){	AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),			 ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));	ahd_outb(ahd, SCBPTR, scbptr & 0xFF);	ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);}static __inline u_intahd_get_hnscb_qoff(struct ahd_softc *ahd){	return (ahd_inw_atomic(ahd, HNSCB_QOFF));}static __inline voidahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value){	ahd_outw_atomic(ahd, HNSCB_QOFF, value);}static __inline u_intahd_get_hescb_qoff(struct ahd_softc *ahd){	return (ahd_inb(ahd, HESCB_QOFF));}static __inline voidahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value){	ahd_outb(ahd, HESCB_QOFF, value);}static __inline u_intahd_get_snscb_qoff(struct ahd_softc *ahd){	u_int oldvalue;	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	oldvalue = ahd_inw(ahd, SNSCB_QOFF);	ahd_outw(ahd, SNSCB_QOFF, oldvalue);	return (oldvalue);}static __inline voidahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value){	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	ahd_outw(ahd, SNSCB_QOFF, value);}static __inline u_intahd_get_sescb_qoff(struct ahd_softc *ahd){	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	return (ahd_inb(ahd, SESCB_QOFF));}static __inline voidahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value){	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	ahd_outb(ahd, SESCB_QOFF, value);}static __inline u_intahd_get_sdscb_qoff(struct ahd_softc *ahd){	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));}static __inline voidahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value){	AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);	ahd_outb(ahd, SDSCB_QOFF, value & 0xFF);	ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF);}static __inline u_intahd_inb_scbram(struct ahd_softc *ahd, u_int offset){	u_int value;	/*	 * Workaround PCI-X Rev A. hardware bug.	 * After a host read of SCB memory, the chip	 * may become confused into thinking prefetch	 * was required.  This starts the discard timer	 * running and can cause an unexpected discard	 * timer interrupt.  The work around is to read	 * a normal register prior to the exhaustion of	 * the discard timer.  The mode pointer register	 * has no side effects and so serves well for	 * this purpose.	 *	 * Razor #528	 */	value = ahd_inb(ahd, offset);	if ((ahd->flags & AHD_PCIX_SCBRAM_RD_BUG) != 0)		ahd_inb(ahd, MODE_PTR);	return (value);}static __inline u_intahd_inw_scbram(struct ahd_softc *ahd, u_int offset){	return (ahd_inb_scbram(ahd, offset)	      | (ahd_inb_scbram(ahd, offset+1) << 8));}static __inline uint32_tahd_inl_scbram(struct ahd_softc *ahd, u_int offset){	return (ahd_inw_scbram(ahd, offset)	      | (ahd_inw_scbram(ahd, offset+2) << 16));}static __inline uint64_tahd_inq_scbram(struct ahd_softc *ahd, u_int offset){	return (ahd_inl_scbram(ahd, offset)	      | ((uint64_t)ahd_inl_scbram(ahd, offset+4)) << 32);}static __inline struct scb *ahd_lookup_scb(struct ahd_softc *ahd, u_int tag){	struct scb* scb;	if (tag >= AHD_SCB_MAX)		return (NULL);	scb = ahd->scb_data.scbindex[tag];	if (scb != NULL)		ahd_sync_scb(ahd, scb,			     BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);	return (scb);}static __inline voidahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb){	struct hardware_scb *q_hscb;	uint32_t saved_hscb_busaddr;	/*	 * Our queuing method is a bit tricky.  The card	 * knows in advance which HSCB (by address) to download,	 * and we can't disappoint it.  To achieve this, the next	 * HSCB to download is saved off in ahd->next_queued_hscb.	 * When we are called to queue "an arbitrary scb",	 * we copy the contents of the incoming HSCB to the one	 * the sequencer knows about, swap HSCB pointers and	 * finally assign the SCB to the tag indexed location	 * in the scb_array.  This makes sure that we can still	 * locate the correct SCB by SCB_TAG.	 */	q_hscb = ahd->next_queued_hscb;	saved_hscb_busaddr = q_hscb->hscb_busaddr;	memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));	q_hscb->hscb_busaddr = saved_hscb_busaddr;	q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;	/* Now swap HSCB pointers. */	ahd->next_queued_hscb = scb->hscb;	scb->hscb = q_hscb;	/* Now define the mapping from tag to SCB in the scbindex */	ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;}/* * Tell the sequencer about a new transaction to execute. */static __inline voidahd_queue_scb(struct ahd_softc *ahd, struct scb *scb){	ahd_swap_with_next_hscb(ahd, scb);	if (SCBID_IS_NULL(SCB_GET_TAG(scb)))		panic("Attempt to queue invalid SCB tag %x\n",		      SCB_GET_TAG(scb));	/*	 * Keep a history of SCBs we've downloaded in the qinfifo.	 */	ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);	ahd->qinfifonext++;	if (scb->sg_count != 0)		ahd_setup_data_scb(ahd, scb);	else		ahd_setup_noxfer_scb(ahd, scb);	ahd_setup_scb_common(ahd, scb);	/*	 * Make sure our data is consistent from the	 * perspective of the adapter.	 */	ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);#ifdef AHD_DEBUG	if ((ahd_debug & AHD_SHOW_QUEUE) != 0) {		uint64_t host_dataptr;		host_dataptr = ahd_le64toh(scb->hscb->dataptr);		printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n",		       ahd_name(ahd),		       SCB_GET_TAG(scb), ahd_le32toh(scb->hscb->hscb_busaddr),		       (u_int)((host_dataptr >> 32) & 0xFFFFFFFF),		       (u_int)(host_dataptr & 0xFFFFFFFF),		       ahd_le32toh(scb->hscb->datacnt));	}#endif	/* Tell the adapter about the newly queued SCB */	ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);}static __inline uint8_t *ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb){	return (scb->sense_data);}static __inline uint32_tahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb){	return (scb->sense_busaddr);}/************************** Interrupt Processing ******************************/static __inline void	ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);static __inline void	ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);static __inline u_int	ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);static __inline int	ahd_intr(struct ahd_softc *ahd);static __inline voidahd_sync_qoutfifo(struct ahd_softc *ahd, int op){	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,			/*offset*/0, /*len*/AHC_SCB_MAX * sizeof(uint16_t), op);}static __inline voidahd_sync_tqinfifo(struct ahd_softc *ahd, int op){#ifdef AHD_TARGET_MODE	if ((ahd->flags & AHD_TARGETROLE) != 0) {		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,				ahd->shared_data_dmamap,				ahd_targetcmd_offset(ahd, 0),				sizeof(struct target_cmd) * AHD_TMODE_CMDS,				op);	}#endif}/* * See if the firmware has posted any completed commands * into our in-core command complete fifos. */#define AHD_RUN_QOUTFIFO 0x1#define AHD_RUN_TQINFIFO 0x2static __inline u_intahd_check_cmdcmpltqueues(struct ahd_softc *ahd){	u_int retval;	retval = 0;	ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_dmamap,			/*offset*/ahd->qoutfifonext, /*len*/2,			BUS_DMASYNC_POSTREAD);	if ((ahd->qoutfifo[ahd->qoutfifonext]	     & QOUTFIFO_ENTRY_VALID_LE) == ahd->qoutfifonext_valid_tag)		retval |= AHD_RUN_QOUTFIFO;#ifdef AHD_TARGET_MODE	if ((ahd->flags & AHD_TARGETROLE) != 0	 && (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) {		ahd_dmamap_sync(ahd, ahd->shared_data_dmat,				ahd->shared_data_dmamap,				ahd_targetcmd_offset(ahd, ahd->tqinfifofnext),				/*len*/sizeof(struct target_cmd),				BUS_DMASYNC_POSTREAD);		if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0)			retval |= AHD_RUN_TQINFIFO;	}#endif	return (retval);}/* * Catch an interrupt from the adapter */static __inline intahd_intr(struct ahd_softc *ahd){	u_int	intstat;	if ((ahd->pause & INTEN) == 0) {		/*		 * Our interrupt is not enabled on the chip		 * and may be disabled for re-entrancy reasons,		 * so just return.  This is likely just a shared		 * interrupt.		 */		return (0);	}	/*	 * Instead of directly reading the interrupt status register,	 * infer the cause of the interrupt by checking our in-core	 * completion queues.  This avoids a costly PCI bus read in	 * most cases.	 */	if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0	 && (ahd_check_cmdcmpltqueues(ahd) != 0))		intstat = CMDCMPLT;	else		intstat = ahd_inb(ahd, INTSTAT);	if ((intstat & INT_PEND) == 0)		return (0);	if (intstat & CMDCMPLT) {		ahd_outb(ahd, CLRINT, CLRCMDINT);		/*		 * Ensure that the chip sees that we've cleared		 * this interrupt before we walk the output fifo.		 * Otherwise, we may, due to posted bus writes,		 * clear the interrupt after we finish the scan,		 * and after the sequencer has added new entries		 * and asserted the interrupt again.		 */		if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {			if (ahd_is_paused(ahd)) {				/*				 * Potentially lost SEQINT.				 * If SEQINTCODE is non-zero,				 * simulate the SEQINT.				 */				if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT)					intstat |= SEQINT;			}		} else {			ahd_flush_device_writes(ahd);		}		ahd_run_qoutfifo(ahd);		ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++;		ahd->cmdcmplt_total++;#ifdef AHD_TARGET_MODE		if ((ahd->flags & AHD_TARGETROLE) != 0)			ahd_run_tqinfifo(ahd, /*paused*/FALSE);#endif	}	/*	 * Handle statuses that may invalidate our cached	 * copy of INTSTAT separately.	 */	if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) {		/* Hot eject.  Do nothing */	} else if (intstat & HWERRINT) {		ahd_handle_hwerrint(ahd);	} else if ((intstat & (PCIINT|SPLTINT)) != 0) {		ahd->bus_intr(ahd);	} else {		if ((intstat & SEQINT) != 0)			ahd_handle_seqint(ahd, intstat);		if ((intstat & SCSIINT) != 0)			ahd_handle_scsiint(ahd, intstat);	}	return (1);}#endif  /* _AIC79XX_INLINE_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -