Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 Switch to the sparc prom library.



details:   https://anonhg.NetBSD.org/src/rev/276f3d1863ed
branches:  trunk
changeset: 559646:276f3d1863ed
user:      pk <pk%NetBSD.org@localhost>
date:      Sun Mar 21 14:10:08 2004 +0000

description:
Switch to the sparc prom library.

diffstat:

 sys/arch/sparc64/include/autoconf.h |   29 +---
 sys/arch/sparc64/include/sparc64.h  |    7 +-
 sys/arch/sparc64/sparc64/autoconf.c |  285 +-----------------------------------
 3 files changed, 10 insertions(+), 311 deletions(-)

diffs (truncated from 421 to 300 lines):

diff -r b32a474ed802 -r 276f3d1863ed sys/arch/sparc64/include/autoconf.h
--- a/sys/arch/sparc64/include/autoconf.h       Sun Mar 21 14:07:01 2004 +0000
+++ b/sys/arch/sparc64/include/autoconf.h       Sun Mar 21 14:10:08 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.h,v 1.20 2004/03/19 15:22:43 pk Exp $ */
+/*     $NetBSD: autoconf.h,v 1.21 2004/03/21 14:10:08 pk Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include <machine/bus.h>
-/*notyet:#include <machine/promlib.h>*/
+#include <machine/promlib.h>
 #include <dev/sbus/sbusvar.h>
 
 /* This is used to map device classes to IPLs */
@@ -126,20 +126,6 @@
 };
 
 /*
- * length; the others convert or make some other guarantee.
- */
-long   prom_getproplen __P((int node, char *name));
-int    prom_getprop __P((int, char *, size_t, int *, void *));
-char   *prom_getpropstring __P((int node, char *name));
-int    prom_getpropint __P((int node, char *name, int deflt));
-
-       /* new interfaces: */
-char   *prom_getpropstringA __P((int, char *, char *, size_t));
-
-struct idprom  *prom_getidprom(void);
-void           prom_getether(int, u_char *);
-
-/*
  * The matchbyname function is useful in drivers that are matched
  * by romaux name, i.e., all `mainbus attached' devices.  It expects
  * its aux pointer to point to a pointer to the name (the address of
@@ -172,16 +158,5 @@
                                      struct device *));
 
 void   bootstrap __P((int));
-int    firstchild __P((int));
-int    nextsibling __P((int));
-void   callrom __P((void));
 struct device *getdevunit __P((char *, int));
-void   *findzs __P((int));
-void   rominterpret __P((char *));
 int    romgetcursoraddr __P((int **, int **));
-int    findroot __P((void));
-int    findnode __P((int, const char *));
-int    node_has_property __P((int, const char *));
-int    prom_getoptionsnode __P((void));
-int    prom_getoption __P((const char *name, char *buf, int buflen));
-
diff -r b32a474ed802 -r 276f3d1863ed sys/arch/sparc64/include/sparc64.h
--- a/sys/arch/sparc64/include/sparc64.h        Sun Mar 21 14:07:01 2004 +0000
+++ b/sys/arch/sparc64/include/sparc64.h        Sun Mar 21 14:10:08 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sparc64.h,v 1.6 2004/03/14 18:18:54 chs Exp $  */
+/*     $NetBSD: sparc64.h,v 1.7 2004/03/21 14:10:08 pk Exp $   */
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -53,9 +53,4 @@
 void prom_stopself(void);
 void prom_startcpu(u_int, void *, u_long);
 
-/*
- * Debug
- */
-void prom_printf (const char *, ...);
-
 #endif /* _MACHINE_SPARC64_H_ */
diff -r b32a474ed802 -r 276f3d1863ed sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Sun Mar 21 14:07:01 2004 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Sun Mar 21 14:10:08 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.94 2004/03/19 15:22:43 pk Exp $ */
+/*     $NetBSD: autoconf.c,v 1.95 2004/03/21 14:10:08 pk Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.94 2004/03/19 15:22:43 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.95 2004/03/21 14:10:08 pk Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -78,7 +78,6 @@
 #include <machine/bus.h>
 #include <machine/autoconf.h>
 #include <machine/openfirm.h>
-#include <machine/idprom.h>
 #include <machine/sparc64.h>
 #include <machine/cpu.h>
 #include <machine/pmap.h>
@@ -102,7 +101,6 @@
 extern int kgdb_debug_panic;
 #endif
 
-static int rootnode;
 char   machine_model[100];
 
 static char *str2hex __P((char *, int *));
@@ -235,6 +233,8 @@
        extern void OF_val2sym32 __P((void *));
 #endif
 
+       prom_init();
+
        /* Initialize the PROM console so printf will not panic */
        (*cn_tab->cn_init)(cn_tab);
 #if NKSYMS || defined(DDB) || defined(LKM)
