You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(79) |
Aug
(27) |
Sep
(64) |
Oct
(202) |
Nov
(31) |
Dec
(59) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(125) |
Feb
(173) |
Mar
(13) |
Apr
(140) |
May
(75) |
Jun
(1) |
Jul
(37) |
Aug
(14) |
Sep
|
Oct
(20) |
Nov
(9) |
Dec
(2) |
2003 |
Jan
(51) |
Feb
(12) |
Mar
(18) |
Apr
(24) |
May
(1) |
Jun
|
Jul
|
Aug
(72) |
Sep
(12) |
Oct
(18) |
Nov
(60) |
Dec
(26) |
2004 |
Jan
(1) |
Feb
(40) |
Mar
(3) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(4) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(5) |
2006 |
Jan
(13) |
Feb
(5) |
Mar
(8) |
Apr
(13) |
May
(7) |
Jun
(6) |
Jul
(10) |
Aug
(6) |
Sep
(6) |
Oct
(35) |
Nov
(20) |
Dec
(10) |
2007 |
Jan
(13) |
Feb
(9) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(2) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(54) |
Jun
(78) |
Jul
(35) |
Aug
(21) |
Sep
(21) |
Oct
(29) |
Nov
(10) |
Dec
(5) |
2010 |
Jan
|
Feb
|
Mar
(26) |
Apr
(55) |
May
(73) |
Jun
(63) |
Jul
(38) |
Aug
(39) |
Sep
(19) |
Oct
(2) |
Nov
(1) |
Dec
(1) |
2011 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Stefan E. <se...@us...> - 2003-04-01 19:01:37
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv7243 Modified Files: system3.c Log Message: - sysver command now prints board revision and type - setip command to set server/client ip for tftp - tftp command reworked. Now download to unused RAM instead to KERNEL_RAM_BASE. Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/system3.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- system3.c 18 Mar 2003 16:24:18 -0000 1.26 +++ system3.c 1 Apr 2003 19:01:29 -0000 1.27 @@ -237,7 +237,7 @@ static void system3_init_hardware(void) { /* init on-board CPLD */ - MEM(SYSTEM3_CTRL_0) = 0x0b; + MEM(SYSTEM3_CTRL_0) = 0x03; MEM(SYSTEM3_CTRL_1) = 0x00; MEM(SYSTEM3_CTRL_2) = 0x00; @@ -320,6 +320,22 @@ static int sysver_cmd( int argc, char *argv[] ) { printf( "version: '%s'\n", module_version ); + switch ( PT_ID_BOARDID ) { + case PT_BOARD_ALPHA: + printf( "ALPHA Board" ); + break; + case PT_BOARD_SYS3: + printf( "SYSTEM 3 Board" ); + break; + case PT_BOARD_DAFIT: + printf( "DAFIT Board" ); + break; + default: + printf( "UNKNOWN Board (ID 0x%X)", PT_ID_BOARDID ); + break; + + } + printf( " revision 0x%02X.\n", PT_ID_REVISION ); return 0; } static char sysver_help[] = "print BLOB and system3 version number\n"; @@ -339,9 +355,8 @@ if ( ret < 0 ) return -EINVAL; sys3_dbg = lvl; - printf( "sys3dbg: debug level set to %d\n", sys3_dbg ); -#if 0 +#if defined(CONFIG_PCMCIA_SUPPORT) if ( lvl>5 ) { cf_dbg_set( 5 ); tar_dbg_set( 5 ); @@ -359,6 +374,7 @@ } #endif + printf( "sys3dbg: debug level set to %d\n", sys3_dbg ); return 0; } static char sys3dbg_help[] = "sys3dbg level\n"; @@ -370,6 +386,9 @@ static void sa1111_init() { + if ( PT_ID_BOARDID == PT_BOARD_DAFIT ) + return; + /* * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111: * (SA-1110 Developer's Manual, section 9.1.2.1) @@ -879,7 +898,6 @@ { int ret = 0; extern int do_arp( u8 *, u8 *); - extern u8 clientipaddress[4]; u8 serverip[4] = { 192, 168, 1, 11 }; u8 servereth[6]; @@ -889,11 +907,6 @@ 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__, @@ -906,17 +919,77 @@ __commandlist(arp_cmd, "arp", arp_help); +int setip_cmd( int argc, char *argv[] ) +{ + extern u8 clientipaddress[4]; + extern u8 serveripaddress[4]; + u8 *ip; + char *ptr, *num; + int i, fini; + + if ( argc < 3 ) + return -EINVAL; + + switch ( argv[1][0] ) { + case 'c': + case 'C': + ip = clientipaddress; + break; + case 's': + case 'S': + ip = serveripaddress; + break; + default: + return -EINVAL; + break; + } + + num = ptr = argv[2]; + fini=0; + for ( i=0; i<4 || !fini; i++ ) { + u32 n; + + while ( *ptr != '\0' && *ptr != '.' ) + ptr++; + + if ( *ptr == '\0' ) + fini = 1; + + *ptr = 0; + + strtou32( num, &n ); + ip[i]=n; + + num = ++ptr; + } + + if ( fini && i<4 ) { + printf( "error parsing ip.\n" ); + return -EINVAL; + } + + printf( "Set IP to %d.%d.%d.%d\n", + ip[0], ip[1], ip[2], ip[3] ); + + return 0; +} +char setip_help[] = "setip command. Set IP addresses for tftp.\n" +"usage: setip {client|server} ip\n" +"\tip in usual dotted-quad format please.\n";; +__commandlist(setip_cmd, "setip", setip_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"; + char *tftp_file = "update.tar"; if ( argc>1 ) { tftp_file = argv[1]; + } else { + printf( "No filename given, using '%s'\n", + tftp_file ); } ret = smc_init( 0x18000000 ); @@ -925,24 +998,17 @@ 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 ); + ret = do_tftp( tftp_file, RAM_START, &size ); if ( ret ) { return -EINVAL; } printf( "%s: file '%s' loaded via tftp to address 0x%08x.\n", - __FUNCTION__, tftp_file, KERNEL_RAM_BASE ); + __FUNCTION__, tftp_file, RAM_START ); return 0; } -char tftp_help[] = "tftp test command. No args.\n";; +char tftp_help[] = "tftp command.\n" +"usage: tftp filename\n" +"\tdownloads file over TFTP to RAM.\n" +"\tUse setip to set client and server IP addresses\n"; __commandlist(tftp_cmd, "tftp", tftp_help); |
From: Stefan E. <se...@us...> - 2003-04-01 18:58:59
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv5678 Modified Files: memsetup-sa1110.S Log Message: - defines to enable full speed memory clocks. This wont change anything for platforms not using the define. The default is still the slow setting. Index: memsetup-sa1110.S =================================================================== RCS file: /cvsroot/blob/blob/src/blob/memsetup-sa1110.S,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- memsetup-sa1110.S 11 Feb 2003 00:02:47 -0000 1.17 +++ memsetup-sa1110.S 1 Apr 2003 18:58:55 -0000 1.18 @@ -173,9 +173,18 @@ ldr r2, [ r0, #_MDREFR ] orr r2, r2, #MDREFR_TRASR(7) orr r2, r2, #MDREFR_DRI(12) + /* only set DB2 bits when _not_ running + * the SDRAM at full clock speed + */ +#ifndef MDREFR_MEMCLK_FULLSPEED_0 orr r2, r2, #MDREFR_K0DB2 +#endif +#ifndef MDREFR_MEMCLK_FULLSPEED_1 orr r2, r2, #MDREFR_K1DB2 +#endif +#ifndef MDREFR_MEMCLK_FULLSPEED_2 orr r2, r2, #MDREFR_K2DB2 +#endif str r2, [ r0, #_MDREFR ] /* set KxRUN */ |
From: Stefan E. <se...@us...> - 2003-04-01 18:55:23
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv4059 Modified Files: arp.c ip_bits.c Log Message: - implemented ARP replies, otherwise tftp stalls. Index: arp.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/arp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- arp.c 18 Mar 2003 16:20:50 -0000 1.2 +++ arp.c 1 Apr 2003 18:55:19 -0000 1.3 @@ -14,6 +14,14 @@ #include <net/ether.h> #include <net/arp.h> +#undef ARP_DEBUG +#ifdef ARP_DEBUG +static int dbg = 1; +# define DBG( x, args... ) if ( dbg>=x ) printf( args ) +#else +# define DBG( x, args... ) ; +#endif + static const unsigned char arp_txpacket[] = { /* destination address */ /* source address */ @@ -73,4 +81,73 @@ } while (--retry); return -1; +} + +int do_arp_reply(unsigned char *rx_pkt, unsigned int size) +{ + struct ether_hdr *eth_request = (struct ether_hdr *)rx_pkt; + struct arp_packet *request = (struct arp_packet *)(rx_pkt+sizeof(struct ether_hdr)); + u8 bcast[6] = { [0 ... 5] 0xff }; + struct arp_packet reply = { + .hw_type = HTON( 0x0001 ), + .proto_type = HTON( 0x0800 ), + .hw_len = 6, + .proto_len = 4, + .opcode = HTON( 0x0002 ) + }; + struct ether_hdr eth_reply; + + DBG( 1, "%s: ETH: %02x:%02x:%02x:%02x:%02x:%02x" + " %02x:%02x:%02x:%02x:%02x:%02x proto 0x%04x\n", __FUNCTION__, + eth_request->dest[0], eth_request->dest[1], eth_request->dest[2], + eth_request->dest[3], eth_request->dest[4], eth_request->dest[5], + eth_request->src[0], eth_request->src[1], eth_request->src[2], + eth_request->src[3], eth_request->src[4], eth_request->src[5], + HTON( eth_request->proto )); + + + /* is it for us or broadcast? */ + if ( !memeq( eth_request->dest, hwaddress, 6 ) && !memeq( eth_request->dest, bcast, 6 )) + return -1; + + DBG( 1, "%s: opcode 0x%04x\n", __FUNCTION__, HTON( request->opcode ) ); + + /* is it an arp request? */ + if ( request->opcode != HTON( 0x0001 ) ) + return -1; + + DBG( 1, "%s: got an arp request from IP %d.%d.%d.%d requesting %d.%d.%d.%d\n", __FUNCTION__, + request->sender.ip[0], + request->sender.ip[1], + request->sender.ip[2], + request->sender.ip[3], + request->target.ip[0], + request->target.ip[1], + request->target.ip[2], + request->target.ip[3] + ); + + /* requesting our IP ? */ + if ( !memeq( request->target.ip, clientipaddress, 4 )) + return -1; + + DBG( 1, "%s: arp request for our IP\n", __FUNCTION__ ); + + /* ethernet header */ + eth_reply.proto = HTON( 0x0806 ); /* ARP */ + memcpy( eth_reply.dest, eth_request->src, 6 ); + memcpy( eth_reply.src, hwaddress, 6 ); + + /* arp reply */ + memcpy(reply.sender.hw, hwaddress, 6); + memcpy(reply.sender.ip, clientipaddress, 4); + memcpy(reply.target.hw, request->sender.hw, 6); + memcpy(reply.target.ip, request->sender.ip, 4); + + memzero(arp_tx, sizeof(arp_tx)); + memcpy(arp_tx, ð_reply, sizeof(struct ether_hdr)); + memcpy(arp_tx + sizeof(struct ether_hdr), &reply, sizeof(struct arp_packet)); + + writeether(arp_tx, sizeof(arp_tx)); + return 0; } Index: ip_bits.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/ip_bits.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ip_bits.c 18 Mar 2003 16:20:49 -0000 1.2 +++ ip_bits.c 1 Apr 2003 18:55:19 -0000 1.3 @@ -11,6 +11,7 @@ #include <serial.h> #include <net/net.h> #include <net/ether.h> +#include <net/arp.h> #include <net/ip_bits.h> unsigned long ip_sequence = 0; @@ -72,9 +73,21 @@ return writeether (ptr, size + OFF_UDP); } +/* handle broadcast packets. For arp requests */ +int do_bcast( unsigned char *ptr, unsigned int size ) +{ + /* check whether or not ARP proto */ + if (((ptr[OFF_ETHER + 12] << 8) | ptr[OFF_ETHER + 13]) != 0x0806) + return 0; /* not ARP */ + + /* ok, its an arp. handle it. */ + return do_arp_reply( ptr, size ); +} + int ipbits_rcv (unsigned char *ptr, unsigned int size, unsigned int *dsz, int sport, int dport) { unsigned int cksum, hdrlen, off_udp; + u8 bcast[6] = { [0 ... 5] 0xff }; size = readether(ptr, size); if (!size) @@ -82,6 +95,10 @@ if (size < MIN_UDPPKTSIZE) /* must be at least this size for UDP */ return 0; + + if (memeq (ptr + OFF_ETHER, bcast, 6)) { + return do_bcast( ptr, size ); + } if (!memeq (ptr + OFF_ETHER, hwaddress, 6)) return 0; /* not for us */ |
From: Stefan E. <se...@us...> - 2003-04-01 18:50:06
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv369 Modified Files: arp.h ether.h Log Message: - packet header structs. Tired of counting byte offsets ;) Index: arp.h =================================================================== RCS file: /cvsroot/blob/blob/include/net/arp.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- arp.h 18 Mar 2003 16:18:53 -0000 1.2 +++ arp.h 1 Apr 2003 18:50:01 -0000 1.3 @@ -8,6 +8,21 @@ * published by the Free Software Foundation. */ +struct arp_ethernet { + unsigned char hw[6]; + unsigned char ip[4]; +} __attribute__ ((packed)); + +struct arp_packet { + unsigned short hw_type; + unsigned short proto_type; + unsigned char hw_len; + unsigned char proto_len; + unsigned short opcode; + struct arp_ethernet sender; + struct arp_ethernet target; +} __attribute__ ((packed)); + /********************************************************************** * do_arp - send ARP request to server * @thwaddr: the target HW address we received @@ -17,3 +32,5 @@ * ethernet HW address <thwaddr> for the IP address <tipaddr>. */ int do_arp(unsigned char *thwaddr, unsigned char *tipaddr); + +int do_arp_reply(unsigned char *rx_pkt, unsigned int size); Index: ether.h =================================================================== RCS file: /cvsroot/blob/blob/include/net/ether.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ether.h 18 Mar 2003 16:18:54 -0000 1.2 +++ ether.h 1 Apr 2003 18:50:01 -0000 1.3 @@ -11,6 +11,14 @@ #ifndef _BLOB_ETHER_H #define _BLOB_ETHER_H 1 +struct ether_hdr { + unsigned char dest[6]; + unsigned char src[6]; + unsigned short proto; +} __attribute__ ((packed)); + +#define HTON( s ) ( ((s&0xff00)>>8 ) | ((s&0xff)<<8) ) + /********************************************************************** * writeether - send a ethernet packet * @buf: the packet |
From: Stefan E. <se...@us...> - 2003-03-18 17:38:47
|
Update of /cvsroot/blob/blob/include In directory sc8-pr-cvs1:/tmp/cvs-serv19512/include Modified Files: Makefile.am Log Message: - added --enable-network configure option. Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/include/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile.am 7 Oct 2001 15:17:49 -0000 1.9 +++ Makefile.am 18 Mar 2003 17:38:14 -0000 1.10 @@ -12,7 +12,8 @@ SUBDIRS = \ - blob + blob \ + net CLEANFILES = *~ |
From: Stefan E. <se...@us...> - 2003-03-18 17:38:47
|
Update of /cvsroot/blob/blob In directory sc8-pr-cvs1:/tmp/cvs-serv19512 Modified Files: acconfig.h configure.in Log Message: - added --enable-network configure option. Index: acconfig.h =================================================================== RCS file: /cvsroot/blob/blob/acconfig.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- acconfig.h 26 Nov 2002 18:52:52 -0000 1.23 +++ acconfig.h 18 Mar 2003 17:38:14 -0000 1.24 @@ -143,6 +143,9 @@ /* Define if zImage support is wanted */ #undef CONFIG_ZIMAGE_SUPPORT +/* Define if network support is wanted */ +#undef CONFIG_NETWORK_SUPPORT + @BOTTOM@ #endif Index: configure.in =================================================================== RCS file: /cvsroot/blob/blob/configure.in,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- configure.in 13 Feb 2003 01:10:52 -0000 1.60 +++ configure.in 18 Mar 2003 17:38:14 -0000 1.61 @@ -325,6 +325,7 @@ AC_DEFINE(PT_SYSTEM3) BLOB_PLATFORM_OBJS="system3.o" BLOB_LED_DRIVER_OBJS="led-sa11x0.o" + BLOB_NETWORK_DRIVER_OBJS="smc9196.o" BLOB_LED_STARTCODE="ledasm-sa11x0.o" BLOB_FLASH_OBJS="intel32.o" DIAG_PLATFORM_OBJS="system3.o" @@ -399,6 +400,7 @@ AC_SUBST(BLOB_SERIAL_DRIVER_OBJS) AC_SUBST(BLOB_LED_STARTCODE) AC_SUBST(BLOB_LED_DRIVER_OBJS) +AC_SUBST(BLOB_NETWORK_DRIVER_OBJS) @@ -502,6 +504,11 @@ [zimage_flag=$enable_zimage], [zimage_flag=no]) +AC_ARG_ENABLE(network, +[ --enable-network Enable networking (bootp/tftp)], +[network_flag=$enable_network], +[network_flag=no]) + @@ -521,6 +528,7 @@ jffs2_flag=yes cramfs_flag=yes zimage_flag=yes + network_flag=yes fi @@ -627,6 +635,13 @@ AC_SUBST(BLOB_ZIMAGE_OBJS) +dnl Check wether or not network support is wanted +if test "x$network_flag" = "xyes" ; then + BLOB_NETWORK_OBJS="bootp.o arp.o tftp.o ip_bits.o" + AC_DEFINE(CONFIG_NETWORK_SUPPORT) +fi +AC_SUBST(BLOB_NETWORK_OBJS) + dnl Check for extra debug info @@ -706,6 +721,7 @@ include/Makefile include/blob/Makefile include/blob/arch/Makefile +include/net/Makefile src/Makefile src/blob/Makefile src/commands/Makefile @@ -738,6 +754,7 @@ echo "JFFS2 support ${jffs2_flag}" echo "cramfs support ${cramfs_flag}" echo "zImage support ${zimage_flag}" +echo "Network support ${network_flag}" echo "Blob commands: ${BLOB_COMMANDS}" echo "Run-time debug information ${blob_debug_flag}" echo "" |
From: Stefan E. <se...@us...> - 2003-03-18 17:38:20
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv19512/src/lib Modified Files: Makefile.am Log Message: - added --enable-network configure option. Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Makefile.am 17 Mar 2003 14:57:24 -0000 1.25 +++ Makefile.am 18 Mar 2003 17:38:16 -0000 1.26 @@ -30,8 +30,8 @@ crc32.c \ error.c \ ext2fs.c \ - i2c.c \ i2c-gpio.c \ + i2c.c \ icache.c \ init.c \ led.c \ @@ -44,9 +44,9 @@ printf.c \ reboot.c \ serial.c \ - strncpy.c \ strlen.c \ strncmp.c \ + strncpy.c \ strtou32.c \ time.c \ util.c @@ -57,18 +57,24 @@ reboot-pxa.c \ reboot-sa11x0.c \ serial-pxa.c \ - serial-sa11x0.c + serial-sa11x0.c \ + arp.c \ + bootp.c \ + tftp.c \ + ip_bits.c libblob_a_DEPENDENCIES = \ @BLOB_REBOOT_DRIVER_OBJS@ \ @BLOB_SERIAL_DRIVER_OBJS@ \ - @BLOB_LED_DRIVER_OBJS@ + @BLOB_LED_DRIVER_OBJS@ \ + @BLOB_NETWORK_OBJS@ libblob_a_LIBADD = \ @BLOB_REBOOT_DRIVER_OBJS@ \ @BLOB_SERIAL_DRIVER_OBJS@ \ - @BLOB_LED_DRIVER_OBJS@ + @BLOB_LED_DRIVER_OBJS@ \ + @BLOB_NETWORK_OBJS@ INCLUDES += \ -I${top_builddir}/include \ |
From: Stefan E. <se...@us...> - 2003-03-18 17:38:20
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv19512/src/blob Modified Files: Makefile.am Log Message: - added --enable-network configure option. Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- Makefile.am 13 Feb 2003 01:10:52 -0000 1.37 +++ Makefile.am 18 Mar 2003 17:38:15 -0000 1.38 @@ -85,6 +85,7 @@ compr_rtime.c compr_rubin.c jffs2.c \ uucodec.c \ xmodem.c \ + smc9196.c \ accelent_sa.c assabet.c brutus.c badge4.c cep.c clart.c frodo.c \ hackkit.c h3600.c idr.c jornada720.c lart.c miniprint.c nesa.c pleb.c \ shannon.c system3.c trizeps.c pxa_idp.c @@ -100,6 +101,7 @@ @BLOB_PLATFORM_OBJS@ \ @BLOB_UUCODEC_OBJS@ \ @BLOB_XMODEM_OBJS@ \ + @BLOB_NETWORK_DRIVER_OBJS@ \ ${top_builddir}/src/commands/libcommands.a \ ${top_builddir}/src/lib/libblob.a \ rest-ld-script @@ -119,6 +121,7 @@ @BLOB_PLATFORM_OBJS@ \ @BLOB_UUCODEC_OBJS@ \ @BLOB_XMODEM_OBJS@ \ + @BLOB_NETWORK_DRIVER_OBJS@ \ -L${top_builddir}/src/commands -L${top_builddir}/src/lib \ -lcommands -lblob \ -lgcc |
From: Stefan E. <se...@us...> - 2003-03-18 17:38:18
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv19512/include/net Added Files: Makefile.am Log Message: - added --enable-network configure option. --- NEW FILE: Makefile.am --- # -*- makefile -*- ########################################################################### ## Filename: Makefile.am ## Version: $Id: Makefile.am,v 1.1 2003/03/18 17:38:14 seletz Exp $ ## Copyright: Copyright (C) 2003, Stefan Eletzhofer ## Author: Stefan Eletzhofer <ste...@el...> ########################################################################### noinst_HEADERS = \ arp.h \ ether.h \ ip_bits.h \ net.h \ smc9196.h \ tftp.h CLEANFILES = ${srcdir}/*~ |
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); |
From: Stefan E. <se...@us...> - 2003-03-18 16:22:12
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv16932 Modified Files: smc9196.c Log Message: - re-enabled status checking on receive Index: smc9196.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/smc9196.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- smc9196.c 18 Mar 2003 11:12:28 -0000 1.1 +++ smc9196.c 18 Mar 2003 16:22:09 -0000 1.2 @@ -680,7 +680,8 @@ memcpy( buf+6, hwaddress, 6 ); -#ifdef SMC_DEBUG +//#ifdef SMC_DEBUG +#if 0 printf( "%s: tx packet (%d bytes):\n", __FUNCTION__, size ); hexdump( buf, size ); #endif @@ -699,9 +700,9 @@ goto done; } - //mask = smc_inb(smc_chip_base, INT_MASK); + mask = smc_inb(smc_chip_base, INT_MASK); /* clear all interrupts */ - //SMC_SET_INT( smc_chip_base, 0); + SMC_SET_INT( smc_chip_base, 0); /* read the status flag, and mask it */ status = smc_inb(smc_chip_base, INTERRUPT) & mask; @@ -709,15 +710,16 @@ ret = 0; } else if ( status & IM_RCV_INT ) { ret = smc_rcv( smc_chip_base, buf, size ); -#ifdef SMC_DEBUG +//#ifdef SMC_DEBUG +#if 0 printf( "%s: rx packet (%d bytes):\n", __FUNCTION__, size ); - hexdump( buf, size ); + hexdump( buf, size>0x80?0x80:size ); #endif } /* restore state register */ - //SMC_SELECT_BANK( smc_chip_base, 2); - //SMC_SET_INT(smc_chip_base, mask); + SMC_SELECT_BANK( smc_chip_base, 2); + SMC_SET_INT(smc_chip_base, mask); done: return ret; } |
From: Stefan E. <se...@us...> - 2003-03-18 16:20:58
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16301 Modified Files: tftp.c ip_bits.c bootp.c arp.c Log Message: - updated to use new net/net.h include Index: tftp.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/tftp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tftp.c 18 Mar 2003 15:05:07 -0000 1.2 +++ tftp.c 18 Mar 2003 16:20:49 -0000 1.3 @@ -7,17 +7,13 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -//#include "init.h" #include <util.h> #include <serial.h> +#include <net/net.h> #include <net/ip_bits.h> #include <net/arp.h> - -#define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) -#define memzero( x, s ) memset((x), 0, (s)) -#define printascii( s ) SerialOutputString( s ) -#define printch( c ) SerialOutputChar( c ) +#include <net/tftp.h> #define TFTP_DEBUG #ifdef TFTP_DEBUG @@ -56,9 +52,6 @@ static unsigned int tftp_length; static unsigned int block; static unsigned long tftp_received; - -extern unsigned char clientipaddress[4]; -extern unsigned char serveripaddress[4]; int tftp_rcv(unsigned long *addr) { Index: ip_bits.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/ip_bits.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ip_bits.c 17 Mar 2003 15:15:29 -0000 1.1 +++ ip_bits.c 18 Mar 2003 16:20:49 -0000 1.2 @@ -7,18 +7,12 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -//#include "init.h" #include <util.h> #include <serial.h> +#include <net/net.h> #include <net/ether.h> #include <net/ip_bits.h> -#define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) -#define memzero( x, s ) memset((x), 0, (s)) -#define printascii( s ) SerialOutputString( s ) -#define printch( c ) SerialOutputChar( c ) - -extern unsigned char hwaddress[6]; unsigned long ip_sequence = 0; unsigned int checksum (unsigned char *ptr, int len, unsigned int cksum) Index: bootp.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/bootp.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- bootp.c 17 Mar 2003 15:15:29 -0000 1.1 +++ bootp.c 18 Mar 2003 16:20:50 -0000 1.2 @@ -7,16 +7,11 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -//#include "init.h" #include <util.h> #include <serial.h> +#include <net/net.h> #include <net/ip_bits.h> -#define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) -#define memzero( x, s ) memset((x), 0, (s)) -#define printascii( s ) SerialOutputString( s ) -#define printch( c ) SerialOutputChar( c ) - static const unsigned char bootp_txpacket[] = { /* destination - broadcast */ /*+source address */ @@ -54,8 +49,6 @@ static unsigned long zero = 0; static unsigned char bootp_tx[42 + 300]; static unsigned char bootp_rx[42 + 400]; - -extern unsigned char hwaddress[6]; unsigned char clientipaddress[4]; unsigned char serveripaddress[4]; Index: arp.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/arp.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- arp.c 17 Mar 2003 15:15:27 -0000 1.1 +++ arp.c 18 Mar 2003 16:20:50 -0000 1.2 @@ -9,12 +9,11 @@ */ //#include "init.h" #include <util.h> +#include <serial.h> +#include <net/net.h> #include <net/ether.h> #include <net/arp.h> -#define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) -#define memzero( x, s ) memset((x), 0, (s)) - static const unsigned char arp_txpacket[] = { /* destination address */ /* source address */ @@ -30,14 +29,11 @@ static unsigned char arp_tx[64]; static unsigned char arp_rx[64]; -extern unsigned char hwaddress[6]; -extern unsigned char clientipaddress[4]; - int arp_rcv (unsigned char *thwaddress) { unsigned int size; - size = readether (arp_rx, 64); + size = readether (arp_rx, sizeof(arp_rx)); if (!size) return 0; @@ -54,10 +50,11 @@ return 1; } -void do_arp (unsigned char *thwaddress, unsigned char *tipaddress) +int do_arp(unsigned char *thwaddress, unsigned char *tipaddress) { int i; unsigned char *p = arp_tx; + int retry = 8; memzero (p, sizeof (arp_tx)); memset (p, 0xff, 6); @@ -67,11 +64,13 @@ memcpy (p + 38, tipaddress, 4); do { - writeether (p, 60); + writeether (arp_tx, sizeof(arp_tx)); for (i = 0; i < 0x00040000; i++) { if (arp_rcv (thwaddress)) - return; + return 0; } - } while (1); + } while (--retry); + + return -1; } |
From: Stefan E. <se...@us...> - 2003-03-18 16:19:07
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv15412 Modified Files: arp.h ether.h ip_bits.h Log Message: - added comments Index: arp.h =================================================================== RCS file: /cvsroot/blob/blob/include/net/arp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- arp.h 17 Mar 2003 15:16:46 -0000 1.1 +++ arp.h 18 Mar 2003 16:18:53 -0000 1.2 @@ -7,4 +7,13 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -extern void do_arp (unsigned char *thwaddr, unsigned char *tipaddr); + +/********************************************************************** + * do_arp - send ARP request to server + * @thwaddr: the target HW address we received + * @tipaddr: the server IP address we want the HAW address for + * + * Sends and ARP REQUEST packet to the network and tries to get the + * ethernet HW address <thwaddr> for the IP address <tipaddr>. + */ +int do_arp(unsigned char *thwaddr, unsigned char *tipaddr); Index: ether.h =================================================================== RCS file: /cvsroot/blob/blob/include/net/ether.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ether.h 17 Mar 2003 15:16:46 -0000 1.1 +++ ether.h 18 Mar 2003 16:18:54 -0000 1.2 @@ -7,5 +7,28 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -extern int writeether (void *buf, int length); -extern int readether (void *buf, int size); + +#ifndef _BLOB_ETHER_H +#define _BLOB_ETHER_H 1 + +/********************************************************************** + * writeether - send a ethernet packet + * @buf: the packet + * @size: its size + * + * This routine needs to be implemented by blob ethernet "drivers" in + * order to be able to use tftp/arp/bootp code + */ +int writeether (void *buf, int length); + +/********************************************************************** + * readether - receive a ethernet packet + * @buf: the packet buffer + * @size: its maximum size + * + * This routine needs to be implemented by blob ethernet "drivers" in + * order to be able to use tftp/arp/bootp code + */ +int readether (void *buf, int size); + +#endif Index: ip_bits.h =================================================================== RCS file: /cvsroot/blob/blob/include/net/ip_bits.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ip_bits.h 17 Mar 2003 15:16:46 -0000 1.1 +++ ip_bits.h 18 Mar 2003 16:18:54 -0000 1.2 @@ -7,6 +7,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#ifndef _BLOB_IPBITS_H +#define _BLOB_IPBITS_H 1 + #define SIZE_ETHER 14 #define SIZE_IP 20 #define SIZE_UDP 8 @@ -24,3 +27,5 @@ extern void printip (char *msg, unsigned char *ip); extern int ipbits_tx (unsigned char *ptr, unsigned int size); extern int ipbits_rcv (unsigned char *ptr, unsigned int size, unsigned int *dsz, int sport, int dport); + +#endif |
From: Stefan E. <se...@us...> - 2003-03-18 16:18:16
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv15062 Added Files: net.h tftp.h smc9196.h Log Message: - created --- NEW FILE: net.h --- /* * net.h * * Copyright 2003 Stefan Eletzhofer <ste...@el...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _BLOB_NET_H #define _BLOB_NET_H 1 /* compatibility macros :) */ #define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) #define memzero( x, s ) memset((x), 0, (s)) #define printascii( s ) SerialOutputString( s ) #define printch( c ) SerialOutputChar( c ) /* defined in lowlevel ethernet drivers */ extern unsigned char hwaddress[6]; /* defined in lib/bootp.c */ extern u8 clientipaddress[4]; extern u8 serveripaddress[4]; extern unsigned char tftpfilename[128]; #endif --- NEW FILE: tftp.h --- /* * tftp.h * * Copyright 2003 Stefan Eletzhofer <ste...@el...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _BLOB_TFTP_H #define _BLOB_TFTP_H 1 /********************************************************************** * do_tftp - fetch file via tftp * @file: the file name on the server to fetch * @addr: the address to store the file to * @size: where to store the number of bytes received * * TFTP file transfer function. Needs client and server IP address * to be set. */ int do_tftp( char *file, unsigned long addr, unsigned long *size ); #endif --- NEW FILE: smc9196.h --- /*------------------------------------------------------------------------ . smc9194.h . Copyright (C) 1996 by Erik Stahlman . . This software may be used and distributed according to the terms . of the GNU General Public License, incorporated herein by reference. . . This file contains register information and access macros for . the SMC91xxx chipset. . . Information contained in this file was obtained from the SMC91C94 . manual from SMC. To get a copy, if you really want one, you can find . information under www.smc.com in the components division. . ( this thanks to advice from Donald Becker ). . . Authors . Erik Stahlman ( er...@vt... ) . . History . 01/06/96 Erik Stahlman moved definitions here from main .c file . 01/19/96 Erik Stahlman polished this up some, and added better . error handling . ---------------------------------------------------------------------------*/ #ifndef _SMC9194_H_ #define _SMC9194_H_ /*--------------------------------------------------------------- . . A description of the SMC registers is probably in order here, . although for details, the SMC datasheet is invaluable. . . Basically, the chip has 4 banks of registers ( 0 to 3 ), which . are accessed by writing a number into the BANK_SELECT register . ( I also use a SMC_SELECT_BANK macro for this ). . . The banks are configured so that for most purposes, bank 2 is all . that is needed for simple run time tasks. -----------------------------------------------------------------------*/ /* . Bank Select Register: . . yyyy yyyy 0000 00xx . xx = bank number . yyyy yyyy = 0x33, for identification purposes. */ #define BANK_SELECT 14 /* BANK 0 */ #define TCR 0 /* transmit control register */ #define TCR_ENABLE 0x0001 /* if this is 1, we can transmit */ #define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */ #define TCR_MON_CNS 0x0400 /* monitors the carrier status */ #define TCR_FDUPLX 0x0800 /* receive packets sent out */ #define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */ #define TCR_FDSE 0x8000 /* full duplex, switched ethernet */ #define TCR_CLEAR 0 /* do NOTHING */ /* the normal settings for the TCR register : */ /* QUESTION: do I want to enable padding of short packets ? */ #define TCR_NORMAL TCR_ENABLE #define EPH_STATUS 2 #define ES_LINK_OK 0x4000 /* is the link integrity ok ? */ #define RCR 4 #define RCR_SOFTRESET 0x8000 /* resets the chip */ #define RCR_STRIP_CRC 0x200 /* strips CRC */ #define RCR_ENABLE 0x100 /* IFF this is set, we can receive packets */ #define RCR_ALMUL 0x4 /* receive all multicast packets */ #define RCR_PROMISC 0x2 /* enable promiscuous mode */ /* the normal settings for the RCR register : */ #define RCR_NORMAL (RCR_STRIP_CRC | RCR_ENABLE) //#define RCR_NORMAL (RCR_PROMISC | RCR_ENABLE) //#define RCR_NORMAL (RCR_ENABLE) #define RCR_CLEAR 0x0 /* set it to a base state */ #define COUNTER 6 #define MIR 8 #define MCR 10 /* 12 is reserved */ /* BANK 1 */ #define CONFIG 0 #define CFG_AUI_SELECT 0x100 #define BASE 2 #define ADDR0 4 #define ADDR1 6 #define ADDR2 8 #define GENERAL 10 #define CONTROL 12 #define CTL_POWERDOWN 0x2000 #define CTL_LE_ENABLE 0x80 #define CTL_CR_ENABLE 0x40 #define CTL_TE_ENABLE 0x0020 #define CTL_AUTO_RELEASE 0x0800 #define CTL_EPROM_SELECT 0x0004 #define CTL_EPROM_RELOAD 0x0002 #define CTL_EPROM_STORE 0x0001 #define CTL_EPROM_ACCESS (CTL_EPROM_RELOAD | CTL_EPROM_STORE) /* high if Eprom is being read */ /* BANK 2 */ #define MMU_CMD 0 #define MC_BUSY 1 /* only readable bit in the register */ #define MC_NOP 0 #define MC_ALLOC 0x20 /* or with number of 256 byte packets */ #define MC_RESET 0x40 #define MC_REMOVE 0x60 /* remove the current rx packet */ #define MC_RELEASE 0x80 /* remove and release the current rx packet */ #define MC_FREEPKT 0xA0 /* Release packet in PNR register */ #define MC_ENQUEUE 0xC0 /* Enqueue the packet for transmit */ #define PNR_ARR 2 #define FIFO_PORTS 4 #define FP_RXEMPTY 0x8000 #define FP_TXEMPTY 0x80 #define POINTER 6 #define PTR_READ 0x2000 #define PTR_RCV 0x8000 #define PTR_AUTOINC 0x4000 #define DATA_1 8 #define DATA_2 10 #define INTERRUPT 12 #define INT_MASK 13 #define IM_RCV_INT 0x1 #define IM_TX_INT 0x2 #define IM_TX_EMPTY_INT 0x4 #define IM_ALLOC_INT 0x8 #define IM_RX_OVRN_INT 0x10 #define IM_EPH_INT 0x20 #define IM_ERCV_INT 0x40 /* not on SMC9192 */ /* BANK 3 */ #define MULTICAST1 0 #define MULTICAST2 2 #define MULTICAST3 4 #define MULTICAST4 6 #define MGMT 8 #define REVISION 10 /* ( hi: chip id low: rev # ) */ /* this is NOT on SMC9192 */ #define ERCV 12 #define CHIP_9190 3 #define CHIP_9194 4 #define CHIP_9195 5 #define CHIP_91100 7 /* . Transmit status bits */ #define TS_SUCCESS 0x0001 #define TS_LOSTCAR 0x0400 #define TS_LATCOL 0x0200 #define TS_16COL 0x0010 /* . Receive status bits */ #define RS_ALGNERR 0x8000 #define RS_BADCRC 0x2000 #define RS_ODDFRAME 0x1000 #define RS_TOOLONG 0x0800 #define RS_TOOSHORT 0x0400 #define RS_MULTICAST 0x0001 #define RS_ERRORS (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT) /* * SMC91C96 ethernet config and status registers. * These are in the "attribute" space. */ #define ECOR 0x8000 #define ECOR_RESET 0x80 #define ECOR_LEVEL_IRQ 0x40 #define ECOR_WR_ATTRIB 0x04 #define ECOR_ENABLE 0x01 #define ECSR 0x8002 #define ECSR_IOIS8 0x20 #define ECSR_PWRDWN 0x04 #define ECSR_INT 0x02 int smc_init( u32 base ); int writeether( u8 *buf, int size ); int readether( u8 *buf, int size ); int set_ethaddr( u8 hw_addr[6] ); int get_ethaddr( u8 hw_addr[6] ); #endif |
From: Stefan E. <se...@us...> - 2003-03-18 15:05:15
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv7489 Modified Files: tftp.c Log Message: - changed Russell's code such that we dont have an endless loop on errors, and we have a limited number of retries. - added a byte counter - changed signature of do_ftp(). Now returns error/success status and takes a size argument. Index: tftp.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/tftp.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tftp.c 17 Mar 2003 15:15:29 -0000 1.1 +++ tftp.c 18 Mar 2003 15:05:07 -0000 1.2 @@ -19,6 +19,14 @@ #define printascii( s ) SerialOutputString( s ) #define printch( c ) SerialOutputChar( c ) +#define TFTP_DEBUG +#ifdef TFTP_DEBUG +static int dbg = 1; +# define DBG( x, args... ) if ( dbg>=x ) printf( args ) +#else +# define DBG( x, args... ) ; +#endif + static const unsigned char tftp_txpacket[] = { /*+destination */ /*+source */ @@ -47,6 +55,7 @@ static int serverport; static unsigned int tftp_length; static unsigned int block; +static unsigned long tftp_received; extern unsigned char clientipaddress[4]; extern unsigned char serveripaddress[4]; @@ -56,6 +65,8 @@ unsigned int tftp_off, tftp_sz, nblk; unsigned char *tftp; + DBG( 5, "%s: addr=%p\n", __FUNCTION__, addr ); + tftp_off = ipbits_rcv (tftp_rx, 800, &tftp_sz, serverport, 0x8000); if (!tftp_off || tftp_rx[tftp_off] != 0) return 0; @@ -66,10 +77,10 @@ printascii ("\nTFTP error: "); printascii (tftp + 4); printch ('\n'); - while (1); + return -2; break; - case 3: /* acknowledge block */ + case 3: /* OpCode: DATA, acknowledge block */ if (block == 0) { serverport = (tftp[-8] << 8) | tftp[-7]; /* copy replied-source port */ @@ -77,7 +88,7 @@ tftp_tx[OFF_UDP + 3] = serverport; tftp_tx[OFF_UDP + 5] = 12; tftp_tx[OFF_IP + 3] = 32; - tftp_tx[OFF_TFTP + 1] = 4; /* ack code */ + tftp_tx[OFF_TFTP + 1] = 4; /* OpCode: ACK */ block = 1; tftp_length = 12; } @@ -85,15 +96,19 @@ if (nblk == block) { tftp_tx[OFF_TFTP + 2] = block >> 8; tftp_tx[OFF_TFTP + 3] = block; - ipbits_tx (tftp_tx, 12); + ipbits_tx (tftp_tx, tftp_length ); memcpy((void *)*addr, tftp + 4, tftp_sz - 4); *addr += tftp_sz - 4; - if ((block & 31) == 1) + tftp_received += tftp_sz - 4; + if ((block & 31) == 1) { printch ('.'); + DBG( 5, "%s: nblk=%d, block=%d, sz=%d\n", __FUNCTION__, nblk, block, tftp_sz ); + } block ++; - } else + } else { if (nblk == block - 1) - ipbits_tx (tftp_tx, 12); + ipbits_tx (tftp_tx, tftp_length ); + } if (tftp_sz != 516) return 1; return -1; @@ -102,15 +117,21 @@ } } -void do_tftp(char *file, unsigned long addr) +int do_tftp(char *file, unsigned long addr, unsigned long *size ) { + int ret; + int finished; unsigned int i; + int retry = 8; + + DBG( 1, "%s: file='%s', addr=%08lx\n", __FUNCTION__, file, addr ); do_arp(serverhwaddress, serveripaddress); serverport = -1; tftp_length = 144; block = 0; + tftp_received = 0; memzero(tftp_tx, sizeof (tftp_tx)); memcpy(tftp_tx + 14, tftp_txpacket, sizeof (tftp_txpacket)); @@ -125,17 +146,34 @@ printascii("TFTPing "); printascii(file); + finished = 0; do { - printch('.'); + printch('*'); ipbits_tx(tftp_tx, tftp_length); - for (i = 0; i < 0x00040000; i++) - switch (tftp_rcv(&addr)) { + for (i = 0; i < 0x00040000 && !finished; i++) { + ret = tftp_rcv(&addr); + switch (ret) { case 1: - goto done; + finished = 1; + break; case -1: i = 0; + break; + case -2: + retry = 0; + break; } - } while (1); -done: - printascii(" Ok\n"); + } + } while (retry-- && !finished); + + if ( finished ) { + printf( " OK.\n" ); + printf( "received %d blocks (%ld bytes)\n", block, tftp_received ); + *size = tftp_received; + ret = 0; + } else { + printf( " ERROR\n" ); + ret = -1; + } + return ret; } |
From: Stefan E. <se...@us...> - 2003-03-18 11:12:32
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv23193 Added Files: smc9196.c Log Message: - first working version of a smc9xxx ethernet "driver" for BLOB. Basically a stripped-down version of drivers/net/smc9194.c. Implements readether()/writeether() wrappers to use with Russell King's arp/tftp/bootp code. --- NEW FILE: smc9196.c --- /* * smc9196.c: Low-level ethernet polling functions * * Most of this code was taken from linux/drivers/net/smc9194.c * Original Author: * Erik Stahlman ( er...@vt... ) * contributors: * Arnaldo Carvalho de Melo <ac...@co...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <util.h> #include <time.h> #include <errno.h> #include <serial.h> #include <command.h> #include <net/smc9196.h> /********************************************************************** * defines */ #define SMC_DEBUG #ifdef SMC_DEBUG # define DBG( x, args... ) if ( dbg>=x ) printf( args ) #else # define DBG( x, args... ) ; #endif #define SMC_BASE (0x18000000) #define SMC_SELECT_BANK( base, x ) smc_outw( x, base, BANK_SELECT ) #define SMC_DELAY() msleep(1); #define SMC_SET_INT(base, x) \ { \ smc_outb((x), base, INT_MASK); \ } /* this enables an interrupt in the interrupt mask register */ #define SMC_ENABLE_INT(x) \ { \ u8 mask; \ mask = smc_inb(ioaddr, INT_MASK); \ mask |= (x); \ smc_outb(mask, ioaddr, INT_MASK); \ } #define SMC_INTERRUPT_MASK (IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT) /* Duplex, half or full. */ #define DUPLEX_HALF 0x00 #define DUPLEX_FULL 0x01 /* Which connector port. */ #define PORT_TP 0x00 #define PORT_AUI 0x01 /********************************************************************** * globals */ u8 hwaddress[6] = { 2, 3, 4, 5, 6, 7 }; /********************************************************************** * module globals */ static int dbg = 1; static u32 smc_chip_base = 0; static u8 pkt[1024]; /********************************************************************** * smc memory access functions */ static inline u8 smc_inb( u32 base, int reg ) { return *((volatile u8 *)(base+reg*4)); } static inline void smc_ins( u32 ioaddr, int reg, u8 *dest, u16 size ) { while( size-- ) *dest++ = smc_inb( ioaddr, reg ); } static inline unsigned short smc_inw(unsigned base, int r) { unsigned char b1, b2; msleep(1); b1 = smc_inb(base, r); msleep(1); b2 = smc_inb(base, r+1); return (b2 << 8) | b1; } static inline void smc_outb( u8 val, u32 base, int r ) { *((volatile u8 *)(base+r*4)) = val; } static inline void smc_outw( u16 val, u32 base, int r ) { smc_outb(val&0xff, base, r); smc_outb(val>>8, base, r+1); } static inline void smc_outl( u32 val, u32 base, int r ) { smc_outb(val, base, r); smc_outb(val>>8, base, r+1); smc_outb(val>>16, base, r+2); smc_outb(val>>24, base, r+3); } static inline void smc_outs( u32 ioaddr, int reg, u8 *dest, u16 size ) { while( size-- ) smc_outb( *dest++, ioaddr, reg ); } static void hexdump( u8 *address, size_t len ) { u8 *endaddress = address + len, *start=address; u8 *tmpaddress; u8 value; /* print it */ for ( ; address < endaddress; address += 0x10) { printf( "0x%08x: ", address-start ); for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress += 1) { value = *tmpaddress; printf( "%02x ", value ); } for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress++) { value = *tmpaddress; if ((value >= ' ') && (value <= '~')) serial_write(value); else serial_write('.'); } serial_write('\n'); } } /********************************************************************** * static functions */ static int smc_probe_chip( u32 base ) { u16 bank; bank = smc_inw( base, BANK_SELECT ); if ( (bank & 0xff00) != 0x3300 ) { DBG( 1, "%s: probe 1 failed\n", __FUNCTION__ ); return -EINVAL; } smc_outw( 0, base, BANK_SELECT ); bank = smc_inw( base, BANK_SELECT ); if ( (bank & 0xff00) != 0x3300 ) { DBG( 1, "%s: probe 2 failed\n", __FUNCTION__ ); return -EINVAL; } DBG( 1, "%s: probe done\n", __FUNCTION__ ); return 0; } static int smc_hw_reset( u32 base ) { u8 ecor, ecsr; u32 addr = base | ( 1<<25 ); /* ATTRIBUTE SPACE */ /* * Reset the device. We must disable IRQs around this. */ ecor = smc_inb(addr, ECOR) & ~ECOR_RESET; smc_outb(ecor | ECOR_RESET, addr, ECOR); msleep(1); /* * The device will ignore all writes to the enable bit while * reset is asserted, even if the reset bit is cleared in the * same write. Must clear reset first, then enable the device. */ smc_outb(ecor, addr, ECOR); smc_outb(ecor | ECOR_ENABLE, addr, ECOR); /* * Force byte mode. */ ecsr = smc_inb(addr, ECSR); smc_outb( ecsr | ECSR_IOIS8, addr, ECSR); DBG( 1, "%s: reset done\n", __FUNCTION__ ); return 0; } /* . Function: smc_reset(struct net_device *dev) . Purpose: . This sets the SMC91xx chip to its normal state, hopefully from whatever . mess that any other DOS driver has put it in. . . Maybe I should reset more registers to defaults in here? SOFTRESET should . do that for me. . . Method: . 1. send a SOFT RESET . 2. wait for it to finish . 3. enable autorelease mode . 4. reset the memory management unit . 5. clear all interrupts . */ static void smc_reset(u32 ioaddr) { /* This resets the registers mostly to defaults, but doesn't affect EEPROM. That seems unnecessary */ SMC_SELECT_BANK( ioaddr, 0); smc_outw(RCR_SOFTRESET, ioaddr, RCR); /* this should pause enough for the chip to be happy */ SMC_DELAY(); /* Set the transmit and receive configuration registers to default values */ smc_outw(RCR_CLEAR, ioaddr, RCR); smc_outw(TCR_CLEAR, ioaddr, TCR); /* set the control register to automatically release successfully transmitted packets, to make the best use out of our limited memory */ SMC_SELECT_BANK( ioaddr, 1); smc_outw(smc_inw(ioaddr, CONTROL) | CTL_AUTO_RELEASE, ioaddr, CONTROL); /* Reset the MMU */ SMC_SELECT_BANK( ioaddr, 2); smc_outw(MC_RESET, ioaddr, MMU_CMD); /* Note: It doesn't seem that waiting for the MMU busy is needed here, but this is a place where future chipsets _COULD_ break. Be wary of issuing another MMU command right after this */ SMC_SET_INT( ioaddr, 0); DBG( 1, "%s: sw reset done.\n", __FUNCTION__ ); } /* * This is responsible for setting the chip appropriately * for the interface type. This should only be called while * the interface is up and running. */ static void smc_set_port(int port, int duplex, u32 ioaddr ) { u16 val; SMC_SELECT_BANK( ioaddr, 1); val = smc_inw(ioaddr, CONFIG); switch (port) { case PORT_TP: DBG( 1, "%s: select TP\n", __FUNCTION__ ); val &= ~CFG_AUI_SELECT; break; case PORT_AUI: DBG( 1, "%s: select AUI\n", __FUNCTION__ ); val |= CFG_AUI_SELECT; break; } smc_outw(val, ioaddr, CONFIG); SMC_SELECT_BANK( ioaddr, 0); val = smc_inw(ioaddr, TCR); switch (duplex) { case DUPLEX_HALF: DBG( 1, "%s: select half duplex\n", __FUNCTION__ ); val &= ~TCR_FDSE; break; case DUPLEX_FULL: DBG( 1, "%s: select full duplex\n", __FUNCTION__ ); val |= TCR_FDSE; break; } smc_outw(val, ioaddr, TCR); } static int smc_get_ethaddr( u32 ioaddr, u8 dev_addr[6] ) { int i; SMC_SELECT_BANK( ioaddr, 1); for ( i=0; i<6; i+=2 ) { u16 address; address = smc_inw(ioaddr, ADDR0 + i); dev_addr[i + 1] = address >> 8; dev_addr[i] = address & 0xFF; } DBG( 1, "%s: got eth addr %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5] ); return 0; } static int smc_set_ethaddr( u32 ioaddr, u8 dev_addr[6] ) { int i; SMC_SELECT_BANK( ioaddr, 1); for ( i=0; i<6; i+=2 ) { u16 address; address = dev_addr[i+1]<<8 | dev_addr[i]; smc_outw(address, ioaddr, ADDR0 + i); } DBG( 1, "%s: set eth addr to %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5] ); return 0; } /* . Function: smc_enable . Purpose: let the chip talk to the outside work . Method: . 1. Enable the transmitter . 2. Enable the receiver . 3. Enable interrupts */ static void smc_enable(u32 ioaddr) { SMC_SELECT_BANK( ioaddr, 0); /* see the header file for options in TCR/RCR NORMAL*/ smc_outw(TCR_NORMAL, ioaddr, TCR); smc_outw(RCR_NORMAL, ioaddr, RCR); /* now, enable interrupts */ SMC_SELECT_BANK( ioaddr, 2); SMC_SET_INT( ioaddr, SMC_INTERRUPT_MASK); //SMC_SET_INT( ioaddr, 0); DBG( 1, "%s: chip enabled.\n", __FUNCTION__ ); } /*------------------------------------------------------------- . . smc_rcv - receive a packet from the card . . There is (at least) a packet waiting to be read from . chip-memory. . . o Read the status . o If an error, record it . o otherwise, read in the packet -------------------------------------------------------------- */ static int smc_rcv( u32 ioaddr, u8 *data, u16 size ) { int ret = 0; int packet_number; u16 status; u16 packet_length; /* assume bank 2 */ packet_number = smc_inw(ioaddr, FIFO_PORTS); if (packet_number & FP_RXEMPTY) { /* we got called , but nothing was on the FIFO */ DBG( 2, "%s: WARNING: smc_rcv with nothing on FIFO.\n", __FUNCTION__); /* don't need to restore anything */ ret = -1; goto done; } /* start reading from the start of the packet */ smc_outw(PTR_READ | PTR_RCV | PTR_AUTOINC, ioaddr, POINTER); /* First two words are status and packet_length */ status = smc_inw(ioaddr, DATA_1); packet_length = smc_inw(ioaddr, DATA_1); packet_length &= 0x07ff; /* mask off top bits */ DBG( 5, "RCV: STATUS %4x LENGTH %4x\n", status, packet_length); /* . the packet length contains 3 extra words : . status, length, and an extra word with an odd byte . */ packet_length -= 6; if (status & RS_ERRORS) { /* error ... */ printf( "%s: RCV error\n", __FUNCTION__ ); ret = -1; goto done; } /* do stuff to make a new packet */ /* read one extra byte */ if (status & RS_ODDFRAME) packet_length++; /* ! This should work without alignment, but it could be ! in the worse case */ if ( packet_length > size ) { printf( "%s: packet (%d) too large for buffer (%d).\n", __FUNCTION__, packet_length, size ); ret = -1; goto done; } smc_ins(ioaddr, DATA_1, data, packet_length); //print_packet(data, packet_length); ret = packet_length; done: /* error or good, tell the card to get rid of this packet */ smc_outw(MC_RELEASE, ioaddr, MMU_CMD); return ret; } /* . Function: smc_hardware_send_packet(struct net_device *) . Purpose: . This sends the actual packet to the SMC9xxx chip. . . Algorithm: . First, see if a saved_skb is available. . (this should NOT be called if there is no 'saved_skb' . Now, find the packet number that the chip allocated . Point the data pointers at it in memory . Set the length word in the chip's memory . Dump the packet to chip memory . Check if a last byte is needed (odd length packet) . if so, set the control flag right . Tell the card to send it . Enable the transmit interrupt, so I know if it failed . Free the kernel data if I actually sent it. */ static void smc_hardware_send_packet( u32 ioaddr, u8 *buf, u16 length ) { u16 lastword; u8 packet_no; DBG( 5, "%s( %p, %p, %d)\n", __FUNCTION__, (void *)ioaddr, (void *)buf, length ); /* If I get here, I _know_ there is a packet slot waiting for me */ packet_no = smc_inb(ioaddr, PNR_ARR + 1); if (packet_no & 0x80) { printf("%s: Memory allocation failed.\n", __FUNCTION__ ); return; } DBG( 5, "packet_no=%d\n", packet_no ); /* we have a packet address, so tell the card to use it */ smc_outb(packet_no, ioaddr, PNR_ARR); /* point to the beginning of the packet */ smc_outw(PTR_AUTOINC, ioaddr, POINTER); DBG( 5, "%s: Trying to xmit packet of length %d\n", __FUNCTION__, length); //print_packet(buf, length); /* send the packet length (+6 for status, length and ctl byte) and the status word (set to zeros) */ smc_outl((length + 6) << 16, ioaddr, DATA_1); /* send the actual data . I _think_ it's faster to send the longs first, and then . mop up by sending the last word. It depends heavily . on alignment, at least on the 486. Maybe it would be . a good idea to check which is optimal? But that could take . almost as much time as is saved? */ smc_outs(ioaddr, DATA_1, buf, length); /* Send the last byte, if there is one. */ if ((length & 1) == 0) lastword = 0; else lastword = 0x2000 | buf[length - 1]; smc_outw(lastword, ioaddr, DATA_1); /* enable the interrupts */ SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT); /* and let the chipset deal with it */ smc_outw(MC_ENQUEUE, ioaddr, MMU_CMD); DBG( 5, "%s: Sent packet of length %d\n", __FUNCTION__, length); return; } /* . Function: smc_wait_to_send_packet(struct sk_buff * skb, struct net_device *) . Purpose: . Attempt to allocate memory for a packet, if chip-memory is not . available, then tell the card to generate an interrupt when it . is available. . . Algorithm: . . o if the saved_skb is not currently null, then drop this packet . on the floor. This should never happen, because of TBUSY. . o if the saved_skb is null, then replace it with the current packet, . o See if I can sending it now. . o (NO): Enable interrupts and let the interrupt handler deal with it. . o (YES):Send it now. */ static int smc_send(u32 ioaddr, u8 *data, u16 length ) { unsigned short numPages; u16 time_out; DBG( 5, "%s( %p, %p, %d)\n", __FUNCTION__, (void *)ioaddr, (void *)data, length ); /* ** The MMU wants the number of pages to be the number of 256 bytes ** 'pages', minus 1 (since a packet can't ever have 0 pages :)) ** ** Pkt size for allocating is data length +6 (for additional status words, ** length and ctl!) If odd size last byte is included in this header. */ numPages = ((length & 0xfffe) + 6) / 256; DBG( 5, "numPages=%d\n", numPages ); if (numPages > 7) { printf("%s: Far too big packet error.\n", __FUNCTION__); return -1; } /* now, try to allocate the memory */ SMC_SELECT_BANK( ioaddr, 2); smc_outw(MC_ALLOC | numPages, ioaddr, MMU_CMD); time_out = 10; do { u16 status; status = smc_inb(ioaddr, INTERRUPT); DBG( 5, "status=%d\n", status ); if (status & IM_ALLOC_INT) { /* acknowledge the interrupt */ smc_outb(IM_ALLOC_INT, ioaddr, INTERRUPT); break; } //msleep(1); } while (-- time_out); if (!time_out) { printf("%s: memory allocation time out.\n", __FUNCTION__ ); return -1; } /* or YES! I can send the packet now.. */ smc_hardware_send_packet(ioaddr, data, length ); return 0; } /********************************************************************** * test command */ static int smctest( int argc, char *argv[] ) { u32 base = SMC_BASE; u8 hw_addr_set[6] = { 2,3,4,5,6,7 }; //u8 hw_addr_set[6] = { 0x00, 0x50, 0x7f, 0x01, 0xcf, 0x0f }; u8 hw_addr[6]; u8 serverip[4] = { 192, 168, 1, 1 }; u8 clientip[4] = { 192, 168, 1, 191 }; int i; static const unsigned char arp_txpacket[] = { /* destination address */ /* source address */ 0x08, 0x06, /* proto */ /* arp */ 0x00, 0x01, /* hardware format: ethernet */ 0x08, 0x00, /* protocol format: ip */ 0x06, /* hardware length */ 0x04, /* protocol length */ 0x00, 0x01 /* arp request */ }; static unsigned char arp_tx[64]; unsigned char *p = arp_tx; if (smc_init(base)) return -EINVAL; set_ethaddr( hw_addr_set ); get_ethaddr( hw_addr ); printf( "eth hw addr %02x:%02x:%02x:%02x:%02x:%02x\n", hw_addr[0], hw_addr[1], hw_addr[2], hw_addr[3], hw_addr[4], hw_addr[5] ); memset (p, 0, sizeof (arp_tx)); memset (p, 0xff, 6); memcpy (p + 12, arp_txpacket, sizeof (arp_txpacket)); memcpy (p + 22, hw_addr, 6); memcpy (p + 28, clientip, 4); memcpy (p + 38, serverip, 4); i=1024; while (i-- ) { //msleep( 100 ); if (!(i & (~0xf ))) printf( "." ); writeether( p, 60 ); } i=1024; while (i-- ) { int pkt_size; pkt_size = readether( pkt, 1024 ); if ( pkt_size > 0 ) { printf( "[%02d]", pkt_size ); } else { printf( "." ); } } printf( "\n" ); return 0; } static char smctesthelp[] = "test smc 91c96 ethernet chip\n"; __commandlist(smctest, "smctest", smctesthelp); /********************************************************************** * exported functions */ int smc_init(u32 base) { DBG( 1, "%s(%08x)\n", __FUNCTION__, base ); smc_hw_reset(base); if ( smc_probe_chip(base) ) return -EINVAL; smc_reset(base); smc_enable(base); smc_set_port( PORT_TP, DUPLEX_HALF, base ); smc_set_ethaddr( base, hwaddress ); smc_chip_base = base; return 0; } int writeether( u8 *buf, int size ) { if ( !smc_chip_base ) return -EINVAL; memcpy( buf+6, hwaddress, 6 ); #ifdef SMC_DEBUG printf( "%s: tx packet (%d bytes):\n", __FUNCTION__, size ); hexdump( buf, size ); #endif return smc_send( smc_chip_base, buf, size ); } int readether( u8 *buf, int size ) { int ret = 0; u8 status; u8 mask = 0xff; if ( !smc_chip_base ) { ret = -EINVAL; goto done; } //mask = smc_inb(smc_chip_base, INT_MASK); /* clear all interrupts */ //SMC_SET_INT( smc_chip_base, 0); /* read the status flag, and mask it */ status = smc_inb(smc_chip_base, INTERRUPT) & mask; if (!status) { ret = 0; } else if ( status & IM_RCV_INT ) { ret = smc_rcv( smc_chip_base, buf, size ); #ifdef SMC_DEBUG printf( "%s: rx packet (%d bytes):\n", __FUNCTION__, size ); hexdump( buf, size ); #endif } /* restore state register */ //SMC_SELECT_BANK( smc_chip_base, 2); //SMC_SET_INT(smc_chip_base, mask); done: return ret; } int set_ethaddr( u8 hw_addr[6] ) { if ( !smc_chip_base ) return -EINVAL; return smc_set_ethaddr( smc_chip_base, hw_addr ); } int get_ethaddr( u8 hw_addr[6] ) { if ( !smc_chip_base ) return -EINVAL; return smc_get_ethaddr( smc_chip_base, hw_addr ); } |
From: Stefan E. <se...@us...> - 2003-03-17 15:16:50
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv27822 Added Files: arp.h ether.h ip_bits.h Log Message: - Header files to Russell's bootp/tftp code. No changes made so far. --- NEW FILE: arp.h --- /* * arp.h * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ extern void do_arp (unsigned char *thwaddr, unsigned char *tipaddr); --- NEW FILE: ether.h --- /* * ether.h * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ extern int writeether (void *buf, int length); extern int readether (void *buf, int size); --- NEW FILE: ip_bits.h --- /* * ip_bits.h * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #define SIZE_ETHER 14 #define SIZE_IP 20 #define SIZE_UDP 8 #define SIZE_BOOTP 300 #define OFF_ETHER (0) #define OFF_IP (OFF_ETHER + SIZE_ETHER) #define OFF_UDP (OFF_IP + SIZE_IP) #define OFF_BOOTP (OFF_UDP + SIZE_UDP) #define OFF_TFTP (OFF_UDP + SIZE_UDP) #define MIN_UDPPKTSIZE (OFF_UDP + SIZE_UDP) extern unsigned int checksum (unsigned char *ptr, int len, unsigned int cksum); extern void printip (char *msg, unsigned char *ip); extern int ipbits_tx (unsigned char *ptr, unsigned int size); extern int ipbits_rcv (unsigned char *ptr, unsigned int size, unsigned int *dsz, int sport, int dport); |
From: Stefan E. <se...@us...> - 2003-03-17 15:15:32
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv26797 Added Files: arp.c tftp.c bootp.c ip_bits.c Log Message: - Russell King's bootp/tftp code. Only minimal changes to make it compile under BLOB. --- NEW FILE: arp.c --- /* * arp.c * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ //#include "init.h" #include <util.h> #include <net/ether.h> #include <net/arp.h> #define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) #define memzero( x, s ) memset((x), 0, (s)) static const unsigned char arp_txpacket[] = { /* destination address */ /* source address */ 0x08, 0x06, /* proto */ /* arp */ 0x00, 0x01, /* hardware format: ethernet */ 0x08, 0x00, /* protocol format: ip */ 0x06, /* hardware length */ 0x04, /* protocol length */ 0x00, 0x01 /* arp request */ }; static unsigned char arp_tx[64]; static unsigned char arp_rx[64]; extern unsigned char hwaddress[6]; extern unsigned char clientipaddress[4]; int arp_rcv (unsigned char *thwaddress) { unsigned int size; size = readether (arp_rx, 64); if (!size) return 0; if (!memeq (arp_rx + 12, arp_tx + 12, 9)) return 0; /* not valid reply */ if (arp_rx[21] != 2) return 0; /* reply */ if (!memeq (arp_rx + 28, arp_tx + 38, 4)) return 0; /* target ip address */ memcpy (thwaddress, arp_rx + 22, 6); return 1; } void do_arp (unsigned char *thwaddress, unsigned char *tipaddress) { int i; unsigned char *p = arp_tx; memzero (p, sizeof (arp_tx)); memset (p, 0xff, 6); memcpy (p + 12, arp_txpacket, sizeof (arp_txpacket)); memcpy (p + 22, hwaddress, 6); memcpy (p + 28, clientipaddress, 4); memcpy (p + 38, tipaddress, 4); do { writeether (p, 60); for (i = 0; i < 0x00040000; i++) { if (arp_rcv (thwaddress)) return; } } while (1); } --- NEW FILE: tftp.c --- /* * tftp.c * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ //#include "init.h" #include <util.h> #include <serial.h> #include <net/ip_bits.h> #include <net/arp.h> #define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) #define memzero( x, s ) memset((x), 0, (s)) #define printascii( s ) SerialOutputString( s ) #define printch( c ) SerialOutputChar( c ) static const unsigned char tftp_txpacket[] = { /*+destination */ /*+source */ /* proto */ /* IP */ 0x45, 0x00, 0x00, 0xa4, /* ver/ihl, TOS, length */ 0x00, 0x00, /*+id */ 0x00, 0x00, 0x40, 0x11, /* frag off, ttl, proto */ 0x00, 0x00, /*+checksum */ 0x00, 0x00, 0x00, 0x00, /*+source address */ 0x00, 0x00, 0x00, 0x00, /*+destination address */ /* UDP */ 0x80, 0x00, /* source port */ 0x00, 0x45, /* destination port */ 0x00, 0x90, /* length (inc header) */ 0x00, 0x00, /*+checksum */ /* TFTP */ 0x00, 0x01 /* opcode: RRQ */ /* filename */ }; static unsigned char serverhwaddress[6]; static char octet[] = "octet"; static unsigned char tftp_tx[200]; static unsigned char tftp_rx[800]; static int serverport; static unsigned int tftp_length; static unsigned int block; extern unsigned char clientipaddress[4]; extern unsigned char serveripaddress[4]; int tftp_rcv(unsigned long *addr) { unsigned int tftp_off, tftp_sz, nblk; unsigned char *tftp; tftp_off = ipbits_rcv (tftp_rx, 800, &tftp_sz, serverport, 0x8000); if (!tftp_off || tftp_rx[tftp_off] != 0) return 0; tftp = tftp_rx + tftp_off; switch (tftp[1]) { case 5: /* error */ printascii ("\nTFTP error: "); printascii (tftp + 4); printch ('\n'); while (1); break; case 3: /* acknowledge block */ if (block == 0) { serverport = (tftp[-8] << 8) | tftp[-7]; /* copy replied-source port */ tftp_tx[OFF_UDP + 2] = serverport >> 8; tftp_tx[OFF_UDP + 3] = serverport; tftp_tx[OFF_UDP + 5] = 12; tftp_tx[OFF_IP + 3] = 32; tftp_tx[OFF_TFTP + 1] = 4; /* ack code */ block = 1; tftp_length = 12; } nblk = (tftp[2] << 8) | tftp[3]; if (nblk == block) { tftp_tx[OFF_TFTP + 2] = block >> 8; tftp_tx[OFF_TFTP + 3] = block; ipbits_tx (tftp_tx, 12); memcpy((void *)*addr, tftp + 4, tftp_sz - 4); *addr += tftp_sz - 4; if ((block & 31) == 1) printch ('.'); block ++; } else if (nblk == block - 1) ipbits_tx (tftp_tx, 12); if (tftp_sz != 516) return 1; return -1; default: return 0; } } void do_tftp(char *file, unsigned long addr) { unsigned int i; do_arp(serverhwaddress, serveripaddress); serverport = -1; tftp_length = 144; block = 0; memzero(tftp_tx, sizeof (tftp_tx)); memcpy(tftp_tx + 14, tftp_txpacket, sizeof (tftp_txpacket)); memcpy(tftp_tx + OFF_ETHER, serverhwaddress, 6); memcpy(tftp_tx + OFF_IP + 12, clientipaddress, 4); memcpy(tftp_tx + OFF_IP + 16, serveripaddress, 4); for (i = 0; file[i]; i++) tftp_tx[OFF_TFTP + 2 + i] = file[i]; memcpy(tftp_tx + OFF_TFTP + 3 + i, octet, 6); printascii("TFTPing "); printascii(file); do { printch('.'); ipbits_tx(tftp_tx, tftp_length); for (i = 0; i < 0x00040000; i++) switch (tftp_rcv(&addr)) { case 1: goto done; case -1: i = 0; } } while (1); done: printascii(" Ok\n"); } --- NEW FILE: bootp.c --- /* * bootp.c * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ //#include "init.h" #include <util.h> #include <serial.h> #include <net/ip_bits.h> #define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) #define memzero( x, s ) memset((x), 0, (s)) #define printascii( s ) SerialOutputString( s ) #define printch( c ) SerialOutputChar( c ) static const unsigned char bootp_txpacket[] = { /* destination - broadcast */ /*+source address */ /* protocol - ip */ /* IP (14) */ 0x45, 0x00, 0x01, 0x48, /* ver/ihl, TOS, length */ 0x00, 0x00, /*+id */ 0x00, 0x00, 0x40, 0x11, /* frag off, ttl, proto */ 0x00, 0x00, /*+checksum */ 0x00, 0x00, 0x00, 0x00, /* source address (unknown) */ 0xff, 0xff, 0xff, 0xff, /* destination address (broadcast) */ /* UDP (34) */ 0x00, 0x44, /* source port */ 0x00, 0x43, /* destination port */ 0x01, 0x34, /* length (inc header) */ 0x00, 0x00, /*+checksum */ /* BOOTP (42) */ 0x01, /* Bootp REQUEST */ 0x01, /* Hardware type - ethernet */ 0x06, /* Hardware address length */ #if 0 0x00, /* HOPS ??? */ 0x00, 0x00, 0x00, 0x00, /*+random ID */ 0x00, 0x00, 0x00, 0x00, /*+time */ 0x00, 0x00, 0x00, 0x00, /* Client IP */ 0x00, 0x00, 0x00, 0x00, /* Your IP */ 0x00, 0x00, 0x00, 0x00, /* Server IP */ 0x00, 0x00, 0x00, 0x00, /* Gateway IP */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*+Hardware address we're asking for */ #endif }; static unsigned int bootp_xid = 0xd1030000; /* bootp_xid is net byte order */ static unsigned long zero = 0; static unsigned char bootp_tx[42 + 300]; static unsigned char bootp_rx[42 + 400]; extern unsigned char hwaddress[6]; unsigned char clientipaddress[4]; unsigned char serveripaddress[4]; unsigned char tftpfilename[128]; int bootp_rcv (void) { unsigned int bootp_off, bootp_sz; unsigned char *bootp; int i; if ((bootp_off = ipbits_rcv (bootp_rx, 360, &bootp_sz, 0x43, 0x44)) == 0) return 0; bootp = bootp_rx + bootp_off; if (bootp[0] != 2 || bootp[1] != 1 || bootp[2] != 6) return 0; /* not reply or wrong hardware type (error?) */ if (!memeq (bootp + 4, &bootp_xid, 4)) return 0; /* wrong xid */ if (!memeq (bootp + 12, &zero, 4)) return 0; /* not our client IP (error?) */ if (!memeq (bootp + 28, hwaddress, 6)) return 0; /* not our hardware address (error?) */ memcpy (clientipaddress, bootp + 16, 4); /* grab our & server ip addresses */ memcpy (serveripaddress, bootp + 20, 4); for (i = 0; i < 127; i++) if ((tftpfilename[i] = bootp[108 + i]) == 0) break; tftpfilename[i] = '\0'; printip ("\nOur IP : ", clientipaddress); printip ("\nServer IP: ", serveripaddress); printascii ("\nTFTP file: "); printascii (tftpfilename); printascii ("\n"); return 1; } char *do_bootp (void) { unsigned int request_time = 0; unsigned int packet_length; int i; memzero (bootp_tx, sizeof (bootp_tx)); memcpy (bootp_tx + 14, bootp_txpacket, sizeof (bootp_txpacket)); memset (bootp_tx + OFF_ETHER, 0xff, 6); memcpy (bootp_tx + OFF_BOOTP + 28, hwaddress, 6); memcpy (bootp_tx + OFF_BOOTP + 4, &bootp_xid, 4); packet_length = (bootp_tx[OFF_UDP + 4] << 8) + bootp_tx[OFF_UDP + 5]; printascii ("Sending bootp request"); do { printch ('.'); bootp_tx[OFF_BOOTP + 8] = request_time >> 8; bootp_tx[OFF_BOOTP + 9] = request_time; request_time ++; ipbits_tx (bootp_tx, packet_length); for (i = 0; i < 0x00030000; i++) if (bootp_rcv()) return tftpfilename; } while (1); } --- NEW FILE: ip_bits.c --- /* * ip_bits.c * * Copyright 1996-2001 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ //#include "init.h" #include <util.h> #include <serial.h> #include <net/ether.h> #include <net/ip_bits.h> #define memeq( x, y, s ) (memcmp((x), (y), (s)) == 0) #define memzero( x, s ) memset((x), 0, (s)) #define printascii( s ) SerialOutputString( s ) #define printch( c ) SerialOutputChar( c ) extern unsigned char hwaddress[6]; unsigned long ip_sequence = 0; unsigned int checksum (unsigned char *ptr, int len, unsigned int cksum) { int i; for (i = 0; i < len - 1; i += 2) cksum += (ptr[i] << 8) | ptr[i + 1]; if (len & 1) cksum += ptr[len - 1] << 8; cksum = (cksum & 0xffff) + (cksum >> 16); cksum = (cksum & 0xffff) + (cksum >> 16); return cksum; } void printip (char *msg, unsigned char *ip) { int i; printascii (msg); for (i = 0; i < 4; i++) { printf( "%02x", ip[i]); printch (i == 3 ? ' ' : '.'); } } int ipbits_tx (unsigned char *ptr, unsigned int size) { unsigned int cksum; ptr[OFF_ETHER + 12] = 8; ptr[OFF_ETHER + 13] = 0; ptr[OFF_UDP + 6] = 0; ptr[OFF_UDP + 7] = 0; ptr[OFF_IP + 4] = ip_sequence >> 8; ptr[OFF_IP + 5] = ip_sequence; ptr[OFF_IP + 10] = 0; ptr[OFF_IP + 11] = 0; ip_sequence ++; cksum = checksum (ptr + OFF_IP + 12, 8, 0x11 + size); cksum = ~checksum (ptr + OFF_UDP, size, cksum); if (cksum == 0) cksum = -1; ptr[OFF_UDP + 6] = cksum >> 8; ptr[OFF_UDP + 7] = cksum; cksum = ~checksum (ptr + OFF_IP, SIZE_IP, 0); if (cksum == 0) cksum = -1; ptr[OFF_IP + 10] = cksum >> 8; ptr[OFF_IP + 11] = cksum; if (size < 32) size = 32; return writeether (ptr, size + OFF_UDP); } int ipbits_rcv (unsigned char *ptr, unsigned int size, unsigned int *dsz, int sport, int dport) { unsigned int cksum, hdrlen, off_udp; size = readether(ptr, size); if (!size) return 0; if (size < MIN_UDPPKTSIZE) /* must be at least this size for UDP */ return 0; if (!memeq (ptr + OFF_ETHER, hwaddress, 6)) return 0; /* not for us */ if (((ptr[OFF_ETHER + 12] << 8) | ptr[OFF_ETHER + 13]) != 0x800) return 0; /* not IP */ hdrlen = (ptr[OFF_IP] - 0x40) * 4; if (hdrlen < 20 || hdrlen > 60) return 0; /* not an IP packet we know about */ cksum = checksum (ptr + OFF_IP, hdrlen, 0); if (cksum != 0xffff) return 0; /* bad ip header checksum */ if (ptr[OFF_IP + 9] != 0x11) return 0; /* not UDP */ off_udp = OFF_IP + hdrlen; hdrlen = (ptr[off_udp + 4] << 8) | ptr[off_udp + 5]; if ((ptr[off_udp + 6] | ptr[off_udp + 7]) != 0) { cksum = checksum (ptr + OFF_IP + 12, 8, 0x11 + hdrlen); cksum = checksum (ptr + off_udp, hdrlen, cksum); if (cksum != 0xffff) return 0; /* bad udp checksum */ } if (sport != -1 && sport != ((ptr[off_udp] << 8) | ptr[off_udp + 1])) return 0; if (((ptr[off_udp + 2] << 8) | ptr[off_udp + 3]) != dport) return 0; /* wrong UDP ports */ *dsz = hdrlen - SIZE_UDP; return off_udp + SIZE_UDP; } |
From: Stefan E. <se...@us...> - 2003-03-17 14:59:12
|
Update of /cvsroot/blob/blob/include/blob In directory sc8-pr-cvs1:/tmp/cvs-serv20020 Modified Files: util.h Log Message: - added mamcmp Index: util.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/util.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- util.h 4 Jan 2003 02:11:42 -0000 1.12 +++ util.h 17 Mar 2003 14:59:08 -0000 1.13 @@ -44,6 +44,8 @@ void *memset(void *dest, int c, size_t n); +int memcmp(const void * cs,const void * ct,size_t count); + int strncmp(const char *s1, const char *s2, size_t maxlen); int strlen(const char *s); |
From: Stefan E. <se...@us...> - 2003-03-17 14:57:29
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv19104 Modified Files: Makefile.am Added Files: memcmp.c Log Message: - added memcmp --- NEW FILE: memcmp.c --- /* * memcmp.c: compare two memory regions. From linux/lib/string.c * * Copyright (C) 1991, 1992 Linus Torvalds * Copyright (C) 2003 Stefan Eletzhofer <ste...@el...> * * $Id: memcmp.c,v 1.1 2003/03/17 14:57:25 seletz Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: memcmp.c,v 1.1 2003/03/17 14:57:25 seletz Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/util.h> #include <blob/types.h> /** * memcmp - Compare two areas of memory * @cs: One area of memory * @ct: Another area of memory * @count: The size of the area. */ int memcmp(const void * cs,const void * ct,size_t count) { const unsigned char *su1, *su2; int res = 0; for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) if ((res = *su1 - *su2) != 0) break; return res; } Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Makefile.am 13 Feb 2003 01:10:53 -0000 1.24 +++ Makefile.am 17 Mar 2003 14:57:24 -0000 1.25 @@ -37,6 +37,7 @@ led.c \ md5.c \ md5support.c \ + memcmp.c \ memcpy.c \ memset.c \ mini_inflate.c \ |
From: Stefan E. <se...@us...> - 2003-03-17 14:52:20
|
Update of /cvsroot/blob/blob/include/net In directory sc8-pr-cvs1:/tmp/cvs-serv16251/net Log Message: Directory /cvsroot/blob/blob/include/net added to the repository |
From: Stefan E. <se...@us...> - 2003-03-11 19:36:29
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv28370 Modified Files: flash-commands.c Log Message: - changed flash command to allow flashing to arbitary partitions, i.e. "flash kernel zImage" flashes the kernel into the zImage partition. If the partition argument is missing, it assumes the 1st argument is also the partition name, which is exactly the old behavior. Index: flash-commands.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/flash-commands.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- flash-commands.c 29 Jan 2003 23:55:49 -0000 1.6 +++ flash-commands.c 11 Mar 2003 19:36:25 -0000 1.7 @@ -67,14 +67,21 @@ u32 numBytes = 0; u32 maxSize = 0; u32 nwords; + char *dest_part; block_source_t type = fromFlash; if(argc < 2) return -ENOPARAMS; - rv = parse_partition(argv[1], &dst, &maxSize); + if ( argc>2 ) { + dest_part = argv[2]; + } else { + dest_part = argv[1]; + } + + rv = parse_partition(dest_part, &dst, &maxSize); if (rv < 0) { - printerror(rv, argv[1]); + printerror(rv, dest_part); return 0; } @@ -122,8 +129,9 @@ return 0; } -static char flashhelp[] = "flash {blob|param|kernel|ramdisk}\n" -"Write <argument> image to flash\n"; +static char flashhelp[] = "flash {blob|param|kernel|ramdisk} [part]\n" +"Write <argument> image to flash using partition <part>. If <part> is omitted\n" +"assume <part>==<argument>\n"; __commandlist(Flash, "flash", flashhelp); |
From: Erik M. <er...@us...> - 2003-02-13 01:10:58
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv20927/src/lib Modified Files: Makefile.am led.c Added Files: led-mmap.c led-sa11x0.c Log Message: LED driver modularisation from Kevin O'Neill. --- NEW FILE: led-mmap.c --- /* * led_mmap.c: simple memory mapped LED control functions * * Copyright (C) 2002, 2003 by SOMA Networks Inc. * * $Id: led-mmap.c,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: led-mmap.c,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/led.h> #include <blob/init.h> static int led_state; static int led_locked; static void mmap_led_on(void) { volatile u16 *ledp; if(led_locked) return; ledp = (volatile u16 *)LED_ADDR; *ledp = LED_ON; led_state = 1; } static void mmap_led_off(void) { volatile u16 *ledp; if(led_locked) return; ledp = (volatile u16 *)LED_ADDR; *ledp = LED_OFF; led_state = 0; } static void mmap_led_toggle(void) { if(led_state) mmap_led_off(); else mmap_led_on(); return; } static void mmap_led_lock(void) { led_locked = 1; } static void mmap_led_unlock(void) { led_locked = 0; } led_driver_t mmap_led_driver = { led_on: mmap_led_on, led_off: mmap_led_off, led_toggle: mmap_led_toggle, led_lock: mmap_led_lock, led_unlock: mmap_led_unlock, }; --- NEW FILE: led-sa11x0.c --- /* * led-sa11x0.c: simple LED control functions * * Copyright (C) 1999 2001 Erik Mouw (J.A...@it...) * * $Id: led-sa11x0.c,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * All functions assume that the LED is properly initialised by the code * in ledasm.S. * */ #ident "$Id: led-sa11x0.c,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/sa1100.h> #include <blob/led.h> #include <blob/init.h> static int led_state; static int led_locked; /* TODO: fix this */ static void sa11x0_led_on(void) { if(led_locked) return; GPSR = LED_GPIO; led_state = 1; } /* TODO: fix this */ static void sa11x0_led_off(void) { if(led_locked) return; GPCR = LED_GPIO; led_state = 0; } static void sa11x0_led_toggle(void) { if(led_state) sa11x0_led_off(); else sa11x0_led_on(); return; } static void sa11x0_led_lock(void) { led_locked = 1; } static void sa11x0_led_unlock(void) { led_locked = 0; } led_driver_t sa11x0_gpio_led_driver = { led_on: sa11x0_led_on, led_off: sa11x0_led_off, led_toggle: sa11x0_led_toggle, led_lock: sa11x0_led_lock, led_unlock: sa11x0_led_unlock, }; Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Makefile.am 4 Jan 2003 02:11:43 -0000 1.23 +++ Makefile.am 13 Feb 2003 01:10:53 -0000 1.24 @@ -51,18 +51,23 @@ util.c EXTRA_libblob_a_SOURCES = \ + led-mmap.c \ + led-sa11x0.c \ reboot-pxa.c \ reboot-sa11x0.c \ serial-pxa.c \ serial-sa11x0.c + libblob_a_DEPENDENCIES = \ @BLOB_REBOOT_DRIVER_OBJS@ \ - @BLOB_SERIAL_DRIVER_OBJS@ + @BLOB_SERIAL_DRIVER_OBJS@ \ + @BLOB_LED_DRIVER_OBJS@ libblob_a_LIBADD = \ @BLOB_REBOOT_DRIVER_OBJS@ \ - @BLOB_SERIAL_DRIVER_OBJS@ + @BLOB_SERIAL_DRIVER_OBJS@ \ + @BLOB_LED_DRIVER_OBJS@ INCLUDES += \ -I${top_builddir}/include \ Index: led.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/led.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- led.c 26 Nov 2002 18:43:43 -0000 1.7 +++ led.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -1,17 +1,9 @@ -/*------------------------------------------------------------------------- - * Filename: led.c - * Version: $Id$ - * Copyright: Copyright (C) 1999, Erik Mouw - * Author: Erik Mouw <J.A...@it...> - * Description: - * Created at: Mon Aug 16 15:39:12 1999 - * Modified by: Erik Mouw <J.A...@it...> - * Modified at: Mon Aug 16 16:55:21 1999 - *-----------------------------------------------------------------------*/ /* * led.c: simple LED control functions * - * Copyright (C) 1999 2001 Erik Mouw (J.A...@it...) + * Copyright (C) 2002, 2003 by SOMA Networks Inc. + * + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,84 +20,67 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* - * All functions assume that the LED is properly initialised by the code - * in ledasm.S. - * - */ #ident "$Id$" #ifdef HAVE_CONFIG_H # include <blob/config.h> -#endif +#endif -#include <blob/arch.h> -#include <blob/sa1100.h> +#include <blob/debug.h> #include <blob/led.h> -#include <blob/init.h> - - - -static int led_state; -static int led_locked; - - +#include <blob/types.h> +led_driver_t *led_driver; -void led_init(void) +int led_init(void) { - led_unlock(); - led_on(); -} - - + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } -/* TODO: fix this */ -void led_on(void) -{ - if(led_locked) - return; + led_driver->led_unlock(); + led_driver->led_on(); - GPSR = LED_GPIO; - led_state = 1; + return 0; } - - -/* TODO: fix this */ -void led_off(void) +int led_on(void) { - if(led_locked) - return; + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } - GPCR = LED_GPIO; - led_state = 0; + led_driver->led_on(); + + return 0; } +int led_off(void) +{ + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } + led_driver->led_off(); + return 0; +} void led_toggle(void) { - if(led_state) - led_off(); - else - led_on(); + led_driver->led_toggle(); } - - - void led_lock(void) { - led_locked = 1; + led_driver->led_lock(); } - - - void led_unlock(void) { - led_locked = 0; + led_driver->led_unlock(); } |
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv20927/src/blob Modified Files: Makefile.am accelent_sa.c assabet.c badge4.c brutus.c cep.c clart.c frodo.c h3600.c hackkit.c idr.c jornada720.c lart.c lubbock.c miniprint.c nesa.c pleb.c pxa_idp.c shannon.c system3.c trizeps.c Added Files: ledasm-mmap.S ledasm-sa11x0.S Removed Files: ledasm.S Log Message: LED driver modularisation from Kevin O'Neill. --- NEW FILE: ledasm-mmap.S --- /* * ledasm-mmap.S: simple LED control code for a memory mapped arch * * Copyright (C) 2003 by SOMA Networks, Inc. * * Derived from: * Copyright (C) 2001 Erik Mouw (J.A...@it...) * * $Id: ledasm-mmap.S,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ .ident "$Id: ledasm-mmap.S,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> .globl ledinit ledinit: mov pc, lr .globl led_on /* turn LED on. clobbers r0 and r1 */ led_on: ldr r0, =LED_ADDR ldr r1, =LED_ON str r1, [r0] ldr r1, [r0] mov pc, lr .globl led_off /* turn LED off. clobbers r0 - r1 */ led_off: ldr r0, =LED_ADDR ldr r1, =LED_OFF str r1, [r0] ldr r1, [r0] mov pc, lr .globl led_blink led_blink: mov pc, lr --- NEW FILE: ledasm-sa11x0.S --- /* * ledasm-sa11x0.S: simple LED control code * * Copyright (C) 2001 Erik Mouw (J.A...@it...) * * $Id: ledasm-sa11x0.S,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * Documentation: * [1] Intel Corporation, "Intel StrongARM SA-1100 Microprocessor * Developer's Manual", April 1999 * [2] Intel Corporation, "Intel StrongARM SA-1110 Microprocessor * Advanced Developer's manual, December 1999 */ .ident "$Id: ledasm-sa11x0.S,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> .text LED: .long LED_GPIO GPIO_BASE: .long 0x90040000 #define GPDR 0x00000004 #define GPSR 0x00000008 #define GPCR 0x0000000c .globl ledinit /* initialise LED GPIO and turn LED on. * clobbers r0 and r1 */ ledinit: #if defined (NO_GPIO_LED_SUPPORT) mov pc, lr #endif ldr r0, GPIO_BASE ldr r1, LED str r1, [r0, #GPDR] /* LED GPIO is output */ str r1, [r0, #GPSR] /* turn LED on */ mov pc, lr .globl led_on /* turn LED on. clobbers r0 and r1 */ led_on: #if defined (NO_GPIO_LED_SUPPORT) mov pc, lr #endif ldr r0, GPIO_BASE ldr r1, LED str r1, [r0, #GPSR] mov pc, lr .globl led_off /* turn LED off. clobbers r0 - r2 */ led_off: #if defined (NO_GPIO_LED_SUPPORT) mov pc, lr #endif ldr r0, GPIO_BASE ldr r1, LED str r1, [r0, #GPCR] mov pc, lr /* busy wait loop. clobbers r0 */ wait_loop: mov r0, #0x400000 wait_loop1: subs r0, r0, #1 bne wait_loop1 mov pc, lr blinky: /* blink LED. clobbers r0 and r1 */ mov r2, lr bl led_on bl wait_loop bl led_off bl wait_loop mov pc, r2 .globl led_blink /* blinks LED r0 times */ /* clobbers r0 - r4 */ led_blink: #if defined (NO_GPIO_LED_SUPPORT) mov pc, lr #endif mov r4, lr mov r3, r0 /* switch LED off if it wasn't already off */ bl led_off bl wait_loop blink0: bl blinky subs r3, r3, #1 bne blink0 mov pc, r4 Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- Makefile.am 10 Feb 2003 23:07:03 -0000 1.36 +++ Makefile.am 13 Feb 2003 01:10:52 -0000 1.37 @@ -143,16 +143,18 @@ # be linked in the wrong order! blob_elf32_SOURCES = \ start.S \ - ledasm.S \ testmem.S EXTRA_blob_elf32_SOURCES = \ + ledasm-mmap.S \ + ledasm-sa11x0.S \ memsetup-sa1100.S \ memsetup-sa1110.S \ start-pxa.S \ start-sa11x0.S blob_elf32_DEPENDENCIES = \ + @BLOB_LED_STARTCODE@ \ @BLOB_MEMSETUP_OBJS@ \ @BLOB_STARTCODE_OBJS@ \ start-ld-script \ @@ -163,6 +165,7 @@ -Wl,-Map,blob-start-elf32.map blob_elf32_LDADD += \ + @BLOB_LED_STARTCODE@ \ @BLOB_MEMSETUP_OBJS@ \ @BLOB_STARTCODE_OBJS@ \ -lgcc @@ -180,11 +183,15 @@ # WARNING: chain.S *must* be the first file, otherwise the target will # be linked in the wrong order! blob_chain_elf32_SOURCES = \ - chain.S \ - ledasm.S + chain.S + +EXTRA_blob_chain_elf32_SOURCES= \ + ledasm-mmap.S \ + ledasm-sa11x0.S blob_chain_elf32_DEPENDENCIES =\ start-ld-script \ + @BLOB_LED_STARTCODE@ \ blob-rest-piggy.o blob_chain_elf32_LDFLAGS += \ @@ -192,6 +199,7 @@ -Wl,-Map,blob-start-chain-elf32.map blob_chain_elf32_LDADD += \ + @BLOB_LED_STARTCODE@ \ -lgcc Index: accelent_sa.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/accelent_sa.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- accelent_sa.c 4 Jan 2003 02:11:42 -0000 1.3 +++ accelent_sa.c 13 Feb 2003 01:10:52 -0000 1.4 @@ -43,6 +43,8 @@ #include <blob/init.h> #include <blob/command.h> #include <blob/uucodec.h> +#include <blob/serial.h> +#include <blob/led.h> extern blob_status_t blob_status; @@ -102,6 +104,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(accelent_sa_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: assabet.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/assabet.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- assabet.c 4 Jan 2003 02:11:42 -0000 1.8 +++ assabet.c 13 Feb 2003 01:10:53 -0000 1.9 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -74,6 +75,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } Index: badge4.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/badge4.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- badge4.c 28 Jan 2003 03:41:28 -0000 1.15 +++ badge4.c 13 Feb 2003 01:10:53 -0000 1.16 @@ -37,6 +37,7 @@ #include <blob/i2c-gpio.h> #include <blob/spd.h> #include <blob/partition.h> +#include <blob/led.h> #define DEBUG @@ -132,8 +133,10 @@ static void badge4_select_drivers(void) { + /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; flash_driver = &intel16_flash_driver; flash_descriptors = badge4_flash_descriptors; Index: brutus.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/brutus.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- brutus.c 4 Jan 2003 02:11:42 -0000 1.7 +++ brutus.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -63,6 +64,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(brutus_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: cep.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/cep.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cep.c 4 Jan 2003 02:11:42 -0000 1.2 +++ cep.c 13 Feb 2003 01:10:53 -0000 1.3 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -74,6 +75,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; /* switch on the LED D3 */ *((volatile u8*)(0x40000004))= 0x02; Index: clart.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/clart.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- clart.c 4 Jan 2003 02:11:42 -0000 1.7 +++ clart.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -66,6 +67,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(clart_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: frodo.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/frodo.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- frodo.c 4 Jan 2003 02:11:43 -0000 1.6 +++ frodo.c 13 Feb 2003 01:10:53 -0000 1.7 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -83,6 +84,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } Index: h3600.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/h3600.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- h3600.c 4 Jan 2003 02:11:43 -0000 1.7 +++ h3600.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -31,6 +31,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -130,6 +131,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(h3600_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: hackkit.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/hackkit.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- hackkit.c 4 Jan 2003 02:11:43 -0000 1.3 +++ hackkit.c 13 Feb 2003 01:10:53 -0000 1.4 @@ -44,6 +44,7 @@ #include <blob/uucodec.h> #include <blob/time.h> #include <blob/partition.h> +#include <blob/led.h> #include <blob/sa1100.h> @@ -119,5 +120,6 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(hackkit_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: idr.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/idr.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- idr.c 4 Jan 2003 02:11:43 -0000 1.11 +++ idr.c 13 Feb 2003 01:10:53 -0000 1.12 @@ -32,6 +32,7 @@ #include <blob/serial.h> #include <blob/sa1100.h> #include <blob/sa1111.h> +#include <blob/led.h> /* flash descriptor for IDR flash */ /* 1x Intel 28F128J3A strataflash (16MB) */ @@ -123,6 +124,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; /* tweak blob config */ blob_status.boot_delay = 1; Index: jornada720.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/jornada720.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- jornada720.c 4 Jan 2003 02:11:43 -0000 1.6 +++ jornada720.c 13 Feb 2003 01:10:53 -0000 1.7 @@ -32,6 +32,7 @@ #include <blob/reboot.h> #include <blob/serial.h> #include <blob/time.h> +#include <blob/led.h> /* flash descriptor for Jornada720 flash */ @@ -78,6 +79,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(init_driver, INIT_LEVEL_DRIVER_SELECTION); Index: lart.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/lart.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- lart.c 4 Jan 2003 02:11:43 -0000 1.8 +++ lart.c 13 Feb 2003 01:10:53 -0000 1.9 @@ -31,6 +31,7 @@ #include <blob/partition.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -134,6 +135,7 @@ { reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; /* we could do funky detection over here, because the LART can * have both internal and external flash with different Index: lubbock.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/lubbock.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- lubbock.c 4 Jan 2003 02:11:43 -0000 1.2 +++ lubbock.c 13 Feb 2003 01:10:53 -0000 1.3 @@ -28,6 +28,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -73,6 +74,7 @@ /* select drivers */ reboot_driver = &pxa_reboot_driver; serial_driver = &pxa_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } Index: miniprint.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/miniprint.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- miniprint.c 4 Jan 2003 02:11:43 -0000 1.2 +++ miniprint.c 13 Feb 2003 01:10:53 -0000 1.3 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> /* flash descriptor for Miniprint flash */ /* 2x Intel 28F128J3A strataflash (a 16MB) */ @@ -56,5 +57,6 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(miniprint_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: nesa.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/nesa.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- nesa.c 4 Jan 2003 02:11:43 -0000 1.8 +++ nesa.c 13 Feb 2003 01:10:53 -0000 1.9 @@ -29,6 +29,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> @@ -77,6 +78,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(nesa_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: pleb.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/pleb.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pleb.c 4 Jan 2003 02:11:43 -0000 1.7 +++ pleb.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -80,6 +80,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(pleb_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: pxa_idp.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/pxa_idp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pxa_idp.c 4 Jan 2003 02:11:43 -0000 1.2 +++ pxa_idp.c 13 Feb 2003 01:10:53 -0000 1.3 @@ -41,6 +41,7 @@ #include <blob/init.h> #include <blob/command.h> #include <blob/uucodec.h> +#include <blob/led.h> extern blob_status_t blob_status; @@ -99,6 +100,7 @@ /* select drivers */ reboot_driver = &pxa_reboot_driver; serial_driver = &pxa_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(accelent_sa_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: shannon.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/shannon.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- shannon.c 4 Jan 2003 02:11:43 -0000 1.12 +++ shannon.c 13 Feb 2003 01:10:53 -0000 1.13 @@ -30,6 +30,7 @@ #include <blob/init.h> #include <blob/reboot.h> #include <blob/serial.h> +#include <blob/led.h> /* flash descriptor for SHANNON flash */ /* 2x AMD *whatever* flash (4MB) */ @@ -70,6 +71,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; /* tweak blob config */ blob_status.boot_delay = 1; Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/system3.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- system3.c 4 Jan 2003 02:11:43 -0000 1.24 +++ system3.c 13 Feb 2003 01:10:53 -0000 1.25 @@ -44,6 +44,7 @@ #include <blob/uucodec.h> #include <blob/time.h> #include <blob/partition.h> +#include <blob/led.h> #include <blob/sa1100.h> #include <blob/sa1111.h> @@ -266,6 +267,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(system3_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: trizeps.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/trizeps.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- trizeps.c 4 Jan 2003 02:11:43 -0000 1.2 +++ trizeps.c 13 Feb 2003 01:10:53 -0000 1.3 @@ -43,6 +43,7 @@ #include <blob/init.h> #include <blob/command.h> #include <blob/uucodec.h> +#include <blob/led.h> /********************************************************************** * defines @@ -109,6 +110,7 @@ /* select drivers */ reboot_driver = &sa11x0_reboot_driver; serial_driver = &sa11x0_serial_driver; + led_driver = &sa11x0_gpio_led_driver; } __initlist(trizeps_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- ledasm.S DELETED --- |
From: Erik M. <er...@us...> - 2003-02-13 01:10:58
|
Update of /cvsroot/blob/blob/include/blob In directory sc8-pr-cvs1:/tmp/cvs-serv20927/include/blob Modified Files: led.h Log Message: LED driver modularisation from Kevin O'Neill. Index: led.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/led.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- led.h 15 Oct 2001 21:27:05 -0000 1.3 +++ led.h 13 Feb 2003 01:10:52 -0000 1.4 @@ -27,14 +27,35 @@ -void led_init(void); -void led_on(void); -void led_off(void); +int led_init(void); +int led_on(void); +int led_off(void); void led_toggle(void); void led_lock(void); void led_unlock(void); +typedef void (*led_on_func_t)(void); +typedef void (*led_off_func_t)(void); +typedef void (*led_toggle_func_t)(void); +typedef void (*led_lock_func_t)(void); +typedef void (*led_unlock_func_t)(void); +typedef struct { + led_on_func_t led_on; + led_off_func_t led_off; + led_toggle_func_t led_toggle; + led_lock_func_t led_lock; + led_unlock_func_t led_unlock; +} led_driver_t; +/* implemented LED drivers */ +extern led_driver_t sa11x0_gpio_led_driver; +extern led_driver_t mmap_led_driver; + +/* FIXME: This still needs to be implemented */ +/* extern led_driver_t pxa_gpio_led_driver; */ + +/* defined in arch specific file */ +extern led_driver_t *led_driver; #endif |