1 /* $Id: errlog.c,v 1.9 2003/06/20 22:43:27 ekohl Exp $
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
;
41 typedef struct _ERROR_LOG_ENTRY
44 } ERROR_LOG_ENTRY
, *PERROR_LOG_ENTRY
;
47 /* GLOBALS *******************************************************************/
49 static KSPIN_LOCK IopAllocationLock
;
50 static ULONG IopTotalLogSize
;
53 /* FUNCTIONS *****************************************************************/
56 IopInitErrorLog (VOID
)
59 KeInitializeSpinLock (&IopAllocationLock
);
61 return STATUS_SUCCESS
;
66 IoAllocateErrorLogEntry (IN PVOID IoObject
,
69 PERROR_LOG_ENTRY LogEntry
;
73 DPRINT1 ("IoAllocateErrorLogEntry() called\n");
78 KeAcquireSpinLock (&IopAllocationLock
,
81 if (IopTotalLogSize
> PAGE_SIZE
)
83 KeReleaseSpinLock (&IopAllocationLock
,
88 LogEntrySize
= sizeof(ERROR_LOG_ENTRY
) + EntrySize
;
89 LogEntry
= ExAllocatePool (NonPagedPool
,
93 KeReleaseSpinLock (&IopAllocationLock
,
98 IopTotalLogSize
+= EntrySize
;
100 LogEntry
->EntrySize
= LogEntrySize
;
102 KeReleaseSpinLock (&IopAllocationLock
,
105 return (PVOID
)((ULONG_PTR
)LogEntry
+ sizeof(ERROR_LOG_ENTRY
));
110 IoWriteErrorLogEntry (IN PVOID ElEntry
)
112 PERROR_LOG_ENTRY LogEntry
;
115 DPRINT1 ("IoWriteErrorLogEntry() called\n");
117 LogEntry
= (PERROR_LOG_ENTRY
)((ULONG_PTR
)ElEntry
- sizeof(ERROR_LOG_ENTRY
));
120 /* FIXME: Write log entry to the error log port or keep it in a list */
123 /* Release error log entry */
124 KeAcquireSpinLock (&IopAllocationLock
,
127 IopTotalLogSize
-= LogEntry
->EntrySize
;
128 ExFreePool (LogEntry
);
130 KeReleaseSpinLock (&IopAllocationLock
,