Merge branch 'master' of git://git.denx.de/u-boot-net

* 'master' of git://git.denx.de/u-boot-net:
  net: move bootfile init into eth_initialize
  net: punt bd->bi_ip_addr
  net: cosmetic: netconsole.c checkpatch compliance
  net: cosmetic: tftp.* checkpatch compliance
  net: cosmetic: sntp.* checkpatch compliance
  net: cosmetic: rarp.* checkpatch compliance
  net: cosmetic: nfs.* checkpatch compliance
  net: cosmetic: net.c checkpatch compliance
  net: cosmetic: eth.c checkpatch compliance
  net: cosmetic: bootp.* checkpatch compliance
  net: cosmetic: net.h checkpatch compliance
  net: Remove volatile from net API
This commit is contained in:
Wolfgang Denk 2012-05-20 22:33:44 +02:00
commit 8bd07c9aaf
48 changed files with 647 additions and 785 deletions

View file

@ -38,7 +38,6 @@
typedef struct bd_info { typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */ int bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */
ulong bi_arch_number; /* unique id for this board */ ulong bi_arch_number; /* unique id for this board */
ulong bi_boot_params; /* where this board expects params */ ulong bi_boot_params; /* where this board expects params */
unsigned long bi_arm_freq; /* arm frequency */ unsigned long bi_arm_freq; /* arm frequency */

View file

@ -555,9 +555,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
arm_pci_init(); arm_pci_init();
#endif #endif
/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
stdio_init(); /* get the devices list going. */ stdio_init(); /* get the devices list going. */
jumptable_init(); jumptable_init();
@ -595,14 +592,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif
#ifdef CONFIG_BOARD_LATE_INIT #ifdef CONFIG_BOARD_LATE_INIT
board_late_init(); board_late_init();

View file

@ -24,7 +24,6 @@
typedef struct bd_info { typedef struct bd_info {
unsigned long bi_baudrate; unsigned long bi_baudrate;
unsigned long bi_ip_addr;
unsigned char bi_phy_id[4]; unsigned char bi_phy_id[4];
unsigned long bi_board_number; unsigned long bi_board_number;
void *bi_boot_params; void *bi_boot_params;

View file

@ -316,8 +316,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
/* initialize environment */ /* initialize environment */
env_relocate(); env_relocate();
bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
stdio_init(); stdio_init();
jumptable_init(); jumptable_init();
console_init_r(); console_init_r();
@ -329,9 +327,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
bb_miiphy_init(); bb_miiphy_init();
#endif #endif
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
s = getenv("bootfile");
if (s)
copy_filename(BootFile, s, sizeof(BootFile));
puts("Net: "); puts("Net: ");
eth_initialize(gd->bd); eth_initialize(gd->bd);
#endif #endif

View file

@ -30,7 +30,6 @@
typedef struct bd_info { typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */ int bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */
unsigned long bi_memstart; /* start of DRAM memory */ unsigned long bi_memstart; /* start of DRAM memory */
phys_size_t bi_memsize; /* size of DRAM memory in bytes */ phys_size_t bi_memsize; /* size of DRAM memory in bytes */

View file

@ -86,7 +86,6 @@ static void display_global_data(void)
printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt)); printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
printf(" \\-bd: %p\n", gd->bd); printf(" \\-bd: %p\n", gd->bd);
printf(" |-bi_baudrate: %x\n", bd->bi_baudrate); printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
printf(" |-bi_ip_addr: %lx\n", bd->bi_ip_addr);
printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params); printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params);
printf(" |-bi_memstart: %lx\n", bd->bi_memstart); printf(" |-bi_memstart: %lx\n", bd->bi_memstart);
printf(" |-bi_memsize: %lx\n", bd->bi_memsize); printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
@ -320,15 +319,8 @@ static void board_net_init_r(bd_t *bd)
bb_miiphy_init(); bb_miiphy_init();
#endif #endif
#ifdef CONFIG_CMD_NET #ifdef CONFIG_CMD_NET
char *s;
if ((s = getenv("bootfile")) != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
printf("Net: "); printf("Net: ");
eth_initialize(gd->bd); eth_initialize(bd);
#endif #endif
} }

View file

@ -47,7 +47,6 @@ typedef struct bd_info {
unsigned long bi_mbar_base; /* base of internal registers */ unsigned long bi_mbar_base; /* base of internal registers */
unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */
unsigned long bi_ip_addr; /* IP Address */
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */ unsigned long bi_busfreq; /* Bus Freq, in MHz */

View file

@ -507,15 +507,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* relocate environment function pointers etc. */ /* relocate environment function pointers etc. */
env_relocate (); env_relocate ();
/*
* Fill in missing fields of bd_info.
* We do this here, where we have "normal" access to the
* environment; we used to do this still running from ROM,
* where had to use getenv_f(), which can be pretty slow when
* the environment is in EEPROM.
*/
bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
WATCHDOG_RESET (); WATCHDOG_RESET ();
#if defined(CONFIG_PCI) #if defined(CONFIG_PCI)
@ -568,11 +559,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {
copy_filename (BootFile, s, sizeof (BootFile));
}
#endif
WATCHDOG_RESET (); WATCHDOG_RESET ();

View file

@ -40,7 +40,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */ unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_baudrate; /* Console Baudrate */ unsigned long bi_baudrate; /* Console Baudrate */
} bd_t; } bd_t;

View file

@ -176,19 +176,12 @@ void board_init (void)
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
printf("Net: "); printf("Net: ");
eth_initialize(gd->bd); eth_initialize(gd->bd);
uchar enetaddr[6]; uchar enetaddr[6];
eth_getenv_enetaddr("ethaddr", enetaddr); eth_getenv_enetaddr("ethaddr", enetaddr);
printf("MAC: %pM\n", enetaddr); printf("MAC: %pM\n", enetaddr);
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
#endif #endif
/* main_loop */ /* main_loop */

View file

@ -33,7 +33,6 @@
typedef struct bd_info { typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */ int bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_arch_number; /* unique id for this board */ unsigned long bi_arch_number; /* unique id for this board */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */
unsigned long bi_memstart; /* start of DRAM memory */ unsigned long bi_memstart; /* start of DRAM memory */

View file

@ -320,9 +320,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* relocate environment function pointers etc. */ /* relocate environment function pointers etc. */
env_relocate(); env_relocate();
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
#if defined(CONFIG_PCI) #if defined(CONFIG_PCI)
/* /*
* Do pci configuration * Do pci configuration
@ -342,14 +339,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif
#ifdef CONFIG_CMD_SPI #ifdef CONFIG_CMD_SPI
puts("SPI: "); puts("SPI: ");

View file

@ -40,7 +40,6 @@
typedef struct bd_info { typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */ int bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */
unsigned char bi_enetaddr[6]; /* Ethernet adress */ unsigned char bi_enetaddr[6]; /* Ethernet adress */
unsigned long bi_arch_number; /* unique id for this board */ unsigned long bi_arch_number; /* unique id for this board */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */

View file

@ -369,9 +369,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
nds32_pci_init(); nds32_pci_init();
#endif #endif
/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
stdio_init(); /* get the devices list going. */ stdio_init(); /* get the devices list going. */
jumptable_init(); jumptable_init();
@ -402,12 +399,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
#endif
#ifdef BOARD_LATE_INIT #ifdef BOARD_LATE_INIT
board_late_init(); board_late_init();
#endif #endif

View file

@ -39,7 +39,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */ unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_baudrate; /* Console Baudrate */ unsigned long bi_baudrate; /* Console Baudrate */
} bd_t; } bd_t;

View file

@ -143,8 +143,6 @@ void board_init (void)
WATCHDOG_RESET (); WATCHDOG_RESET ();
env_relocate(); env_relocate();
bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
WATCHDOG_RESET (); WATCHDOG_RESET ();
stdio_init(); stdio_init();
jumptable_init(); jumptable_init();

View file

