ia64/xen-unstable

changeset 16071:2d761ca771fb

xen: Changes to printk handling:
1. Command-line option 'console_timestamps' adds a timestamp prefix
to each line of Xen console output (x86 only, after CMOS has been
interrogated).
2. Clean up prefix handling and vanity banner info.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Thu Oct 04 17:58:16 2007 +0100 (2007-10-04)
parents 65c4977850d7
children b629d7a2bcc7
files xen/arch/ia64/xen/xensetup.c xen/arch/x86/time.c xen/drivers/char/console.c xen/include/asm-ia64/time.h xen/include/asm-powerpc/time.h xen/include/asm-x86/time.h xen/include/xen/console.h
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Thu Oct 04 14:21:11 2007 +0100
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Thu Oct 04 17:58:16 2007 +0100
     1.3 @@ -315,7 +315,6 @@ void __init start_kernel(void)
     1.4  #endif
     1.5  
     1.6      init_console();
     1.7 -    set_printk_prefix("(XEN) ");
     1.8  
     1.9      if (running_on_sim || ia64_boot_param->domain_start == 0 ||
    1.10                            ia64_boot_param->domain_size == 0) {
     2.1 --- a/xen/arch/x86/time.c	Thu Oct 04 14:21:11 2007 +0100
     2.2 +++ b/xen/arch/x86/time.c	Thu Oct 04 17:58:16 2007 +0100
     2.3 @@ -1038,6 +1038,18 @@ int dom0_pit_access(struct ioreq *ioreq)
     2.4      return 0;
     2.5  }
     2.6  
     2.7 +struct tm wallclock_time(void)
     2.8 +{
     2.9 +    uint64_t seconds;
    2.10 +
    2.11 +    if ( !wc_sec )
    2.12 +        return (struct tm) { 0 };
    2.13 +
    2.14 +    seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec;
    2.15 +    do_div(seconds, 1000000000);
    2.16 +    return gmtime(seconds);
    2.17 +}
    2.18 +
    2.19  /*
    2.20   * Local variables:
    2.21   * mode: C
     3.1 --- a/xen/drivers/char/console.c	Thu Oct 04 14:21:11 2007 +0100
     3.2 +++ b/xen/drivers/char/console.c	Thu Oct 04 17:58:16 2007 +0100
     3.3 @@ -53,13 +53,15 @@ boolean_param("sync_console", opt_sync_c
     3.4  static int opt_console_to_ring;
     3.5  boolean_param("console_to_ring", opt_console_to_ring);
     3.6  
     3.7 +/* console_timestamps: include a timestamp prefix on every Xen console line. */
     3.8 +static int opt_console_timestamps;
     3.9 +boolean_param("console_timestamps", opt_console_timestamps);
    3.10 +
    3.11  #define CONRING_SIZE 16384
    3.12  #define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
    3.13  static char conring[CONRING_SIZE];
    3.14  static unsigned int conringc, conringp;
    3.15  
    3.16 -static char printk_prefix[16] = "";
    3.17 -
    3.18  static int sercon_handle = -1;
    3.19  
    3.20  static DEFINE_SPINLOCK(console_lock);
    3.21 @@ -448,6 +450,26 @@ static int printk_prefix_check(char *p, 
    3.22              ((loglvl < upper_thresh) && printk_ratelimit()));
    3.23  } 
    3.24  
    3.25 +static void printk_start_of_line(void)
    3.26 +{
    3.27 +    struct tm tm;
    3.28 +    char tstr[32];
    3.29 +
    3.30 +    __putstr("(XEN) ");
    3.31 +
    3.32 +    if ( !opt_console_timestamps )
    3.33 +        return;
    3.34 +
    3.35 +    tm = wallclock_time();
    3.36 +    if ( tm.tm_mday == 0 )
    3.37 +        return;
    3.38 +
    3.39 +    snprintf(tstr, sizeof(tstr), "[%04u-%02u-%02u %02u:%02u:%02u] ",
    3.40 +             1900 + tm.tm_year, tm.tm_mon, tm.tm_mday,
    3.41 +             tm.tm_hour, tm.tm_min, tm.tm_sec);
    3.42 +    __putstr(tstr);
    3.43 +}
    3.44 +
    3.45  void printk(const char *fmt, ...)
    3.46  {
    3.47      static char   buf[1024];
    3.48 @@ -475,7 +497,7 @@ void printk(const char *fmt, ...)
    3.49          if ( do_print )
    3.50          {
    3.51              if ( start_of_line )
    3.52 -                __putstr(printk_prefix);
    3.53 +                printk_start_of_line();
    3.54              __putstr(p);
    3.55              __putstr("\n");
    3.56          }
    3.57 @@ -490,7 +512,7 @@ void printk(const char *fmt, ...)
    3.58          if ( do_print )
    3.59          {
    3.60              if ( start_of_line )
    3.61 -                __putstr(printk_prefix);
    3.62 +                printk_start_of_line();
    3.63              __putstr(p);
    3.64          }
    3.65          start_of_line = 0;
    3.66 @@ -500,11 +522,6 @@ void printk(const char *fmt, ...)
    3.67      local_irq_restore(flags);
    3.68  }
    3.69  
    3.70 -void set_printk_prefix(const char *prefix)
    3.71 -{
    3.72 -    safe_strcpy(printk_prefix, prefix);
    3.73 -}
    3.74 -
    3.75  void __init init_console(void)
    3.76  {
    3.77      char *p;
    3.78 @@ -523,15 +540,12 @@ void __init init_console(void)
    3.79      serial_set_rx_handler(sercon_handle, serial_rx);
    3.80  
    3.81      /* HELLO WORLD --- start-of-day banner text. */
    3.82 -    printk(xen_banner());
    3.83 -    printk(" http://www.cl.cam.ac.uk/netos/xen\n");
    3.84 -    printk(" University of Cambridge Computer Laboratory\n\n");
    3.85 -    printk(" Xen version %d.%d%s (%s@%s) (%s) %s\n",
    3.86 +    __putstr(xen_banner());
    3.87 +    printk("Xen version %d.%d%s (%s@%s) (%s) %s\n",
    3.88             xen_major_version(), xen_minor_version(), xen_extra_version(),
    3.89             xen_compile_by(), xen_compile_domain(),
    3.90             xen_compiler(), xen_compile_date());
    3.91 -    printk(" Latest ChangeSet: %s\n\n", xen_changeset());
    3.92 -    set_printk_prefix("(XEN) ");
    3.93 +    printk("Latest ChangeSet: %s\n", xen_changeset());
    3.94  
    3.95      if ( opt_sync_console )
    3.96      {
    3.97 @@ -687,7 +701,7 @@ int __printk_ratelimit(int ratelimit_ms,
    3.98              snprintf(lost_str, sizeof(lost_str), "%d", lost);
    3.99              /* console_lock may already be acquired by printk(). */
   3.100              spin_lock_recursive(&console_lock);
   3.101 -            __putstr(printk_prefix);
   3.102 +            printk_start_of_line();
   3.103              __putstr("printk: ");
   3.104              __putstr(lost_str);
   3.105              __putstr(" messages suppressed.\n");
     4.1 --- a/xen/include/asm-ia64/time.h	Thu Oct 04 14:21:11 2007 +0100
     4.2 +++ b/xen/include/asm-ia64/time.h	Thu Oct 04 17:58:16 2007 +0100
     4.3 @@ -1,2 +1,9 @@
     4.4 +#ifndef _ASM_TIME_H_
     4.5 +#define _ASM_TIME_H_
     4.6 +
     4.7  #include <asm/linux/time.h>
     4.8  #include <asm/timex.h>
     4.9 +
    4.10 +#define wallclock_time() ((struct tm) { 0 })
    4.11 +
    4.12 +#endif /* _ASM_TIME_H_ */
     5.1 --- a/xen/include/asm-powerpc/time.h	Thu Oct 04 14:21:11 2007 +0100
     5.2 +++ b/xen/include/asm-powerpc/time.h	Thu Oct 04 17:58:16 2007 +0100
     5.3 @@ -80,4 +80,7 @@ static inline u64 tb_to_ns(u64 tb)
     5.4  {
     5.5      return tb * (__nano(1) / timebase_freq);
     5.6  }
     5.7 +
     5.8 +#define wallclock_time() ((struct tm) { 0 })
     5.9 +
    5.10  #endif
     6.1 --- a/xen/include/asm-x86/time.h	Thu Oct 04 14:21:11 2007 +0100
     6.2 +++ b/xen/include/asm-x86/time.h	Thu Oct 04 17:58:16 2007 +0100
     6.3 @@ -31,4 +31,7 @@ int dom0_pit_access(struct ioreq *ioreq)
     6.4  
     6.5  int cpu_frequency_change(u64 freq);
     6.6  
     6.7 +struct tm;
     6.8 +struct tm wallclock_time(void);
     6.9 +
    6.10  #endif /* __X86_TIME_H__ */
     7.1 --- a/xen/include/xen/console.h	Thu Oct 04 14:21:11 2007 +0100
     7.2 +++ b/xen/include/xen/console.h	Thu Oct 04 17:58:16 2007 +0100
     7.3 @@ -11,8 +11,6 @@
     7.4  #include <xen/guest_access.h>
     7.5  #include <public/xen.h>
     7.6  
     7.7 -void set_printk_prefix(const char *prefix);
     7.8 -
     7.9  long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
    7.10  
    7.11  void init_console(void);