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.

129 lines
3.9 KiB

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