@ -33,7 +33,6 @@
typedef struct bd_info { typedef struct bd_info {
unsigned long bi_baudrate; /* serial console baudrate */ unsigned long bi_baudrate; /* serial console baudrate */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_arch_number; /* unique id for this board */ unsigned long bi_arch_number; /* unique id for this board */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */
unsigned long bi_memstart; /* start of DRAM memory */ unsigned long bi_memstart; /* start of DRAM memory */

View file

@ -63,7 +63,6 @@ typedef struct bd_info {
unsigned long bi_vcofreq; /* VCO Freq, in MHz */ unsigned long bi_vcofreq; /* VCO Freq, in MHz */
#endif #endif
unsigned long bi_bootflags; /* boot / reboot flag (Unused) */ unsigned long bi_bootflags; /* boot / reboot flag (Unused) */
unsigned long bi_ip_addr; /* IP Address */
unsigned char bi_enetaddr[6]; /* OLD: see README.enetaddr */ unsigned char bi_enetaddr[6]; /* OLD: see README.enetaddr */
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_intfreq; /* Internal Freq, in MHz */

View file

@ -877,9 +877,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
#endif #endif
#endif /* CONFIG_CMD_NET */ #endif /* CONFIG_CMD_NET */
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
WATCHDOG_RESET(); WATCHDOG_RESET();
#if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
@ -935,14 +932,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif
WATCHDOG_RESET(); WATCHDOG_RESET();

View file

@ -45,7 +45,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
unsigned long bi_ip_addr; /* IP Address */
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */ unsigned long bi_busfreq; /* Bus Freq, in MHz */

View file

@ -235,9 +235,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* initialize environment */ /* initialize environment */
env_relocate(); env_relocate();
/* IP Address */
gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
stdio_init(); /* get the devices list going. */ stdio_init(); /* get the devices list going. */
jumptable_init(); jumptable_init();

View file

@ -33,7 +33,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */ unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_baudrate; /* Console Baudrate */ unsigned long bi_baudrate; /* Console Baudrate */
unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_boot_params; /* where this board expects params */
} bd_t; } bd_t;

View file

@ -100,14 +100,6 @@ static int sh_mem_env_init(void)
return 0; return 0;
} }
#if defined(CONFIG_CMD_NET)
static int sh_net_init(void)
{
gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
return 0;
}
#endif
#if defined(CONFIG_CMD_MMC) #if defined(CONFIG_CMD_MMC)
static int sh_mmc_init(void) static int sh_mmc_init(void)
{ {
@ -145,9 +137,6 @@ init_fnc_t *init_sequence[] =
#ifdef CONFIG_BOARD_LATE_INIT #ifdef CONFIG_BOARD_LATE_INIT
board_late_init, board_late_init,
#endif #endif
#if defined(CONFIG_CMD_NET)
sh_net_init, /* SH specific eth init */
#endif
#if defined(CONFIG_CMD_MMC) #if defined(CONFIG_CMD_MMC)
sh_mmc_init, sh_mmc_init,
#endif #endif
@ -201,15 +190,8 @@ void sh_generic_init(void)
bb_miiphy_init(); bb_miiphy_init();
#endif #endif
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
{
char *s;
puts("Net: "); puts("Net: ");
eth_initialize(gd->bd); eth_initialize(gd->bd);
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif /* CONFIG_CMD_NET */ #endif /* CONFIG_CMD_NET */
while (1) { while (1) {

View file

@ -51,7 +51,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
unsigned long bi_ip_addr; /* IP Address */
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */ unsigned long bi_busfreq; /* Bus Freq, in MHz */

View file

@ -333,8 +333,6 @@ void board_init_f(ulong bootflag)
mac_read_from_eeprom(); mac_read_from_eeprom();
#endif #endif
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
#if defined(CONFIG_PCI) #if defined(CONFIG_PCI)
/* /*
* Do pci configuration * Do pci configuration
@ -359,11 +357,6 @@ void board_init_f(ulong bootflag)
/* Initialize from environment */ /* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr); load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
if ((s = getenv("bootfile")) != NULL) {
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif /* CONFIG_CMD_NET */
WATCHDOG_RESET(); WATCHDOG_RESET();

View file

@ -36,9 +36,7 @@ int set_reloc_flag_r(void);
int mem_malloc_init_r(void); int mem_malloc_init_r(void);
int init_bd_struct_r(void); int init_bd_struct_r(void);
int flash_init_r(void); int flash_init_r(void);
int init_ip_address_r(void);
int status_led_set_r(void); int status_led_set_r(void);
int set_bootfile_r(void);
int set_load_addr_r(void); int set_load_addr_r(void);
#endif /* !_INIT_HELPERS_H_ */ #endif /* !_INIT_HELPERS_H_ */

View file

@ -45,7 +45,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */
unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
unsigned long bi_ip_addr; /* IP Address */
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */ unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */ unsigned long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */ unsigned long bi_busfreq; /* Bus Freq, in MHz */

View file

@ -157,9 +157,6 @@ init_fnc_t *init_sequence_r[] = {
flash_init_r, flash_init_r,
#endif #endif
env_relocate_r, env_relocate_r,
#ifdef CONFIG_CMD_NET
init_ip_address_r,
#endif
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
pci_init_r, pci_init_r,
#endif #endif
@ -180,9 +177,6 @@ init_fnc_t *init_sequence_r[] = {
status_led_set_r, status_led_set_r,
#endif #endif
set_load_addr_r, set_load_addr_r,
#if defined(CONFIG_CMD_NET)
set_bootfile_r,
#endif
#if defined(CONFIG_CMD_IDE) #if defined(CONFIG_CMD_IDE)
ide_init_r, ide_init_r,
#endif #endif

View file

@ -179,14 +179,6 @@ int flash_init_r(void)
} }
#endif #endif
int init_ip_address_r(void)
{
/* IP Address */
bd_data.bi_ip_addr = getenv_IPaddr("ipaddr");
return 0;
}
#ifdef CONFIG_STATUS_LED #ifdef CONFIG_STATUS_LED
int status_led_set_r(void) int status_led_set_r(void)
{ {
@ -196,18 +188,6 @@ int status_led_set_r(void)
} }
#endif #endif
int set_bootfile_r(void)
{
char *s;
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
return 0;
}
int set_load_addr_r(void) int set_load_addr_r(void)
{ {
/* Initialize from environment */ /* Initialize from environment */

View file

@ -730,12 +730,11 @@ int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* /*
* Update whole ip-addr * Update whole ip-addr
*/ */
bd->bi_ip_addr = ipaddr;
sprintf(str, "%ld.%ld.%ld.%ld", sprintf(str, "%ld.%ld.%ld.%ld",
(bd->bi_ip_addr & 0xff000000) >> 24, (ipaddr & 0xff000000) >> 24,
(bd->bi_ip_addr & 0x00ff0000) >> 16, (ipaddr & 0x00ff0000) >> 16,
(bd->bi_ip_addr & 0x0000ff00) >> 8, (ipaddr & 0x0000ff00) >> 8,
(bd->bi_ip_addr & 0x000000ff)); (ipaddr & 0x000000ff));
setenv("ipaddr", str); setenv("ipaddr", str);
printf("Updated ip_addr from bp_eeprom to %s!\n", str); printf("Updated ip_addr from bp_eeprom to %s!\n", str);
} }

View file

@ -147,7 +147,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_HERMES #ifdef CONFIG_HERMES
print_mhz("ethspeed", bd->bi_ethspeed); print_mhz("ethspeed", bd->bi_ethspeed);
#endif #endif
printf("IP addr = %pI4\n", &bd->bi_ip_addr); printf("IP addr = %s\n", getenv("ipaddr"));
printf("baudrate = %6ld bps\n", bd->bi_baudrate); printf("baudrate = %6ld bps\n", bd->bi_baudrate);
print_num("relocaddr", gd->relocaddr); print_num("relocaddr", gd->relocaddr);
return 0; return 0;
@ -172,7 +172,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %ld bps\n", bd->bi_baudrate); printf("baudrate = %ld bps\n", bd->bi_baudrate);
@ -196,7 +196,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif #endif
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate); printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
return 0; return 0;
@ -229,7 +229,7 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %6ld bps\n", bd->bi_baudrate); printf("baudrate = %6ld bps\n", bd->bi_baudrate);
return 0; return 0;
@ -275,7 +275,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_eth(3); print_eth(3);
#endif #endif
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %ld bps\n", bd->bi_baudrate); printf("baudrate = %ld bps\n", bd->bi_baudrate);
@ -303,7 +303,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_num("flashoffset", (ulong)bd->bi_flashoffset); print_num("flashoffset", (ulong)bd->bi_flashoffset);
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
printf("baudrate = %d bps\n", bd->bi_baudrate); printf("baudrate = %d bps\n", bd->bi_baudrate);
return 0; return 0;
@ -323,7 +323,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_num("flashoffset", (ulong)bd->bi_flashoffset); print_num("flashoffset", (ulong)bd->bi_flashoffset);
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
printf("baudrate = %d bps\n", bd->bi_baudrate); printf("baudrate = %d bps\n", bd->bi_baudrate);
return 0; return 0;
@ -343,7 +343,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_num("flashoffset", (ulong)bd->bi_flashoffset); print_num("flashoffset", (ulong)bd->bi_flashoffset);
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
printf("baudrate = %lu bps\n", bd->bi_baudrate); printf("baudrate = %lu bps\n", bd->bi_baudrate);
return 0; return 0;
@ -367,7 +367,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %d bps\n", bd->bi_baudrate); printf("baudrate = %d bps\n", bd->bi_baudrate);
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
@ -403,7 +403,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate); printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
return 0; return 0;
@ -436,7 +436,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
print_mhz("ethspeed", bd->bi_ethspeed); print_mhz("ethspeed", bd->bi_ethspeed);
#endif #endif
printf("baudrate = %d bps\n", bd->bi_baudrate); printf("baudrate = %d bps\n", bd->bi_baudrate);
@ -461,7 +461,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
print_num("FB base ", gd->fb_base); print_num("FB base ", gd->fb_base);
return 0; return 0;
@ -485,7 +485,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %d bps\n", bd->bi_baudrate); printf("baudrate = %d bps\n", bd->bi_baudrate);
@ -506,7 +506,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) #if defined(CONFIG_CMD_NET)
print_eth(0); print_eth(0);
printf("ip_addr = %pI4\n", &bd->bi_ip_addr); printf("ip_addr = %s\n", getenv("ipaddr"));
#endif #endif
printf("baudrate = %ld bps\n", bd->bi_baudrate); printf("baudrate = %ld bps\n", bd->bi_baudrate);

View file

@ -343,21 +343,7 @@ int _do_env_set(int flag, int argc, char * const argv[])
* Some variables should be updated when the corresponding * Some variables should be updated when the corresponding
* entry in the environment is changed * entry in the environment is changed
*/ */
if (strcmp(name, "ipaddr") == 0) { if (strcmp(argv[1], "loadaddr") == 0) {
char *s = argv[2]; /* always use only one arg */
char *e;
unsigned long addr;
bd->bi_ip_addr = 0;
for (addr = 0, i = 0; i < 4; ++i) {
ulong val = s ? simple_strtoul(s, &e, 10) : 0;
addr <<= 8;
addr |= val & 0xFF;
if (s)
s = *e ? e + 1 : e;
}
bd->bi_ip_addr = htonl(addr);
return 0;
} else if (strcmp(argv[1], "loadaddr") == 0) {
load_addr = simple_strtoul(argv[2], NULL, 16); load_addr = simple_strtoul(argv[2], NULL, 16);
return 0; return 0;
} }

View file

@ -973,7 +973,6 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
#ifdef CONFIG_SHOW_ACTIVITY #ifdef CONFIG_SHOW_ACTIVITY
while (!tstc()) { while (!tstc()) {
extern void show_activity(int arg);
show_activity(0); show_activity(0);
WATCHDOG_RESET(); WATCHDOG_RESET();
} }

View file

@ -29,16 +29,16 @@
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
static char input_buffer[512]; static char input_buffer[512];
static int input_size = 0; /* char count in input buffer */ static int input_size; /* char count in input buffer */
static int input_offset = 0; /* offset to valid chars in input buffer */ static int input_offset; /* offset to valid chars in input buffer */
static int input_recursion = 0; static int input_recursion;
static int output_recursion = 0; static int output_recursion;
static int net_timeout; static int net_timeout;
static uchar nc_ether[6]; /* server enet address */ static uchar nc_ether[6]; /* server enet address */
static IPaddr_t nc_ip; /* server ip */ static IPaddr_t nc_ip; /* server ip */
static short nc_port; /* source/target port */ static short nc_port; /* source/target port */
static const char *output_packet; /* used by first send udp */ static const char *output_packet; /* used by first send udp */
static int output_packet_len = 0; static int output_packet_len;
static void nc_wait_arp_handler(uchar *pkt, unsigned dest, static void nc_wait_arp_handler(uchar *pkt, unsigned dest,
IPaddr_t sip, unsigned src, IPaddr_t sip, unsigned src,
@ -71,7 +71,8 @@ void NcStart (void)
NetSetHandler(nc_wait_arp_handler); NetSetHandler(nc_wait_arp_handler);
pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE; pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
memcpy(pkt, output_packet, output_packet_len); memcpy(pkt, output_packet, output_packet_len);
NetSendUDPPacket (nc_ether, nc_ip, nc_port, nc_port, output_packet_len); NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
output_packet_len);
} }
} }
@ -82,18 +83,18 @@ int nc_input_packet (uchar * pkt, unsigned dest, unsigned src, unsigned len)
if (dest != nc_port || !len) if (dest != nc_port || !len)
return 0; /* not for us */ return 0; /* not for us */
if (input_size == sizeof input_buffer) if (input_size == sizeof(input_buffer))
return 1; /* no space */ return 1; /* no space */
if (len > sizeof input_buffer - input_size) if (len > sizeof(input_buffer) - input_size)
len = sizeof input_buffer - input_size; len = sizeof(input_buffer) - input_size;
end = input_offset + input_size; end = input_offset + input_size;
if (end > sizeof input_buffer) if (end > sizeof(input_buffer))
end -= sizeof input_buffer; end -= sizeof(input_buffer);
chunk = len; chunk = len;
if (end + len > sizeof input_buffer) { if (end + len > sizeof(input_buffer)) {
chunk = sizeof input_buffer - end; chunk = sizeof(input_buffer) - end;
memcpy(input_buffer, pkt + chunk, len - chunk); memcpy(input_buffer, pkt + chunk, len - chunk);
} }
memcpy(input_buffer + end, pkt, chunk); memcpy(input_buffer + end, pkt, chunk);
@ -111,9 +112,9 @@ static void nc_send_packet (const char *buf, int len)
uchar *ether; uchar *ether;
IPaddr_t ip; IPaddr_t ip;
if ((eth = eth_get_dev ()) == NULL) { eth = eth_get_dev();
if (eth == NULL)
return; return;
}
if (!memcmp(nc_ether, NetEtherNullAddr, 6)) { if (!memcmp(nc_ether, NetEtherNullAddr, 6)) {
if (eth->state == ETH_STATE_ACTIVE) if (eth->state == ETH_STATE_ACTIVE)
@ -152,7 +153,8 @@ static int nc_start(void)
nc_ip = getenv_IPaddr("ncip"); nc_ip = getenv_IPaddr("ncip");
if (!nc_ip) if (!nc_ip)
return -1; /* ncip is 0.0.0.0 */ return -1; /* ncip is 0.0.0.0 */
if ((p = strchr (getenv ("ncip"), ':')) != NULL) p = strchr(getenv("ncip"), ':');
if (p != NULL)
nc_port = simple_strtoul(p + 1, NULL, 10); nc_port = simple_strtoul(p + 1, NULL, 10);
} else } else
nc_ip = ~0; /* ncip is not set */ nc_ip = ~0; /* ncip is not set */
@ -163,9 +165,9 @@ static int nc_start(void)
if (nc_ip == ~0 || /* 255.255.255.255 */ if (nc_ip == ~0 || /* 255.255.255.255 */
((netmask & our_ip) == (netmask & nc_ip) && /* on the same net */ ((netmask & our_ip) == (netmask & nc_ip) && /* on the same net */
(netmask | nc_ip) == ~0)) /* broadcast to our net */ (netmask | nc_ip) == ~0)) /* broadcast to our net */
memset (nc_ether, 0xff, sizeof nc_ether); memset(nc_ether, 0xff, sizeof(nc_ether));
else else
memset (nc_ether, 0, sizeof nc_ether); /* force arp request */ memset(nc_ether, 0, sizeof(nc_ether)); /* force arp request */
return 0; return 0;
} }
@ -214,8 +216,8 @@ static int nc_getc(void)
c = input_buffer[input_offset++]; c = input_buffer[input_offset++];
if (input_offset >= sizeof input_buffer) if (input_offset >= sizeof(input_buffer))
input_offset -= sizeof input_buffer; input_offset -= sizeof(input_buffer);
input_size--; input_size--;
return c; return c;

