Deleted Added
full compact
emac.c (165401) emac.c (168013)
1/*******************************************************************************
2 *
3 * Filename: emac.c
4 *
5 * Instantiation of routines for MAC/ethernet functions supporting tftp.
6 *
7 * Revision information:
8 *

--- 5 unchanged lines hidden (view full) ---

14 * No warranty, expressed or implied, is included with this software. It is
15 * provided "AS IS" and no warranty of any kind including statutory or aspects
16 * relating to merchantability or fitness for any purpose is provided. All
17 * intellectual property rights of others is maintained with the respective
18 * owners. This software is not copyrighted and is intended for reference
19 * only.
20 * END_BLOCK
21 *
1/*******************************************************************************
2 *
3 * Filename: emac.c
4 *
5 * Instantiation of routines for MAC/ethernet functions supporting tftp.
6 *
7 * Revision information:
8 *

--- 5 unchanged lines hidden (view full) ---

14 * No warranty, expressed or implied, is included with this software. It is
15 * provided "AS IS" and no warranty of any kind including statutory or aspects
16 * relating to merchantability or fitness for any purpose is provided. All
17 * intellectual property rights of others is maintained with the respective
18 * owners. This software is not copyrighted and is intended for reference
19 * only.
20 * END_BLOCK
21 *
22 * $FreeBSD: head/sys/boot/arm/at91/libat91/emac.c 165401 2006-12-20 18:26:37Z imp $
22 * $FreeBSD: head/sys/boot/arm/at91/libat91/emac.c 168013 2007-03-28 22:40:37Z imp $
23 ******************************************************************************/
24
25#include "at91rm9200.h"
26#include "at91rm9200_lowlevel.h"
27#include "emac.h"
28#include "lib.h"
29
30/* ****************************** GLOBALS *************************************/

--- 376 unchanged lines hidden (view full) ---

407#ifdef BOOT_TSC
408 while (1) {
409 for (i = 0; i < 10; i++) {
410 stat2 = AT91F_MII_ReadPhy(pEmac, MII_STS_REG);
411 if (stat2 & MII_STS_LINK_STAT)
412 break;
413 printf(".");
414 sec = GetSeconds();
23 ******************************************************************************/
24
25#include "at91rm9200.h"
26#include "at91rm9200_lowlevel.h"
27#include "emac.h"
28#include "lib.h"
29
30/* ****************************** GLOBALS *************************************/

--- 376 unchanged lines hidden (view full) ---

407#ifdef BOOT_TSC
408 while (1) {
409 for (i = 0; i < 10; i++) {
410 stat2 = AT91F_MII_ReadPhy(pEmac, MII_STS_REG);
411 if (stat2 & MII_STS_LINK_STAT)
412 break;
413 printf(".");
414 sec = GetSeconds();
415 while (GetSeconds() <= sec) continue;
415 while (GetSeconds() == sec)
416 continue;
416 }
417 if (stat2 & MII_STS_LINK_STAT)
418 break;
419 printf("Resetting MII...");
420 AT91F_MII_WritePhy(pEmac, 0x0, 0x8000);
421 while (AT91F_MII_ReadPhy(pEmac, 0x0) & 0x8000) continue;
422 }
423 printf("emac: link");

--- 112 unchanged lines hidden (view full) ---

536 if ((!localMACSet) || (!localIPSet) || (!serverIPSet))
537 return ;
538
539 AT91F_EmacEntry();
540 GetServerAddress();
541 dlAddress = (char*)address;
542 lastSize = 0;
543 timeout = 10;
417 }
418 if (stat2 & MII_STS_LINK_STAT)
419 break;
420 printf("Resetting MII...");
421 AT91F_MII_WritePhy(pEmac, 0x0, 0x8000);
422 while (AT91F_MII_ReadPhy(pEmac, 0x0) & 0x8000) continue;
423 }
424 printf("emac: link");

--- 112 unchanged lines hidden (view full) ---

537 if ((!localMACSet) || (!localIPSet) || (!serverIPSet))
538 return ;
539
540 AT91F_EmacEntry();
541 GetServerAddress();
542 dlAddress = (char*)address;
543 lastSize = 0;
544 timeout = 10;
544 thisSeconds = GetSeconds() + 1;
545 thisSeconds = (GetSeconds() + 2) % 32;
545 serverPort = SWAP16(69);
546 ++localPort;
547 ackBlock = -1;
548
549 while (timeout) {
550 if (CheckForNewPacket(&IpHeader)) {
551 if (ackBlock == -2)
552 break;
553 timeout = 10;
546 serverPort = SWAP16(69);
547 ++localPort;
548 ackBlock = -1;
549
550 while (timeout) {
551 if (CheckForNewPacket(&IpHeader)) {
552 if (ackBlock == -2)
553 break;
554 timeout = 10;
554 thisSeconds = GetSeconds() + 1;
555 } else if (GetSeconds() > thisSeconds) {
555 thisSeconds = (GetSeconds() + 2) % 32;
556 } else if (GetSeconds() == thisSeconds) {
556 --timeout;
557 --timeout;
557 thisSeconds = GetSeconds() + 1;
558 thisSeconds = (GetSeconds() + 2) % 32;
558 if (!serverMACSet)
559 GetServerAddress();
560 else if (ackBlock == -1)
561 TFTP_RequestFile(filename);
562 else {
563 // Be sure to send a NAK, which is done by
564 // ACKing the last block we got.
565 TFTP_ACK_Data(0, ackBlock, 512);
566 printf("\nNAK %u\n", ackBlock);
567 }
568 }
569 }
570 if (timeout == 0)
571 printf("TFTP TIMEOUT!\n");
572}
559 if (!serverMACSet)
560 GetServerAddress();
561 else if (ackBlock == -1)
562 TFTP_RequestFile(filename);
563 else {
564 // Be sure to send a NAK, which is done by
565 // ACKing the last block we got.
566 TFTP_ACK_Data(0, ackBlock, 512);
567 printf("\nNAK %u\n", ackBlock);
568 }
569 }
570 }
571 if (timeout == 0)
572 printf("TFTP TIMEOUT!\n");
573}