Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Aug 2006 23:25:58 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 103618 for review
Message-ID:  <200608102325.k7ANPwP4079606@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608102325.k7ANPwP4079606>