Source-Changes-HG archive

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

[src/trunk]: src/sys implement device_register() for ofppc.



details:   https://anonhg.NetBSD.org/src/rev/90ed9978cb9a
branches:  trunk
changeset: 536519:90ed9978cb9a
user:      chs <chs%NetBSD.org@localhost>
date:      Wed Sep 18 01:44:12 2002 +0000

description:
implement device_register() for ofppc.
use ofcons_cnprobe().

diffstat:

 sys/arch/ofppc/firepower/firepower.c |  105 ++++++++++++++++++++++++++++++++++-
 sys/arch/ofppc/include/autoconf.h    |   39 ++++++++-----
 sys/arch/ofppc/include/cpu.h         |    3 +-
 sys/arch/ofppc/include/types.h       |    4 +-
 sys/arch/ofppc/ofppc/machdep.c       |   18 +++---
 sys/arch/ofppc/ofppc/mainbus.c       |   52 +++++++---------
 sys/dev/ofw/ofbus.c                  |   27 +++++---
 sys/dev/ofw/openfirm.h               |   10 ++-
 8 files changed, 186 insertions(+), 72 deletions(-)

diffs (truncated from 486 to 300 lines):

diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/firepower/firepower.c
--- a/sys/arch/ofppc/firepower/firepower.c      Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/firepower/firepower.c      Wed Sep 18 01:44:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firepower.c,v 1.3 2002/07/05 18:45:18 matt Exp $       */
+/*     $NetBSD: firepower.c,v 1.4 2002/09/18 01:44:12 chs Exp $        */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -49,7 +49,14 @@
 
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+#include <dev/ata/atavar.h>
+#include <dev/ata/wdvar.h>
+#include <dev/ic/wdcvar.h>
 
+#include <machine/autoconf.h>
 #include <machine/bat.h>
 #include <machine/intr.h>
 #include <machine/platform.h>
@@ -63,6 +70,9 @@
 void   firepower_cons_init(void);
 void   firepower_device_register(struct device *, void *);
 
+extern char bootpath[];
+extern char cbootpath[];
+
 /*
  * firepower_init:
  *
@@ -74,6 +84,7 @@
 
        platform.cons_init = firepower_cons_init;
        platform.device_register = firepower_device_register;
+       platform.softintr_init = firepower_softintr_init;
 
        /*
         * Map VA==PA the region that includes ISA I/O, PCI Config,
@@ -108,6 +119,11 @@
 {
 }
 
+#define DEVICE_IS(dev, name) \
+       (!strncmp((dev)->dv_xname, (name), sizeof(name) - 1) && \
+        (dev)->dv_xname[sizeof(name) - 1] >= '0' && \
+        (dev)->dv_xname[sizeof(name) - 1] <= '9')
+
 /*
  * firepower_device_register:
  *
@@ -117,6 +133,93 @@
 void
 firepower_device_register(struct device *dev, void *aux)
 {
+       static struct device *parent;
+       static char *bp = bootpath + 1, *cp = cbootpath + 1;
+       unsigned long addr;
+       char *pnext, *paddr;
+       int clen;
+
+       if (booted_device)
+               return;
+
+       /* Skip over devices not represented in the OF tree. */
+       if (DEVICE_IS(dev, "mainbus")) {
+               parent = dev;
+               return;
+       }
+       if (DEVICE_IS(dev, "atapibus") || DEVICE_IS(dev, "scsibus"))
+               return;
+
+       if (DEVICE_IS(dev->dv_parent, "atapibus") ||
+           DEVICE_IS(dev->dv_parent, "scsibus")) {
+               if (dev->dv_parent->dv_parent != parent)
+                       return;
+       } else if (dev->dv_parent != parent) {
+               return;
+       }
+
+       /*
+        * Get the address part of the current path component.
+        */
+       pnext = strchr(cp, '/');
+       if (pnext) {
+               clen = pnext - cp;
+               pnext++;
+       } else {
+               clen = strlen(cp);
+       }
+       addr = 0;
+       paddr = strchr(cp, '@');
+       if (pnext && paddr > pnext) {
+               paddr = NULL;
+       } else if (!paddr && bp) {
+               paddr = strchr(bp, '@');
+       }
+       if (paddr) {
+               addr = strtoul(paddr + 1, NULL, 0x10);
+       }
+
+       if (DEVICE_IS(dev->dv_parent, "mainbus")) {
+               struct ofbus_attach_args *oba = aux;
+               
+               if (strcmp(oba->oba_busname, "cpu") == 0)
+                       return;
+       } else if (DEVICE_IS(dev->dv_parent, "ofbus")) {
+               struct ofbus_attach_args *oba = aux;
+
+               if (strncmp(oba->oba_ofname, cp, clen))
+                       return;
+       } else if (DEVICE_IS(dev->dv_parent, "pci")) {
+               struct pci_attach_args *pa = aux;
+
+               if (addr != pa->pa_device)
+                       return;
+       } else if (DEVICE_IS(dev->dv_parent, "scsibus") ||
+                  DEVICE_IS(dev->dv_parent, "atapibus")) {
+               struct scsipibus_attach_args *sa = aux;
+
+               /* periph_target is target for scsi, drive # for atapi */
+               if (addr != sa->sa_periph->periph_target)
+                       return;
+       } else
+               return;
+
+       /*
+        * If we reach this point, then dev is a match for the current
+        * path component.
+        */
+
+       if (pnext && *pnext) {
+               parent = dev;
+               cp = pnext;
+               bp = strchr(bp, '/');
+               if (bp)
+                       bp++;
+               return;
+       } else {
+               booted_device = dev;
+               return;
+       }
 }
 
 /*
diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/include/autoconf.h
--- a/sys/arch/ofppc/include/autoconf.h Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/include/autoconf.h Wed Sep 18 01:44:12 2002 +0000
@@ -1,20 +1,29 @@
-#ifndef _MACHINE_AUTOCONF_H_
-#define _MACHINE_AUTOCONF_H_
+/*     $NetBSD: autoconf.h,v 1.5 2002/09/18 01:44:13 chs Exp $ */
+
+#ifndef _OFPPC_AUTOCONF_H_
+#define _OFPPC_AUTOCONF_H_
+
+struct confargs {
+       const char      *ca_name;
+       u_int           ca_node;
+       int             ca_nreg;
+       u_int           *ca_reg;
+       int             ca_nintr;
+       int             *ca_intr;
+
+       u_int           ca_baseaddr;
+       /* bus_space_tag_t ca_tag; */
+};
 
 #ifdef _KERNEL
