summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/iha.c1004
-rw-r--r--sys/dev/ic/iha.h10
-rw-r--r--sys/dev/pci/iha_pci.c10
3 files changed, 424 insertions, 600 deletions
diff --git a/sys/dev/ic/iha.c b/sys/dev/ic/iha.c
index 46789691ce9..9888fb4ec1e 100644
--- a/sys/dev/ic/iha.c
+++ b/sys/dev/ic/iha.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iha.c,v 1.6 2001/07/10 23:30:39 krw Exp $ */
+/* $OpenBSD: iha.c,v 1.7 2001/07/13 03:24:20 krw Exp $ */
/*
* Initio INI-9xxxU/UW SCSI Device Driver
*
@@ -78,7 +78,7 @@ struct scsi_device iha_dev = {
* SCSI Rate Table, indexed by FLAG_SCSI_RATE field of
* TCS_Flags.
*/
-static u_int8_t tul_rate_tbl[8] = {
+static const u_int8_t iha_rate_tbl[8] = {
/* fast 20 */
/* nanosecond divide by 4 */
12, /* 50ns, 20M */
@@ -91,178 +91,95 @@ static u_int8_t tul_rate_tbl[8] = {
62 /* 250ns, 4M */
};
-static struct nvram tul_nvram;
-
-static u_int8_t tul_dftNvRam[64] = {
- /* -- Header ------------------------------------ */
- 0x25, 0xc9, /* NVM_Signature */
- 0x40, /* NVM_Size */
- 0x01, /* NVM_Revision */
-
- /* -- Host Adapter Structure -------------------- */
- 0x95, /* NVM_ModelByte0 */
- 0x00, /* NVM_ModelByte1 */
- 0x00, /* NVM_ModelInfo */
- 0x01, /* NVM_NumOfCh */
- BIOSCFG_DEFAULT, /* NVM_BIOSConfig1 */
- 0, /* NVM_BIOSConfig2 */
- 0, /* NVM_HAConfig1 */
- 0, /* NVM_HAConfig2 */
-
- /* -- NVM_Scsi[0] ------------------------------- */
- 7, /* NVM_SCSI_Id */
- CFG_DEFAULT, /* NVM_SCSI_Cfg */
- 0, /* NVM_SCSI_CfgByte2 */
- 8, /* NVM_SCSI_Targets */
- /* NVM_SCSI_TargetFlags */
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
-
- /* -- NVM_Scsi[1] ------------------------------- */
- 7, /* NVM_SCSI_Id */
- CFG_DEFAULT, /* NVM_SCSI_Cfg */
- 0, /* NVM_SCSI_CfgByte2 */
- 8, /* NVM_SCSI_Targets */
- /* NVM_SCSI_TargetFlags */
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
- FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT, FLAG_DEFAULT,
-
- 0,0,0,0,0,0,0,0,0,0, /* NVM_Reserved[10] */
- 0,0 /* NVM_CheckSum */
-};
-
-static u_int8_t tul_data_over_run __P((struct iha_scsi_req_q *));
-
-static void tul_push_sense_request __P((struct iha_softc *,
- struct iha_scsi_req_q *));
-static void tul_timeout __P((void *));
-static int tul_alloc_scbs __P((struct iha_softc *));
-
-static void tul_read_eeprom __P((bus_space_tag_t, bus_space_handle_t));
-static void tul_se2_update_all __P((bus_space_tag_t, bus_space_handle_t));
-static int tul_se2_rd_all __P((bus_space_tag_t, bus_space_handle_t));
-static void tul_se2_wr __P((bus_space_tag_t, bus_space_handle_t,
- u_int8_t, u_int16_t));
-static void tul_se2_instr __P((bus_space_tag_t, bus_space_handle_t,
- u_int8_t));
-static u_int16_t tul_se2_rd __P((bus_space_tag_t, bus_space_handle_t,
- u_int8_t));
-
-static void tul_reset_scsi_bus __P((struct iha_softc *));
-static void tul_reset_chip __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static void tul_reset_dma __P((bus_space_tag_t, bus_space_handle_t));
-
-static void tul_reset_tcs __P((struct tcs *, u_int8_t));
-
-static void tul_print_info __P((struct iha_softc *, int));
-
-static void tul_done_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
-static void tul_exec_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
-
-static void tul_main __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static void tul_scsi __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-
-static int tul_wait __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t, u_int8_t));
-
-static void tul_mark_busy_scb __P((struct iha_scsi_req_q *));
-
-static void tul_append_free_scb __P((struct iha_softc *,
- struct iha_scsi_req_q *));
-static struct iha_scsi_req_q *tul_pop_free_scb __P((struct iha_softc *));
-
-static void tul_append_done_scb __P((struct iha_softc *,
- struct iha_scsi_req_q *, u_int8_t));
-static struct iha_scsi_req_q *tul_pop_done_scb __P((struct iha_softc *));
-
-static void tul_append_pend_scb __P((struct iha_softc *,
- struct iha_scsi_req_q *));
-static void tul_push_pend_scb __P((struct iha_softc *,
- struct iha_scsi_req_q *));
-static void tul_del_pend_scb __P((struct iha_softc *,
- struct iha_scsi_req_q *));
-static struct iha_scsi_req_q *tul_find_pend_scb __P((struct iha_softc *));
-
-static void tul_sync_done __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static void tul_wide_done __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static void tul_bad_seq __P((struct iha_softc *));
-
-static int tul_next_state __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_1 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_2 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_3 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_4 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_5 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_6 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_state_8 __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-
-static void tul_set_ssig __P((bus_space_tag_t,
- bus_space_handle_t, u_int8_t, u_int8_t));
-
-static int tul_xpad_in __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_xpad_out __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-
-static int tul_xfer_data __P((struct iha_scsi_req_q *,
- bus_space_tag_t, bus_space_handle_t,
- int direction));
-
-static int tul_status_msg __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-
-static int tul_msgin __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_msgin_sdtr __P((struct iha_softc *));
-static int tul_msgin_extended __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_msgin_ignore_wid_resid __P((struct iha_softc *,
- bus_space_tag_t,
- bus_space_handle_t));
-
-static int tul_msgout __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t,
- u_int8_t));
-static int tul_msgout_extended __P((struct iha_softc *,
+static struct iha_nvram iha_nvram;
+
+u_int8_t iha_data_over_run __P((struct iha_scsi_req_q *));
+void iha_push_sense_request __P((struct iha_softc *, struct iha_scsi_req_q *));
+void iha_timeout __P((void *));
+int iha_alloc_scbs __P((struct iha_softc *));
+void iha_read_eeprom __P((bus_space_tag_t, bus_space_handle_t));
+int iha_se2_rd_all __P((bus_space_tag_t, bus_space_handle_t));
+void iha_se2_instr __P((bus_space_tag_t, bus_space_handle_t, u_int8_t));
+u_int16_t iha_se2_rd __P((bus_space_tag_t, bus_space_handle_t, u_int8_t));
+void iha_reset_scsi_bus __P((struct iha_softc *));
+void iha_reset_chip __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+void iha_reset_dma __P((bus_space_tag_t, bus_space_handle_t));
+void iha_reset_tcs __P((struct tcs *, u_int8_t));
+void iha_print_info __P((struct iha_softc *, int));
+void iha_done_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+void iha_exec_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+void iha_main __P((struct iha_softc *, bus_space_tag_t, bus_space_handle_t));
+void iha_scsi __P((struct iha_softc *, bus_space_tag_t, bus_space_handle_t));
+int iha_wait __P((struct iha_softc *, bus_space_tag_t, bus_space_handle_t,
+ u_int8_t));
+void iha_mark_busy_scb __P((struct iha_scsi_req_q *));
+void iha_append_free_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+struct iha_scsi_req_q *iha_pop_free_scb __P((struct iha_softc *));
+void iha_append_done_scb __P((struct iha_softc *, struct iha_scsi_req_q *,
+ u_int8_t));
+struct iha_scsi_req_q *iha_pop_done_scb __P((struct iha_softc *));
+void iha_append_pend_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+void iha_push_pend_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+void iha_del_pend_scb __P((struct iha_softc *, struct iha_scsi_req_q *));
+struct iha_scsi_req_q *iha_find_pend_scb __P((struct iha_softc *));
+void iha_sync_done __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+void iha_wide_done __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+void iha_bad_seq __P((struct iha_softc *));
+int iha_next_state __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_1 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_2 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_3 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_4 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_5 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_6 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_state_8 __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+void iha_set_ssig __P((bus_space_tag_t,
+ bus_space_handle_t, u_int8_t, u_int8_t));
+int iha_xpad_in __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_xpad_out __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_xfer_data __P((struct iha_scsi_req_q *,
+ bus_space_tag_t, bus_space_handle_t,
+ int direction));
+int iha_status_msg __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_msgin __P((struct iha_softc *, bus_space_tag_t, bus_space_handle_t));
+int iha_msgin_sdtr __P((struct iha_softc *));
+int iha_msgin_extended __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_msgin_ignore_wid_resid __P((struct iha_softc *,
bus_space_tag_t, bus_space_handle_t));
-static void tul_msgout_abort __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t,
- u_int8_t));
-static int tul_msgout_reject __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_msgout_sdtr __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_msgout_wdtr __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-
-static void tul_select __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t,
- struct iha_scsi_req_q *, u_int8_t));
-
-static void tul_busfree __P((struct iha_softc *,
- bus_space_tag_t, bus_space_handle_t));
-static int tul_resel __P((struct iha_softc *,
+int iha_msgout __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t, u_int8_t));
+int iha_msgout_extended __P((struct iha_softc *,
bus_space_tag_t, bus_space_handle_t));
-
-static void tul_abort_xs __P((struct iha_softc *,
- struct scsi_xfer *, u_int8_t));
+void iha_msgout_abort __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t, u_int8_t));
+int iha_msgout_reject __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_msgout_sdtr __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_msgout_wdtr __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+void iha_select __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t,
+ struct iha_scsi_req_q *, u_int8_t));
+void iha_busfree __P((struct iha_softc *,
+ bus_space_tag_t, bus_space_handle_t));
+int iha_resel __P((struct iha_softc *, bus_space_tag_t, bus_space_handle_t));
+void iha_abort_xs __P((struct iha_softc *, struct scsi_xfer *, u_int8_t));
/*
* iha_intr - the interrupt service routine for the iha driver
@@ -290,7 +207,7 @@ iha_intr(arg)
bus_space_write_1(iot, ioh, TUL_IMSK, MASK_ALL);
sc->HCS_Semaph = SEMAPH_IN_MAIN;
- tul_main(sc, iot, ioh);
+ iha_main(sc, iot, ioh);
sc->HCS_Semaph = ~SEMAPH_IN_MAIN;
bus_space_write_1(iot, ioh, TUL_IMSK, (MASK_ALL & ~MSCMP));
@@ -322,7 +239,7 @@ iha_scsi_cmd(xs)
return (COMPLETE);
}
- pScb = tul_pop_free_scb(sc);
+ pScb = iha_pop_free_scb(sc);
if (pScb == NULL) {
/* XXX - different xs->error/return if
* SCSI_POLL/_NOSLEEP? */
@@ -369,7 +286,7 @@ iha_scsi_cmd(xs)
printf("%s: error %d loading dma map\n",
sc->sc_dev.dv_xname, error);
- tul_append_free_scb(sc, pScb);
+ iha_append_free_scb(sc, pScb);
xs->error = XS_DRIVER_STUFFUP;
return (COMPLETE);
@@ -406,11 +323,11 @@ iha_scsi_cmd(xs)
* contain garbage that confuses timeout_del() later on.
* But, timeout_add() ONLY if we are not polling.
*/
- timeout_set(&xs->stimeout, tul_timeout, pScb);
+ timeout_set(&xs->stimeout, iha_timeout, pScb);
if ((xs->flags & SCSI_POLL) == 0)
timeout_add(&xs->stimeout, (xs->timeout/1000) * hz);
- tul_exec_scb(sc, pScb);
+ iha_exec_scb(sc, pScb);
if ((xs->flags & ITSDONE) == 0)
return (SUCCESSFULLY_QUEUED);
@@ -428,16 +345,16 @@ iha_init_tulip(sc)
{
struct iha_scsi_req_q *pScb;
bus_space_handle_t ioh;
- struct nvram_scsi *pScsi;
+ struct iha_nvram_scsi *pScsi;
bus_space_tag_t iot;
int i, error;
iot = sc->sc_iot;
ioh = sc->sc_ioh;
- tul_read_eeprom(iot, ioh);
+ iha_read_eeprom(iot, ioh);
- pScsi = &tul_nvram.NVM_Scsi[0];
+ pScsi = &iha_nvram.NVM_Scsi[0];
/*
* fill in the prototype scsi_link.
@@ -460,7 +377,7 @@ iha_init_tulip(sc)
TAILQ_INIT(&sc->HCS_PendScb);
TAILQ_INIT(&sc->HCS_DoneScb);
- error = tul_alloc_scbs(sc);
+ error = iha_alloc_scbs(sc);
if (error != 0)
return (error);
@@ -492,7 +409,7 @@ iha_init_tulip(sc)
bus_space_write_1(iot, ioh, TUL_IMSK, MASK_ALL);
/* Stop any I/O and reset the scsi module */
- tul_reset_dma(iot, ioh);
+ iha_reset_dma(iot, ioh);
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSMOD);
/* Program HBA's SCSI ID */
@@ -500,7 +417,7 @@ iha_init_tulip(sc)
/*
* Configure the channel as requested by the NVRAM settings read
- * into tul_nvram by tul_read_eeprom() above.
+ * into iha_nvram by iha_read_eeprom() above.
*/
if ((pScsi->NVM_SCSI_Cfg & CFG_EN_PAR) != 0)
@@ -522,10 +439,10 @@ iha_init_tulip(sc)
for (i = 0; i < IHA_MAX_TARGETS; i++) {
sc->HCS_Tcs[i].TCS_Flags = pScsi->NVM_SCSI_TargetFlags[i];
- tul_reset_tcs(&sc->HCS_Tcs[i], sc->HCS_SConf1);
+ iha_reset_tcs(&sc->HCS_Tcs[i], sc->HCS_SConf1);
}
- tul_reset_chip(sc, iot, ioh);
+ iha_reset_chip(sc, iot, ioh);
bus_space_write_1(iot, ioh, TUL_SIEN, ALL_INTERRUPTS);
return (0);
@@ -548,10 +465,10 @@ iha_minphys(bp)
}
/*
- * tul_reset_dma - abort any active DMA xfer, reset tulip FIFO.
+ * iha_reset_dma - abort any active DMA xfer, reset tulip FIFO.
*/
-static void
-tul_reset_dma(iot, ioh)
+void
+iha_reset_dma(iot, ioh)
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
@@ -567,10 +484,10 @@ tul_reset_dma(iot, ioh)
}
/*
- * tul_pop_free_scb - return the first free SCB, or NULL if there are none.
+ * iha_pop_free_scb - return the first free SCB, or NULL if there are none.
*/
-static struct iha_scsi_req_q *
-tul_pop_free_scb(sc)
+struct iha_scsi_req_q *
+iha_pop_free_scb(sc)
struct iha_softc *sc;
{
struct iha_scsi_req_q *pScb;
@@ -591,12 +508,12 @@ tul_pop_free_scb(sc)
}
/*
- * tul_append_free_scb - append the supplied SCB to the tail of the
+ * iha_append_free_scb - append the supplied SCB to the tail of the
* HCS_FreeScb queue after clearing and resetting
* everything possible.
*/
-static void
-tul_append_free_scb(sc, pScb)
+void
+iha_append_free_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -646,8 +563,8 @@ tul_append_free_scb(sc, pScb)
splx(s);
}
-static void
-tul_append_pend_scb(sc, pScb)
+void
+iha_append_pend_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -661,8 +578,8 @@ tul_append_pend_scb(sc, pScb)
TAILQ_INSERT_TAIL(&sc->HCS_PendScb, pScb, SCB_ScbList);
}
-static void
-tul_push_pend_scb(sc, pScb)
+void
+iha_push_pend_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -681,13 +598,13 @@ tul_push_pend_scb(sc, pScb)
}
/*
- * tul_find_pend_scb - scan the pending queue for a SCB that can be
+ * iha_find_pend_scb - scan the pending queue for a SCB that can be
* processed immediately. Return NULL if none found
* and a pointer to the SCB if one is found. If there
* is an active SCB, return NULL!
*/
-static struct iha_scsi_req_q *
-tul_find_pend_scb(sc)
+struct iha_scsi_req_q *
+iha_find_pend_scb(sc)
struct iha_softc *sc;
{
struct iha_scsi_req_q *pScb;
@@ -742,10 +659,10 @@ tul_find_pend_scb(sc)
}
/*
- * tul_del_pend_scb - remove pScb from HCS_PendScb
+ * iha_del_pend_scb - remove pScb from HCS_PendScb
*/
-static void
-tul_del_pend_scb(sc, pScb)
+void
+iha_del_pend_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -758,8 +675,8 @@ tul_del_pend_scb(sc, pScb)
splx(s);
}
-static void
-tul_mark_busy_scb(pScb)
+void
+iha_mark_busy_scb(pScb)
struct iha_scsi_req_q *pScb;
{
int s;
@@ -776,8 +693,8 @@ tul_mark_busy_scb(pScb)
splx(s);
}
-static void
-tul_append_done_scb(sc, pScb, hastat)
+void
+iha_append_done_scb(sc, pScb, hastat)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
u_int8_t hastat;
@@ -809,8 +726,8 @@ tul_append_done_scb(sc, pScb, hastat)
splx(s);
}
-static struct iha_scsi_req_q *
-tul_pop_done_scb(sc)
+struct iha_scsi_req_q *
+iha_pop_done_scb(sc)
struct iha_softc *sc;
{
struct iha_scsi_req_q *pScb;
@@ -831,12 +748,12 @@ tul_pop_done_scb(sc)
}
/*
- * tul_abort_xs - find the SCB associated with the supplied xs and
+ * iha_abort_xs - find the SCB associated with the supplied xs and
* stop all processing on it, moving it to the done
* queue with the supplied host status value.
*/
-static void
-tul_abort_xs(sc, xs, hastat)
+void
+iha_abort_xs(sc, xs, hastat)
struct iha_softc *sc;
struct scsi_xfer *xs;
u_int8_t hastat;
@@ -850,8 +767,8 @@ tul_abort_xs(sc, xs, hastat)
TAILQ_FOREACH(pScb, &sc->HCS_PendScb, SCB_ScbList)
if (pScb->SCB_Xs == xs) {
- tul_del_pend_scb(sc, pScb);
- tul_append_done_scb(sc, pScb, hastat);
+ iha_del_pend_scb(sc, pScb);
+ iha_append_done_scb(sc, pScb, hastat);
splx(s);
return;
}
@@ -866,7 +783,7 @@ tul_abort_xs(sc, xs, hastat)
case STATUS_BUSY:
case STATUS_SELECT:
if (pScb->SCB_Xs == xs) {
- tul_append_done_scb(sc, pScb, hastat);
+ iha_append_done_scb(sc, pScb, hastat);
splx(s);
return;
}
@@ -879,29 +796,29 @@ tul_abort_xs(sc, xs, hastat)
}
/*
- * tul_bad_seq - a SCSI bus phase was encountered out of the
+ * iha_bad_seq - a SCSI bus phase was encountered out of the
* correct/expected sequence. Reset the SCSI bus.
*/
-static void
-tul_bad_seq(sc)
+void
+iha_bad_seq(sc)
struct iha_softc *sc;
{
struct iha_scsi_req_q *pScb = sc->HCS_ActScb;
if (pScb != NULL)
- tul_append_done_scb(sc, pScb, HOST_BAD_PHAS);
+ iha_append_done_scb(sc, pScb, HOST_BAD_PHAS);
- tul_reset_scsi_bus(sc);
- tul_reset_chip(sc, sc->sc_iot, sc->sc_ioh);
+ iha_reset_scsi_bus(sc);
+ iha_reset_chip(sc, sc->sc_iot, sc->sc_ioh);
}
/*
- * tul_push_sense_request - obtain auto sense data by pushing the
+ * iha_push_sense_request - obtain auto sense data by pushing the
* SCB needing it back onto the pending
* queue with a REQUEST_SENSE CDB.
*/
-static void
-tul_push_sense_request(sc, pScb)
+void
+iha_push_sense_request(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -926,17 +843,17 @@ tul_push_sense_request(sc, pScb)
timeout_add(&pScb->SCB_Xs->stimeout,
(pScb->SCB_Timeout/1000) * hz);
- tul_push_pend_scb(sc, pScb);
+ iha_push_pend_scb(sc, pScb);
}
/*
- * tul_main - process the active SCB, taking one off pending and making it
+ * iha_main - process the active SCB, taking one off pending and making it
* active if necessary, and any done SCB's created as
* a result until there are no interrupts pending and no pending
* SCB's that can be started.
*/
-static void
-tul_main(sc, iot, ioh)
+void
+iha_main(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -944,10 +861,10 @@ tul_main(sc, iot, ioh)
struct iha_scsi_req_q *pScb;
for (;;) {
-tul_scsi_label:
- tul_scsi(sc, iot, ioh);
+iha_scsi_label:
+ iha_scsi(sc, iot, ioh);
- while ((pScb = tul_pop_done_scb(sc)) != NULL) {
+ while ((pScb = iha_pop_done_scb(sc)) != NULL) {
switch (pScb->SCB_TaStat) {
case SCSI_CMD_TERMINATED:
@@ -961,8 +878,8 @@ tul_scsi_label:
pScb->SCB_HaStat = HOST_BAD_PHAS;
else {
- tul_push_sense_request(sc, pScb);
- goto tul_scsi_label;
+ iha_push_sense_request(sc, pScb);
+ goto iha_scsi_label;
}
break;
@@ -977,27 +894,27 @@ tul_scsi_label:
break;
}
- tul_done_scb(sc, pScb);
+ iha_done_scb(sc, pScb);
}
/*
* If there are no interrupts pending, or we can't start
* a pending sc, break out of the for(;;). Otherwise
* continue the good work with another call to
- * tul_scsi().
+ * iha_scsi().
*/
if (((bus_space_read_1(iot, ioh, TUL_STAT0) & INTPD) == 0)
- && (tul_find_pend_scb(sc) == NULL))
+ && (iha_find_pend_scb(sc) == NULL))
break;
}
}
/*
- * tul_scsi - service any outstanding interrupts. If there are none, try to
+ * iha_scsi - service any outstanding interrupts. If there are none, try to
* start another SCB currently in the pending queue.
*/
-static void
-tul_scsi(sc, iot, ioh)
+void
+iha_scsi(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1017,34 +934,34 @@ tul_scsi(sc, iot, ioh)
sc->HCS_Phase = sc->HCS_JSStatus0 & PH_MASK;
if ((sc->HCS_JSInt & SRSTD) != 0) {
- tul_reset_scsi_bus(sc);
+ iha_reset_scsi_bus(sc);
return;
}
if ((sc->HCS_JSInt & RSELED) != 0) {
- tul_resel(sc, iot, ioh);
+ iha_resel(sc, iot, ioh);
return;
}
if ((sc->HCS_JSInt & (STIMEO | DISCD)) != 0) {
- tul_busfree(sc, iot, ioh);
+ iha_busfree(sc, iot, ioh);
return;
}
if ((sc->HCS_JSInt & (SCMDN | SBSRV)) != 0) {
- tul_next_state(sc, iot, ioh);
+ iha_next_state(sc, iot, ioh);
return;
}
if ((sc->HCS_JSInt & SELED) != 0)
- tul_set_ssig(iot, ioh, 0, 0);
+ iha_set_ssig(iot, ioh, 0, 0);
}
/*
* There were no interrupts pending which required action elsewhere, so
* see if it is possible to start the selection phase on a pending SCB
*/
- if ((pScb = tul_find_pend_scb(sc)) == NULL)
+ if ((pScb = iha_find_pend_scb(sc)) == NULL)
return;
pTcs = pScb->SCB_Tcs;
@@ -1059,24 +976,24 @@ tul_scsi(sc, iot, ioh)
if (((pTcs->TCS_Flags & FLAG_NO_NEG_WIDE) == 0)
||
((pTcs->TCS_Flags & FLAG_NO_NEG_SYNC) == 0))
- tul_select(sc, iot, ioh, pScb, SELATNSTOP);
+ iha_select(sc, iot, ioh, pScb, SELATNSTOP);
else if (pScb->SCB_TagMsg != 0)
- tul_select(sc, iot, ioh, pScb, SEL_ATN3);
+ iha_select(sc, iot, ioh, pScb, SEL_ATN3);
else
- tul_select(sc, iot, ioh, pScb, SEL_ATN);
+ iha_select(sc, iot, ioh, pScb, SEL_ATN);
} else {
- tul_select(sc, iot, ioh, pScb, SELATNSTOP);
+ iha_select(sc, iot, ioh, pScb, SELATNSTOP);
pScb->SCB_NxtStat = 8;
}
if ((pScb->SCB_Flags & SCSI_POLL) != 0) {
for (; pScb->SCB_Timeout > 0; pScb->SCB_Timeout--) {
- if (tul_wait(sc, iot, ioh, NO_OP) == -1)
+ if (iha_wait(sc, iot, ioh, NO_OP) == -1)
break;
- if (tul_next_state(sc, iot, ioh) == -1)
+ if (iha_next_state(sc, iot, ioh) == -1)
break;
delay(1000); /* Only happens in boot, so it's ok */
}
@@ -1089,18 +1006,18 @@ tul_scsi(sc, iot, ioh)
* Conversely, xs->error has not been set yet
*/
if (pScb->SCB_Timeout == 0)
- tul_timeout(pScb);
+ iha_timeout(pScb);
else if ((pScb->SCB_CDB[0] == INQUIRY)
&& (pScb->SCB_Lun == 0)
&& (pScb->SCB_HaStat == HOST_OK)
&& (pScb->SCB_TaStat == SCSI_OK))
- tul_print_info(sc, pScb->SCB_Target);
+ iha_print_info(sc, pScb->SCB_Target);
}
}
/*
- * tul_data_over_run - return HOST_OK for all SCSI opcodes where BufLen
+ * iha_data_over_run - return HOST_OK for all SCSI opcodes where BufLen
* is an 'Allocation Length'. All other SCSI opcodes
* get HOST_DO_DU as they SHOULD have xferred all the
* data requested.
@@ -1109,8 +1026,8 @@ tul_scsi(sc, iot, ioh)
* found by scanning all the SCSI-3 T10 drafts. See
* www.t10.org for the curious with a .pdf reader.
*/
-static u_int8_t
-tul_data_over_run(pScb)
+u_int8_t
+iha_data_over_run(pScb)
struct iha_scsi_req_q *pScb;
{
switch (pScb->SCB_CDB[0]) {
@@ -1161,11 +1078,11 @@ tul_data_over_run(pScb)
}
/*
- * tul_next_state - prcess the current SCB as requested in it's
+ * iha_next_state - prcess the current SCB as requested in it's
* SCB_NxtStat member.
*/
-static int
-tul_next_state(sc, iot, ioh)
+int
+iha_next_state(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1175,12 +1092,12 @@ tul_next_state(sc, iot, ioh)
switch (sc->HCS_ActScb->SCB_NxtStat) {
case 1:
- if (tul_state_1(sc, iot, ioh) == 3)
+ if (iha_state_1(sc, iot, ioh) == 3)
goto state_3;
break;
case 2:
- switch (tul_state_2(sc, iot, ioh)) {
+ switch (iha_state_2(sc, iot, ioh)) {
case 3: goto state_3;
case 4: goto state_4;
default: break;
@@ -1189,13 +1106,13 @@ tul_next_state(sc, iot, ioh)
case 3:
state_3:
- if (tul_state_3(sc, iot, ioh) == 4)
+ if (iha_state_3(sc, iot, ioh) == 4)
goto state_4;
break;
case 4:
state_4:
- switch (tul_state_4(sc, iot, ioh)) {
+ switch (iha_state_4(sc, iot, ioh)) {
case 0: return (0);
case 6: goto state_6;
default: break;
@@ -1203,7 +1120,7 @@ tul_next_state(sc, iot, ioh)
break;
case 5:
- switch (tul_state_5(sc, iot, ioh)) {
+ switch (iha_state_5(sc, iot, ioh)) {
case 4: goto state_4;
case 6: goto state_6;
default: break;
@@ -1212,11 +1129,11 @@ tul_next_state(sc, iot, ioh)
case 6:
state_6:
- tul_state_6(sc, iot, ioh);
+ iha_state_6(sc, iot, ioh);
break;
case 8:
- tul_state_8(sc, iot, ioh);
+ iha_state_8(sc, iot, ioh);
break;
default:
@@ -1224,7 +1141,7 @@ tul_next_state(sc, iot, ioh)
printf("[debug] -unknown state: %i-\n",
sc->HCS_ActScb->SCB_NxtStat);
#endif
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
break;
}
@@ -1232,13 +1149,13 @@ tul_next_state(sc, iot, ioh)
}
/*
- * tul_state_1 - selection is complete after a SELATNSTOP. If the target
+ * iha_state_1 - selection is complete after a SELATNSTOP. If the target
* has put the bus into MSG_OUT phase start wide/sync
* negotiation. Otherwise clear the FIFO and go to state 3,
* which will send the SCSI CDB to the target.
*/
-static int
-tul_state_1(sc, iot, ioh)
+int
+iha_state_1(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1247,7 +1164,7 @@ tul_state_1(sc, iot, ioh)
struct tcs *pTcs;
u_int16_t flags;
- tul_mark_busy_scb(pScb);
+ iha_mark_busy_scb(pScb);
pTcs = pScb->SCB_Tcs;
@@ -1277,36 +1194,36 @@ tul_state_1(sc, iot, ioh)
flags = pTcs->TCS_Flags;
if ((flags & FLAG_NO_NEG_WIDE) == 0) {
- if (tul_msgout_wdtr(sc, iot, ioh) == -1)
+ if (iha_msgout_wdtr(sc, iot, ioh) == -1)
return (-1);
} else if ((flags & FLAG_NO_NEG_SYNC) == 0) {
- if (tul_msgout_sdtr(sc, iot, ioh) == -1)
+ if (iha_msgout_sdtr(sc, iot, ioh) == -1)
return (-1);
}
} else {
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- tul_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
}
return (3);
}
/*
- * tul_state_2 - selection is complete after a SEL_ATN or SEL_ATN3. If the SCSI
+ * iha_state_2 - selection is complete after a SEL_ATN or SEL_ATN3. If the SCSI
* CDB has already been send, go to state 4 to start the data
* xfer. Otherwise reset the FIFO and go to state 3, sending
* the SCSI CDB.
*/
-static int
-tul_state_2(sc, iot, ioh)
+int
+iha_state_2(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
struct iha_scsi_req_q *pScb = sc->HCS_ActScb;
- tul_mark_busy_scb(pScb);
+ iha_mark_busy_scb(pScb);
bus_space_write_1(iot, ioh, TUL_SCONFIG0, pScb->SCB_Tcs->TCS_SConfig0);
@@ -1315,18 +1232,18 @@ tul_state_2(sc, iot, ioh)
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- tul_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
return (3);
}
/*
- * tul_state_3 - send the SCSI CDB to the target, processing any status
+ * iha_state_3 - send the SCSI CDB to the target, processing any status
* or other messages received until that is done or
* abandoned.
*/
-static int
-tul_state_3(sc, iot, ioh)
+int
+iha_state_3(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1339,50 +1256,50 @@ tul_state_3(sc, iot, ioh)
case PHASE_CMD_OUT:
bus_space_write_multi_1(iot, ioh, TUL_SFIFO,
pScb->SCB_CDB, pScb->SCB_CDBLen);
- if (tul_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
+ if (iha_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
return (-1);
else if (sc->HCS_Phase == PHASE_CMD_OUT) {
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
} else
return (4);
case PHASE_MSG_IN:
pScb->SCB_NxtStat = 3;
- if (tul_msgin(sc, iot, ioh) == -1)
+ if (iha_msgin(sc, iot, ioh) == -1)
return (-1);
break;
case PHASE_STATUS_IN:
- if (tul_status_msg(sc, iot, ioh) == -1)
+ if (iha_status_msg(sc, iot, ioh) == -1)
return (-1);
break;
case PHASE_MSG_OUT:
flags = pScb->SCB_Tcs->TCS_Flags;
if ((flags & FLAG_NO_NEG_SYNC) != 0) {
- if (tul_msgout(sc, iot, ioh, MSG_NOOP) == -1)
+ if (iha_msgout(sc, iot, ioh, MSG_NOOP) == -1)
return (-1);
- } else if (tul_msgout_sdtr(sc, iot, ioh) == -1)
+ } else if (iha_msgout_sdtr(sc, iot, ioh) == -1)
return (-1);
break;
default:
printf("[debug] -s3- bad phase = %d\n", sc->HCS_Phase);
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
}
/*
- * tul_state_4 - start a data xfer. Handle any bus state
+ * iha_state_4 - start a data xfer. Handle any bus state
* transitions until PHASE_DATA_IN/_OUT
* or the attempt is abandoned. If there is
* no data to xfer, go to state 6 and finish
* processing the current SCB.
*/
-static int
-tul_state_4(sc, iot, ioh)
+int
+iha_state_4(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1399,14 +1316,14 @@ tul_state_4(sc, iot, ioh)
switch (sc->HCS_Phase) {
case PHASE_STATUS_IN:
if ((pScb->SCB_Flags & FLAG_DIR) != 0)
- pScb->SCB_HaStat = tul_data_over_run(pScb);
- if ((tul_status_msg(sc, iot, ioh)) == -1)
+ pScb->SCB_HaStat = iha_data_over_run(pScb);
+ if ((iha_status_msg(sc, iot, ioh)) == -1)
return (-1);
break;
case PHASE_MSG_IN:
pScb->SCB_NxtStat = 4;
- if (tul_msgin(sc, iot, ioh) == -1)
+ if (iha_msgin(sc, iot, ioh) == -1)
return (-1);
break;
@@ -1414,38 +1331,38 @@ tul_state_4(sc, iot, ioh)
if ((sc->HCS_JSStatus0 & SPERR) != 0) {
pScb->SCB_BufLen = 0;
pScb->SCB_HaStat = HOST_SPERR;
- if (tul_msgout(sc, iot, ioh,
+ if (iha_msgout(sc, iot, ioh,
MSG_INITIATOR_DET_ERR) == -1)
return (-1);
else
return (6);
} else {
- if (tul_msgout(sc, iot, ioh, MSG_NOOP) == -1)
+ if (iha_msgout(sc, iot, ioh, MSG_NOOP) == -1)
return (-1);
}
break;
case PHASE_DATA_IN:
- return (tul_xfer_data(pScb, iot, ioh, SCSI_DATA_IN));
+ return (iha_xfer_data(pScb, iot, ioh, SCSI_DATA_IN));
case PHASE_DATA_OUT:
- return (tul_xfer_data(pScb, iot, ioh, SCSI_DATA_OUT));
+ return (iha_xfer_data(pScb, iot, ioh, SCSI_DATA_OUT));
default:
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
}
}
/*
- * tul_state_5 - handle the partial or final completion of the current
+ * iha_state_5 - handle the partial or final completion of the current
* data xfer. If DMA is still active stop it. If there is
* more data to xfer, go to state 4 and start the xfer.
* If not go to state 6 and finish the SCB.
*/
-static int
-tul_state_5(sc, iot, ioh)
+int
+iha_state_5(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1496,7 +1413,7 @@ tul_state_5(sc, iot, ioh)
}
if ((cnt == 1) && (sc->HCS_Phase == PHASE_DATA_OUT)) {
- if (tul_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
+ if (iha_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
return (-1);
cnt = 0;
@@ -1541,12 +1458,12 @@ tul_state_5(sc, iot, ioh)
}
/*
- * tul_state_6 - finish off the active scb (may require several
+ * iha_state_6 - finish off the active scb (may require several
* iterations if PHASE_MSG_IN) and return -1 to indicate
* the bus is free.
*/
-static int
-tul_state_6(sc, iot, ioh)
+int
+iha_state_6(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1554,42 +1471,42 @@ tul_state_6(sc, iot, ioh)
for (;;)
switch (sc->HCS_Phase) {
case PHASE_STATUS_IN:
- if (tul_status_msg(sc, iot, ioh) == -1)
+ if (iha_status_msg(sc, iot, ioh) == -1)
return (-1);
break;
case PHASE_MSG_IN:
sc->HCS_ActScb->SCB_NxtStat = 6;
- if ((tul_msgin(sc, iot, ioh)) == -1)
+ if ((iha_msgin(sc, iot, ioh)) == -1)
return (-1);
break;
case PHASE_MSG_OUT:
- if ((tul_msgout(sc, iot, ioh, MSG_NOOP)) == -1)
+ if ((iha_msgout(sc, iot, ioh, MSG_NOOP)) == -1)
return (-1);
break;
case PHASE_DATA_IN:
- if (tul_xpad_in(sc, iot, ioh) == -1)
+ if (iha_xpad_in(sc, iot, ioh) == -1)
return (-1);
break;
case PHASE_DATA_OUT:
- if (tul_xpad_out(sc, iot, ioh) == -1)
+ if (iha_xpad_out(sc, iot, ioh) == -1)
return (-1);
break;
default:
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
}
/*
- * tul_state_8 - reset the active device and all busy SCBs using it
+ * iha_state_8 - reset the active device and all busy SCBs using it
*/
-static int
-tul_state_8(sc, iot, ioh)
+int
+iha_state_8(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1604,21 +1521,21 @@ tul_state_8(sc, iot, ioh)
pScb = sc->HCS_ActScb;
/* This SCB finished correctly -- resetting the device */
- tul_append_done_scb(sc, pScb, HOST_OK);
+ iha_append_done_scb(sc, pScb, HOST_OK);
- tul_reset_tcs(pScb->SCB_Tcs, sc->HCS_SConf1);
+ iha_reset_tcs(pScb->SCB_Tcs, sc->HCS_SConf1);
tar = pScb->SCB_Target;
for (i = 0, pScb = sc->HCS_Scb; i < IHA_MAX_SCB; i++, pScb++)
if (pScb->SCB_Target == tar)
switch (pScb->SCB_Status) {
case STATUS_BUSY:
- tul_append_done_scb(sc,
+ iha_append_done_scb(sc,
pScb, HOST_DEV_RST);
break;
case STATUS_SELECT:
- tul_push_pend_scb(sc, pScb);
+ iha_push_pend_scb(sc, pScb);
break;
default:
@@ -1627,19 +1544,19 @@ tul_state_8(sc, iot, ioh)
sc->HCS_Flags |= FLAG_EXPECT_DISC;
- if (tul_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
+ if (iha_wait(sc, iot, ioh, XF_FIFO_OUT) == -1)
return (-1);
}
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
/*
- * tul_xfer_data - initiate the DMA xfer of the data
+ * iha_xfer_data - initiate the DMA xfer of the data
*/
-static int
-tul_xfer_data(pScb, iot, ioh, direction)
+int
+iha_xfer_data(pScb, iot, ioh, direction)
struct iha_scsi_req_q *pScb;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1674,8 +1591,8 @@ tul_xfer_data(pScb, iot, ioh, direction)
return (0);
}
-static int
-tul_xpad_in(sc, iot, ioh)
+int
+iha_xpad_in(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1691,7 +1608,7 @@ tul_xpad_in(sc, iot, ioh)
else
bus_space_write_4(iot, ioh, TUL_STCNT0, 1);
- switch (tul_wait(sc, iot, ioh, XF_FIFO_IN)) {
+ switch (iha_wait(sc, iot, ioh, XF_FIFO_IN)) {
case -1:
return (-1);
@@ -1706,8 +1623,8 @@ tul_xpad_in(sc, iot, ioh)
}
}
-static int
-tul_xpad_out(sc, iot, ioh)
+int
+iha_xpad_out(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1725,7 +1642,7 @@ tul_xpad_out(sc, iot, ioh)
bus_space_write_1(iot, ioh, TUL_SFIFO, 0);
- switch (tul_wait(sc, iot, ioh, XF_FIFO_OUT)) {
+ switch (iha_wait(sc, iot, ioh, XF_FIFO_OUT)) {
case -1:
return (-1);
@@ -1741,8 +1658,8 @@ tul_xpad_out(sc, iot, ioh)
}
}
-static int
-tul_status_msg(sc, iot, ioh)
+int
+iha_status_msg(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1751,7 +1668,7 @@ tul_status_msg(sc, iot, ioh)
u_int8_t msg;
int phase;
- if ((phase = tul_wait(sc, iot, ioh, CMD_COMP)) == -1)
+ if ((phase = iha_wait(sc, iot, ioh, CMD_COMP)) == -1)
return (-1);
pScb = sc->HCS_ActScb;
@@ -1766,56 +1683,56 @@ tul_status_msg(sc, iot, ioh)
bus_space_write_1(iot, ioh, TUL_SFIFO,
MSG_PARITY_ERROR);
- return (tul_wait(sc, iot, ioh, XF_FIFO_OUT));
+ return (iha_wait(sc, iot, ioh, XF_FIFO_OUT));
} else if (phase == PHASE_MSG_IN) {
msg = bus_space_read_1(iot, ioh, TUL_SFIFO);
if ((sc->HCS_JSStatus0 & SPERR) != 0)
- switch (tul_wait(sc, iot, ioh, MSG_ACCEPT)) {
+ switch (iha_wait(sc, iot, ioh, MSG_ACCEPT)) {
case -1:
return (-1);
case PHASE_MSG_OUT:
bus_space_write_1(iot, ioh, TUL_SFIFO,
MSG_PARITY_ERROR);
- return (tul_wait(sc, iot, ioh, XF_FIFO_OUT));
+ return (iha_wait(sc, iot, ioh, XF_FIFO_OUT));
default:
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
if (msg == MSG_CMDCOMPLETE) {
if ((pScb->SCB_TaStat
& (SCSI_INTERM | SCSI_BUSY)) == SCSI_INTERM) {
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
sc->HCS_Flags |= FLAG_EXPECT_DONE_DISC;
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- return (tul_wait(sc, iot, ioh, MSG_ACCEPT));
+ return (iha_wait(sc, iot, ioh, MSG_ACCEPT));
}
if ((msg == MSG_LINK_CMD_COMPLETE)
|| (msg == MSG_LINK_CMD_COMPLETEF)) {
if ((pScb->SCB_TaStat
& (SCSI_INTERM | SCSI_BUSY)) == SCSI_INTERM)
- return (tul_wait(sc, iot, ioh, MSG_ACCEPT));
+ return (iha_wait(sc, iot, ioh, MSG_ACCEPT));
}
}
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
/*
- * tul_busfree - SCSI bus free detected as a result of a TIMEOUT or
+ * iha_busfree - SCSI bus free detected as a result of a TIMEOUT or
* DISCONNECT interrupt. Reset the tulip FIFO and
* SCONFIG0 and enable hardware reselect. Move any active
* SCB to HCS_DoneScb list. Return an appropriate host status
* if an I/O was active.
*/
-static void
-tul_busfree(sc, iot, ioh)
+void
+iha_busfree(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1831,16 +1748,16 @@ tul_busfree(sc, iot, ioh)
if (pScb != NULL) {
if (pScb->SCB_Status == STATUS_SELECT)
/* selection timeout */
- tul_append_done_scb(sc, pScb, HOST_SEL_TOUT);
+ iha_append_done_scb(sc, pScb, HOST_SEL_TOUT);
else
/* Unexpected bus free */
- tul_append_done_scb(sc, pScb, HOST_BAD_PHAS);
+ iha_append_done_scb(sc, pScb, HOST_BAD_PHAS);
}
}
-static void
-tul_reset_scsi_bus(sc)
+void
+iha_reset_scsi_bus(sc)
struct iha_softc *sc;
{
struct iha_scsi_req_q *pScb;
@@ -1849,16 +1766,16 @@ tul_reset_scsi_bus(sc)
s = splbio();
- tul_reset_dma(sc->sc_iot, sc->sc_ioh);
+ iha_reset_dma(sc->sc_iot, sc->sc_ioh);
for (i = 0, pScb = sc->HCS_Scb; i < IHA_MAX_SCB; i++, pScb++)
switch (pScb->SCB_Status) {
case STATUS_BUSY:
- tul_append_done_scb(sc, pScb, HOST_SCSI_RST);
+ iha_append_done_scb(sc, pScb, HOST_SCSI_RST);
break;
case STATUS_SELECT:
- tul_push_pend_scb(sc, pScb);
+ iha_push_pend_scb(sc, pScb);
break;
default:
@@ -1866,16 +1783,16 @@ tul_reset_scsi_bus(sc)
}
for (i = 0, pTcs = sc->HCS_Tcs; i < IHA_MAX_TARGETS; i++, pTcs++)
- tul_reset_tcs(pTcs, sc->HCS_SConf1);
+ iha_reset_tcs(pTcs, sc->HCS_SConf1);
splx(s);
}
/*
- * tul_resel - handle a detected SCSI bus reselection request.
+ * iha_resel - handle a detected SCSI bus reselection request.
*/
-static int
-tul_resel(sc, iot, ioh)
+int
+iha_resel(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1886,7 +1803,7 @@ tul_resel(sc, iot, ioh)
if (sc->HCS_ActScb != NULL) {
if ((sc->HCS_ActScb->SCB_Status == STATUS_SELECT))
- tul_push_pend_scb(sc, sc->HCS_ActScb);
+ iha_push_pend_scb(sc, sc->HCS_ActScb);
sc->HCS_ActScb = NULL;
}
@@ -1912,12 +1829,12 @@ tul_resel(sc, iot, ioh)
* the tag.
*/
- switch (tul_wait(sc, iot, ioh, MSG_ACCEPT)) {
+ switch (iha_wait(sc, iot, ioh, MSG_ACCEPT)) {
case -1:
return (-1);
case PHASE_MSG_IN:
bus_space_write_4(iot, ioh, TUL_STCNT0, 1);
- if ((tul_wait(sc, iot, ioh, XF_FIFO_IN)) == -1)
+ if ((iha_wait(sc, iot, ioh, XF_FIFO_IN)) == -1)
return (-1);
break;
default:
@@ -1929,12 +1846,12 @@ tul_resel(sc, iot, ioh)
if ((msg < MSG_SIMPLE_Q_TAG) || (msg > MSG_ORDERED_Q_TAG))
goto abort;
- switch (tul_wait(sc, iot, ioh, MSG_ACCEPT)) {
+ switch (iha_wait(sc, iot, ioh, MSG_ACCEPT)) {
case -1:
return (-1);
case PHASE_MSG_IN:
bus_space_write_4(iot, ioh, TUL_STCNT0, 1);
- if ((tul_wait(sc, iot, ioh, XF_FIFO_IN)) == -1)
+ if ((iha_wait(sc, iot, ioh, XF_FIFO_IN)) == -1)
return (-1);
break;
default:
@@ -1951,20 +1868,20 @@ tul_resel(sc, iot, ioh)
|| (pScb->SCB_Lun != lun)
|| (pScb->SCB_Status != STATUS_BUSY)) {
abort:
- tul_msgout_abort(sc, iot, ioh, abortmsg);
+ iha_msgout_abort(sc, iot, ioh, abortmsg);
return (-1);
}
sc->HCS_ActScb = pScb;
- if (tul_wait(sc, iot, ioh, MSG_ACCEPT) == -1)
+ if (iha_wait(sc, iot, ioh, MSG_ACCEPT) == -1)
return (-1);
- return(tul_next_state(sc, iot, ioh));
+ return(iha_next_state(sc, iot, ioh));
}
-static int
-tul_msgin(sc, iot, ioh)
+int
+iha_msgin(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -1979,47 +1896,47 @@ tul_msgin(sc, iot, ioh)
bus_space_write_4(iot, ioh, TUL_STCNT0, 1);
- phase = tul_wait(sc, iot, ioh, XF_FIFO_IN);
+ phase = iha_wait(sc, iot, ioh, XF_FIFO_IN);
msg = bus_space_read_1(iot, ioh, TUL_SFIFO);
switch (msg) {
case MSG_DISCONNECT:
sc->HCS_Flags |= FLAG_EXPECT_DISC;
- if (tul_wait(sc, iot, ioh, MSG_ACCEPT) != -1)
- tul_bad_seq(sc);
+ if (iha_wait(sc, iot, ioh, MSG_ACCEPT) != -1)
+ iha_bad_seq(sc);
phase = -1;
break;
case MSG_SAVEDATAPOINTER:
case MSG_RESTOREPOINTERS:
case MSG_NOOP:
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
break;
case MSG_MESSAGE_REJECT:
/* XXX - need to clear FIFO like other 'Clear ATN'?*/
- tul_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
flags = sc->HCS_ActScb->SCB_Tcs->TCS_Flags;
if ((flags & FLAG_NO_NEG_SYNC) == 0)
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
break;
case MSG_EXTENDED:
- phase = tul_msgin_extended(sc, iot, ioh);
+ phase = iha_msgin_extended(sc, iot, ioh);
break;
case MSG_IGN_WIDE_RESIDUE:
- phase = tul_msgin_ignore_wid_resid(sc, iot, ioh);
+ phase = iha_msgin_ignore_wid_resid(sc, iot, ioh);
break;
case MSG_CMDCOMPLETE:
sc->HCS_Flags |= FLAG_EXPECT_DONE_DISC;
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
if (phase != -1) {
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
return (-1);
}
break;
default:
- printf("[debug] tul_msgin: bad msg type: %d\n", msg);
- phase = tul_msgout_reject(sc, iot, ioh);
+ printf("[debug] iha_msgin: bad msg type: %d\n", msg);
+ phase = iha_msgout_reject(sc, iot, ioh);
break;
}
@@ -2029,33 +1946,33 @@ tul_msgin(sc, iot, ioh)
/* NOTREACHED */
}
-static int
-tul_msgin_ignore_wid_resid(sc, iot, ioh)
+int
+iha_msgin_ignore_wid_resid(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
int phase;
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
if (phase == PHASE_MSG_IN) {
- phase = tul_wait(sc, iot, ioh, XF_FIFO_IN);
+ phase = iha_wait(sc, iot, ioh, XF_FIFO_IN);
if (phase != -1) {
bus_space_write_1(iot, ioh, TUL_SFIFO, 0);
bus_space_read_1 (iot, ioh, TUL_SFIFO);
bus_space_read_1 (iot, ioh, TUL_SFIFO);
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
}
}
return (phase);
}
-static int
-tul_msgin_extended(sc, iot, ioh)
+int
+iha_msgin_extended(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2067,14 +1984,14 @@ tul_msgin_extended(sc, iot, ioh)
* read all input, discarding the excess, and then reject
*/
for (i = 0; i < IHA_MAX_EXTENDED_MSG; i++) {
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
if (phase != PHASE_MSG_IN)
return (phase);
bus_space_write_4(iot, ioh, TUL_STCNT0, 1);
- if (tul_wait(sc, iot, ioh, XF_FIFO_IN) == -1)
+ if (iha_wait(sc, iot, ioh, XF_FIFO_IN) == -1)
return (-1);
sc->HCS_Msg[i] = bus_space_read_1(iot, ioh, TUL_SFIFO);
@@ -2087,21 +2004,21 @@ tul_msgin_extended(sc, iot, ioh)
msgcode = sc->HCS_Msg[1];
if ((msglen == MSG_EXT_SDTR_LEN) && (msgcode == MSG_EXT_SDTR)) {
- if (tul_msgin_sdtr(sc) == 0) {
- tul_sync_done(sc, iot, ioh);
- return (tul_wait(sc, iot, ioh, MSG_ACCEPT));
+ if (iha_msgin_sdtr(sc) == 0) {
+ iha_sync_done(sc, iot, ioh);
+ return (iha_wait(sc, iot, ioh, MSG_ACCEPT));
}
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
if (phase != PHASE_MSG_OUT)
return (phase);
/* Clear FIFO for important message - final SYNC offer */
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- tul_sync_done(sc, iot, ioh); /* This is our final offer */
+ iha_sync_done(sc, iot, ioh); /* This is our final offer */
} else if ((msglen == MSG_EXT_WDTR_LEN) && (msgcode == MSG_EXT_WDTR)) {
@@ -2111,39 +2028,39 @@ tul_msgin_extended(sc, iot, ioh)
sc->HCS_Msg[2] = 0; /* Offer async xfers only */
else if (sc->HCS_Msg[2] > 2) /* BAD MSG: 2 is max value */
- return (tul_msgout_reject(sc, iot, ioh));
+ return (iha_msgout_reject(sc, iot, ioh));
else if (sc->HCS_Msg[2] == 2) /* a request for 32 bit xfers*/
sc->HCS_Msg[2] = 1; /* Offer 16 instead */
else {
- tul_wide_done(sc, iot, ioh);
+ iha_wide_done(sc, iot, ioh);
if ((flags & FLAG_NO_NEG_SYNC) == 0)
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- return (tul_wait(sc, iot, ioh, MSG_ACCEPT));
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ return (iha_wait(sc, iot, ioh, MSG_ACCEPT));
}
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- phase = tul_wait(sc, iot, ioh, MSG_ACCEPT);
+ phase = iha_wait(sc, iot, ioh, MSG_ACCEPT);
if (phase != PHASE_MSG_OUT)
return (phase);
} else
- return (tul_msgout_reject(sc, iot, ioh));
+ return (iha_msgout_reject(sc, iot, ioh));
/* Send message built in sc->HCS_Msg[] */
- return (tul_msgout_extended(sc, iot, ioh));
+ return (iha_msgout_extended(sc, iot, ioh));
}
/*
- * tul_msgin_sdtr - check SDTR msg in HCS_Msg. If the offer is
+ * iha_msgin_sdtr - check SDTR msg in HCS_Msg. If the offer is
* acceptable leave HCS_Msg as is and return 0.
* If the negotiation must continue, modify HCS_Msg
* as needed and return 1. Else return 0.
*/
-static int
-tul_msgin_sdtr(sc)
+int
+iha_msgin_sdtr(sc)
struct iha_softc *sc;
{
u_int16_t flags;
@@ -2152,7 +2069,7 @@ tul_msgin_sdtr(sc)
flags = sc->HCS_ActScb->SCB_Tcs->TCS_Flags;
- default_period = tul_rate_tbl[flags & FLAG_SCSI_RATE];
+ default_period = iha_rate_tbl[flags & FLAG_SCSI_RATE];
if (sc->HCS_Msg[3] == 0) /* target offered async only. Accept it. */
return (0);
@@ -2182,8 +2099,8 @@ tul_msgin_sdtr(sc)
return (newoffer);
}
-static int
-tul_msgout(sc, iot, ioh, msg)
+int
+iha_msgout(sc, iot, ioh, msg)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2191,50 +2108,50 @@ tul_msgout(sc, iot, ioh, msg)
{
bus_space_write_1(iot, ioh, TUL_SFIFO, msg);
- return (tul_wait(sc, iot, ioh, XF_FIFO_OUT));
+ return (iha_wait(sc, iot, ioh, XF_FIFO_OUT));
}
-static void
-tul_msgout_abort(sc, iot, ioh, aborttype)
+void
+iha_msgout_abort(sc, iot, ioh, aborttype)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t aborttype;
{
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- switch (tul_wait(sc, iot, ioh, MSG_ACCEPT)) {
+ switch (iha_wait(sc, iot, ioh, MSG_ACCEPT)) {
case -1:
break;
case PHASE_MSG_OUT:
sc->HCS_Flags |= FLAG_EXPECT_DISC;
- if (tul_msgout(sc, iot, ioh, aborttype) != -1)
- tul_bad_seq(sc);
+ if (iha_msgout(sc, iot, ioh, aborttype) != -1)
+ iha_bad_seq(sc);
break;
default:
- tul_bad_seq(sc);
+ iha_bad_seq(sc);
break;
}
}
-static int
-tul_msgout_reject(sc, iot, ioh)
+int
+iha_msgout_reject(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
- tul_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL, ATN);
- if (tul_wait(sc, iot, ioh, MSG_ACCEPT) == PHASE_MSG_OUT)
- return (tul_msgout(sc, iot, ioh, MSG_MESSAGE_REJECT));
+ if (iha_wait(sc, iot, ioh, MSG_ACCEPT) == PHASE_MSG_OUT)
+ return (iha_msgout(sc, iot, ioh, MSG_MESSAGE_REJECT));
return (-1);
}
-static int
-tul_msgout_extended(sc, iot, ioh)
+int
+iha_msgout_extended(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2246,16 +2163,16 @@ tul_msgout_extended(sc, iot, ioh)
bus_space_write_multi_1(iot, ioh, TUL_SFIFO,
sc->HCS_Msg, sc->HCS_Msg[0]+1);
- phase = tul_wait(sc, iot, ioh, XF_FIFO_OUT);
+ phase = iha_wait(sc, iot, ioh, XF_FIFO_OUT);
bus_space_write_1(iot, ioh, TUL_SCTRL0, RSFIFO);
- tul_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
+ iha_set_ssig(iot, ioh, REQ | BSY | SEL | ATN, 0);
return (phase);
}
-static int
-tul_msgout_wdtr(sc, iot, ioh)
+int
+iha_msgout_wdtr(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2266,11 +2183,11 @@ tul_msgout_wdtr(sc, iot, ioh)
sc->HCS_Msg[1] = MSG_EXT_WDTR;
sc->HCS_Msg[2] = MSG_EXT_WDTR_BUS_16_BIT;
- return (tul_msgout_extended(sc, iot, ioh));
+ return (iha_msgout_extended(sc, iot, ioh));
}
-static int
-tul_msgout_sdtr(sc, iot, ioh)
+int
+iha_msgout_sdtr(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2280,18 +2197,18 @@ tul_msgout_sdtr(sc, iot, ioh)
rateindex = sc->HCS_ActScb->SCB_Tcs->TCS_Flags & FLAG_SCSI_RATE;
- sync_rate = tul_rate_tbl[rateindex];
+ sync_rate = iha_rate_tbl[rateindex];
sc->HCS_Msg[0] = MSG_EXT_SDTR_LEN;
sc->HCS_Msg[1] = MSG_EXT_SDTR;
sc->HCS_Msg[2] = sync_rate;
sc->HCS_Msg[3] = IHA_MAX_TARGETS-1; /* REQ/ACK */
- return (tul_msgout_extended(sc, iot, ioh));
+ return (iha_msgout_extended(sc, iot, ioh));
}
-static void
-tul_wide_done(sc, iot, ioh)
+void
+iha_wide_done(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2311,8 +2228,8 @@ tul_wide_done(sc, iot, ioh)
bus_space_write_1(iot, ioh, TUL_SYNCM, pTcs->TCS_JS_Period);
}
-static void
-tul_sync_done(sc, iot, ioh)
+void
+iha_sync_done(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2326,7 +2243,7 @@ tul_sync_done(sc, iot, ioh)
/* pick the highest possible rate */
for (i = 0; i < 8; i++)
- if (tul_rate_tbl[i] >= sc->HCS_Msg[2])
+ if (iha_rate_tbl[i] >= sc->HCS_Msg[2])
break;
pTcs->TCS_JS_Period |= (i << 4);
@@ -2341,7 +2258,7 @@ tul_sync_done(sc, iot, ioh)
}
void
-tul_reset_chip(sc, iot, ioh)
+iha_reset_chip(sc, iot, ioh)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2356,7 +2273,7 @@ tul_reset_chip(sc, iot, ioh)
sc->HCS_JSInt = bus_space_read_1(iot, ioh, TUL_SISTAT);
while((sc->HCS_JSInt & SRSTD) == 0);
- tul_set_ssig(iot, ioh, 0, 0);
+ iha_set_ssig(iot, ioh, 0, 0);
/*
* Stall for 2 seconds, wait for target's firmware ready.
@@ -2367,8 +2284,8 @@ tul_reset_chip(sc, iot, ioh)
bus_space_read_1(iot, ioh, TUL_SISTAT); /* Clear any active interrupt*/
}
-static void
-tul_select(sc, iot, ioh, pScb, select_type)
+void
+iha_select(sc, iot, ioh, pScb, select_type)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2400,12 +2317,12 @@ tul_select(sc, iot, ioh, pScb, select_type)
break;
default:
- printf("[debug] tul_select() - unknown select type = 0x%02x\n",
+ printf("[debug] iha_select() - unknown select type = 0x%02x\n",
select_type);
return;
}
- tul_del_pend_scb(sc, pScb);
+ iha_del_pend_scb(sc, pScb);
pScb->SCB_Status = STATUS_SELECT;
sc->HCS_ActScb = pScb;
@@ -2414,12 +2331,12 @@ tul_select(sc, iot, ioh, pScb, select_type)
}
/*
- * tul_wait - wait for an interrupt to service or a SCSI bus phase change
+ * iha_wait - wait for an interrupt to service or a SCSI bus phase change
* after writing the supplied command to the tulip chip. If
* the command is NO_OP, skip the command writing.
*/
-static int
-tul_wait(sc, iot, ioh, cmd)
+int
+iha_wait(sc, iot, ioh, cmd)
struct iha_softc *sc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
@@ -2443,17 +2360,17 @@ tul_wait(sc, iot, ioh, cmd)
if ((sc->HCS_JSInt & SRSTD) != 0) {
/* SCSI bus reset interrupt */
- tul_reset_scsi_bus(sc);
+ iha_reset_scsi_bus(sc);
return (-1);
}
if ((sc->HCS_JSInt & RSELED) != 0)
/* Reselection interrupt */
- return (tul_resel(sc, iot, ioh));
+ return (iha_resel(sc, iot, ioh));
if ((sc->HCS_JSInt & STIMEO) != 0) {
/* selected/reselected timeout interrupt */
- tul_busfree(sc, iot, ioh);
+ iha_busfree(sc, iot, ioh);
return (-1);
}
@@ -2464,7 +2381,7 @@ tul_wait(sc, iot, ioh, cmd)
bus_space_write_1(iot, ioh, TUL_SCONFIG0,
SCONFIG0DEFAULT);
bus_space_write_1(iot, ioh, TUL_SCTRL1, EHRSL);
- tul_append_done_scb(sc, sc->HCS_ActScb, HOST_OK);
+ iha_append_done_scb(sc, sc->HCS_ActScb, HOST_OK);
sc->HCS_Flags &= ~FLAG_EXPECT_DONE_DISC;
} else if ((sc->HCS_Flags & FLAG_EXPECT_DISC) != 0) {
@@ -2476,7 +2393,7 @@ tul_wait(sc, iot, ioh, cmd)
sc->HCS_Flags &= ~FLAG_EXPECT_DISC;
} else
- tul_busfree(sc, iot, ioh);
+ iha_busfree(sc, iot, ioh);
return (-1);
}
@@ -2485,11 +2402,11 @@ tul_wait(sc, iot, ioh, cmd)
}
/*
- * tul_done_scb - We have a scb which has been processed by the
+ * iha_done_scb - We have a scb which has been processed by the
* adaptor, now we look to see how the operation went.
*/
-static void
-tul_done_scb(sc, pScb)
+void
+iha_done_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -2569,11 +2486,11 @@ tul_done_scb(sc, pScb)
scsi_done(xs);
}
- tul_append_free_scb(sc, pScb);
+ iha_append_free_scb(sc, pScb);
}
-static void
-tul_timeout(arg)
+void
+iha_timeout(arg)
void *arg;
{
struct iha_scsi_req_q *pScb = (struct iha_scsi_req_q *)arg;
@@ -2581,19 +2498,19 @@ tul_timeout(arg)
struct iha_softc *sc;
if (xs == NULL)
- printf("[debug] tul_timeout called with xs == NULL\n");
+ printf("[debug] iha_timeout called with xs == NULL\n");
else {
sc = xs->sc_link->adapter_softc;
sc_print_addr(xs->sc_link);
printf("SCSI OpCode 0x%02x timed out\n", xs->cmd->opcode);
- tul_abort_xs(xs->sc_link->adapter_softc, xs, HOST_TIMED_OUT);
+ iha_abort_xs(xs->sc_link->adapter_softc, xs, HOST_TIMED_OUT);
}
}
-static void
-tul_exec_scb(sc, pScb)
+void
+iha_exec_scb(sc, pScb)
struct iha_softc *sc;
struct iha_scsi_req_q *pScb;
{
@@ -2605,12 +2522,12 @@ tul_exec_scb(sc, pScb)
if (((pScb->SCB_Flags & SCSI_RESET) != 0)
|| (pScb->SCB_CDB[0] == REQUEST_SENSE))
- tul_push_pend_scb(sc, pScb); /* Insert SCB at head of Pend */
+ iha_push_pend_scb(sc, pScb); /* Insert SCB at head of Pend */
else
- tul_append_pend_scb(sc, pScb); /* Append SCB to tail of Pend */
+ iha_append_pend_scb(sc, pScb); /* Append SCB to tail of Pend */
/*
- * Run through tul_main() to ensure something is active, if
+ * Run through iha_main() to ensure something is active, if
* only this new SCB.
*/
if (sc->HCS_Semaph != SEMAPH_IN_MAIN) {
@@ -2621,7 +2538,7 @@ tul_exec_scb(sc, pScb)
sc->HCS_Semaph = SEMAPH_IN_MAIN;;
splx(s);
- tul_main(sc, iot, ioh);
+ iha_main(sc, iot, ioh);
s = splbio();
sc->HCS_Semaph = ~SEMAPH_IN_MAIN;;
@@ -2633,11 +2550,11 @@ tul_exec_scb(sc, pScb)
/*
- * tul_set_ssig - read the current scsi signal mask, then write a new
+ * iha_set_ssig - read the current scsi signal mask, then write a new
* one which turns off/on the specified signals.
*/
-static void
-tul_set_ssig( iot, ioh, offsigs, onsigs)
+void
+iha_set_ssig( iot, ioh, offsigs, onsigs)
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t offsigs, onsigs;
@@ -2648,8 +2565,8 @@ tul_set_ssig( iot, ioh, offsigs, onsigs)
bus_space_write_1(iot, ioh, TUL_SSIGO, (currsigs & ~offsigs) | onsigs);
}
-static void
-tul_print_info(sc, target)
+void
+iha_print_info(sc, target)
struct iha_softc *sc;
int target;
{
@@ -2678,10 +2595,10 @@ tul_print_info(sc, target)
/*
- * tul_alloc_scbs - allocate and map the SCB's for the supplied IHA_SOFTC
+ * iha_alloc_scbs - allocate and map the SCB's for the supplied IHA_SOFTC
*/
-static int
-tul_alloc_scbs(sc)
+int
+iha_alloc_scbs(sc)
struct iha_softc *sc;
{
bus_dma_segment_t seg;
@@ -2734,126 +2651,36 @@ tul_alloc_scbs(sc)
}
/*
- * tul_read_eeprom - read Serial EEPROM value & set to defaults
+ * iha_read_eeprom - read Serial EEPROM value & set to defaults
* if required. XXX - Writing does NOT work!
*/
void
-tul_read_eeprom(iot, ioh)
+iha_read_eeprom(iot, ioh)
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
u_int8_t gctrl;
- /*------Enable EEProm programming ---*/
+ /* Enable EEProm programming */
gctrl = bus_space_read_1(iot, ioh, TUL_GCTRL0) | EEPRG;
bus_space_write_1(iot, ioh, TUL_GCTRL0, gctrl);
- /*------ Program default pattern ----*/
- if (tul_se2_rd_all(iot, ioh) == 0) {
- tul_se2_update_all(iot, ioh);
- if(tul_se2_rd_all(iot, ioh) == 0)
- panic("could not program iha Tulip EEPROM\n");
- }
+ /* Read EEProm */
+ if (iha_se2_rd_all(iot, ioh) == 0)
+ panic("iha: could not read EEPROM\n");
- /*------ Disable EEProm programming ---*/
+ /* Disable EEProm programming */
gctrl = bus_space_read_1(iot, ioh, TUL_GCTRL0) & ~EEPRG;
bus_space_write_1(iot, ioh, TUL_GCTRL0, gctrl);
}
/*
- * tul_se2_update_all - Update SCSI H/A configuration parameters from
- * serial EEPROM Setup default pattern. Only
- * change those values different from the values
- * in tul_nvram.
- */
-void
-tul_se2_update_all(iot, ioh)
- bus_space_tag_t iot;
- bus_space_handle_t ioh;
-{
- u_int16_t *np, *np1;
- u_int32_t chksum;
- u_int8_t i;
-
- /* Enable erase/write state of EEPROM */
- tul_se2_instr(iot, ioh, ENABLE_ERASE);
- bus_space_write_1(iot, ioh, TUL_NVRAM, 0);
- DELAY(5);
-
- np = (u_int16_t *)tul_dftNvRam;
- np1 = (u_int16_t *)&tul_nvram;
-
- for (i = 0, chksum = 0; i < 31; i++, np++, np1++) {
- if (*np != *np1)
- tul_se2_wr(iot, ioh, i, *np);
- chksum += *np;
- }
-
- chksum &= 0x0000ffff;
- tul_se2_wr(iot, ioh, 31, chksum);
-
- /* Disable erase/write state of EEPROM */
- tul_se2_instr(iot, ioh, 0);
- bus_space_write_1(iot, ioh, TUL_NVRAM, 0);
- DELAY(5);
-}
-
-/*
- * tul_se2_wr - write the given 16 bit value into the Serial EEPROM
- * at the specified offset
- */
-void
-tul_se2_wr(iot, ioh, addr, writeWord)
- bus_space_tag_t iot;
- bus_space_handle_t ioh;
- u_int8_t addr;
- u_int16_t writeWord;
-{
- u_int8_t bit;
- int i;
-
- /* send 'WRITE' Instruction == address | WRITE bit */
- tul_se2_instr(iot, ioh, (addr | WRITE));
-
- for (i = 15; i >= 0; i--, writeWord <<= 1) {
- if (writeWord & 0x8000)
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS | NVRDO);
- else
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS);
- DELAY(5);
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS | NVRCK);
- DELAY(5);
- }
-
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS);
- DELAY(5);
- bus_space_write_1(iot, ioh, TUL_NVRAM, 0);
- DELAY(5);
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS);
- DELAY(5);
-
- for (;;) {
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS | NVRCK);
- DELAY(5);
- bus_space_write_1(iot, ioh, TUL_NVRAM, NVRCS);
- DELAY(5);
- bit = bus_space_read_1(iot, ioh, TUL_NVRAM) & NVRDI;
- DELAY(5);
- if (bit != 0)
- break; /* write complete */
- }
-
- bus_space_write_1(iot, ioh, TUL_NVRAM, 0);
- DELAY(5);
-}
-
-/*
- * tul_se2_rd - read & return the 16 bit value at the specified
+ * iha_se2_rd - read & return the 16 bit value at the specified
* offset in the Serial E2PROM
*
*/
u_int16_t
-tul_se2_rd(iot, ioh, addr)
+iha_se2_rd(iot, ioh, addr)
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t addr;
@@ -2863,7 +2690,7 @@ tul_se2_rd(iot, ioh, addr)
int i;
/* Send 'READ' instruction == address | READ bit */
- tul_se2_instr(iot, ioh, (addr | READ));
+ iha_se2_instr(iot, ioh, (addr | READ));
readWord = 0;
for (i = 15; i >= 0; i--) {
@@ -2887,39 +2714,38 @@ tul_se2_rd(iot, ioh, addr)
}
/*
- * tul_se2_rd_all - Read SCSI H/A config parameters from serial EEPROM
- * into tul_nvram static variable.
+ * iha_se2_rd_all - Read SCSI H/A config parameters from serial EEPROM
+ * into iha_nvram variable.
*/
int
-tul_se2_rd_all(iot, ioh)
+iha_se2_rd_all(iot, ioh)
bus_space_tag_t iot;
bus_space_handle_t ioh;
{
- u_int16_t *np, *np1;
+ u_int16_t *np;
u_int32_t chksum;
u_int8_t i;
- np = (u_int16_t *)&tul_nvram;
- np1 = (u_int16_t *)&tul_dftNvRam;
+ np = (u_int16_t *)&iha_nvram;
- for (i = 0, chksum = 0; i < 31; i++, np++, np1++) {
- *np = tul_se2_rd(iot, ioh, i);
+ for (i = 0, chksum = 0; i < 31; i++, np++) {
+ *np = iha_se2_rd(iot, ioh, i);
chksum += *np;
}
- *np = tul_se2_rd(iot, ioh, 31); /* read checksum from eeprom */
+ *np = iha_se2_rd(iot, ioh, 31); /* read checksum from eeprom */
chksum &= 0x0000ffff; /* calculated checksum is lower 16 bits of sum */
- return (tul_nvram.NVM_Signature == SIGNATURE)
+ return (iha_nvram.NVM_Signature == SIGNATURE)
&&
- (tul_nvram.NVM_CheckSum == chksum);
+ (iha_nvram.NVM_CheckSum == chksum);
}
/*
- * tul_se2_instr - write an octet to serial E2PROM one bit at a time
+ * iha_se2_instr - write an octet to serial E2PROM one bit at a time
*/
void
-tul_se2_instr(iot, ioh, instr)
+iha_se2_instr(iot, ioh, instr)
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t instr;
@@ -2953,13 +2779,13 @@ tul_se2_instr(iot, ioh, instr)
}
/*
- * tul_reset_tcs - reset the target control structure pointed
+ * iha_reset_tcs - reset the target control structure pointed
* to by pTcs to default values. TCS_Flags
* only has the negotiation done bits reset as
* the other bits are fixed at initialization.
*/
void
-tul_reset_tcs(pTcs, config0)
+iha_reset_tcs(pTcs, config0)
struct tcs *pTcs;
u_int8_t config0;
{
diff --git a/sys/dev/ic/iha.h b/sys/dev/ic/iha.h
index 133008149d2..c43ada91fbd 100644
--- a/sys/dev/ic/iha.h
+++ b/sys/dev/ic/iha.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iha.h,v 1.4 2001/07/10 23:30:39 krw Exp $ */
+/* $OpenBSD: iha.h,v 1.5 2001/07/13 03:24:20 krw Exp $ */
/*
* Initio INI-9xxxU/UW SCSI Device Driver
*
@@ -192,7 +192,7 @@ struct iha_softc {
* EEPROM for one SCSI Channel
*
*/
-struct nvram_scsi {
+struct iha_nvram_scsi {
u_int8_t NVM_SCSI_Id; /* 0x00 Channel Adapter SCSI Id */
u_int8_t NVM_SCSI_Cfg; /* 0x01 Channel configuration */
#define CFG_SCSI_RESET 0x0001 /* Reset bus at power up */
@@ -201,19 +201,17 @@ struct nvram_scsi {
#define CFG_ACT_TERM2 0x0008 /* Enable active term 2 */
#define CFG_AUTO_TERM 0x0010 /* Enable auto terminator */
#define CFG_EN_PWR 0x0080 /* Enable power mgmt */
-#define CFG_DEFAULT (CFG_SCSI_RESET | CFG_AUTO_TERM | CFG_EN_PAR)
u_int8_t NVM_SCSI_CfgByte2; /* 0x02 Unused Channel Cfg byte 2*/
u_int8_t NVM_SCSI_Targets; /* 0x03 Number of SCSI targets */
/* 0x04 Lower bytes of targ flags*/
u_int8_t NVM_SCSI_TargetFlags[IHA_MAX_TARGETS];
-#define FLAG_DEFAULT (FLAG_NO_WIDE | FLAG_1GIGA | FLAG_EN_DISC)
};
/*
* Tulip (aka ini-950) Serial EEPROM Layout
*
*/
-struct nvram {
+struct iha_nvram {
/* ---------- Header ------------------------------------------------*/
u_int16_t NVM_Signature; /* 0x00 NVRAM Signature */
#define SIGNATURE 0xC925
@@ -239,7 +237,7 @@ struct nvram {
#define HACFG_LUNMASK 0x70 /* Boot LUN number */
#define HACFG_CHANMASK 0x80 /* Boot Channel number */
u_int8_t NVM_HAConfig2; /* 0x0b Host adapter config 2 */
- struct nvram_scsi NVM_Scsi[2]; /* 0x0c */
+ struct iha_nvram_scsi NVM_Scsi[2]; /* 0x0c */
u_int8_t NVM_Reserved[10]; /* 0x34 */
/* --------- CheckSum -----------------------------------------------*/
diff --git a/sys/dev/pci/iha_pci.c b/sys/dev/pci/iha_pci.c
index ddbf4fae032..f45995be5ec 100644
--- a/sys/dev/pci/iha_pci.c
+++ b/sys/dev/pci/iha_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iha_pci.c,v 1.3 2001/06/12 15:40:32 niklas Exp $ */
+/* $OpenBSD: iha_pci.c,v 1.4 2001/07/13 03:24:19 krw Exp $ */
/*
* Initio INI-9xxxU/UW SCSI Device Driver
*
@@ -53,14 +53,14 @@
#include <dev/ic/iha.h>
-static int iha_pci_probe __P((struct device *, void *, void *));
-static void iha_pci_attach __P((struct device *, struct device *, void *));
+int iha_pci_probe __P((struct device *, void *, void *));
+void iha_pci_attach __P((struct device *, struct device *, void *));
struct cfattach iha_pci_ca = {
sizeof(struct iha_softc), iha_pci_probe, iha_pci_attach
};
-static int
+int
iha_pci_probe(parent, match, aux)
struct device *parent;
void *match;
@@ -78,7 +78,7 @@ iha_pci_probe(parent, match, aux)
return (0);
}
-static void
+void
iha_pci_attach(parent, self, aux)
struct device *parent;
struct device *self;