Some integrated Davicom cards in sparc64 boxes have an all zeros

MAC address in the EEPROM, and we need to get it from OpenFirmware.
This isn't very pretty but time is lacking to do this in a better
way this near 5.2-RELEASE.  This is a RELENG_5_2 candidate.

Original version by:	Marius Strobl <marius@alchemy.franken.de>
Tested by:		Pete Bentley <pete@sorted.org>
Reviewed by:		jake
This commit is contained in:
Maxime Henrion 2004-01-08 19:08:27 +00:00
parent 53369ac9bb
commit ec6a729924
4 changed files with 54 additions and 0 deletions

View File

@ -131,6 +131,11 @@ __FBSDID("$FreeBSD$");
#include <pci/if_dcreg.h>
#ifdef __sparc64__
#include <dev/ofw/openfirm.h>
#include <machine/ofw_machdep.h>
#endif
MODULE_DEPEND(dc, pci, 1, 1, 1);
MODULE_DEPEND(dc, ether, 1, 1, 1);
MODULE_DEPEND(dc, miibus, 1, 1, 1);
@ -2106,6 +2111,19 @@ dc_attach(device_t dev)
dc_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 1);
break;
case DC_TYPE_DM9102:
dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);
#ifdef __sparc64__
/*
* If this is an onboard dc(4) the station address read from
* the EEPROM is all zero and we have to get it from the fcode.
*/
for (i = 0; i < ETHER_ADDR_LEN; i++)
if (eaddr[i] != 0x00)
break;
if (i >= ETHER_ADDR_LEN && OF_getetheraddr2(dev, eaddr) == -1)
OF_getetheraddr(dev, eaddr);
#endif
break;
case DC_TYPE_21143:
case DC_TYPE_ASIX:
dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);

View File

@ -131,6 +131,11 @@ __FBSDID("$FreeBSD$");
#include <pci/if_dcreg.h>
#ifdef __sparc64__
#include <dev/ofw/openfirm.h>
#include <machine/ofw_machdep.h>
#endif
MODULE_DEPEND(dc, pci, 1, 1, 1);
MODULE_DEPEND(dc, ether, 1, 1, 1);
MODULE_DEPEND(dc, miibus, 1, 1, 1);
@ -2106,6 +2111,19 @@ dc_attach(device_t dev)
dc_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 1);
break;
case DC_TYPE_DM9102:
dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);
#ifdef __sparc64__
/*
* If this is an onboard dc(4) the station address read from
* the EEPROM is all zero and we have to get it from the fcode.
*/
for (i = 0; i < ETHER_ADDR_LEN; i++)
if (eaddr[i] != 0x00)
break;
if (i >= ETHER_ADDR_LEN && OF_getetheraddr2(dev, eaddr) == -1)
OF_getetheraddr(dev, eaddr);
#endif
break;
case DC_TYPE_21143:
case DC_TYPE_ASIX:
dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);

View File

@ -32,6 +32,7 @@
int OF_decode_addr(phandle_t, int *, bus_addr_t *);
void OF_getetheraddr(device_t, u_char *);
int OF_getetheraddr2(device_t, u_char *);
void cpu_shutdown(void *);
void openfirmware_exit(void *);

View File

@ -29,6 +29,8 @@
* Some OpenFirmware helper functions that are likely machine dependent.
*/
#include "opt_ofw_pci.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -58,6 +60,21 @@ OF_getetheraddr(device_t dev, u_char *addr)
bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN);
}
int
OF_getetheraddr2(device_t dev, u_char *addr)
{
phandle_t node;
#ifdef OFW_NEWPCI
node = ofw_pci_get_node(dev);
#else
node = ofw_pci_node(dev);
#endif
if (node <= 0)
return (-1);
return (OF_getprop(node, "local-mac-address", addr, ETHER_ADDR_LEN));
}
int
OF_decode_addr(phandle_t node, int *space, bus_addr_t *addr)
{