From owner-p4-projects@FreeBSD.ORG Thu Aug 10 23:25:59 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 95C2D16A4E5; Thu, 10 Aug 2006 23:25:59 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5932416A4DE for ; Thu, 10 Aug 2006 23:25:59 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D3BA143D6A for ; Thu, 10 Aug 2006 23:25:58 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7ANPwQj079609 for ; Thu, 10 Aug 2006 23:25:58 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7ANPwP4079606 for perforce@freebsd.org; Thu, 10 Aug 2006 23:25:58 GMT (envelope-from imp@freebsd.org) Date: Thu, 10 Aug 2006 23:25:58 GMT Message-Id: <200608102325.k7ANPwP4079606@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 103618 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2006 23:25:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=103618 Change 103618 by imp@imp_lighthouse on 2006/08/10 23:25:53 Save 3108 bytes in bootsd by separating out the init part of emac and the tftp part of emac. Considering that we're talking 316 bytes now and 3428 before, that's a 90% savings for the emac contribution to size. alas, anything that implements tftp will still pay this price. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/Makefile#15 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.c#24 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.h#8 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac_init.c#1 add Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/Makefile#15 (text+ko) ==== @@ -4,7 +4,7 @@ LIB= at91 INTERNALLIB= -SRCS=at91rm9200_lowlevel.c delay.c eeprom.c emac.c fpga.c getc.c \ +SRCS=at91rm9200_lowlevel.c delay.c eeprom.c emac.c emac_init.c fpga.c getc.c \ p_string.c putchar.c printf.c reset.c spi_flash.c xmodem.c NO_MAN= ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.c#24 (text+ko) ==== @@ -29,22 +29,14 @@ /* ********************** PRIVATE FUNCTIONS/DATA ******************************/ -static unsigned localMACSet, serverMACSet; -static unsigned char localMACAddr[6], serverMACAddr[6]; -static unsigned localMAClow, localMAChigh; -static unsigned localIPSet, serverIPSet; +static char serverMACAddr[6]; static unsigned char localIPAddr[4], serverIPAddr[4]; -static unsigned short serverPort, localPort; static int ackBlock; -static unsigned lastSize; static char *dlAddress; static unsigned transmitBuffer[1024 / sizeof(unsigned)]; static unsigned tftpSendPacket[256 / sizeof(unsigned)]; -receive_descriptor_t *p_rxBD; - - /* * .KB_C_FN_DEFINITION_START * unsigned short IP_checksum(unsigned short *p, int len) @@ -472,64 +464,8 @@ /* ************************** GLOBAL FUNCTIONS ********************************/ - /* * .KB_C_FN_DEFINITION_START - * void EMAC_SetMACAddress(unsigned low_address, unsigned high_address) - * This global function sets the MAC address. low_address is the first - * four bytes while high_address is the last 2 bytes of the 48-bit value. - * .KB_C_FN_DEFINITION_END - */ -void -EMAC_SetMACAddress(unsigned char mac[6]) -{ - AT91PS_PMC pPMC = AT91C_BASE_PMC; - AT91PS_EMAC pEmac = AT91C_BASE_EMAC; - - /* enable the peripheral clock before using EMAC */ - pPMC->PMC_PCER = ((unsigned) 1 << AT91C_ID_EMAC); - - p_memcpy(localMACAddr, mac, 6); - localMAClow = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; - localMAChigh = (mac[0] << 8) | mac[1]; - localMACSet = 1; - - AT91C_BASE_PMC->PMC_PCER = 1u << AT91C_ID_EMAC; - AT91C_BASE_PIOA->PIO_ASR = - AT91C_PA14_ERXER | AT91C_PA12_ERX0 | AT91C_PA13_ERX1 | - AT91C_PA8_ETXEN | AT91C_PA16_EMDIO | AT91C_PA9_ETX0 | - AT91C_PA10_ETX1 | AT91C_PA11_ECRS_ECRSDV | AT91C_PA15_EMDC | - AT91C_PA7_ETXCK_EREFCK; - AT91C_BASE_PIOA->PIO_PDR = - AT91C_PA14_ERXER | AT91C_PA12_ERX0 | AT91C_PA13_ERX1 | - AT91C_PA8_ETXEN | AT91C_PA16_EMDIO | AT91C_PA9_ETX0 | - AT91C_PA10_ETX1 | AT91C_PA11_ECRS_ECRSDV | AT91C_PA15_EMDC | - AT91C_PA7_ETXCK_EREFCK; -#ifdef BOOT_KB9202 /* Really !RMII */ - AT91C_BASE_PIOB->PIO_BSR = - AT91C_PB12_ETX2 | AT91C_PB13_ETX3 | AT91C_PB14_ETXER | - AT91C_PB15_ERX2 | AT91C_PB16_ERX3 | AT91C_PB17_ERXDV | - AT91C_PB18_ECOL | AT91C_PB19_ERXCK; - AT91C_BASE_PIOB->PIO_PDR = - AT91C_PB12_ETX2 | AT91C_PB13_ETX3 | AT91C_PB14_ETXER | - AT91C_PB15_ERX2 | AT91C_PB16_ERX3 | AT91C_PB17_ERXDV | - AT91C_PB18_ECOL | AT91C_PB19_ERXCK; -#endif - pEmac->EMAC_CTL = 0; - - pEmac->EMAC_CFG = (pEmac->EMAC_CFG & ~(AT91C_EMAC_CLK)) | -#ifdef BOOT_TSC - AT91C_EMAC_RMII | -#endif - AT91C_EMAC_CLK_HCLK_32 | AT91C_EMAC_CAF; - // the sequence write EMAC_SA1L and write EMAC_SA1H must be respected - pEmac->EMAC_SA1L = localMAClow; - pEmac->EMAC_SA1H = localMAChigh; -} - - -/* - * .KB_C_FN_DEFINITION_START * void SetServerIPAddress(unsigned address) * This global function sets the IP of the TFTP download server. * .KB_C_FN_DEFINITION_END @@ -622,22 +558,3 @@ if (timeout == 0) printf("TFTP TIMEOUT!\r\n"); } - - -/* - * .KB_C_FN_DEFINITION_START - * void EMAC_Init(void) - * This global function initializes variables used in tftp transfers. - * .KB_C_FN_DEFINITION_END - */ -void -EMAC_Init(void) -{ - p_rxBD = (receive_descriptor_t*)RX_BUFFER_START; - localMACSet = 0; - serverMACSet = 0; - localIPSet = 0; - serverIPSet = 0; - localPort = SWAP16(0x8002); - lastSize = 0; -} ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.h#8 (text+ko) ==== @@ -127,4 +127,12 @@ #define MII_SSTS_10HDX 0x1000 #endif +extern unsigned char localMACAddr[6]; +extern unsigned localMAClow, localMAChigh; +extern unsigned localMACSet, serverMACSet; +extern receive_descriptor_t *p_rxBD; +extern unsigned lastSize; +extern unsigned localIPSet, serverIPSet; +extern unsigned short serverPort, localPort; + #endif /* _EMAC_H_ */