ia64/xen-unstable

changeset 3875:ffb2d7ac4b7f

bitkeeper revision 1.1228 (421803d5d7vOI2phFwJN5YLJZi4dkg)

cleanup.
author kaf24@scramble.cl.cam.ac.uk
date Sun Feb 20 03:28:21 2005 +0000 (2005-02-20)
parents ad1d06d64313
children f9bc35b38b6c
files xen/common/keyhandler.c xen/drivers/char/console.c xen/include/xen/lib.h
line diff
     1.1 --- a/xen/common/keyhandler.c	Sat Feb 19 20:01:12 2005 +0000
     1.2 +++ b/xen/common/keyhandler.c	Sun Feb 20 03:28:21 2005 +0000
     1.3 @@ -158,11 +158,10 @@ void do_debug_key(unsigned char key, str
     1.4  #ifndef NDEBUG
     1.5  void debugtrace_key(unsigned char key)
     1.6  {
     1.7 -    static int send_to_console = 0;
     1.8 -
     1.9 -    send_to_console = !send_to_console;
    1.10 -    printk("Toggling the state of debugtrace_printk\n");
    1.11 -    debugtrace_dump(send_to_console);
    1.12 +    debugtrace_send_to_console = !debugtrace_send_to_console;
    1.13 +    debugtrace_dump();
    1.14 +    printk("debugtrace_printk now writing to %s.\n",
    1.15 +           debugtrace_send_to_console ? "console" : "buffer");
    1.16  }
    1.17  #endif
    1.18  
     2.1 --- a/xen/drivers/char/console.c	Sat Feb 19 20:01:12 2005 +0000
     2.2 +++ b/xen/drivers/char/console.c	Sun Feb 20 03:28:21 2005 +0000
     2.3 @@ -476,40 +476,19 @@ void console_force_lock(void)
     2.4  
     2.5  #ifndef NDEBUG
     2.6  
     2.7 +/* Send output direct to console, or buffer it? */
     2.8 +int debugtrace_send_to_console;
     2.9 +
    2.10  static unsigned char *debugtrace_buf; /* Debug-trace buffer */
    2.11  static unsigned int   debugtrace_prd; /* Producer index     */
    2.12  static unsigned int   debugtrace_kilobytes = 128, debugtrace_bytes;
    2.13 -static int            debugtrace_send_to_console = 0;
    2.14  static spinlock_t debugtrace_lock = SPIN_LOCK_UNLOCKED;
    2.15  integer_param("debugtrace", debugtrace_kilobytes);
    2.16  
    2.17 -
    2.18 -static void _debugtrace_reset(int send_to_console)
    2.19 -{
    2.20 -    if (send_to_console)
    2.21 -        printk("debugtrace_printk now writting to console\n");
    2.22 -    else
    2.23 -        printk("debugtrace_printk now writting to buffer\n");
    2.24 -
    2.25 -    if ( debugtrace_bytes != 0 )
    2.26 -        memset(debugtrace_buf, '\0', debugtrace_bytes);
    2.27 -
    2.28 -    debugtrace_prd = 0;
    2.29 -    debugtrace_send_to_console = send_to_console;
    2.30 -}
    2.31 -
    2.32 -void debugtrace_reset(int send_to_console)
    2.33 -{
    2.34 -    unsigned long flags;
    2.35 -
    2.36 -    spin_lock_irqsave(&debugtrace_lock, flags);
    2.37 -    _debugtrace_reset(send_to_console);
    2.38 -    spin_unlock_irqrestore(&debugtrace_lock, flags);
    2.39 -}
    2.40 -
    2.41 -void debugtrace_dump(int send_to_console)
    2.42 +void debugtrace_dump(void)
    2.43  {
    2.44      int _watchdog_on = watchdog_on;
    2.45 +    unsigned long flags;
    2.46  
    2.47      if ( debugtrace_bytes == 0 )
    2.48          return;
    2.49 @@ -517,7 +496,7 @@ void debugtrace_dump(int send_to_console
    2.50      /* Watchdog can trigger if we print a really large buffer. */
    2.51      watchdog_on = 0;
    2.52  
    2.53 -    spin_lock(&debugtrace_lock);
    2.54 +    spin_lock_irqsave(&debugtrace_lock, flags);
    2.55  
    2.56      /* Print oldest portion of the ring. */
    2.57      serial_puts(sercon_handle, &debugtrace_buf[debugtrace_prd]);
    2.58 @@ -526,18 +505,18 @@ void debugtrace_dump(int send_to_console
    2.59      debugtrace_buf[debugtrace_prd] = '\0';
    2.60      serial_puts(sercon_handle, &debugtrace_buf[0]);
    2.61  
    2.62 -    _debugtrace_reset(send_to_console);
    2.63 +    memset(debugtrace_buf, '\0', debugtrace_bytes);
    2.64  
    2.65 -    spin_unlock(&debugtrace_lock);
    2.66 +    spin_unlock_irqrestore(&debugtrace_lock, flags);
    2.67  
    2.68      watchdog_on = _watchdog_on;
    2.69  }
    2.70  
    2.71  void debugtrace_printk(const char *fmt, ...)
    2.72  {
    2.73 -    static char       buf[1024];
    2.74 +    static char    buf[1024];
    2.75  
    2.76 -    va_list       args;
    2.77 +    va_list        args;
    2.78      unsigned char *p;
    2.79      unsigned long  flags;
    2.80  
    2.81 @@ -550,7 +529,7 @@ void debugtrace_printk(const char *fmt, 
    2.82      (void)vsnprintf(buf, sizeof(buf), fmt, args);
    2.83      va_end(args);
    2.84  
    2.85 -    if (debugtrace_send_to_console)
    2.86 +    if ( debugtrace_send_to_console )
    2.87      {
    2.88          serial_puts(sercon_handle, buf);
    2.89      }
    2.90 @@ -558,10 +537,9 @@ void debugtrace_printk(const char *fmt, 
    2.91      {
    2.92          for ( p = buf; *p != '\0'; p++ )
    2.93          {
    2.94 -            debugtrace_buf[debugtrace_prd++] = *p;
    2.95 -            
    2.96 -            /* always leave a null byte at the end of the buffer */
    2.97 -            if (debugtrace_prd == debugtrace_bytes-1)
    2.98 +            debugtrace_buf[debugtrace_prd++] = *p;            
    2.99 +            /* Always leave a nul byte at the end of the buffer. */
   2.100 +            if ( debugtrace_prd == (debugtrace_bytes - 1) )
   2.101                  debugtrace_prd = 0;
   2.102          }
   2.103      }
   2.104 @@ -586,8 +564,6 @@ static int __init debugtrace_init(void)
   2.105      debugtrace_buf = (unsigned char *)alloc_xenheap_pages(order);
   2.106      ASSERT(debugtrace_buf != NULL);
   2.107  
   2.108 -    debugtrace_reset(0);
   2.109 -
   2.110      return 0;
   2.111  }
   2.112  __initcall(debugtrace_init);
   2.113 @@ -611,7 +587,7 @@ void panic(const char *fmt, ...)
   2.114      unsigned long flags;
   2.115      extern void machine_restart(char *);
   2.116      
   2.117 -    debugtrace_dump(0);
   2.118 +    debugtrace_dump();
   2.119  
   2.120      va_start(args, fmt);
   2.121      (void)vsnprintf(buf, sizeof(buf), fmt, args);
     3.1 --- a/xen/include/xen/lib.h	Sat Feb 19 20:01:12 2005 +0000
     3.2 +++ b/xen/include/xen/lib.h	Sun Feb 20 03:28:21 2005 +0000
     3.3 @@ -7,7 +7,7 @@
     3.4  #include <xen/string.h>
     3.5  
     3.6  #define BUG() do {					\
     3.7 -    debugtrace_dump(0);                                 \
     3.8 +    debugtrace_dump();                                  \
     3.9      printk("BUG at %s:%d\n", __FILE__, __LINE__);	\
    3.10      FORCE_CRASH();                                      \
    3.11  } while ( 0 )
    3.12 @@ -30,13 +30,12 @@ struct domain;
    3.13  void cmdline_parse(char *cmdline);
    3.14  
    3.15  #ifndef NDEBUG
    3.16 -extern void debugtrace_reset(int send_to_console);
    3.17 -extern void debugtrace_dump(int send_to_console);
    3.18 +extern int debugtrace_send_to_console;
    3.19 +extern void debugtrace_dump(void);
    3.20  extern void debugtrace_printk(const char *fmt, ...);
    3.21  #else
    3.22 -#define debugtrace_reset(_send_to_console) ((void)0)
    3.23 -#define debugtrace_dump(_send_to_console)  ((void)0)
    3.24 -#define debugtrace_printk(_f, ...)         ((void)0)
    3.25 +#define debugtrace_dump()          ((void)0)
    3.26 +#define debugtrace_printk(_f, ...) ((void)0)
    3.27  #endif
    3.28  
    3.29  #define printk printf