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.

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