mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-15 01:06:41 +08:00
if_cgem: Use rtems_bsd_get_mac_address()
This commit is contained in:
parent
dec6b678bb
commit
6a73f64fe2
@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <rtems/bsd/local/miibus_if.h>
|
#include <rtems/bsd/local/miibus_if.h>
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
||||||
|
#include <rtems/bsd/bsd.h>
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
#define IF_CGEM_NAME "cgem"
|
#define IF_CGEM_NAME "cgem"
|
||||||
@ -233,7 +234,9 @@ static void
|
|||||||
cgem_get_mac(struct cgem_softc *sc, u_char eaddr[])
|
cgem_get_mac(struct cgem_softc *sc, u_char eaddr[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
#ifndef __rtems__
|
||||||
uint32_t rnd;
|
uint32_t rnd;
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
/* See if boot loader gave us a MAC address already. */
|
/* See if boot loader gave us a MAC address already. */
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
@ -252,6 +255,7 @@ cgem_get_mac(struct cgem_softc *sc, u_char eaddr[])
|
|||||||
|
|
||||||
/* No MAC from boot loader? Assign a random one. */
|
/* No MAC from boot loader? Assign a random one. */
|
||||||
if (i == 4) {
|
if (i == 4) {
|
||||||
|
#ifndef __rtems__
|
||||||
rnd = arc4random();
|
rnd = arc4random();
|
||||||
|
|
||||||
eaddr[0] = 'b';
|
eaddr[0] = 'b';
|
||||||
@ -260,6 +264,10 @@ cgem_get_mac(struct cgem_softc *sc, u_char eaddr[])
|
|||||||
eaddr[3] = (rnd >> 16) & 0xff;
|
eaddr[3] = (rnd >> 16) & 0xff;
|
||||||
eaddr[4] = (rnd >> 8) & 0xff;
|
eaddr[4] = (rnd >> 8) & 0xff;
|
||||||
eaddr[5] = rnd & 0xff;
|
eaddr[5] = rnd & 0xff;
|
||||||
|
#else /* __rtems__ */
|
||||||
|
rtems_bsd_get_mac_address(device_get_name(sc->dev),
|
||||||
|
device_get_unit(sc->dev), eaddr);
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
device_printf(sc->dev, "no mac address found, assigning "
|
device_printf(sc->dev, "no mac address found, assigning "
|
||||||
"random: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
"random: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user