ReactOS  0.4.15-dev-1201-gb2cf5a4
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 }
struct _SRB_HISTORY_ITEM SRB_HISTORY_ITEM
struct _SRB_HISTORY SRB_HISTORY
VOID History(INT dir, LPTSTR commandline)
Definition: history.c:326
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

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 }
_In_ PTRANSFER_PACKET Pkt
Definition: classp.h:1754
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define TRUE
Definition: types.h:120
PSTORAGE_REQUEST_BLOCK_HEADER Srb
Definition: classp.h:580
#define IsDescriptorSenseDataFormat(SenseInfoBuffer)
Definition: scsi.h:3685
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__inline PVOID ClasspTransferPacketGetSenseInfoBuffer(_In_ PTRANSFER_PACKET Pkt)
Definition: classp.h:2513
void * PVOID
Definition: retypes.h:9
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
PSRB_HISTORY RetryHistory
Definition: classp.h:598
PFIXED_SENSE_DATA senseInfoBuffer
Definition: scsi.h:3710
unsigned char UCHAR
Definition: xmlstorage.h:181
static ATOM item
Definition: dde.c:856
#define min(a, b)
Definition: monoChain.cc:55
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__inline UCHAR ClasspTransferPacketGetSenseInfoBufferLength(_In_ PTRANSFER_PACKET Pkt)
Definition: classp.h:2521
BOOLEAN validSense
Definition: scsi.h:4018
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ 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 );
61  NT_ASSERT( fdoData->InterpretSenseInfo->Compress != 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
_In_ PTRANSFER_PACKET Pkt
Definition: classp.h:1754
PDEVICE_OBJECT Fdo
Definition: classp.h:503
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
PSRB_HISTORY RetryHistory
Definition: classp.h:598
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:871
static ATOM item
Definition: dde.c:856
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PCLASS_INTERPRET_SENSE_INFO2 InterpretSenseInfo
Definition: classp.h:958
#define NT_ASSERT
Definition: rtlfuncs.h:3312