1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Fix probes when a port address is specified.

This commit is contained in:
Justin T. Gibbs 1998-11-10 06:44:54 +00:00
parent d0993d7584
commit 3c1cabf7a2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=41048
9 changed files with 157 additions and 143 deletions

View File

@ -44,7 +44,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: adv_isa.c,v 1.5 1998/10/10 00:44:12 imp Exp $
* $Id: adv_isa.c,v 1.6 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -122,7 +122,7 @@ advisaprobe(struct isa_device *id)
if (id->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (id->id_iobase >= adv_isa_ioports[port_index])
if (id->id_iobase <= adv_isa_ioports[port_index])
break;
if ((port_index > max_port_index)
|| (id->id_iobase != adv_isa_ioports[port_index])) {

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: aha_isa.c,v 1.3 1998/10/10 00:44:12 imp Exp $
* $Id: aha_isa.c,v 1.4 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -68,7 +68,7 @@ aha_isa_probe(dev)
*/
struct aha_softc *aha;
int port_index;
int max_port_index;
int max_port_index;
/*
* We ignore the unit number assigned by config to allow
@ -79,30 +79,15 @@ aha_isa_probe(dev)
dev->id_unit = aha_unit;
aha = NULL;
port_index = 0;
max_port_index = AHA_NUM_ISAPORTS - 1;
/*
* Bound our board search if the user has
* specified an exact port.
*/
if (dev->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (dev->id_iobase >= aha_isa_ports[port_index].addr)
break;
if ((port_index > max_port_index)
|| (dev->id_iobase != aha_isa_ports[port_index].addr)) {
printf("
aha_isa_probe: Invalid baseport of 0x%x specified.
aha_isa_probe: Nearest valid baseport is 0x%x.
aha_isa_probe: Failing probe.\n",
dev->id_iobase,
(port_index <= max_port_index)
? aha_isa_ports[port_index].addr
: aha_isa_ports[max_port_index].addr);
return 0;
}
max_port_index = port_index;
}
aha_find_probe_range(dev->id_iobase, &port_index, &max_port_index);
if (port_index < 0)
return 0;
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@ -110,7 +95,7 @@ aha_isa_probe: Failing probe.\n",
u_int ioport;
int error;
ioport = aha_isa_ports[port_index].addr;
ioport = aha_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
@ -118,7 +103,7 @@ aha_isa_probe: Failing probe.\n",
*/
if (aha_check_probed_iop(ioport) != 0)
continue;
dev->id_iobase = aha_isa_ports[port_index].addr;
dev->id_iobase = ioport;
if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
continue;
@ -141,7 +126,7 @@ aha_isa_probe: Failing probe.\n",
* Determine our IRQ, and DMA settings and
* export them to the configuration system.
*/
error = aha_cmd(aha, BOP_INQUIRE_CONFIG, NULL, /*parmlen*/0,
error = aha_cmd(aha, AOP_INQUIRE_CONFIG, NULL, /*parmlen*/0,
(u_int8_t*)&config_data, sizeof(config_data),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
@ -166,6 +151,7 @@ aha_isa_probe: Failing probe.\n",
printf("aha_isa_probe: Invalid DMA setting "
"detected for adapter at 0x%x. "
"Failing probe\n", ioport);
return (0);
}
dev->id_irq = (config_data.irq << 9);
dev->id_intr = aha_isa_intr;

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bt.c,v 1.7 1998/10/15 23:46:28 gibbs Exp $
* $Id: bt.c,v 1.8 1998/10/30 02:06:44 gibbs Exp $
*/
/*
@ -181,12 +181,26 @@ u_long bt_unit = 0;
*/
struct bt_isa_port bt_isa_ports[] =
{
{ 0x330, 0 },
{ 0x334, 0 },
{ 0x230, 0 },
{ 0x234, 0 },
{ 0x130, 0 },
{ 0x134, 0 }
{ 0x130, 0, 4 },
{ 0x134, 0, 5 },
{ 0x230, 0, 2 },
{ 0x234, 0, 3 },
{ 0x330, 0, 0 },
{ 0x334, 0, 1 }
};
/*
* I/O ports listed in the order enumerated by the
* card for certain op codes.
*/
u_int16_t bt_board_ports[] =
{
0x330,
0x334,
0x230,
0x234,
0x130,
0x134
};
/* Exported functions */
@ -814,7 +828,7 @@ bt_check_probed_iop(u_int ioport)
{
u_int i;
for (i=0; i < BT_NUM_ISAPORTS; i++) {
for (i = 0; i < BT_NUM_ISAPORTS; i++) {
if (bt_isa_ports[i].addr == ioport) {
if (bt_isa_ports[i].probed != 0)
return (1);
@ -826,17 +840,11 @@ bt_check_probed_iop(u_int ioport)
return (1);
}
u_int
bt_fetch_isa_iop(isa_compat_io_t port)
{
return (bt_isa_ports[port].addr);
}
void
bt_mark_probed_bio(isa_compat_io_t port)
{
if (port < BIO_DISABLED)
bt_isa_ports[port].probed = 1;
bt_mark_probed_iop(bt_board_ports[port]);
}
void
@ -852,6 +860,44 @@ bt_mark_probed_iop(u_int ioport)
}
}
void
bt_find_probe_range(int ioport, int *port_index, int *max_port_index)
{
if (ioport > 0) {
int i;
for (i = 0;i < BT_NUM_ISAPORTS; i++)
if (ioport <= bt_isa_ports[i].addr)
break;
if ((i >= BT_NUM_ISAPORTS)
|| (ioport != bt_isa_ports[i].addr)) {
printf("
bt_isa_probe: Invalid baseport of 0x%x specified.
bt_isa_probe: Nearest valid baseport is 0x%x.
bt_isa_probe: Failing probe.\n",
ioport,
(i < BT_NUM_ISAPORTS)
? bt_isa_ports[i].addr
: bt_isa_ports[BT_NUM_ISAPORTS - 1].addr);
*port_index = *max_port_index = -1;
return;
}
*port_index = *max_port_index = bt_isa_ports[i].bio;
} else {
*port_index = 0;
*max_port_index = BT_NUM_ISAPORTS - 1;
}
}
int
bt_iop_from_bio(isa_compat_io_t bio_index)
{
if (bio_index >= 0 && bio_index < BT_NUM_ISAPORTS)
return (bt_board_ports[bio_index]);
return (-1);
}
static void
btallocccbs(struct bt_softc *bt)
{
@ -924,6 +970,7 @@ btfreeccb(struct bt_softc *bt, struct bt_ccb *bccb)
}
bccb->flags = BCCB_FREE;
SLIST_INSERT_HEAD(&bt->free_bt_ccbs, bccb, links);
bt->active_ccbs--;
splx(s);
}
@ -936,13 +983,16 @@ btgetccb(struct bt_softc *bt)
s = splcam();
if ((bccb = SLIST_FIRST(&bt->free_bt_ccbs)) != NULL) {
SLIST_REMOVE_HEAD(&bt->free_bt_ccbs, links);
bt->active_ccbs++;
} else if (bt->num_ccbs < bt->max_ccbs) {
btallocccbs(bt);
bccb = SLIST_FIRST(&bt->free_bt_ccbs);
if (bccb == NULL)
printf("%s: Can't malloc BCCB\n", bt_name(bt));
else
else {
SLIST_REMOVE_HEAD(&bt->free_bt_ccbs, links);
bt->active_ccbs++;
}
}
splx(s);
@ -1347,8 +1397,27 @@ btexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
/* Tell the adapter about this command */
bt->cur_outbox->ccb_addr = btccbvtop(bt, bccb);
if (bt->cur_outbox->action_code != BMBO_FREE)
panic("%s: Too few mailboxes or to many ccbs???", bt_name(bt));
if (bt->cur_outbox->action_code != BMBO_FREE) {
/*
* We should never encounter a busy mailbox.
* If we do, warn the user, and treat it as
* a resource shortage. If the controller is
* hung, one of the pending transactions will
* timeout causing us to start recovery operations.
*/
printf("%s: Encountered busy mailbox with %d out of %d "
"commands active!!!", bt_name(bt), bt->active_ccbs,
bt->max_ccbs);
untimeout(bttimeout, bccb, ccb->ccb_h.timeout_ch);
if (nseg != 0)
bus_dmamap_unload(bt->buffer_dmat, bccb->dmamap);
btfreeccb(bt, bccb);
bt->resource_shortage = TRUE;
xpt_freeze_simq(bt->sim, /*count*/1);
ccb->ccb_h.status = CAM_REQUEUE_REQ;
xpt_done(ccb);
return;
}
bt->cur_outbox->action_code = BMBO_START;
bt_outb(bt, COMMAND_REG, BOP_START_MBOX);
btnextoutbox(bt);
@ -1469,14 +1538,20 @@ btdone(struct bt_softc *bt, struct bt_ccb *bccb, bt_mbi_comp_code_t comp_code)
break;
case BMBI_ABORT:
case BMBI_ERROR:
#if 0
printf("bt: ccb %x - error %x occured. btstat = %x, sdstat = %x\n",
bccb, comp_code, bccb->hccb.btstat, bccb->hccb.sdstat);
#endif
printf("bt: ccb %p - error %x occured. "
"btstat = %x, sdstat = %x\n",
(void *)bccb, comp_code, bccb->hccb.btstat,
bccb->hccb.sdstat);
/* An error occured */
switch(bccb->hccb.btstat) {
case BTSTAT_DATARUN_ERROR:
if (bccb->hccb.data_len <= 0) {
if (bccb->hccb.data_len == 0) {
/*
* At least firmware 4.22, does this
* for a QUEUE FULL condition.
*/
bccb->hccb.sdstat = SCSI_STATUS_QUEUE_FULL;
} else if (bccb->hccb.data_len < 0) {
csio->ccb_h.status = CAM_DATA_RUN_ERR;
break;
}

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bt_isa.c,v 1.3 1998/10/10 00:44:12 imp Exp $
* $Id: bt_isa.c,v 1.4 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -86,24 +86,10 @@ bt_isa_probe(dev)
* Bound our board search if the user has
* specified an exact port.
*/
if (dev->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (dev->id_iobase >= bt_isa_ports[port_index].addr)
break;
if ((port_index > max_port_index)
|| (dev->id_iobase != bt_isa_ports[port_index].addr)) {
printf("
bt_isa_probe: Invalid baseport of 0x%x specified.
bt_isa_probe: Nearest valid baseport is 0x%x.
bt_isa_probe: Failing probe.\n",
dev->id_iobase,
(port_index <= max_port_index)
? bt_isa_ports[port_index].addr
: bt_isa_ports[max_port_index].addr);
return 0;
}
max_port_index = port_index;
}
bt_find_probe_range(dev->id_iobase, &port_index, &max_port_index);
if (port_index < 0)
return 0;
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@ -111,7 +97,7 @@ bt_isa_probe: Failing probe.\n",
u_int ioport;
int error;
ioport = bt_isa_ports[port_index].addr;
ioport = bt_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
@ -119,7 +105,7 @@ bt_isa_probe: Failing probe.\n",
*/
if (bt_check_probed_iop(ioport) != 0)
continue;
dev->id_iobase = bt_isa_ports[port_index].addr;
dev->id_iobase = ioport;
if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
continue;
@ -169,6 +155,7 @@ bt_isa_probe: Failing probe.\n",
printf("bt_isa_probe: Invalid DMA setting "
"detected for adapter at 0x%x. "
"Failing probe\n", ioport);
return (0);
}
} else {
/* VL DMA */

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: btreg.h,v 1.1 1998/09/15 07:32:49 gibbs Exp $
* $Id: btreg.h,v 1.2 1998/10/30 02:06:44 gibbs Exp $
*/
#ifndef _BTREG_H_
@ -408,6 +408,7 @@ typedef struct {
struct bt_isa_port {
u_int16_t addr;
u_int8_t probed;
u_int8_t bio;
};
extern struct bt_isa_port bt_isa_ports[];
@ -549,7 +550,7 @@ struct bt_hccb {
wide_tag_type :2; /* Wide Lun CCB format */
u_int8_t cmd_len;
u_int8_t sense_len;
u_int32_t data_len;
int32_t data_len; /* residuals can be negative */
u_int32_t data_addr;
u_int8_t reserved[2];
u_int8_t btstat;
@ -599,6 +600,7 @@ struct bt_softc {
struct bt_ccb *bt_ccb_array;
SLIST_HEAD(,bt_ccb) free_bt_ccbs;
LIST_HEAD(,ccb_hdr) pending_ccbs;
u_int active_ccbs;
u_int32_t bt_ccb_physbase;
bt_mbox_in_t *in_boxes;
bt_mbox_out_t *out_boxes;
@ -664,9 +666,13 @@ int bt_attach(struct bt_softc *bt);
void bt_intr(void *arg);
char * bt_name(struct bt_softc *bt);
int bt_check_probed_iop(u_int ioport);
u_int bt_fetch_isa_iop(isa_compat_io_t port);
void bt_mark_probed_bio(isa_compat_io_t port);
void bt_mark_probed_iop(u_int ioport);
void bt_find_probe_range(int ioport,
int *port_index,
int *max_port_index);
int bt_iop_from_bio(isa_compat_io_t bio_index);
#define DEFAULT_CMD_TIMEOUT 10000 /* 1 sec */
int bt_cmd(struct bt_softc *bt, bt_op_t opcode,

View File

@ -44,7 +44,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: adv_isa.c,v 1.5 1998/10/10 00:44:12 imp Exp $
* $Id: adv_isa.c,v 1.6 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -122,7 +122,7 @@ advisaprobe(struct isa_device *id)
if (id->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (id->id_iobase >= adv_isa_ioports[port_index])
if (id->id_iobase <= adv_isa_ioports[port_index])
break;
if ((port_index > max_port_index)
|| (id->id_iobase != adv_isa_ioports[port_index])) {

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: aha_isa.c,v 1.3 1998/10/10 00:44:12 imp Exp $
* $Id: aha_isa.c,v 1.4 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -68,7 +68,7 @@ aha_isa_probe(dev)
*/
struct aha_softc *aha;
int port_index;
int max_port_index;
int max_port_index;
/*
* We ignore the unit number assigned by config to allow
@ -79,30 +79,15 @@ aha_isa_probe(dev)
dev->id_unit = aha_unit;
aha = NULL;
port_index = 0;
max_port_index = AHA_NUM_ISAPORTS - 1;
/*
* Bound our board search if the user has
* specified an exact port.
*/
if (dev->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (dev->id_iobase >= aha_isa_ports[port_index].addr)
break;
if ((port_index > max_port_index)
|| (dev->id_iobase != aha_isa_ports[port_index].addr)) {
printf("
aha_isa_probe: Invalid baseport of 0x%x specified.
aha_isa_probe: Nearest valid baseport is 0x%x.
aha_isa_probe: Failing probe.\n",
dev->id_iobase,
(port_index <= max_port_index)
? aha_isa_ports[port_index].addr
: aha_isa_ports[max_port_index].addr);
return 0;
}
max_port_index = port_index;
}
aha_find_probe_range(dev->id_iobase, &port_index, &max_port_index);
if (port_index < 0)
return 0;
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@ -110,7 +95,7 @@ aha_isa_probe: Failing probe.\n",
u_int ioport;
int error;
ioport = aha_isa_ports[port_index].addr;
ioport = aha_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
@ -118,7 +103,7 @@ aha_isa_probe: Failing probe.\n",
*/
if (aha_check_probed_iop(ioport) != 0)
continue;
dev->id_iobase = aha_isa_ports[port_index].addr;
dev->id_iobase = ioport;
if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
continue;
@ -141,7 +126,7 @@ aha_isa_probe: Failing probe.\n",
* Determine our IRQ, and DMA settings and
* export them to the configuration system.
*/
error = aha_cmd(aha, BOP_INQUIRE_CONFIG, NULL, /*parmlen*/0,
error = aha_cmd(aha, AOP_INQUIRE_CONFIG, NULL, /*parmlen*/0,
(u_int8_t*)&config_data, sizeof(config_data),
DEFAULT_CMD_TIMEOUT);
if (error != 0) {
@ -166,6 +151,7 @@ aha_isa_probe: Failing probe.\n",
printf("aha_isa_probe: Invalid DMA setting "
"detected for adapter at 0x%x. "
"Failing probe\n", ioport);
return (0);
}
dev->id_irq = (config_data.irq << 9);
dev->id_intr = aha_isa_intr;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bt_isa.c,v 1.3 1998/10/10 00:44:12 imp Exp $
* $Id: bt_isa.c,v 1.4 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -86,24 +86,10 @@ bt_isa_probe(dev)
* Bound our board search if the user has
* specified an exact port.
*/
if (dev->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (dev->id_iobase >= bt_isa_ports[port_index].addr)
break;
if ((port_index > max_port_index)
|| (dev->id_iobase != bt_isa_ports[port_index].addr)) {
printf("
bt_isa_probe: Invalid baseport of 0x%x specified.
bt_isa_probe: Nearest valid baseport is 0x%x.
bt_isa_probe: Failing probe.\n",
dev->id_iobase,
(port_index <= max_port_index)
? bt_isa_ports[port_index].addr
: bt_isa_ports[max_port_index].addr);
return 0;
}
max_port_index = port_index;
}
bt_find_probe_range(dev->id_iobase, &port_index, &max_port_index);
if (port_index < 0)
return 0;
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@ -111,7 +97,7 @@ bt_isa_probe: Failing probe.\n",
u_int ioport;
int error;
ioport = bt_isa_ports[port_index].addr;
ioport = bt_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
@ -119,7 +105,7 @@ bt_isa_probe: Failing probe.\n",
*/
if (bt_check_probed_iop(ioport) != 0)
continue;
dev->id_iobase = bt_isa_ports[port_index].addr;
dev->id_iobase = ioport;
if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
continue;
@ -169,6 +155,7 @@ bt_isa_probe: Failing probe.\n",
printf("bt_isa_probe: Invalid DMA setting "
"detected for adapter at 0x%x. "
"Failing probe\n", ioport);
return (0);
}
} else {
/* VL DMA */

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bt_isa.c,v 1.3 1998/10/10 00:44:12 imp Exp $
* $Id: bt_isa.c,v 1.4 1998/10/12 18:53:33 imp Exp $
*/
#include <sys/param.h>
@ -86,24 +86,10 @@ bt_isa_probe(dev)
* Bound our board search if the user has
* specified an exact port.
*/
if (dev->id_iobase > 0) {
for (;port_index <= max_port_index; port_index++)
if (dev->id_iobase >= bt_isa_ports[port_index].addr)
break;
if ((port_index > max_port_index)
|| (dev->id_iobase != bt_isa_ports[port_index].addr)) {
printf("
bt_isa_probe: Invalid baseport of 0x%x specified.
bt_isa_probe: Nearest valid baseport is 0x%x.
bt_isa_probe: Failing probe.\n",
dev->id_iobase,
(port_index <= max_port_index)
? bt_isa_ports[port_index].addr
: bt_isa_ports[max_port_index].addr);
return 0;
}
max_port_index = port_index;
}
bt_find_probe_range(dev->id_iobase, &port_index, &max_port_index);
if (port_index < 0)
return 0;
/* Attempt to find an adapter */
for (;port_index <= max_port_index; port_index++) {
@ -111,7 +97,7 @@ bt_isa_probe: Failing probe.\n",
u_int ioport;
int error;
ioport = bt_isa_ports[port_index].addr;
ioport = bt_iop_from_bio(port_index);
/*
* Ensure this port has not already been claimed already
@ -119,7 +105,7 @@ bt_isa_probe: Failing probe.\n",
*/
if (bt_check_probed_iop(ioport) != 0)
continue;
dev->id_iobase = bt_isa_ports[port_index].addr;
dev->id_iobase = ioport;
if (haveseen_isadev(dev, CC_IOADDR | CC_QUIET))
continue;
@ -169,6 +155,7 @@ bt_isa_probe: Failing probe.\n",
printf("bt_isa_probe: Invalid DMA setting "
"detected for adapter at 0x%x. "
"Failing probe\n", ioport);
return (0);
}
} else {
/* VL DMA */