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.

124 lines
4.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: errlog.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "pch.h"
  11. VOID
  12. PptLogError(
  13. IN PDRIVER_OBJECT DriverObject,
  14. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  15. IN PHYSICAL_ADDRESS P1,
  16. IN PHYSICAL_ADDRESS P2,
  17. IN ULONG SequenceNumber,
  18. IN UCHAR MajorFunctionCode,
  19. IN UCHAR RetryCount,
  20. IN ULONG UniqueErrorValue,
  21. IN NTSTATUS FinalStatus,
  22. IN NTSTATUS SpecificIOStatus
  23. )
  24. /*++
  25. Routine Description:
  26. This routine allocates an error log entry, copies the supplied data
  27. to it, and requests that it be written to the error log file.
  28. Arguments:
  29. DriverObject - Supplies a pointer to the driver object for the device
  30. DeviceObject - Supplies a pointer to the device object associated
  31. with the device that had the error, early in
  32. initialization, one may not yet exist.
  33. P1,P2 - Supplies the physical addresses for the controller
  34. ports involved with the error if they are available
  35. and puts them through as dump data.
  36. SequenceNumber - Supplies a ulong value that is unique to an IRP over
  37. the life of the irp in this driver - 0 generally
  38. means an error not associated with an irp.
  39. MajorFunctionCode - Supplies the major function code of the irp if there
  40. is an error associated with it.
  41. RetryCount - Supplies the number of times a particular operation
  42. has been retried.
  43. UniqueErrorValue - Supplies a unique long word that identifies the
  44. particular call to this function.
  45. FinalStatus - Supplies the final status given to the irp that was
  46. associated with this error. If this log entry is
  47. being made during one of the retries this value
  48. will be STATUS_SUCCESS.
  49. SpecificIOStatus - Supplies the IO status for this particular error.
  50. Return Value:
  51. None.
  52. --*/
  53. {
  54. PIO_ERROR_LOG_PACKET ErrorLogEntry;
  55. PVOID ObjectToUse;
  56. SHORT DumpToAllocate;
  57. DD(NULL,DDE,"PptLogError()\n");
  58. if (ARGUMENT_PRESENT(DeviceObject)) {
  59. ObjectToUse = DeviceObject;
  60. } else {
  61. ObjectToUse = DriverObject;
  62. }
  63. DumpToAllocate = 0;
  64. if (P1.LowPart != 0 || P1.HighPart != 0) {
  65. DumpToAllocate = (SHORT) sizeof(PHYSICAL_ADDRESS);
  66. }
  67. if (P2.LowPart != 0 || P2.HighPart != 0) {
  68. DumpToAllocate += (SHORT) sizeof(PHYSICAL_ADDRESS);
  69. }
  70. ErrorLogEntry = IoAllocateErrorLogEntry(ObjectToUse,
  71. (UCHAR) (sizeof(IO_ERROR_LOG_PACKET) + DumpToAllocate));
  72. if (!ErrorLogEntry) {
  73. return;
  74. }
  75. ErrorLogEntry->ErrorCode = SpecificIOStatus;
  76. ErrorLogEntry->SequenceNumber = SequenceNumber;
  77. ErrorLogEntry->MajorFunctionCode = MajorFunctionCode;
  78. ErrorLogEntry->RetryCount = RetryCount;
  79. ErrorLogEntry->UniqueErrorValue = UniqueErrorValue;
  80. ErrorLogEntry->FinalStatus = FinalStatus;
  81. ErrorLogEntry->DumpDataSize = DumpToAllocate;
  82. if (DumpToAllocate) {
  83. RtlCopyMemory(ErrorLogEntry->DumpData, &P1, sizeof(PHYSICAL_ADDRESS));
  84. if (DumpToAllocate > sizeof(PHYSICAL_ADDRESS)) {
  85. RtlCopyMemory(((PUCHAR) ErrorLogEntry->DumpData) +
  86. sizeof(PHYSICAL_ADDRESS), &P2,
  87. sizeof(PHYSICAL_ADDRESS));
  88. }
  89. }
  90. IoWriteErrorLogEntry(ErrorLogEntry);
  91. }