ReactOS 0.4.15-dev-7924-g5949c20
history.c File Reference
#include "classp.h"
#include "debug.h"
Include dependency graph for history.c:

Go to the source code of this file.

Functions

VOID HistoryInitializeRetryLogs (_Out_ PSRB_HISTORY History, ULONG HistoryCount)
 
VOID HistoryLogSendPacket (TRANSFER_PACKET *Pkt)
 
VOID HistoryLogReturnedPacket (TRANSFER_PACKET *Pkt)
 

Function Documentation

◆ HistoryInitializeRetryLogs()

VOID HistoryInitializeRetryLogs ( _Out_ PSRB_HISTORY  History,
ULONG  HistoryCount 
)

Definition at line 36 of file history.c.

36 {
37 ULONG tmpSize = HistoryCount * sizeof(SRB_HISTORY_ITEM);
38 tmpSize += sizeof(SRB_HISTORY) - sizeof(SRB_HISTORY_ITEM);
39 RtlZeroMemory(History, tmpSize);
40 History->TotalHistoryCount = HistoryCount;
41 return;
42}
VOID History(INT dir, LPTSTR commandline)
Definition: history.c:326
struct _SRB_HISTORY SRB_HISTORY
struct _SRB_HISTORY_ITEM SRB_HISTORY_ITEM
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59

Referenced by __drv_allocatesMem().

◆ HistoryLogReturnedPacket()

VOID HistoryLogReturnedPacket ( TRANSFER_PACKET Pkt)

Definition at line 83 of file history.c.

83 {
84
85 PSRB_HISTORY history;
87 UCHAR senseSize;
89 UCHAR senseInfoBufferLength;
90 SENSE_DATA convertedSenseBuffer = {0};
92
94 history = Pkt->RetryHistory;
95 NT_ASSERT( history->UsedHistoryCount <= history->TotalHistoryCount );
96 item = &( history->History[ history->UsedHistoryCount-1 ] );
97
98 // Query the tick count and store in the history
99 KeQueryTickCount(&item->TickCountCompleted);
100
101 // Copy the SRB Status...
102 item->SrbStatus = Pkt->Srb->SrbStatus;
103
104 //
105 // Process sense data
106 //
107
109 senseInfoBufferLength = ClasspTransferPacketGetSenseInfoBufferLength(Pkt);
110
112
113 validSense = ScsiConvertToFixedSenseFormat(senseInfoBuffer,
114 senseInfoBufferLength,
115 (PVOID)&convertedSenseBuffer,
116 sizeof(convertedSenseBuffer));
117
118 if (validSense) {
119 senseInfoBuffer = (PVOID)&convertedSenseBuffer;
120 senseInfoBufferLength = sizeof(convertedSenseBuffer);
121 }
122 }
123
124 RtlZeroMemory(&(item->NormalizedSenseData), sizeof(item->NormalizedSenseData));
125
126 if (validSense) {
127
128 // Determine the amount of valid sense data
129
130 if (!ScsiGetTotalSenseByteCountIndicated(senseInfoBuffer,
131 senseInfoBufferLength,
132 &senseSize)) {
133 senseSize = senseInfoBufferLength;
134 }
135
136 // Normalize the sense data copy in the history
137 senseSize = min(senseSize, sizeof(item->NormalizedSenseData));
138 RtlCopyMemory(&(item->NormalizedSenseData),
140 senseSize
141 );
142 }
143
144 return;
145}
unsigned char BOOLEAN
_In_ PTRANSFER_PACKET Pkt
Definition: classp.h:1754
FORCEINLINE PVOID ClasspTransferPacketGetSenseInfoBuffer(_In_ PTRANSFER_PACKET Pkt)
Definition: classp.h:2513
FORCEINLINE UCHAR ClasspTransferPacketGetSenseInfoBufferLength(_In_ PTRANSFER_PACKET Pkt)
Definition: classp.h:2521
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static ATOM item
Definition: dde.c:856
#define min(a, b)
Definition: monoChain.cc:55
PFIXED_SENSE_DATA senseInfoBuffer
Definition: scsi.h:3710
BOOLEAN validSense
Definition: scsi.h:4018
#define IsDescriptorSenseDataFormat(SenseInfoBuffer)
Definition: scsi.h:3685
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
PSTORAGE_REQUEST_BLOCK_HEADER Srb
Definition: classp.h:580
PSRB_HISTORY RetryHistory
Definition: classp.h:598
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define NT_ASSERT
Definition: rtlfuncs.h:3310
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ HistoryLogSendPacket()

VOID HistoryLogSendPacket ( TRANSFER_PACKET Pkt)

Definition at line 45 of file history.c.

45 {
46
47 PSRB_HISTORY history;
49
51 history = Pkt->RetryHistory;
52 // sending a packet implies a new history unit is to be used.
53 NT_ASSERT( history->UsedHistoryCount <= history->TotalHistoryCount );
54
55 // if already all used up, request class driver to remove at least one history unit
56 if (history->UsedHistoryCount == history->TotalHistoryCount )
57 {
59 PCLASS_PRIVATE_FDO_DATA fdoData = fdoExtension->PrivateFdoData;
60 NT_ASSERT( fdoData->InterpretSenseInfo != NULL );
62 fdoData->InterpretSenseInfo->Compress( fdoExtension->DeviceObject, history );
63 NT_ASSERT( history->UsedHistoryCount < history->TotalHistoryCount );
64 }
65
66 // thus, since we are about to increment the count, it must now be less...
67 NT_ASSERT( history->UsedHistoryCount < history->TotalHistoryCount );
68
69 // increment the number of history units in use
70 history->UsedHistoryCount++;
71
72 // determine index to use
73 item = &( history->History[ history->UsedHistoryCount-1 ] );
74
75 // zero out the history item
77
78 // Query the tick count and store in the history
79 KeQueryTickCount(&item->TickCountSent);
80 return;
81}
__callback PCLASS_COMPRESS_RETRY_HISTORY_DATA Compress
Definition: classpnp.h:565
PCLASS_INTERPRET_SENSE_INFO2 InterpretSenseInfo
Definition: classp.h:958
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:871
PDEVICE_OBJECT Fdo
Definition: classp.h:503