Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips clean up "mainbus" related code.
details: https://anonhg.NetBSD.org/src/rev/843b298e65f3
branches: trunk
changeset: 515144:843b298e65f3
user: uch <uch%NetBSD.org@localhost>
date: Mon Sep 17 17:03:44 2001 +0000
description:
clean up "mainbus" related code.
diffstat:
sys/arch/hpcmips/conf/files.hpcmips | 4 +-
sys/arch/hpcmips/hpcmips/bus_space.c | 33 ++++++-
sys/arch/hpcmips/hpcmips/machdep.c | 9 +-
sys/arch/hpcmips/hpcmips/machdep.h | 6 +-
sys/arch/hpcmips/hpcmips/mainbus.c | 141 ++++++++++++++--------------------
sys/arch/hpcmips/include/bus.h | 3 +-
sys/arch/hpcmips/tx/tx39.c | 64 +++++----------
sys/arch/hpcmips/vr/vr.c | 85 ++++++++------------
8 files changed, 151 insertions(+), 194 deletions(-)
diffs (truncated from 674 to 300 lines):
diff -r 932c753053b3 -r 843b298e65f3 sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips Mon Sep 17 16:26:56 2001 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips Mon Sep 17 17:03:44 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpcmips,v 1.60 2001/09/05 15:46:10 sato Exp $
+# $NetBSD: files.hpcmips,v 1.61 2001/09/17 17:03:44 uch Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@@ -30,7 +30,7 @@
#
# Bus-independent devices
#
-device mainbus { } # no locators
+device mainbus { [id = -1] }
attach mainbus at root
device cpu # not optional
diff -r 932c753053b3 -r 843b298e65f3 sys/arch/hpcmips/hpcmips/bus_space.c
--- a/sys/arch/hpcmips/hpcmips/bus_space.c Mon Sep 17 16:26:56 2001 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_space.c Mon Sep 17 17:03:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.12 2001/09/16 05:32:19 uch Exp $ */
+/* $NetBSD: bus_space.c,v 1.13 2001/09/17 17:03:45 uch Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -55,20 +55,39 @@
#define MAX_BUSSPACE_TAG 10
-static struct hpcmips_bus_space sys_bus_space[MAX_BUSSPACE_TAG];
-static int bus_space_index = 0;
-bus_space_handle_t __hpcmips_cacheable(bus_space_tag_t, bus_addr_t,
- bus_size_t, int);
+static struct hpcmips_bus_space __bus_space[MAX_BUSSPACE_TAG];
+static int __bus_space_index;
+static struct hpcmips_bus_space __sys_bus_space;
+static bus_space_tag_t __sys_bus_space_tag;
+
+bus_space_handle_t __hpcmips_cacheable(bus_space_tag_t, bus_addr_t, bus_size_t,
+ int);
+
+bus_space_tag_t
+hpcmips_system_bus_space()
+{
+
+ if (__sys_bus_space_tag != 0)
+ return (__sys_bus_space_tag);
+
+ strcpy(__sys_bus_space.t_name, "whole bus space");
+ __sys_bus_space.t_base = 0x0;
+ __sys_bus_space.t_size = 0xffffffff;
+ __sys_bus_space.t_extent = 0; /* No extent for bootstraping */
+ __sys_bus_space_tag = &__sys_bus_space;
+
+ return (__sys_bus_space_tag);
+}
bus_space_tag_t
hpcmips_alloc_bus_space_tag()
{
bus_space_tag_t t;
- if (bus_space_index >= MAX_BUSSPACE_TAG) {
+ if (__bus_space_index >= MAX_BUSSPACE_TAG) {
panic("hpcmips_internal_alloc_bus_space_tag: tag full.");
}
- t = &sys_bus_space[bus_space_index++];
+ t = &__bus_space[__bus_space_index++];
return (t);
}
diff -r 932c753053b3 -r 843b298e65f3 sys/arch/hpcmips/hpcmips/machdep.c
--- a/sys/arch/hpcmips/hpcmips/machdep.c Mon Sep 17 16:26:56 2001 +0000
+++ b/sys/arch/hpcmips/hpcmips/machdep.c Mon Sep 17 17:03:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.62 2001/09/16 15:45:43 uch Exp $ */
+/* $NetBSD: machdep.c,v 1.63 2001/09/17 17:03:45 uch Exp $ */
/*-
* Copyright (c) 1999 Shin Takemura, All rights reserved.
@@ -67,14 +67,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
+ * from: Utah Hdr: machdep.c 1.63 91/04/24
+ *
* @(#)machdep.c 8.3 (Berkeley) 1/12/94
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.63 2001/09/17 17:03:45 uch Exp $");
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.62 2001/09/16 15:45:43 uch Exp $");
-
-/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
#include "opt_vr41xx.h"
#include "opt_tx39xx.h"
#include "opt_boot_standalone.h"
@@ -94,7 +94,6 @@
#include <sys/reboot.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
-#include <sys/kcore.h>
#include <sys/boot_flag.h>
#include <ufs/mfs/mfs_extern.h> /* mfs_initminiroot() */
diff -r 932c753053b3 -r 843b298e65f3 sys/arch/hpcmips/hpcmips/machdep.h
--- a/sys/arch/hpcmips/hpcmips/machdep.h Mon Sep 17 16:26:56 2001 +0000
+++ b/sys/arch/hpcmips/hpcmips/machdep.h Mon Sep 17 17:03:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.6 2001/09/16 15:45:43 uch Exp $ */
+/* $NetBSD: machdep.h,v 1.7 2001/09/17 17:03:45 uch Exp $ */
/*
* Copyright (c) 1998 Jonathan Stone. All rights reserved.
@@ -34,5 +34,9 @@
extern struct device *booted_device;
extern int booted_partition;
+#include <sys/kcore.h>
+extern phys_ram_seg_t mem_clusters[];
+extern int mem_cluster_cnt;
+
int badaddr(void *, u_int);
void makebootdev(char *);
diff -r 932c753053b3 -r 843b298e65f3 sys/arch/hpcmips/hpcmips/mainbus.c
--- a/sys/arch/hpcmips/hpcmips/mainbus.c Mon Sep 17 16:26:56 2001 +0000
+++ b/sys/arch/hpcmips/hpcmips/mainbus.c Mon Sep 17 17:03:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.13 2001/09/16 15:45:44 uch Exp $ */
+/* $NetBSD: mainbus.c,v 1.14 2001/09/17 17:03:45 uch Exp $ */
/*-
* Copyright (c) 1999
@@ -34,116 +34,91 @@
*
*/
-#include "opt_vr41xx.h"
-#include "opt_tx39xx.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <machine/platid.h>
-#include <machine/platid_mask.h>
+
+#include "locators.h"
-/* Definition of the mainbus driver. */
-static int mbmatch(struct device *, struct cfdata *, void *);
-static void mbattach(struct device *, struct device *, void *);
-static int mbprint(void *, const char *);
+#ifdef DEBUG
+#define STATIC
+#else
+#define STATIC static
+#endif
-bus_space_tag_t mb_bus_space_init(void);
+STATIC int mainbus_match(struct device *, struct cfdata *, void *);
+STATIC void mainbus_attach(struct device *, struct device *, void *);
+STATIC int mainbus_search(struct device *, struct cfdata *, void *);
+STATIC int mainbus_print(void *, const char *);
struct cfattach mainbus_ca = {
- sizeof(struct device), mbmatch, mbattach
+ sizeof(struct device), mainbus_match, mainbus_attach
};
-bus_space_tag_t system_bus_iot; /* Serial console requires this */
-static int mainbus_found; /* There can be only one. */
+STATIC int __mainbus_attached;
-static int
-mbmatch(struct device *parent, struct cfdata *cf, void *aux)
+int
+mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
{
- if (mainbus_found)
- return (0);
-
- return (1);
-}
-
-bus_space_tag_t
-mb_bus_space_init()
-{
- bus_space_tag_t iot;
-
- iot = hpcmips_alloc_bus_space_tag();
- strcpy(iot->t_name, "System internal");
- iot->t_base = 0x0;
- iot->t_size = 0xffffffff;
- iot->t_extent = 0; /* No extent for bootstraping */
- system_bus_iot = iot;
-
- return (iot);
+ return (__mainbus_attached ? 0 : 1); /* don't attach twice */
}
-static void
-mbattach(struct device *parent, struct device *self, void *aux)
+void
+mainbus_attach(struct device *parent, struct device *self, void *aux)
{
- int i;
- register struct device *mb = self;
+ static const char *devnames[] = { /* ATTACH ORDER */
+ "cpu", /* 1. CPU */
+ "vrip", "txsim", /* 2. System BUS */
+ "bivideo", "btnmgr", "hpcapm", /* 3. misc */
+ };
struct mainbus_attach_args ma;
- char *devnames[] = {
- "txsim", "vrip", "bivideo", "btnmgr", "hpcapm",
- };
+ int i;
- mainbus_found = 1;
-
+ __mainbus_attached = 1;
+
printf("\n");
- /* Attach CPU */
- ma.ma_name = "cpu";
- config_found(mb, &ma, mbprint);
-
-#if defined TX39XX && defined VR41XX
-/* XXX: currently, the case defined TX39XX && defined VR41XX don't work */
-#error misconfiguration
-#endif /* defined TX39XX && defined VR41XX */
+ /* default dumb bus_space */
+ ma.ma_iot = hpcmips_system_bus_space();
+ hpcmips_init_bus_space_extent(ma.ma_iot);
- /* Platform Specific Function Hooks */
-#ifdef VR41XX
-#ifdef TX39XX
- if (platid_match(&platid, &platid_mask_CPU_MIPS_VR_41XX))
-#endif /* TX39XX */
- {
- if (!system_bus_iot)
- mb_bus_space_init();
- /* Now prepare extent */
- hpcmips_init_bus_space_extent(system_bus_iot);
- ma.ma_iot = system_bus_iot;
- }
-#endif /* VR41XX */
-#ifdef TX39XX
-#ifdef VR41XX
- if (platid_match(&platid, &platid_mask_CPU_MIPS_TX_3900)
- || platid_match(&platid, &platid_mask_CPU_MIPS_TX_3920))
-#endif /* VR41XX */
- {
- ; /* do nothing.. */
- }
-#endif /* TX39XX */
-
- /* Attach devices */
- for (i = 0; i < sizeof(devnames)/sizeof(*devnames); i++) {
+ /* search and attach devices in order */
+ for (i = 0; i < sizeof(devnames) / sizeof(devnames[0]); i++) {
ma.ma_name = devnames[i];
- config_found(mb, &ma, mbprint);
+ config_search(mainbus_search, self, &ma);
}
}
+int
+mainbus_search(struct device *parent, struct cfdata *cf, void *aux)
+{
+ struct mainbus_attach_args *ma = (void *)aux;
+ int locator = cf->cf_loc[MAINBUSCF_ID];
-static int
-mbprint(void *aux, const char *pnp)
+ /* check device name */
+ if (strcmp(ma->ma_name, cf->cf_driver->cd_name) != 0)
+ return (0);
+
+ /* check platform ID in config file */
+ if (locator != MAINBUSCF_ID_DEFAULT &&
+ !platid_match(&platid, PLATID_DEREFP(locator)))
+ return (0);
+
+ /* attach device */
+ if ((*cf->cf_attach->ca_match)(parent, cf, ma))
+ config_attach(parent, cf, ma, mainbus_print);
+
+ return (0);
+}
+
+int
Home |
Main Index |
Thread Index |
Old Index