@@ -553,37 +553,6 @@
 }
 
 int
-findroot()
-{
-       register int node;
-
-       if ((node = rootnode) == 0 && (node = OF_peer(0)) == 0)
-               panic("no PROM root device");
-       rootnode = node;
-       return (node);
-}
-
-/*
- * Given a `first child' node number, locate the node with the given name.
- * Return the node number, or 0 if not found.
- */
-int
-findnode(first, name)
-       int first;
-       register const char *name;
-{
-       int node;
-       char buf[32];
-
-       for (node = first; node; node = OF_peer(node)) {
-               if ((OF_getprop(node, "name", buf, sizeof(buf)) > 0) &&
-                       (strcmp(buf, name) == 0))
-                       return (node);
-       }
-       return (0);
-}
-
-int
 mainbus_match(parent, cf, aux)
        struct device *parent;
        struct cfdata *cf;
@@ -755,247 +724,6 @@
 CFATTACH_DECL(mainbus, sizeof(struct device),
     mainbus_match, mainbus_attach, NULL, NULL);
 
-int
-prom_getprop(node, name, size, nitem, bufp)
-       int     node;
-       char    *name;
-       size_t  size;
-       int     *nitem;
-       void    *bufp;
-{
-       void    *buf;
-       long    len;
-
-       len = prom_getproplen(node, name);
-       if (len <= 0)
-               return (ENOENT);
-
-       if ((len % size) != 0)
-               return (EINVAL);
-
-       buf = *(void **)bufp;
-       if (buf == NULL) {
-               /* No storage provided, so we allocate some */
-               buf = malloc(len, M_DEVBUF, M_NOWAIT);
-               if (buf == NULL)
-                       return (ENOMEM);
-       } else {
-               if (size * (*nitem) < len)
-                       return (ENOMEM);
-       }
-
-       OF_getprop(node, name, buf, len);
-       *(void **)bufp = buf;
-       *nitem = len / size;
-       return (0);
-}
-
-
-/*
- * Internal form of proplen().  Returns the property length.
- */
-long
-prom_getproplen(node, name)
-       int node;
-       char *name;
-{
-       return (OF_getproplen(node, name));
-}
-
-/*
- * Return a string property.  There is a (small) limit on the length;
- * the string is fetched into a static buffer which is overwritten on
- * subsequent calls.
- */
-char *
-prom_getpropstring(node, name)
-       int node;
-       char *name;
-{
-       static char stringbuf[32];
-
-       return (prom_getpropstringA(node, name, stringbuf, sizeof stringbuf));
-}
-
-/* Alternative prom_getpropstring(), where caller provides the buffer */
-char *
-prom_getpropstringA(node, name, buffer, bufsize)
-       int node;
-       char *name;
-       char *buffer;
-       size_t bufsize;
-{
-       int blen = bufsize - 1;
-
-       if (prom_getprop(node, name, 1, &blen, &buffer) != 0)
-               blen = 0;
-
-       buffer[blen] = '\0';    /* usually unnecessary */
-       return (buffer);
-}
-
-/*
- * Fetch an integer (or pointer) property.
- * The return value is the property, or the default if there was none.
- */
-int
-prom_getpropint(node, name, deflt)
-       int node;
-       char *name;
-       int deflt;
-{
-       int intbuf;
-
-       if (OF_getprop(node, name, &intbuf, sizeof(intbuf)) != sizeof(intbuf))
-               return (deflt);
-
-       return (intbuf);
-}
-
-/*
- * OPENPROM functions.  These are here mainly to hide the OPENPROM interface
- * from the rest of the kernel.
- */
-int
-firstchild(node)
-       int node;
-{
-
-       return OF_child(node);
-}
-
-int
-nextsibling(node)
-       int node;
-{
-
-       return OF_peer(node);
-}
-
-/* The following are used primarily in consinit() */
-
-int
-node_has_property(node, prop)  /* returns 1 if node has given property */
-       register int node;
-       register const char *prop;
-{
-       return (OF_getproplen(node, (caddr_t)prop) != -1);
-}
-
-/*
- * Get the global "options" node Id.
- */
-int prom_getoptionsnode()
-{
-static int optionsnode;
-
-       if (optionsnode == 0) {
-               optionsnode = findnode(firstchild(findroot()), "options");
-       }
-       return optionsnode;
-}
-



Home | Main Index | Thread Index | Old Index