ReactOS  0.4.15-dev-1377-ga59cecd
pdo.c File Reference
#include "scsiport.h"
#include <debug.h>
Include dependency graph for pdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PSCSI_PORT_LUN_EXTENSION SpiAllocateLunExtension (_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
 
PSCSI_PORT_LUN_EXTENSION SpiGetLunExtension (_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
 
PSCSI_REQUEST_BLOCK_INFO SpiGetSrbData (_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ UCHAR QueueTag)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pdo.c.

Function Documentation

◆ SpiAllocateLunExtension()

PSCSI_PORT_LUN_EXTENSION SpiAllocateLunExtension ( _In_ PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 16 of file pdo.c.

18 {
19  PSCSI_PORT_LUN_EXTENSION LunExtension;
20  ULONG LunExtensionSize;
21 
22  DPRINT("SpiAllocateLunExtension(%p)\n", DeviceExtension);
23 
24  /* Round LunExtensionSize first to the sizeof LONGLONG */
25  LunExtensionSize = (DeviceExtension->LunExtensionSize +
26  sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1);
27 
28  LunExtensionSize += sizeof(SCSI_PORT_LUN_EXTENSION);
29  DPRINT("LunExtensionSize %lu\n", LunExtensionSize);
30 
31  LunExtension = ExAllocatePoolWithTag(NonPagedPool, LunExtensionSize, TAG_SCSIPORT);
32  if (LunExtension == NULL)
33  {
34  DPRINT1("Out of resources!\n");
35  return NULL;
36  }
37 
38  /* Zero everything */
39  RtlZeroMemory(LunExtension, LunExtensionSize);
40 
41  /* Initialize a list of requests */
42  InitializeListHead(&LunExtension->SrbInfo.Requests);
43 
44  /* Initialize timeout counter */
45  LunExtension->RequestTimeout = -1;
46 
47  /* Set maximum queue size */
48  LunExtension->MaxQueueCount = 256;
49 
50  /* Initialize request queue */
51  KeInitializeDeviceQueue(&LunExtension->DeviceQueue);
52 
53  return LunExtension;
54 }
KDEVICE_QUEUE DeviceQueue
Definition: scsiport.h:133
VOID NTAPI KeInitializeDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue)
Definition: devqueue.c:22
#define TAG_SCSIPORT
Definition: scsiport.h:20
struct _SCSI_PORT_LUN_EXTENSION SCSI_PORT_LUN_EXTENSION
void DPRINT(...)
Definition: polytest.cpp:61
int64_t LONGLONG
Definition: typedefs.h:68
SCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:147
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by SpiScanAdapter().

◆ SpiGetLunExtension()

PSCSI_PORT_LUN_EXTENSION SpiGetLunExtension ( _In_ PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun 
)

Definition at line 57 of file pdo.c.

62 {
63  PSCSI_PORT_LUN_EXTENSION LunExtension;
64 
65  DPRINT("SpiGetLunExtension(%p %u %u %u) called\n",
66  DeviceExtension, PathId, TargetId, Lun);
67 
68  /* Get appropriate list */
69  LunExtension = DeviceExtension->LunExtensionList[(TargetId + Lun) % LUS_NUMBER];
70 
71  /* Iterate it until we find what we need */
72  while (LunExtension)
73  {
74  if (LunExtension->TargetId == TargetId &&
75  LunExtension->Lun == Lun &&
76  LunExtension->PathId == PathId)
77  {
78  /* All matches, return */
79  return LunExtension;
80  }
81 
82  /* Advance to the next item */
83  LunExtension = LunExtension->Next;
84  }
85 
86  /* We did not find anything */
87  DPRINT("Nothing found\n");
88  return NULL;
89 }
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1310
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1310
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1310
#define LUS_NUMBER
Definition: scsiport.h:23
struct _SCSI_PORT_LUN_EXTENSION * Next
Definition: scsiport.h:126
void DPRINT(...)
Definition: polytest.cpp:61
#define NULL
Definition: types.h:112

Referenced by ScsiPortDispatchScsi(), ScsiPortGetLogicalUnit(), ScsiPortNotification(), ScsiPortStartIo(), ScsiPortStartPacket(), SpiBuildDeviceMap(), SpiGetSrbData(), SpiProcessCompletedRequest(), SpiSaveInterruptData(), and SpiSendInquiry().

◆ SpiGetSrbData()

PSCSI_REQUEST_BLOCK_INFO SpiGetSrbData ( _In_ PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ UCHAR  QueueTag 
)

Definition at line 92 of file pdo.c.

98 {
99  PSCSI_PORT_LUN_EXTENSION LunExtension;
100 
101  if (QueueTag == SP_UNTAGGED)
102  {
103  /* Untagged request, get LU and return pointer to SrbInfo */
104  LunExtension = SpiGetLunExtension(DeviceExtension,
105  PathId,
106  TargetId,
107  Lun);
108 
109  /* Return NULL in case of error */
110  if (!LunExtension)
111  return(NULL);
112 
113  /* Return the pointer to SrbInfo */
114  return &LunExtension->SrbInfo;
115  }
116  else
117  {
118  /* Make sure the tag is valid, if it is - return the data */
119  if (QueueTag > DeviceExtension->SrbDataCount || QueueTag < 1)
120  return NULL;
121  else
122  return &DeviceExtension->SrbInfo[QueueTag -1];
123  }
124 }
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1310
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1310
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1310
PSCSI_PORT_LUN_EXTENSION SpiGetLunExtension(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
Definition: pdo.c:57
#define SP_UNTAGGED
Definition: srb.h:225
SCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:147
#define NULL
Definition: types.h:112

Referenced by ScsiPortGetPhysicalAddress(), ScsiPortNotification(), ScsiPortStartPacket(), and SpiAllocateSrbStructures().