X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fnetconsole.c;h=69089f92cec913b1ab6d0c33f94273d8cc10badf;hb=81735b2568cf634d601c0d4a1bbc3a3882bc8eda;hp=6c27c08f2aa5f7dc08e5d5996790109bad3439e5;hpb=eedcd078fe1434d93b84322c4e14c52f80282a41;p=oweals%2Fu-boot.git diff --git a/drivers/netconsole.c b/drivers/netconsole.c index 6c27c08f2a..69089f92ce 100644 --- a/drivers/netconsole.c +++ b/drivers/netconsole.c @@ -29,9 +29,7 @@ #include #include -#ifndef CONFIG_NET_MULTI -#error define CONFIG_NET_MULTI to use netconsole -#endif +DECLARE_GLOBAL_DATA_PTR; static char input_buffer[512]; static int input_size = 0; /* char count in input buffer */ @@ -109,8 +107,6 @@ int nc_input_packet (uchar * pkt, unsigned dest, unsigned src, unsigned len) static void nc_send_packet (const char *buf, int len) { - DECLARE_GLOBAL_DATA_PTR; - struct eth_device *eth; int inited = 0; uchar *pkt; @@ -153,11 +149,12 @@ int nc_start (void) nc_port = 6666; /* default port */ if (getenv ("ncip")) { + char *p; + nc_ip = getenv_IPaddr ("ncip"); if (!nc_ip) return -1; /* ncip is 0.0.0.0 */ - char *p = strchr (getenv ("ncip"), ':'); - if (p) + if ((p = strchr (getenv ("ncip"), ':')) != NULL) nc_port = simple_strtoul (p + 1, NULL, 10); } else nc_ip = ~0; /* ncip is not set */ @@ -188,13 +185,13 @@ void nc_putc (char c) void nc_puts (const char *s) { + int len; + if (output_recursion) return; output_recursion = 1; - int len = strlen (s); - - if (len > 512) + if ((len = strlen (s)) > 512) len = 512; nc_send_packet (s, len); @@ -204,6 +201,8 @@ void nc_puts (const char *s) int nc_getc (void) { + uchar c; + input_recursion = 1; net_timeout = 0; /* no timeout */ @@ -212,8 +211,8 @@ int nc_getc (void) input_recursion = 0; - uchar c = input_buffer[input_offset]; - input_offset++; + c = input_buffer[input_offset++]; + if (input_offset >= sizeof input_buffer) input_offset -= sizeof input_buffer; input_size--;