PERFORCE change 95809 for review
Warner Losh
imp at FreeBSD.org
Fri Apr 21 18:23:38 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95809
Change 95809 by imp at imp_hammer on 2006/04/21 18:23:00
formatting nits
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.c#6 edit
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/emac.c#6 (text+ko) ====
@@ -52,7 +52,8 @@
* This private function calculates the IP checksum for various headers.
* .KB_C_FN_DEFINITION_END
*/
-static unsigned short IP_checksum(unsigned short *p, int len)
+static unsigned short
+IP_checksum(unsigned short *p, int len)
{
unsigned i, t;
@@ -72,8 +73,9 @@
* This private function sends an ARP request to determine the server MAC.
* .KB_C_FN_DEFINITION_END
*/
-static void GetServerAddress(void) {
-
+static void
+GetServerAddress(void)
+{
arp_header_t *p_ARP;
p_ARP = (arp_header_t*)transmitBuffer;
@@ -112,7 +114,8 @@
* This private function initializes and send a TFTP packet.
* .KB_C_FN_DEFINITION_END
*/
-static void Send_TFTP_Packet(char *tftpData, unsigned tftpLength)
+static void
+Send_TFTP_Packet(char *tftpData, unsigned tftpLength)
{
transmit_header_t *macHdr = (transmit_header_t*)tftpSendPacket;
ip_header_t *ipHdr;
@@ -175,8 +178,9 @@
* This private function sends a RRQ packet to the server.
* .KB_C_FN_DEFINITION_END
*/
-static void TFTP_RequestFile(char *filename) {
-
+static void
+TFTP_RequestFile(char *filename)
+{
tftp_header_t tftpHeader;
char *cPtr, *ePtr, *mPtr;
unsigned length;
@@ -201,8 +205,9 @@
* This private function sends an ACK packet to the server.
* .KB_C_FN_DEFINITION_END
*/
-static void TFTP_ACK_Data(char *data, unsigned short block_num, unsigned short len) {
-
+static void
+TFTP_ACK_Data(char *data, unsigned short block_num, unsigned short len)
+{
tftp_header_t tftpHeader;
if (block_num == (ackBlock + 1)) {
@@ -228,8 +233,9 @@
* any here.
* .KB_C_FN_DEFINITION_END
*/
-static void CheckForNewPacket(ip_header_t *pHeader) {
-
+static void
+CheckForNewPacket(ip_header_t *pHeader)
+{
unsigned short *pFrameType, *pArpOp;
unsigned i;
char *pData;
@@ -358,8 +364,9 @@
* This private function reads the PHY device.
* .KB_C_FN_DEFINITION_END
*/
-static unsigned short AT91F_MII_ReadPhy (AT91PS_EMAC pEmac, unsigned char addr) {
-
+static unsigned short
+AT91F_MII_ReadPhy (AT91PS_EMAC pEmac, unsigned char addr)
+{
unsigned value = 0x60020000 | (addr << 18);
pEmac->EMAC_CTL |= AT91C_EMAC_MPE;
@@ -376,8 +383,9 @@
* This private function determines the link speed set by the PHY.
* .KB_C_FN_DEFINITION_END
*/
-static void MII_GetLinkSpeed(AT91PS_EMAC pEmac) {
-
+static void
+MII_GetLinkSpeed(AT91PS_EMAC pEmac)
+{
unsigned short stat2;
unsigned update = 0;
@@ -409,8 +417,9 @@
* This private function initializes the EMAC on the chip.
* .KB_C_FN_DEFINITION_END
*/
-static void AT91F_EmacEntry(void) {
-
+static void
+AT91F_EmacEntry(void)
+{
unsigned i;
char *pRxPacket = (char*)RX_DATA_START;
AT91PS_EMAC pEmac = AT91C_BASE_EMAC;
@@ -455,8 +464,9 @@
* four bytes while high_address is the last 2 bytes of the 48-bit value.
* .KB_C_FN_DEFINITION_END
*/
-void SetMACAddress(unsigned low_address, unsigned high_address) {
-
+void
+SetMACAddress(unsigned low_address, unsigned high_address)
+{
AT91PS_EMAC pEmac = AT91C_BASE_EMAC;
AT91PS_PMC pPMC = AT91C_BASE_PMC;
@@ -490,8 +500,9 @@
* This global function sets the IP of the TFTP download server.
* .KB_C_FN_DEFINITION_END
*/
-void SetServerIPAddress(unsigned address) {
-
+void
+SetServerIPAddress(unsigned address)
+{
// force update in case the IP has changed
serverMACSet = 0;
@@ -510,8 +521,9 @@
* This global function sets the IP of this module.
* .KB_C_FN_DEFINITION_END
*/
-void SetLocalIPAddress(unsigned address) {
-
+void
+SetLocalIPAddress(unsigned address)
+{
// force update in case the IP has changed
serverMACSet = 0;
@@ -532,7 +544,8 @@
* executed.
* .KB_C_FN_DEFINITION_END
*/
-void TFTP_Download(unsigned address, char *filename)
+void
+TFTP_Download(unsigned address, char *filename)
{
ip_header_t IpHeader;
unsigned thisSeconds, running, state;
@@ -550,53 +563,25 @@
return ;
if (!MAC_init) {
- AT91C_BASE_PMC->PMC_PCER =
- ((unsigned) 1 << AT91C_ID_EMAC);
-
+ AT91C_BASE_PMC->PMC_PCER = 1u << AT91C_ID_EMAC;
AT91C_BASE_PIOA->PIO_ASR =
- ((unsigned) AT91C_PA14_ERXER ) |
- ((unsigned) AT91C_PA12_ERX0 ) |
- ((unsigned) AT91C_PA13_ERX1 ) |
- ((unsigned) AT91C_PA8_ETXEN ) |
- ((unsigned) AT91C_PA16_EMDIO ) |
- ((unsigned) AT91C_PA9_ETX0 ) |
- ((unsigned) AT91C_PA10_ETX1 ) |
- ((unsigned) AT91C_PA11_ECRS_ECRSDV) |
- ((unsigned) AT91C_PA15_EMDC ) |
- ((unsigned) AT91C_PA7_ETXCK_EREFCK);
- AT91C_BASE_PIOA->PIO_BSR = 0;
+ 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 =
- ((unsigned) AT91C_PA14_ERXER ) |
- ((unsigned) AT91C_PA12_ERX0 ) |
- ((unsigned) AT91C_PA13_ERX1 ) |
- ((unsigned) AT91C_PA8_ETXEN ) |
- ((unsigned) AT91C_PA16_EMDIO ) |
- ((unsigned) AT91C_PA9_ETX0 ) |
- ((unsigned) AT91C_PA10_ETX1 ) |
- ((unsigned) AT91C_PA11_ECRS_ECRSDV) |
- ((unsigned) AT91C_PA15_EMDC ) |
- ((unsigned) AT91C_PA7_ETXCK_EREFCK);
-
- AT91C_BASE_PIOB->PIO_ASR = 0;
+ 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_PIOB->PIO_BSR =
- ((unsigned) AT91C_PB12_ETX2) |
- ((unsigned) AT91C_PB13_ETX3) |
- ((unsigned) AT91C_PB14_ETXER) |
- ((unsigned) AT91C_PB15_ERX2) |
- ((unsigned) AT91C_PB16_ERX3) |
- ((unsigned) AT91C_PB17_ERXDV) |
- ((unsigned) AT91C_PB18_ECOL) |
- ((unsigned) AT91C_PB19_ERXCK);
+ 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 =
- ((unsigned) AT91C_PB12_ETX2) |
- ((unsigned) AT91C_PB13_ETX3) |
- ((unsigned) AT91C_PB14_ETXER) |
- ((unsigned) AT91C_PB15_ERX2) |
- ((unsigned) AT91C_PB16_ERX3) |
- ((unsigned) AT91C_PB17_ERXDV) |
- ((unsigned) AT91C_PB18_ECOL) |
- ((unsigned) AT91C_PB19_ERXCK);
-
+ AT91C_PB12_ETX2 | AT91C_PB13_ETX3 | AT91C_PB14_ETXER |
+ AT91C_PB15_ERX2 | AT91C_PB16_ERX3 | AT91C_PB17_ERXDV |
+ AT91C_PB18_ECOL | AT91C_PB19_ERXCK;
MAC_init = 1;
}
@@ -663,6 +648,8 @@
break;
}
}
+ if (timeout == 0)
+ printf("TFTP TIMEOUT!\r\n");
}
@@ -672,8 +659,9 @@
* This global function initializes variables used in tftp transfers.
* .KB_C_FN_DEFINITION_END
*/
-void EMAC_Init(void) {
-
+void
+EMAC_Init(void)
+{
p_rxBD = (receive_descriptor_t*)RX_BUFFER_START;
localMACSet = 0;
serverMACSet = 0;
More information about the p4-projects
mailing list