summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-05-07 23:19:00 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-05-07 23:19:00 +0000
commit78109a53c2792421e2abc3239f814e9735943ac9 (patch)
treeddddfd8bc96d0a83ece23e99e0ef926858acfbfb /sys/dev
parent1da498271a610e2cbfba3f83899919ff81ea213a (diff)
Add remaining glue for physical disk count.
Fix a bugglet in the size of GDT_IOCHAN_DESC structure.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/gdt_common.c54
-rw-r--r--sys/dev/ic/gdtreg.h19
-rw-r--r--sys/dev/ic/gdtvar.h8
3 files changed, 68 insertions, 13 deletions
diff --git a/sys/dev/ic/gdt_common.c b/sys/dev/ic/gdt_common.c
index e05ce2dac8b..16e80a94ab2 100644
--- a/sys/dev/ic/gdt_common.c
+++ b/sys/dev/ic/gdt_common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gdt_common.c,v 1.34 2006/05/07 20:46:00 marco Exp $ */
+/* $OpenBSD: gdt_common.c,v 1.35 2006/05/07 23:18:59 marco Exp $ */
/*
* Copyright (c) 1999, 2000, 2003 Niklas Hallqvist. All rights reserved.
@@ -312,7 +312,7 @@ gdt_attach(gdt)
/* Read more information */
if (gdt->sc_more_proc) {
- int bus;
+ int bus, j;
/* physical drives, channel addresses */
/* step 1: get magical bus number from firmware */
gdt_enc32(gdt->sc_scratch + GDT_IOC_VERSION, GDT_IOC_NEWEST);
@@ -322,7 +322,7 @@ gdt_attach(gdt)
gdt_enc32(gdt->sc_scratch + GDT_IOC_LIST_OFFSET, GDT_IOC_HDR_SZ);
if (gdt_internal_cmd(gdt, GDT_CACHESERVICE, GDT_IOCTL,
GDT_IOCHAN_DESC, GDT_INVALID_CHANNEL,
- GDT_IOC_HDR_SZ + GDT_IOC_SZ)) {
+ GDT_IOC_HDR_SZ + GDT_IOC_SZ * GDT_MAXBUS)) {
GDT_DPRINTF(GDT_D_INFO, ("method 1\n"));
for (bus = 0; bus < gdt->sc_bus_cnt; bus++) {
gdt->sc_raw[bus].ra_address =
@@ -353,6 +353,52 @@ gdt_attach(gdt)
gdt->sc_raw[bus].ra_local_no));
}
}
+ /* step 2: use magical bus number to get nr of phys disks */
+ for (bus = 0; bus < gdt->sc_bus_cnt; bus++) {
+ gdt_enc32(gdt->sc_scratch + GDT_GETCH_CHANNEL_NO,
+ gdt->sc_raw[bus].ra_local_no);
+ if (gdt_internal_cmd(gdt, GDT_CACHESERVICE, GDT_IOCTL,
+ GDT_SCSI_CHAN_CNT | GDT_L_CTRL_PATTERN,
+ gdt->sc_raw[bus].ra_address | GDT_INVALID_CHANNEL,
+ GDT_GETCH_SZ)) {
+ gdt->sc_raw[bus].ra_phys_cnt =
+ gdt_dec32(gdt->sc_scratch +
+ GDT_GETCH_DRIVE_CNT);
+ GDT_DPRINTF(GDT_D_INFO, ("chan: %d disks: %d\n",
+ bus, gdt->sc_raw[bus].ra_phys_cnt));
+ }
+
+ /* step 3: get scsi disk nr */
+ if (gdt->sc_raw[bus].ra_phys_cnt > 0) {
+ gdt_enc32(gdt->sc_scratch +
+ GDT_GETSCSI_CHAN,
+ gdt->sc_raw[bus].ra_local_no);
+ gdt_enc32(gdt->sc_scratch +
+ GDT_GETSCSI_CNT,
+ gdt->sc_raw[bus].ra_phys_cnt);
+ if (gdt_internal_cmd(gdt, GDT_CACHESERVICE,
+ GDT_IOCTL,
+ GDT_SCSI_DR_LIST | GDT_L_CTRL_PATTERN,
+ gdt->sc_raw[bus].ra_address |
+ GDT_INVALID_CHANNEL,
+ GDT_GETSCSI_SZ))
+ for (j = 0;
+ j < gdt->sc_raw[bus].ra_phys_cnt;
+ j++) {
+ gdt->sc_raw[bus].ra_id_list[j] =
+ gdt_dec32(gdt->sc_scratch +
+ GDT_GETSCSI_LIST +
+ GDT_GETSCSI_LIST_SZ * j);
+ GDT_DPRINTF(GDT_D_INFO,
+ (" diskid: %d\n",
+ gdt->sc_raw[bus].ra_id_list[j]));
+ }
+ else
+ gdt->sc_raw[bus].ra_phys_cnt = 0;
+ }
+ /* add found disks to grand total */
+ gdt->sc_total_disks += gdt->sc_raw[bus].ra_phys_cnt;
+ }
} /* if (gdt->sc_more_proc) */
if (!gdt_internal_cmd(gdt, GDT_SCSIRAWSERVICE, GDT_INIT, 0, 0, 0)) {
@@ -1464,7 +1510,7 @@ int
gdt_ioctl_inq(struct gdt_softc *sc, struct bioc_inq *bi)
{
bi->bi_novol = sc->sc_ndevs;
- bi->bi_nodisk = 0;
+ bi->bi_nodisk = sc->sc_total_disks;
strlcpy(bi->bi_dev, DEVNAME(sc), sizeof(bi->bi_dev));
diff --git a/sys/dev/ic/gdtreg.h b/sys/dev/ic/gdtreg.h
index e3758577af5..7ab6e9c58d7 100644
--- a/sys/dev/ic/gdtreg.h
+++ b/sys/dev/ic/gdtreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gdtreg.h,v 1.3 2003/06/03 20:49:28 deraadt Exp $ */
+/* $OpenBSD: gdtreg.h,v 1.4 2006/05/07 23:18:59 marco Exp $ */
/*
* Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved.
@@ -95,10 +95,10 @@
#define GDT_IOCHAN_DESC 0x5d /* description of IO channel */
#define GDT_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */
-#define GDT_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */
+#define GDT_L_CTRL_PATTERN 0x20000000L /* SCSI IOCTL mask */
#define GDT_ARRAY_INFO 0x12 /* array drive info */
#define GDT_ARRAY_DRV_LIST 0x0f /* array drive list */
-#define GDT_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */
+#define GDT_LA_CTRL_PATTERN 0x10000000L /* array IOCTL mask */
#define GDT_CACHE_DRV_CNT 0x01 /* cache drive count */
#define GDT_CACHE_DRV_LIST 0x02 /* cache drive list */
#define GDT_CACHE_INFO 0x04 /* cache info */
@@ -106,9 +106,9 @@
#define GDT_CACHE_DRV_INFO 0x07 /* cache drive info */
#define GDT_BOARD_FEATURES 0x15 /* controller features */
#define GDT_BOARD_INFO 0x28 /* controller info */
-#define GDT_HOST_GET 0x10001 /* get host drive list */
-#define GDT_IO_CHANNEL 0x20000 /* default IO channel */
-#define GDT_INVALID_CHANNEL 0xffff /* invalid channel */
+#define GDT_HOST_GET 0x10001L /* get host drive list */
+#define GDT_IO_CHANNEL 0x20000L /* default IO channel */
+#define GDT_INVALID_CHANNEL 0xffffL /* invalid channel */
/* XXX not belonging here */
/* IOCTLs */
@@ -234,6 +234,13 @@
#define GDT_GETCH_SIOP_STATE 0x09 /* u_int8_t, SCSI processor state */
#define GDT_GETCH_SZ 0x0a
+/* Get SCSI drive numbers */
+#define GDT_GETSCSI_CHAN 0x00 /* u_int32_t, scsi channel number */
+#define GDT_GETSCSI_CNT 0x04 /* u_int32_t, nr of entries */
+#define GDT_GETSCSI_LIST 0x08 /* u_int32_t, minor device nr */
+#define GDT_GETSCSI_LIST_SZ 0x04
+#define GDT_GETSCSI_SZ (GDT_GETSCSI_LIST_SZ * GDT_MAXID)
+
/* Cache info/config IOCTL structures */
#define GDT_CPAR_VERSION 0x00 /* u_int32_t, firmware version */
#define GDT_CPAR_STATE 0x04 /* u_int16_t, cache state (on/off) */
diff --git a/sys/dev/ic/gdtvar.h b/sys/dev/ic/gdtvar.h
index e801b7a443c..25b21838c1a 100644
--- a/sys/dev/ic/gdtvar.h
+++ b/sys/dev/ic/gdtvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gdtvar.h,v 1.11 2006/05/07 20:34:09 marco Exp $ */
+/* $OpenBSD: gdtvar.h,v 1.12 2006/05/07 23:18:59 marco Exp $ */
/*
* Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved.
@@ -320,6 +320,8 @@ struct gdt_softc {
u_int8_t sc_bus_id[GDT_MAXBUS];
u_int8_t sc_more_proc;
+ u_int32_t sc_total_disks;
+
struct {
u_int8_t hd_present;
u_int8_t hd_is_logdrv;
@@ -344,7 +346,7 @@ struct gdt_softc {
u_int8_t ra_local_no; /* local channel number */
u_int8_t ra_io_cnt[GDT_MAXID]; /* current IO count */
u_int32_t ra_address; /* channel address */
- u_int32_t ra_id_lis[GDT_MAXID]; /* IDs of phys disks */
+ u_int32_t ra_id_list[GDT_MAXID]; /* IDs of phys disks */
} sc_raw[GDT_MAXBUS]; /* SCSI channels */
struct {
@@ -438,7 +440,7 @@ static __inline__ u_int8_t
gdt_dec8(addr)
u_int8_t *addr;
{
- return *addr;
+ return *(u_int8_t *)addr;
}
static __inline__ u_int16_t