Source code of Windows XP (NT5)
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.

175 lines
3.2 KiB

  1. /*
  2. ************************************************************************
  3. *
  4. * SETTINGS.c
  5. *
  6. *
  7. * Portions Copyright (C) 1996-2001 National Semiconductor Corp.
  8. * All rights reserved.
  9. * Copyright (C) 1996-2001 Microsoft Corporation. All Rights Reserved.
  10. *
  11. *
  12. *
  13. *************************************************************************
  14. */
  15. #include "nsc.h"
  16. const baudRateInfo supportedBaudRateTable[NUM_BAUDRATES] = {
  17. {
  18. BAUDRATE_2400,
  19. 2400,
  20. NDIS_IRDA_SPEED_2400,
  21. },
  22. {
  23. BAUDRATE_9600,
  24. 9600,
  25. NDIS_IRDA_SPEED_9600,
  26. },
  27. {
  28. BAUDRATE_19200,
  29. 19200,
  30. NDIS_IRDA_SPEED_19200,
  31. },
  32. {
  33. BAUDRATE_38400,
  34. 38400,
  35. NDIS_IRDA_SPEED_38400,
  36. },
  37. {
  38. BAUDRATE_57600,
  39. 57600,
  40. NDIS_IRDA_SPEED_57600,
  41. },
  42. {
  43. BAUDRATE_115200,
  44. 115200,
  45. NDIS_IRDA_SPEED_115200,
  46. },
  47. {
  48. BAUDRATE_576000,
  49. 576000,
  50. NDIS_IRDA_SPEED_576K,
  51. },
  52. {
  53. BAUDRATE_1152000,
  54. 1152000,
  55. NDIS_IRDA_SPEED_1152K,
  56. },
  57. {
  58. BAUDRATE_4000000,
  59. 4000000,
  60. NDIS_IRDA_SPEED_4M,
  61. }
  62. };
  63. #if DBG
  64. // UINT dbgOpt = DBG_LOG | DBG_FIR_MODE ;
  65. UINT dbgOpt = DBG_ERR; //|DBG_FIR_MODE|DBG_SIR_MODE|DBG_BUF;
  66. #ifdef DBG_ADD_PKT_ID
  67. BOOLEAN addPktIdOn = TRUE;
  68. #endif
  69. /*
  70. * LOGGING stuff
  71. */
  72. void LogEvent(char *msg, UINT val)
  73. {
  74. dbgLog[dbgLogIndex].msg = msg;
  75. NdisGetCurrentSystemTime((PLARGE_INTEGER)&dbgLog[dbgLogIndex].usec);
  76. dbgLog[dbgLogIndex].val = val;
  77. dbgLogIndex++;
  78. dbgLogIndex %= LOG_LENGTH;
  79. }
  80. UINT dbgLogIndex = 0;
  81. struct logEntry dbgLog[LOG_LENGTH] = {0};
  82. void DumpLog()
  83. {
  84. UINT i;
  85. for (i = 0; i < dbgLogIndex; i++) {
  86. ULONG usec = (ULONG)dbgLog[i].usec;
  87. ULONG last_usec = (ULONG) ((i == 0) ?
  88. 0 : (UINT) dbgLog[i-1].usec);
  89. ULONG dif;
  90. if (last_usec > usec) {
  91. DbgPrint("----- > LOG WRAPPING ---->\r\n");
  92. }
  93. dif = usec - last_usec;
  94. DbgPrint("%012uld :%8d %-40s : 0x%x\r\n",
  95. usec, dif, dbgLog[i].msg, dbgLog[i].val);
  96. }
  97. dbgOpt &= ~DBG_DUMPLOG;
  98. dbgLogIndex = 0;
  99. }
  100. VOID DBG_PrintBuf(PUCHAR bufptr, UINT buflen)
  101. {
  102. UINT i, linei;
  103. #define ISPRINT(ch) (((ch) >= ' ') && ((ch) <= '~'))
  104. #define PRINTCHAR(ch) (UCHAR)(ISPRINT(ch) ? (ch) : '.')
  105. DbgPrint("\r\n %d bytes @%xh:", buflen, bufptr);
  106. /*
  107. * Print whole lines of 8 characters with HEX and ASCII
  108. */
  109. for (i = 0; i+8 <= (UINT)buflen; i += 8) {
  110. UCHAR ch0 = bufptr[i+0],
  111. ch1 = bufptr[i+1], ch2 = bufptr[i+2],
  112. ch3 = bufptr[i+3], ch4 = bufptr[i+4],
  113. ch5 = bufptr[i+5], ch6 = bufptr[i+6],
  114. ch7 = bufptr[i+7];
  115. DbgPrint("\r\n %02x %02x %02x %02x %02x %02x %02x %02x"
  116. " %c %c %c %c %c %c %c %c",
  117. ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7,
  118. PRINTCHAR(ch0), PRINTCHAR(ch1),
  119. PRINTCHAR(ch2), PRINTCHAR(ch3),
  120. PRINTCHAR(ch4), PRINTCHAR(ch5),
  121. PRINTCHAR(ch6), PRINTCHAR(ch7));
  122. }
  123. /*
  124. * Print final incomplete line
  125. */
  126. DbgPrint("\r\n ");
  127. for (linei = 0; (linei < 8) && (i < buflen); i++, linei++){
  128. DbgPrint(" %02x", (UINT)(bufptr[i]));
  129. }
  130. DbgPrint(" ");
  131. i -= linei;
  132. while (linei++ < 8) DbgPrint(" ");
  133. for (linei = 0; (linei < 8) && (i < buflen); i++, linei++){
  134. UCHAR ch = bufptr[i];
  135. DbgPrint(" %c", PRINTCHAR(ch));
  136. }
  137. DbgPrint("\t\t<>\r\n");
  138. }
  139. VOID DBG_NDIS_Buffer(PNDIS_BUFFER ndisBuf);
  140. VOID DBG_NDIS_Buffer(PNDIS_BUFFER ndisBuf)
  141. {
  142. UCHAR *ptr;
  143. UINT bufLen;
  144. NdisQueryBuffer(ndisBuf, (PVOID *)&ptr, &bufLen);
  145. DBG_PrintBuf(ptr, bufLen);
  146. }
  147. #endif