4 #define MAX_BUFFER_SIZE 256
10 ULONG pi_UniqueErrorCode,
12 PWCHAR pi_InsertionStr,
19 Writes an event log entry to the event log.
23 pi_pIoObject......... The IO object ( driver object or device object ).
24 pi_ErrorCode......... The error code.
25 pi_UniqueErrorCode... A specific error code.
26 pi_FinalStatus....... The final status.
27 pi_nDataItems........ Number of data items.
37 { /* WriteEventLogEntryStr */
39 /* Variable argument list */
41 /* Pointer to an error log entry */
42 PIO_ERROR_LOG_PACKET l_pErrorLogEntry;
43 /* sizeof insertion string */
44 int l_Size = (int)((pi_InsertionStr) ? ((wcslen(pi_InsertionStr) + 1) * sizeof( WCHAR )) : 0);
45 int l_PktSize =sizeof(IO_ERROR_LOG_PACKET)+pi_nDataItems*sizeof(ULONG);
46 int l_TotalSize =l_PktSize +l_Size;
48 /* Init the variable argument list */
49 va_start(l_Argptr, pi_nDataItems);
51 /* Allocate an error log entry */
52 if (l_TotalSize >= ERROR_LOG_MAXIMUM_SIZE - 2)
53 l_TotalSize = ERROR_LOG_MAXIMUM_SIZE - 2;
54 l_pErrorLogEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(
55 pi_pIoObject, (UCHAR)l_TotalSize );
57 /* Check allocation */
58 if ( l_pErrorLogEntry != NULL)
64 /* Set the error log entry header */
65 l_pErrorLogEntry->ErrorCode = pi_ErrorCode;
66 l_pErrorLogEntry->DumpDataSize = (USHORT) (pi_nDataItems*sizeof(ULONG));
67 l_pErrorLogEntry->SequenceNumber = 0;
68 l_pErrorLogEntry->MajorFunctionCode = 0;
69 l_pErrorLogEntry->IoControlCode = 0;
70 l_pErrorLogEntry->RetryCount = 0;
71 l_pErrorLogEntry->UniqueErrorValue = pi_UniqueErrorCode;
72 l_pErrorLogEntry->FinalStatus = pi_FinalStatus;
74 /* Insert the data items */
75 for (l_nDataItem = 0; l_nDataItem < pi_nDataItems; l_nDataItem++)
76 { /* Inset a data item */
78 /* Current data item */
81 /* Get next data item */
82 l_CurDataItem = va_arg( l_Argptr, int);
84 /* Put it into the data array */
85 l_pErrorLogEntry->DumpData[l_nDataItem] = l_CurDataItem ;
87 } /* Inset a data item */
89 /* add insertion string */
90 if (pi_InsertionStr) {
92 int sz = min( l_TotalSize - l_PktSize, l_Size );
93 l_pErrorLogEntry->NumberOfStrings = 1;
94 l_pErrorLogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + l_pErrorLogEntry->DumpDataSize;
95 ptr = (char*)l_pErrorLogEntry + l_pErrorLogEntry->StringOffset;
96 memcpy( ptr, pi_InsertionStr, sz );
97 *(WCHAR*)&ptr[sz - 2] = (WCHAR)0;
100 /* Write the packet */
101 IoWriteErrorLogEntry(l_pErrorLogEntry);
105 /* Term the variable argument list */
108 } /* WriteEventLogEntry */
113 IN struct mlx4_dev * mdev,
119 UCHAR buf[MAX_BUFFER_SIZE];
120 WCHAR wbuf[MAX_BUFFER_SIZE];
123 va_start(list, format);
124 buf[MAX_BUFFER_SIZE - 1] = '\0';
125 RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list);
126 DbgPrint( (char*)buf );
129 // print to Event Log
130 if (!RtlStringCchPrintfW(wbuf, sizeof(wbuf)/sizeof(wbuf[0]), L"%S", buf))
131 WriteEventLogEntryStr( mdev->pdev->p_self_do, (ULONG)EVENT_MLX4_ANY_ERROR, 0, 0, wbuf, 0, 0 );
136 IN struct mlx4_dev * mdev,
143 UCHAR buf[MAX_BUFFER_SIZE];
147 va_start(list, format);
148 buf[MAX_BUFFER_SIZE - 1] = '\0';
149 RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list);
150 DbgPrint( (char*)buf );
154 UNUSED_PARAM(format);
160 IN struct mlx4_dev ** mdev,
166 UCHAR buf[MAX_BUFFER_SIZE];
167 WCHAR wbuf[MAX_BUFFER_SIZE];
170 va_start(list, format);
171 buf[MAX_BUFFER_SIZE - 1] = '\0';
172 RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list);
173 DbgPrint( (char*)buf );
176 // print to Event Log
177 RtlStringCchPrintfW(wbuf, sizeof(wbuf)/sizeof(wbuf[0]), L"%S", buf);
178 WriteEventLogEntryStr( (*mdev)->pdev->p_self_do, (ULONG)EVENT_MLX4_ANY_ERROR, 0, 0, wbuf, 0, 0 );
183 IN struct mlx4_dev ** p_mdev,
190 UCHAR buf[MAX_BUFFER_SIZE];
191 UNUSED_PARAM(p_mdev);
194 va_start(list, format);
195 buf[MAX_BUFFER_SIZE - 1] = '\0';
196 RtlStringCbVPrintfA( (char*)buf, sizeof(buf), format, list);
197 DbgPrint( (char*)buf );
200 UNUSED_PARAM(p_mdev);
201 UNUSED_PARAM(format);