* Cleanup, minor fixes

* Patch by Rune Torgersen, 16 Apr 2004:
  LBA48 fixes

* Patches by Pantelis Antoniou, 16 Apr 2004:
  - Fix some compile problems;
    add "once" functionality for the netretry variable
master
wdenk 20 years ago
parent c26e454dfc
commit 6e5923851e
  1. 5
      CHANGELOG
  2. 13
      README
  3. 5
      common/cmd_ide.c
  4. 2
      common/cmd_mem.c
  5. 78
      common/cmd_net.c
  6. 11
      common/cmd_pcmcia.c
  7. 4
      common/command.c
  8. 5
      common/console.c
  9. 6
      cpu/mpc8xx/fec.c
  10. 10
      disk/part.c
  11. 24
      include/configs/NETPHONE.h
  12. 6
      include/part.h
  13. 197
      net/net.c

@ -1,6 +1,9 @@
====================================================================== ======================================================================
Changes for U-Boot 1.1.1: Changes for U-Boot 1.1.1:
====================================================================== ======================================================================
* Patch by Rune Torgersen, 16 Apr 2004:
LBA48 fixes
* Patches by Pantelis Antoniou, 16 Apr 2004: * Patches by Pantelis Antoniou, 16 Apr 2004:
- add support for a new version of an Intracom board and fix - add support for a new version of an Intracom board and fix
@ -17,6 +20,8 @@ Changes for U-Boot 1.1.1:
2. A new exit command was added which terminates the current 2. A new exit command was added which terminates the current
executing script. executing script.
3. Fixed handing of $? (exit code of last executed command) 3. Fixed handing of $? (exit code of last executed command)
- Fix some compile problems;
add "once" functionality for the netretry variable
* Patch by George G. Davis, 02 Apr 2004: * Patch by George G. Davis, 02 Apr 2004:
add support for Intel Assabet board add support for Intel Assabet board

@ -788,7 +788,7 @@ The following options need to be configured:
selected via environment 'videomode'. Two diferent ways selected via environment 'videomode'. Two diferent ways
are possible: are possible:
- "videomode=num" 'num' is a standard LiLo mode numbers. - "videomode=num" 'num' is a standard LiLo mode numbers.
Following standard modes are supported (* is default): Following standard modes are supported (* is default):
Colors 640x480 800x600 1024x768 1152x864 1280x1024 Colors 640x480 800x600 1024x768 1152x864 1280x1024
-------------+--------------------------------------------- -------------+---------------------------------------------
@ -951,7 +951,7 @@ The following options need to be configured:
the DHCP server. the DHCP server.
- CDP Options: - CDP Options:
CONFIG_CDP_DEVICE_ID CONFIG_CDP_DEVICE_ID
The device id used in CDP trigger frames. The device id used in CDP trigger frames.
@ -1948,10 +1948,8 @@ Low Level (hardware related) configuration options:
- CONFIG_FEC[12]_PHY - CONFIG_FEC[12]_PHY
Define to the hardcoded PHY address which corresponds Define to the hardcoded PHY address which corresponds
to the given FEC. to the given FEC; i. e.
#define CONFIG_FEC1_PHY 4
i.e.
#define CONFIG_FEC1_PHY 4
means that the PHY with address 4 is connected to FEC1 means that the PHY with address 4 is connected to FEC1
When set to -1, means to probe for first available. When set to -1, means to probe for first available.
@ -2266,6 +2264,9 @@ configurations; the following names are supported:
netretry - When set to "no" each network operation will netretry - When set to "no" each network operation will
either succeed or fail without retrying. either succeed or fail without retrying.
When set to "once" the network operation will
fail when all the available network interfaces
are tried once without success.
Useful on scripts which control the retry operation Useful on scripts which control the retry operation
themselves. themselves.

