Date: Sat, 9 Jun 2007 14:39:42 +0200 From: Bernd Walter <ticso@cicely12.cicely.de> To: =?iso-8859-1?Q?Bj=F6rn_K=F6nig?= <bkoenig@alpha-tierchen.de> Cc: arm@freebsd.org, ticso@cicely.de Subject: Re: if_ate handles the bytes of the MAC address in a "wrong" order Message-ID: <20070609123941.GJ16463@cicely12.cicely.de> In-Reply-To: <59832.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181391583.squirrel@webmail.alpha-tierchen.de> References: <53385.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181314300.squirrel@webmail.alpha-tierchen.de> <20070608.120902.-399284744.imp@bsdimp.com> <20070608225912.GB16463@cicely12.cicely.de> <63859.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181372440.squirrel@webmail.alpha-tierchen.de> <20070609092708.GE16463@cicely12.cicely.de> <58807.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181386624.squirrel@webmail.alpha-tierchen.de> <20070609112758.GH16463@cicely12.cicely.de> <59832.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181391583.squirrel@webmail.alpha-tierchen.de>
index | next in thread | previous in thread | raw e-mail
On Sat, Jun 09, 2007 at 02:19:43PM +0200, Björn König wrote:
> This is finally my suggestion for a new ate_get_mac function that
> corresponds with the ate_set_mac function and with Linux's code, but not
> with the SAM7X example.
They do all agree - it is the same as the SAM7X.
However - I prefer the explizit byte code as we do now, instead of
using bcopy.
Of course we need to fix the order in our loader ocde as well.
> --- src/sys/arm/at91/if_ate.c.orig Fri Feb 23 13:18:27 2007
> +++ src/sys/arm/at91/if_ate.c Sat Jun 9 13:59:16 2007
> @@ -170,7 +170,7 @@
> struct sysctl_ctx_list *sctx;
> struct sysctl_oid *soid;
> int err;
> - u_char eaddr[6];
> + u_char eaddr[ETHER_ADDR_LEN];
>
> sc->dev = dev;
> err = ate_activate(dev);
> @@ -587,24 +587,28 @@
> static int
> ate_get_mac(struct ate_softc *sc, u_char *eaddr)
> {
> + bus_size_t sa_low_reg[] = { ETH_SA1L, ETH_SA2L, ETH_SA3L, ETH_SA4L };
> + bus_size_t sa_high_reg[] = { ETH_SA1H, ETH_SA2H, ETH_SA3H, ETH_SA4H };
> uint32_t low, high;
> + int i;
>
> /*
> * The boot loader setup the MAC with an address, if one is set in
> - * the loader. The TSC loader will also set the MAC address in a
> - * similar way. Grab the MAC address from the SA1[HL] registers.
> + * the loader. Grab the MAC address from the SA[1-4][HL] registers.
> */
> - low = RD4(sc, ETH_SA1L);
> - high = RD4(sc, ETH_SA1H);
> - if ((low | (high & 0xffff)) == 0)
> - return (ENXIO);
> - eaddr[0] = (high >> 8) & 0xff;
> - eaddr[1] = high & 0xff;
> - eaddr[2] = (low >> 24) & 0xff;
> - eaddr[3] = (low >> 16) & 0xff;
> - eaddr[4] = (low >> 8) & 0xff;
> - eaddr[5] = low & 0xff;
> - return (0);
> + for (i = 0; i < 4; i++)
> + {
> + low = RD4(sc, sa_low_reg[i]);
> + high = RD4(sc, sa_high_reg[i]);
> + if ((low | (high & 0xffff)) != 0)
> + {
> + bcopy(&low, eaddr, 4);
> + bcopy(&high, eaddr+4, 2);
> + return (0);
> + }
> + }
> +
> + return (ENXIO);
> }
>
> static void
--
B.Walter http://www.bwct.de http://www.fizon.de
bernd@bwct.de info@bwct.de support@fizon.de
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070609123941.GJ16463>
