From eedcd078fe1434d93b84322c4e14c52f80282a41 Mon Sep 17 00:00:00 2001 From: wdenk Date: Wed, 8 Sep 2004 22:03:11 +0000 Subject: * Patch by Detlev Zundel, 08 Sep 2004: Update etags build target * Improve NetConsole support: add support for broadcast destination address and buffered input. * Cleanup compiler warnings for GCC 3.3.x and later * Fix problem in cmd_jffs2.c introduced by CFG_JFFS_SINGLE_PART patch --- drivers/i82365.c | 3 +- drivers/netconsole.c | 104 +++++++++++++++++++++++++++++++++++++++++---------- drivers/smiLynxEM.c | 2 +- 3 files changed, 87 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/i82365.c b/drivers/i82365.c index 5f44eac..1ac50d7 100644 --- a/drivers/i82365.c +++ b/drivers/i82365.c @@ -429,7 +429,8 @@ static int i365_set_io_map (socket_info_t * s, struct pccard_io_map *io) u_char map, ioctl; map = io->map; - if ((map > 1) || (io->start > 0xffff) || (io->stop > 0xffff) || + /* comment out: comparison is always false due to limited range of data type */ + if ((map > 1) || /* (io->start > 0xffff) || (io->stop > 0xffff) || */ (io->stop < io->start)) return -1; /* Turn off the window before changing anything */ diff --git a/drivers/netconsole.c b/drivers/netconsole.c index 7e19161..6c27c08 100644 --- a/drivers/netconsole.c +++ b/drivers/netconsole.c @@ -33,10 +33,17 @@ #error define CONFIG_NET_MULTI to use netconsole #endif -static uchar nc_buf = 0; /* input buffer */ +static char input_buffer[512]; +static int input_size = 0; /* char count in input buffer */ +static int input_offset = 0; /* offset to valid chars in input buffer */ static int input_recursion = 0; static int output_recursion = 0; static int net_timeout; +static uchar nc_ether[6]; /* server enet address */ +static IPaddr_t nc_ip; /* server ip */ +static short nc_port; /* source/target port */ +static const char *output_packet; /* used by first send udp */ +static int output_packet_len = 0; static void nc_wait_arp_handler (uchar * pkt, unsigned dest, unsigned src, unsigned len) @@ -47,7 +54,7 @@ static void nc_wait_arp_handler (uchar * pkt, unsigned dest, unsigned src, static void nc_handler (uchar * pkt, unsigned dest, unsigned src, unsigned len) { - if (nc_buf) + if (input_size) NetState = NETLOOP_SUCCESS; /* got input - quit net loop */ } @@ -58,23 +65,45 @@ static void nc_timeout (void) void NcStart (void) { - if (memcmp (NetServerEther, NetEtherNullAddr, 6)) { + if (!output_packet_len || memcmp (nc_ether, NetEtherNullAddr, 6)) { /* going to check for input packet */ NetSetHandler (nc_handler); NetSetTimeout (net_timeout, nc_timeout); } else { /* send arp request */ + uchar *pkt; NetSetHandler (nc_wait_arp_handler); - NetSendUDPPacket (NetServerEther, NetServerIP, 6665, 6666, 0); + pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE; + memcpy (pkt, output_packet, output_packet_len); + NetSendUDPPacket (nc_ether, nc_ip, nc_port, nc_port, output_packet_len); } } int nc_input_packet (uchar * pkt, unsigned dest, unsigned src, unsigned len) { - if (dest != 6666 || !len) + int end, chunk; + + if (dest != nc_port || !len) return 0; /* not for us */ - nc_buf = *pkt; + if (input_size == sizeof input_buffer) + return 1; /* no space */ + if (len > sizeof input_buffer - input_size) + len = sizeof input_buffer - input_size; + + end = input_offset + input_size; + if (end > sizeof input_buffer) + end -= sizeof input_buffer; + + chunk = len; + if (end + len > sizeof input_buffer) { + chunk = sizeof input_buffer - end; + memcpy(input_buffer, pkt + chunk, len - chunk); + } + memcpy (input_buffer + end, pkt, chunk); + + input_size += len; + return 1; } @@ -85,11 +114,20 @@ static void nc_send_packet (const char *buf, int len) struct eth_device *eth; int inited = 0; uchar *pkt; + uchar *ether; + IPaddr_t ip; - if (!memcmp (NetServerEther, NetEtherNullAddr, 6)) + if ((eth = eth_get_dev ()) == NULL) { return; + } - if ((eth = eth_get_dev ()) == NULL) { + if (!memcmp (nc_ether, NetEtherNullAddr, 6)) { + if (eth->state == ETH_STATE_ACTIVE) + return; /* inside net loop */ + output_packet = buf; + output_packet_len = len; + NetLoop (NETCONS); /* wait for arp reply and send packet */ + output_packet_len = 0; return; } @@ -100,7 +138,9 @@ static void nc_send_packet (const char *buf, int len) } pkt = (uchar *) NetTxPacket + NetEthHdrSize () + IP_HDR_SIZE; memcpy (pkt, buf, len); - NetSendUDPPacket (NetServerEther, NetServerIP, 6666, 6665, len); + ether = nc_ether; + ip = nc_ip; + NetSendUDPPacket (ether, ip, nc_port, nc_port, len); if (inited) eth_halt (); @@ -108,10 +148,31 @@ static void nc_send_packet (const char *buf, int len) int nc_start (void) { - if (memcmp (NetServerEther, NetEtherNullAddr, 6)) - return 0; - - return NetLoop (NETCONS); /* wait for arp reply */ + int netmask, our_ip; + + nc_port = 6666; /* default port */ + + if (getenv ("ncip")) { + nc_ip = getenv_IPaddr ("ncip"); + if (!nc_ip) + return -1; /* ncip is 0.0.0.0 */ + char *p = strchr (getenv ("ncip"), ':'); + if (p) + nc_port = simple_strtoul (p + 1, NULL, 10); + } else + nc_ip = ~0; /* ncip is not set */ + + our_ip = getenv_IPaddr ("ipaddr"); + netmask = getenv_IPaddr ("netmask"); + + if (nc_ip == ~0 || /* 255.255.255.255 */ + ((netmask & our_ip) == (netmask & nc_ip) && /* on the same net */ + (netmask | nc_ip) == ~0)) /* broadcast to our net */ + memset (nc_ether, 0xff, sizeof nc_ether); + else + memset (nc_ether, 0, sizeof nc_ether); /* force arp request */ + + return 0; } void nc_putc (char c) @@ -146,15 +207,18 @@ int nc_getc (void) input_recursion = 1; net_timeout = 0; /* no timeout */ - while (!nc_buf) + while (!input_size) NetLoop (NETCONS); input_recursion = 0; - uchar tmp = nc_buf; + uchar c = input_buffer[input_offset]; + input_offset++; + if (input_offset >= sizeof input_buffer) + input_offset -= sizeof input_buffer; + input_size--; - nc_buf = 0; - return tmp; + return c; } int nc_tstc (void) @@ -164,7 +228,7 @@ int nc_tstc (void) if (input_recursion) return 0; - if (nc_buf) + if (input_size) return 1; eth = eth_get_dev (); @@ -174,11 +238,11 @@ int nc_tstc (void) input_recursion = 1; net_timeout = 1; - NetLoop (NETCONS); /* kind of poll */ + NetLoop (NETCONS); /* kind of poll */ input_recursion = 0; - return nc_buf != 0; + return input_size != 0; } int drv_nc_init (void) diff --git a/drivers/smiLynxEM.c b/drivers/smiLynxEM.c index 26469e2..94092a3 100644 --- a/drivers/smiLynxEM.c +++ b/drivers/smiLynxEM.c @@ -550,7 +550,7 @@ static void smiLoadCcr (struct ctfb_res_modes *var, unsigned short device_id) smiWrite (SMI_INDX_C4, 0x6b, 0x15); /* VCLK */ - freq = 1000000000000L / var -> pixclock; + freq = 1000000000000LL / var -> pixclock; FindPQ ((unsigned int)freq, &p, &q); -- cgit v1.1