@ -1186,13 +1186,12 @@ static void ide_ident (block_dev_desc_t *dev_desc)
#ifdef CONFIG_LBA48 #ifdef CONFIG_LBA48
if (iop->command_set_2 & 0x0400) { /* LBA 48 support */ if (iop->command_set_2 & 0x0400) { /* LBA 48 support */
dev_desc->lba48support = 1; dev_desc->lba48 = 1;
dev_desc->lba48 = (unsigned long long)iop->lba48_capacity[0] | dev_desc->lba = (unsigned long long)iop->lba48_capacity[0] |
((unsigned long long)iop->lba48_capacity[1] << 16) | ((unsigned long long)iop->lba48_capacity[1] << 16) |
((unsigned long long)iop->lba48_capacity[2] << 32) | ((unsigned long long)iop->lba48_capacity[2] << 32) |
((unsigned long long)iop->lba48_capacity[3] << 48); ((unsigned long long)iop->lba48_capacity[3] << 48);
} else { } else {
dev_desc->lba48support = 0;
dev_desc->lba48 = 0; dev_desc->lba48 = 0;
} }
#endif /* CONFIG_LBA48 */ #endif /* CONFIG_LBA48 */

@ -1001,7 +1001,7 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong addr, length; ulong addr, length;
ulong crc; ulong crc;
ulong *ptr; ulong *ptr;
ulong vcrc; ulong vcrc;
int verify; int verify;
int ac; int ac;
char **av; char **av;

