ReactOS 0.4.17-dev-1268-g5608ce5
srbex.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for srbex.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 C_ASSERT (FIELD_OFFSET(EXTENDED_REQUEST, Address) >=sizeof(STORAGE_REQUEST_BLOCK))
 
 C_ASSERT (FIELD_OFFSET(EXTENDED_REQUEST, Cdb) >=FIELD_OFFSET(EXTENDED_REQUEST, Address)+sizeof(STOR_ADDR_BTL8))
 
VOID NTAPI StorpBuildUnitAddress (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Out_ PSTOR_ADDR_BTL8 Address)
 Fills in the bus, target and LUN address of a logical unit.
 
BOOLEAN NTAPI StorpIsExtendedSrb (_In_ PVOID Srb)
 Tells whether a request block is in the extended format.
 
PQUEUED_REQUEST_REFERENCE NTAPI StorpRequestReference (_In_ PSCSI_REQUEST_BLOCK Srb)
 Finds the request reference behind an SRB in either format.
 
PVOID NTAPI StorpSrbDataBuffer (_In_ PSCSI_REQUEST_BLOCK Srb)
 Finds the data buffer of a request in either format.
 
VOID NTAPI StorpBuildExtendedSrb (_In_ PSCSI_REQUEST_BLOCK Srb, _Out_ PEXTENDED_REQUEST Request)
 Fills in the extended request a miniport will be given.
 
VOID NTAPI StorpCompleteExtendedSrb (_In_ PSCSI_REQUEST_BLOCK Srb, _In_ PEXTENDED_REQUEST Request)
 Carries the miniport's answer back to the original request block.
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file srbex.c.

Function Documentation

◆ C_ASSERT() [1/2]

◆ C_ASSERT() [2/2]

◆ StorpBuildExtendedSrb()

VOID NTAPI StorpBuildExtendedSrb ( _In_ PSCSI_REQUEST_BLOCK  Srb,
_Out_ PEXTENDED_REQUEST  Request 
)

Fills in the extended request a miniport will be given.

Parameters
SrbThe request as the class layer built it.
RequestStorage for the translated request, already zeroed.

Definition at line 102 of file srbex.c.

105{
106 PSTORAGE_REQUEST_BLOCK Extended = &Request->Srb;
107
108 Extended->Length = sizeof(*Extended);
109 Extended->Function = SRB_FUNCTION_STORAGE_REQUEST_BLOCK;
110 Extended->SrbStatus = SRB_STATUS_PENDING;
111 Extended->Signature = SRB_SIGNATURE;
112 Extended->Version = STORAGE_REQUEST_BLOCK_VERSION_1;
113 Extended->SrbLength = sizeof(*Request);
114 Extended->SrbFunction = Srb->Function;
115 Extended->SrbFlags = Srb->SrbFlags;
116 Extended->RequestTag = Srb->QueueTag;
117 Extended->RequestAttribute = Srb->QueueAction;
118 Extended->TimeOutValue = Srb->TimeOutValue;
119 Extended->DataTransferLength = Srb->DataTransferLength;
120 Extended->DataBuffer = Srb->DataBuffer;
121
122 /* The miniport hands this straight back to us on completion */
123 Extended->OriginalRequest = Srb->OriginalRequest;
124 Extended->MiniportContext = Srb->SrbExtension;
125
126 Extended->AddressOffset = FIELD_OFFSET(EXTENDED_REQUEST, Address);
127
128 Request->Address.Type = STOR_ADDRESS_TYPE_BTL8;
129 Request->Address.AddressLength = STOR_ADDR_BTL8_ADDRESS_LENGTH;
130 Request->Address.Path = Srb->PathId;
131 Request->Address.Target = Srb->TargetId;
132 Request->Address.Lun = Srb->Lun;
133
134 /* Only SRB_FUNCTION_EXECUTE_SCSI carries a CDB */
136 return;
137
138 Extended->NumSrbExData = 1;
139 Extended->SrbExDataOffset[0] = FIELD_OFFSET(EXTENDED_REQUEST, Cdb);
140
143 Request->Cdb.ScsiStatus = Srb->ScsiStatus;
144 Request->Cdb.SenseInfoBufferLength = Srb->SenseInfoBufferLength;
145 Request->Cdb.CdbLength = Srb->CdbLength;
146 Request->Cdb.SenseInfoBuffer = Srb->SenseInfoBuffer;
147
148 RtlCopyMemory(Request->Cdb.Cdb, Srb->Cdb, sizeof(Request->Cdb.Cdb));
149}
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_STATUS_PENDING
Definition: srb.h:340
static WCHAR Address[46]
Definition: ping.c:68
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:159
#define STOR_ADDRESS_TYPE_BTL8
Definition: scsi.h:3571
#define STOR_ADDR_BTL8_ADDRESS_LENGTH
Definition: scsi.h:3574
#define SRB_SIGNATURE
Definition: srb.h:616
#define STORAGE_REQUEST_BLOCK_VERSION_1
Definition: srb.h:617
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:108
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:661
@ SrbExDataTypeScsiCdb16
Definition: srb.h:459
#define SRBEX_DATA_SCSI_CDB16_LENGTH
Definition: srb.h:489
UCHAR QueueTag
Definition: srb.h:256
ULONG TimeOutValue
Definition: srb.h:262
UCHAR TargetId
Definition: srb.h:254
PVOID OriginalRequest
Definition: srb.h:266
UCHAR SenseInfoBufferLength
Definition: srb.h:259
PVOID DataBuffer
Definition: srb.h:263
UCHAR PathId
Definition: srb.h:253
UCHAR QueueAction
Definition: srb.h:257
UCHAR CdbLength
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:279
PVOID SenseInfoBuffer
Definition: srb.h:264
UCHAR Function
Definition: srb.h:250
UCHAR ScsiStatus
Definition: srb.h:252
ULONG DataTransferLength
Definition: srb.h:261
PVOID SrbExtension
Definition: srb.h:267
ULONG SrbFlags
Definition: srb.h:260
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request

