Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc Split the part out of prom_getether() that de...
details: https://anonhg.NetBSD.org/src/rev/a0a7fe8ee585
branches: trunk
changeset: 751007:a0a7fe8ee585
user: martin <martin%NetBSD.org@localhost>
date: Thu Jan 21 11:40:01 2010 +0000
description:
Split the part out of prom_getether() that deals with the local
firmware device node into a new function.
diffstat:
sys/arch/sparc/include/promlib.h | 3 ++-
sys/arch/sparc/sparc/promlib.c | 30 ++++++++++++++++++++----------
2 files changed, 22 insertions(+), 11 deletions(-)
diffs (92 lines):
diff -r c9f818f39a99 -r a0a7fe8ee585 sys/arch/sparc/include/promlib.h
--- a/sys/arch/sparc/include/promlib.h Thu Jan 21 08:57:17 2010 +0000
+++ b/sys/arch/sparc/include/promlib.h Thu Jan 21 11:40:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.h,v 1.23 2008/04/28 20:23:36 martin Exp $ */
+/* $NetBSD: promlib.h,v 1.24 2010/01/21 11:40:01 martin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -129,6 +129,7 @@
struct idprom *prom_getidprom(void);
void prom_getether(int, u_char *);
+bool prom_get_node_ether(int, u_char*);
const char *prom_pa_location(u_int, u_int);
void prom_init(void); /* To setup promops */
diff -r c9f818f39a99 -r a0a7fe8ee585 sys/arch/sparc/sparc/promlib.c
--- a/sys/arch/sparc/sparc/promlib.c Thu Jan 21 08:57:17 2010 +0000
+++ b/sys/arch/sparc/sparc/promlib.c Thu Jan 21 11:40:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.c,v 1.41 2008/04/28 20:23:36 martin Exp $ */
+/* $NetBSD: promlib.c,v 1.42 2010/01/21 11:40:01 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.41 2008/04/28 20:23:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.42 2010/01/21 11:40:01 martin Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sparc_arch.h"
@@ -993,12 +993,24 @@
void prom_getether(int node, u_char *cp)
{
- struct idprom *idp = prom_getidprom();
+ struct idprom *idp;
+
+ if (prom_get_node_ether(node, cp))
+ return;
+
+ /* Fall back on the machine's global ethernet address */
+ idp = prom_getidprom();
+ memcpy(cp, idp->idp_etheraddr, 6);
+}
+
+bool
+prom_get_node_ether(int node, u_char *cp)
+{
char buf[6+1], *bp;
int nitem;
if (node == 0)
- goto read_idprom;
+ return false;
/*
* First, try the node's "mac-address" property.
@@ -1013,7 +1025,7 @@
if (prom_getprop(node, "mac-address", 1, &nitem, &bp) == 0 &&
nitem >= 6) {
memcpy(cp, bp, 6);
- return;
+ return true;
}
/*
@@ -1023,17 +1035,15 @@
*/
if (prom_getoption("local-mac-address?", buf, sizeof buf) != 0 ||
strcmp(buf, "true") != 0)
- goto read_idprom;
+ return false;
/* Retrieve the node's "local-mac-address" property, if any */
nitem = 6;
if (prom_getprop(node, "local-mac-address", 1, &nitem, &cp) == 0 &&
nitem == 6)
- return;
+ return true;
- /* Fall back on the machine's global ethernet address */
-read_idprom:
- memcpy(cp, idp->idp_etheraddr, 6);
+ return false;
}
/*
Home |
Main Index |
Thread Index |
Old Index