@ -94,62 +94,50 @@ U_BOOT_CMD(
); );
#endif /* CFG_CMD_NFS */ #endif /* CFG_CMD_NFS */
static void netboot_update_env(void) static void netboot_update_env (void)
{ {
char tmp[22] ; char tmp[22];
if (NetOurGatewayIP) { if (NetOurGatewayIP) {
ip_to_string (NetOurGatewayIP, tmp); ip_to_string (NetOurGatewayIP, tmp);
setenv("gatewayip", tmp); setenv ("gatewayip", tmp);
} }
if (NetOurSubnetMask) {
ip_to_string (NetOurSubnetMask, tmp);
setenv("netmask", tmp);
}
if (NetOurHostName[0]) if (NetOurSubnetMask) {
setenv("hostname", NetOurHostName); ip_to_string (NetOurSubnetMask, tmp);
setenv ("netmask", tmp);
}
if (NetOurRootPath[0]) if (NetOurHostName[0])
setenv("rootpath", NetOurRootPath); setenv ("hostname", NetOurHostName);
if (NetOurIP) { if (NetOurRootPath[0])
ip_to_string (NetOurIP, tmp); setenv ("rootpath", NetOurRootPath);
setenv("ipaddr", tmp);
}
if (NetServerIP) { if (NetOurIP) {
ip_to_string (NetServerIP, tmp); ip_to_string (NetOurIP, tmp);
setenv("serverip", tmp); setenv ("ipaddr", tmp);
} }
if (NetOurDNSIP) { if (NetServerIP) {
ip_to_string (NetOurDNSIP, tmp); ip_to_string (NetServerIP, tmp);
setenv("dnsip", tmp); setenv ("serverip", tmp);
} }
if (NetOurDNSIP) {
ip_to_string (NetOurDNSIP, tmp);
setenv ("dnsip", tmp);
}
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2) #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
if (NetOurDNS2IP) { if (NetOurDNS2IP) {
ip_to_string (NetOurDNS2IP, tmp); ip_to_string (NetOurDNS2IP, tmp);
setenv("dnsip2", tmp); setenv ("dnsip2", tmp);
} }
#endif #endif
if (NetOurNISDomain[0])
if (NetOurNISDomain[0]) setenv ("domain", NetOurNISDomain);
setenv("domain", NetOurNISDomain);
if (ntohs(NetOurVLAN) != (ushort)-1) {
VLAN_to_string(NetOurVLAN, tmp);
setenv("vlan", tmp);
}
if (ntohs(NetOurNativeVLAN) != (ushort)-1) {
VLAN_to_string(NetOurNativeVLAN, tmp);
setenv("vlan", tmp);
}
} }
static int static int
netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
{ {

@ -1,5 +1,5 @@
/* /*
* (C) Copyright 2000-2002 * (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
* *
* See file CREDITS for list of people who contributed to this * See file CREDITS for list of people who contributed to this
@ -91,7 +91,7 @@ static int voltage_set(int slot, int vcc, int vpp);
#if (! defined(CONFIG_I82365)) && (! defined(CONFIG_PXA_PCMCIA)) #if (! defined(CONFIG_I82365)) && (! defined(CONFIG_PXA_PCMCIA))
static u_int m8xx_get_graycode(u_int size); static u_int m8xx_get_graycode(u_int size);
#endif /* CONFIG_I82365 */ #endif /* !CONFIG_I82365, !CONFIG_PXA_PCMCIA */
#if 0 #if 0
static u_int m8xx_get_speed(u_int ns, u_int is_io); static u_int m8xx_get_speed(u_int ns, u_int is_io);
#endif #endif
@ -106,9 +106,10 @@ static u_int *pcmcia_pgcrx[2] = {
&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra, &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb, &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
}; };
#define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot]) #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
#endif /* CONFIG_PXA_PCMCIA */
#endif /* CONFIG_I82365 */ #endif /* CONFIG_I82365 */
#if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA) #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
@ -116,9 +117,7 @@ static void print_funcid (int func);
static void print_fixed (volatile uchar *p); static void print_fixed (volatile uchar *p);
static int identify (volatile uchar *p); static int identify (volatile uchar *p);
static int check_ide_device (int slot); static int check_ide_device (int slot);
#endif /* CONFIG_IDE_8xx_PCCARD */ #endif /* CONFIG_IDE_8xx_PCCARD, CONFIG_PXA_PCMCIA */
#endif
const char *indent = "\t "; const char *indent = "\t ";

@ -89,12 +89,12 @@ do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#if 0 #if 0
{ {
printf("test:"); printf("test:");
left = 1; left = 1;
while (argv[left]) while (argv[left])
printf(" %s", argv[left++]); printf(" %s", argv[left++]);
} }
#endif #endif
last_expr = 0; last_expr = 0;
left = argc - 1; ap = argv + 1; left = argc - 1; ap = argv + 1;
if (left > 0 && strcmp(ap[0], "!") == 0) { if (left > 0 && strcmp(ap[0], "!") == 0) {

@ -412,6 +412,9 @@ int console_init_r (void)
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
char *stdinname, *stdoutname, *stderrname; char *stdinname, *stdoutname, *stderrname;
device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL; device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
#ifdef CFG_CONSOLE_ENV_OVERWRITE
int i;
#endif /* CFG_CONSOLE_ENV_OVERWRITE */
/* set default handlers at first */ /* set default handlers at first */
gd->jt[XF_getc] = serial_getc; gd->jt[XF_getc] = serial_getc;
@ -483,7 +486,7 @@ int console_init_r (void)
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
setenv (stdio_names[i], stdio_devices[i]->name); setenv (stdio_names[i], stdio_devices[i]->name);
} }
#endif /* CFG_CONSOLE_ENV_OVERWRITE */ #endif /* CFG_CONSOLE_ENV_OVERWRITE */
#if 0 #if 0
/* If nothing usable installed, use only the initial console */ /* If nothing usable installed, use only the initial console */

@ -702,9 +702,9 @@ static int fec_init (struct eth_device *dev, bd_t * bd)
#if defined(CONFIG_MII) && defined(CONFIG_RMII) #if defined(CONFIG_MII) && defined(CONFIG_RMII)
/* the MII interface is connected to FEC1 /* the MII interface is connected to FEC1
so for the miiphy_xxx function to work we must * so for the miiphy_xxx function to work we must
call mii_init since fec_halt messes the thing up */ * call mii_init since fec_halt messes the thing up
*/
if (efis->ether_index != 0) if (efis->ether_index != 0)
mii_init(); mii_init();

@ -87,12 +87,8 @@ void dev_print (block_dev_desc_t *dev_desc)
if ((dev_desc->lba * dev_desc->blksz)>0L) { if ((dev_desc->lba * dev_desc->blksz)>0L) {
ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem; ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
lbaint_t lba; lbaint_t lba;
#ifdef CONFIG_LBA48
if (dev_desc->lba48support) lba = dev_desc->lba;
lba = dev_desc->lba48;
else
#endif
lba = dev_desc->lba;
lba512 = (lba * (dev_desc->blksz/512)); lba512 = (lba * (dev_desc->blksz/512));
mb = (10 * lba512) / 2048; /* 2048 = (1024 * 1024) / 512 MB */ mb = (10 * lba512) / 2048; /* 2048 = (1024 * 1024) / 512 MB */
@ -104,7 +100,7 @@ void dev_print (block_dev_desc_t *dev_desc)
gb_quot = gb / 10; gb_quot = gb / 10;
gb_rem = gb - (10 * gb_quot); gb_rem = gb - (10 * gb_quot);
#ifdef CONFIG_LBA48 #ifdef CONFIG_LBA48
if (dev_desc->lba48support) if (dev_desc->lba48)
printf (" Supports 48-bit addressing\n"); printf (" Supports 48-bit addressing\n");
#endif #endif
#if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF) #if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF)

@ -664,11 +664,11 @@ typedef unsigned int led_id_t;
+------+----------------+------------------------------------------------------------ +------+----------------+------------------------------------------------------------
| # | Name | Comment | # | Name | Comment
+------+----------------+------------------------------------------------------------ +------+----------------+------------------------------------------------------------
| 0 | BKBR1 | (V1) Keyboard input scan | 0 | BKBR1 | (V1) Keyboard input scan
| 1 | BKBR3 | (V1) Keyboard input scan | 1 | BKBR3 | (V1) Keyboard input scan
| 2 | BKBR4 | (V1) Keyboard input scan | 2 | BKBR4 | (V1) Keyboard input scan
| 3 | BKBR2 | (V1) Keyboard input scan | 3 | BKBR2 | (V1) Keyboard input scan
| 4 | HOOK | (V1) Hook switch | 4 | HOOK | (V1) Hook switch
| 5 | BT_LINK | (V1) Bluetooth link status | 5 | BT_LINK | (V1) Bluetooth link status
| 6 | HOST_WAKE | (V1) Bluetooth host wake up | 6 | HOST_WAKE | (V1) Bluetooth host wake up
| 7 | OK_ETH | (V1) Cisco inline power OK status | 7 | OK_ETH | (V1) Cisco inline power OK status
@ -681,13 +681,13 @@ typedef unsigned int led_id_t;
+------+----------------+------------------------------------------------------------ +------+----------------+------------------------------------------------------------
| # | Name | Comment | # | Name | Comment
+------+----------------+------------------------------------------------------------ +------+----------------+------------------------------------------------------------
| 0 | KEY1 | Keyboard output scan | 0 | KEY1 | Keyboard output scan
| 1 | KEY2 | Keyboard output scan | 1 | KEY2 | Keyboard output scan
| 2 | KEY3 | Keyboard output scan | 2 | KEY3 | Keyboard output scan
| 3 | KEY4 | Keyboard output scan | 3 | KEY4 | Keyboard output scan
| 4 | KEY5 | Keyboard output scan | 4 | KEY5 | Keyboard output scan
| 5 | KEY6 | Keyboard output scan | 5 | KEY6 | Keyboard output scan
| 6 | KEY7 | Keyboard output scan | 6 | KEY7 | Keyboard output scan
| 7 | BT_WAKE | Bluetooth wake up | 7 | BT_WAKE | Bluetooth wake up
+------+----------------+------------------------------------------------------------ +------+----------------+------------------------------------------------------------

@ -22,7 +22,7 @@
*/ */
#ifndef _PART_H #ifndef _PART_H
#define _PART_H #define _PART_H
#include <ide.h>
typedef struct block_dev_desc { typedef struct block_dev_desc {
int if_type; /* type of the interface */ int if_type; /* type of the interface */
@ -35,14 +35,14 @@ typedef struct block_dev_desc {
#ifdef CONFIG_LBA48 #ifdef CONFIG_LBA48
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
#endif #endif
unsigned long lba; /* number of blocks */ lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */ unsigned long blksz; /* block size */
unsigned char vendor [40+1]; /* IDE model, SCSI Vendor */ unsigned char vendor [40+1]; /* IDE model, SCSI Vendor */
unsigned char product[20+1]; /* IDE Serial no, SCSI product */ unsigned char product[20+1]; /* IDE Serial no, SCSI product */
unsigned char revision[8+1]; /* firmware revision */ unsigned char revision[8+1]; /* firmware revision */
unsigned long (*block_read)(int dev, unsigned long (*block_read)(int dev,
unsigned long start, unsigned long start,
unsigned long blkcnt, lbaint_t blkcnt,
unsigned long *buffer); unsigned long *buffer);
}block_dev_desc_t; }block_dev_desc_t;

@ -122,7 +122,7 @@ uchar NetBcastAddr[6] = /* Ethernet bcast address */
uchar NetEtherNullAddr[6] = uchar NetEtherNullAddr[6] =
{ 0, 0, 0, 0, 0, 0 }; { 0, 0, 0, 0, 0, 0 };
#if (CONFIG_COMMANDS & CFG_CMD_CDP) #if (CONFIG_COMMANDS & CFG_CMD_CDP)
uchar NetCDPAddr[6] = /* Ethernet bcast address */ uchar NetCDPAddr[6] = /* Ethernet bcast address */
{ 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc }; { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc };
#endif #endif
int NetState; /* Network loop state */ int NetState; /* Network loop state */
@ -132,8 +132,9 @@ static int NetRestarted = 0; /* Network loop restarted */
static int NetDevExists = 0; /* At least one device configured */ static int NetDevExists = 0; /* At least one device configured */
#endif #endif
ushort NetOurVLAN = ntohs(-1); /* default is without VLAN */ /* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
ushort NetOurNativeVLAN = htons(-1); /* dido */ ushort NetOurVLAN = 0xFFFF; /* default is without VLAN */
ushort NetOurNativeVLAN = 0xFFFF; /* ditto */
char BootFile[128]; /* Boot File name */ char BootFile[128]; /* Boot File name */
@ -170,43 +171,45 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart; ulong NetArpWaitTimerStart;
int NetArpWaitTry; int NetArpWaitTry;
void ArpRequest(void) void ArpRequest (void)
{ {
int i; int i;
volatile uchar *pkt; volatile uchar *pkt;
ARP_t * arp; ARP_t *arp;
#ifdef ET_DEBUG #ifdef ET_DEBUG
printf("ARP broadcast %d\n", NetArpWaitTry); printf ("ARP broadcast %d\n", NetArpWaitTry);
#endif #endif
pkt = NetTxPacket; pkt = NetTxPacket;
pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP); pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
arp = (ARP_t *)pkt; arp = (ARP_t *) pkt;
arp->ar_hrd = htons(ARP_ETHER); arp->ar_hrd = htons (ARP_ETHER);
arp->ar_pro = htons(PROT_IP); arp->ar_pro = htons (PROT_IP);
arp->ar_hln = 6; arp->ar_hln = 6;
arp->ar_pln = 4; arp->ar_pln = 4;
arp->ar_op = htons(ARPOP_REQUEST); arp->ar_op = htons (ARPOP_REQUEST);
memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */ memcpy (&arp->ar_data[0], NetOurEther, 6); /* source ET addr */
NetWriteIP((uchar*)&arp->ar_data[6], NetOurIP); /* source IP addr */ NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP); /* source IP addr */
for (i=10; i<16; ++i) { for (i = 10; i < 16; ++i) {
arp->ar_data[i] = 0; /* dest ET addr = 0 */ arp->ar_data[i] = 0; /* dest ET addr = 0 */
} }
if((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) { if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
if (NetOurGatewayIP == 0) { (NetOurIP & NetOurSubnetMask)) {
puts ("## Warning: gatewayip needed but not set\n"); if (NetOurGatewayIP == 0) {
} puts ("## Warning: gatewayip needed but not set\n");
NetArpWaitReplyIP = NetOurGatewayIP; }
} else NetArpWaitReplyIP = NetOurGatewayIP;
NetArpWaitReplyIP = NetArpWaitPacketIP; } else {
NetArpWaitReplyIP = NetArpWaitPacketIP;
}
NetWriteIP((uchar*)&arp->ar_data[16], NetArpWaitReplyIP); NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); (void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
} }
void ArpTimeoutCheck(void) void ArpTimeoutCheck(void)
@ -260,7 +263,6 @@ NetLoop(proto_t protocol)
if (!NetTxPacket) { if (!NetTxPacket) {
int i; int i;
/* /*
* Setup packet buffers, aligned correctly. * Setup packet buffers, aligned correctly.
*/ */
@ -269,7 +271,6 @@ NetLoop(proto_t protocol)
for (i = 0; i < PKTBUFSRX; i++) { for (i = 0; i < PKTBUFSRX; i++) {
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
} }
} }
if (!NetArpWaitTxPacket) { if (!NetArpWaitTxPacket) {
@ -279,9 +280,11 @@ NetLoop(proto_t protocol)
} }
eth_halt(); eth_halt();
#ifdef CONFIG_NET_MULTI
eth_set_current(); eth_set_current();
if(eth_init(bd) < 0) #endif
return(-1); if (eth_init(bd) < 0)
return(-1);
restart: restart:
#ifdef CONFIG_NET_MULTI #ifdef CONFIG_NET_MULTI
@ -519,43 +522,42 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
/* Totally ignore the packet */ /* Totally ignore the packet */
} }
void void NetStartAgain (void)
NetStartAgain(void)
{ {
#ifdef CONFIG_NET_MULTI
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
char *s; #endif
char *nretry;
int noretry = 0, once = 0;
if ((s = getenv("netretry")) != NULL && *s == 'n') { if ((nretry = getenv ("netretry")) != NULL) {
eth_halt(); noretry = (strcmp (nretry, "no") == 0);
once = (strcmp (nretry, "once") == 0);
}
if (noretry) {
eth_halt ();
NetState = NETLOOP_FAIL; NetState = NETLOOP_FAIL;
return; return;
} }
#ifndef CONFIG_NET_MULTI #ifndef CONFIG_NET_MULTI
NetSetTimeout(10 * CFG_HZ, startAgainTimeout); NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
NetSetHandler(startAgainHandler); NetSetHandler (startAgainHandler);
#else #else /* !CONFIG_NET_MULTI*/
eth_halt(); eth_halt ();
eth_try_another(!NetRestarted); eth_try_another (!NetRestarted);
eth_init(gd->bd); eth_init (gd->bd);
if (NetRestartWrap) if (NetRestartWrap) {
{
NetRestartWrap = 0; NetRestartWrap = 0;
if (NetDevExists) if (NetDevExists && !once) {
{ NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
NetSetTimeout(10 * CFG_HZ, startAgainTimeout); NetSetHandler (startAgainHandler);
NetSetHandler(startAgainHandler); } else {
}
else
{
NetState = NETLOOP_FAIL; NetState = NETLOOP_FAIL;
} }
} } else {
else
{
NetState = NETLOOP_RESTART; NetState = NETLOOP_RESTART;
} }
#endif #endif /* CONFIG_NET_MULTI */
} }
/**********************************************************************/ /**********************************************************************/
@ -629,7 +631,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
#ifdef ET_DEBUG #ifdef ET_DEBUG
printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n", printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]); dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
#endif #endif
pkt = (uchar *)NetTxPacket; pkt = (uchar *)NetTxPacket;
@ -637,7 +639,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
NetSetIP (pkt, dest, dport, sport, len); NetSetIP (pkt, dest, dport, sport, len);
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len); (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
return 0; /* transmited */ return 0; /* transmitted */
} }
#if (CONFIG_COMMANDS & CFG_CMD_PING) #if (CONFIG_COMMANDS & CFG_CMD_PING)
@ -722,14 +724,13 @@ static void PingStart(void)
{ {
#if defined(CONFIG_NET_MULTI) #if defined(CONFIG_NET_MULTI)
printf ("Using %s device\n", eth_get_name()); printf ("Using %s device\n", eth_get_name());
#endif #endif /* CONFIG_NET_MULTI */
NetSetTimeout (10 * CFG_HZ, PingTimeout); NetSetTimeout (10 * CFG_HZ, PingTimeout);
NetSetHandler (PingHandler); NetSetHandler (PingHandler);
PingSend(); PingSend();
} }
#endif /* CFG_CMD_PING */
#endif
#if (CONFIG_COMMANDS & CFG_CMD_CDP) #if (CONFIG_COMMANDS & CFG_CMD_CDP)
@ -812,9 +813,12 @@ int CDPSendTrigger(void)
volatile ushort *s; volatile ushort *s;
volatile ushort *cp; volatile ushort *cp;
Ethernet_t *et; Ethernet_t *et;
char buf[32];
int len; int len;
ushort chksum; ushort chksum;
#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
char buf[32];
#endif
pkt = NetTxPacket; pkt = NetTxPacket;
et = (Ethernet_t *)pkt; et = (Ethernet_t *)pkt;
@ -1073,8 +1077,7 @@ static void CDPStart(void)
CDPSendTrigger(); CDPSendTrigger();
} }
#endif /* CFG_CMD_CDP */
#endif
void void
@ -1381,7 +1384,6 @@ NetReceive(volatile uchar * inpkt, int len)
ntohs(ip->udp_dst), ntohs(ip->udp_dst),
ntohs(ip->udp_src), ntohs(ip->udp_src),
ntohs(ip->udp_len) - 8); ntohs(ip->udp_len) - 8);
break; break;
} }
} }
@ -1392,68 +1394,67 @@ NetReceive(volatile uchar * inpkt, int len)
static int net_check_prereq (proto_t protocol) static int net_check_prereq (proto_t protocol)
{ {
switch (protocol) { switch (protocol) {
/* Fall through */ /* Fall through */
#if (CONFIG_COMMANDS & CFG_CMD_PING) #if (CONFIG_COMMANDS & CFG_CMD_PING)
case PING: case PING:
if (NetPingIP == 0) { if (NetPingIP == 0) {
puts ("*** ERROR: ping address not given\n"); puts ("*** ERROR: ping address not given\n");
return (1); return (1);
} }
goto common; goto common;
#endif #endif
#if (CONFIG_COMMANDS & CFG_CMD_NFS) #if (CONFIG_COMMANDS & CFG_CMD_NFS)
case NFS: case NFS:
#endif #endif
case TFTP: case TFTP:
if (NetServerIP == 0) { if (NetServerIP == 0) {
puts ("*** ERROR: `serverip' not set\n"); puts ("*** ERROR: `serverip' not set\n");
return (1); return (1);
} }
#if (CONFIG_COMMANDS & CFG_CMD_PING) #if (CONFIG_COMMANDS & CFG_CMD_PING)
common: common:
#endif #endif
if (NetOurIP == 0) { if (NetOurIP == 0) {
puts ("*** ERROR: `ipaddr' not set\n"); puts ("*** ERROR: `ipaddr' not set\n");
return (1); return (1);
} }
/* Fall through */ /* Fall through */
case DHCP: case DHCP:
case RARP: case RARP:
case BOOTP: case BOOTP:
case CDP: case CDP:
if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) { if (memcmp (NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
#ifdef CONFIG_NET_MULTI #ifdef CONFIG_NET_MULTI
extern int eth_get_dev_index (void); extern int eth_get_dev_index (void);
int num = eth_get_dev_index(); int num = eth_get_dev_index ();
switch (num) { switch (num) {
case -1: case -1:
puts ("*** ERROR: No ethernet found.\n"); puts ("*** ERROR: No ethernet found.\n");
return (1); return (1);
case 0: case 0:
puts ("*** ERROR: `ethaddr' not set\n"); puts ("*** ERROR: `ethaddr' not set\n");
break; break;
default: default:
printf ("*** ERROR: `eth%daddr' not set\n", printf ("*** ERROR: `eth%daddr' not set\n",
num); num);
break; break;
} }
NetStartAgain (); NetStartAgain ();
return (2); return (2);
#else #else
puts ("*** ERROR: `ethaddr' not set\n"); puts ("*** ERROR: `ethaddr' not set\n");
return (1); return (1);
#endif #endif
} }
/* Fall through */ /* Fall through */
default: default:
return(0); return (0);
} }
return (0); /* OK */ return (0); /* OK */
} }
/**********************************************************************/ /**********************************************************************/
@ -1529,7 +1530,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
/* /*
* Construct an IP and UDP header. * Construct an IP and UDP header.
(need to set no fragment bit - XXX) * (need to set no fragment bit - XXX)
*/ */
ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */ ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
ip->ip_tos = 0; ip->ip_tos = 0;
@ -1570,7 +1571,7 @@ void ip_to_string (IPaddr_t x, char *s)
(int) ((x >> 24) & 0xff), (int) ((x >> 24) & 0xff),
(int) ((x >> 16) & 0xff), (int) ((x >> 16) & 0xff),
(int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff) (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
); );
} }
IPaddr_t string_to_ip(char *s) IPaddr_t string_to_ip(char *s)

Loading…
Cancel
Save