Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.9 KiB

  1. /**************************************************************************************************************************
  2. * DEBUG.C SigmaTel STIR4200 debug module
  3. **************************************************************************************************************************
  4. * (C) Unpublished Copyright of Sigmatel, Inc. All Rights Reserved.
  5. *
  6. *
  7. * Created: 04/06/2000
  8. * Version 0.9
  9. *
  10. *
  11. **************************************************************************************************************************/
  12. #if DBG
  13. #include "ndis.h"
  14. #include "stdarg.h"
  15. #include "stdio.h"
  16. #include "usbdi.h"
  17. #include "usbdlib.h"
  18. #include "debug.h"
  19. //
  20. // begin, data/code used only in DBG build
  21. //
  22. IRUSB_DBGDATA gDbgBuf = { 0, 0, 0 };
  23. //
  24. // ptr to global debug data struct; txt buffer is only allocated in DBG builds
  25. //
  26. PIRUSB_DBGDATA gpDbg = &gDbgBuf;
  27. #ifdef DEBUG
  28. int DbgSettings =
  29. //DBG_PNP |
  30. //DBG_TIME |
  31. //DBG_DBG |
  32. //DBG_STAT |
  33. //DBG_FUNCTION |
  34. DBG_ERROR |
  35. //DBG_WARN |
  36. //DBG_BUFS |
  37. //DBG_OUT |
  38. 0;
  39. #endif
  40. /*****************************************************************************
  41. *
  42. * Function: DBG_PrintBuf
  43. *
  44. * Synopsis: Prints a message to the debugger.
  45. *
  46. * Arguments: bufptr - pointer to the data to print
  47. * buflen - length of data
  48. *
  49. * Returns: None
  50. *
  51. * Notes:
  52. *
  53. *****************************************************************************/
  54. VOID
  55. DBG_PrintBuf(
  56. IN PUCHAR bufptr,
  57. int buflen
  58. )
  59. {
  60. int i, linei;
  61. #define ISPRINT(ch) (((ch) >= ' ') && ((ch) <= '~'))
  62. #define PRINTCHAR(ch) (UCHAR)(ISPRINT(ch) ? (ch) : '.')
  63. DbgPrint("\r\n %d bytes @%x:", buflen, bufptr);
  64. //
  65. // Print whole lines of 8 characters with HEX and ASCII
  66. //
  67. for (i = 0; i+8 <= buflen; i += 8)
  68. {
  69. UCHAR ch0 = bufptr[i+0],
  70. ch1 = bufptr[i+1], ch2 = bufptr[i+2],
  71. ch3 = bufptr[i+3], ch4 = bufptr[i+4],
  72. ch5 = bufptr[i+5], ch6 = bufptr[i+6],
  73. ch7 = bufptr[i+7];
  74. DbgPrint("\r\n %02x %02x %02x %02x %02x %02x %02x %02x"
  75. " %c %c %c %c %c %c %c %c",
  76. ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7,
  77. PRINTCHAR(ch0), PRINTCHAR(ch1),
  78. PRINTCHAR(ch2), PRINTCHAR(ch3),
  79. PRINTCHAR(ch4), PRINTCHAR(ch5),
  80. PRINTCHAR(ch6), PRINTCHAR(ch7));
  81. }
  82. //
  83. // Print final incomplete line
  84. //
  85. DbgPrint("\r\n ");
  86. for (linei = 0; (linei < 8) && (i < buflen); i++, linei++)
  87. {
  88. DbgPrint(" %02x", (int)(bufptr[i]));
  89. }
  90. DbgPrint(" ");
  91. i -= linei;
  92. while (linei++ < 8) DbgPrint(" ");
  93. for (linei = 0; (linei < 8) && (i < buflen); i++, linei++){
  94. UCHAR ch = bufptr[i];
  95. DbgPrint(" %c", PRINTCHAR(ch));
  96. }
  97. DbgPrint("\t\t<>\r\n");
  98. }
  99. #endif // end , if DBG