Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/luna68k/stand/boot Reorgenize boot device configura...



details:   https://anonhg.NetBSD.org/src/rev/54fc369daad4
branches:  trunk
changeset: 325873:54fc369daad4
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jan 10 11:12:03 2014 +0000

description:
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
 :

diffstat:

 sys/arch/luna68k/stand/boot/Makefile    |    4 +-
 sys/arch/luna68k/stand/boot/autoconf.c  |  446 +------------------------------
 sys/arch/luna68k/stand/boot/boot.c      |    4 +-
 sys/arch/luna68k/stand/boot/device.h    |  120 --------
 sys/arch/luna68k/stand/boot/devopen.c   |    4 +-
 sys/arch/luna68k/stand/boot/if_le.c     |   26 +-
 sys/arch/luna68k/stand/boot/init_main.c |   73 ++--
 sys/arch/luna68k/stand/boot/ioconf.c    |  100 -------
 sys/arch/luna68k/stand/boot/samachdep.h |   12 +-
 sys/arch/luna68k/stand/boot/sc.c        |  184 +++++++++---
 sys/arch/luna68k/stand/boot/scsivar.h   |    6 +-
 sys/arch/luna68k/stand/boot/sd.c        |  215 ++++----------
 sys/arch/luna68k/stand/boot/version     |    4 +-
 13 files changed, 285 insertions(+), 913 deletions(-)

diffs (truncated from 1707 to 300 lines):

diff -r 50988d951296 -r 54fc369daad4 sys/arch/luna68k/stand/boot/Makefile
--- a/sys/arch/luna68k/stand/boot/Makefile      Fri Jan 10 10:45:34 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/Makefile      Fri Jan 10 11:12:03 2014 +0000
@@ -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 @@
 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
diff -r 50988d951296 -r 54fc369daad4 sys/arch/luna68k/stand/boot/autoconf.c
--- a/sys/arch/luna68k/stand/boot/autoconf.c    Fri Jan 10 10:45:34 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/autoconf.c    Fri Jan 10 11:12:03 2014 +0000
@@ -1,47 +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.
- *
- * 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. 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.
+/*-
+ * 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
@@ -51,400 +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. 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
- */
-
-/*
- * autoconf.c -- Determine mass storage and memory configuration for a machine.
- *          by A.Fujita, NOV-30-1991
- *
- * Modified by A.Fujita, FEB-04-1992
+ * 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.
  */
 
-
-#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;



Home | Main Index | Thread Index | Old Index