View file

@ -819,6 +819,10 @@ int pcmcia_init (void);
#include <bootstage.h> #include <bootstage.h>
#ifdef CONFIG_SHOW_ACTIVITY
void show_activity(int arg);
#endif
/* Multicore arch functions */ /* Multicore arch functions */
#ifdef CONFIG_MP #ifdef CONFIG_MP
int cpu_status(int nr); int cpu_status(int nr);

View file

@ -81,7 +81,7 @@ struct eth_device {
int state; int state;
int (*init) (struct eth_device *, bd_t *); int (*init) (struct eth_device *, bd_t *);
int (*send) (struct eth_device*, volatile void* packet, int length); int (*send) (struct eth_device *, void *packet, int length);
int (*recv) (struct eth_device *); int (*recv) (struct eth_device *);
void (*halt) (struct eth_device *); void (*halt) (struct eth_device *);
#ifdef CONFIG_MCAST_TFTP #ifdef CONFIG_MCAST_TFTP
@ -120,10 +120,11 @@ extern int eth_getenv_enetaddr_by_index(const char *base_name, int index,
extern int usb_eth_initialize(bd_t *bi); extern int usb_eth_initialize(bd_t *bi);
extern int eth_init(bd_t *bis); /* Initialize the device */ extern int eth_init(bd_t *bis); /* Initialize the device */
extern int eth_send(volatile void *packet, int length); /* Send a packet */ extern int eth_send(void *packet, int length); /* Send a packet */
#ifdef CONFIG_API #ifdef CONFIG_API
extern int eth_receive(volatile void *packet, int length); /* Receive a packet*/ extern int eth_receive(void *packet, int length); /* Receive a packet*/
extern void (*push_packet)(void *packet, int length);
#endif #endif
extern int eth_rx(void); /* Check for received packets */ extern int eth_rx(void); /* Check for received packets */
extern void eth_halt(void); /* stop SCC */ extern void eth_halt(void); /* stop SCC */
@ -326,7 +327,7 @@ typedef struct icmphdr {
/* net.c */ /* net.c */
/** BOOTP EXTENTIONS **/ /** BOOTP EXTENTIONS **/
extern IPaddr_t NetOurGatewayIP; /* Our gateway IP addresse */ extern IPaddr_t NetOurGatewayIP; /* Our gateway IP address */
extern IPaddr_t NetOurSubnetMask; /* Our subnet mask (0 = unknown) */ extern IPaddr_t NetOurSubnetMask; /* Our subnet mask (0 = unknown) */
extern IPaddr_t NetOurDNSIP; /* Our Domain Name Server (0 = unknown) */ extern IPaddr_t NetOurDNSIP; /* Our Domain Name Server (0 = unknown) */
#if defined(CONFIG_BOOTP_DNS2) #if defined(CONFIG_BOOTP_DNS2)
@ -342,9 +343,9 @@ extern uchar NetOurEther[6]; /* Our ethernet address */
extern uchar NetServerEther[6]; /* Boot server enet address */ extern uchar NetServerEther[6]; /* Boot server enet address */
extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */ extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */ extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
extern volatile uchar * NetTxPacket; /* THE transmit packet */ extern uchar *NetTxPacket; /* THE transmit packet */
extern volatile uchar * NetRxPackets[PKTBUFSRX];/* Receive packets */ extern uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
extern volatile uchar * NetRxPacket; /* Current receive packet */ extern uchar *NetRxPacket; /* Current receive packet */
extern int NetRxPacketLen; /* Current rx packet length */ extern int NetRxPacketLen; /* Current rx packet length */
extern unsigned NetIPID; /* IP ID (counting) */ extern unsigned NetIPID; /* IP ID (counting) */
extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */ extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */
@ -395,6 +396,10 @@ extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */
extern int NetTimeOffset; /* offset time from UTC */ extern int NetTimeOffset; /* offset time from UTC */
#endif #endif
#if defined(CONFIG_MCAST_TFTP)
extern IPaddr_t Mcast_addr;
#endif
/* Initialize the network adapter */ /* Initialize the network adapter */
extern int NetLoop(enum proto_t); extern int NetLoop(enum proto_t);
@ -408,10 +413,10 @@ extern void NetStartAgain(void);
extern int NetEthHdrSize(void); extern int NetEthHdrSize(void);
/* Set ethernet header; returns the size of the header */ /* Set ethernet header; returns the size of the header */
extern int NetSetEther(volatile uchar *, uchar *, uint); extern int NetSetEther(uchar *, uchar *, uint);
/* Set IP header */ /* Set IP header */
extern void NetSetIP(volatile uchar *, IPaddr_t, int, int, int); extern void NetSetIP(uchar *, IPaddr_t, int, int, int);
/* Checksum */ /* Checksum */
extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */
@ -423,13 +428,19 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */ extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */
/* Transmit "NetTxPacket" */ /* Transmit "NetTxPacket" */
extern void NetSendPacket(volatile uchar *, int); extern void NetSendPacket(uchar *, int);
/* Transmit UDP packet, performing ARP request if needed */ /* Transmit UDP packet, performing ARP request if needed */
extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len); extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport,
int sport, int len);
/* Processes a received packet */ /* Processes a received packet */
extern void NetReceive(volatile uchar *, int); extern void NetReceive(uchar *, int);
#ifdef CONFIG_NETCONSOLE
void NcStart(void);
int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
#endif
/* /*
* Check if autoload is enabled. If so, use either NFS or TFTP to download * Check if autoload is enabled. If so, use either NFS or TFTP to download
@ -445,9 +456,10 @@ void net_auto_load(void);
* footprint in our tests. * footprint in our tests.
*/ */
/* return IP *in network byteorder* */ /* return IP *in network byteorder* */
static inline IPaddr_t NetReadIP(volatile void *from) static inline IPaddr_t NetReadIP(void *from)
{ {
IPaddr_t ip; IPaddr_t ip;
memcpy((void *)&ip, (void *)from, sizeof(ip)); memcpy((void *)&ip, (void *)from, sizeof(ip));
return ip; return ip;
} }
@ -456,6 +468,7 @@ static inline IPaddr_t NetReadIP(volatile void *from)
static inline ulong NetReadLong(ulong *from) static inline ulong NetReadLong(ulong *from)
{ {
ulong l; ulong l;
memcpy((void *)&l, (void *)from, sizeof(l)); memcpy((void *)&l, (void *)from, sizeof(l));
return l; return l;
} }
@ -467,7 +480,7 @@ static inline void NetWriteIP(void *to, IPaddr_t ip)
} }
/* copy IP */ /* copy IP */
static inline void NetCopyIP(volatile void *to, void *from) static inline void NetCopyIP(void *to, void *from)
{ {
memcpy((void *)to, from, sizeof(IPaddr_t)); memcpy((void *)to, from, sizeof(IPaddr_t));
} }
@ -498,7 +511,7 @@ static inline int is_zero_ether_addr(const u8 *addr)
*/ */
static inline int is_multicast_ether_addr(const u8 *addr) static inline int is_multicast_ether_addr(const u8 *addr)
{ {
return (0x01 & addr[0]); return 0x01 & addr[0];
} }
/* /*
@ -509,7 +522,8 @@ static inline int is_multicast_ether_addr(const u8 *addr)
*/ */
static inline int is_broadcast_ether_addr(const u8 *addr) static inline int is_broadcast_ether_addr(const u8 *addr)
{ {
return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff; return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) ==
0xff;
} }
/* /*

View file

@ -43,8 +43,8 @@ ulong seed1, seed2;
#if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_CMD_DHCP)
dhcp_state_t dhcp_state = INIT; dhcp_state_t dhcp_state = INIT;
unsigned long dhcp_leasetime = 0; unsigned long dhcp_leasetime;
IPaddr_t NetDHCPServerIP = 0; IPaddr_t NetDHCPServerIP;
static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len); unsigned len);
@ -64,37 +64,29 @@ static char *dhcpmsg2str(int type)
} }
} }
#endif #endif
#if defined(CONFIG_BOOTP_VENDOREX)
extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
#endif
#endif #endif
static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len) static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{ {
Bootp_t *bp = (Bootp_t *) pkt; struct Bootp_t *bp = (struct Bootp_t *) pkt;
int retval = 0; int retval = 0;
if (dest != PORT_BOOTPC || src != PORT_BOOTPS) if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
retval = -1; retval = -1;
else if (len < sizeof (Bootp_t) - OPT_SIZE) else if (len < sizeof(struct Bootp_t) - OPT_SIZE)
retval = -2; retval = -2;
else if (bp->bp_op != OP_BOOTREQUEST && else if (bp->bp_op != OP_BOOTREQUEST &&
bp->bp_op != OP_BOOTREPLY && bp->bp_op != OP_BOOTREPLY &&
bp->bp_op != DHCP_OFFER && bp->bp_op != DHCP_OFFER &&
bp->bp_op != DHCP_ACK && bp->bp_op != DHCP_ACK &&
bp->bp_op != DHCP_NAK ) { bp->bp_op != DHCP_NAK)
retval = -3; retval = -3;
}
else if (bp->bp_htype != HWT_ETHER) else if (bp->bp_htype != HWT_ETHER)
retval = -4; retval = -4;
else if (bp->bp_hlen != HWL_ETHER) else if (bp->bp_hlen != HWL_ETHER)
retval = -5; retval = -5;
else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) { else if (NetReadLong((ulong *)&bp->bp_id) != BootpID)
retval = -6; retval = -6;
}
debug("Filtering pkt = %d\n", retval); debug("Filtering pkt = %d\n", retval);
@ -104,7 +96,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
/* /*
* Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
*/ */
static void BootpCopyNetParams(Bootp_t *bp) static void BootpCopyNetParams(struct Bootp_t *bp)
{ {
__maybe_unused IPaddr_t tmp_ip; __maybe_unused IPaddr_t tmp_ip;
@ -124,19 +116,18 @@ static void BootpCopyNetParams(Bootp_t *bp)
* don't delete exising entry when BOOTP / DHCP reply does * don't delete exising entry when BOOTP / DHCP reply does
* not contain a new value * not contain a new value
*/ */
if (*BootFile) { if (*BootFile)
setenv("bootfile", BootFile); setenv("bootfile", BootFile);
} }
}
static int truncate_sz(const char *name, int maxlen, int curlen) static int truncate_sz(const char *name, int maxlen, int curlen)
{ {
if (curlen >= maxlen) { if (curlen >= maxlen) {
printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n", printf("*** WARNING: %s is too long (%d - max: %d)"
name, curlen, maxlen); " - truncated\n", name, curlen, maxlen);
curlen = maxlen - 1; curlen = maxlen - 1;
} }
return (curlen); return curlen;
} }
#if !defined(CONFIG_CMD_DHCP) #if !defined(CONFIG_CMD_DHCP)
@ -160,22 +151,19 @@ static void BootpVendorFieldProcess (u8 * ext)
break; break;
/* Variable length fields */ /* Variable length fields */
case 3: /* Gateways list */ case 3: /* Gateways list */
if (NetOurGatewayIP == 0) { if (NetOurGatewayIP == 0)
NetCopyIP(&NetOurGatewayIP, (IPaddr_t *) (ext + 2)); NetCopyIP(&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
}
break; break;
case 4: /* Time server - Not yet supported */ case 4: /* Time server - Not yet supported */
break; break;
case 5: /* IEN-116 name server - Not yet supported */ case 5: /* IEN-116 name server - Not yet supported */
break; break;
case 6: case 6:
if (NetOurDNSIP == 0) { if (NetOurDNSIP == 0)
NetCopyIP(&NetOurDNSIP, (IPaddr_t *) (ext + 2)); NetCopyIP(&NetOurDNSIP, (IPaddr_t *) (ext + 2));
}
#if defined(CONFIG_BOOTP_DNS2) #if defined(CONFIG_BOOTP_DNS2)
if ((NetOurDNS2IP == 0) && (size > 4)) { if ((NetOurDNS2IP == 0) && (size > 4))
NetCopyIP(&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4)); NetCopyIP(&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
}
#endif #endif
break; break;
case 7: /* Log server - Not yet supported */ case 7: /* Log server - Not yet supported */
@ -190,7 +178,8 @@ static void BootpVendorFieldProcess (u8 * ext)
break; break;
case 12: /* Host name */ case 12: /* Host name */
if (NetOurHostName[0] == 0) { if (NetOurHostName[0] == 0) {
size = truncate_sz ("Host Name", sizeof (NetOurHostName), size); size = truncate_sz("Host Name",
sizeof(NetOurHostName), size);
memcpy(&NetOurHostName, ext + 2, size); memcpy(&NetOurHostName, ext + 2, size);
NetOurHostName[size] = 0; NetOurHostName[size] = 0;
} }
@ -209,7 +198,8 @@ static void BootpVendorFieldProcess (u8 * ext)
break; break;
case 17: /* Root path */ case 17: /* Root path */
if (NetOurRootPath[0] == 0) { if (NetOurRootPath[0] == 0) {
size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size); size = truncate_sz("Root Path",
sizeof(NetOurRootPath), size);
memcpy(&NetOurRootPath, ext + 2, size); memcpy(&NetOurRootPath, ext + 2, size);
NetOurRootPath[size] = 0; NetOurRootPath[size] = 0;
} }
@ -224,7 +214,8 @@ static void BootpVendorFieldProcess (u8 * ext)
/* IP host layer fields */ /* IP host layer fields */
case 40: /* NIS Domain name */ case 40: /* NIS Domain name */
if (NetOurNISDomain[0] == 0) { if (NetOurNISDomain[0] == 0) {
size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size); size = truncate_sz("NIS Domain Name",
sizeof(NetOurNISDomain), size);
memcpy(&NetOurNISDomain, ext + 2, size); memcpy(&NetOurNISDomain, ext + 2, size);
NetOurNISDomain[size] = 0; NetOurNISDomain[size] = 0;
} }
@ -298,14 +289,15 @@ static void
BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len) unsigned len)
{ {
Bootp_t *bp; struct Bootp_t *bp;
debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n", debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
src, dest, len, sizeof (Bootp_t)); src, dest, len, sizeof(struct Bootp_t));
bp = (Bootp_t *)pkt; bp = (struct Bootp_t *)pkt;
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */ /* Filter out pkts we don't want */
if (BootpCheckPkt(pkt, dest, src, len))
return; return;
/* /*
@ -349,7 +341,8 @@ BootpTimeout(void)
* Initialize BOOTP extension fields in the request. * Initialize BOOTP extension fields in the request.
*/ */
#if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_CMD_DHCP)
static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP) static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID,
IPaddr_t RequestedIP)
{ {
u8 *start = e; u8 *start = e;
u8 *cnt; u8 *cnt;
@ -402,7 +395,8 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
*e++ = tmp & 0xff; *e++ = tmp & 0xff;
} }
#if defined(CONFIG_BOOTP_SEND_HOSTNAME) #if defined(CONFIG_BOOTP_SEND_HOSTNAME)
if ((hostname = getenv ("hostname"))) { hostname = getenv("hostname");
if (hostname) {
int hostnamelen = strlen(hostname); int hostnamelen = strlen(hostname);
*e++ = 12; /* Hostname */ *e++ = 12; /* Hostname */
@ -448,7 +442,8 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
#endif #endif
#if defined(CONFIG_BOOTP_VENDOREX) #if defined(CONFIG_BOOTP_VENDOREX)
if ((x = dhcp_vendorex_prep (e))) x = dhcp_vendorex_prep(e);
if (x)
return x - start; return x - start;
#endif #endif
@ -586,8 +581,8 @@ static int BootpExtended (u8 * e)
void void
BootpRequest(void) BootpRequest(void)
{ {
volatile uchar *pkt, *iphdr; uchar *pkt, *iphdr;
Bootp_t *bp; struct Bootp_t *bp;
int ext_len, pktlen, iplen; int ext_len, pktlen, iplen;
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start"); bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start");
@ -634,7 +629,6 @@ BootpRequest (void)
} }
/* Random Number Generator */ /* Random Number Generator */
for (reg = 0; reg <= 0; reg++) { for (reg = 0; reg <= 0; reg++) {
sum = seed1 + seed2; sum = seed1 + seed2;
if (sum < seed1 || sum < seed2) if (sum < seed1 || sum < seed2)
@ -650,9 +644,9 @@ BootpRequest (void)
} }
printf("Random delay: %ld ms...\n", sum); printf("Random delay: %ld ms...\n", sum);
for (reg=0; reg <sum; reg++) { for (reg = 0; reg < sum; reg++)
udelay(1000); /*Wait 1ms*/ udelay(1000); /*Wait 1ms*/
}
#endif /* CONFIG_BOOTP_RANDOM_DELAY */ #endif /* CONFIG_BOOTP_RANDOM_DELAY */
printf("BOOTP broadcast %d\n", ++BootpTry); printf("BOOTP broadcast %d\n", ++BootpTry);
@ -662,16 +656,18 @@ BootpRequest (void)
pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
/* /*
* Next line results in incorrect packet size being transmitted, resulting * Next line results in incorrect packet size being transmitted,
* in errors in some DHCP servers, reporting missing bytes. Size must be * resulting in errors in some DHCP servers, reporting missing bytes.
* set in packet header after extension length has been determined. * Size must be set in packet header after extension length has been
* determined.
* C. Hallinan, DS4.COM, Inc. * C. Hallinan, DS4.COM, Inc.
*/ */
/* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */ /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC,
sizeof (struct Bootp_t)); */
iphdr = pkt; /* We need this later for NetSetIP() */ iphdr = pkt; /* We need this later for NetSetIP() */
pkt += IP_HDR_SIZE; pkt += IP_HDR_SIZE;
bp = (Bootp_t *)pkt; bp = (struct Bootp_t *)pkt;
bp->bp_op = OP_BOOTREQUEST; bp->bp_op = OP_BOOTREQUEST;
bp->bp_htype = HWT_ETHER; bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER; bp->bp_hlen = HWL_ETHER;
@ -707,7 +703,8 @@ BootpRequest (void)
* Calculate proper packet lengths taking into account the * Calculate proper packet lengths taking into account the
* variable size of the options field * variable size of the options field
*/ */
pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len; pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE -
sizeof(bp->bp_vend) + ext_len;
iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len; iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);
@ -722,7 +719,7 @@ BootpRequest (void)
} }
#if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_CMD_DHCP)
static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp) static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
{ {
uchar *end = popt + BOOTP_HDR_SIZE; uchar *end = popt + BOOTP_HDR_SIZE;
int oplen, size; int oplen, size;
@ -749,20 +746,21 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
case 6: case 6:
NetCopyIP(&NetOurDNSIP, (popt + 2)); NetCopyIP(&NetOurDNSIP, (popt + 2));
#if defined(CONFIG_BOOTP_DNS2) #if defined(CONFIG_BOOTP_DNS2)
if (*(popt + 1) > 4) { if (*(popt + 1) > 4)
NetCopyIP(&NetOurDNS2IP, (popt + 2 + 4)); NetCopyIP(&NetOurDNS2IP, (popt + 2 + 4));
}
#endif #endif
break; break;
case 12: case 12:
size = truncate_sz ("Host Name", sizeof (NetOurHostName), oplen); size = truncate_sz("Host Name",
sizeof(NetOurHostName), oplen);
memcpy(&NetOurHostName, popt + 2, size); memcpy(&NetOurHostName, popt + 2, size);
NetOurHostName[size] = 0; NetOurHostName[size] = 0;
break; break;
case 15: /* Ignore Domain Name Option */ case 15: /* Ignore Domain Name Option */
break; break;
case 17: case 17:
size = truncate_sz ("Root Path", sizeof (NetOurRootPath), oplen); size = truncate_sz("Root Path",
sizeof(NetOurRootPath), oplen);
memcpy(&NetOurRootPath, popt + 2, size); memcpy(&NetOurRootPath, popt + 2, size);
NetOurRootPath[size] = 0; NetOurRootPath[size] = 0;
break; break;
@ -816,7 +814,8 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
if (dhcp_vendorex_proc(popt)) if (dhcp_vendorex_proc(popt))
break; break;
#endif #endif
printf ("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt); printf("*** Unhandled DHCP Option in OFFER/ACK:"
" %d\n", *popt);
break; break;
} }
popt += oplen + 2; /* Process next option */ popt += oplen + 2; /* Process next option */
@ -837,10 +836,10 @@ static int DhcpMessageType(unsigned char *popt)
return -1; return -1;
} }
static void DhcpSendRequestPkt(Bootp_t *bp_offer) static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
{ {
volatile uchar *pkt, *iphdr; uchar *pkt, *iphdr;
Bootp_t *bp; struct Bootp_t *bp;
int pktlen, iplen, extlen; int pktlen, iplen, extlen;
IPaddr_t OfferedIP; IPaddr_t OfferedIP;
@ -853,14 +852,14 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
iphdr = pkt; /* We'll need this later to set proper pkt size */ iphdr = pkt; /* We'll need this later to set proper pkt size */
pkt += IP_HDR_SIZE; pkt += IP_HDR_SIZE;
bp = (Bootp_t *)pkt; bp = (struct Bootp_t *)pkt;
bp->bp_op = OP_BOOTREQUEST; bp->bp_op = OP_BOOTREQUEST;
bp->bp_htype = HWT_ETHER; bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER; bp->bp_hlen = HWL_ETHER;
bp->bp_hops = 0; bp->bp_hops = 0;
bp->bp_secs = htons(get_timer(0) / 1000); bp->bp_secs = htons(get_timer(0) / 1000);
/* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by /* Do not set the client IP, your IP, or server IP yet, since it
* the server yet */ * hasn't been ACK'ed by the server yet */
/* /*
* RFC3046 requires Relay Agents to discard packets with * RFC3046 requires Relay Agents to discard packets with
@ -882,9 +881,11 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
/* Copy offered IP into the parameters request list */ /* Copy offered IP into the parameters request list */
NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr); NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP); extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST,
NetDHCPServerIP, OfferedIP);
pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen; pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE -
sizeof(bp->bp_vend) + extlen;
iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen; iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
@ -902,24 +903,25 @@ static void
DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len) unsigned len)
{ {
Bootp_t *bp = (Bootp_t *)pkt; struct Bootp_t *bp = (struct Bootp_t *)pkt;
debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n", debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
src, dest, len, dhcp_state); src, dest, len, dhcp_state);
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */ /* Filter out pkts we don't want */
if (BootpCheckPkt(pkt, dest, src, len))
return; return;
debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n", debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state:"
src, dest, len, dhcp_state); " %d\n", src, dest, len, dhcp_state);
switch (dhcp_state) { switch (dhcp_state) {
case SELECTING: case SELECTING:
/* /*
* Wait an appropriate time for any potential DHCPOFFER packets * Wait an appropriate time for any potential DHCPOFFER packets
* to arrive. Then select one, and generate DHCPREQUEST response. * to arrive. Then select one, and generate DHCPREQUEST
* If filename is in format we recognize, assume it is a valid * response. If filename is in format we recognize, assume it
* OFFER from a server we want. * is a valid OFFER from a server we want.
*/ */
debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file); debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
#ifdef CONFIG_SYS_BOOTFILE_PREFIX #ifdef CONFIG_SYS_BOOTFILE_PREFIX
@ -931,7 +933,8 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("TRANSITIONING TO REQUESTING STATE\n"); debug("TRANSITIONING TO REQUESTING STATE\n");
dhcp_state = REQUESTING; dhcp_state = REQUESTING;
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
NetSetTimeout(TIMEOUT, BootpTimeout); NetSetTimeout(TIMEOUT, BootpTimeout);
@ -946,11 +949,14 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("DHCP State: REQUESTING\n"); debug("DHCP State: REQUESTING\n");
if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) { if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) {
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
BootpCopyNetParams(bp); /* Store net params from reply */ /* Store net params from reply */
BootpCopyNetParams(bp);
dhcp_state = BOUND; dhcp_state = BOUND;
printf ("DHCP client bound to address %pI4\n", &NetOurIP); printf("DHCP client bound to address %pI4\n",
&NetOurIP);
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP,
"bootp_stop"); "bootp_stop");

