3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/errlog.c
6 * PURPOSE: Error logging
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
16 #include <internal/port.h>
19 #include <internal/debug.h>
21 /* TYPES *********************************************************************/
24 typedef struct _IO_ERROR_LOG_PACKET
26 UCHAR MajorFunctionCode;
29 USHORT NumberOfStrings;
33 ULONG UniqueErrorValue;
37 LARGE_INTEGER DeviceOffset;
39 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
42 typedef struct _ERROR_LOG_ENTRY
45 } ERROR_LOG_ENTRY, *PERROR_LOG_ENTRY;
48 /* GLOBALS *******************************************************************/
50 static KSPIN_LOCK IopAllocationLock;
51 static ULONG IopTotalLogSize;
54 /* FUNCTIONS *****************************************************************/
57 IopInitErrorLog (VOID)
60 KeInitializeSpinLock (&IopAllocationLock);
62 return STATUS_SUCCESS;
70 IoAllocateErrorLogEntry (IN PVOID IoObject,
73 PERROR_LOG_ENTRY LogEntry;
77 DPRINT1 ("IoAllocateErrorLogEntry() called\n");
82 KeAcquireSpinLock (&IopAllocationLock,
85 if (IopTotalLogSize > PAGE_SIZE)
87 KeReleaseSpinLock (&IopAllocationLock,
92 LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
93 LogEntry = ExAllocatePool (NonPagedPool,
97 KeReleaseSpinLock (&IopAllocationLock,
102 IopTotalLogSize += EntrySize;
104 LogEntry->EntrySize = LogEntrySize;
106 KeReleaseSpinLock (&IopAllocationLock,
109 return (PVOID)((ULONG_PTR)LogEntry + sizeof(ERROR_LOG_ENTRY));
117 IoWriteErrorLogEntry (IN PVOID ElEntry)
119 PERROR_LOG_ENTRY LogEntry;
122 DPRINT1 ("IoWriteErrorLogEntry() called\n");
124 LogEntry = (PERROR_LOG_ENTRY)((ULONG_PTR)ElEntry - sizeof(ERROR_LOG_ENTRY));
127 /* FIXME: Write log entry to the error log port or keep it in a list */
130 /* Release error log entry */
131 KeAcquireSpinLock (&IopAllocationLock,
134 IopTotalLogSize -= LogEntry->EntrySize;
135 ExFreePool (LogEntry);
137 KeReleaseSpinLock (&IopAllocationLock,