Referenced by PortPdoAfterBuildingScatterGatherList().

◆ StorpBuildUnitAddress()

VOID NTAPI StorpBuildUnitAddress ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_Out_ PSTOR_ADDR_BTL8  Address 
)

Fills in the bus, target and LUN address of a logical unit.

Definition at line 28 of file srbex.c.

31{
32 RtlZeroMemory(Address, sizeof(*Address));
33
36 Address->Path = (UCHAR)PdoExtension->Bus;
37 Address->Target = (UCHAR)PdoExtension->Target;
38 Address->Lun = (UCHAR)PdoExtension->Lun;
39}
@ PdoExtension
Definition: precomp.h:62
unsigned char UCHAR
Definition: typedefs.h:53
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by PortCreatePdo(), and PortDeletePdo().

◆ StorpCompleteExtendedSrb()

VOID NTAPI StorpCompleteExtendedSrb ( _In_ PSCSI_REQUEST_BLOCK  Srb,
_In_ PEXTENDED_REQUEST  Request 
)

Carries the miniport's answer back to the original request block.

Definition at line 157 of file srbex.c.

160{
161 PSTORAGE_REQUEST_BLOCK Extended = &Request->Srb;
162
163 Srb->SrbStatus = Extended->SrbStatus;
164 Srb->DataTransferLength = Extended->DataTransferLength;
165
166 if (Extended->NumSrbExData == 0)
167 return;
168
169 Srb->ScsiStatus = Request->Cdb.ScsiStatus;
170 Srb->SenseInfoBufferLength = Request->Cdb.SenseInfoBufferLength;
171}
UCHAR SrbStatus
Definition: srb.h:251

Referenced by StorPortNotification().

◆ StorpIsExtendedSrb()

BOOLEAN NTAPI StorpIsExtendedSrb ( _In_ PVOID  Srb)

Tells whether a request block is in the extended format.

Definition at line 47 of file srbex.c.

49{
51
52 return (Header->Function == SRB_FUNCTION_STORAGE_REQUEST_BLOCK);
53}
Definition: Header.h:9
struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER * PSTORAGE_REQUEST_BLOCK_HEADER

Referenced by StorPortNotification(), StorpRequestReference(), and StorpSrbDataBuffer().

◆ StorpRequestReference()

PQUEUED_REQUEST_REFERENCE NTAPI StorpRequestReference ( _In_ PSCSI_REQUEST_BLOCK  Srb)

Finds the request reference behind an SRB in either format.

Definition at line 61 of file srbex.c.

63{
65 {
67
69 }
70
72}
BOOLEAN NTAPI StorpIsExtendedSrb(_In_ PVOID Srb)
Tells whether a request block is in the extended format.
Definition: srbex.c:47

Referenced by StorPortExtendedFunction(), StorPortGetScatterGatherList(), and StorPortNotification().

◆ StorpSrbDataBuffer()

PVOID NTAPI StorpSrbDataBuffer ( _In_ PSCSI_REQUEST_BLOCK  Srb)

Finds the data buffer of a request in either format.

Definition at line 80 of file srbex.c.

82{
84 {
86
87 return Extended->DataBuffer;
88 }
89
90 return Srb->DataBuffer;
91}

Referenced by StorPortExtendedFunction().