-void initppc (u_int, u_int, char *);
-void strayintr (int);
+void initppc(u_int, u_int, char *);
+void strayintr(int);
 
-void inittodr (time_t);
-void resettodr (void);
-void cpu_initclocks (void);
-void decr_intr (struct clockframe *);
-void setstatclockrate (int);
-
-#ifdef __BROKEN_DK_ESTABLISH
-void dk_cleanup(void);
-#endif
-
+void inittodr(time_t);
+void resettodr(void);
+void cpu_initclocks(void);
+void decr_intr(struct clockframe *);
+void setstatclockrate(int);
 #endif /* _KERNEL */
 
-#endif /* _MACHINE_AUTOCONF_H_ */
+#endif /* _OFPPC_AUTOCONF_H_ */
diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/include/cpu.h
--- a/sys/arch/ofppc/include/cpu.h      Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/include/cpu.h      Wed Sep 18 01:44:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.18 2001/10/22 23:01:18 thorpej Exp $ */
+/*     $NetBSD: cpu.h,v 1.19 2002/09/18 01:44:13 chs Exp $     */
 
 /*
  * Copyright (C) 1995-1997 Wolfgang Solfrank.
@@ -42,7 +42,6 @@
 
 #if defined(_KERNEL)
 #define        CPU_MAXNUM      1
-extern char *bootpath;
 extern struct cfdriver cpu_cd;
 #endif
 
diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/include/types.h
--- a/sys/arch/ofppc/include/types.h    Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/include/types.h    Wed Sep 18 01:44:12 2002 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: types.h,v 1.3 2000/05/16 05:45:49 thorpej Exp $        */
+/*     $NetBSD: types.h,v 1.4 2002/09/18 01:44:13 chs Exp $    */
 
 #include <powerpc/types.h>
 
-#define        __BROKEN_DK_ESTABLISH
+#define __HAVE_DEVICE_REGISTER
diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/ofppc/machdep.c
--- a/sys/arch/ofppc/ofppc/machdep.c    Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/ofppc/machdep.c    Wed Sep 18 01:44:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.77 2002/07/09 19:21:05 matt Exp $        */
+/*     $NetBSD: machdep.c,v 1.78 2002/09/18 01:44:13 chs Exp $ */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -73,7 +73,7 @@
 /*
  * Global variables used here and there
  */
-char *bootpath;
+char bootpath[256];
 
 int lcsplx(int);                       /* called from locore.S */
 
@@ -136,7 +136,7 @@
        /*
         * Parse arg string.
         */
-       bootpath = args;
+       strcpy(bootpath, args);
        while (*++args && *args != ' ');
        if (*args) {
                for(*args++ = 0; *args; args++)
@@ -174,30 +174,30 @@
 void
 cpu_startup()
 {
-       int msr;
+
        mpc6xx_startup(NULL);
 
        /*
         * Now allow hardware interrupts.
         */
        splhigh();
-       asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
-           :   "=r"(msr)
-           :   "K"((u_short)(PSL_EE|PSL_RI)));
+       mtmsr(mfmsr() | PSL_EE | PSL_RI);
+       (*platform.softintr_init)();
 }
 
 void
 consinit()
 {
 
-       /* Nothing to do; console is already initialized. */
+       (*cn_tab->cn_probe)(cn_tab);
 }
 
+void   ofcons_cnprobe(struct consdev *);
 int    ofppc_cngetc(dev_t);
 void   ofppc_cnputc(dev_t, int);
 
 struct consdev ofppc_bootcons = {
-       NULL, NULL, ofppc_cngetc, ofppc_cnputc, nullcnpollc, NULL,
+       ofcons_cnprobe, NULL, ofppc_cngetc, ofppc_cnputc, nullcnpollc, NULL,
            makedev(0,0), 1,
 };
 
diff -r 1b5ce484d5ce -r 90ed9978cb9a sys/arch/ofppc/ofppc/mainbus.c
--- a/sys/arch/ofppc/ofppc/mainbus.c    Wed Sep 18 01:43:07 2002 +0000
+++ b/sys/arch/ofppc/ofppc/mainbus.c    Wed Sep 18 01:44:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.7 2001/10/23 22:52:14 thorpej Exp $       */
+/*     $NetBSD: mainbus.c,v 1.8 2002/09/18 01:44:13 chs Exp $   */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -108,40 +108,35 @@
         * see CPUs after other devices in the boot messages.
         */



Home | Main Index | Thread Index | Old Index