Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sun68k/sun68k Added common sun68k autoconfiguration...



details:   https://anonhg.NetBSD.org/src/rev/df6b9e7a8b1a
branches:  trunk
changeset: 511785:df6b9e7a8b1a
user:      fredette <fredette%NetBSD.org@localhost>
date:      Wed Jun 27 02:48:32 2001 +0000

description:
Added common sun68k autoconfiguration and bus_space
related code.  Currently used by sun2.

diffstat:

 sys/arch/sun68k/sun68k/autoconf.c       |  461 +++++++++++++++++
 sys/arch/sun68k/sun68k/bus.c            |  829 ++++++++++++++++++++++++++++++++
 sys/arch/sun68k/sun68k/isr.c            |  362 +++++++++++++
 sys/arch/sun68k/sun68k/procfs_machdep.c |   20 +
 sys/arch/sun68k/sun68k/vme_sun68k.c     |  423 ++++++++++++++++
 sys/arch/sun68k/sun68k/vme_sun68k.h     |   41 +
 6 files changed, 2136 insertions(+), 0 deletions(-)

diffs (truncated from 2160 to 300 lines):

diff -r 4d8124acb9b8 -r df6b9e7a8b1a sys/arch/sun68k/sun68k/autoconf.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sun68k/sun68k/autoconf.c Wed Jun 27 02:48:32 2001 +0000
@@ -0,0 +1,461 @@
+/*     $NetBSD: autoconf.c,v 1.1 2001/06/27 02:48:32 fredette Exp $    */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Adam Glass, Gordon W. Ross, and Matthew Fredette.
+ *
+ * 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 NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Setup the system to run on the current machine.
+ *
+ * Configure() is called at boot time.  Available devices are
+ * determined (from possibilities mentioned in ioconf.c), and
+ * the drivers are initialized.
+ */
+
+#include "opt_kgdb.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/reboot.h>
+
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+
+#include <machine/autoconf.h>
+#include <machine/intr.h>
+#include <machine/promlib.h>
+
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
+
+/*
+ * Do general device autoconfiguration,
+ * then choose root device (etc.)
+ * Called by machdep.c: cpu_startup()
+ */
+void
+cpu_configure()
+{
+
+       /*
+        * Consider stopping for a debugger before
+        * autoconfiguration.
+        */
+       if (boothowto & RB_KDB) {
+#ifdef KGDB
+               /* XXX - Ask on console for kgdb_dev? */
+               /* Note: this will just return if kgdb_dev==NODEV */
+               kgdb_connect(1);
+#else  /* KGDB */
+               /* Either DDB or no debugger (just PROM). */
+               Debugger();
+#endif /* KGDB */
+       }
+
+       /*
+        * Install handlers for our "soft" interrupts.
+        * There might be a better place to do this?
+        */
+       softintr_init();
+
+       /* General device autoconfiguration. */
+       if (config_rootfound("mainbus", NULL) == NULL)
+               panic("configure: mainbus not found");
+
+       /*
+        * Now that device autoconfiguration is finished,
+        * we can safely enable interrupts.
+        */
+       printf("enabling interrupts\n");
+       (void)spl0();
+}
+
+static int     mainbus_match __P((struct device *, struct cfdata *, void *));
+static void    mainbus_attach __P((struct device *, struct device *, void *));
+
+struct cfattach mainbus_ca = {
+       sizeof(struct device), mainbus_match, mainbus_attach
+};
+
+/*
+ * Probe for the mainbus; always succeeds.
+ */
+static int
+mainbus_match(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+
+       return 1;
+}
+
+/*
+ * Do "direct" configuration for the bus types on mainbus.
+ * This controls the order of autoconfig for important things
+ * used early.  For example, idprom is used by Ether drivers.
+ */
+static void
+mainbus_attach(parent, self, args)
+       struct device *parent;
+       struct device *self;
+       void *args;
+{
+extern struct sun68k_bus_dma_tag mainbus_dma_tag;
+extern struct sun68k_bus_space_tag mainbus_space_tag;
+
+       struct mainbus_attach_args ma;
+       const char *const *cpp;
+       static const char *const special[] = {
+               /* find these first */
+               "obio",
+               "obmem",
+               NULL
+       };
+
+       printf("\n");
+
+       ma.ma_bustag = &mainbus_space_tag;
+       ma.ma_dmatag = &mainbus_dma_tag;
+
+       /* Find all `early' mainbus buses */
+       for (cpp = special; *cpp != NULL; cpp++) {
+               ma.ma_name = *cpp;
+               (void)config_found(self, &ma, NULL);
+       }
+
+       /* Find the remaining buses */
+       ma.ma_name = NULL;
+       (void) config_found(self, &ma, NULL);
+
+       /* Lastly, find the PROM console */
+       ma.ma_name = "pcons";
+       (void) config_found(self, &ma, NULL);
+}
+
+/*
+ * sun68k_bus_search:
+ * This function is passed to config_search() by the attach function
+ * for each of the "bus" drivers (obio, obmem, mbmem, vme, ...).
+ * The purpose of this function is to copy the "locators" into our
+ * _attach_args structure, so child drivers may use the _attach_args both
+ * as match parameters and as temporary storage for the defaulted
+ * locator values determined in the child_match and preserved for
+ * the child_attach function.  If the bus attach functions just
+ * used config_found, then we would not have an opportunity to
+ * setup the _attach_args for each child match and attach call.
+ */
+int sun68k_bus_search(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       struct mainbus_attach_args *map = aux;
+       struct mainbus_attach_args ma;
+       cfmatch_t mf;
+
+       /* Check whether we're looking for a specifically named device */
+       if (map->ma_name != NULL && strcmp(map->ma_name, cf->cf_driver->cd_name) != 0)
+               return (0);
+
+#ifdef DIAGNOSTIC
+       if (cf->cf_fstate == FSTATE_STAR)
+               panic("bus_scan: FSTATE_STAR");
+#endif
+
+       /*
+        * Prepare to copy the locators into our _attach_args.
+        */
+       ma = *map;
+       ma.ma_name = NULL;
+
+       /*
+        * Avoid entries which are missing attach information that
+        * they need, or that have attach information that they
+        * cannot have.  The individual bus attach functions tell
+        * us this by initializing the locator fields in the attach
+        * args they provide us.
+        *
+        * At the same time we copy these values into the _attach_args
+        * will pass to the device's match and attach functions.
+        */
+#ifdef DIAGNOSTIC
+#define BAD_LOCATOR(ma_loc, what) panic("sun68k_bus_search: %s %s for: %s%d\n", \
+                                    map-> ma_loc == LOCATOR_REQUIRED ? "missing" : "unexpected", \
+                                    what, cf->cf_driver->cd_name, cf->cf_unit)
+#else
+#define BAD_LOCATOR(ma_loc, what) return (0)
+#endif
+#define CHECK_LOCATOR(ma_loc, cf_loc, what) \
+       if ((map-> ma_loc == LOCATOR_FORBIDDEN && cf->cf_loc != -1) || \
+           (map-> ma_loc == LOCATOR_REQUIRED && cf->cf_loc == -1)) \
+               BAD_LOCATOR( ma_loc, what); \
+       else \
+               ma. ma_loc = cf->cf_loc
+       ma.ma_paddr = LOCATOR_REQUIRED;
+       CHECK_LOCATOR(ma_paddr, cf_paddr, "address");
+       CHECK_LOCATOR(ma_pri, cf_intpri, "ipl");
+
+       /*
+        * Note that this allows the match function to save
+        * defaulted locators in the _attach_args that will be
+        * preserved for the related attach call.
+        * XXX - This is a hack...
+        */
+       mf = cf->cf_attach->ca_match;
+       if ((*mf)(parent, cf, &ma) > 0) {
+               config_attach(parent, cf, &ma, sun68k_bus_print);
+       }
+       return (0);
+}
+
+/*
+ * sun68k_bus_print:
+ * Just print out the final (non-default) locators.
+ * The parent name is non-NULL when there was no match
+ * found by config_found().
+ */
+int
+sun68k_bus_print(args, name)
+       void *args;
+       const char *name;
+{
+       struct mainbus_attach_args *ma = args;
+
+       if (name)
+               printf("%s:", name);
+
+       if (ma->ma_paddr != -1)
+               printf(" addr 0x%x", (unsigned int) ma->ma_paddr);
+       if (ma->ma_pri != -1)
+               printf(" ipl %d", ma->ma_pri);
+
+       return(UNCONF);
+}
+
+/****************************************************************/
+
+/* This takes the args: name, ctlr, unit */
+typedef struct device * (*findfunc_t) __P((char *, int, int));
+
+static struct device * find_dev_byname __P((char *));
+static struct device * net_find  __P((char *, int, int));
+static struct device * scsi_find __P((char *, int, int));
+static struct device * xx_find   __P((char *, int, int));
+
+struct prom_n2f {
+       const char name[4];
+       findfunc_t func;
+};
+static struct prom_n2f prom_dev_table[] = {
+       { "ie",         net_find },
+       { "ec",         net_find },
+       { "le",         net_find },
+       { "sd",         scsi_find },
+       { "xy",         xx_find },
+       { "xd",         xx_find },
+       { "",           0 },
+};
+
+/*



Home | Main Index | Thread Index | Old Index