View file

@ -19,13 +19,17 @@
* BOOTP header. * BOOTP header.
*/ */
#if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_CMD_DHCP)
#define OPT_SIZE 312 /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */ /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
#define OPT_SIZE 312
#if defined(CONFIG_BOOTP_VENDOREX)
extern u8 *dhcp_vendorex_prep(u8 *e); /*rtn new e after add own opts. */
extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */
#endif
#else #else
#define OPT_SIZE 64 #define OPT_SIZE 64
#endif #endif
typedef struct struct Bootp_t {
{
uchar bp_op; /* Operation */ uchar bp_op; /* Operation */
# define OP_BOOTREQUEST 1 # define OP_BOOTREQUEST 1
# define OP_BOOTREPLY 2 # define OP_BOOTREPLY 2
@ -45,9 +49,9 @@ typedef struct
char bp_sname[64]; /* Server host name */ char bp_sname[64]; /* Server host name */
char bp_file[128]; /* Boot file name */ char bp_file[128]; /* Boot file name */
char bp_vend[OPT_SIZE]; /* Vendor information */ char bp_vend[OPT_SIZE]; /* Vendor information */
} Bootp_t; };
#define BOOTP_HDR_SIZE sizeof (Bootp_t) #define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE) #define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE)
/**********************************************************************/ /**********************************************************************/

