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.

145 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1991-8 Microsoft Corporation
  3. Module Name:
  4. errlog.c
  5. Abstract:
  6. this module provides error logging capabilities for
  7. the redbook driver
  8. Author:
  9. Henry Gabryjelski (henrygab) 1-Oct-1998
  10. Environment:
  11. kernel mode only
  12. Notes:
  13. Revision History:
  14. --*/
  15. #include "redbook.h"
  16. #include "proto.h"
  17. #ifdef _USE_ETW
  18. #include "errlog.tmh"
  19. #endif // _USE_ETW
  20. VOID
  21. RedBookLogError(
  22. IN PREDBOOK_DEVICE_EXTENSION DeviceExtension,
  23. IN NTSTATUS IoErrorCode,
  24. IN NTSTATUS FinalStatus
  25. )
  26. /*++
  27. Routine Description:
  28. This routine performs error logging for the redbook driver.
  29. Arguments:
  30. Extension - Extension.
  31. UniqueErrorValue - Values defined to uniquely identify error location.
  32. Return Value:
  33. None
  34. --*/
  35. {
  36. PIO_ERROR_LOG_PACKET errorLogPacket;
  37. ULONG count;
  38. ULONG rCount;
  39. USHORT simpleCode;
  40. ULONG packetSize;
  41. count = InterlockedIncrement(&DeviceExtension->ErrorLog.Count);
  42. simpleCode = (USHORT)(IoErrorCode & REDBOOK_ERR_MASK);
  43. ASSERT(simpleCode < REDBOOK_ERR_MAXIMUM);
  44. switch (IoErrorCode) {
  45. case REDBOOK_ERR_TOO_MANY_READ_ERRORS:
  46. case REDBOOK_ERR_TOO_MANY_STREAM_ERRORS:
  47. case REDBOOK_ERR_CANNOT_OPEN_SYSAUDIO_MIXER:
  48. case REDBOOK_ERR_CANNOT_CREATE_VIRTUAL_SOURCE:
  49. case REDBOOK_ERR_CANNOT_OPEN_PREFERRED_WAVEOUT_DEVICE:
  50. case REDBOOK_ERR_CANNOT_GET_NUMBER_OF_PINS:
  51. case REDBOOK_ERR_CANNOT_CONNECT_TO_PLAYBACK_PINS:
  52. case REDBOOK_ERR_WMI_INIT_FAILED:
  53. case REDBOOK_ERR_CANNOT_CREATE_THREAD:
  54. case REDBOOK_ERR_INSUFFICIENT_DATA_STREAM_PAUSED:
  55. case REDBOOK_ERR_UNSUPPORTED_DRIVE:
  56. NOTHING;
  57. break;
  58. default:
  59. KdPrintEx((DPFLTR_REDBOOK_ID, RedbookDebugError, "[redbook] "
  60. "LogErr !! Invalid error code %lx\n", IoErrorCode));
  61. return;
  62. }
  63. //
  64. // Use an exponential backoff algorithm to log events.
  65. //
  66. rCount = InterlockedIncrement(&DeviceExtension->ErrorLog.RCount[simpleCode]);
  67. if (CountOfSetBits(rCount) != 1) {
  68. KdPrintEx((DPFLTR_REDBOOK_ID, RedbookDebugErrlog, "[redbook] "
  69. "LogError => IoErrorCode %lx Occurance %d\n",
  70. IoErrorCode, rCount));
  71. return;
  72. }
  73. KdPrintEx((DPFLTR_REDBOOK_ID, RedbookDebugErrlog, "[redbook] "
  74. "LogError => IoErrorCode %lx Occurance %d\n",
  75. IoErrorCode, rCount));
  76. packetSize = sizeof(IO_ERROR_LOG_PACKET) + sizeof(ULONG);
  77. errorLogPacket = (PIO_ERROR_LOG_PACKET)
  78. IoAllocateErrorLogEntry(DeviceExtension->SelfDeviceObject,
  79. (UCHAR)packetSize);
  80. if (errorLogPacket==NULL) {
  81. KdPrintEx((DPFLTR_REDBOOK_ID, RedbookDebugErrlog, "[redbook] "
  82. "LogError => unable to allocate error log packet\n"));
  83. return;
  84. }
  85. KdPrintEx((DPFLTR_REDBOOK_ID, RedbookDebugErrlog, "[redbook] "
  86. "LogError => allocated error log at %p, size %x\n",
  87. errorLogPacket, packetSize));
  88. //
  89. // this function relies upon IoAllocateErrorLogEntry() zero'ing the packet
  90. //
  91. errorLogPacket->MajorFunctionCode = -1;
  92. errorLogPacket->IoControlCode = -1;
  93. errorLogPacket->ErrorCode = IoErrorCode;
  94. errorLogPacket->FinalStatus = FinalStatus;
  95. errorLogPacket->SequenceNumber = count;
  96. errorLogPacket->DumpDataSize = 4; // bytes
  97. errorLogPacket->DumpData[0] = rCount;
  98. IoWriteErrorLogEntry(errorLogPacket);
  99. return;
  100. }