Module Name: src
Committed By: tsutsui
Date: Fri Jan 10 11:12:03 UTC 2014
Modified Files:
src/sys/arch/luna68k/stand/boot: Makefile autoconf.c boot.c devopen.c
if_le.c init_main.c samachdep.h sc.c scsivar.h sd.c version
Removed Files:
src/sys/arch/luna68k/stand/boot: device.h ioconf.c
Log Message:
Reorgenize boot device configuration. The idea is taken from OpenBSD/luna88k.
- remove kernel-like autoconfiguration to probe bootable devices
- initialize SCSI and Ethernet controllers statically instead
- reorganize device softc structures per autoconf removal
- probe and print all SCSI disks (but don't assign unit numbers)
- make sdopen() to recheck the device and allocate softc dynamically
- use controller number and SCSI target ID (ctlr * 10 + id) to specify
the boot disk on the "boot" command arg
- bump version to denote changes
Now bootloader works as the following:
---
>> NetBSD/luna68k boot, Revision 1.8 (Wed Jan 8 22:13:12 JST 2014)
>> (based on Stinger ver 0.0 [Phase-31])
Machine model = LUNA-II
Physical Memory = 0x4000000 (64 MB)
sc0 at 0xe1000000: async, parity, ID 7
ID 3: TEAC FC-1 HGF 10 rev , 512 bytes/sect x 2879 sectors
ID 6: IBM DPES-31080 rev S31Q, 512 bytes/sect x 2118143 sectors
sc1 at 0xe1000040: async, parity, ID 7
ID 6: MELCO DSC-G rev 1.00, 512 bytes/sect x 62533295 sectors
le0: Am7990 LANCE Ethernet, mem at 0x71010000
le0: Ethernet address = 00:00:0a:03:42:77
Press return to boot now, any other key for boot menu
booting sd(16,0)netbsd - starting in 0 seconds.
auto-boot sd(16,0)netbsd
1911696+96040 [280480+159179]=0x255a30
:
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/luna68k/stand/boot/Makefile \
src/sys/arch/luna68k/stand/boot/autoconf.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/boot.c \
src/sys/arch/luna68k/stand/boot/devopen.c \
src/sys/arch/luna68k/stand/boot/if_le.c
cvs rdiff -u -r1.7 -r0 src/sys/arch/luna68k/stand/boot/device.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/luna68k/stand/boot/init_main.c \
src/sys/arch/luna68k/stand/boot/sc.c src/sys/arch/luna68k/stand/boot/sd.c \
src/sys/arch/luna68k/stand/boot/version
cvs rdiff -u -r1.5 -r0 src/sys/arch/luna68k/stand/boot/ioconf.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/luna68k/stand/boot/samachdep.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/stand/boot/scsivar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/luna68k/stand/boot/Makefile
diff -u src/sys/arch/luna68k/stand/boot/Makefile:1.9 src/sys/arch/luna68k/stand/boot/Makefile:1.10
--- src/sys/arch/luna68k/stand/boot/Makefile:1.9 Tue Jan 22 15:48:40 2013
+++ src/sys/arch/luna68k/stand/boot/Makefile Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $
+# $NetBSD: Makefile,v 1.10 2014/01/10 11:12:03 tsutsui Exp $
# @(#)Makefile 8.2 (Berkeley) 8/15/93
NOMAN= # defined
@@ -32,7 +32,7 @@ LDSCRIPT= ${.CURDIR}/boot.ldscript
LINKFORMAT= -static -N -Ttext ${TEXTADDR} -T ${LDSCRIPT}
SRCS= locore.S
-SRCS+= init_main.c autoconf.c ioconf.c
+SRCS+= init_main.c autoconf.c
SRCS+= trap.c
SRCS+= devopen.c
SRCS+= conf.c
Index: src/sys/arch/luna68k/stand/boot/autoconf.c
diff -u src/sys/arch/luna68k/stand/boot/autoconf.c:1.9 src/sys/arch/luna68k/stand/boot/autoconf.c:1.10
--- src/sys/arch/luna68k/stand/boot/autoconf.c:1.9 Fri Jan 3 03:25:25 2014
+++ src/sys/arch/luna68k/stand/boot/autoconf.c Fri Jan 10 11:12:03 2014
@@ -1,10 +1,7 @@
-/* $NetBSD: autoconf.c,v 1.9 2014/01/03 03:25:25 tsutsui Exp $ */
+/* $NetBSD: autoconf.c,v 1.10 2014/01/10 11:12:03 tsutsui Exp $ */
-/*
- * Copyright (c) 1992 OMRON Corporation.
- *
- * This code is derived from software contributed to Berkeley by
- * OMRON Corporation.
+/*-
+ * Copyright (c) 2013 Izumi Tsutsui. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -14,437 +11,32 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
- */
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * OMRON Corporation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
*
- * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * autoconf.c -- Determine mass storage and memory configuration for a machine.
- * by A.Fujita, NOV-30-1991
- *
- * Modified by A.Fujita, FEB-04-1992
- */
-
-
-#include <sys/param.h>
-#include <sys/dkstat.h>
#include <machine/cpu.h>
-#include <lib/libkern/libkern.h>
#include <luna68k/stand/boot/samachdep.h>
-#include <luna68k/stand/boot/device.h>
-
-int dkn; /* number of iostat dk numbers assigned so far */
-struct hp_hw sc_table[MAX_CTLR];
-
-#ifdef DEBUG
-int acdebug = 1;
-#endif
-
-static int find_controller(struct hp_hw *);
-static int find_device(struct hp_hw *);
-static void find_slaves(struct hp_ctlr *);
-static int same_hw_device(struct hp_hw *, struct hp_device *);
-
-/*
- * Determine mass storage and memory configuration for a machine.
- */
-void
-configure(void)
-{
- struct hp_hw *hw;
- int found;
-
- /*
- * Look over each hardware device actually found and attempt
- * to match it with an ioconf.c table entry.
- */
- for (hw = sc_table; hw->hw_type; hw++) {
- if (hw->hw_type & CONTROLLER)
- found = find_controller(hw);
- else
- found = find_device(hw);
-#ifdef DEBUG
- if (!found) {
- printf("unconfigured %s ", hw->hw_name);
- printf("at 0x%x\n", (u_int)hw->hw_addr);
- }
-#endif
- }
-
-}
-
-#define dr_type(d, s) \
- (strcmp((d)->d_name, (s)) == 0)
-
-#define same_hw_ctlr(hw, hc) \
- ((hw)->hw_type == SCSI && dr_type((hc)->hp_driver, "sc"))
-
-int
-find_controller(struct hp_hw *hw)
-{
- struct hp_ctlr *hc;
- struct hp_ctlr *match_c;
- uint8_t *addr, *oaddr;
-
-#ifdef DEBUG
- if (acdebug)
- printf("find_controller: hw: %s at sc%d (%x), type %x...",
- hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
-#endif
- addr = hw->hw_addr;
- match_c = NULL;
- for (hc = hp_cinit; hc->hp_driver; hc++) {
- if (hc->hp_alive)
- continue;
- /*
- * Make sure we are looking at the right
- * controller type.
- */
- if (!same_hw_ctlr(hw, hc))
- continue;
- /*
- * Exact match; all done
- */
- if (hc->hp_addr == addr) {
- match_c = hc;
- break;
- }
- /*
- * Wildcard; possible match so remember first instance
- * but continue looking for exact match.
- */
- if ((int)hc->hp_addr == WILD_CARD_CTLR && match_c == NULL)
- match_c = hc;
- }
-#ifdef DEBUG
- if (acdebug) {
- if (match_c)
- printf("found %s%d\n",
- match_c->hp_driver->d_name,
- match_c->hp_unit);
- else
- printf("not found\n");
- }
-#endif
- /*
- * Didn't find an ioconf entry for this piece of hardware,
- * just ignore it.
- */
- if (match_c == NULL)
- return(0);
- /*
- * Found a match, attempt to initialize and configure all attached
- * slaves. Note, we can still fail if HW won't initialize.
- */
- hc = match_c;
- oaddr = hc->hp_addr;
- hc->hp_addr = hw->hw_addr;
- if ((*hc->hp_driver->d_init)(hc)) {
- hc->hp_alive = 1;
- printf("%s%d", hc->hp_driver->d_name, hc->hp_unit);
- printf(" at %p,", hc->hp_addr);
- printf(" ipl %d\n", hc->hp_ipl);
- find_slaves(hc);
- } else
- hc->hp_addr = oaddr;
- return(1);
-}
-
-int
-find_device(struct hp_hw *hw)
-{
- struct hp_device *hd;
- struct hp_device *match_d;
- uint8_t *addr, *oaddr;
-
-#ifdef DEBUG
- if (acdebug)
- printf("find_device: hw: %s at sc%d (%x), type %x...",
- hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
-#endif
- match_d = NULL;
- for (hd = hp_dinit; hd->hpd_driver; hd++) {
- if (hd->hpd_alive)
- continue;
- /* Must not be a slave */
- if (hd->hpd_cdriver)
- continue;
- addr = hd->hpd_addr;
- /*
- * Exact match; all done.
- */
- if (addr != NULL && addr == hw->hw_addr) {
- match_d = hd;
- break;
- }
- /*
- * Wildcard; possible match so remember first instance
- * but continue looking for exact match.
- */
- if (addr == NULL && same_hw_device(hw, hd) && match_d == NULL)
- match_d = hd;
- }
-#ifdef DEBUG
- if (acdebug) {
- if (match_d)
- printf("found %s%d\n",
- match_d->hpd_driver->d_name,
- match_d->hpd_unit);
- else
- printf("not found\n");
- }
-#endif
- /*
- * Didn't find an ioconf entry for this piece
- * of hardware, just ignore it.
- */
- if (match_d == NULL)
- return(0);
- /*
- * Found a match, attempt to initialize.
- * Note, we can still fail if HW won't initialize.
- */
- hd = match_d;
- oaddr = hd->hpd_addr;
- hd->hpd_addr = hw->hw_addr;
- if ((*hd->hpd_driver->d_init)(hd)) {
- hd->hpd_alive = 1;
- printf("%s%d", hd->hpd_driver->d_name, hd->hpd_unit);
- printf(" at %p\n", hd->hpd_addr);
- } else
- hd->hpd_addr = oaddr;
- return(1);
-}
-
-/*
- * Search each BUS controller found for slaves attached to it.
- * The bad news is that we don't know how to uniquely identify all slaves
- * (e.g. PPI devices on HP-IB). The good news is that we can at least
- * differentiate those from slaves we can identify. At worst (a totally
- * wildcarded entry) this will cause us to locate such a slave at the first
- * unused position instead of where it really is. To save grief, non-
- * identifing devices should always be fully qualified.
- */
-void
-find_slaves(struct hp_ctlr *hc)
-{
- int s;
- struct hp_device *hd;
- struct hp_device *match_s;
- int maxslaves = MAXSLAVES-1;
- int new_s, new_c, old_s, old_c;
- int rescan;
-
-#ifdef DEBUG
- if (acdebug)
- printf("find_slaves: for %s%d\n",
- hc->hp_driver->d_name, hc->hp_unit);
-#endif
- for (s = 0; s < maxslaves; s++) {
- rescan = 1;
- match_s = NULL;
- for (hd = hp_dinit; hd->hpd_driver; hd++) {
- /*
- * Rule out the easy ones:
- * 1. slave already assigned or not a slave
- * 2. not of the proper type
- * 3. controller specified but not this one
- * 4. slave specified but not this one
- */
- if (hd->hpd_alive || hd->hpd_cdriver == NULL)
- continue;
- if (!dr_type(hc->hp_driver, hd->hpd_cdriver->d_name))
- continue;
- if (hd->hpd_ctlr >= 0 && hd->hpd_ctlr != hc->hp_unit)
- continue;
- if (hd->hpd_slave >= 0 && hd->hpd_slave != s)
- continue;
- /*
- * Case 0: first possible match.
- * Remember it and keep looking for better.
- */
- if (match_s == NULL) {
- match_s = hd;
- new_c = hc->hp_unit;
- new_s = s;
- continue;
- }
- /*
- * Case 1: exact match.
- * All done. Note that we do not attempt any other
- * matches if this one fails. This allows us to
- * "reserve" locations for dynamic addition of
- * disk/tape drives by fully qualifing the location.
- */
- if (hd->hpd_slave == s && hd->hpd_ctlr == hc->hp_unit) {
- match_s = hd;
- rescan = 0;
- break;
- }
- /*
- * Case 2: right controller, wildcarded slave.
- * Remember first and keep looking for an exact match.
- */
- if (hd->hpd_ctlr == hc->hp_unit &&
- match_s->hpd_ctlr < 0) {
- match_s = hd;
- new_s = s;
- continue;
- }
- /*
- * Case 3: right slave, wildcarded controller.
- * Remember and keep looking for a better match.
- */
- if (hd->hpd_slave == s &&
- match_s->hpd_ctlr < 0 && match_s->hpd_slave < 0) {
- match_s = hd;
- new_c = hc->hp_unit;
- continue;
- }
- /*
- * OW: we had a totally wildcarded spec.
- * If we got this far, we have found a possible
- * match already (match_s != NULL) so there is no
- * reason to remember this one.
- */
- continue;
- }
- /*
- * Found a match. We need to set hp_ctlr/hp_slave properly
- * for the init routines but we also need to remember all
- * the old values in case this doesn't pan out.
- */
- if (match_s) {
- hd = match_s;
- old_c = hd->hpd_ctlr;
- old_s = hd->hpd_slave;
- if (hd->hpd_ctlr < 0)
- hd->hpd_ctlr = new_c;
- if (hd->hpd_slave < 0)
- hd->hpd_slave = new_s;
-#ifdef DEBUG
- if (acdebug)
- printf("looking for %s%d at slave %d...",
- hd->hpd_driver->d_name,
- hd->hpd_unit, hd->hpd_slave);
-#endif
-
- if ((*hd->hpd_driver->d_init)(hd)) {
-#ifdef DEBUG
- if (acdebug)
- printf("found\n");
-#endif
- printf("%s%d at %s%d, slave %d\n",
- hd->hpd_driver->d_name, hd->hpd_unit,
- hc->hp_driver->d_name, hd->hpd_ctlr,
- hd->hpd_slave);
- hd->hpd_alive = 1;
- rescan = 1;
- } else {
-#ifdef DEBUG
- if (acdebug)
- printf("not found\n");
-#endif
- hd->hpd_ctlr = old_c;
- hd->hpd_slave = old_s;
- }
- }
- }
-}
-
-int
-same_hw_device(struct hp_hw *hw, struct hp_device *hd)
-{
- int found = 0;
-
- switch (hw->hw_type) {
- case NET:
- found = dr_type(hd->hpd_driver, "le");
- break;
- case SCSI:
- found = dr_type(hd->hpd_driver, "scsi");
- break;
- }
- return(found);
-}
-
-#define setup_hw(hw, addr, type, name) \
- (hw)->hw_addr = addr; \
- (hw)->hw_type = type; \
- (hw)->hw_name = name
void
find_devs(void)
{
- struct hp_hw *hw = sc_table;
-
- setup_hw(hw, (uint8_t *)0x51000000, SIO, "uPD7201A (SIO)");
- hw++;
-
- setup_hw(hw, (uint8_t *)0x51000004, KEYBOARD, "uPD7201A (KBD)");
- hw++;
-
- setup_hw(hw, (uint8_t *)0xe1000000, SCSI, "MB89352 (SPC)");
- hw++;
- if (machtype == LUNA_II && !badaddr((void *) 0xe1000040)) {
- setup_hw(hw, (uint8_t *)0xe1000040, SCSI, "MB89352 (SPC)");
- hw++;
+ /* find and init devices */
+ scinit(0, (uint8_t *)0xe1000000);
+ if (machtype == LUNA_II) {
+ scinit(1, (uint8_t *)0xe1000040);
}
- if (!badaddr((void *) 0xf1000000)) {
- setup_hw(hw, (uint8_t *)0xf1000000, NET, "Am7990 (LANCE)");
- hw++;
+ if (!badaddr((void *)0xf1000000)) {
+ leinit(0, (uint8_t *)0xf1000000);
}
}
Index: src/sys/arch/luna68k/stand/boot/boot.c
diff -u src/sys/arch/luna68k/stand/boot/boot.c:1.4 src/sys/arch/luna68k/stand/boot/boot.c:1.5
--- src/sys/arch/luna68k/stand/boot/boot.c:1.4 Fri Jan 3 03:44:41 2014
+++ src/sys/arch/luna68k/stand/boot/boot.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.4 2014/01/03 03:44:41 tsutsui Exp $ */
+/* $NetBSD: boot.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -159,7 +159,7 @@ get_boot_device(const char *s, int *devp
}
*devp = 0; /* XXX not yet */
- *unitp = unit; /* XXX should pass SCSI ID, not logical unit number */
+ *unitp = unit;
*partp = part;
return 0;
Index: src/sys/arch/luna68k/stand/boot/devopen.c
diff -u src/sys/arch/luna68k/stand/boot/devopen.c:1.4 src/sys/arch/luna68k/stand/boot/devopen.c:1.5
--- src/sys/arch/luna68k/stand/boot/devopen.c:1.4 Fri Jan 3 06:15:10 2014
+++ src/sys/arch/luna68k/stand/boot/devopen.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.4 2014/01/03 06:15:10 tsutsui Exp $ */
+/* $NetBSD: devopen.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -155,7 +155,7 @@ make_device(const char *str, int *devp,
if (*cp >= '0' && *cp <= '9')
unit = unit * 10 + *cp - '0';
}
- if (unit < 0 || unit >= 20 || (unit % 10) > 7) {
+ if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) > 7) {
#ifdef DEBUG
printf("%s: invalid unit number (%d)\n", __func__, unit);
#endif
Index: src/sys/arch/luna68k/stand/boot/if_le.c
diff -u src/sys/arch/luna68k/stand/boot/if_le.c:1.4 src/sys/arch/luna68k/stand/boot/if_le.c:1.5
--- src/sys/arch/luna68k/stand/boot/if_le.c:1.4 Fri Jan 3 03:25:25 2014
+++ src/sys/arch/luna68k/stand/boot/if_le.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le.c,v 1.4 2014/01/03 03:25:25 tsutsui Exp $ */
+/* $NetBSD: if_le.c,v 1.5 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 2013 Izumi Tsutsui. All rights reserved.
@@ -72,7 +72,6 @@
#include <lib/libsa/netif.h>
#include <luna68k/stand/boot/samachdep.h>
-#include <luna68k/stand/boot/device.h>
/* libsa netif_driver glue functions */
static int le_match(struct netif *, void *);
@@ -84,13 +83,6 @@ static void le_end(struct netif *);
static void myetheraddr(uint8_t *);
-/* luna68k driver glue stuff */
-struct driver ledriver = {
- leinit,
- "le",
- NULL
-};
-
/* libsa netif glue stuff */
struct netif_stats le_stats;
struct netif_dif le_ifs[] = {
@@ -114,27 +106,25 @@ int debug;
#endif
int
-leinit(void *arg)
+leinit(int unit, void *addr)
{
- struct hp_device *hd = arg;
void *cookie;
void *reg, *mem;
uint8_t eaddr[6];
- reg = hd->hpd_addr;
+ reg = addr;
mem = (void *)0x71010000; /* XXX */
myetheraddr(eaddr);
- cookie = lance_attach(hd->hpd_unit, reg, mem, eaddr);
+ cookie = lance_attach(unit, reg, mem, eaddr);
if (cookie == NULL)
return 0;
- printf("%s%d: Am7990 LANCE Ethernet, mem at 0x%x\n",
- hd->hpd_driver->d_name, hd->hpd_unit, (uint32_t)mem);
- printf("%s%d: Ethernet address = %s\n",
- hd->hpd_driver->d_name, hd->hpd_unit,
- ether_sprintf(eaddr));
+ printf("le%d: Am7990 LANCE Ethernet, mem at 0x%x\n",
+ unit, (uint32_t)mem);
+ printf("le%d: Ethernet address = %s\n",
+ unit, ether_sprintf(eaddr));
return 1;
}
Index: src/sys/arch/luna68k/stand/boot/init_main.c
diff -u src/sys/arch/luna68k/stand/boot/init_main.c:1.8 src/sys/arch/luna68k/stand/boot/init_main.c:1.9
--- src/sys/arch/luna68k/stand/boot/init_main.c:1.8 Sun Jan 5 06:56:22 2014
+++ src/sys/arch/luna68k/stand/boot/init_main.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.8 2014/01/05 06:56:22 tsutsui Exp $ */
+/* $NetBSD: init_main.c,v 1.9 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -135,7 +135,7 @@ struct luna1_bootinfo {
uint8_t bd_xxx1; /* 0: ??? */
uint8_t bd_boot; /* 1: 1 == booted */
char bd_name[2]; /* 2: device name (dk, fb, sd ... ) */
- uint8_t bd_unit; /* 4: unit number (not ID) */
+ uint8_t bd_drv; /* 4: drive number (not ID) */
uint8_t bd_xxx2; /* 5: ??? */
uint8_t bd_xxx3; /* 6: ??? */
uint8_t bd_part; /* 7: dk partition / st record # */
@@ -162,7 +162,7 @@ struct luna2_bootinfo {
char bd_name[4]; /* 2: device name (dk, ft, sd ... ) */
uint8_t bd_xxx2; /* 6: ??? */
uint8_t bd_ctlr; /* 7: SCSI controller number */
- uint8_t bd_unit; /* 8: SCSI ID number */
+ uint8_t bd_id; /* 8: SCSI ID number */
uint8_t bd_xxx3; /* 9: device number index? */
uint8_t bd_xxx4; /* 10: ??? */
uint8_t bd_part; /* 11: dk partition / st record # */
@@ -180,6 +180,7 @@ main(void)
const char *machstr;
const char *bootdev;
int unit, part;
+ int bdev, ctlr, id;
/*
* Initialize the console before we print anything out.
@@ -225,7 +226,6 @@ main(void)
#endif
find_devs();
- configure();
printf("\n");
/* use sd(0,0) for the default boot device */
@@ -235,13 +235,14 @@ main(void)
if (machtype == LUNA_I) {
const struct luna1_bootinfo *bi1 = (void *)LUNA1_BOOTINFOADDR;
- int dev = bi1->bi_device;
- switch (dev) {
+ bdev = bi1->bi_device;
+ switch (bdev) {
case LUNA1_BTDEV_DK:
- /* XXX: should check hp_dinfo in ioconf.c */
- /* note: bd_unit is not SCSI ID */
- unit = bi1->bi_devinfo[dev].bd_unit;
+ /* note: bd_drv is not SCSI ID */
+ ctlr = 0;
+ id = 6 - bi1->bi_devinfo[bdev].bd_drv;
+ unit = UNIT(ctlr, id);
break;
case LUNA1_BTDEV_ET:
bootdev = "le";
@@ -253,31 +254,25 @@ main(void)
}
#ifdef BTINFO_DEBUG
printf("bi1->bi_device = 0x%02x\n", bi1->bi_device);
- printf("bi1->bi_devinfo[dev].bd_boot = 0x%02x\n",
- bi1->bi_devinfo[dev].bd_boot);
- printf("bi1->bi_devinfo[dev].bd_name = %c%c\n",
- bi1->bi_devinfo[dev].bd_name[0],
- bi1->bi_devinfo[dev].bd_name[1]);
- printf("bi1->bi_devinfo[dev].bd_unit = 0x%02x\n",
- bi1->bi_devinfo[dev].bd_unit);
- printf("bi1->bi_devinfo[dev].bd_part = 0x%02x\n",
- bi1->bi_devinfo[dev].bd_part);
+ printf("bi1->bi_devinfo[bdev].bd_boot = 0x%02x\n",
+ bi1->bi_devinfo[bdev].bd_boot);
+ printf("bi1->bi_devinfo[bdev].bd_name = %c%c\n",
+ bi1->bi_devinfo[bdev].bd_name[0],
+ bi1->bi_devinfo[bdev].bd_name[1]);
+ printf("bi1->bi_devinfo[bdev].bd_drv = 0x%02x\n",
+ bi1->bi_devinfo[bdev].bd_drv);
+ printf("bi1->bi_devinfo[bdev].bd_part = 0x%02x\n",
+ bi1->bi_devinfo[bdev].bd_part);
#endif
} else {
const struct luna2_bootinfo *bi2 = (void *)LUNA2_BOOTINFOADDR;
- int dev = bi2->bi_device;
- int ctlr, id;
- switch (dev) {
+ bdev = bi2->bi_device;
+ switch (bdev) {
case LUNA2_BTDEV_DK:
- ctlr = bi2->bi_devinfo[dev].bd_ctlr;
- id = bi2->bi_devinfo[dev].bd_unit;
- /* XXX: should check hp_dinfo in ioconf.c */
- unit = 6 - id;
- if (ctlr == 1) {
- /* XXX: should check hp_dinfo in ioconf.c */
- unit += 2;
- }
+ ctlr = bi2->bi_devinfo[bdev].bd_ctlr;
+ id = bi2->bi_devinfo[bdev].bd_id;
+ unit = UNIT(ctlr, id);
break;
default:
/* not supported */
@@ -285,16 +280,16 @@ main(void)
}
#ifdef BTINFO_DEBUG
printf("bi2->bi_device = 0x%02x\n", bi2->bi_device);
- printf("bi2->bi_devinfo[dev].bd_boot = 0x%02x\n",
- bi2->bi_devinfo[dev].bd_boot);
- printf("bi2->bi_devinfo[dev].bd_name = %s\n",
- bi2->bi_devinfo[dev].bd_name);
- printf("bi2->bi_devinfo[dev].bd_ctlr = 0x%02x\n",
- bi2->bi_devinfo[dev].bd_ctlr);
- printf("bi2->bi_devinfo[dev].bd_unit = 0x%02x\n",
- bi2->bi_devinfo[dev].bd_unit);
- printf("bi2->bi_devinfo[dev].bd_part = 0x%02x\n",
- bi2->bi_devinfo[dev].bd_part);
+ printf("bi2->bi_devinfo[bdev].bd_boot = 0x%02x\n",
+ bi2->bi_devinfo[bdev].bd_boot);
+ printf("bi2->bi_devinfo[bdev].bd_name = %s\n",
+ bi2->bi_devinfo[bdev].bd_name);
+ printf("bi2->bi_devinfo[bdev].bd_ctlr = 0x%02x\n",
+ bi2->bi_devinfo[bdev].bd_ctlr);
+ printf("bi2->bi_devinfo[bdev].bd_id = 0x%02x\n",
+ bi2->bi_devinfo[bdev].bd_id);
+ printf("bi2->bi_devinfo[bdev].bd_part = 0x%02x\n",
+ bi2->bi_devinfo[bdev].bd_part);
#endif
}
Index: src/sys/arch/luna68k/stand/boot/sc.c
diff -u src/sys/arch/luna68k/stand/boot/sc.c:1.8 src/sys/arch/luna68k/stand/boot/sc.c:1.9
--- src/sys/arch/luna68k/stand/boot/sc.c:1.8 Fri Jan 3 07:17:19 2014
+++ src/sys/arch/luna68k/stand/boot/sc.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sc.c,v 1.8 2014/01/03 07:17:19 tsutsui Exp $ */
+/* $NetBSD: sc.c,v 1.9 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -81,25 +81,19 @@
#include <sys/param.h>
#include <luna68k/stand/boot/samachdep.h>
#include <luna68k/stand/boot/scsireg.h>
-#include <luna68k/stand/boot/device.h>
#include <luna68k/stand/boot/scsivar.h>
-#define SCSI_IPL 2
#define SCSI_ID 7
-static int scinit(void *);
-static void screset(int);
+static void screset(struct scsi_softc *);
+static void scprobe(struct scsi_softc *, uint, uint);
static int issue_select(struct scsidevice *, u_char);
static void ixfer_start(struct scsidevice *, int, u_char, int);
static void ixfer_out(struct scsidevice *, int, u_char *);
static void ixfer_in(struct scsidevice *, int, u_char *);
static int scrun(int, int, u_char *, int, u_char *, int, volatile int *);
static int scfinish(int);
-static void scabort(struct scsi_softc *, struct scsidevice *);
-
-struct driver scdriver = {
- scinit, "sc", scintr,
-};
+static void scabort(struct scsi_softc *);
struct scsi_softc scsi_softc[NSC];
@@ -108,20 +102,17 @@ struct scsi_softc scsi_softc[NSC];
*/
int
-scinit(void *arg)
+scinit(int ctlr, void *addr)
{
- struct hp_ctlr *hc = arg;
struct scsi_softc *hs;
- int unit;
+ uint id;
- unit = hc->hp_unit;
- if (unit < 0 || unit >= NSC)
+ if (ctlr < 0 || ctlr >= NSC)
return 0;
- hs = &scsi_softc[unit];
-
- hc->hp_ipl = SCSI_IPL;
- hs->sc_hc = hc;
+ hs = &scsi_softc[ctlr];
+ hs->sc_ctlr = ctlr;
+ hs->sc_spc = addr;
hs->sc_flags = 0;
hs->sc_phase = BUS_FREE_PHASE;
@@ -136,17 +127,20 @@ scinit(void *arg)
hs->sc_stat = 0;
hs->sc_msg[0] = 0;
- screset(hc->hp_unit);
+ screset(hs);
+
+ for (id = 0; id < 7; id++)
+ scprobe(hs, id, 0);
+
return(1);
}
void
-screset(int unit)
+screset(struct scsi_softc *hs)
{
- struct scsi_softc *hs = &scsi_softc[unit];
- struct scsidevice *hd = (struct scsidevice *)hs->sc_hc->hp_addr;
+ struct scsidevice *hd = hs->sc_spc;
- printf("sc%d: ", unit);
+ printf("sc%d at 0x%08lx: ", hs->sc_ctlr, (u_long)hs->sc_spc);
/*
* Disable interrupts then reset the FUJI chip.
@@ -177,7 +171,98 @@ screset(int unit)
DELAY(400);
hd->scsi_sctl &= ~SCTL_DISABLE;
- printf(", scsi id %d\n", SCSI_ID);
+ printf(", ID %d\n", SCSI_ID);
+}
+
+bool
+scident(uint ctlr, uint target, uint lun, struct scsi_inquiry *inqout,
+ uint32_t *capout)
+{
+ struct scsi_inquiry inqbuf;
+ struct scsi_generic_cdb inq = {
+ 6,
+ { CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 }
+ };
+ uint32_t capbuf[2];
+ struct scsi_generic_cdb cap = {
+ 10,
+ { CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+ };
+ int i;
+ int tries = 10;
+
+ /*
+ * See if unit exists and is a disk then read block size & nblocks.
+ */
+ while ((i = scsi_test_unit_rdy(ctlr, target, lun)) != 0) {
+ if (i < 0 || --tries < 0)
+ return false;
+ if (i == STS_CHECKCOND) {
+ u_char sensebuf[8];
+ struct scsi_xsense *sp = (struct scsi_xsense *)sensebuf;
+
+ scsi_request_sense(ctlr, target, lun, sensebuf, 8);
+ if (sp->class == 7 && sp->key == 6)
+ /* drive doing an RTZ -- give it a while */
+ DELAY(1000000);
+ }
+ DELAY(1000);
+ }
+ if (scsi_immed_command(ctlr, target, lun, &inq, (u_char *)&inqbuf,
+ sizeof(inqbuf)) ||
+ scsi_immed_command(ctlr, target, lun, &cap, (u_char *)&capbuf,
+ sizeof(capbuf)))
+ /* doesn't exist or not a CCS device */
+ return false;
+
+ switch (inqbuf.type) {
+ case 0: /* disk */
+ case 4: /* WORM */
+ case 5: /* CD-ROM */
+ case 7: /* Magneto-optical */
+ break;
+ default: /* not a disk */
+ return false;
+ }
+
+ if (inqout != NULL)
+ *inqout = inqbuf;
+ if (capout != NULL) {
+ /* assume big endian */
+ capout[0] = capbuf[0];
+ capout[1] = capbuf[1];
+ }
+
+ return true;
+}
+
+static void
+scprobe(struct scsi_softc *hs, uint target, uint lun)
+{
+ struct scsi_inquiry inqbuf;
+ uint32_t capbuf[2];
+ char idstr[32];
+ int i;
+
+ if (!scident(hs->sc_ctlr, target, lun, &inqbuf, capbuf))
+ return;
+
+ memcpy(idstr, &inqbuf.vendor_id, 28);
+ for (i = 27; i > 23; --i)
+ if (idstr[i] != ' ')
+ break;
+ idstr[i + 1] = '\0';
+ for (i = 23; i > 7; --i)
+ if (idstr[i] != ' ')
+ break;
+ idstr[i + 1] = '\0';
+ for (i = 7; i >= 0; --i)
+ if (idstr[i] != ' ')
+ break;
+ idstr[i + 1] = '\0';
+
+ printf(" ID %d: %s %s rev %s", target, idstr, &idstr[8], &idstr[24]);
+ printf(", %d bytes/sect x %d sectors\n", capbuf[1], capbuf[0]);
}
@@ -251,7 +336,7 @@ ixfer_in(struct scsidevice *hd, int len,
*/
int
-scrun(int ctlr, int slave, u_char *cdb, int cdblen, u_char *buf, int len,
+scrun(int ctlr, int target, u_char *cdb, int cdblen, u_char *buf, int len,
volatile int *lock)
{
struct scsi_softc *hs;
@@ -261,14 +346,16 @@ scrun(int ctlr, int slave, u_char *cdb,
return 0;
hs = &scsi_softc[ctlr];
- hd = (struct scsidevice *)hs->sc_hc->hp_addr;
+ hd = hs->sc_spc;
+ if (hd == NULL)
+ return 0;
if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
return(0);
hs->sc_flags = 0;
hs->sc_phase = ARB_SEL_PHASE;
- hs->sc_target = slave;
+ hs->sc_target = target;
hs->sc_cdb = cdb;
hs->sc_cdblen = cdblen;
@@ -308,13 +395,14 @@ scfinish(int ctlr)
}
void
-scabort(struct scsi_softc *hs, struct scsidevice *hd)
+scabort(struct scsi_softc *hs)
{
+ struct scsidevice *hd = hs->sc_spc;
int len;
u_char junk;
printf("sc%d: abort phase=0x%x, ssts=0x%x, ints=0x%x\n",
- hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts,
+ hs->sc_ctlr, hd->scsi_psns, hd->scsi_ssts,
hd->scsi_ints);
if (hd->scsi_ints != 0)
@@ -365,7 +453,7 @@ out:
*/
if (len < 0 && hs)
printf("sc%d: abort failed. phase=0x%x, ssts=0x%x\n",
- hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts);
+ hs->sc_ctlr, hd->scsi_psns, hd->scsi_ssts);
}
@@ -374,19 +462,19 @@ out:
*/
int
-scsi_test_unit_rdy(int ctlr, int slave, int unit)
+scsi_test_unit_rdy(int ctlr, int target, int lun)
{
static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY };
int status;
volatile int lock;
#ifdef DEBUG
- printf("scsi_test_unit_rdy( %d, %d, %d): Start\n", ctlr, slave, unit);
+ printf("scsi_test_unit_rdy( %d, %d, %d): Start\n", ctlr, target, lun);
#endif
- cdb.lun = unit;
+ cdb.lun = lun;
- if (!(scrun(ctlr, slave, (void *)&cdb, 6, NULL, 0, &lock))) {
+ if (!(scrun(ctlr, target, (void *)&cdb, 6, NULL, 0, &lock))) {
#ifdef DEBUG
printf("scsi_test_unit_rdy: Command Transfer Failed.\n");
#endif
@@ -409,7 +497,7 @@ scsi_test_unit_rdy(int ctlr, int slave,
}
int
-scsi_request_sense(int ctlr, int slave, int unit, u_char *buf, unsigned int len)
+scsi_request_sense(int ctlr, int target, int lun, u_char *buf, unsigned int len)
{
static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE };
int status;
@@ -427,10 +515,10 @@ scsi_request_sense(int ctlr, int slave,
/* テープユニットの状態を調べるため、Addtional Sens Fieldをアクセスする */
/* 必要があるのでデバイスドライバ側でlenを決定することにする */
- cdb.lun = unit;
+ cdb.lun = lun;
cdb.len = len;
- if (!(scrun(ctlr, slave, (void *)&cdb, 6, buf, len, &lock))) {
+ if (!(scrun(ctlr, target, (void *)&cdb, 6, buf, len, &lock))) {
#ifdef DEBUG
printf("scsi_request_sense: Command Transfer Failed.\n");
#endif
@@ -453,7 +541,7 @@ scsi_request_sense(int ctlr, int slave,
}
int
-scsi_immed_command(int ctlr, int slave, int unit, struct scsi_generic_cdb *cdb,
+scsi_immed_command(int ctlr, int target, int lun, struct scsi_generic_cdb *cdb,
u_char *buf, unsigned int len)
{
int status;
@@ -461,12 +549,12 @@ scsi_immed_command(int ctlr, int slave,
#ifdef DEBUG
printf("scsi_immed_command( %d, %d, %d, cdb(%d), buf, %d): Start\n",
- ctlr, slave, unit, cdb->len, len);
+ ctlr, target, lun, cdb->len, len);
#endif
- cdb->cdb[1] |= unit << 5;
+ cdb->cdb[1] |= lun << 5;
- if (!(scrun(ctlr, slave, (void *)&cdb->cdb[0], cdb->len, buf, len, &lock))) {
+ if (!(scrun(ctlr, target, (void *)&cdb->cdb[0], cdb->len, buf, len, &lock))) {
#ifdef DEBUG
printf("scsi_immed_command: Command Transfer Failed.\n");
#endif
@@ -489,7 +577,7 @@ scsi_immed_command(int ctlr, int slave,
}
int
-scsi_format_unit(int ctlr, int slave, int unit)
+scsi_format_unit(int ctlr, int target, int lun)
{
static struct scsi_cdb6 cdb = { CMD_FORMAT_UNIT, 0, 0, 0, 0, 0 };
int status;
@@ -499,12 +587,12 @@ scsi_format_unit(int ctlr, int slave, in
#endif
#ifdef DEBUG
- printf("scsi_format_unit( %d, %d, %d): Start\n", ctlr, slave, unit);
+ printf("scsi_format_unit( %d, %d, %d): Start\n", ctlr, target, lun);
#endif
- cdb.lun = unit;
+ cdb.lun = lun;
- if (!(scrun(ctlr, slave, (void *)&cdb, 6, (u_char *) 0, 0, &lock))) {
+ if (!(scrun(ctlr, target, (void *)&cdb, 6, (u_char *) 0, 0, &lock))) {
#ifdef DEBUG
printf("scsi_format_unit: Command Transfer Failed.\n");
#endif
@@ -548,7 +636,7 @@ scintr(void)
for (i = 0; i < NSC; i++) {
hs = &scsi_softc[i];
- hd = (struct scsidevice *) hs->sc_hc->hp_addr;
+ hd = hs->sc_spc;
if ((ints = hd->scsi_ints) != 0)
goto get_intr;
}
@@ -669,7 +757,7 @@ scintr(void)
*/
abort:
/* SCSI IO failed */
- scabort(hs, hd);
+ scabort(hs);
hd->scsi_ints = ints;
*(hs->sc_lock) = SC_IO_FAILED;
return -1;
Index: src/sys/arch/luna68k/stand/boot/sd.c
diff -u src/sys/arch/luna68k/stand/boot/sd.c:1.8 src/sys/arch/luna68k/stand/boot/sd.c:1.9
--- src/sys/arch/luna68k/stand/boot/sd.c:1.8 Fri Jan 3 07:17:19 2014
+++ src/sys/arch/luna68k/stand/boot/sd.c Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.8 2014/01/03 07:17:19 tsutsui Exp $ */
+/* $NetBSD: sd.c,v 1.9 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -83,123 +83,37 @@
#include <sys/disklabel.h>
#include <luna68k/stand/boot/samachdep.h>
#include <luna68k/stand/boot/scsireg.h>
-#include <luna68k/stand/boot/device.h>
-
-struct disklabel sdlabel[NSD];
struct sd_softc {
- struct hp_device *sc_hd;
- short sc_flags;
- short sc_type; /* drive type */
- short sc_punit; /* physical unit (scsi lun) */
- u_short sc_bshift; /* convert device blocks to DEV_BSIZE blks */
- u_int sc_blks; /* number of blocks on device */
+ int sc_unit;
+ uint sc_ctlr;
+ uint sc_tgt;
+ uint sc_lun;
+ int sc_part;
+ uint sc_bshift; /* convert device blocks to DEV_BSIZE blks */
+ uint sc_blks; /* number of blocks on device */
int sc_blksize; /* device block size in bytes */
+ struct disklabel sc_label;
};
-struct sd_devdata {
- int unit; /* drive number */
- int part; /* partition */
-};
-
-static int sdinit(void *);
-static int sdident(struct sd_softc *, struct hp_device *);
-
-struct driver sddriver = {
- sdinit, "sd", NULL,
-};
-
-struct sd_softc sd_softc[NSD];
-struct sd_devdata sd_devdata[NSD];
-
-/* sc_flags values */
-#define SDF_ALIVE 0x1
-
-#define sdunit(x) ((minor(x) >> 3) & 0x7)
-#define sdpart(x) (minor(x) & 0x7)
-
-static struct scsi_inquiry inqbuf;
-static struct scsi_generic_cdb inq = {
- 6,
- { CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 }
-};
-
-static u_long capbuf[2];
-struct scsi_generic_cdb cap = {
- 10,
- { CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-};
+static struct sd_softc *sdinit(uint);
+static int sdident(struct sd_softc *);
int
-sdident(struct sd_softc *sc, struct hp_device *hd)
+sdident(struct sd_softc *sc)
{
- char idstr[32];
- int unit;
- int ctlr, slave;
+ struct scsi_inquiry inqbuf;
+ uint32_t capbuf[2];
int i;
- int tries = 10;
- ctlr = hd->hpd_ctlr;
- slave = hd->hpd_slave;
- unit = sc->sc_punit;
+ if (!scident(sc->sc_ctlr, sc->sc_tgt, sc->sc_lun, &inqbuf, capbuf))
+ return -1;
- /*
- * See if unit exists and is a disk then read block size & nblocks.
- */
- while ((i = scsi_test_unit_rdy(ctlr, slave, unit)) != 0) {
- if (i < 0 || --tries < 0)
- return (-1);
- if (i == STS_CHECKCOND) {
- u_char sensebuf[8];
- struct scsi_xsense *sp = (struct scsi_xsense *)sensebuf;
-
- scsi_request_sense(ctlr, slave, unit, sensebuf, 8);
- if (sp->class == 7 && sp->key == 6)
- /* drive doing an RTZ -- give it a while */
- DELAY(1000000);
- }
- DELAY(1000);
- }
- if (scsi_immed_command(ctlr, slave, unit, &inq, (u_char *)&inqbuf,
- sizeof(inqbuf)) ||
- scsi_immed_command(ctlr, slave, unit, &cap, (u_char *)&capbuf,
- sizeof(capbuf)))
- /* doesn't exist or not a CCS device */
- return (-1);
-
- switch (inqbuf.type) {
- case 0: /* disk */
- case 4: /* WORM */
- case 5: /* CD-ROM */
- case 7: /* Magneto-optical */
- break;
- default: /* not a disk */
- return (-1);
- }
sc->sc_blks = capbuf[0];
sc->sc_blksize = capbuf[1];
- memcpy(idstr, &inqbuf.vendor_id, 28);
- for (i = 27; i > 23; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- for (i = 23; i > 7; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- for (i = 7; i >= 0; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- printf("sd%d: %s %s rev %s", hd->hpd_unit, idstr, &idstr[8],
- &idstr[24]);
-
- printf(", %d bytes/sect x %d sectors\n", sc->sc_blksize, sc->sc_blks);
if (sc->sc_blksize != DEV_BSIZE) {
if (sc->sc_blksize < DEV_BSIZE) {
- printf("sd%d: need %d byte blocks - drive ignored\n",
- unit, DEV_BSIZE);
return (-1);
}
for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1)
@@ -209,30 +123,33 @@ sdident(struct sd_softc *sc, struct hp_d
return(inqbuf.type);
}
-int
-sdinit(void *arg)
+struct sd_softc *
+sdinit(uint unit)
{
- struct hp_device *hd = arg;
- struct sd_softc *sc = &sd_softc[hd->hpd_unit];
+ struct sd_softc *sc;
struct disklabel *lp;
char *msg;
+ int type;
#ifdef DEBUG
- printf("sdinit: hd->hpd_unit = %d\n", hd->hpd_unit);
- printf("sdinit: hd->hpd_ctlr = %d, hd->hpd_slave = %d\n",
- hd->hpd_ctlr, hd->hpd_slave);
+ printf("sdinit: unit = %d\n", unit);
#endif
- sc->sc_hd = hd;
- sc->sc_punit = 0; /* XXX no LUN support yet */
- sc->sc_type = sdident(sc, hd);
- if (sc->sc_type < 0)
- return(0);
+ sc = alloc(sizeof *sc);
+ memset(sc, 0, sizeof *sc);
+
+ sc->sc_unit = unit;
+ sc->sc_ctlr = CTLR(unit);
+ sc->sc_tgt = TARGET(unit);
+ sc->sc_lun = 0; /* XXX no LUN support yet */
+ type = sdident(sc);
+ if (type < 0)
+ return NULL;
/*
* Use the default sizes until we've read the label,
* or longer if there isn't one there.
*/
- lp = &sdlabel[hd->hpd_unit];
+ lp = &sc->sc_label;
if (lp->d_secpercyl == 0) {
lp->d_secsize = DEV_BSIZE;
@@ -247,19 +164,18 @@ sdinit(void *arg)
/*
* read disklabel
*/
- msg = readdisklabel(hd->hpd_ctlr, hd->hpd_slave, lp);
+ msg = readdisklabel(sc->sc_ctlr, sc->sc_tgt, lp);
if (msg != NULL)
- printf("sd%d: %s\n", hd->hpd_unit, msg);
+ printf("sd(%d): %s\n", unit, msg);
- sc->sc_flags = SDF_ALIVE;
- return(1);
+ return sc;
}
int
sdopen(struct open_file *f, ...)
{
va_list ap;
- struct sd_devdata *sd;
+ struct sd_softc *sc;
int unit, part;
va_start(ap, f);
@@ -267,15 +183,17 @@ sdopen(struct open_file *f, ...)
part = va_arg(ap, int);
va_end(ap);
- if (unit < 0 || unit >= NSD)
+ if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) >= 7)
return(-1);
- if (part < 0 || part >= 8)
+ if (part < 0 || part >= MAXPARTITIONS)
return(-1);
- sd = &sd_devdata[unit];
- sd->unit = unit;
- sd->part = part;
- f->f_devdata = (void *)sd;
+ sc = sdinit(unit);
+ if (sc == NULL)
+ return -1;
+
+ sc->sc_part = part;
+ f->f_devdata = (void *)sc;
return 0;
}
@@ -283,10 +201,9 @@ sdopen(struct open_file *f, ...)
int
sdclose(struct open_file *f)
{
- struct sd_devdata *sd = f->f_devdata;
+ struct sd_softc *sc = f->f_devdata;
- sd->unit = -1;
- sd->part = -1;
+ dealloc(sc, sizeof *sc);
f->f_devdata = NULL;
return 0;
@@ -306,28 +223,25 @@ int
sdstrategy(void *devdata, int func, daddr_t dblk, size_t size, void *v_buf,
size_t *rsize)
{
- struct sd_devdata *sd = devdata;
+ struct sd_softc *sc;
struct disklabel *lp;
- uint8_t *buf = v_buf;
- int unit = sd->unit;
- int part = sd->part;
- struct sd_softc *sc = &sd_softc[unit];
+ uint8_t *buf;
struct scsi_generic_cdb *cdb;
daddr_t blk;
- u_int nblk = size >> sc->sc_bshift;
- int stat, ctlr, slave;
+ u_int nblk;
+ int stat;
#ifdef DEBUG
int i;
#endif
- if (unit < 0 || unit >= NSD)
- return(-1);
-
- ctlr = sc->sc_hd->hpd_ctlr;
- slave = sc->sc_hd->hpd_slave;
-
- lp = &sdlabel[unit];
- blk = dblk + (lp->d_partitions[part].p_offset >> sc->sc_bshift);
+ sc = devdata;
+ if (sc == NULL)
+ return -1;
+
+ buf = v_buf;
+ lp = &sc->sc_label;
+ blk = dblk + (lp->d_partitions[sc->sc_part].p_offset >> sc->sc_bshift);
+ nblk = size >> sc->sc_bshift;
if (func == F_READ)
cdb = &cdb_read;
@@ -343,13 +257,14 @@ sdstrategy(void *devdata, int func, dadd
cdb->cdb[8] = ((nblk >> DEV_BSHIFT) & 0x00ff);
#ifdef DEBUG
- printf("sdstrategy: unit = %d\n", unit);
+ printf("sdstrategy: unit = %d\n", sc->sc_unit);
printf("sdstrategy: blk = %lu (0x%lx), nblk = %u (0x%x)\n", (u_long)blk, (long)blk, nblk, nblk);
for (i = 0; i < 10; i++)
printf("sdstrategy: cdb[%d] = 0x%x\n", i, cdb->cdb[i]);
- printf("sdstrategy: ctlr = %d, slave = %d\n", ctlr, slave);
+ printf("sdstrategy: ctlr = %d, target = %d\n", sc->sc_ctlr, sc->sc_tgt);
#endif
- stat = scsi_immed_command(ctlr, slave, sc->sc_punit, cdb, buf, size);
+ stat = scsi_immed_command(sc->sc_ctlr, sc->sc_tgt, sc->sc_lun,
+ cdb, buf, size);
if (rsize)
*rsize = size;
Index: src/sys/arch/luna68k/stand/boot/version
diff -u src/sys/arch/luna68k/stand/boot/version:1.8 src/sys/arch/luna68k/stand/boot/version:1.9
--- src/sys/arch/luna68k/stand/boot/version:1.8 Sun Jan 5 06:56:22 2014
+++ src/sys/arch/luna68k/stand/boot/version Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.8 2014/01/05 06:56:22 tsutsui Exp $
+$NetBSD: version,v 1.9 2014/01/10 11:12:03 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
@@ -12,3 +12,5 @@ is taken as the current.
1.5: Check netboot and set proper default boot device.
1.6: Accept empty unit, partition, and filename. (defaults: 0, 0, "netbsd")
1.7: Check boot device on PROM and set proper default boot device and unit.
+1.8: Probe SCSI devices at any IDs and change boot command to use SCSI
+ controller number and target ID to specify the boot disk.
Index: src/sys/arch/luna68k/stand/boot/samachdep.h
diff -u src/sys/arch/luna68k/stand/boot/samachdep.h:1.14 src/sys/arch/luna68k/stand/boot/samachdep.h:1.15
--- src/sys/arch/luna68k/stand/boot/samachdep.h:1.14 Fri Jan 3 07:17:19 2014
+++ src/sys/arch/luna68k/stand/boot/samachdep.h Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: samachdep.h,v 1.14 2014/01/03 07:17:19 tsutsui Exp $ */
+/* $NetBSD: samachdep.h,v 1.15 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -102,7 +102,7 @@ int fsrestore(int, char **);
int getline(const char *, char *);
/* if_le.c */
-int leinit(void *);
+int leinit(int, void *);
/* init_main.c */
extern int cpuspeed;
@@ -167,6 +167,9 @@ int romcngetc(dev_t);
void romcnputc(dev_t, int);
/* sc.c */
+int scinit(int, void *);
+struct scsi_inquiry;
+bool scident(uint, uint, uint, struct scsi_inquiry *, uint32_t *);
struct scsi_generic_cdb;
int scsi_immed_command(int, int, int, struct scsi_generic_cdb *, u_char *,
unsigned int);
@@ -210,6 +213,11 @@ void trap(int, unsigned int, unsigned in
char *readdisklabel(int, int, struct disklabel *);
+/* use following device unit number strategy to make parser easier */
+#define UNIT(ctlr, target) ((ctlr) * 10 + (target))
+#define CTLR(unit) ((unit) / 10)
+#define TARGET(unit) ((unit) % 10)
+
#define DELAY(n) \
do { \
register int __N = cpuspeed * (n); \
Index: src/sys/arch/luna68k/stand/boot/scsivar.h
diff -u src/sys/arch/luna68k/stand/boot/scsivar.h:1.1 src/sys/arch/luna68k/stand/boot/scsivar.h:1.2
--- src/sys/arch/luna68k/stand/boot/scsivar.h:1.1 Sat Jan 5 17:44:24 2013
+++ src/sys/arch/luna68k/stand/boot/scsivar.h Fri Jan 10 11:12:03 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: scsivar.h,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */
+/* $NetBSD: scsivar.h,v 1.2 2014/01/10 11:12:03 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -71,7 +71,9 @@
*/
struct scsi_softc {
- struct hp_ctlr *sc_hc;
+ struct scsidevice *sc_spc;
+ int sc_ctlr;
+
u_char *sc_buf; /* Data Buffer Pointor*/
u_char *sc_cdb; /* CDB Buffer Pointor */
volatile int *sc_lock; /* Lock Flag addres */