From owner-freebsd-arm@FreeBSD.ORG Sun Jun 10 20:47:27 2007 Return-Path: X-Original-To: arm@freebsd.org Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BC6AD16A46B for ; Sun, 10 Jun 2007 20:47:27 +0000 (UTC) (envelope-from bkoenig@alpha-tierchen.de) Received: from mail.liberty-hosting.de (mail.smartterra.de [195.225.132.203]) by mx1.freebsd.org (Postfix) with ESMTP id 50FEF13C45D for ; Sun, 10 Jun 2007 20:47:26 +0000 (UTC) (envelope-from bkoenig@alpha-tierchen.de) Received: from mail.liberty-hosting.de ([195.225.132.203]) by localhost (liberty-mail [195.225.132.203]) (amavisd-new, port 10024) with ESMTP id 64522-10 for ; Sun, 10 Jun 2007 22:47:21 +0200 (CEST) Received: from home.alpha-tierchen.de (port-212-202-170-5.dynamic.qsc.de [212.202.170.5]) by mail.liberty-hosting.de (Postfix) with ESMTP id E63761805BD for ; Sun, 10 Jun 2007 22:47:20 +0200 (CEST) Received: from webmail.alpha-tierchen.de (localhost [127.0.0.1]) by home.alpha-tierchen.de (Postfix) with ESMTP id EF2C145046 for ; Sun, 10 Jun 2007 22:47:17 +0200 (CEST) Received: from 2001:6f8:101e:0:20e:cff:fe6d:6adb (SquirrelMail authenticated user bkoenig) by webmail.alpha-tierchen.de with HTTP; Sun, 10 Jun 2007 22:47:17 +0200 (CEST) Message-ID: <62668.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181508437.squirrel@webmail.alpha-tierchen.de> In-Reply-To: <20070610105550.GQ16463@cicely12.cicely.de> References: <59832.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181391583.squirrel@webmail.alpha-tierchen.de> <20070609123941.GJ16463@cicely12.cicely.de> <51831.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181397815.squirrel@webmail.alpha-tierchen.de> <20070609.094708.-2034663768.imp@bsdimp.com> <1161.89.247.105.240.1181457870.squirrel@webmail.alpha-tierchen.de> <20070610105550.GQ16463@cicely12.cicely.de> Date: Sun, 10 Jun 2007 22:47:17 +0200 (CEST) From: =?iso-8859-1?Q?Bj=F6rn_K=F6nig?= To: arm@freebsd.org User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070610224717_21390" X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at mail.smartterra.de Cc: Subject: Re: if_ate handles the bytes of the MAC address in a "wrong" order X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2007 20:47:27 -0000 ------=_20070610224717_21390 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Ok, this patch additionally adds the kernel option ATE_REVERSE_MAC that allows you to build a kernel that works with a version of the loader that uses the previous byte order. Björn ------=_20070610224717_21390 Content-Type: text/x-diff; name="ate.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="ate.diff" --- src/sys/arm/at91/if_ate.c Sat Jun 9 15:50:50 2007 +++ src/sys/arm/at91/if_ate.c Sun Jun 10 22:06:49 2007 @@ -35,6 +35,10 @@ #include __FBSDID("$FreeBSD: src/sys/arm/at91/if_ate.c,v 1.19 2007/02/23 12:18:27 piso Exp $"); +#ifdef HAVE_KERNEL_OPTION_HEADERS +#include "opt_ate.h" +#endif + #include #include #include @@ -170,7 +174,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 +591,43 @@ 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 one 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) + { +#ifdef ATE_REVERSE_MAC + 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; +#else + + eaddr[0] = low & 0xff; + eaddr[1] = (low >> 8) & 0xff; + eaddr[2] = (low >> 16) & 0xff; + eaddr[3] = (low >> 24) & 0xff; + eaddr[4] = high & 0xff; + eaddr[5] = (high >> 8) & 0xff; +#endif + return (0); + } + } + + return (ENXIO); } static void --- src/sys/boot/arm/at91/libat91/emac_init.c Wed Dec 20 19:26:37 2006 +++ src/sys/boot/arm/at91/libat91/emac_init.c Sat Jun 9 15:55:23 2007 @@ -79,8 +79,8 @@ pPMC->PMC_PCER = ((unsigned) 1 << AT91C_ID_EMAC); memcpy(localMACAddr, mac, 6); - localMAClow = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; - localMAChigh = (mac[0] << 8) | mac[1]; + localMAClow = (mac[3] << 24) | (mac[2] << 16) | (mac[1] << 8) | mac[0]; + localMAChigh = (mac[5] << 8) | mac[4]; localMACSet = 1; AT91C_BASE_PMC->PMC_PCER = 1u << AT91C_ID_EMAC; --- src/sys/conf/options.arm Mon Feb 19 02:03:07 2007 +++ src/sys/conf/options.arm Sun Jun 10 22:01:59 2007 @@ -24,3 +24,4 @@ AT91_BWCT opt_at91.h AT91_TSC opt_at91.h AT91_KWIKBYTE opt_at91.h +ATE_REVERSE_MAC opt_ate.h ------=_20070610224717_21390--