Changeset 118 for trunk


Ignore:
Timestamp:
Jul 11, 2011, 11:08:37 AM (14 years ago)
Author:
Markus Thielen
Message:

include time stamps in debug log

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/libc.c

    r116 r118  
    5858                                                ULONG parm2);
    5959static int              mdelay_cal_end         (void);
     60static void             printf_nts             (const char *fmt, ...);
    6061
    6162/* ------------------------ global/static variables ------------------------ */
     
    276277 *        messages should never exceed 1024 bytes.
    277278 */
    278 void vprintf(const char *fmt, va_list va)
     279void vprintf(int ts, const char *fmt, va_list va)
    279280{
    280281  static char buf[1024];
    281282  char *s;
    282   int len;
     283  int len = 0;
    283284
    284285  spin_lock(com_lock);
    285 
    286   len = vsprintf(buf, fmt, va);
     286 
     287  if (ts) {
     288    /* include timestamp */
     289    if (gis) {
     290      len = sprintf(buf, "[%ld] ", gis->msecs);
     291    } else {
     292      len = sprintf(buf, "[gis=0] ");
     293    }
     294  }
     295
     296  len += vsprintf(buf + len, fmt, va);
    287297
    288298   if (com_base == 0) {
     
    335345
    336346  va_start(va, fmt);
    337   vprintf(fmt, va);
    338 }
     347  vprintf(1, fmt, va);
     348}
     349
     350/******************************************************************************
     351 * Print messages to COM port with no time stamp
     352 */
     353static void printf_nts(const char *fmt, ...)
     354{
     355  va_list va;
     356
     357  va_start(va, fmt);
     358  vprintf(0, fmt, va);
     359}
     360
    339361
    340362/******************************************************************************
     
    383405  /* print header */
    384406  va_start(va, fmt);
    385   vprintf(fmt, va);
     407  vprintf(1, fmt, va);
    386408
    387409  /* print hex block */
    388410  while (len > 0) {
    389     printf("%Fp ", buf);
     411    printf_nts("%Fp ", buf);
    390412
    391413    /* print hex block */
    392414    for (i = 0; i < 16; i++) {
    393415      if (i < len) {
    394         printf("%c%02x", ((i == 8) ? '-' : ' '), buf[i]);
     416        printf_nts("%c%02x", ((i == 8) ? '-' : ' '), buf[i]);
    395417      } else {
    396         printf("   ");
     418        printf_nts("   ");
    397419      }
    398420    }
    399421
    400422    /* print ASCII block */
    401     printf("   ");
     423    printf_nts("   ");
    402424    for (i = 0; i < ((len > 16) ? 16 : len); i++) {
    403       printf("%c", (buf[i] >= 32 && buf[i] < 128) ? buf[i] : '.');
    404     }
    405     printf("\n");
     425      printf_nts("%c", (buf[i] >= 32 && buf[i] < 128) ? buf[i] : '.');
     426    }
     427    printf_nts("\n");
    406428
    407429    buf += 16;
Note: See TracChangeset for help on using the changeset viewer.