View file

@ -82,14 +82,12 @@ int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
#ifdef CONFIG_API #ifdef CONFIG_API
extern void (*push_packet)(volatile void *, int);
static struct { static struct {
uchar data[PKTSIZE]; uchar data[PKTSIZE];
int length; int length;
} eth_rcv_bufs[PKTBUFSRX]; } eth_rcv_bufs[PKTBUFSRX];
static unsigned int eth_rcv_current = 0, eth_rcv_last = 0; static unsigned int eth_rcv_current, eth_rcv_last;
#endif #endif
static struct eth_device *eth_devices, *eth_current; static struct eth_device *eth_devices, *eth_current;
@ -143,9 +141,8 @@ struct eth_device *eth_get_dev_by_index(int index)
int eth_get_dev_index(void) int eth_get_dev_index(void)
{ {
if (!eth_current) { if (!eth_current)
return -1; return -1;
}
return eth_current->index; return eth_current->index;
} }
@ -190,9 +187,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
if (dev->write_hwaddr && if (dev->write_hwaddr &&
!eth_mac_skip(eth_number) && !eth_mac_skip(eth_number) &&
is_valid_ether_addr(dev->enetaddr)) { is_valid_ether_addr(dev->enetaddr))
ret = dev->write_hwaddr(dev); ret = dev->write_hwaddr(dev);
}
return ret; return ret;
} }
@ -200,7 +196,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
int eth_register(struct eth_device *dev) int eth_register(struct eth_device *dev)
{ {
struct eth_device *d; struct eth_device *d;
static int index = 0; static int index;
assert(strlen(dev->name) < sizeof(dev->name)); assert(strlen(dev->name) < sizeof(dev->name));
@ -249,6 +245,14 @@ int eth_unregister(struct eth_device *dev)
return 0; return 0;
} }
static void eth_env_init(bd_t *bis)
{
const char *s;
if ((s = getenv("bootfile")) != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
int eth_initialize(bd_t *bis) int eth_initialize(bd_t *bis)
{ {
int num_devices = 0; int num_devices = 0;
@ -264,6 +268,8 @@ int eth_initialize(bd_t *bis)
phy_init(); phy_init();
#endif #endif
eth_env_init(bis);
/* /*
* If board-specific initialization exists, call it. * If board-specific initialization exists, call it.
* If not, call a CPU-specific one * If not, call a CPU-specific one
@ -297,7 +303,8 @@ int eth_initialize(bd_t *bis)
} }
if (strchr(dev->name, ' ')) if (strchr(dev->name, ' '))
puts("\nWarning: eth device name has a space!\n"); puts("\nWarning: eth device name has a space!"
"\n");
if (eth_write_hwaddr(dev, "eth", dev->index)) if (eth_write_hwaddr(dev, "eth", dev->index))
puts("\nWarning: failed to set MAC address\n"); puts("\nWarning: failed to set MAC address\n");
@ -407,7 +414,7 @@ void eth_halt(void)
eth_current->state = ETH_STATE_PASSIVE; eth_current->state = ETH_STATE_PASSIVE;
} }
int eth_send(volatile void *packet, int length) int eth_send(void *packet, int length)
{ {
if (!eth_current) if (!eth_current)
return -1; return -1;
@ -424,9 +431,9 @@ int eth_rx(void)
} }
#ifdef CONFIG_API #ifdef CONFIG_API
static void eth_save_packet(volatile void *packet, int length) static void eth_save_packet(void *packet, int length)
{ {
volatile char *p = packet; char *p = packet;
int i; int i;
if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current) if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current)
@ -442,9 +449,9 @@ static void eth_save_packet(volatile void *packet, int length)
eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX; eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX;
} }
int eth_receive(volatile void *packet, int length) int eth_receive(void *packet, int length)
{ {
volatile char *p = packet; char *p = packet;
void *pp = push_packet; void *pp = push_packet;
int i; int i;
@ -472,37 +479,35 @@ int eth_receive(volatile void *packet, int length)
void eth_try_another(int first_restart) void eth_try_another(int first_restart)
{ {
static struct eth_device *first_failed = NULL; static struct eth_device *first_failed;
char *ethrotate; char *ethrotate;
/* /*
* Do not rotate between network interfaces when * Do not rotate between network interfaces when
* 'ethrotate' variable is set to 'no'. * 'ethrotate' variable is set to 'no'.
*/ */
if (((ethrotate = getenv ("ethrotate")) != NULL) && ethrotate = getenv("ethrotate");
(strcmp(ethrotate, "no") == 0)) if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
return; return;
if (!eth_current) if (!eth_current)
return; return;
if (first_restart) { if (first_restart)
first_failed = eth_current; first_failed = eth_current;
}
eth_current = eth_current->next; eth_current = eth_current->next;
eth_current_changed(); eth_current_changed();
if (first_failed == eth_current) { if (first_failed == eth_current)
NetRestartWrap = 1; NetRestartWrap = 1;
} }
}
void eth_set_current(void) void eth_set_current(void)
{ {
static char *act = NULL; static char *act;
static int env_changed_id = 0; static int env_changed_id;
struct eth_device *old_current; struct eth_device *old_current;
int env_id; int env_id;
@ -528,5 +533,5 @@ void eth_set_current(void)
char *eth_get_name(void) char *eth_get_name(void)
{ {
return (eth_current ? eth_current->name : "unknown"); return eth_current ? eth_current->name : "unknown";
} }

View file

@ -77,6 +77,7 @@
#include <common.h> #include <common.h>
#include <watchdog.h> #include <watchdog.h>
#include <command.h> #include <command.h>
#include <linux/compiler.h>
#include <net.h> #include <net.h>
#include "bootp.h" #include "bootp.h"
#include "tftp.h" #include "tftp.h"
@ -152,7 +153,7 @@ IPaddr_t NetOurIP;
/* Server IP addr (0 = unknown) */ /* Server IP addr (0 = unknown) */
IPaddr_t NetServerIP; IPaddr_t NetServerIP;
/* Current receive packet */ /* Current receive packet */
volatile uchar *NetRxPacket; uchar *NetRxPacket;
/* Current rx packet length */ /* Current rx packet length */
int NetRxPacketLen; int NetRxPacketLen;
/* IP packet ID */ /* IP packet ID */
@ -161,7 +162,7 @@ unsigned NetIPID;
uchar NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; uchar NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
uchar NetEtherNullAddr[6]; uchar NetEtherNullAddr[6];
#ifdef CONFIG_API #ifdef CONFIG_API
void (*push_packet)(volatile void *, int len) = 0; void (*push_packet)(void *, int len) = 0;
#endif #endif
#if defined(CONFIG_CMD_CDP) #if defined(CONFIG_CMD_CDP)
/* Ethernet bcast address */ /* Ethernet bcast address */
@ -203,15 +204,10 @@ IPaddr_t NetNtpServerIP;
int NetTimeOffset; int NetTimeOffset;
#endif #endif
#ifdef CONFIG_NETCONSOLE uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
void NcStart(void);
int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
#endif
volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
/* Receive packet */ /* Receive packet */
volatile uchar *NetRxPackets[PKTBUFSRX]; uchar *NetRxPackets[PKTBUFSRX];
/* Current RX packet handler */ /* Current RX packet handler */
static rxhand_f *packetHandler; static rxhand_f *packetHandler;
@ -225,7 +221,7 @@ static ulong timeStart;
/* Current timeout value */ /* Current timeout value */
static ulong timeDelta; static ulong timeDelta;
/* THE transmit packet */ /* THE transmit packet */
volatile uchar *NetTxPacket; uchar *NetTxPacket;
static int net_check_prereq(enum proto_t protocol); static int net_check_prereq(enum proto_t protocol);
@ -246,7 +242,7 @@ int NetArpWaitTry;
void ArpRequest(void) void ArpRequest(void)
{ {
volatile uchar *pkt; uchar *pkt;
ARP_t *arp; ARP_t *arp;
debug("ARP broadcast %d\n", NetArpWaitTry); debug("ARP broadcast %d\n", NetArpWaitTry);
@ -342,13 +338,11 @@ void net_auto_load(void)
static void NetInitLoop(enum proto_t protocol) static void NetInitLoop(enum proto_t protocol)
{ {
static int env_changed_id; static int env_changed_id;
bd_t *bd = gd->bd;
int env_id = get_env_id(); int env_id = get_env_id();
/* update only when the environment has changed */ /* update only when the environment has changed */
if (env_changed_id != env_id) { if (env_changed_id != env_id) {
NetOurIP = getenv_IPaddr("ipaddr"); NetOurIP = getenv_IPaddr("ipaddr");
NetCopyIP(&bd->bi_ip_addr, &NetOurIP);
NetOurGatewayIP = getenv_IPaddr("gatewayip"); NetOurGatewayIP = getenv_IPaddr("gatewayip");
NetOurSubnetMask = getenv_IPaddr("netmask"); NetOurSubnetMask = getenv_IPaddr("netmask");
NetServerIP = getenv_IPaddr("serverip"); NetServerIP = getenv_IPaddr("serverip");
@ -527,10 +521,7 @@ restart:
for (;;) { for (;;) {
WATCHDOG_RESET(); WATCHDOG_RESET();
#ifdef CONFIG_SHOW_ACTIVITY #ifdef CONFIG_SHOW_ACTIVITY
{
extern void show_activity(int arg);
show_activity(1); show_activity(1);
}
#endif #endif
/* /*
* Check the ethernet for a new packet. The ethernet * Check the ethernet for a new packet. The ethernet
@ -705,7 +696,7 @@ NetSetTimeout(ulong iv, thand_f *f)
void void
NetSendPacket(volatile uchar *pkt, int len) NetSendPacket(uchar *pkt, int len)
{ {
(void) eth_send(pkt, len); (void) eth_send(pkt, len);
} }
@ -768,8 +759,8 @@ static ushort PingSeqNo;
int PingSend(void) int PingSend(void)
{ {
static uchar mac[6]; static uchar mac[6];
volatile IP_t *ip; IP_t *ip;
volatile ushort *s; ushort *s;
uchar *pkt; uchar *pkt;
/* XXX always send arp request */ /* XXX always send arp request */
@ -784,7 +775,7 @@ int PingSend(void)
pkt = NetArpWaitTxPacket; pkt = NetArpWaitTxPacket;
pkt += NetSetEther(pkt, mac, PROT_IP); pkt += NetSetEther(pkt, mac, PROT_IP);
ip = (volatile IP_t *)pkt; ip = (IP_t *)pkt;
/* /*
* Construct an IP and ICMP header. * Construct an IP and ICMP header.
@ -936,9 +927,9 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
int CDPSendTrigger(void) int CDPSendTrigger(void)
{ {
volatile uchar *pkt; uchar *pkt;
volatile ushort *s; ushort *s;
volatile ushort *cp; ushort *cp;
Ethernet_t *et; Ethernet_t *et;
int len; int len;
ushort chksum; ushort chksum;
@ -965,7 +956,7 @@ int CDPSendTrigger(void)
/* CDP header */ /* CDP header */
*pkt++ = 0x02; /* CDP version 2 */ *pkt++ = 0x02; /* CDP version 2 */
*pkt++ = 180; /* TTL */ *pkt++ = 180; /* TTL */
s = (volatile ushort *)pkt; s = (ushort *)pkt;
cp = s; cp = s;
/* checksum (0 for later calculation) */ /* checksum (0 for later calculation) */
*s++ = htons(0); *s++ = htons(0);
@ -1103,8 +1094,8 @@ CDPHandler(const uchar *pkt, unsigned len)
* output a warning * output a warning
*/ */
if (pkt[0] != 0x02) if (pkt[0] != 0x02)
printf("** WARNING: CDP packet received with a protocol version %d > 2\n", printf("**WARNING: CDP packet received with a protocol version "
pkt[0] & 0xff); "%d > 2\n", pkt[0] & 0xff);
if (CDP_compute_csum(pkt, len) != 0) if (CDP_compute_csum(pkt, len) != 0)
return; return;
@ -1239,7 +1230,7 @@ struct hole {
static IP_t *__NetDefragment(IP_t *ip, int *lenp) static IP_t *__NetDefragment(IP_t *ip, int *lenp)
{ {
static uchar pkt_buff[IP_PKTSIZE] __attribute__((aligned(PKTALIGN))); static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
static u16 first_hole, total_len; static u16 first_hole, total_len;
struct hole *payload, *thisfrag, *h, *newh; struct hole *payload, *thisfrag, *h, *newh;
IP_t *localip = (IP_t *)pkt_buff; IP_t *localip = (IP_t *)pkt_buff;
@ -1439,7 +1430,7 @@ static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
} }
void void
NetReceive(volatile uchar *inpkt, int len) NetReceive(uchar *inpkt, int len)
{ {
Ethernet_t *et; Ethernet_t *et;
IP_t *ip; IP_t *ip;
@ -1611,6 +1602,7 @@ NetReceive(volatile uchar *inpkt, int len)
/* matched waiting packet's address */ /* matched waiting packet's address */
if (tmp == NetArpWaitReplyIP) { if (tmp == NetArpWaitReplyIP) {
debug("Got it\n"); debug("Got it\n");
/* save address for later use */ /* save address for later use */
memcpy(NetArpWaitPacketMAC, memcpy(NetArpWaitPacketMAC,
&arp->ar_data[0], 6); &arp->ar_data[0], 6);
@ -1619,7 +1611,8 @@ NetReceive(volatile uchar *inpkt, int len)
(*packetHandler)(0, 0, 0, 0, 0); (*packetHandler)(0, 0, 0, 0, 0);
#endif #endif
/* modify header, and transmit it */ /* modify header, and transmit it */
memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6); memcpy(((Ethernet_t *)NetArpWaitTxPacket)->
et_dest, NetArpWaitPacketMAC, 6);
(void) eth_send(NetArpWaitTxPacket, (void) eth_send(NetArpWaitTxPacket,
NetArpWaitTxPacketSize); NetArpWaitTxPacketSize);
@ -1856,7 +1849,6 @@ common:
case CDP: case CDP:
case DHCP: case DHCP:
if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) { if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
extern int eth_get_dev_index(void);
int num = eth_get_dev_index(); int num = eth_get_dev_index();
switch (num) { switch (num) {
@ -1918,7 +1910,7 @@ NetEthHdrSize(void)
} }
int int
NetSetEther(volatile uchar *xet, uchar * addr, uint prot) NetSetEther(uchar *xet, uchar * addr, uint prot)
{ {
Ethernet_t *et = (Ethernet_t *)xet; Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid; ushort myvlanid;
@ -1943,7 +1935,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
} }
void void
NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len) NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
{ {
IP_t *ip = (IP_t *)xip; IP_t *ip = (IP_t *)xip;

View file

@ -33,8 +33,8 @@
#define NFS_RETRY_COUNT 30 #define NFS_RETRY_COUNT 30
#define NFS_TIMEOUT 2000UL #define NFS_TIMEOUT 2000UL
static int fs_mounted = 0; static int fs_mounted;
static unsigned long rpc_id = 0; static unsigned long rpc_id;
static int nfs_offset = -1; static int nfs_offset = -1;
static int nfs_len; static int nfs_len;
@ -61,7 +61,7 @@ static char *nfs_filename;
static char *nfs_path; static char *nfs_path;
static char nfs_path_buff[2048]; static char nfs_path_buff[2048];
static __inline__ int static inline int
store_block(uchar *src, unsigned offset, unsigned len) store_block(uchar *src, unsigned offset, unsigned len)
{ {
ulong newsize = offset + len; ulong newsize = offset + len;
@ -148,9 +148,8 @@ static long *rpc_add_credentials (long *p)
*p++ = htonl(hl+20); /* auth length */ *p++ = htonl(hl+20); /* auth length */
*p++ = htonl(0); /* stamp */ *p++ = htonl(0); /* stamp */
*p++ = htonl(hostnamelen); /* hostname string */ *p++ = htonl(hostnamelen); /* hostname string */
if (hostnamelen & 3) { if (hostnamelen & 3)
*(p + hostnamelen / 4) = 0; /* add zero padding */ *(p + hostnamelen / 4) = 0; /* add zero padding */
}
memcpy(p, hostname, hostnamelen); memcpy(p, hostname, hostnamelen);
p += hl / 4; p += hl / 4;
*p++ = 0; /* uid */ *p++ = 0; /* uid */
@ -190,7 +189,8 @@ rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt; pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
memcpy ((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, (char *)&pkt, pktlen); memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
(char *)&pkt, pktlen);
if (rpc_prog == PROG_PORTMAP) if (rpc_prog == PROG_PORTMAP)
sport = SUNRPC_PORT; sport = SUNRPC_PORT;
@ -199,7 +199,8 @@ rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
else else
sport = NfsSrvNfsPort; sport = NfsSrvNfsPort;
NetSendUDPPacket (NetServerEther, NfsServerIP, sport, NfsOurPort, pktlen); NetSendUDPPacket(NetServerEther, NfsServerIP, sport, NfsOurPort,
pktlen);
} }
/************************************************************************** /**************************************************************************
@ -237,7 +238,8 @@ nfs_mount_req (char *path)
p = (uint32_t *)rpc_add_credentials((long *)p); p = (uint32_t *)rpc_add_credentials((long *)p);
*p++ = htonl(pathlen); *p++ = htonl(pathlen);
if (pathlen & 3) *(p + pathlen / 4) = 0; if (pathlen & 3)
*(p + pathlen / 4) = 0;
memcpy(p, path, pathlen); memcpy(p, path, pathlen);
p += (pathlen + 3) / 4; p += (pathlen + 3) / 4;
@ -256,10 +258,9 @@ nfs_umountall_req (void)
uint32_t *p; uint32_t *p;
int len; int len;
if ((NfsSrvMountPort == -1) || (!fs_mounted)) { if ((NfsSrvMountPort == -1) || (!fs_mounted))
/* Nothing mounted, nothing to umount */ /* Nothing mounted, nothing to umount */
return; return;
}
p = &(data[0]); p = &(data[0]);
p = (uint32_t *)rpc_add_credentials((long *)p); p = (uint32_t *)rpc_add_credentials((long *)p);
@ -313,7 +314,8 @@ nfs_lookup_req (char *fname)
memcpy(p, dirfh, NFS_FHSIZE); memcpy(p, dirfh, NFS_FHSIZE);
p += (NFS_FHSIZE / 4); p += (NFS_FHSIZE / 4);
*p++ = htonl(fnamelen); *p++ = htonl(fnamelen);
if (fnamelen & 3) *(p + fnamelen / 4) = 0; if (fnamelen & 3)
*(p + fnamelen / 4) = 0;
memcpy(p, fname, fnamelen); memcpy(p, fname, fnamelen);
p += (fnamelen + 3) / 4; p += (fnamelen + 3) / 4;
@ -398,9 +400,8 @@ rpc_lookup_reply (int prog, uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus || if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus) { rpc_pkt.u.reply.astatus)
return -1; return -1;
}
switch (prog) { switch (prog) {
case PROG_MOUNT: case PROG_MOUNT:
@ -429,9 +430,8 @@ nfs_mount_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus || if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus || rpc_pkt.u.reply.astatus ||
rpc_pkt.u.reply.data[0]) { rpc_pkt.u.reply.data[0])
return -1; return -1;
}
fs_mounted = 1; fs_mounted = 1;
memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE); memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
@ -453,9 +453,8 @@ nfs_umountall_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus || if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus) { rpc_pkt.u.reply.astatus)
return -1; return -1;
}
fs_mounted = 0; fs_mounted = 0;
memset(dirfh, 0, sizeof(dirfh)); memset(dirfh, 0, sizeof(dirfh));
@ -478,9 +477,8 @@ nfs_lookup_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus || if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus || rpc_pkt.u.reply.astatus ||
rpc_pkt.u.reply.data[0]) { rpc_pkt.u.reply.data[0])
return -1; return -1;
}
memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE); memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
@ -503,9 +501,8 @@ nfs_readlink_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus || if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus || rpc_pkt.u.reply.astatus ||
rpc_pkt.u.reply.data[0]) { rpc_pkt.u.reply.data[0])
return -1; return -1;
}
rlen = ntohl(rpc_pkt.u.reply.data[1]); /* new path length */ rlen = ntohl(rpc_pkt.u.reply.data[1]); /* new path length */
@ -513,7 +510,8 @@ nfs_readlink_reply (uchar *pkt, unsigned len)
int pathlen; int pathlen;
strcat(nfs_path, "/"); strcat(nfs_path, "/");
pathlen = strlen(nfs_path); pathlen = strlen(nfs_path);
memcpy (nfs_path+pathlen, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen); memcpy(nfs_path + pathlen, (uchar *)&(rpc_pkt.u.reply.data[2]),
rlen);
nfs_path[pathlen + rlen] = 0; nfs_path[pathlen + rlen] = 0;
} else { } else {
memcpy(nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen); memcpy(nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen);
@ -539,24 +537,22 @@ nfs_read_reply (uchar *pkt, unsigned len)
rpc_pkt.u.reply.verifier || rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus || rpc_pkt.u.reply.astatus ||
rpc_pkt.u.reply.data[0]) { rpc_pkt.u.reply.data[0]) {
if (rpc_pkt.u.reply.rstatus) { if (rpc_pkt.u.reply.rstatus)
return -9999; return -9999;
} if (rpc_pkt.u.reply.astatus)
if (rpc_pkt.u.reply.astatus) {
return -9999; return -9999;
} return -ntohl(rpc_pkt.u.reply.data[0]);
return -ntohl(rpc_pkt.u.reply.data[0]);;
} }
if ((nfs_offset!=0) && !((nfs_offset) % (NFS_READ_SIZE/2*10*HASHES_PER_LINE))) { if ((nfs_offset != 0) && !((nfs_offset) %
(NFS_READ_SIZE / 2 * 10 * HASHES_PER_LINE)))
puts("\n\t "); puts("\n\t ");
} if (!(nfs_offset % ((NFS_READ_SIZE / 2) * 10)))
if (!(nfs_offset % ((NFS_READ_SIZE/2)*10))) {
putc('#'); putc('#');
}
rlen = ntohl(rpc_pkt.u.reply.data[18]); rlen = ntohl(rpc_pkt.u.reply.data[18]);
if ( store_block ((uchar *)pkt+sizeof(rpc_pkt.u.reply), nfs_offset, rlen) ) if (store_block((uchar *)pkt + sizeof(rpc_pkt.u.reply),
nfs_offset, rlen))
return -9999; return -9999;
return rlen; return rlen;
@ -586,7 +582,8 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
debug("%s\n", __func__); debug("%s\n", __func__);
if (dest != NfsOurPort) return; if (dest != NfsOurPort)
return;
switch (NfsState) { switch (NfsState) {
case STATE_PRCLOOKUP_PROG_MOUNT_REQ: case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
@ -657,13 +654,13 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
if (rlen > 0) { if (rlen > 0) {
nfs_offset += rlen; nfs_offset += rlen;
NfsSend(); NfsSend();
} } else if ((rlen == -NFSERR_ISDIR) || (rlen == -NFSERR_INVAL)) {
else if ((rlen == -NFSERR_ISDIR)||(rlen == -NFSERR_INVAL)) {
/* symbolic link */ /* symbolic link */
NfsState = STATE_READLINK_REQ; NfsState = STATE_READLINK_REQ;
NfsSend(); NfsSend();
} else { } else {
if ( ! rlen ) NfsDownloadState = NETLOOP_SUCCESS; if (!rlen)
NfsDownloadState = NETLOOP_SUCCESS;
NfsState = STATE_UMOUNT_REQ; NfsState = STATE_UMOUNT_REQ;
NfsSend(); NfsSend();
} }
@ -725,7 +722,8 @@ NfsStart (void)
IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask; IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask;
if (OurNet != ServerNet) if (OurNet != ServerNet)
printf("; sending through gateway %pI4", &NetOurGatewayIP); printf("; sending through gateway %pI4",
&NetOurGatewayIP);
} }
printf("\nFilename '%s/%s'.", nfs_path, nfs_filename); printf("\nFilename '%s/%s'.", nfs_path, nfs_filename);

View file

@ -71,7 +71,7 @@ void
RarpRequest(void) RarpRequest(void)
{ {
int i; int i;
volatile uchar *pkt; uchar *pkt;
ARP_t *rarp; ARP_t *rarp;
printf("RARP broadcast %d\n", ++RarpTry); printf("RARP broadcast %d\n", ++RarpTry);
@ -88,11 +88,11 @@ RarpRequest (void)
rarp->ar_op = htons(RARPOP_REQUEST); rarp->ar_op = htons(RARPOP_REQUEST);
memcpy(&rarp->ar_data[0], NetOurEther, 6); /* source ET addr */ memcpy(&rarp->ar_data[0], NetOurEther, 6); /* source ET addr */
memcpy(&rarp->ar_data[6], &NetOurIP, 4); /* source IP addr */ memcpy(&rarp->ar_data[6], &NetOurIP, 4); /* source IP addr */
memcpy (&rarp->ar_data[10], NetOurEther, 6); /* dest ET addr = source ET addr ??*/ /* dest ET addr = source ET addr ??*/
memcpy(&rarp->ar_data[10], NetOurEther, 6);
/* dest. IP addr set to broadcast */ /* dest. IP addr set to broadcast */
for (i = 0; i <= 3; i++) { for (i = 0; i <= 3; i++)
rarp->ar_data[16 + i] = 0xff; rarp->ar_data[16 + i] = 0xff;
}
NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);

View file

@ -31,12 +31,14 @@ SntpSend (void)
pkt.vn = NTP_VERSION; pkt.vn = NTP_VERSION;
pkt.mode = NTP_MODE_CLIENT; pkt.mode = NTP_MODE_CLIENT;
memcpy ((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, (char *)&pkt, pktlen); memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
(char *)&pkt, pktlen);
SntpOurPort = 10000 + (get_timer(0) % 4096); SntpOurPort = 10000 + (get_timer(0) % 4096);
sport = NTP_SERVICE_PORT; sport = NTP_SERVICE_PORT;
NetSendUDPPacket (NetServerEther, NetNtpServerIP, sport, SntpOurPort, pktlen); NetSendUDPPacket(NetServerEther, NetNtpServerIP, sport, SntpOurPort,
pktlen);
} }
static void static void
@ -57,7 +59,8 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("%s\n", __func__); debug("%s\n", __func__);
if (dest != SntpOurPort) return; if (dest != SntpOurPort)
return;
/* /*
* As the RTC's used in U-Boot sepport second resolution only * As the RTC's used in U-Boot sepport second resolution only
@ -83,7 +86,7 @@ SntpStart (void)
NetSetTimeout(SNTP_TIMEOUT, SntpTimeout); NetSetTimeout(SNTP_TIMEOUT, SntpTimeout);
NetSetHandler(SntpHandler); NetSetHandler(SntpHandler);
memset (NetServerEther, 0, 6); memset(NetServerEther, 0, sizeof(NetServerEther));
SntpSend(); SntpSend();
} }

View file

@ -11,6 +11,9 @@
#include <net.h> #include <net.h>
#include "tftp.h" #include "tftp.h"
#include "bootp.h" #include "bootp.h"
#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
#include <flash.h>
#endif
/* Well known TFTP port # */ /* Well known TFTP port # */
#define WELL_KNOWN_PORT 69 #define WELL_KNOWN_PORT 69
@ -112,10 +115,6 @@ static char default_filename[DEFAULT_NAME_LEN];
static char tftp_filename[MAX_LEN]; static char tftp_filename[MAX_LEN];
#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
extern flash_info_t flash_info[];
#endif
/* 512 is poor choice for ethernet, MTU is typically 1500. /* 512 is poor choice for ethernet, MTU is typically 1500.
* Minus eth.hdrs thats 1468. Can get 2x better throughput with * Minus eth.hdrs thats 1468. Can get 2x better throughput with
* almost-MTU block sizes. At least try... fall back to 512 if need be. * almost-MTU block sizes. At least try... fall back to 512 if need be.
@ -137,7 +136,6 @@ static unsigned *Bitmap;
static int PrevBitmapHole, Mapsize = MTFTP_BITMAPSIZE; static int PrevBitmapHole, Mapsize = MTFTP_BITMAPSIZE;
static uchar ProhibitMcast, MasterClient; static uchar ProhibitMcast, MasterClient;
static uchar Multicast; static uchar Multicast;
extern IPaddr_t Mcast_addr;
static int Mcast_port; static int Mcast_port;
static ulong TftpEndingBlock; /* can get 'last' block before done..*/ static ulong TftpEndingBlock; /* can get 'last' block before done..*/
@ -157,7 +155,7 @@ mcast_cleanup(void)
#endif /* CONFIG_MCAST_TFTP */ #endif /* CONFIG_MCAST_TFTP */
static __inline__ void static inline void
store_block(unsigned block, uchar *src, unsigned len) store_block(unsigned block, uchar *src, unsigned len)
{ {
ulong offset = block * TftpBlkSize + TftpBlockWrapOffset; ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
@ -182,8 +180,7 @@ store_block(unsigned block, uchar *src, unsigned len)
NetState = NETLOOP_FAIL; NetState = NETLOOP_FAIL;
return; return;
} }
} } else
else
#endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */ #endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
{ {
(void)memcpy((void *)(load_addr + offset), src, len); (void)memcpy((void *)(load_addr + offset), src, len);
@ -310,9 +307,9 @@ static void
TftpSend(void) TftpSend(void)
{ {
uchar *pkt; uchar *pkt;
volatile uchar *xp; uchar *xp;
int len = 0; int len = 0;
volatile ushort *s; ushort *s;
#ifdef CONFIG_MCAST_TFTP #ifdef CONFIG_MCAST_TFTP
/* Multicast TFTP.. non-MasterClients do not ACK data. */ /* Multicast TFTP.. non-MasterClients do not ACK data. */
@ -357,12 +354,14 @@ TftpSend(void)
0, TftpBlkSizeOption, 0); 0, TftpBlkSizeOption, 0);
#ifdef CONFIG_MCAST_TFTP #ifdef CONFIG_MCAST_TFTP
/* Check all preconditions before even trying the option */ /* Check all preconditions before even trying the option */
if (!ProhibitMcast if (!ProhibitMcast) {
&& (Bitmap = malloc(Mapsize)) Bitmap = malloc(Mapsize);
&& eth_get_dev()->mcast) { if (Bitmap && eth_get_dev()->mcast) {
free(Bitmap); free(Bitmap);
Bitmap = NULL; Bitmap = NULL;
pkt += sprintf((char *)pkt, "multicast%c%c", 0, 0); pkt += sprintf((char *)pkt, "multicast%c%c",
0, 0);
}
} }
#endif /* CONFIG_MCAST_TFTP */ #endif /* CONFIG_MCAST_TFTP */
len = pkt - xp; len = pkt - xp;
@ -630,8 +629,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
mcast_cleanup(); mcast_cleanup();
NetState = NETLOOP_SUCCESS; NetState = NETLOOP_SUCCESS;
} }
} } else
else
#endif #endif
if (len < TftpBlkSize) if (len < TftpBlkSize)
tftp_complete(); tftp_complete();