From: Stefan E. <se...@us...> - 2003-03-18 16:24:23
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv17325 Modified Files: system3.c Log Message: - bootp, arp and tftp test commands. They'll probably go into src/commands. They need some fleshing out, IP addresses and so on are hard-coded ATM. This is Work In Progress, so YMMV etc. Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/system3.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- system3.c 13 Feb 2003 01:10:53 -0000 1.25 +++ system3.c 18 Mar 2003 16:24:18 -0000 1.26 @@ -55,6 +55,7 @@ #include <blob/cf.h> #include <blob/ide.h> #include <blob/tar.h> +#include <net/smc9196.h> /********************************************************************** * defines @@ -218,8 +219,6 @@ * static functions */ static char module_version[] = "$Id$"; -static void dumpmem(char *ptr, int len); -static char tohex(char b); static void sa1111_init(); /********************************************************************* @@ -342,6 +341,7 @@ sys3_dbg = lvl; printf( "sys3dbg: debug level set to %d\n", sys3_dbg ); +#if 0 if ( lvl>5 ) { cf_dbg_set( 5 ); tar_dbg_set( 5 ); @@ -357,6 +357,7 @@ io_dbg_set( 0 ); pcmcia_dbg_set( 0 ); } +#endif return 0; } @@ -827,41 +828,6 @@ /***************************************************************** * misc utility funcs */ -#if 0 -static char tohex(char b) -{ - b = b & 0xf; - if (b < 10) return '0' + b; - return 'a' + (b - 10); -} - -static void dumpmem(char *ptr, int len) -{ - char line[80], chars[80], *p, b, *c, *end; - int j; - - end = ptr + len; - while (ptr < end) { - SerialOutputHex((int)ptr); - p = line; - c = chars; - - *p++ = ' '; - for (j = 0; j < 16; j++) { - b = *ptr++; - *p++ = tohex(b >> 4); - *p++ = tohex(b); - *p++ = ' '; - *c++ = ' ' <= b && b <= '~' ? b : '.'; - } - *p = 0; - SerialOutputString(line); - *c = 0; - SerialOutputString(chars); - serial_write('\n'); - } -} -#endif /***************************************************************** * manually reference flash and download commands until they @@ -886,3 +852,97 @@ extern int dlfile_cmd(int argc, char *argv[]); extern char dlfile_help[]; __commandlist(dlfile_cmd, "dlfile", dlfile_help); + +int bootp_cmd(int argc, char *argv[]) +{ + int ret = 0; + char *file; + extern char *do_bootp(void); + + ret = smc_init( 0x18000000 ); + if ( ret ) { + printf( "smc_init failed: %d\n", ret ); + return ret; + } + + file = do_bootp(); + + if ( file ) + printf( "TFTP File: '%s'\n", file ); + + return 0; +} +char bootp_help[] = "bootp test command. No args.\n";; +__commandlist(bootp_cmd, "net_bootp", bootp_help); + +int arp_cmd(int argc, char *argv[]) +{ + int ret = 0; + extern int do_arp( u8 *, u8 *); + extern u8 clientipaddress[4]; + u8 serverip[4] = { 192, 168, 1, 11 }; + u8 servereth[6]; + + ret = smc_init( 0x18000000 ); + if ( ret ) { + printf( "smc_init failed: %d\n", ret ); + return ret; + } + + clientipaddress[0]=192; + clientipaddress[1]=168; + clientipaddress[2]=1; + clientipaddress[3]=191; + + ret = do_arp( servereth, serverip ); + + printf( "%s: got eth addr %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, + servereth[0], servereth[1], servereth[2], servereth[3], servereth[4], + servereth[5] ); + + return 0; +} +char arp_help[] = "arp test command. No args.\n";; +__commandlist(arp_cmd, "arp", arp_help); + + +int tftp_cmd(int argc, char *argv[]) +{ + int ret = 0; + extern int do_tftp(char *file, unsigned long addr, unsigned long *size); + extern u8 clientipaddress[4]; + extern u8 serveripaddress[4]; + unsigned long size = 0; + char *tftp_file = "zImage"; + + if ( argc>1 ) { + tftp_file = argv[1]; + } + + ret = smc_init( 0x18000000 ); + if ( ret ) { + printf( "smc_init failed: %d\n", ret ); + return ret; + } + + clientipaddress[0]=192; + clientipaddress[1]=168; + clientipaddress[2]=1; + clientipaddress[3]=191; + + serveripaddress[0]=192; + serveripaddress[1]=168; + serveripaddress[2]=1; + serveripaddress[3]=2; + + ret = do_tftp( tftp_file, KERNEL_RAM_BASE, &size ); + if ( ret ) { + return -EINVAL; + } + + printf( "%s: file '%s' loaded via tftp to address 0x%08x.\n", + __FUNCTION__, tftp_file, KERNEL_RAM_BASE ); + return 0; +} +char tftp_help[] = "tftp test command. No args.\n";; +__commandlist(tftp_cmd, "tftp", tftp_help); |