summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/u-boot.h1
-rw-r--r--arch/arm/lib/board.c11
-rw-r--r--arch/avr32/include/asm/u-boot.h1
-rw-r--r--arch/avr32/lib/board.c5
-rw-r--r--arch/blackfin/include/asm/u-boot.h1
-rw-r--r--arch/blackfin/lib/board.c10
-rw-r--r--arch/m68k/include/asm/u-boot.h1
-rw-r--r--arch/m68k/lib/board.c14
-rw-r--r--arch/microblaze/include/asm/u-boot.h1
-rw-r--r--arch/microblaze/lib/board.c7
-rw-r--r--arch/mips/include/asm/u-boot.h1
-rw-r--r--arch/mips/lib/board.c11
-rw-r--r--arch/nds32/include/asm/u-boot.h1
-rw-r--r--arch/nds32/lib/board.c9
-rw-r--r--arch/nios2/include/asm/u-boot.h1
-rw-r--r--arch/nios2/lib/board.c2
-rw-r--r--arch/openrisc/include/asm/u-boot.h1
-rw-r--r--arch/powerpc/include/asm/u-boot.h1
-rw-r--r--arch/powerpc/lib/board.c11
-rw-r--r--arch/sandbox/include/asm/u-boot.h1
-rw-r--r--arch/sandbox/lib/board.c3
-rw-r--r--arch/sh/include/asm/u-boot.h1
-rw-r--r--arch/sh/lib/board.c22
-rw-r--r--arch/sparc/include/asm/u-boot.h1
-rw-r--r--arch/sparc/lib/board.c7
-rw-r--r--arch/x86/include/asm/init_helpers.h2
-rw-r--r--arch/x86/include/asm/u-boot.h1
-rw-r--r--arch/x86/lib/board.c6
-rw-r--r--arch/x86/lib/init_helpers.c20
-rw-r--r--board/esd/cpci405/cpci405.c9
-rw-r--r--common/cmd_bdinfo.c28
-rw-r--r--common/cmd_nvedit.c16
-rw-r--r--common/main.c1
-rw-r--r--drivers/net/netconsole.c122
-rw-r--r--include/common.h4
-rw-r--r--include/net.h146
-rw-r--r--net/bootp.c344
-rw-r--r--net/bootp.h56
-rw-r--r--net/eth.c89
-rw-r--r--net/net.c58
-rw-r--r--net/nfs.c300
-rw-r--r--net/nfs.h2
-rw-r--r--net/rarp.c30
-rw-r--r--net/rarp.h4
-rw-r--r--net/sntp.c31
-rw-r--r--net/sntp.h2
-rw-r--r--net/tftp.c36
-rw-r--r--net/tftp.h2
48 files changed, 648 insertions, 786 deletions
diff --git a/arch/arm/include/asm/u-boot.h b/arch/arm/include/asm/u-boot.h
index 20e1653..eac3800 100644
--- a/arch/arm/include/asm/u-boot.h
+++ b/arch/arm/include/asm/u-boot.h
@@ -38,7 +38,6 @@
typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */
- unsigned long bi_ip_addr; /* IP Address */
ulong bi_arch_number; /* unique id for this board */
ulong bi_boot_params; /* where this board expects params */
unsigned long bi_arm_freq; /* arm frequency */
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 5270c11..024646c 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -555,9 +555,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
arm_pci_init();
#endif
- /* IP Address */
- gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
stdio_init(); /* get the devices list going. */
jumptable_init();
@@ -595,14 +592,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */
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
board_late_init();
diff --git a/arch/avr32/include/asm/u-boot.h b/arch/avr32/include/asm/u-boot.h
index ff1ed23..1d2959a 100644
--- a/arch/avr32/include/asm/u-boot.h
+++ b/arch/avr32/include/asm/u-boot.h
@@ -24,7 +24,6 @@
typedef struct bd_info {
unsigned long bi_baudrate;
- unsigned long bi_ip_addr;
unsigned char bi_phy_id[4];
unsigned long bi_board_number;
void *bi_boot_params;
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index d626c29..b390a6c 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -316,8 +316,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
/* initialize environment */
env_relocate();
- bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-
stdio_init();
jumptable_init();
console_init_r();
@@ -329,9 +327,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
- s = getenv("bootfile");
- if (s)
- copy_filename(BootFile, s, sizeof(BootFile));
puts("Net: ");
eth_initialize(gd->bd);
#endif
diff --git a/arch/blackfin/include/asm/u-boot.h b/arch/blackfin/include/asm/u-boot.h
index 9712fc0..df81183 100644
--- a/arch/blackfin/include/asm/u-boot.h
+++ b/arch/blackfin/include/asm/u-boot.h
@@ -30,7 +30,6 @@
typedef struct bd_info {
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_memstart; /* start of DRAM memory */
phys_size_t bi_memsize; /* size of DRAM memory in bytes */
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 2d424a2..c380d27 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -86,7 +86,6 @@ static void display_global_data(void)
printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
printf(" \\-bd: %p\n", gd->bd);
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_memstart: %lx\n", bd->bi_memstart);
printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
@@ -320,15 +319,8 @@ static void board_net_init_r(bd_t *bd)
bb_miiphy_init();
#endif
#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: ");
- eth_initialize(gd->bd);
+ eth_initialize(bd);
#endif
}
diff --git a/arch/m68k/include/asm/u-boot.h b/arch/m68k/include/asm/u-boot.h
index 0a48bbd..973c9ee 100644
--- a/arch/m68k/include/asm/u-boot.h
+++ b/arch/m68k/include/asm/u-boot.h
@@ -47,7 +47,6 @@ typedef struct bd_info {
unsigned long bi_mbar_base; /* base of internal registers */
unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
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 long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 1526967..65a8595 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -507,15 +507,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* relocate environment function pointers etc. */
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 ();
#if defined(CONFIG_PCI)
@@ -568,11 +559,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* Initialize from environment */
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 ();
diff --git a/arch/microblaze/include/asm/u-boot.h b/arch/microblaze/include/asm/u-boot.h
index 21c72d5..a0b1dbf 100644
--- a/arch/microblaze/include/asm/u-boot.h
+++ b/arch/microblaze/include/asm/u-boot.h
@@ -40,7 +40,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */
- unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_baudrate; /* Console Baudrate */
} bd_t;
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index 9828b76..f3679d5 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -176,19 +176,12 @@ void board_init (void)
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
- /* IP Address */
- bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
printf("Net: ");
eth_initialize(gd->bd);
uchar enetaddr[6];
eth_getenv_enetaddr("ethaddr", enetaddr);
printf("MAC: %pM\n", enetaddr);
-
- s = getenv("bootfile");
- if (s != NULL)
- copy_filename(BootFile, s, sizeof(BootFile));
#endif
/* main_loop */
diff --git a/arch/mips/include/asm/u-boot.h b/arch/mips/include/asm/u-boot.h
index edb87bb..590649a 100644
--- a/arch/mips/include/asm/u-boot.h
+++ b/arch/mips/include/asm/u-boot.h
@@ -33,7 +33,6 @@
typedef struct bd_info {
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_boot_params; /* where this board expects params */
unsigned long bi_memstart; /* start of DRAM memory */
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index 38e6e77..59a8001 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -320,9 +320,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* relocate environment function pointers etc. */
env_relocate();
- /* IP Address */
- bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
#if defined(CONFIG_PCI)
/*
* Do pci configuration
@@ -342,14 +339,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */
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
puts("SPI: ");
diff --git a/arch/nds32/include/asm/u-boot.h b/arch/nds32/include/asm/u-boot.h
index 9a69750..eabbf38 100644
--- a/arch/nds32/include/asm/u-boot.h
+++ b/arch/nds32/include/asm/u-boot.h
@@ -40,7 +40,6 @@
typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */
- unsigned long bi_ip_addr; /* IP Address */
unsigned char bi_enetaddr[6]; /* Ethernet adress */
unsigned long bi_arch_number; /* unique id for this board */
unsigned long bi_boot_params; /* where this board expects params */
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index 074aabf..7121313 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -369,9 +369,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
nds32_pci_init();
#endif
- /* IP Address */
- gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
stdio_init(); /* get the devices list going. */
jumptable_init();
@@ -402,12 +399,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */
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
board_late_init();
#endif
diff --git a/arch/nios2/include/asm/u-boot.h b/arch/nios2/include/asm/u-boot.h
index f7c70ff..315ef8b 100644
--- a/arch/nios2/include/asm/u-boot.h
+++ b/arch/nios2/include/asm/u-boot.h
@@ -39,7 +39,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */
- unsigned long bi_ip_addr; /* IP Address */
unsigned long bi_baudrate; /* Console Baudrate */
} bd_t;
diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 65de26e..ca8a3e5 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -143,8 +143,6 @@ void board_init (void)
WATCHDOG_RESET ();
env_relocate();
- bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-
WATCHDOG_RESET ();
stdio_init();
jumptable_init();
diff --git a/arch/openrisc/include/asm/u-boot.h b/arch/openrisc/include/asm/u-boot.h
index 2913994..76b8132 100644
--- a/arch/openrisc/include/asm/u-boot.h
+++ b/arch/openrisc/include/asm/u-boot.h
@@ -33,7 +33,6 @@
typedef struct bd_info {
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_boot_params; /* where this board expects params */
unsigned long bi_memstart; /* start of DRAM memory */
diff --git a/arch/powerpc/include/asm/u-boot.h b/arch/powerpc/include/asm/u-boot.h
index b2fa2b5..1552054 100644
--- a/arch/powerpc/include/asm/u-boot.h
+++ b/arch/powerpc/include/asm/u-boot.h
@@ -63,7 +63,6 @@ typedef struct bd_info {
unsigned long bi_vcofreq; /* VCO Freq, in MHz */
#endif
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 short bi_ethspeed; /* Ethernet speed in Mbps */
unsigned long bi_intfreq; /* Internal Freq, in MHz */
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index d5b75e5..fea310e 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -877,9 +877,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
#endif
#endif /* CONFIG_CMD_NET */
- /* IP Address */
- bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
WATCHDOG_RESET();
#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 */
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();
diff --git a/arch/sandbox/include/asm/u-boot.h b/arch/sandbox/include/asm/u-boot.h
index 166ef14..de8120a 100644
--- a/arch/sandbox/include/asm/u-boot.h
+++ b/arch/sandbox/include/asm/u-boot.h
@@ -45,7 +45,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */
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 long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 306d1ec..c173bf9 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -235,9 +235,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* initialize environment */
env_relocate();
- /* IP Address */
- gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
stdio_init(); /* get the devices list going. */
jumptable_init();
diff --git a/arch/sh/include/asm/u-boot.h b/arch/sh/include/asm/u-boot.h
index 4574512..6c04daf 100644
--- a/arch/sh/include/asm/u-boot.h
+++ b/arch/sh/include/asm/u-boot.h
@@ -33,7 +33,6 @@ typedef struct bd_info {
unsigned long bi_flashoffset; /* reserved area for startup monitor */
unsigned long bi_sramstart; /* start 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_boot_params; /* where this board expects params */
} bd_t;
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index eb021e8..34d7881 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -100,14 +100,6 @@ static int sh_mem_env_init(void)
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)
static int sh_mmc_init(void)
{
@@ -145,9 +137,6 @@ init_fnc_t *init_sequence[] =
#ifdef CONFIG_BOARD_LATE_INIT
board_late_init,
#endif
-#if defined(CONFIG_CMD_NET)
- sh_net_init, /* SH specific eth init */
-#endif
#if defined(CONFIG_CMD_MMC)
sh_mmc_init,
#endif
@@ -201,15 +190,8 @@ void sh_generic_init(void)
bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
- {
- char *s;
- puts("Net: ");
- eth_initialize(gd->bd);
-
- s = getenv("bootfile");
- if (s != NULL)
- copy_filename(BootFile, s, sizeof(BootFile));
- }
+ puts("Net: ");
+ eth_initialize(gd->bd);
#endif /* CONFIG_CMD_NET */
while (1) {
diff --git a/arch/sparc/include/asm/u-boot.h b/arch/sparc/include/asm/u-boot.h
index 1d94087..8d01118 100644
--- a/arch/sparc/include/asm/u-boot.h
+++ b/arch/sparc/include/asm/u-boot.h
@@ -51,7 +51,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */
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 long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index c0d2608..7e48775 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -333,8 +333,6 @@ void board_init_f(ulong bootflag)
mac_read_from_eeprom();
#endif
- /* IP Address */
- bd->bi_ip_addr = getenv_IPaddr("ipaddr");
#if defined(CONFIG_PCI)
/*
* Do pci configuration
@@ -359,11 +357,6 @@ void board_init_f(ulong bootflag)
/* Initialize from environment */
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();
diff --git a/arch/x86/include/asm/init_helpers.h b/arch/x86/include/asm/init_helpers.h
index 192f18e..8afb443 100644
--- a/arch/x86/include/asm/init_helpers.h
+++ b/arch/x86/include/asm/init_helpers.h
@@ -36,9 +36,7 @@ int set_reloc_flag_r(void);
int mem_malloc_init_r(void);
int init_bd_struct_r(void);
int flash_init_r(void);
-int init_ip_address_r(void);
int status_led_set_r(void);
-int set_bootfile_r(void);
int set_load_addr_r(void);
#endif /* !_INIT_HELPERS_H_ */
diff --git a/arch/x86/include/asm/u-boot.h b/arch/x86/include/asm/u-boot.h
index 26450eb..da667c5 100644
--- a/arch/x86/include/asm/u-boot.h
+++ b/arch/x86/include/asm/u-boot.h
@@ -45,7 +45,6 @@ typedef struct bd_info {
unsigned long bi_sramstart; /* start of SRAM memory */
unsigned long bi_sramsize; /* size of SRAM memory */
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 long bi_intfreq; /* Internal Freq, in MHz */
unsigned long bi_busfreq; /* Bus Freq, in MHz */
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index 5f0b62c..90cf7fc 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -157,9 +157,6 @@ init_fnc_t *init_sequence_r[] = {
flash_init_r,
#endif
env_relocate_r,
-#ifdef CONFIG_CMD_NET
- init_ip_address_r,
-#endif
#ifdef CONFIG_PCI
pci_init_r,
#endif
@@ -180,9 +177,6 @@ init_fnc_t *init_sequence_r[] = {
status_led_set_r,
#endif
set_load_addr_r,
-#if defined(CONFIG_CMD_NET)
- set_bootfile_r,
-#endif
#if defined(CONFIG_CMD_IDE)
ide_init_r,
#endif
diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c
index 9f4dee0..9ec34ff 100644
--- a/arch/x86/lib/init_helpers.c
+++ b/arch/x86/lib/init_helpers.c
@@ -179,14 +179,6 @@ int flash_init_r(void)
}
#endif
-int init_ip_address_r(void)
-{
- /* IP Address */
- bd_data.bi_ip_addr = getenv_IPaddr("ipaddr");
-
- return 0;
-}
-
#ifdef CONFIG_STATUS_LED
int status_led_set_r(void)
{
@@ -196,18 +188,6 @@ int status_led_set_r(void)
}
#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)
{
/* Initialize from environment */
diff --git a/board/esd/cpci405/cpci405.c b/board/esd/cpci405/cpci405.c
index 41b5ba0..1441b10 100644
--- a/board/esd/cpci405/cpci405.c
+++ b/board/esd/cpci405/cpci405.c
@@ -730,12 +730,11 @@ int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/*
* Update whole ip-addr
*/
- bd->bi_ip_addr = ipaddr;
sprintf(str, "%ld.%ld.%ld.%ld",
- (bd->bi_ip_addr & 0xff000000) >> 24,
- (bd->bi_ip_addr & 0x00ff0000) >> 16,
- (bd->bi_ip_addr & 0x0000ff00) >> 8,
- (bd->bi_ip_addr & 0x000000ff));
+ (ipaddr & 0xff000000) >> 24,
+ (ipaddr & 0x00ff0000) >> 16,
+ (ipaddr & 0x0000ff00) >> 8,
+ (ipaddr & 0x000000ff));
setenv("ipaddr", str);
printf("Updated ip_addr from bp_eeprom to %s!\n", str);
}
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index 3ab285b..42f08fd 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -147,7 +147,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_HERMES
print_mhz("ethspeed", bd->bi_ethspeed);
#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);
print_num("relocaddr", gd->relocaddr);
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
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
#if defined(CONFIG_CMD_NET)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
printf("baudrate = %6ld bps\n", bd->bi_baudrate);
return 0;
@@ -275,7 +275,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_eth(3);
#endif
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
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_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);
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_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);
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_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);
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
printf("baudrate = %d bps\n", bd->bi_baudrate);
#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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
printf("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
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)
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);
#endif
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
print_num("FB base ", gd->fb_base);
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
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)
print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("ip_addr = %s\n", getenv("ipaddr"));
#endif
printf("baudrate = %ld bps\n", bd->bi_baudrate);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e1ccdd8..5999cb8 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -343,21 +343,7 @@ int _do_env_set(int flag, int argc, char * const argv[])
* Some variables should be updated when the corresponding
* entry in the environment is changed
*/
- if (strcmp(name, "ipaddr") == 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) {
+ if (strcmp(argv[1], "loadaddr") == 0) {
load_addr = simple_strtoul(argv[2], NULL, 16);
return 0;
}
diff --git a/common/main.c b/common/main.c
index 3b9e39a..a933357 100644
--- a/common/main.c
+++ b/common/main.c
@@ -973,7 +973,6 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout)
#ifdef CONFIG_SHOW_ACTIVITY
while (!tstc()) {
- extern void show_activity(int arg);
show_activity(0);
WATCHDOG_RESET();
}
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 56ba64f..7acd5b0 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -29,81 +29,82 @@
DECLARE_GLOBAL_DATA_PTR;
static char input_buffer[512];
-static int input_size = 0; /* char count in input buffer */
-static int input_offset = 0; /* offset to valid chars in input buffer */
-static int input_recursion = 0;
-static int output_recursion = 0;
+static int input_size; /* char count in input buffer */
+static int input_offset; /* offset to valid chars in input buffer */
+static int input_recursion;
+static int output_recursion;
static int net_timeout;
-static uchar nc_ether[6]; /* server enet address */
-static IPaddr_t nc_ip; /* server ip */
-static short nc_port; /* source/target port */
-static const char *output_packet; /* used by first send udp */
-static int output_packet_len = 0;
+static uchar nc_ether[6]; /* server enet address */
+static IPaddr_t nc_ip; /* server ip */
+static short nc_port; /* source/target port */
+static const char *output_packet; /* used by first send udp */
+static int output_packet_len;
static void nc_wait_arp_handler(uchar *pkt, unsigned dest,
IPaddr_t sip, unsigned src,
unsigned len)
{
- NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */
+ NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */
}
static void nc_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len)
{
if (input_size)
- NetState = NETLOOP_SUCCESS; /* got input - quit net loop */
+ NetState = NETLOOP_SUCCESS; /* got input - quit net loop */
}
-static void nc_timeout (void)
+static void nc_timeout(void)
{
NetState = NETLOOP_SUCCESS;
}
-void NcStart (void)
+void NcStart(void)
{
- if (!output_packet_len || memcmp (nc_ether, NetEtherNullAddr, 6)) {
+ if (!output_packet_len || memcmp(nc_ether, NetEtherNullAddr, 6)) {
/* going to check for input packet */
- NetSetHandler (nc_handler);
- NetSetTimeout (net_timeout, nc_timeout);
+ NetSetHandler(nc_handler);
+ NetSetTimeout(net_timeout, nc_timeout);
} else {
/* send arp request */
uchar *pkt;
- NetSetHandler (nc_wait_arp_handler);
- pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE;
- memcpy (pkt, output_packet, output_packet_len);
- NetSendUDPPacket (nc_ether, nc_ip, nc_port, nc_port, output_packet_len);
+ NetSetHandler(nc_wait_arp_handler);
+ pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
+ memcpy(pkt, output_packet, output_packet_len);
+ NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
+ output_packet_len);
}
}
-int nc_input_packet (uchar * pkt, unsigned dest, unsigned src, unsigned len)
+int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)
{
int end, chunk;
if (dest != nc_port || !len)
- return 0; /* not for us */
+ return 0; /* not for us */
- if (input_size == sizeof input_buffer)
- return 1; /* no space */
- if (len > sizeof input_buffer - input_size)
- len = sizeof input_buffer - input_size;
+ if (input_size == sizeof(input_buffer))
+ return 1; /* no space */
+ if (len > sizeof(input_buffer) - input_size)
+ len = sizeof(input_buffer) - input_size;
end = input_offset + input_size;
- if (end > sizeof input_buffer)
- end -= sizeof input_buffer;
+ if (end > sizeof(input_buffer))
+ end -= sizeof(input_buffer);
chunk = len;
- if (end + len > sizeof input_buffer) {
- chunk = sizeof input_buffer - end;
+ if (end + len > sizeof(input_buffer)) {
+ chunk = sizeof(input_buffer) - end;
memcpy(input_buffer, pkt + chunk, len - chunk);
}
- memcpy (input_buffer + end, pkt, chunk);
+ memcpy(input_buffer + end, pkt, chunk);
input_size += len;
return 1;
}
-static void nc_send_packet (const char *buf, int len)
+static void nc_send_packet(const char *buf, int len)
{
struct eth_device *eth;
int inited = 0;
@@ -111,33 +112,33 @@ static void nc_send_packet (const char *buf, int len)
uchar *ether;
IPaddr_t ip;
- if ((eth = eth_get_dev ()) == NULL) {
+ eth = eth_get_dev();
+ if (eth == NULL)
return;
- }
- if (!memcmp (nc_ether, NetEtherNullAddr, 6)) {
+ if (!memcmp(nc_ether, NetEtherNullAddr, 6)) {
if (eth->state == ETH_STATE_ACTIVE)
return; /* inside net loop */
output_packet = buf;
output_packet_len = len;
- NetLoop (NETCONS); /* wait for arp reply and send packet */
+ NetLoop(NETCONS); /* wait for arp reply and send packet */
output_packet_len = 0;
return;
}
if (eth->state != ETH_STATE_ACTIVE) {
- if (eth_init (gd->bd) < 0)
+ if (eth_init(gd->bd) < 0)
return;
inited = 1;
}
- pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE;
- memcpy (pkt, buf, len);
+ pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
+ memcpy(pkt, buf, len);
ether = nc_ether;
ip = nc_ip;
- NetSendUDPPacket (ether, ip, nc_port, nc_port, len);
+ NetSendUDPPacket(ether, ip, nc_port, nc_port, len);
if (inited)
- eth_halt ();
+ eth_halt();
}
static int nc_start(void)
@@ -146,26 +147,27 @@ static int nc_start(void)
nc_port = 6666; /* default port */
- if (getenv ("ncip")) {
+ if (getenv("ncip")) {
char *p;
- nc_ip = getenv_IPaddr ("ncip");
+ nc_ip = getenv_IPaddr("ncip");
if (!nc_ip)
return -1; /* ncip is 0.0.0.0 */
- if ((p = strchr (getenv ("ncip"), ':')) != NULL)
- nc_port = simple_strtoul (p + 1, NULL, 10);
+ p = strchr(getenv("ncip"), ':');
+ if (p != NULL)
+ nc_port = simple_strtoul(p + 1, NULL, 10);
} else
nc_ip = ~0; /* ncip is not set */
- our_ip = getenv_IPaddr ("ipaddr");
- netmask = getenv_IPaddr ("netmask");
+ our_ip = getenv_IPaddr("ipaddr");
+ netmask = getenv_IPaddr("netmask");
if (nc_ip == ~0 || /* 255.255.255.255 */
((netmask & our_ip) == (netmask & nc_ip) && /* on the same net */
- (netmask | nc_ip) == ~0)) /* broadcast to our net */
- memset (nc_ether, 0xff, sizeof nc_ether);
+ (netmask | nc_ip) == ~0)) /* broadcast to our net */
+ memset(nc_ether, 0xff, sizeof(nc_ether));
else
- memset (nc_ether, 0, sizeof nc_ether); /* force arp request */
+ memset(nc_ether, 0, sizeof(nc_ether)); /* force arp request */
return 0;
}
@@ -176,7 +178,7 @@ static void nc_putc(char c)
return;
output_recursion = 1;
- nc_send_packet (&c, 1);
+ nc_send_packet(&c, 1);
output_recursion = 0;
}
@@ -208,14 +210,14 @@ static int nc_getc(void)
net_timeout = 0; /* no timeout */
while (!input_size)
- NetLoop (NETCONS);
+ NetLoop(NETCONS);
input_recursion = 0;
c = input_buffer[input_offset++];
- if (input_offset >= sizeof input_buffer)
- input_offset -= sizeof input_buffer;
+ if (input_offset >= sizeof(input_buffer))
+ input_offset -= sizeof(input_buffer);
input_size--;
return c;
@@ -231,28 +233,28 @@ static int nc_tstc(void)
if (input_size)
return 1;
- eth = eth_get_dev ();
+ eth = eth_get_dev();
if (eth && eth->state == ETH_STATE_ACTIVE)
return 0; /* inside net loop */
input_recursion = 1;
net_timeout = 1;
- NetLoop (NETCONS); /* kind of poll */
+ NetLoop(NETCONS); /* kind of poll */
input_recursion = 0;
return input_size != 0;
}
-int drv_nc_init (void)
+int drv_nc_init(void)
{
struct stdio_dev dev;
int rc;
- memset (&dev, 0, sizeof (dev));
+ memset(&dev, 0, sizeof(dev));
- strcpy (dev.name, "nc");
+ strcpy(dev.name, "nc");
dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
dev.start = nc_start;
dev.putc = nc_putc;
@@ -260,7 +262,7 @@ int drv_nc_init (void)
dev.getc = nc_getc;
dev.tstc = nc_tstc;
- rc = stdio_register (&dev);
+ rc = stdio_register(&dev);
return (rc == 0) ? 1 : rc;
}
diff --git a/include/common.h b/include/common.h
index ff7126d..eb9de18 100644
--- a/include/common.h
+++ b/include/common.h
@@ -819,6 +819,10 @@ int pcmcia_init (void);
#include <bootstage.h>
+#ifdef CONFIG_SHOW_ACTIVITY
+void show_activity(int arg);
+#endif
+
/* Multicore arch functions */
#ifdef CONFIG_MP
int cpu_status(int nr);
diff --git a/include/net.h b/include/net.h
index ee11f82..92afc19 100644
--- a/include/net.h
+++ b/include/net.h
@@ -80,14 +80,14 @@ struct eth_device {
int iobase;
int state;
- int (*init) (struct eth_device*, bd_t*);
- int (*send) (struct eth_device*, volatile void* packet, int length);
- int (*recv) (struct eth_device*);
- void (*halt) (struct eth_device*);
+ int (*init) (struct eth_device *, bd_t *);
+ int (*send) (struct eth_device *, void *packet, int length);
+ int (*recv) (struct eth_device *);
+ void (*halt) (struct eth_device *);
#ifdef CONFIG_MCAST_TFTP
- int (*mcast) (struct eth_device*, u32 ip, u8 set);
+ int (*mcast) (struct eth_device *, u32 ip, u8 set);
#endif
- int (*write_hwaddr) (struct eth_device*);
+ int (*write_hwaddr) (struct eth_device *);
struct eth_device *next;
int index;
void *priv;
@@ -101,7 +101,7 @@ extern void eth_set_current(void); /* set nterface to ethcur var */
extern struct eth_device *eth_get_dev(void); /* get the current device MAC */
extern struct eth_device *eth_get_dev_by_name(const char *devname);
extern struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */
-extern int eth_get_dev_index (void); /* get the device index */
+extern int eth_get_dev_index(void); /* get the device index */
extern void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
extern int eth_getenv_enetaddr(char *name, uchar *enetaddr);
extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
@@ -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 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
-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
extern int eth_rx(void); /* Check for received packets */
extern void eth_halt(void); /* stop SCC */
@@ -142,8 +143,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
int eth_number);
#ifdef CONFIG_MCAST_TFTP
-int eth_mcast_join( IPaddr_t mcast_addr, u8 join);
-u32 ether_crc (size_t len, unsigned char const *p);
+int eth_mcast_join(IPaddr_t mcast_addr, u8 join);
+u32 ether_crc(size_t len, unsigned char const *p);
#endif
@@ -218,8 +219,8 @@ typedef struct {
#define IP_FLAGS_DFRAG 0x4000 /* don't fragments */
#define IP_FLAGS_MFRAG 0x2000 /* more fragments */
-#define IP_HDR_SIZE_NO_UDP (sizeof (IP_t) - 8)
-#define IP_HDR_SIZE (sizeof (IP_t))
+#define IP_HDR_SIZE_NO_UDP (sizeof(IP_t) - 8)
+#define IP_HDR_SIZE (sizeof(IP_t))
/*
@@ -326,46 +327,46 @@ typedef struct icmphdr {
/* net.c */
/** BOOTP EXTENTIONS **/
-extern IPaddr_t NetOurGatewayIP; /* Our gateway IP addresse */
-extern IPaddr_t NetOurSubnetMask; /* Our subnet mask (0 = unknown)*/
-extern IPaddr_t NetOurDNSIP; /* Our Domain Name Server (0 = unknown)*/
+extern IPaddr_t NetOurGatewayIP; /* Our gateway IP address */
+extern IPaddr_t NetOurSubnetMask; /* Our subnet mask (0 = unknown) */
+extern IPaddr_t NetOurDNSIP; /* Our Domain Name Server (0 = unknown) */
#if defined(CONFIG_BOOTP_DNS2)
-extern IPaddr_t NetOurDNS2IP; /* Our 2nd Domain Name Server (0 = unknown)*/
+extern IPaddr_t NetOurDNS2IP; /* Our 2nd Domain Name Server (0 = unknown) */
#endif
-extern char NetOurNISDomain[32]; /* Our NIS domain */
-extern char NetOurHostName[32]; /* Our hostname */
-extern char NetOurRootPath[64]; /* Our root path */
-extern ushort NetBootFileSize; /* Our boot file size in blocks */
+extern char NetOurNISDomain[32]; /* Our NIS domain */
+extern char NetOurHostName[32]; /* Our hostname */
+extern char NetOurRootPath[64]; /* Our root path */
+extern ushort NetBootFileSize; /* Our boot file size in blocks */
/** END OF BOOTP EXTENTIONS **/
-extern ulong NetBootFileXferSize; /* size of bootfile in bytes */
-extern uchar NetOurEther[6]; /* Our ethernet address */
-extern uchar NetServerEther[6]; /* Boot server enet address */
-extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
-extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
-extern volatile uchar * NetTxPacket; /* THE transmit packet */
-extern volatile uchar * NetRxPackets[PKTBUFSRX];/* Receive packets */
-extern volatile uchar * NetRxPacket; /* Current receive packet */
-extern int NetRxPacketLen; /* Current rx packet length */
-extern unsigned NetIPID; /* IP ID (counting) */
-extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */
+extern ulong NetBootFileXferSize; /* size of bootfile in bytes */
+extern uchar NetOurEther[6]; /* Our ethernet address */
+extern uchar NetServerEther[6]; /* Boot server enet address */
+extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
+extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
+extern uchar *NetTxPacket; /* THE transmit packet */
+extern uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
+extern uchar *NetRxPacket; /* Current receive packet */
+extern int NetRxPacketLen; /* Current rx packet length */
+extern unsigned NetIPID; /* IP ID (counting) */
+extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */
extern uchar NetEtherNullAddr[6];
-#define VLAN_NONE 4095 /* untagged */
-#define VLAN_IDMASK 0x0fff /* mask of valid vlan id */
-extern ushort NetOurVLAN; /* Our VLAN */
-extern ushort NetOurNativeVLAN; /* Our Native VLAN */
+#define VLAN_NONE 4095 /* untagged */
+#define VLAN_IDMASK 0x0fff /* mask of valid vlan id */
+extern ushort NetOurVLAN; /* Our VLAN */
+extern ushort NetOurNativeVLAN; /* Our Native VLAN */
-extern uchar NetCDPAddr[6]; /* Ethernet CDP address */
-extern ushort CDPNativeVLAN; /* CDP returned native VLAN */
-extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */
+extern uchar NetCDPAddr[6]; /* Ethernet CDP address */
+extern ushort CDPNativeVLAN; /* CDP returned native VLAN */
+extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */
-extern int NetState; /* Network loop state */
+extern int NetState; /* Network loop state */
#define NETLOOP_CONTINUE 1
#define NETLOOP_RESTART 2
#define NETLOOP_SUCCESS 3
#define NETLOOP_FAIL 4
-extern int NetRestartWrap; /* Tried all network devices */
+extern int NetRestartWrap; /* Tried all network devices */
enum proto_t {
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
@@ -373,7 +374,7 @@ enum proto_t {
};
/* from net/net.c */
-extern char BootFile[128]; /* Boot File name */
+extern char BootFile[128]; /* Boot File name */
#if defined(CONFIG_CMD_DNS)
extern char *NetDNSResolve; /* The host to resolve */
@@ -381,7 +382,7 @@ extern char *NetDNSenvvar; /* the env var to put the ip into */
#endif
#if defined(CONFIG_CMD_PING)
-extern IPaddr_t NetPingIP; /* the ip address to ping */
+extern IPaddr_t NetPingIP; /* the ip address to ping */
#endif
#if defined(CONFIG_CMD_CDP)
@@ -391,8 +392,12 @@ extern ushort CDPApplianceVLAN;
#endif
#if defined(CONFIG_CMD_SNTP)
-extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */
-extern int NetTimeOffset; /* offset time from UTC */
+extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */
+extern int NetTimeOffset; /* offset time from UTC */
+#endif
+
+#if defined(CONFIG_MCAST_TFTP)
+extern IPaddr_t Mcast_addr;
#endif
/* Initialize the network adapter */
@@ -408,28 +413,34 @@ extern void NetStartAgain(void);
extern int NetEthHdrSize(void);
/* 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 */
-extern void NetSetIP(volatile uchar *, IPaddr_t, int, int, int);
+extern void NetSetIP(uchar *, IPaddr_t, int, int, int);
/* Checksum */
-extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */
-extern uint NetCksum(uchar *, int); /* Calculate the checksum */
+extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */
+extern uint NetCksum(uchar *, int); /* Calculate the checksum */
/* Set callbacks */
-extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
+extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
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" */
-extern void NetSendPacket(volatile uchar *, int);
+extern void NetSendPacket(uchar *, int);
/* 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 */
-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
@@ -445,10 +456,11 @@ void net_auto_load(void);
* footprint in our tests.
*/
/* return IP *in network byteorder* */
-static inline IPaddr_t NetReadIP(volatile void *from)
+static inline IPaddr_t NetReadIP(void *from)
{
IPaddr_t ip;
- memcpy((void*)&ip, (void*)from, sizeof(ip));
+
+ memcpy((void *)&ip, (void *)from, sizeof(ip));
return ip;
}
@@ -456,26 +468,27 @@ static inline IPaddr_t NetReadIP(volatile void *from)
static inline ulong NetReadLong(ulong *from)
{
ulong l;
- memcpy((void*)&l, (void*)from, sizeof(l));
+
+ memcpy((void *)&l, (void *)from, sizeof(l));
return l;
}
/* write IP *in network byteorder* */
static inline void NetWriteIP(void *to, IPaddr_t ip)
{
- memcpy(to, (void*)&ip, sizeof(ip));
+ memcpy(to, (void *)&ip, sizeof(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));
}
/* copy ulong */
static inline void NetCopyLong(ulong *to, ulong *from)
{
- memcpy((void*)to, (void*)from, sizeof(ulong));
+ memcpy((void *)to, (void *)from, sizeof(ulong));
}
/**
@@ -498,7 +511,7 @@ static inline int is_zero_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)
{
- 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;
}
/*
@@ -529,13 +543,13 @@ static inline int is_valid_ether_addr(const u8 *addr)
}
/* Convert an IP address to a string */
-extern void ip_to_string (IPaddr_t x, char *s);
+extern void ip_to_string(IPaddr_t x, char *s);
/* Convert a string to ip address */
extern IPaddr_t string_to_ip(const char *s);
/* Convert a VLAN id to a string */
-extern void VLAN_to_string (ushort x, char *s);
+extern void VLAN_to_string(ushort x, char *s);
/* Convert a string to a vlan id */
extern ushort string_to_VLAN(const char *s);
@@ -544,7 +558,7 @@ extern ushort string_to_VLAN(const char *s);
extern ushort getenv_VLAN(char *);
/* copy a filename (allow for "..." notation, limit length) */
-extern void copy_filename (char *dst, const char *src, int size);
+extern void copy_filename(char *dst, const char *src, int size);
/* get a random source port */
extern unsigned int random_port(void);
diff --git a/net/bootp.c b/net/bootp.c
index 9e32476..d0a7da2 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -19,19 +19,19 @@
#endif
#include <linux/compiler.h>
-#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
+#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
#define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */
#ifndef CONFIG_NET_RETRY_COUNT
-# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
+# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
#else
# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
#endif
-#define PORT_BOOTPS 67 /* BOOTP server UDP port */
-#define PORT_BOOTPC 68 /* BOOTP client UDP port */
+#define PORT_BOOTPS 67 /* BOOTP server UDP port */
+#define PORT_BOOTPC 68 /* BOOTP client UDP port */
-#ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
+#ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
#define CONFIG_DHCP_MIN_EXT_LEN 64
#endif
@@ -43,8 +43,8 @@ ulong seed1, seed2;
#if defined(CONFIG_CMD_DHCP)
dhcp_state_t dhcp_state = INIT;
-unsigned long dhcp_leasetime = 0;
-IPaddr_t NetDHCPServerIP = 0;
+unsigned long dhcp_leasetime;
+IPaddr_t NetDHCPServerIP;
static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len);
@@ -64,37 +64,29 @@ static char *dhcpmsg2str(int type)
}
}
#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
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;
if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
retval = -1;
- else if (len < sizeof (Bootp_t) - OPT_SIZE)
+ else if (len < sizeof(struct Bootp_t) - OPT_SIZE)
retval = -2;
else if (bp->bp_op != OP_BOOTREQUEST &&
- bp->bp_op != OP_BOOTREPLY &&
- bp->bp_op != DHCP_OFFER &&
- bp->bp_op != DHCP_ACK &&
- bp->bp_op != DHCP_NAK ) {
+ bp->bp_op != OP_BOOTREPLY &&
+ bp->bp_op != DHCP_OFFER &&
+ bp->bp_op != DHCP_ACK &&
+ bp->bp_op != DHCP_NAK)
retval = -3;
- }
else if (bp->bp_htype != HWT_ETHER)
retval = -4;
else if (bp->bp_hlen != HWL_ETHER)
retval = -5;
- else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) {
+ else if (NetReadLong((ulong *)&bp->bp_id) != BootpID)
retval = -6;
- }
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
*/
-static void BootpCopyNetParams(Bootp_t *bp)
+static void BootpCopyNetParams(struct Bootp_t *bp)
{
__maybe_unused IPaddr_t tmp_ip;
@@ -113,10 +105,10 @@ static void BootpCopyNetParams(Bootp_t *bp)
NetCopyIP(&tmp_ip, &bp->bp_siaddr);
if (tmp_ip != 0)
NetCopyIP(&NetServerIP, &bp->bp_siaddr);
- memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
+ memcpy(NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
#endif
if (strlen(bp->bp_file) > 0)
- copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
+ copy_filename(BootFile, bp->bp_file, sizeof(BootFile));
debug("Bootfile: %s\n", BootFile);
@@ -124,97 +116,95 @@ static void BootpCopyNetParams(Bootp_t *bp)
* don't delete exising entry when BOOTP / DHCP reply does
* not contain a new value
*/
- if (*BootFile) {
- setenv ("bootfile", BootFile);
- }
+ if (*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) {
- printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n",
- name, curlen, maxlen);
+ printf("*** WARNING: %s is too long (%d - max: %d)"
+ " - truncated\n", name, curlen, maxlen);
curlen = maxlen - 1;
}
- return (curlen);
+ return curlen;
}
#if !defined(CONFIG_CMD_DHCP)
-static void BootpVendorFieldProcess (u8 * ext)
+static void BootpVendorFieldProcess(u8 *ext)
{
int size = *(ext + 1);
debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
- *(ext + 1));
+ *(ext + 1));
NetBootFileSize = 0;
switch (*ext) {
/* Fixed length fields */
- case 1: /* Subnet mask */
+ case 1: /* Subnet mask */
if (NetOurSubnetMask == 0)
- NetCopyIP (&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
+ NetCopyIP(&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
break;
- case 2: /* Time offset - Not yet supported */
+ case 2: /* Time offset - Not yet supported */
break;
/* Variable length fields */
- case 3: /* Gateways list */
- if (NetOurGatewayIP == 0) {
- NetCopyIP (&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
- }
+ case 3: /* Gateways list */
+ if (NetOurGatewayIP == 0)
+ NetCopyIP(&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
break;
- case 4: /* Time server - Not yet supported */
+ case 4: /* Time server - Not yet supported */
break;
- case 5: /* IEN-116 name server - Not yet supported */
+ case 5: /* IEN-116 name server - Not yet supported */
break;
case 6:
- if (NetOurDNSIP == 0) {
- NetCopyIP (&NetOurDNSIP, (IPaddr_t *) (ext + 2));
- }
+ if (NetOurDNSIP == 0)
+ NetCopyIP(&NetOurDNSIP, (IPaddr_t *) (ext + 2));
#if defined(CONFIG_BOOTP_DNS2)
- if ((NetOurDNS2IP == 0) && (size > 4)) {
- NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
- }
+ if ((NetOurDNS2IP == 0) && (size > 4))
+ NetCopyIP(&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
#endif
break;
- case 7: /* Log server - Not yet supported */
+ case 7: /* Log server - Not yet supported */
break;
- case 8: /* Cookie/Quote server - Not yet supported */
+ case 8: /* Cookie/Quote server - Not yet supported */
break;
- case 9: /* LPR server - Not yet supported */
+ case 9: /* LPR server - Not yet supported */
break;
- case 10: /* Impress server - Not yet supported */
+ case 10: /* Impress server - Not yet supported */
break;
- case 11: /* RPL server - Not yet supported */
+ case 11: /* RPL server - Not yet supported */
break;
- case 12: /* Host name */
+ case 12: /* Host name */
if (NetOurHostName[0] == 0) {
- size = truncate_sz ("Host Name", sizeof (NetOurHostName), size);
- memcpy (&NetOurHostName, ext + 2, size);
+ size = truncate_sz("Host Name",
+ sizeof(NetOurHostName), size);
+ memcpy(&NetOurHostName, ext + 2, size);
NetOurHostName[size] = 0;
}
break;
- case 13: /* Boot file size */
+ case 13: /* Boot file size */
if (size == 2)
- NetBootFileSize = ntohs (*(ushort *) (ext + 2));
+ NetBootFileSize = ntohs(*(ushort *) (ext + 2));
else if (size == 4)
- NetBootFileSize = ntohl (*(ulong *) (ext + 2));
+ NetBootFileSize = ntohl(*(ulong *) (ext + 2));
break;
- case 14: /* Merit dump file - Not yet supported */
+ case 14: /* Merit dump file - Not yet supported */
break;
- case 15: /* Domain name - Not yet supported */
+ case 15: /* Domain name - Not yet supported */
break;
- case 16: /* Swap server - Not yet supported */
+ case 16: /* Swap server - Not yet supported */
break;
- case 17: /* Root path */
+ case 17: /* Root path */
if (NetOurRootPath[0] == 0) {
- size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size);
- memcpy (&NetOurRootPath, ext + 2, size);
+ size = truncate_sz("Root Path",
+ sizeof(NetOurRootPath), size);
+ memcpy(&NetOurRootPath, ext + 2, size);
NetOurRootPath[size] = 0;
}
break;
- case 18: /* Extension path - Not yet supported */
+ case 18: /* Extension path - Not yet supported */
/*
* This can be used to send the information of the
* vendor area in another file that the client can
@@ -222,10 +212,11 @@ static void BootpVendorFieldProcess (u8 * ext)
*/
break;
/* IP host layer fields */
- case 40: /* NIS Domain name */
+ case 40: /* NIS Domain name */
if (NetOurNISDomain[0] == 0) {
- size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size);
- memcpy (&NetOurNISDomain, ext + 2, size);
+ size = truncate_sz("NIS Domain Name",
+ sizeof(NetOurNISDomain), size);
+ memcpy(&NetOurNISDomain, ext + 2, size);
NetOurNISDomain[size] = 0;
}
break;
@@ -235,7 +226,7 @@ static void BootpVendorFieldProcess (u8 * ext)
break;
#endif
/* Application layer fields */
- case 43: /* Vendor specific info - Not yet supported */
+ case 43: /* Vendor specific info - Not yet supported */
/*
* Binary information to exchange specific
* product information.
@@ -245,7 +236,7 @@ static void BootpVendorFieldProcess (u8 * ext)
}
}
-static void BootpVendorProcess (u8 * ext, int size)
+static void BootpVendorProcess(u8 *ext, int size)
{
u8 *end = ext + size;
@@ -259,11 +250,11 @@ static void BootpVendorProcess (u8 * ext, int size)
ext += ext[1] + 2;
if (ext <= end)
- BootpVendorFieldProcess (opt);
+ BootpVendorFieldProcess(opt);
}
}
- debug("[BOOTP] Received fields: \n");
+ debug("[BOOTP] Received fields:\n");
if (NetOurSubnetMask)
debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
@@ -298,27 +289,28 @@ static void
BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
unsigned len)
{
- Bootp_t *bp;
+ struct Bootp_t *bp;
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;
/*
* Got a good BOOTP reply. Copy the data into our variables.
*/
#ifdef CONFIG_STATUS_LED
- status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
#endif
BootpCopyNetParams(bp); /* Store net parameters from reply */
/* Retrieve extended information (we must parse the vendor area) */
- if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
+ if (NetReadLong((ulong *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
BootpVendorProcess((uchar *)&bp->bp_vend[4], len);
NetSetTimeout(0, (thand_f *)0);
@@ -337,11 +329,11 @@ static void
BootpTimeout(void)
{
if (BootpTry >= TIMEOUT_COUNT) {
- puts ("\nRetry count exceeded; starting again\n");
- NetStartAgain ();
+ puts("\nRetry count exceeded; starting again\n");
+ NetStartAgain();
} else {
- NetSetTimeout (TIMEOUT, BootpTimeout);
- BootpRequest ();
+ NetSetTimeout(TIMEOUT, BootpTimeout);
+ BootpRequest();
}
}
@@ -349,7 +341,8 @@ BootpTimeout(void)
* Initialize BOOTP extension fields in the request.
*/
#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 *cnt;
@@ -381,7 +374,7 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
*e++ = (576 - 312 + OPT_SIZE) & 0xff;
if (ServerID) {
- int tmp = ntohl (ServerID);
+ int tmp = ntohl(ServerID);
*e++ = 54; /* ServerID */
*e++ = 4;
@@ -392,7 +385,7 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
}
if (RequestedIP) {
- int tmp = ntohl (RequestedIP);
+ int tmp = ntohl(RequestedIP);
*e++ = 50; /* Requested IP */
*e++ = 4;
@@ -402,12 +395,13 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
*e++ = tmp & 0xff;
}
#if defined(CONFIG_BOOTP_SEND_HOSTNAME)
- if ((hostname = getenv ("hostname"))) {
- int hostnamelen = strlen (hostname);
+ hostname = getenv("hostname");
+ if (hostname) {
+ int hostnamelen = strlen(hostname);
*e++ = 12; /* Hostname */
*e++ = hostnamelen;
- memcpy (e, hostname, hostnamelen);
+ memcpy(e, hostname, hostnamelen);
e += hostnamelen;
}
#endif
@@ -448,7 +442,8 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
#endif
#if defined(CONFIG_BOOTP_VENDOREX)
- if ((x = dhcp_vendorex_prep (e)))
+ x = dhcp_vendorex_prep(e);
+ if (x)
return x - start;
#endif
@@ -508,9 +503,9 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
#else
/*
- * Warning: no field size check - change CONFIG_BOOTP_* at your own risk!
+ * Warning: no field size check - change CONFIG_BOOTP_* at your own risk!
*/
-static int BootpExtended (u8 * e)
+static int BootpExtended(u8 *e)
{
u8 *start = e;
@@ -584,10 +579,10 @@ static int BootpExtended (u8 * e)
#endif
void
-BootpRequest (void)
+BootpRequest(void)
{
- volatile uchar *pkt, *iphdr;
- Bootp_t *bp;
+ uchar *pkt, *iphdr;
+ struct Bootp_t *bp;
int ext_len, pktlen, iplen;
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start");
@@ -600,22 +595,22 @@ BootpRequest (void)
int reg;
ulong tst1, tst2, sum, m_mask, m_value = 0;
- if (BootpTry ==0) {
+ if (BootpTry == 0) {
/* get our mac */
eth_getenv_enetaddr("ethaddr", bi_enetaddr);
debug("BootpRequest => Our Mac: ");
- for (reg=0; reg<6; reg++)
- debug("%x%c", bi_enetaddr[reg], reg==5 ? '\n' : ':');
+ for (reg = 0; reg < 6; reg++)
+ debug("%x%c", bi_enetaddr[reg], reg == 5 ? '\n' : ':');
/* Mac-Manipulation 2 get seed1 */
- tst1=0;
- tst2=0;
- for (reg=2; reg<6; reg++) {
+ tst1 = 0;
+ tst2 = 0;
+ for (reg = 2; reg < 6; reg++) {
tst1 = tst1 << 8;
tst1 = tst1 | bi_enetaddr[reg];
}
- for (reg=0; reg<2; reg++) {
+ for (reg = 0; reg < 2; reg++) {
tst2 = tst2 | bi_enetaddr[reg];
tst2 = tst2 << 8;
}
@@ -623,8 +618,8 @@ BootpRequest (void)
seed1 = tst1^tst2;
/* Mirror seed1*/
- m_mask=0x1;
- for (reg=1;reg<=32;reg++) {
+ m_mask = 0x1;
+ for (reg = 1; reg <= 32; reg++) {
m_value |= (m_mask & seed1);
seed1 = seed1 >> 1;
m_value = m_value << 1;
@@ -634,44 +629,45 @@ BootpRequest (void)
}
/* Random Number Generator */
-
- for (reg=0;reg<=0;reg++) {
+ for (reg = 0; reg <= 0; reg++) {
sum = seed1 + seed2;
if (sum < seed1 || sum < seed2)
sum++;
seed2 = seed1;
seed1 = sum;
- if (BootpTry<=2) { /* Start with max 1024 * 1ms */
+ if (BootpTry <= 2) { /* Start with max 1024 * 1ms */
sum = sum >> (22-BootpTry);
- } else { /*After 3rd BOOTP request max 8192 * 1ms */
+ } else { /*After 3rd BOOTP request max 8192 * 1ms */
sum = sum >> 19;
}
}
- printf ("Random delay: %ld ms...\n", sum);
- for (reg=0; reg <sum; reg++) {
+ printf("Random delay: %ld ms...\n", sum);
+ for (reg = 0; reg < sum; reg++)
udelay(1000); /*Wait 1ms*/
- }
+
#endif /* CONFIG_BOOTP_RANDOM_DELAY */
printf("BOOTP broadcast %d\n", ++BootpTry);
pkt = NetTxPacket;
- memset ((void*)pkt, 0, PKTSIZE);
+ memset((void *)pkt, 0, PKTSIZE);
pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
/*
- * Next line results in incorrect packet size being transmitted, resulting
- * in errors in some DHCP servers, reporting missing bytes. Size must be
- * set in packet header after extension length has been determined.
+ * Next line results in incorrect packet size being transmitted,
+ * resulting in errors in some DHCP servers, reporting missing bytes.
+ * Size must be set in packet header after extension length has been
+ * determined.
* 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() */
pkt += IP_HDR_SIZE;
- bp = (Bootp_t *)pkt;
+ bp = (struct Bootp_t *)pkt;
bp->bp_op = OP_BOOTREQUEST;
bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER;
@@ -681,8 +677,8 @@ BootpRequest (void)
NetWriteIP(&bp->bp_yiaddr, 0);
NetWriteIP(&bp->bp_siaddr, 0);
NetWriteIP(&bp->bp_giaddr, 0);
- memcpy (bp->bp_chaddr, NetOurEther, 6);
- copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
+ memcpy(bp->bp_chaddr, NetOurEther, 6);
+ copy_filename(bp->bp_file, BootFile, sizeof(bp->bp_file));
/* Request additional information from the BOOTP/DHCP server */
#if defined(CONFIG_CMD_DHCP)
@@ -707,7 +703,8 @@ BootpRequest (void)
* Calculate proper packet lengths taking into account the
* 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;
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);
@@ -722,7 +719,7 @@ BootpRequest (void)
}
#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;
int oplen, size;
@@ -734,50 +731,51 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
oplen = *(popt + 1);
switch (*popt) {
case 1:
- NetCopyIP (&NetOurSubnetMask, (popt + 2));
+ NetCopyIP(&NetOurSubnetMask, (popt + 2));
break;
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
case 2: /* Time offset */
to_ptr = &NetTimeOffset;
- NetCopyLong ((ulong *)to_ptr, (ulong *)(popt + 2));
- NetTimeOffset = ntohl (NetTimeOffset);
+ NetCopyLong((ulong *)to_ptr, (ulong *)(popt + 2));
+ NetTimeOffset = ntohl(NetTimeOffset);
break;
#endif
case 3:
- NetCopyIP (&NetOurGatewayIP, (popt + 2));
+ NetCopyIP(&NetOurGatewayIP, (popt + 2));
break;
case 6:
- NetCopyIP (&NetOurDNSIP, (popt + 2));
+ NetCopyIP(&NetOurDNSIP, (popt + 2));
#if defined(CONFIG_BOOTP_DNS2)
- if (*(popt + 1) > 4) {
- NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
- }
+ if (*(popt + 1) > 4)
+ NetCopyIP(&NetOurDNS2IP, (popt + 2 + 4));
#endif
break;
case 12:
- size = truncate_sz ("Host Name", sizeof (NetOurHostName), oplen);
- memcpy (&NetOurHostName, popt + 2, size);
+ size = truncate_sz("Host Name",
+ sizeof(NetOurHostName), oplen);
+ memcpy(&NetOurHostName, popt + 2, size);
NetOurHostName[size] = 0;
break;
case 15: /* Ignore Domain Name Option */
break;
case 17:
- size = truncate_sz ("Root Path", sizeof (NetOurRootPath), oplen);
- memcpy (&NetOurRootPath, popt + 2, size);
+ size = truncate_sz("Root Path",
+ sizeof(NetOurRootPath), oplen);
+ memcpy(&NetOurRootPath, popt + 2, size);
NetOurRootPath[size] = 0;
break;
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
case 42: /* NTP server IP */
- NetCopyIP (&NetNtpServerIP, (popt + 2));
+ NetCopyIP(&NetNtpServerIP, (popt + 2));
break;
#endif
case 51:
- NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2));
+ NetCopyLong(&dhcp_leasetime, (ulong *) (popt + 2));
break;
case 53: /* Ignore Message Type Option */
break;
case 54:
- NetCopyIP (&NetDHCPServerIP, (popt + 2));
+ NetCopyIP(&NetDHCPServerIP, (popt + 2));
break;
case 58: /* Ignore Renewal Time Option */
break;
@@ -792,7 +790,7 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
* pass the bootp packet pointer into here as the
* second arg
*/
- size = truncate_sz ("Opt Boot File",
+ size = truncate_sz("Opt Boot File",
sizeof(bp->bp_file),
oplen);
if (bp->bp_file[0] == '\0' && size > 0) {
@@ -813,10 +811,11 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
break;
default:
#if defined(CONFIG_BOOTP_VENDOREX)
- if (dhcp_vendorex_proc (popt))
+ if (dhcp_vendorex_proc(popt))
break;
#endif
- printf ("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt);
+ printf("*** Unhandled DHCP Option in OFFER/ACK:"
+ " %d\n", *popt);
break;
}
popt += oplen + 2; /* Process next option */
@@ -825,42 +824,42 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
static int DhcpMessageType(unsigned char *popt)
{
- if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
+ if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC))
return -1;
popt += 4;
- while ( *popt != 0xff ) {
- if ( *popt == 53 ) /* DHCP Message Type */
+ while (*popt != 0xff) {
+ if (*popt == 53) /* DHCP Message Type */
return *(popt + 2);
popt += *(popt + 1) + 2; /* Scan through all options */
}
return -1;
}
-static void DhcpSendRequestPkt(Bootp_t *bp_offer)
+static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
{
- volatile uchar *pkt, *iphdr;
- Bootp_t *bp;
+ uchar *pkt, *iphdr;
+ struct Bootp_t *bp;
int pktlen, iplen, extlen;
IPaddr_t OfferedIP;
debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
pkt = NetTxPacket;
- memset ((void*)pkt, 0, PKTSIZE);
+ memset((void *)pkt, 0, PKTSIZE);
pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
- 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;
- bp = (Bootp_t *)pkt;
+ bp = (struct Bootp_t *)pkt;
bp->bp_op = OP_BOOTREQUEST;
bp->bp_htype = HWT_ETHER;
bp->bp_hlen = HWL_ETHER;
bp->bp_hops = 0;
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
- * the server yet */
+ /* Do not set the client IP, your IP, or server IP yet, since it
+ * hasn't been ACK'ed by the server yet */
/*
* RFC3046 requires Relay Agents to discard packets with
@@ -868,7 +867,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
*/
NetWriteIP(&bp->bp_giaddr, 0);
- memcpy (bp->bp_chaddr, NetOurEther, 6);
+ memcpy(bp->bp_chaddr, NetOurEther, 6);
/*
* ID is the id of the OFFER packet
@@ -882,9 +881,11 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
/* Copy offered IP into the parameters request list */
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;
NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
@@ -902,36 +903,38 @@ static void
DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
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",
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;
- debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
- src, dest, len, dhcp_state);
+ debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state:"
+ " %d\n", src, dest, len, dhcp_state);
switch (dhcp_state) {
case SELECTING:
/*
* Wait an appropriate time for any potential DHCPOFFER packets
- * to arrive. Then select one, and generate DHCPREQUEST response.
- * If filename is in format we recognize, assume it is a valid
- * OFFER from a server we want.
+ * to arrive. Then select one, and generate DHCPREQUEST
+ * response. If filename is in format we recognize, assume it
+ * is a valid OFFER from a server we want.
*/
debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
#ifdef CONFIG_SYS_BOOTFILE_PREFIX
if (strncmp(bp->bp_file,
CONFIG_SYS_BOOTFILE_PREFIX,
- strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
+ strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0) {
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
debug("TRANSITIONING TO REQUESTING STATE\n");
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);
NetSetTimeout(TIMEOUT, BootpTimeout);
@@ -945,14 +948,17 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
case REQUESTING:
debug("DHCP State: REQUESTING\n");
- if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
- if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
+ if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) {
+ if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
+ htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
- BootpCopyNetParams(bp); /* Store net params from reply */
+ /* Store net params from reply */
+ BootpCopyNetParams(bp);
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,
- "bootp_stop");
+ "bootp_stop");
net_auto_load();
return;
@@ -962,7 +968,7 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
/* DHCP client bound to address */
break;
default:
- puts ("DHCP: INVALID STATE\n");
+ puts("DHCP: INVALID STATE\n");
break;
}
diff --git a/net/bootp.h b/net/bootp.h
index 50625ab..ce73734 100644
--- a/net/bootp.h
+++ b/net/bootp.h
@@ -10,7 +10,7 @@
#define __BOOTP_H__
#ifndef __NET_H__
-#include <net.h>
+#include <net.h>
#endif /* __NET_H__ */
/**********************************************************************/
@@ -19,35 +19,39 @@
* BOOTP header.
*/
#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
#define OPT_SIZE 64
#endif
-typedef struct
-{
- uchar bp_op; /* Operation */
+struct Bootp_t {
+ uchar bp_op; /* Operation */
# define OP_BOOTREQUEST 1
# define OP_BOOTREPLY 2
- uchar bp_htype; /* Hardware type */
+ uchar bp_htype; /* Hardware type */
# define HWT_ETHER 1
- uchar bp_hlen; /* Hardware address length */
+ uchar bp_hlen; /* Hardware address length */
# define HWL_ETHER 6
- uchar bp_hops; /* Hop count (gateway thing) */
- ulong bp_id; /* Transaction ID */
- ushort bp_secs; /* Seconds since boot */
- ushort bp_spare1; /* Alignment */
- IPaddr_t bp_ciaddr; /* Client IP address */
- IPaddr_t bp_yiaddr; /* Your (client) IP address */
- IPaddr_t bp_siaddr; /* Server IP address */
- IPaddr_t bp_giaddr; /* Gateway IP address */
- uchar bp_chaddr[16]; /* Client hardware address */
- char bp_sname[64]; /* Server host name */
- char bp_file[128]; /* Boot file name */
- char bp_vend[OPT_SIZE]; /* Vendor information */
-} Bootp_t;
-
-#define BOOTP_HDR_SIZE sizeof (Bootp_t)
+ uchar bp_hops; /* Hop count (gateway thing) */
+ ulong bp_id; /* Transaction ID */
+ ushort bp_secs; /* Seconds since boot */
+ ushort bp_spare1; /* Alignment */
+ IPaddr_t bp_ciaddr; /* Client IP address */
+ IPaddr_t bp_yiaddr; /* Your (client) IP address */
+ IPaddr_t bp_siaddr; /* Server IP address */
+ IPaddr_t bp_giaddr; /* Gateway IP address */
+ uchar bp_chaddr[16]; /* Client hardware address */
+ char bp_sname[64]; /* Server host name */
+ char bp_file[128]; /* Boot file name */
+ char bp_vend[OPT_SIZE]; /* Vendor information */
+};
+
+#define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE)
/**********************************************************************/
@@ -56,16 +60,16 @@ typedef struct
*/
/* bootp.c */
-extern ulong BootpID; /* ID of cur BOOTP request */
-extern char BootFile[128]; /* Boot file name */
+extern ulong BootpID; /* ID of cur BOOTP request */
+extern char BootFile[128]; /* Boot file name */
extern int BootpTry;
#ifdef CONFIG_BOOTP_RANDOM_DELAY
-extern ulong seed1, seed2; /* seed for random BOOTP delay */
+extern ulong seed1, seed2; /* seed for random BOOTP delay */
#endif
/* Send a BOOTP request */
-extern void BootpRequest (void);
+extern void BootpRequest(void);
/****************** DHCP Support *********************/
extern void DhcpRequest(void);
diff --git a/net/eth.c b/net/eth.c
index 3eeb908..d9a6430 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -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")));
#ifdef CONFIG_API
-extern void (*push_packet)(volatile void *, int);
-
static struct {
uchar data[PKTSIZE];
int length;
} 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
static struct eth_device *eth_devices, *eth_current;
@@ -141,11 +139,10 @@ struct eth_device *eth_get_dev_by_index(int index)
return target_dev;
}
-int eth_get_dev_index (void)
+int eth_get_dev_index(void)
{
- if (!eth_current) {
+ if (!eth_current)
return -1;
- }
return eth_current->index;
}
@@ -176,7 +173,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
- memcmp(dev->enetaddr, env_enetaddr, 6)) {
+ memcmp(dev->enetaddr, env_enetaddr, 6)) {
printf("\nWarning: %s MAC addresses don't match:\n",
dev->name);
printf("Address in SROM is %pM\n",
@@ -189,10 +186,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
}
if (dev->write_hwaddr &&
- !eth_mac_skip(eth_number) &&
- is_valid_ether_addr(dev->enetaddr)) {
+ !eth_mac_skip(eth_number) &&
+ is_valid_ether_addr(dev->enetaddr))
ret = dev->write_hwaddr(dev);
- }
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)
{
struct eth_device *d;
- static int index = 0;
+ static int index;
assert(strlen(dev->name) < sizeof(dev->name));
@@ -208,7 +204,7 @@ int eth_register(struct eth_device *dev)
eth_current = eth_devices = dev;
eth_current_changed();
} else {
- for (d=eth_devices; d->next!=eth_devices; d=d->next)
+ for (d = eth_devices; d->next != eth_devices; d = d->next)
;
d->next = dev;
}
@@ -249,6 +245,14 @@ int eth_unregister(struct eth_device *dev)
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 num_devices = 0;
@@ -264,6 +268,8 @@ int eth_initialize(bd_t *bis)
phy_init();
#endif
+ eth_env_init(bis);
+
/*
* If board-specific initialization exists, call it.
* If not, call a CPU-specific one
@@ -278,36 +284,37 @@ int eth_initialize(bd_t *bis)
printf("Net Initialization Skipped\n");
if (!eth_devices) {
- puts ("No ethernet found.\n");
+ puts("No ethernet found.\n");
bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
} else {
struct eth_device *dev = eth_devices;
- char *ethprime = getenv ("ethprime");
+ char *ethprime = getenv("ethprime");
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
do {
if (dev->index)
- puts (", ");
+ puts(", ");
printf("%s", dev->name);
- if (ethprime && strcmp (dev->name, ethprime) == 0) {
+ if (ethprime && strcmp(dev->name, ethprime) == 0) {
eth_current = dev;
- puts (" [PRIME]");
+ puts(" [PRIME]");
}
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))
puts("\nWarning: failed to set MAC address\n");
dev = dev->next;
num_devices++;
- } while(dev != eth_devices);
+ } while (dev != eth_devices);
eth_current_changed();
- putc ('\n');
+ putc('\n');
}
return num_devices;
@@ -318,9 +325,9 @@ int eth_initialize(bd_t *bis)
* mcast_addr: multicast ipaddr from which multicast Mac is made
* join: 1=join, 0=leave.
*/
-int eth_mcast_join( IPaddr_t mcast_ip, u8 join)
+int eth_mcast_join(IPaddr_t mcast_ip, u8 join)
{
- u8 mcast_mac[6];
+ u8 mcast_mac[6];
if (!eth_current || !eth_current->mcast)
return -1;
mcast_mac[5] = htonl(mcast_ip) & 0xff;
@@ -337,7 +344,7 @@ int eth_mcast_join( IPaddr_t mcast_ip, u8 join)
* some other adapter -- hash tables
*/
#define CRCPOLY_LE 0xedb88320
-u32 ether_crc (size_t len, unsigned char const *p)
+u32 ether_crc(size_t len, unsigned char const *p)
{
int i;
u32 crc;
@@ -364,7 +371,7 @@ int eth_init(bd_t *bis)
struct eth_device *old_current, *dev;
if (!eth_current) {
- puts ("No ethernet found.\n");
+ puts("No ethernet found.\n");
return -1;
}
@@ -384,7 +391,7 @@ int eth_init(bd_t *bis)
do {
debug("Trying %s\n", eth_current->name);
- if (eth_current->init(eth_current,bis) >= 0) {
+ if (eth_current->init(eth_current, bis) >= 0) {
eth_current->state = ETH_STATE_ACTIVE;
return 0;
@@ -407,7 +414,7 @@ void eth_halt(void)
eth_current->state = ETH_STATE_PASSIVE;
}
-int eth_send(volatile void *packet, int length)
+int eth_send(void *packet, int length)
{
if (!eth_current)
return -1;
@@ -424,9 +431,9 @@ int eth_rx(void)
}
#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;
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;
}
-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;
int i;
@@ -472,38 +479,36 @@ int eth_receive(volatile void *packet, int length)
void eth_try_another(int first_restart)
{
- static struct eth_device *first_failed = NULL;
+ static struct eth_device *first_failed;
char *ethrotate;
/*
* Do not rotate between network interfaces when
* 'ethrotate' variable is set to 'no'.
*/
- if (((ethrotate = getenv ("ethrotate")) != NULL) &&
- (strcmp(ethrotate, "no") == 0))
+ ethrotate = getenv("ethrotate");
+ if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
return;
if (!eth_current)
return;
- if (first_restart) {
+ if (first_restart)
first_failed = eth_current;
- }
eth_current = eth_current->next;
eth_current_changed();
- if (first_failed == eth_current) {
+ if (first_failed == eth_current)
NetRestartWrap = 1;
- }
}
void eth_set_current(void)
{
- static char *act = NULL;
- static int env_changed_id = 0;
- struct eth_device* old_current;
+ static char *act;
+ static int env_changed_id;
+ struct eth_device *old_current;
int env_id;
if (!eth_current) /* XXX no current */
@@ -526,7 +531,7 @@ void eth_set_current(void)
eth_current_changed();
}
-char *eth_get_name (void)
+char *eth_get_name(void)
{
- return (eth_current ? eth_current->name : "unknown");
+ return eth_current ? eth_current->name : "unknown";
}
diff --git a/net/net.c b/net/net.c
index c5acf8f..e9536b3 100644
--- a/net/net.c
+++ b/net/net.c
@@ -77,6 +77,7 @@
#include <common.h>
#include <watchdog.h>
#include <command.h>
+#include <linux/compiler.h>
#include <net.h>
#include "bootp.h"
#include "tftp.h"
@@ -152,7 +153,7 @@ IPaddr_t NetOurIP;
/* Server IP addr (0 = unknown) */
IPaddr_t NetServerIP;
/* Current receive packet */
-volatile uchar *NetRxPacket;
+uchar *NetRxPacket;
/* Current rx packet length */
int NetRxPacketLen;
/* IP packet ID */
@@ -161,7 +162,7 @@ unsigned NetIPID;
uchar NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
uchar NetEtherNullAddr[6];
#ifdef CONFIG_API
-void (*push_packet)(volatile void *, int len) = 0;
+void (*push_packet)(void *, int len) = 0;
#endif
#if defined(CONFIG_CMD_CDP)
/* Ethernet bcast address */
@@ -203,15 +204,10 @@ IPaddr_t NetNtpServerIP;
int NetTimeOffset;
#endif
-#ifdef CONFIG_NETCONSOLE
-void NcStart(void);
-int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
-#endif
-
-volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
+uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
/* Receive packet */
-volatile uchar *NetRxPackets[PKTBUFSRX];
+uchar *NetRxPackets[PKTBUFSRX];
/* Current RX packet handler */
static rxhand_f *packetHandler;
@@ -225,7 +221,7 @@ static ulong timeStart;
/* Current timeout value */
static ulong timeDelta;
/* THE transmit packet */
-volatile uchar *NetTxPacket;
+uchar *NetTxPacket;
static int net_check_prereq(enum proto_t protocol);
@@ -246,7 +242,7 @@ int NetArpWaitTry;
void ArpRequest(void)
{
- volatile uchar *pkt;
+ uchar *pkt;
ARP_t *arp;
debug("ARP broadcast %d\n", NetArpWaitTry);
@@ -342,13 +338,11 @@ void net_auto_load(void)
static void NetInitLoop(enum proto_t protocol)
{
static int env_changed_id;
- bd_t *bd = gd->bd;
int env_id = get_env_id();
/* update only when the environment has changed */
if (env_changed_id != env_id) {
NetOurIP = getenv_IPaddr("ipaddr");
- NetCopyIP(&bd->bi_ip_addr, &NetOurIP);
NetOurGatewayIP = getenv_IPaddr("gatewayip");
NetOurSubnetMask = getenv_IPaddr("netmask");
NetServerIP = getenv_IPaddr("serverip");
@@ -527,10 +521,7 @@ restart:
for (;;) {
WATCHDOG_RESET();
#ifdef CONFIG_SHOW_ACTIVITY
- {
- extern void show_activity(int arg);
- show_activity(1);
- }
+ show_activity(1);
#endif
/*
* Check the ethernet for a new packet. The ethernet
@@ -705,7 +696,7 @@ NetSetTimeout(ulong iv, thand_f *f)
void
-NetSendPacket(volatile uchar *pkt, int len)
+NetSendPacket(uchar *pkt, int len)
{
(void) eth_send(pkt, len);
}
@@ -768,8 +759,8 @@ static ushort PingSeqNo;
int PingSend(void)
{
static uchar mac[6];
- volatile IP_t *ip;
- volatile ushort *s;
+ IP_t *ip;
+ ushort *s;
uchar *pkt;
/* XXX always send arp request */
@@ -784,7 +775,7 @@ int PingSend(void)
pkt = NetArpWaitTxPacket;
pkt += NetSetEther(pkt, mac, PROT_IP);
- ip = (volatile IP_t *)pkt;
+ ip = (IP_t *)pkt;
/*
* Construct an IP and ICMP header.
@@ -936,9 +927,9 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
int CDPSendTrigger(void)
{
- volatile uchar *pkt;
- volatile ushort *s;
- volatile ushort *cp;
+ uchar *pkt;
+ ushort *s;
+ ushort *cp;
Ethernet_t *et;
int len;
ushort chksum;
@@ -965,7 +956,7 @@ int CDPSendTrigger(void)
/* CDP header */
*pkt++ = 0x02; /* CDP version 2 */
*pkt++ = 180; /* TTL */
- s = (volatile ushort *)pkt;
+ s = (ushort *)pkt;
cp = s;
/* checksum (0 for later calculation) */
*s++ = htons(0);
@@ -1103,8 +1094,8 @@ CDPHandler(const uchar *pkt, unsigned len)
* output a warning
*/
if (pkt[0] != 0x02)
- printf("** WARNING: CDP packet received with a protocol version %d > 2\n",
- pkt[0] & 0xff);
+ printf("**WARNING: CDP packet received with a protocol version "
+ "%d > 2\n", pkt[0] & 0xff);
if (CDP_compute_csum(pkt, len) != 0)
return;
@@ -1239,7 +1230,7 @@ struct hole {
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;
struct hole *payload, *thisfrag, *h, *newh;
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
-NetReceive(volatile uchar *inpkt, int len)
+NetReceive(uchar *inpkt, int len)
{
Ethernet_t *et;
IP_t *ip;
@@ -1611,6 +1602,7 @@ NetReceive(volatile uchar *inpkt, int len)
/* matched waiting packet's address */
if (tmp == NetArpWaitReplyIP) {
debug("Got it\n");
+
/* save address for later use */
memcpy(NetArpWaitPacketMAC,
&arp->ar_data[0], 6);
@@ -1619,7 +1611,8 @@ NetReceive(volatile uchar *inpkt, int len)
(*packetHandler)(0, 0, 0, 0, 0);
#endif
/* 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,
NetArpWaitTxPacketSize);
@@ -1856,7 +1849,6 @@ common:
case CDP:
case DHCP:
if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
- extern int eth_get_dev_index(void);
int num = eth_get_dev_index();
switch (num) {
@@ -1918,7 +1910,7 @@ NetEthHdrSize(void)
}
int
-NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
+NetSetEther(uchar *xet, uchar * addr, uint prot)
{
Ethernet_t *et = (Ethernet_t *)xet;
ushort myvlanid;
@@ -1943,7 +1935,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
}
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;
diff --git a/net/nfs.c b/net/nfs.c
index b5b482c..54f56c4 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -33,8 +33,8 @@
#define NFS_RETRY_COUNT 30
#define NFS_TIMEOUT 2000UL
-static int fs_mounted = 0;
-static unsigned long rpc_id = 0;
+static int fs_mounted;
+static unsigned long rpc_id;
static int nfs_offset = -1;
static int nfs_len;
@@ -61,14 +61,14 @@ static char *nfs_filename;
static char *nfs_path;
static char nfs_path_buff[2048];
-static __inline__ int
-store_block (uchar * src, unsigned offset, unsigned len)
+static inline int
+store_block(uchar *src, unsigned offset, unsigned len)
{
ulong newsize = offset + len;
#ifdef CONFIG_SYS_DIRECT_FLASH_NFS
int i, rc = 0;
- for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++) {
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
/* start address in flash? */
if (load_addr + offset >= flash_info[i].start[0]) {
rc = 1;
@@ -77,15 +77,15 @@ store_block (uchar * src, unsigned offset, unsigned len)
}
if (rc) { /* Flash is destination for this packet */
- rc = flash_write ((uchar *)src, (ulong)(load_addr+offset), len);
+ rc = flash_write((uchar *)src, (ulong)(load_addr+offset), len);
if (rc) {
- flash_perror (rc);
+ flash_perror(rc);
return -1;
}
} else
#endif /* CONFIG_SYS_DIRECT_FLASH_NFS */
{
- (void)memcpy ((void *)(load_addr + offset), src, len);
+ (void)memcpy((void *)(load_addr + offset), src, len);
}
if (NetBootFileXferSize < (offset+len))
@@ -94,7 +94,7 @@ store_block (uchar * src, unsigned offset, unsigned len)
}
static char*
-basename (char *path)
+basename(char *path)
{
char *fname;
@@ -110,11 +110,11 @@ basename (char *path)
}
static char*
-dirname (char *path)
+dirname(char *path)
{
char *fname;
- fname = basename (path);
+ fname = basename(path);
--fname;
*fname = '\0';
return path;
@@ -123,14 +123,14 @@ dirname (char *path)
/**************************************************************************
RPC_ADD_CREDENTIALS - Add RPC authentication/verifier entries
**************************************************************************/
-static long *rpc_add_credentials (long *p)
+static long *rpc_add_credentials(long *p)
{
int hl;
int hostnamelen;
char hostname[256];
- strcpy (hostname, "");
- hostnamelen=strlen (hostname);
+ strcpy(hostname, "");
+ hostnamelen = strlen(hostname);
/* Here's the executive summary on authentication requirements of the
* various NFS server implementations: Linux accepts both AUTH_NONE
@@ -148,10 +148,9 @@ static long *rpc_add_credentials (long *p)
*p++ = htonl(hl+20); /* auth length */
*p++ = htonl(0); /* stamp */
*p++ = htonl(hostnamelen); /* hostname string */
- if (hostnamelen & 3) {
+ if (hostnamelen & 3)
*(p + hostnamelen / 4) = 0; /* add zero padding */
- }
- memcpy (p, hostname, hostnamelen);
+ memcpy(p, hostname, hostnamelen);
p += hl / 4;
*p++ = 0; /* uid */
*p++ = 0; /* gid */
@@ -168,7 +167,7 @@ static long *rpc_add_credentials (long *p)
RPC_LOOKUP - Lookup RPC Port numbers
**************************************************************************/
static void
-rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
+rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
{
struct rpc_t pkt;
unsigned long id;
@@ -186,11 +185,12 @@ rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
p = (uint32_t *)&(pkt.u.call.data);
if (datalen)
- memcpy ((char *)p, (char *)data, datalen*sizeof(uint32_t));
+ memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
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)
sport = SUNRPC_PORT;
@@ -199,14 +199,15 @@ rpc_req (int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
else
sport = NfsSrvNfsPort;
- NetSendUDPPacket (NetServerEther, NfsServerIP, sport, NfsOurPort, pktlen);
+ NetSendUDPPacket(NetServerEther, NfsServerIP, sport, NfsOurPort,
+ pktlen);
}
/**************************************************************************
RPC_LOOKUP - Lookup RPC Port numbers
**************************************************************************/
static void
-rpc_lookup_req (int prog, int ver)
+rpc_lookup_req(int prog, int ver)
{
uint32_t data[16];
@@ -217,56 +218,56 @@ rpc_lookup_req (int prog, int ver)
data[6] = htonl(17); /* IP_UDP */
data[7] = 0;
- rpc_req (PROG_PORTMAP, PORTMAP_GETPORT, data, 8);
+ rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8);
}
/**************************************************************************
NFS_MOUNT - Mount an NFS Filesystem
**************************************************************************/
static void
-nfs_mount_req (char *path)
+nfs_mount_req(char *path)
{
uint32_t data[1024];
uint32_t *p;
int len;
int pathlen;
- pathlen = strlen (path);
+ pathlen = strlen(path);
p = &(data[0]);
p = (uint32_t *)rpc_add_credentials((long *)p);
*p++ = htonl(pathlen);
- if (pathlen & 3) *(p + pathlen / 4) = 0;
- memcpy (p, path, pathlen);
+ if (pathlen & 3)
+ *(p + pathlen / 4) = 0;
+ memcpy(p, path, pathlen);
p += (pathlen + 3) / 4;
len = (uint32_t *)p - (uint32_t *)&(data[0]);
- rpc_req (PROG_MOUNT, MOUNT_ADDENTRY, data, len);
+ rpc_req(PROG_MOUNT, MOUNT_ADDENTRY, data, len);
}
/**************************************************************************
NFS_UMOUNTALL - Unmount all our NFS Filesystems on the Server
**************************************************************************/
static void
-nfs_umountall_req (void)
+nfs_umountall_req(void)
{
uint32_t data[1024];
uint32_t *p;
int len;
- if ((NfsSrvMountPort == -1) || (!fs_mounted)) {
+ if ((NfsSrvMountPort == -1) || (!fs_mounted))
/* Nothing mounted, nothing to umount */
return;
- }
p = &(data[0]);
- p = (uint32_t *)rpc_add_credentials ((long *)p);
+ p = (uint32_t *)rpc_add_credentials((long *)p);
len = (uint32_t *)p - (uint32_t *)&(data[0]);
- rpc_req (PROG_MOUNT, MOUNT_UMOUNTALL, data, len);
+ rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len);
}
/***************************************************************************
@@ -277,65 +278,66 @@ nfs_umountall_req (void)
* so that inside the nfs() function a recursion can be done.
**************************************************************************/
static void
-nfs_readlink_req (void)
+nfs_readlink_req(void)
{
uint32_t data[1024];
uint32_t *p;
int len;
p = &(data[0]);
- p = (uint32_t *)rpc_add_credentials ((long *)p);
+ p = (uint32_t *)rpc_add_credentials((long *)p);
- memcpy (p, filefh, NFS_FHSIZE);
+ memcpy(p, filefh, NFS_FHSIZE);
p += (NFS_FHSIZE / 4);
len = (uint32_t *)p - (uint32_t *)&(data[0]);
- rpc_req (PROG_NFS, NFS_READLINK, data, len);
+ rpc_req(PROG_NFS, NFS_READLINK, data, len);
}
/**************************************************************************
NFS_LOOKUP - Lookup Pathname
**************************************************************************/
static void
-nfs_lookup_req (char *fname)
+nfs_lookup_req(char *fname)
{
uint32_t data[1024];
uint32_t *p;
int len;
int fnamelen;
- fnamelen = strlen (fname);
+ fnamelen = strlen(fname);
p = &(data[0]);
- p = (uint32_t *)rpc_add_credentials ((long *)p);
+ p = (uint32_t *)rpc_add_credentials((long *)p);
- memcpy (p, dirfh, NFS_FHSIZE);
+ memcpy(p, dirfh, NFS_FHSIZE);
p += (NFS_FHSIZE / 4);
*p++ = htonl(fnamelen);
- if (fnamelen & 3) *(p + fnamelen / 4) = 0;
- memcpy (p, fname, fnamelen);
+ if (fnamelen & 3)
+ *(p + fnamelen / 4) = 0;
+ memcpy(p, fname, fnamelen);
p += (fnamelen + 3) / 4;
len = (uint32_t *)p - (uint32_t *)&(data[0]);
- rpc_req (PROG_NFS, NFS_LOOKUP, data, len);
+ rpc_req(PROG_NFS, NFS_LOOKUP, data, len);
}
/**************************************************************************
NFS_READ - Read File on NFS Server
**************************************************************************/
static void
-nfs_read_req (int offset, int readlen)
+nfs_read_req(int offset, int readlen)
{
uint32_t data[1024];
uint32_t *p;
int len;
p = &(data[0]);
- p = (uint32_t *)rpc_add_credentials ((long *)p);
+ p = (uint32_t *)rpc_add_credentials((long *)p);
- memcpy (p, filefh, NFS_FHSIZE);
+ memcpy(p, filefh, NFS_FHSIZE);
p += (NFS_FHSIZE / 4);
*p++ = htonl(offset);
*p++ = htonl(readlen);
@@ -343,7 +345,7 @@ nfs_read_req (int offset, int readlen)
len = (uint32_t *)p - (uint32_t *)&(data[0]);
- rpc_req (PROG_NFS, NFS_READ, data, len);
+ rpc_req(PROG_NFS, NFS_READ, data, len);
}
/**************************************************************************
@@ -351,31 +353,31 @@ RPC request dispatcher
**************************************************************************/
static void
-NfsSend (void)
+NfsSend(void)
{
debug("%s\n", __func__);
switch (NfsState) {
case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
- rpc_lookup_req (PROG_MOUNT, 1);
+ rpc_lookup_req(PROG_MOUNT, 1);
break;
case STATE_PRCLOOKUP_PROG_NFS_REQ:
- rpc_lookup_req (PROG_NFS, 2);
+ rpc_lookup_req(PROG_NFS, 2);
break;
case STATE_MOUNT_REQ:
- nfs_mount_req (nfs_path);
+ nfs_mount_req(nfs_path);
break;
case STATE_UMOUNT_REQ:
- nfs_umountall_req ();
+ nfs_umountall_req();
break;
case STATE_LOOKUP_REQ:
- nfs_lookup_req (nfs_filename);
+ nfs_lookup_req(nfs_filename);
break;
case STATE_READ_REQ:
- nfs_read_req (nfs_offset, nfs_len);
+ nfs_read_req(nfs_offset, nfs_len);
break;
case STATE_READLINK_REQ:
- nfs_readlink_req ();
+ nfs_readlink_req();
break;
}
}
@@ -385,11 +387,11 @@ Handlers for the reply from server
**************************************************************************/
static int
-rpc_lookup_reply (int prog, uchar *pkt, unsigned len)
+rpc_lookup_reply(int prog, uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
- memcpy ((unsigned char *)&rpc_pkt, pkt, len);
+ memcpy((unsigned char *)&rpc_pkt, pkt, len);
debug("%s\n", __func__);
@@ -398,9 +400,8 @@ rpc_lookup_reply (int prog, uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
- rpc_pkt.u.reply.astatus) {
+ rpc_pkt.u.reply.astatus)
return -1;
- }
switch (prog) {
case PROG_MOUNT:
@@ -415,13 +416,13 @@ rpc_lookup_reply (int prog, uchar *pkt, unsigned len)
}
static int
-nfs_mount_reply (uchar *pkt, unsigned len)
+nfs_mount_reply(uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
debug("%s\n", __func__);
- memcpy ((unsigned char *)&rpc_pkt, pkt, len);
+ memcpy((unsigned char *)&rpc_pkt, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
@@ -429,48 +430,46 @@ nfs_mount_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus ||
- rpc_pkt.u.reply.data[0]) {
+ rpc_pkt.u.reply.data[0])
return -1;
- }
fs_mounted = 1;
- memcpy (dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
+ memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
return 0;
}
static int
-nfs_umountall_reply (uchar *pkt, unsigned len)
+nfs_umountall_reply(uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
debug("%s\n", __func__);
- memcpy ((unsigned char *)&rpc_pkt, pkt, len);
+ memcpy((unsigned char *)&rpc_pkt, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
- rpc_pkt.u.reply.astatus) {
+ rpc_pkt.u.reply.astatus)
return -1;
- }
fs_mounted = 0;
- memset (dirfh, 0, sizeof(dirfh));
+ memset(dirfh, 0, sizeof(dirfh));
return 0;
}
static int
-nfs_lookup_reply (uchar *pkt, unsigned len)
+nfs_lookup_reply(uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
debug("%s\n", __func__);
- memcpy ((unsigned char *)&rpc_pkt, pkt, len);
+ memcpy((unsigned char *)&rpc_pkt, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
@@ -478,24 +477,23 @@ nfs_lookup_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus ||
- rpc_pkt.u.reply.data[0]) {
+ rpc_pkt.u.reply.data[0])
return -1;
- }
- memcpy (filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
+ memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
return 0;
}
static int
-nfs_readlink_reply (uchar *pkt, unsigned len)
+nfs_readlink_reply(uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
int rlen;
debug("%s\n", __func__);
- memcpy ((unsigned char *)&rpc_pkt, pkt, len);
+ memcpy((unsigned char *)&rpc_pkt, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
@@ -503,34 +501,34 @@ nfs_readlink_reply (uchar *pkt, unsigned len)
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus ||
- rpc_pkt.u.reply.data[0]) {
+ rpc_pkt.u.reply.data[0])
return -1;
- }
- rlen = ntohl (rpc_pkt.u.reply.data[1]); /* new path length */
+ rlen = ntohl(rpc_pkt.u.reply.data[1]); /* new path length */
if (*((char *)&(rpc_pkt.u.reply.data[2])) != '/') {
int pathlen;
- strcat (nfs_path, "/");
+ strcat(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;
} else {
- memcpy (nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen);
+ memcpy(nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen);
nfs_path[rlen] = 0;
}
return 0;
}
static int
-nfs_read_reply (uchar *pkt, unsigned len)
+nfs_read_reply(uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
int rlen;
debug("%s\n", __func__);
- memcpy ((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
+ memcpy((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
return -1;
@@ -539,24 +537,22 @@ nfs_read_reply (uchar *pkt, unsigned len)
rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus ||
rpc_pkt.u.reply.data[0]) {
- if (rpc_pkt.u.reply.rstatus) {
+ if (rpc_pkt.u.reply.rstatus)
return -9999;
- }
- if (rpc_pkt.u.reply.astatus) {
+ if (rpc_pkt.u.reply.astatus)
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))) {
- puts ("\n\t ");
- }
- if (!(nfs_offset % ((NFS_READ_SIZE/2)*10))) {
- putc ('#');
- }
+ if ((nfs_offset != 0) && !((nfs_offset) %
+ (NFS_READ_SIZE / 2 * 10 * HASHES_PER_LINE)))
+ puts("\n\t ");
+ if (!(nfs_offset % ((NFS_READ_SIZE / 2) * 10)))
+ putc('#');
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 rlen;
@@ -567,15 +563,15 @@ Interfaces of U-BOOT
**************************************************************************/
static void
-NfsTimeout (void)
+NfsTimeout(void)
{
- if ( ++NfsTimeoutCount > NFS_RETRY_COUNT ) {
- puts ("\nRetry count exceeded; starting again\n");
- NetStartAgain ();
+ if (++NfsTimeoutCount > NFS_RETRY_COUNT) {
+ puts("\nRetry count exceeded; starting again\n");
+ NetStartAgain();
} else {
puts("T ");
- NetSetTimeout (NFS_TIMEOUT, NfsTimeout);
- NfsSend ();
+ NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
+ NfsSend();
}
}
@@ -586,86 +582,87 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
debug("%s\n", __func__);
- if (dest != NfsOurPort) return;
+ if (dest != NfsOurPort)
+ return;
switch (NfsState) {
case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
- rpc_lookup_reply (PROG_MOUNT, pkt, len);
+ rpc_lookup_reply(PROG_MOUNT, pkt, len);
NfsState = STATE_PRCLOOKUP_PROG_NFS_REQ;
- NfsSend ();
+ NfsSend();
break;
case STATE_PRCLOOKUP_PROG_NFS_REQ:
- rpc_lookup_reply (PROG_NFS, pkt, len);
+ rpc_lookup_reply(PROG_NFS, pkt, len);
NfsState = STATE_MOUNT_REQ;
- NfsSend ();
+ NfsSend();
break;
case STATE_MOUNT_REQ:
if (nfs_mount_reply(pkt, len)) {
- puts ("*** ERROR: Cannot mount\n");
+ puts("*** ERROR: Cannot mount\n");
/* just to be sure... */
NfsState = STATE_UMOUNT_REQ;
- NfsSend ();
+ NfsSend();
} else {
NfsState = STATE_LOOKUP_REQ;
- NfsSend ();
+ NfsSend();
}
break;
case STATE_UMOUNT_REQ:
if (nfs_umountall_reply(pkt, len)) {
- puts ("*** ERROR: Cannot umount\n");
+ puts("*** ERROR: Cannot umount\n");
NetState = NETLOOP_FAIL;
} else {
- puts ("\ndone\n");
+ puts("\ndone\n");
NetState = NfsDownloadState;
}
break;
case STATE_LOOKUP_REQ:
if (nfs_lookup_reply(pkt, len)) {
- puts ("*** ERROR: File lookup fail\n");
+ puts("*** ERROR: File lookup fail\n");
NfsState = STATE_UMOUNT_REQ;
- NfsSend ();
+ NfsSend();
} else {
NfsState = STATE_READ_REQ;
nfs_offset = 0;
nfs_len = NFS_READ_SIZE;
- NfsSend ();
+ NfsSend();
}
break;
case STATE_READLINK_REQ:
if (nfs_readlink_reply(pkt, len)) {
- puts ("*** ERROR: Symlink fail\n");
+ puts("*** ERROR: Symlink fail\n");
NfsState = STATE_UMOUNT_REQ;
- NfsSend ();
+ NfsSend();
} else {
debug("Symlink --> %s\n", nfs_path);
- nfs_filename = basename (nfs_path);
- nfs_path = dirname (nfs_path);
+ nfs_filename = basename(nfs_path);
+ nfs_path = dirname(nfs_path);
NfsState = STATE_MOUNT_REQ;
- NfsSend ();
+ NfsSend();
}
break;
case STATE_READ_REQ:
- rlen = nfs_read_reply (pkt, len);
- NetSetTimeout (NFS_TIMEOUT, NfsTimeout);
+ rlen = nfs_read_reply(pkt, len);
+ NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
if (rlen > 0) {
nfs_offset += rlen;
- NfsSend ();
- }
- else if ((rlen == -NFSERR_ISDIR)||(rlen == -NFSERR_INVAL)) {
+ NfsSend();
+ } else if ((rlen == -NFSERR_ISDIR) || (rlen == -NFSERR_INVAL)) {
/* symbolic link */
NfsState = STATE_READLINK_REQ;
- NfsSend ();
+ NfsSend();
} else {
- if ( ! rlen ) NfsDownloadState = NETLOOP_SUCCESS;
+ if (!rlen)
+ NfsDownloadState = NETLOOP_SUCCESS;
NfsState = STATE_UMOUNT_REQ;
- NfsSend ();
+ NfsSend();
}
break;
}
@@ -673,7 +670,7 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
void
-NfsStart (void)
+NfsStart(void)
{
debug("%s\n", __func__);
NfsDownloadState = NETLOOP_FAIL;
@@ -683,7 +680,7 @@ NfsStart (void)
if (nfs_path == NULL) {
NetState = NETLOOP_FAIL;
- puts ("*** ERROR: Fail allocate memory\n");
+ puts("*** ERROR: Fail allocate memory\n");
return;
}
@@ -692,29 +689,29 @@ NfsStart (void)
NetOurIP & 0xFF,
(NetOurIP >> 8) & 0xFF,
(NetOurIP >> 16) & 0xFF,
- (NetOurIP >> 24) & 0xFF );
- strcpy (nfs_path, default_filename);
+ (NetOurIP >> 24) & 0xFF);
+ strcpy(nfs_path, default_filename);
- printf ("*** Warning: no boot file name; using '%s'\n",
+ printf("*** Warning: no boot file name; using '%s'\n",
nfs_path);
} else {
- char *p=BootFile;
+ char *p = BootFile;
- p = strchr (p, ':');
+ p = strchr(p, ':');
if (p != NULL) {
- NfsServerIP = string_to_ip (BootFile);
+ NfsServerIP = string_to_ip(BootFile);
++p;
- strcpy (nfs_path, p);
+ strcpy(nfs_path, p);
} else {
- strcpy (nfs_path, BootFile);
+ strcpy(nfs_path, BootFile);
}
}
- nfs_filename = basename (nfs_path);
- nfs_path = dirname (nfs_path);
+ nfs_filename = basename(nfs_path);
+ nfs_path = dirname(nfs_path);
- printf ("Using %s device\n", eth_get_name());
+ printf("Using %s device\n", eth_get_name());
printf("File transfer via NFS from server %pI4"
"; our IP address is %pI4", &NfsServerIP, &NetOurIP);
@@ -725,19 +722,20 @@ NfsStart (void)
IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask;
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);
if (NetBootFileSize) {
- printf (" Size is 0x%x Bytes = ", NetBootFileSize<<9);
- print_size (NetBootFileSize<<9, "");
+ printf(" Size is 0x%x Bytes = ", NetBootFileSize<<9);
+ print_size(NetBootFileSize<<9, "");
}
- printf ("\nLoad address: 0x%lx\n"
+ printf("\nLoad address: 0x%lx\n"
"Loading: *\b", load_addr);
- NetSetTimeout (NFS_TIMEOUT, NfsTimeout);
- NetSetHandler (NfsHandler);
+ NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
+ NetSetHandler(NfsHandler);
NfsTimeoutCount = 0;
NfsState = STATE_PRCLOOKUP_PROG_MOUNT_REQ;
@@ -747,7 +745,7 @@ NfsStart (void)
NfsOurPort = 1000;
/* zero out server ether in case the server ip has changed */
- memset (NetServerEther, 0, 6);
+ memset(NetServerEther, 0, 6);
- NfsSend ();
+ NfsSend();
}
diff --git a/net/nfs.h b/net/nfs.h
index de8a0c6..a5a1b43 100644
--- a/net/nfs.h
+++ b/net/nfs.h
@@ -72,7 +72,7 @@ struct rpc_t {
} reply;
} u;
};
-extern void NfsStart (void); /* Begin NFS */
+extern void NfsStart(void); /* Begin NFS */
/**********************************************************************/
diff --git a/net/rarp.c b/net/rarp.c
index 097f970..5a813a2 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -58,21 +58,21 @@ static void
RarpTimeout(void)
{
if (RarpTry >= TIMEOUT_COUNT) {
- puts ("\nRetry count exceeded; starting again\n");
- NetStartAgain ();
+ puts("\nRetry count exceeded; starting again\n");
+ NetStartAgain();
} else {
- NetSetTimeout (TIMEOUT, RarpTimeout);
- RarpRequest ();
+ NetSetTimeout(TIMEOUT, RarpTimeout);
+ RarpRequest();
}
}
void
-RarpRequest (void)
+RarpRequest(void)
{
int i;
- volatile uchar *pkt;
- ARP_t * rarp;
+ uchar *pkt;
+ ARP_t *rarp;
printf("RARP broadcast %d\n", ++RarpTry);
pkt = NetTxPacket;
@@ -81,18 +81,18 @@ RarpRequest (void)
rarp = (ARP_t *)pkt;
- rarp->ar_hrd = htons (ARP_ETHER);
- rarp->ar_pro = htons (PROT_IP);
+ rarp->ar_hrd = htons(ARP_ETHER);
+ rarp->ar_pro = htons(PROT_IP);
rarp->ar_hln = 6;
rarp->ar_pln = 4;
- rarp->ar_op = htons (RARPOP_REQUEST);
- memcpy (&rarp->ar_data[0], NetOurEther, 6); /* source ET addr */
- memcpy (&rarp->ar_data[6], &NetOurIP, 4); /* source IP addr */
- memcpy (&rarp->ar_data[10], NetOurEther, 6); /* dest ET addr = source ET addr ??*/
+ rarp->ar_op = htons(RARPOP_REQUEST);
+ memcpy(&rarp->ar_data[0], NetOurEther, 6); /* source ET addr */
+ memcpy(&rarp->ar_data[6], &NetOurIP, 4); /* source IP addr */
+ /* dest ET addr = source ET addr ??*/
+ memcpy(&rarp->ar_data[10], NetOurEther, 6);
/* dest. IP addr set to broadcast */
- for (i = 0; i <= 3; i++) {
+ for (i = 0; i <= 3; i++)
rarp->ar_data[16 + i] = 0xff;
- }
NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
diff --git a/net/rarp.h b/net/rarp.h
index 0c16d46..4e92d80 100644
--- a/net/rarp.h
+++ b/net/rarp.h
@@ -35,9 +35,9 @@
* Global functions and variables.
*/
-extern int RarpTry;
+extern int RarpTry;
-extern void RarpRequest (void); /* Send a RARP request */
+extern void RarpRequest(void); /* Send a RARP request */
/**********************************************************************/
diff --git a/net/sntp.c b/net/sntp.c
index 82f2fe6..69cddb1 100644
--- a/net/sntp.c
+++ b/net/sntp.c
@@ -17,7 +17,7 @@
static int SntpOurPort;
static void
-SntpSend (void)
+SntpSend(void)
{
struct sntp_pkt_t pkt;
int pktlen = SNTP_PACKET_LEN;
@@ -25,24 +25,26 @@ SntpSend (void)
debug("%s\n", __func__);
- memset (&pkt, 0, sizeof(pkt));
+ memset(&pkt, 0, sizeof(pkt));
pkt.li = NTP_LI_NOLEAP;
pkt.vn = NTP_VERSION;
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);
sport = NTP_SERVICE_PORT;
- NetSendUDPPacket (NetServerEther, NetNtpServerIP, sport, SntpOurPort, pktlen);
+ NetSendUDPPacket(NetServerEther, NetNtpServerIP, sport, SntpOurPort,
+ pktlen);
}
static void
-SntpTimeout (void)
+SntpTimeout(void)
{
- puts ("Timeout\n");
+ puts("Timeout\n");
NetState = NETLOOP_FAIL;
return;
}
@@ -57,19 +59,20 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
debug("%s\n", __func__);
- if (dest != SntpOurPort) return;
+ if (dest != SntpOurPort)
+ return;
/*
* As the RTC's used in U-Boot sepport second resolution only
* we simply ignore the sub-second field.
*/
- memcpy (&seconds, &rpktp->transmit_timestamp, sizeof(ulong));
+ memcpy(&seconds, &rpktp->transmit_timestamp, sizeof(ulong));
to_tm(ntohl(seconds) - 2208988800UL + NetTimeOffset, &tm);
#if defined(CONFIG_CMD_DATE)
- rtc_set (&tm);
+ rtc_set(&tm);
#endif
- printf ("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n",
+ printf("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
@@ -77,13 +80,13 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
}
void
-SntpStart (void)
+SntpStart(void)
{
debug("%s\n", __func__);
- NetSetTimeout (SNTP_TIMEOUT, SntpTimeout);
+ NetSetTimeout(SNTP_TIMEOUT, SntpTimeout);
NetSetHandler(SntpHandler);
- memset (NetServerEther, 0, 6);
+ memset(NetServerEther, 0, sizeof(NetServerEther));
- SntpSend ();
+ SntpSend();
}
diff --git a/net/sntp.h b/net/sntp.h
index 8a097bf..1d0046e 100644
--- a/net/sntp.h
+++ b/net/sntp.h
@@ -56,6 +56,6 @@ struct sntp_pkt_t {
unsigned long long transmit_timestamp;
};
-extern void SntpStart (void); /* Begin SNTP */
+extern void SntpStart(void); /* Begin SNTP */
#endif /* __SNTP_H__ */
diff --git a/net/tftp.c b/net/tftp.c
index 7aa3e23..bc7fe05 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -11,6 +11,9 @@
#include <net.h>
#include "tftp.h"
#include "bootp.h"
+#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
+#include <flash.h>
+#endif
/* Well known TFTP port # */
#define WELL_KNOWN_PORT 69
@@ -112,10 +115,6 @@ static char default_filename[DEFAULT_NAME_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.
* 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.
@@ -137,7 +136,6 @@ static unsigned *Bitmap;
static int PrevBitmapHole, Mapsize = MTFTP_BITMAPSIZE;
static uchar ProhibitMcast, MasterClient;
static uchar Multicast;
-extern IPaddr_t Mcast_addr;
static int Mcast_port;
static ulong TftpEndingBlock; /* can get 'last' block before done..*/
@@ -157,7 +155,7 @@ mcast_cleanup(void)
#endif /* CONFIG_MCAST_TFTP */
-static __inline__ void
+static inline void
store_block(unsigned block, uchar *src, unsigned len)
{
ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
@@ -182,8 +180,7 @@ store_block(unsigned block, uchar *src, unsigned len)
NetState = NETLOOP_FAIL;
return;
}
- }
- else
+ } else
#endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
{
(void)memcpy((void *)(load_addr + offset), src, len);
@@ -310,9 +307,9 @@ static void
TftpSend(void)
{
uchar *pkt;
- volatile uchar *xp;
- int len = 0;
- volatile ushort *s;
+ uchar *xp;
+ int len = 0;
+ ushort *s;
#ifdef CONFIG_MCAST_TFTP
/* Multicast TFTP.. non-MasterClients do not ACK data. */
@@ -357,12 +354,14 @@ TftpSend(void)
0, TftpBlkSizeOption, 0);
#ifdef CONFIG_MCAST_TFTP
/* Check all preconditions before even trying the option */
- if (!ProhibitMcast
- && (Bitmap = malloc(Mapsize))
- && eth_get_dev()->mcast) {
- free(Bitmap);
- Bitmap = NULL;
- pkt += sprintf((char *)pkt, "multicast%c%c", 0, 0);
+ if (!ProhibitMcast) {
+ Bitmap = malloc(Mapsize);
+ if (Bitmap && eth_get_dev()->mcast) {
+ free(Bitmap);
+ Bitmap = NULL;
+ pkt += sprintf((char *)pkt, "multicast%c%c",
+ 0, 0);
+ }
}
#endif /* CONFIG_MCAST_TFTP */
len = pkt - xp;
@@ -630,8 +629,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
mcast_cleanup();
NetState = NETLOOP_SUCCESS;
}
- }
- else
+ } else
#endif
if (len < TftpBlkSize)
tftp_complete();
diff --git a/net/tftp.h b/net/tftp.h
index c51aa25..18e4c9c 100644
--- a/net/tftp.h
+++ b/net/tftp.h
@@ -19,7 +19,7 @@
void TftpStart(enum proto_t protocol); /* Begin TFTP get/put */
#ifdef CONFIG_CMD_TFTPSRV
-extern void TftpStartServer(void); /* Wait for incoming TFTP put */
+extern void TftpStartServer(void); /* Wait for incoming TFTP put */
#endif
/**********************************************************************/