summaryrefslogtreecommitdiff
path: root/usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c')
-rw-r--r--usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c b/usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c
new file mode 100644
index 0000000000..492b66869d
--- /dev/null
+++ b/usr/src/psm/promif/ieee1275/sun4/prom_macaddr.c
@@ -0,0 +1,78 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 1994, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Return our machine address in the single argument.
+ */
+
+#include <sys/promif.h>
+#include <sys/promimpl.h>
+#include <sys/idprom.h>
+
+/*ARGSUSED*/
+int
+prom_getmacaddr(ihandle_t hd, caddr_t ea)
+{
+ idprom_t idprom;
+ dnode_t macnodeid;
+
+ /*
+ * Look for the 'mac-address' property in the device node
+ * associated with the ihandle 'hd'. This handles the
+ * cases when we booted from the network device, using either
+ * the platform mac address or a local mac address. This
+ * code will always return whichever mac-address was used by the
+ * firmware (local or platform, depending on nvram settings).
+ */
+ macnodeid = prom_getphandle(hd);
+ if (macnodeid != OBP_BADNODE) {
+ if (prom_getproplen(macnodeid, OBP_MAC_ADDR) != -1) {
+ (void) prom_getprop(macnodeid, OBP_MAC_ADDR, ea);
+ return (0);
+ }
+ }
+
+ /*
+ * The code above, should have taken care of the case
+ * when we booted from the device ... otherwise, as a fallback
+ * case, return the system mac address from the idprom.
+ * This code (idprom) is SMCC (and compatibles) platform-centric.
+ * This code always returns the platform mac address.
+ */
+ if (prom_getidprom((caddr_t) &idprom, sizeof (idprom)) == 0) {
+ register char *f = (char *) idprom.id_ether;
+ register char *t = ea;
+ int i;
+
+ for (i = 0; i < sizeof (idprom.id_ether); ++i)
+ *t++ = *f++;
+
+ return (0);
+ } else
+ return (-1); /* our world must be starting to explode */
+}