ReactOS  0.4.14-dev-57-g333b8f1
scsiport.c File Reference
#include <freeldr.h>
#include <debug.h>
#include <ntddk.h>
#include <srb.h>
#include <scsi.h>
#include <ntddscsi.h>
#include <ntddstor.h>
#include <ntdddisk.h>
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for scsiport.c:

Go to the source code of this file.

Classes

struct  SCSI_PORT_DEVICE_EXTENSION
 
struct  tagDISKCONTEXT
 

Macros

#define _SCSIPORT_
 
#define SCSI_PORT_NEXT_REQUEST_READY   0x0008
 
#define TAG_SCSI_DEVEXT   'DscS'
 
#define TAG_SCSI_ACCESS_RANGES   'AscS'
 

Typedefs

typedef struct SCSI_PORT_DEVICE_EXTENSIONPSCSI_PORT_DEVICE_EXTENSION
 
typedef struct tagDISKCONTEXT DISKCONTEXT
 

Functions

 DBG_DEFAULT_CHANNEL (SCSIPORT)
 
ULONG ntohl (IN ULONG Value)
 
static BOOLEAN SpiSendSynchronousSrb (IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
 
static ARC_STATUS DiskClose (ULONG FileId)
 
static ARC_STATUS DiskGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
static ARC_STATUS DiskOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
static ARC_STATUS DiskRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
static ARC_STATUS DiskSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
static NTSTATUS SpiCreatePortConfig (IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PHW_INITIALIZATION_DATA HwInitData, OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, IN BOOLEAN ZeroStruct)
 
VOID __cdecl ScsiDebugPrint (IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, IN ...)
 
VOID NTAPI ScsiPortCompleteRequest (IN PVOID HwDeviceExtension, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN UCHAR SrbStatus)
 
ULONG NTAPI ScsiPortConvertPhysicalAddressToUlong (IN SCSI_PHYSICAL_ADDRESS Address)
 
SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress (IN ULONG_PTR UlongAddress)
 
VOID NTAPI ScsiPortFlushDma (IN PVOID DeviceExtension)
 
VOID NTAPI ScsiPortFreeDeviceBase (IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
 
ULONG NTAPI ScsiPortGetBusData (IN PVOID DeviceExtension, IN ULONG BusDataType, IN ULONG SystemIoBusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
PVOID NTAPI ScsiPortGetDeviceBase (IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, IN ULONG SystemIoBusNumber, IN SCSI_PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfBytes, IN BOOLEAN InIoSpace)
 
PVOID NTAPI ScsiPortGetLogicalUnit (IN PVOID HwDeviceExtension, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun)
 
SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortGetPhysicalAddress (IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, IN PVOID VirtualAddress, OUT ULONG *Length)
 
PSCSI_REQUEST_BLOCK NTAPI ScsiPortGetSrb (IN PVOID DeviceExtension, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN LONG QueueTag)
 
static NTSTATUS SpiAllocateCommonBuffer (IN OUT PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN ULONG NonCachedSize)
 
PVOID NTAPI ScsiPortGetUncachedExtension (IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, IN ULONG NumberOfBytes)
 
PVOID NTAPI ScsiPortGetVirtualAddress (IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress)
 
static VOID SpiScanDevice (IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PCHAR ArcName, IN ULONG ScsiBus, IN ULONG TargetId, IN ULONG Lun)
 
static VOID SpiScanAdapter (IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN ULONG ScsiBus, IN UCHAR PathId)
 
static VOID SpiResourceToConfig (IN PHW_INITIALIZATION_DATA HwInitializationData, IN PCM_FULL_RESOURCE_DESCRIPTOR ResourceDescriptor, IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig)
 
static BOOLEAN SpiGetPciConfigData (IN PHW_INITIALIZATION_DATA HwInitializationData, IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig, IN ULONG BusNumber, IN OUT PPCI_SLOT_NUMBER NextSlotNumber)
 
ULONG NTAPI ScsiPortInitialize (IN PVOID Argument1, IN PVOID Argument2, IN PHW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext OPTIONAL)
 
VOID NTAPI ScsiPortIoMapTransfer (IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, IN PVOID LogicalAddress, IN ULONG Length)
 
VOID NTAPI ScsiPortLogError (IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN ULONG ErrorCode, IN ULONG UniqueId)
 
VOID NTAPI ScsiPortMoveMemory (IN PVOID WriteBuffer, IN PVOID ReadBuffer, IN ULONG Length)
 
VOID __cdecl ScsiPortNotification (IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, IN ...)
 
VOID NTAPI ScsiPortReadPortBufferUchar (IN PUCHAR Port, OUT PUCHAR Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortReadPortBufferUlong (IN PULONG Port, OUT PULONG Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortReadPortBufferUshort (IN PUSHORT Port, OUT PUSHORT Buffer, IN ULONG Count)
 
UCHAR NTAPI ScsiPortReadPortUchar (IN PUCHAR Port)
 
ULONG NTAPI ScsiPortReadPortUlong (IN PULONG Port)
 
USHORT NTAPI ScsiPortReadPortUshort (IN PUSHORT Port)
 
VOID NTAPI ScsiPortReadRegisterBufferUchar (IN PUCHAR Register, IN PUCHAR Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortReadRegisterBufferUlong (IN PULONG Register, IN PULONG Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortReadRegisterBufferUshort (IN PUSHORT Register, IN PUSHORT Buffer, IN ULONG Count)
 
UCHAR NTAPI ScsiPortReadRegisterUchar (IN PUCHAR Register)
 
ULONG NTAPI ScsiPortReadRegisterUlong (IN PULONG Register)
 
USHORT NTAPI ScsiPortReadRegisterUshort (IN PUSHORT Register)
 
ULONG NTAPI ScsiPortSetBusDataByOffset (IN PVOID DeviceExtension, IN ULONG BusDataType, IN ULONG SystemIoBusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
VOID NTAPI ScsiPortStallExecution (IN ULONG Delay)
 
BOOLEAN NTAPI ScsiPortValidateRange (IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, IN ULONG SystemIoBusNumber, IN SCSI_PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfBytes, IN BOOLEAN InIoSpace)
 
VOID NTAPI ScsiPortWritePortBufferUchar (IN PUCHAR Port, IN PUCHAR Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWritePortBufferUlong (IN PULONG Port, IN PULONG Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWritePortBufferUshort (IN PUSHORT Port, IN PUSHORT Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWritePortUchar (IN PUCHAR Port, IN UCHAR Value)
 
VOID NTAPI ScsiPortWritePortUlong (IN PULONG Port, IN ULONG Value)
 
VOID NTAPI ScsiPortWritePortUshort (IN PUSHORT Port, IN USHORT Value)
 
VOID NTAPI ScsiPortWriteRegisterBufferUchar (IN PUCHAR Register, IN PUCHAR Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWriteRegisterBufferUlong (IN PULONG Register, IN PULONG Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWriteRegisterBufferUshort (IN PUSHORT Register, IN PUSHORT Buffer, IN ULONG Count)
 
VOID NTAPI ScsiPortWriteRegisterUchar (IN PUCHAR Register, IN UCHAR Value)
 
VOID NTAPI ScsiPortWriteRegisterUlong (IN PULONG Register, IN ULONG Value)
 
VOID NTAPI ScsiPortWriteRegisterUshort (IN PUSHORT Register, IN USHORT Value)
 
ULONG LoadBootDeviceDriver (VOID)
 

Variables

PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions [SCSI_MAXIMUM_BUSES]
 
static const DEVVTBL DiskVtbl
 
char __ImageBase
 

Macro Definition Documentation

◆ _SCSIPORT_

#define _SCSIPORT_

Definition at line 16 of file scsiport.c.

◆ SCSI_PORT_NEXT_REQUEST_READY

#define SCSI_PORT_NEXT_REQUEST_READY   0x0008

Definition at line 54 of file scsiport.c.

◆ TAG_SCSI_ACCESS_RANGES

#define TAG_SCSI_ACCESS_RANGES   'AscS'

Definition at line 57 of file scsiport.c.

◆ TAG_SCSI_DEVEXT

#define TAG_SCSI_DEVEXT   'DscS'

Definition at line 56 of file scsiport.c.

Typedef Documentation

◆ DISKCONTEXT

◆ PSCSI_PORT_DEVICE_EXTENSION

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( SCSIPORT  )

◆ DiskClose()

static ARC_STATUS DiskClose ( ULONG  FileId)
static

Definition at line 169 of file scsiport.c.

170 {
173  return ESUCCESS;
174 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ DiskGetFileInformation()

static ARC_STATUS DiskGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 176 of file scsiport.c.

177 {
179 
181 
182  /*
183  * The ARC specification mentions that for partitions, StartingAddress and
184  * EndingAddress are the start and end positions of the partition in terms
185  * of byte offsets from the start of the disk.
186  * CurrentAddress is the current offset into (i.e. relative to) the partition.
187  */
188  Information->StartingAddress.QuadPart = Context->SectorOffset * Context->SectorSize;
189  Information->EndingAddress.QuadPart = (Context->SectorOffset + Context->SectorCount) * Context->SectorSize;
190  Information->CurrentAddress.QuadPart = Context->SectorNumber * Context->SectorSize;
191 
192  return ESUCCESS;
193 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
Iosb Information
Definition: create.c:4377

◆ DiskOpen()

static ARC_STATUS DiskOpen ( CHAR Path,
OPENMODE  OpenMode,
ULONG FileId 
)
static

Definition at line 195 of file scsiport.c.

196 {
198  PCDB Cdb;
199  READ_CAPACITY_DATA ReadCapacityBuffer;
200 
202  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
203  ULONG ScsiBus, PathId, TargetId, Lun, Partition, PathSyntax;
207 
208  /* Parse ARC path */
209  if (!DissectArcPath2(Path, &ScsiBus, &TargetId, &Lun, &Partition, &PathSyntax))
210  return EINVAL;
211  if (PathSyntax != 0) /* scsi() format */
212  return EINVAL;
213  DeviceExtension = ScsiDeviceExtensions[ScsiBus];
214  PathId = ScsiBus - DeviceExtension->BusNum;
215 
216  /* Get disk capacity and sector size */
218  if (!Srb)
219  return ENOMEM;
221  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
222  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
223  Srb->PathId = (UCHAR)PathId;
224  Srb->TargetId = (UCHAR)TargetId;
225  Srb->Lun = (UCHAR)Lun;
226  Srb->CdbLength = 10;
227  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
228  Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA);
229  Srb->TimeOutValue = 5; /* in seconds */
230  Srb->DataBuffer = &ReadCapacityBuffer;
231  Cdb = (PCDB)Srb->Cdb;
232  Cdb->CDB10.OperationCode = SCSIOP_READ_CAPACITY;
233  if (!SpiSendSynchronousSrb(DeviceExtension, Srb))
234  {
235  return EIO;
236  }
237 
238  /* Transform result to host endianness */
239  SectorCount = ntohl(ReadCapacityBuffer.LogicalBlockAddress);
240  SectorSize = ntohl(ReadCapacityBuffer.BytesPerBlock);
241 
242  if (Partition != 0)
243  {
244  /* Need to offset start of disk and length */
246  return EIO;
247  }
248 
250  if (!Context)
251  return ENOMEM;
252  Context->DeviceExtension = DeviceExtension;
253  Context->PathId = (UCHAR)PathId;
254  Context->TargetId = (UCHAR)TargetId;
255  Context->Lun = (UCHAR)Lun;
256  Context->SectorSize = SectorSize;
257  Context->SectorOffset = SectorOffset;
258  Context->SectorCount = SectorCount;
259  Context->SectorNumber = 0;
260  FsSetDeviceSpecific(*FileId, Context);
261 
262  return ESUCCESS;
263 }
PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]
Definition: scsiport.c:109
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1117
Definition: arc.h:32
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1117
Definition: arc.h:39
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1117
Definition: cdrw_hw.h:28
ULONG ntohl(IN ULONG Value)
Definition: scsiport.c:114
ULONG LogicalBlockAddress
Definition: cdrw_hw.h:1471
struct _CDB::_CDB10 CDB10
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
Definition: arc.h:48
#define SectorOffset(L)
Definition: cdprocs.h:1632
union _CDB * PCDB
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint64_t ULONGLONG
Definition: typedefs.h:65
VOID FsSetDeviceSpecific(ULONG FileId, VOID *Specific)
Definition: fs.c:409
BOOLEAN DissectArcPath2(IN PCSTR ArcPath, OUT PULONG x, OUT PULONG y, OUT PULONG z, OUT PULONG Partition, OUT PULONG PathSyntax)
Definition: arcname.c:121
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
struct _READ_CAPACITY_DATA READ_CAPACITY_DATA
unsigned char UCHAR
Definition: xmlstorage.h:181
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
ULONG SectorCount
Definition: part_xbox.c:32
PRTL_UNICODE_STRING_BUFFER Path
Definition: arc.h:40
#define SCSIOP_READ_CAPACITY
Definition: cdrw_hw.h:904
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static BOOLEAN SpiSendSynchronousSrb(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: scsiport.c:130
_In_ ULONG SectorSize
Definition: halfuncs.h:291
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

◆ DiskRead()

static ARC_STATUS DiskRead ( ULONG  FileId,
VOID Buffer,
ULONG  N,
ULONG Count 
)
static

Definition at line 265 of file scsiport.c.

266 {
269  PCDB Cdb;
270  ULONG FullSectors, NbSectors;
271  ULONG Lba;
272 
273  *Count = 0;
274 
275  if (N == 0)
276  return ESUCCESS;
277 
278  FullSectors = N / Context->SectorSize;
279  NbSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
280  if (Context->SectorNumber + NbSectors >= Context->SectorCount)
281  return EINVAL;
282  if (FullSectors > 0xffff)
283  return EINVAL;
284 
285  /* Read full sectors */
286  ASSERT(Context->SectorNumber < 0xFFFFFFFF);
287  Lba = (ULONG)(Context->SectorOffset + Context->SectorNumber);
288  if (FullSectors > 0)
289  {
291  if (!Srb)
292  return ENOMEM;
293 
295  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
296  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
297  Srb->PathId = Context->PathId;
298  Srb->TargetId = Context->TargetId;
299  Srb->Lun = Context->Lun;
300  Srb->CdbLength = 10;
301  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
302  Srb->DataTransferLength = FullSectors * Context->SectorSize;
303  Srb->TimeOutValue = 5; /* in seconds */
304  Srb->DataBuffer = Buffer;
305  Cdb = (PCDB)Srb->Cdb;
306  Cdb->CDB10.OperationCode = SCSIOP_READ;
307  Cdb->CDB10.LogicalUnitNumber = Srb->Lun;
308  Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff;
309  Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff;
310  Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff;
311  Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff;
312  Cdb->CDB10.TransferBlocksMsb = (FullSectors >> 8) & 0xff;
313  Cdb->CDB10.TransferBlocksLsb = FullSectors & 0xff;
314  if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb))
315  {
316  return EIO;
317  }
318  Buffer = (PUCHAR)Buffer + FullSectors * Context->SectorSize;
319  N -= FullSectors * Context->SectorSize;
320  *Count += FullSectors * Context->SectorSize;
321  Context->SectorNumber += FullSectors;
322  Lba += FullSectors;
323  }
324 
325  /* Read incomplete last sector */
326  if (N > 0)
327  {
328  PUCHAR Sector;
329 
330  Sector = ExAllocatePool(PagedPool, Context->SectorSize);
331  if (!Sector)
332  return ENOMEM;
333 
335  if (!Srb)
336  {
337  ExFreePool(Sector);
338  return ENOMEM;
339  }
340 
342  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
343  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
344  Srb->PathId = Context->PathId;
345  Srb->TargetId = Context->TargetId;
346  Srb->Lun = Context->Lun;
347  Srb->CdbLength = 10;
348  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
349  Srb->DataTransferLength = Context->SectorSize;
350  Srb->TimeOutValue = 5; /* in seconds */
351  Srb->DataBuffer = Sector;
352  Cdb = (PCDB)Srb->Cdb;
353  Cdb->CDB10.OperationCode = SCSIOP_READ;
354  Cdb->CDB10.LogicalUnitNumber = Srb->Lun;
355  Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff;
356  Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff;
357  Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff;
358  Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff;
359  Cdb->CDB10.TransferBlocksMsb = 0;
360  Cdb->CDB10.TransferBlocksLsb = 1;
361  if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb))
362  {
363  ExFreePool(Sector);
364  return EIO;
365  }
366  RtlCopyMemory(Buffer, Sector, N);
367  *Count += N;
368  /* Context->SectorNumber remains untouched (incomplete sector read) */
369  ExFreePool(Sector);
370  }
371 
372  return ESUCCESS;
373 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
Definition: arc.h:32
Definition: arc.h:39
unsigned char * PUCHAR
Definition: retypes.h:3
Definition: cdrw_hw.h:28
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
struct _CDB::_CDB10 CDB10
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
Definition: arc.h:48
#define SCSIOP_READ
Definition: cdrw_hw.h:905
union _CDB * PCDB
Definition: bufpool.h:45
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: arc.h:40
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static BOOLEAN SpiSendSynchronousSrb(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: scsiport.c:130
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ DiskSeek()

static ARC_STATUS DiskSeek ( ULONG  FileId,
LARGE_INTEGER Position,
SEEKMODE  SeekMode 
)
static

Definition at line 375 of file scsiport.c.

376 {
378  LARGE_INTEGER NewPosition = *Position;
379 
380  switch (SeekMode)
381  {
382  case SeekAbsolute:
383  break;
384  case SeekRelative:
385  NewPosition.QuadPart += (Context->SectorNumber * Context->SectorSize);
386  break;
387  default:
388  ASSERT(FALSE);
389  return EINVAL;
390  }
391 
392  if (NewPosition.QuadPart & (Context->SectorSize - 1))
393  return EINVAL;
394 
395  /* Convert in number of sectors */
396  NewPosition.QuadPart /= Context->SectorSize;
397  if (NewPosition.QuadPart >= Context->SectorCount)
398  return EINVAL;
399 
400  Context->SectorNumber = NewPosition.QuadPart;
401  return ESUCCESS;
402 }
Definition: arc.h:32
Definition: arc.h:39
static COORD Position
Definition: mouse.c:34
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LONGLONG QuadPart
Definition: typedefs.h:112

◆ LoadBootDeviceDriver()

ULONG LoadBootDeviceDriver ( VOID  )

Definition at line 1619 of file scsiport.c.

1620 {
1621  PIMAGE_NT_HEADERS NtHeaders;
1623  PIMAGE_IMPORT_DESCRIPTOR ImportTable;
1624  ULONG ImportTableSize;
1625  PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE;
1626  CHAR NtBootDdPath[MAX_PATH];
1627  PVOID ImageBase = NULL;
1628  ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath);
1629  BOOLEAN Success;
1630 
1631  // FIXME: Must be done *INSIDE* the HAL!
1632 #ifdef _M_IX86
1635 #endif
1636 
1637  /* Initialize the loaded module list */
1639 
1640  /* Create full ntbootdd.sys path */
1641  strcpy(NtBootDdPath, FrLdrBootPath);
1642  strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
1643 
1644  /* Load file */
1645  Success = PeLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase);
1646  if (!Success)
1647  {
1648  /* That's OK. File simply doesn't exist */
1649  return ESUCCESS;
1650  }
1651 
1652  /* Allocate a DTE for ntbootdd */
1654  "NTBOOTDD.SYS", ImageBase, &BootDdDTE);
1655  if (!Success)
1656  return EIO;
1657 
1658  /* Add the PE part of freeldr.sys to the list of loaded executables, it
1659  contains ScsiPort* exports, imported by ntbootdd.sys */
1661  "FREELDR.SYS", &__ImageBase, &FreeldrDTE);
1662  if (!Success)
1663  {
1664  RemoveEntryList(&BootDdDTE->InLoadOrderLinks);
1665  return EIO;
1666  }
1667 
1668  /* Fix imports */
1670 
1671  /* Now unlinkt the DTEs, they won't be valid later */
1672  RemoveEntryList(&BootDdDTE->InLoadOrderLinks);
1673  RemoveEntryList(&FreeldrDTE->InLoadOrderLinks);
1674 
1675  if (!Success)
1676  return EIO;
1677 
1678  /* Change imports to PA */
1680  TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ImportTableSize);
1681  for (;(ImportTable->Name != 0) && (ImportTable->FirstThunk != 0);ImportTable++)
1682  {
1683  PIMAGE_THUNK_DATA ThunkData = (PIMAGE_THUNK_DATA)VaToPa(RVA(BootDdDTE->DllBase, ImportTable->FirstThunk));
1684 
1685  while (((PIMAGE_THUNK_DATA)ThunkData)->u1.AddressOfData != 0)
1686  {
1687  ThunkData->u1.Function = (ULONG)VaToPa((PVOID)ThunkData->u1.Function);
1688  ThunkData++;
1689  }
1690  }
1691 
1692  /* Relocate image to PA */
1693  NtHeaders = RtlImageNtHeader(VaToPa(BootDdDTE->DllBase));
1694  if (!NtHeaders)
1695  return EIO;
1697  NtHeaders->OptionalHeader.ImageBase - (ULONG_PTR)BootDdDTE->DllBase,
1698  "FreeLdr",
1699  TRUE,
1700  TRUE, /* in case of conflict still return success */
1701  FALSE);
1702  if (!Success)
1703  return EIO;
1704 
1705  /* Call the entrypoint */
1706  EntryPoint = VaToPa(BootDdDTE->EntryPoint);
1707  (*EntryPoint)(NULL, NULL);
1708 
1709  return ESUCCESS;
1710 }
BOOLEAN PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:509
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
BOOLEAN PeLdrLoadImage(IN PCHAR FileName, IN TYPE_OF_MEMORY MemoryType, OUT PVOID *ImageBasePA)
Definition: peloader.c:701
VOID NTAPI HalpInitBusHandler(VOID)
Definition: bushndlr.c:420
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
Definition: arc.h:32
char CHAR
Definition: xmlstorage.h:175
struct _IMAGE_IMPORT_DESCRIPTOR * PIMAGE_IMPORT_DESCRIPTOR
GLdouble u1
Definition: glext.h:8308
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
PVOID DllBase
Definition: btrfs_drv.h:1784
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PVOID EntryPoint
Definition: ntddk_ex.h:203
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define MAX_PATH
Definition: compat.h:26
union _IMAGE_THUNK_DATA32::@2055 u1
#define RtlImageDirectoryEntryToData
Definition: compat.h:460
Definition: btrfs_drv.h:1780
Definition: typedefs.h:117
LIST_ENTRY InLoadOrderLinks
Definition: ldrtypes.h:138
#define RVA(m, b)
Definition: freeldr.h:24
NTSYSAPI ULONG NTAPI LdrRelocateImageWithBias(_In_ PVOID NewAddress, _In_ LONGLONG AdditionalBias, _In_ PCCH LoaderName, _In_ ULONG Success, _In_ ULONG Conflict, _In_ ULONG Invalid)
VOID NTAPI HalpInitializePciStubs(VOID)
Definition: pci.c:674
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Definition: arc.h:40
#define RtlImageNtHeader
Definition: compat.h:457
#define IMAGE_DIRECTORY_ENTRY_IMPORT
Definition: pedump.c:260
char __ImageBase
Definition: mstscax.cpp:17
#define BOOLEAN
Definition: pedump.c:73
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
CHAR FrLdrBootPath[MAX_PATH]
Definition: mach.c:34
BOOLEAN PeLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BasePA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
Definition: peloader.c:585
LIST_ENTRY * ModuleListHead
Definition: kdpacket.c:23
PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
Definition: ntimage.h:566

Referenced by RunLoader().

◆ ntohl()

ULONG ntohl ( IN ULONG  Value)

Definition at line 114 of file scsiport.c.

116 {
117  FOUR_BYTE Dest;
119 
120  Dest.Byte0 = Source->Byte3;
121  Dest.Byte1 = Source->Byte2;
122  Dest.Byte2 = Source->Byte1;
123  Dest.Byte3 = Source->Byte0;
124 
125  return Dest.AsULong;
126 }
UCHAR Byte0
Definition: tools.h:16
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
struct _FOUR_BYTE * PFOUR_BYTE
UCHAR Byte3
Definition: tools.h:19
UCHAR Byte1
Definition: tools.h:17
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
UCHAR Byte2
Definition: tools.h:18
ULONG AsULong
Definition: scsi.h:2681

Referenced by DiskOpen().

◆ ScsiDebugPrint()

VOID __cdecl ScsiDebugPrint ( IN ULONG  DebugPrintLevel,
IN PCCHAR  DebugMessage,
IN ...   
)

Definition at line 462 of file scsiport.c.

466 {
467  va_list ap;
468  CHAR Buffer[512];
469  ULONG Length;
470 
471  if (DebugPrintLevel > 10)
472  return;
473 
474  va_start(ap, DebugMessage);
475 
476  /* Construct a string */
477  Length = _vsnprintf(Buffer, 512, DebugMessage, ap);
478 
479  /* Check if we went past the buffer */
480  if (Length == MAXULONG)
481  {
482  /* Terminate it if we went over-board */
483  Buffer[sizeof(Buffer) - 1] = '\0';
484 
485  /* Put maximum */
486  Length = sizeof(Buffer);
487  }
488 
489  /* Print the message */
490  TRACE("%s", Buffer);
491 
492  /* Cleanup */
493  va_end(ap);
494 }
char CHAR
Definition: xmlstorage.h:175
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define MAXULONG
Definition: typedefs.h:250
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define _vsnprintf
Definition: xmlstorage.h:202
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ ScsiPortCompleteRequest()

VOID NTAPI ScsiPortCompleteRequest ( IN PVOID  HwDeviceExtension,
IN UCHAR  PathId,
IN UCHAR  TargetId,
IN UCHAR  Lun,
IN UCHAR  SrbStatus 
)

Definition at line 498 of file scsiport.c.

504 {
505  // FIXME
507 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by AtapiResetController(), BT958HwResetBus(), and BusLogic_ProcessCompletedCCBs().

◆ ScsiPortConvertPhysicalAddressToUlong()

ULONG NTAPI ScsiPortConvertPhysicalAddressToUlong ( IN SCSI_PHYSICAL_ADDRESS  Address)

Definition at line 512 of file scsiport.c.

514 {
515  return Address.LowPart;
516 }
static WCHAR Address[46]
Definition: ping.c:68

Referenced by SpiBuildDeviceMap().

◆ ScsiPortConvertUlongToPhysicalAddress()

SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress ( IN ULONG_PTR  UlongAddress)

◆ ScsiPortFlushDma()

VOID NTAPI ScsiPortFlushDma ( IN PVOID  DeviceExtension)

Definition at line 531 of file scsiport.c.

533 {
534  // FIXME
536 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortFreeDeviceBase()

VOID NTAPI ScsiPortFreeDeviceBase ( IN PVOID  HwDeviceExtension,
IN PVOID  MappedAddress 
)

Definition at line 540 of file scsiport.c.

543 {
544  // Nothing to do
545 }

Referenced by AtapiFindController(), AtapiFindIsaController(), AtapiFindNativeModeController(), AtapiFindPCIController(), and UniataChipDetect().

◆ ScsiPortGetBusData()

ULONG NTAPI ScsiPortGetBusData ( IN PVOID  DeviceExtension,
IN ULONG  BusDataType,
IN ULONG  SystemIoBusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 549 of file scsiport.c.

556 {
557  return HalGetBusDataByOffset(BusDataType, SystemIoBusNumber, SlotNumber, Buffer, 0, Length);
558 }
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73

Referenced by AtapiAliSouthBridgeFixup(), AtapiFindController(), AtapiFindNativeModeController(), AtapiRosbSouthBridgeFixup(), AtapiViaSouthBridgeFixup(), and FindBrokenController().

◆ ScsiPortGetDeviceBase()

PVOID NTAPI ScsiPortGetDeviceBase ( IN PVOID  HwDeviceExtension,
IN INTERFACE_TYPE  BusType,
IN ULONG  SystemIoBusNumber,
IN SCSI_PHYSICAL_ADDRESS  IoAddress,
IN ULONG  NumberOfBytes,
IN BOOLEAN  InIoSpace 
)

Definition at line 562 of file scsiport.c.

569 {
572 
573  AddressSpace = (ULONG)InIoSpace;
575  SystemIoBusNumber,
576  IoAddress,
577  &AddressSpace,
579  {
580  return NULL;
581  }
582 
583  /* I/O space */
584  if (AddressSpace != 0)
585  return (PVOID)TranslatedAddress.u.LowPart;
586 
587  // FIXME
589  return (PVOID)IoAddress.LowPart;
590 }
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:156
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2268
struct _LARGE_INTEGER::@2201 u
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by AtapiFindController(), AtapiFindIsaController(), AtapiFindNativeModeController(), AtapiFindPCIController(), AtapiGetIoRange(), BT958HwFindAdapter(), and UniataFindBusMasterController().

◆ ScsiPortGetLogicalUnit()

PVOID NTAPI ScsiPortGetLogicalUnit ( IN PVOID  HwDeviceExtension,
IN UCHAR  PathId,
IN UCHAR  TargetId,
IN UCHAR  Lun 
)

Definition at line 594 of file scsiport.c.

599 {
600  // FIXME
602  return NULL;
603 }
smooth NULL
Definition: ftsmooth.c:416
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortGetPhysicalAddress()

SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortGetPhysicalAddress ( IN PVOID  HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb  OPTIONAL,
IN PVOID  VirtualAddress,
OUT ULONG Length 
)

Definition at line 607 of file scsiport.c.

612 {
613  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
615  ULONG BufferLength = 0;
616  ULONG Offset;
617 
618  TRACE("ScsiPortGetPhysicalAddress(%p %p %p %p)\n",
619  HwDeviceExtension, Srb, VirtualAddress, Length);
620 
621  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
622 
623  if (Srb == NULL || Srb->SenseInfoBuffer == VirtualAddress)
624  {
625  /* Simply look it up in the allocated common buffer */
626  Offset = (PUCHAR)VirtualAddress - (PUCHAR)DeviceExtension->SrbExtensionBuffer;
627 
628  BufferLength = DeviceExtension->CommonBufferLength - Offset;
630  }
631  else
632  {
633  /* Nothing */
635  }
636 
637  *Length = BufferLength;
638  return PhysicalAddress;
639 }
#define SP_UNINITIALIZED_VALUE
Definition: srb.h:224
unsigned char * PUCHAR
Definition: retypes.h:3
struct SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
unsigned int ULONG
Definition: retypes.h:1
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by BusLogic_InitializeHostAdapter(), BusLogic_QueueCommand(), and BusLogic_WriteOutgoingMailbox().

◆ ScsiPortGetSrb()

PSCSI_REQUEST_BLOCK NTAPI ScsiPortGetSrb ( IN PVOID  DeviceExtension,
IN UCHAR  PathId,
IN UCHAR  TargetId,
IN UCHAR  Lun,
IN LONG  QueueTag 
)

Definition at line 643 of file scsiport.c.

649 {
650  // FIXME
652  return NULL;
653 }
smooth NULL
Definition: ftsmooth.c:416
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by AtapiStartIo__(), and BT958HwStartIO().

◆ ScsiPortGetUncachedExtension()

PVOID NTAPI ScsiPortGetUncachedExtension ( IN PVOID  HwDeviceExtension,
IN PPORT_CONFIGURATION_INFORMATION  ConfigInfo,
IN ULONG  NumberOfBytes 
)

Definition at line 721 of file scsiport.c.

725 {
726  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
728  ULONG MapRegistersCount;
730 
731  TRACE("ScsiPortGetUncachedExtension(%p %p %lu)\n",
732  HwDeviceExtension, ConfigInfo, NumberOfBytes);
733 
734  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
735 
736  /* Check for allocated common DMA buffer */
737  if (DeviceExtension->SrbExtensionBuffer != NULL)
738  {
739  return NULL;
740  }
741 
742  /* Check for DMA adapter object */
743  if (DeviceExtension->AdapterObject == NULL)
744  {
745  /* Initialize DMA adapter description */
747 
749  DeviceDescription.Master = ConfigInfo->Master;
750  DeviceDescription.ScatterGather = ConfigInfo->ScatterGather;
751  DeviceDescription.DemandMode = ConfigInfo->DemandMode;
752  DeviceDescription.Dma32BitAddresses = ConfigInfo->Dma32BitAddresses;
753  DeviceDescription.BusNumber = ConfigInfo->SystemIoBusNumber;
754  DeviceDescription.DmaChannel = ConfigInfo->DmaChannel;
755  DeviceDescription.InterfaceType = ConfigInfo->AdapterInterfaceType;
756  DeviceDescription.DmaWidth = ConfigInfo->DmaWidth;
757  DeviceDescription.DmaSpeed = ConfigInfo->DmaSpeed;
758  DeviceDescription.MaximumLength = ConfigInfo->MaximumTransferLength;
759  DeviceDescription.DmaPort = ConfigInfo->DmaPort;
760 
761  /* Get a DMA adapter object */
762 #if 0
763  DeviceExtension->AdapterObject =
764  HalGetAdapter(&DeviceDescription, &MapRegistersCount);
765 
766  /* Fail in case of error */
767  if (DeviceExtension->AdapterObject == NULL)
768  {
769  return NULL;
770  }
771 #else
772  MapRegistersCount = 0;
773 #endif
774 
775  /* Set number of physical breaks */
776  if (ConfigInfo->NumberOfPhysicalBreaks != 0 &&
777  MapRegistersCount > ConfigInfo->NumberOfPhysicalBreaks)
778  {
779  DeviceExtension->PortCapabilities.MaximumPhysicalPages =
780  ConfigInfo->NumberOfPhysicalBreaks;
781  }
782  else
783  {
784  DeviceExtension->PortCapabilities.MaximumPhysicalPages = MapRegistersCount;
785  }
786  }
787 
788  /* Update Srb extension size */
789  if (DeviceExtension->SrbExtensionSize != ConfigInfo->SrbExtensionSize)
790  DeviceExtension->SrbExtensionSize = ConfigInfo->SrbExtensionSize;
791 
792  /* Allocate a common DMA buffer */
793  Status = SpiAllocateCommonBuffer(DeviceExtension, NumberOfBytes);
794 
795  if (!NT_SUCCESS(Status))
796  {
797  TRACE("SpiAllocateCommonBuffer() failed with Status = 0x%08X!\n", Status);
798  return NULL;
799  }
800 
801  return DeviceExtension->NonCachedExtension;
802 }
IO_SCSI_CAPABILITIES PortCapabilities
Definition: scsiport.c:79
struct SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
DMA_SPEED DmaSpeed
Definition: iotypes.h:2038
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2020
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2030
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN DemandMode
Definition: iotypes.h:2028
BOOLEAN ScatterGather
Definition: iotypes.h:2027
DMA_WIDTH DmaWidth
Definition: iotypes.h:2037
Status
Definition: gdiplustypes.h:24
PADAPTER_OBJECT AdapterObject
Definition: scsiport.c:87
static NTSTATUS SpiAllocateCommonBuffer(IN OUT PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN ULONG NonCachedSize)
Definition: scsiport.c:657
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2036
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:998
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PADAPTER_OBJECT NTAPI HalGetAdapter(IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:22

Referenced by Buslogic_InitBT958().

◆ ScsiPortGetVirtualAddress()

PVOID NTAPI ScsiPortGetVirtualAddress ( IN PVOID  HwDeviceExtension,
IN SCSI_PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 806 of file scsiport.c.

809 {
810  // FIXME
812  return NULL;
813 }
smooth NULL
Definition: ftsmooth.c:416
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by AtapiDmaPioSync(), and BusLogic_ScanIncomingMailboxes().

◆ ScsiPortInitialize()

ULONG NTAPI ScsiPortInitialize ( IN PVOID  Argument1,
IN PVOID  Argument2,
IN PHW_INITIALIZATION_DATA  HwInitializationData,
IN PVOID HwContext  OPTIONAL 
)

Definition at line 1117 of file scsiport.c.

1122 {
1123  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
1124  ULONG DeviceExtensionSize;
1125  PORT_CONFIGURATION_INFORMATION PortConfig;
1126  BOOLEAN Again;
1127  BOOLEAN FirstConfigCall = TRUE;
1129  UCHAR ScsiBus;
1130  NTSTATUS Status;
1131 
1132  if (HwInitializationData->HwInitializationDataSize != sizeof(HW_INITIALIZATION_DATA))
1133  {
1134  return STATUS_INVALID_PARAMETER;
1135  }
1136 
1137  /* Check params for validity */
1138  if ((HwInitializationData->HwInitialize == NULL) ||
1139  (HwInitializationData->HwStartIo == NULL) ||
1140  (HwInitializationData->HwInterrupt == NULL) ||
1141  (HwInitializationData->HwFindAdapter == NULL) ||
1142  (HwInitializationData->HwResetBus == NULL))
1143  {
1144  return STATUS_INVALID_PARAMETER;
1145  }
1146 
1147  /* Zero starting slot number */
1148  SlotNumber.u.AsULONG = 0;
1149 
1150  while (TRUE)
1151  {
1152  Again = FALSE;
1153 
1154  DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize;
1155  DeviceExtension = FrLdrTempAlloc(DeviceExtensionSize, TAG_SCSI_DEVEXT);
1156  if (!DeviceExtension)
1157  {
1158  return STATUS_NO_MEMORY;
1159  }
1160  RtlZeroMemory(DeviceExtension, DeviceExtensionSize);
1161  DeviceExtension->InterruptFlags = SCSI_PORT_NEXT_REQUEST_READY;
1162  DeviceExtension->HwInitialize = HwInitializationData->HwInitialize;
1163  DeviceExtension->HwStartIo = HwInitializationData->HwStartIo;
1164  DeviceExtension->HwInterrupt = HwInitializationData->HwInterrupt;
1165  DeviceExtension->HwResetBus = HwInitializationData->HwResetBus;
1166  DeviceExtension->MiniPortDeviceExtension = (PVOID)(DeviceExtension + 1);
1167 
1168  Status = SpiCreatePortConfig(DeviceExtension,
1170  &PortConfig,
1171  FirstConfigCall);
1172  if (Status != STATUS_SUCCESS)
1173  {
1174  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1175  return Status;
1176  }
1177 
1178  PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges;
1179  PortConfig.AccessRanges = FrLdrTempAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges,
1181  if (!PortConfig.AccessRanges)
1182  {
1183  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1184  return STATUS_NO_MEMORY;
1185  }
1186  RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges);
1187 
1188  /* Search for matching PCI device */
1189  if ((HwInitializationData->AdapterInterfaceType == PCIBus) &&
1190  (HwInitializationData->VendorIdLength > 0) &&
1191  (HwInitializationData->VendorId != NULL) &&
1192  (HwInitializationData->DeviceIdLength > 0) &&
1193  (HwInitializationData->DeviceId != NULL))
1194  {
1195  PortConfig.BusInterruptLevel = 0;
1196 
1197  /* Get PCI device data */
1198  TRACE("VendorId '%.*s' DeviceId '%.*s'\n",
1199  HwInitializationData->VendorIdLength,
1200  HwInitializationData->VendorId,
1201  HwInitializationData->DeviceIdLength,
1202  HwInitializationData->DeviceId);
1203 
1205  &PortConfig,
1206  0, /* FIXME */
1207  &SlotNumber))
1208  {
1209  /* Continue to the next bus, nothing here */
1210  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1211  return STATUS_INTERNAL_ERROR;
1212  }
1213 
1214  if (!PortConfig.BusInterruptLevel)
1215  {
1216  /* Bypass this slot, because no interrupt was assigned */
1217  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1218  return STATUS_INTERNAL_ERROR;
1219  }
1220  }
1221 
1222  if (HwInitializationData->HwFindAdapter(
1223  DeviceExtension->MiniPortDeviceExtension,
1224  HwContext,
1225  NULL,
1226  NULL,
1227  &PortConfig,
1228  &Again) != SP_RETURN_FOUND)
1229  {
1230  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1231  return STATUS_INTERNAL_ERROR;
1232  }
1233 
1234  /* Copy all stuff which we ever need from PortConfig to the DeviceExtension */
1236  DeviceExtension->MaxTargedIds = SCSI_MAXIMUM_TARGETS_PER_BUS;
1237  else
1238  DeviceExtension->MaxTargedIds = PortConfig.MaximumNumberOfTargets;
1239 
1240  DeviceExtension->BusNum = PortConfig.SystemIoBusNumber;
1241 
1242  TRACE("Adapter found: buses = %d, targets = %d\n",
1243  PortConfig.NumberOfBuses, DeviceExtension->MaxTargedIds);
1244 
1245  /* Initialize adapter */
1246  if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension))
1247  {
1248  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1249  return STATUS_INTERNAL_ERROR;
1250  }
1251 
1252  /* Scan bus */
1253  for (ScsiBus = 0; ScsiBus < PortConfig.NumberOfBuses; ScsiBus++)
1254  {
1255  SpiScanAdapter(DeviceExtension, PortConfig.SystemIoBusNumber, ScsiBus);
1256  PortConfig.SystemIoBusNumber++;
1257  }
1258 
1259  FirstConfigCall = FALSE;
1260  if (!Again)
1261  {
1262  break;
1263  }
1264  }
1265 
1266  return STATUS_SUCCESS;
1267 }
#define TRUE
Definition: types.h:120
static NTSTATUS SpiCreatePortConfig(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PHW_INITIALIZATION_DATA HwInitData, OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, IN BOOLEAN ZeroStruct)
Definition: scsiport.c:415
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static BOOLEAN SpiGetPciConfigData(IN PHW_INITIALIZATION_DATA HwInitializationData, IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig, IN ULONG BusNumber, IN OUT PPCI_SLOT_NUMBER NextSlotNumber)
Definition: scsiport.c:1017
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:664
struct _SCSI_PORT_DEVICE_EXTENSION SCSI_PORT_DEVICE_EXTENSION
ACCESS_RANGE(* AccessRanges)[]
Definition: srb.h:70
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
#define SCSI_MAXIMUM_TARGETS_PER_BUS
Definition: srb.h:22
#define SCSI_PORT_NEXT_REQUEST_READY
Definition: scsiport.c:54
PHW_INITIALIZE HwInitialize
Definition: scsiport.c:81
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define TRACE(s)
Definition: solgame.cpp:4
#define TAG_SCSI_ACCESS_RANGES
Definition: scsiport.c:57
#define SP_RETURN_FOUND
Definition: srb.h:514
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
unsigned char UCHAR
Definition: xmlstorage.h:181
static VOID SpiScanAdapter(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN ULONG ScsiBus, IN UCHAR PathId)
Definition: scsiport.c:861
Status
Definition: gdiplustypes.h:24
PHW_RESET_BUS HwResetBus
Definition: scsiport.c:84
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
PHW_INTERRUPT HwInterrupt
Definition: scsiport.c:83
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define TAG_SCSI_DEVEXT
Definition: scsiport.c:56
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:664
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by DriverEntry().

◆ ScsiPortIoMapTransfer()

VOID NTAPI ScsiPortIoMapTransfer ( IN PVOID  HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK  Srb,
IN PVOID  LogicalAddress,
IN ULONG  Length 
)

Definition at line 1271 of file scsiport.c.

1276 {
1277  // FIXME
1278  UNIMPLEMENTED;
1279 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortLogError()

VOID NTAPI ScsiPortLogError ( IN PVOID  HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb  OPTIONAL,
IN UCHAR  PathId,
IN UCHAR  TargetId,
IN UCHAR  Lun,
IN ULONG  ErrorCode,
IN ULONG  UniqueId 
)

Definition at line 1283 of file scsiport.c.

1291 {
1292  // FIXME
1293  UNIMPLEMENTED;
1294 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by AtapiStartIo(), AtapiStartIo__(), BT958HwFindAdapter(), Buslogic_InitBT958(), BusLogic_ProcessCompletedCCBs(), and MapError().

◆ ScsiPortMoveMemory()

VOID NTAPI ScsiPortMoveMemory ( IN PVOID  WriteBuffer,
IN PVOID  ReadBuffer,
IN ULONG  Length 
)

Definition at line 1298 of file scsiport.c.

1302 {
1304 }
#define ReadBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:339
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344

Referenced by Atapi2Scsi(), AtapiStartIo(), AtapiStartIo__(), BusLogic_QueueCommand(), and IssueIdentify().

◆ ScsiPortNotification()

VOID __cdecl ScsiPortNotification ( IN SCSI_NOTIFICATION_TYPE  NotificationType,
IN PVOID  HwDeviceExtension,
IN ...   
)

Definition at line 1308 of file scsiport.c.

1312 {
1313  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
1315  va_list ap;
1316 
1317  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
1318 
1319  va_start(ap, HwDeviceExtension);
1320 
1321  switch (NotificationType)
1322  {
1323  case RequestComplete:
1324  /* Mask the SRB as completed */
1326  Srb->SrbFlags &= ~SRB_FLAGS_IS_ACTIVE;
1327  break;
1328 
1329  case NextRequest:
1330  /* Say that device is ready */
1331  DeviceExtension->InterruptFlags |= SCSI_PORT_NEXT_REQUEST_READY;
1332  break;
1333 
1334  default:
1335  // FIXME
1336  UNIMPLEMENTED;
1337  }
1338 
1339  va_end(ap);
1340 }
#define SRB_FLAGS_IS_ACTIVE
Definition: srb.h:399
struct SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
#define va_end(ap)
Definition: acmsvcex.h:90
#define SCSI_PORT_NEXT_REQUEST_READY
Definition: scsiport.c:54
char * va_list
Definition: acmsvcex.h:78
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define UNIMPLEMENTED
Definition: debug.h:114
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

Referenced by AtapiCallBack(), AtapiCallBack__(), AtapiInterrupt(), AtapiInterrupt__(), AtapiQueueTimerDpc(), AtapiResetController(), AtapiResetController__(), AtapiSendCommand(), AtapiStartIo(), AtapiStartIo__(), AtapiTimerDpc(), BT958HwStartIO(), BT958WmiSrb(), BusLogic_ProcessCompletedCCBs(), ScsiPortCompleteRequest(), ScsiPortStartIo(), ScsiPortStartPacket(), and SpiCompleteRequest().

◆ ScsiPortReadPortBufferUchar()

VOID NTAPI ScsiPortReadPortBufferUchar ( IN PUCHAR  Port,
OUT PUCHAR  Buffer,
IN ULONG  Count 
)

Definition at line 1344 of file scsiport.c.

1348 {
1350 }
CPPORT Port[4]
Definition: headless.c:34
PPC_QUAL void __inbytestring(unsigned long Port, unsigned char *Buffer, unsigned long Count)
Definition: intrin_ppc.h:584
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
Definition: bufpool.h:45

◆ ScsiPortReadPortBufferUlong()

VOID NTAPI ScsiPortReadPortBufferUlong ( IN PULONG  Port,
OUT PULONG  Buffer,
IN ULONG  Count 
)

Definition at line 1354 of file scsiport.c.

1358 {
1360 }
CPPORT Port[4]
Definition: headless.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
Definition: bufpool.h:45
PPC_QUAL void __indwordstring(unsigned long Port, unsigned long *Buffer, unsigned long Count)
Definition: intrin_ppc.h:598

◆ ScsiPortReadPortBufferUshort()

VOID NTAPI ScsiPortReadPortBufferUshort ( IN PUSHORT  Port,
OUT PUSHORT  Buffer,
IN ULONG  Count 
)

Definition at line 1364 of file scsiport.c.

1368 {
1370 }
CPPORT Port[4]
Definition: headless.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
Definition: bufpool.h:45
PPC_QUAL void __inwordstring(unsigned long Port, unsigned short *Buffer, unsigned long Count)
Definition: intrin_ppc.h:591

◆ ScsiPortReadPortUchar()

UCHAR NTAPI ScsiPortReadPortUchar ( IN PUCHAR  Port)

Definition at line 1374 of file scsiport.c.

1376 {
1377  TRACE("ScsiPortReadPortUchar(%p)\n", Port);
1378 
1379  return READ_PORT_UCHAR(Port);
1380 }
CPPORT Port[4]
Definition: headless.c:34
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:528
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by AtapiFindController(), AtapiFindNativeModeController(), AtapiFindPCIController(), AtapiHwInitialize(), AtapiInterrupt(), FindDevices(), IdeMediaStatus(), IdeSendCommand(), IssueIdentify(), MapError(), ReadBusLogicPort(), and SetDriveParameters().

◆ ScsiPortReadPortUlong()

ULONG NTAPI ScsiPortReadPortUlong ( IN PULONG  Port)

Definition at line 1384 of file scsiport.c.

1386 {
1387  return READ_PORT_ULONG(Port);
1388 }
CPPORT Port[4]
Definition: headless.c:34
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70

◆ ScsiPortReadPortUshort()

USHORT NTAPI ScsiPortReadPortUshort ( IN PUSHORT  Port)

Definition at line 1392 of file scsiport.c.

1394 {
1395  return READ_PORT_USHORT(Port);
1396 }
CPPORT Port[4]
Definition: headless.c:34
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63

Referenced by AtapiSendCommand(), and IssueIdentify().

◆ ScsiPortReadRegisterBufferUchar()

VOID NTAPI ScsiPortReadRegisterBufferUchar ( IN PUCHAR  Register,
IN PUCHAR  Buffer,
IN ULONG  Count 
)

Definition at line 1400 of file scsiport.c.

1404 {
1405  // FIXME
1406  UNIMPLEMENTED;
1407 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterBufferUlong()

VOID NTAPI ScsiPortReadRegisterBufferUlong ( IN PULONG  Register,
IN PULONG  Buffer,
IN ULONG  Count 
)

Definition at line 1411 of file scsiport.c.

1415 {
1416  // FIXME
1417  UNIMPLEMENTED;
1418 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterBufferUshort()

VOID NTAPI ScsiPortReadRegisterBufferUshort ( IN PUSHORT  Register,
IN PUSHORT  Buffer,
IN ULONG  Count 
)

Definition at line 1422 of file scsiport.c.

1426 {
1427  // FIXME
1428  UNIMPLEMENTED;
1429 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterUchar()

UCHAR NTAPI ScsiPortReadRegisterUchar ( IN PUCHAR  Register)

Definition at line 1433 of file scsiport.c.

1435 {
1436  return READ_REGISTER_UCHAR(Register);
1437 }
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)

◆ ScsiPortReadRegisterUlong()

ULONG NTAPI ScsiPortReadRegisterUlong ( IN PULONG  Register)

Definition at line 1441 of file scsiport.c.

1443 {
1444  return READ_REGISTER_ULONG(Register);
1445 }
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)

◆ ScsiPortReadRegisterUshort()

USHORT NTAPI ScsiPortReadRegisterUshort ( IN PUSHORT  Register)

Definition at line 1449 of file scsiport.c.

1451 {
1452  return READ_REGISTER_USHORT(Register);
1453 }
NTKERNELAPI USHORT NTAPI READ_REGISTER_USHORT(IN PUSHORT Register)

◆ ScsiPortSetBusDataByOffset()

ULONG NTAPI ScsiPortSetBusDataByOffset ( IN PVOID  DeviceExtension,
IN ULONG  BusDataType,
IN ULONG  SystemIoBusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 1457 of file scsiport.c.

1465 {
1466  // FIXME
1467  UNIMPLEMENTED;
1468  return 0;
1469 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortStallExecution()

◆ ScsiPortValidateRange()

BOOLEAN NTAPI ScsiPortValidateRange ( IN PVOID  HwDeviceExtension,
IN INTERFACE_TYPE  BusType,
IN ULONG  SystemIoBusNumber,
IN SCSI_PHYSICAL_ADDRESS  IoAddress,
IN ULONG  NumberOfBytes,
IN BOOLEAN  InIoSpace 
)

Definition at line 1481 of file scsiport.c.

1488 {
1489  // FIXME
1490  UNIMPLEMENTED;
1491  return TRUE;
1492 }
#define TRUE
Definition: types.h:120
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by BT958HwFindAdapter(), and UniataFindBusMasterController().

◆ ScsiPortWritePortBufferUchar()

VOID NTAPI ScsiPortWritePortBufferUchar ( IN PUCHAR  Port,
IN PUCHAR  Buffer,
IN ULONG  Count 
)

Definition at line 1501 of file scsiport.c.

1505 {
1507 }
CPPORT Port[4]
Definition: headless.c:34
PPC_QUAL void __outbytestring(unsigned long const Port, const unsigned char *const Buffer, const unsigned long Count)
Definition: intrin_ppc.h:653
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
Definition: bufpool.h:45

◆ ScsiPortWritePortBufferUlong()

VOID NTAPI ScsiPortWritePortBufferUlong ( IN PULONG  Port,
IN PULONG  Buffer,
IN ULONG  Count 
)

Definition at line 1511 of file scsiport.c.

1515 {
1517 }
CPPORT Port[4]
Definition: headless.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
PPC_QUAL void __outdwordstring(unsigned long const Port, const unsigned long *const Buffer, const unsigned long Count)
Definition: intrin_ppc.h:671
Definition: bufpool.h:45

◆ ScsiPortWritePortBufferUshort()

VOID NTAPI ScsiPortWritePortBufferUshort ( IN PUSHORT  Port,
IN PUSHORT  Buffer,
IN ULONG  Count 
)

Definition at line 1521 of file scsiport.c.

1525 {
1527 }
CPPORT Port[4]
Definition: headless.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define H2I(Port)
Definition: portio.c:18
Definition: bufpool.h:45
PPC_QUAL void __outwordstring(unsigned long const Port, const unsigned short *const Buffer, const unsigned long Count)
Definition: intrin_ppc.h:662

◆ ScsiPortWritePortUchar()

VOID NTAPI ScsiPortWritePortUchar ( IN PUCHAR  Port,
IN UCHAR  Value 
)

◆ ScsiPortWritePortUlong()

VOID NTAPI ScsiPortWritePortUlong ( IN PULONG  Port,
IN ULONG  Value 
)

Definition at line 1540 of file scsiport.c.

1543 {
1545 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
CPPORT Port[4]
Definition: headless.c:34
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123

◆ ScsiPortWritePortUshort()

VOID NTAPI ScsiPortWritePortUshort ( IN PUSHORT  Port,
IN USHORT  Value 
)

Definition at line 1549 of file scsiport.c.

1552 {
1554 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
CPPORT Port[4]
Definition: headless.c:34
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115

◆ ScsiPortWriteRegisterBufferUchar()

VOID NTAPI ScsiPortWriteRegisterBufferUchar ( IN PUCHAR  Register,
IN PUCHAR  Buffer,
IN ULONG  Count 
)

Definition at line 1558 of file scsiport.c.

1562 {
1563  // FIXME
1564  UNIMPLEMENTED;
1565 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterBufferUlong()

VOID NTAPI ScsiPortWriteRegisterBufferUlong ( IN PULONG  Register,
IN PULONG  Buffer,
IN ULONG  Count 
)

Definition at line 1569 of file scsiport.c.

1573 {
1574  // FIXME
1575  UNIMPLEMENTED;
1576 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterBufferUshort()

VOID NTAPI ScsiPortWriteRegisterBufferUshort ( IN PUSHORT  Register,
IN PUSHORT  Buffer,
IN ULONG  Count 
)

Definition at line 1580 of file scsiport.c.

1584 {
1585  // FIXME
1586  UNIMPLEMENTED;
1587 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterUchar()

VOID NTAPI ScsiPortWriteRegisterUchar ( IN PUCHAR  Register,
IN UCHAR  Value 
)

Definition at line 1591 of file scsiport.c.

1594 {
1595  WRITE_REGISTER_UCHAR(Register, Value);
1596 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

◆ ScsiPortWriteRegisterUlong()

VOID NTAPI ScsiPortWriteRegisterUlong ( IN PULONG  Register,
IN ULONG  Value 
)

Definition at line 1600 of file scsiport.c.

1603 {
1604  WRITE_REGISTER_ULONG(Register, Value);
1605 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)

◆ ScsiPortWriteRegisterUshort()

VOID NTAPI ScsiPortWriteRegisterUshort ( IN PUSHORT  Register,
IN USHORT  Value 
)

Definition at line 1609 of file scsiport.c.

1612 {
1613  WRITE_REGISTER_USHORT(Register, Value);
1614 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT(IN PUSHORT Register, IN USHORT Value)

◆ SpiAllocateCommonBuffer()

static NTSTATUS SpiAllocateCommonBuffer ( IN OUT PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  NonCachedSize 
)
static

Definition at line 657 of file scsiport.c.

660 {
661  PVOID CommonBuffer;
662  ULONG CommonBufferLength, BufSize;
663 
664  /* If size is 0, set it to 16 */
665  if (!DeviceExtension->SrbExtensionSize)
666  DeviceExtension->SrbExtensionSize = 16;
667 
668  /* Calculate size */
669  BufSize = DeviceExtension->SrbExtensionSize;
670 
671  /* Round it */
672  BufSize = (BufSize + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1);
673 
674  /* Sum up into the total common buffer length, and round it to page size */
675  CommonBufferLength =
676  ROUND_TO_PAGES(NonCachedSize);
677 
678  /* Allocate it */
679  if (!DeviceExtension->AdapterObject)
680  {
681  /* From nonpaged pool if there is no DMA */
682  CommonBuffer = ExAllocatePool(NonPagedPool, CommonBufferLength);
683  }
684  else
685  {
686  /* Perform a full request since we have a DMA adapter*/
688  CommonBuffer = NULL;
689  }
690 
691  /* Fail in case of error */
692  if (!CommonBuffer)
694 
695  /* Zero it */
696  RtlZeroMemory(CommonBuffer, CommonBufferLength);
697 
698  /* Store its size in Device Extension */
699  DeviceExtension->CommonBufferLength = CommonBufferLength;
700 
701  /* SrbExtension buffer is located at the beginning of the buffer */
702  DeviceExtension->SrbExtensionBuffer = CommonBuffer;
703 
704  /* Non-cached extension buffer is located at the end of
705  the common buffer */
706  if (NonCachedSize)
707  {
708  CommonBufferLength -= NonCachedSize;
709  DeviceExtension->NonCachedExtension = (PUCHAR)CommonBuffer + CommonBufferLength;
710  }
711  else
712  {
713  DeviceExtension->NonCachedExtension = NULL;
714  }
715 
716  return STATUS_SUCCESS;
717 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
unsigned char * PUCHAR
Definition: retypes.h:3
smooth NULL
Definition: ftsmooth.c:416
#define BufSize
Definition: FsRtlTunnel.c:28
int64_t LONGLONG
Definition: typedefs.h:66
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define ROUND_TO_PAGES(Size)
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ScsiPortGetUncachedExtension().

◆ SpiCreatePortConfig()

static NTSTATUS SpiCreatePortConfig ( IN PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
IN PHW_INITIALIZATION_DATA  HwInitData,
OUT PPORT_CONFIGURATION_INFORMATION  ConfigInfo,
IN BOOLEAN  ZeroStruct 
)
static

Definition at line 415 of file scsiport.c.

420 {
421  ULONG Bus;
422 
423  /* Zero out the struct if told so */
424  if (ZeroStruct)
425  {
426  /* First zero the portconfig */
427  RtlZeroMemory(ConfigInfo, sizeof(PORT_CONFIGURATION_INFORMATION));
428 
429  /* Initialize the struct */
430  ConfigInfo->Length = sizeof(PORT_CONFIGURATION_INFORMATION);
431  ConfigInfo->AdapterInterfaceType = HwInitData->AdapterInterfaceType;
432  ConfigInfo->InterruptMode = Latched;
433  ConfigInfo->DmaChannel = SP_UNINITIALIZED_VALUE;
434  ConfigInfo->DmaPort = SP_UNINITIALIZED_VALUE;
435  ConfigInfo->MaximumTransferLength = SP_UNINITIALIZED_VALUE;
436  ConfigInfo->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS_PER_BUS;
437 
438  /* Store parameters */
439  ConfigInfo->NeedPhysicalAddresses = HwInitData->NeedPhysicalAddresses;
440  ConfigInfo->MapBuffers = HwInitData->MapBuffers;
441  ConfigInfo->AutoRequestSense = HwInitData->AutoRequestSense;
442  ConfigInfo->ReceiveEvent = HwInitData->ReceiveEvent;
443  ConfigInfo->TaggedQueuing = HwInitData->TaggedQueuing;
444  ConfigInfo->MultipleRequestPerLu = HwInitData->MultipleRequestPerLu;
445 
446  /* Get the disk usage */
447  ConfigInfo->AtdiskPrimaryClaimed = FALSE; // FIXME
448  ConfigInfo->AtdiskSecondaryClaimed = FALSE; // FIXME
449 
450  /* Initiator bus id is not set */
451  for (Bus = 0; Bus < 8; Bus++)
452  ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE;
453  }
454 
455  ConfigInfo->NumberOfPhysicalBreaks = 17;
456 
457  return STATUS_SUCCESS;
458 }
#define SP_UNINITIALIZED_VALUE
Definition: srb.h:224
#define SCSI_MAXIMUM_TARGETS_PER_BUS
Definition: srb.h:22
char CCHAR
Definition: typedefs.h:50
struct _PORT_CONFIGURATION_INFORMATION PORT_CONFIGURATION_INFORMATION
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ScsiPortInitialize().

◆ SpiGetPciConfigData()

static BOOLEAN SpiGetPciConfigData ( IN PHW_INITIALIZATION_DATA  HwInitializationData,
IN OUT PPORT_CONFIGURATION_INFORMATION  PortConfig,
IN ULONG  BusNumber,
IN OUT PPCI_SLOT_NUMBER  NextSlotNumber 
)
static

Definition at line 1017 of file scsiport.c.

1022 {
1023  PCI_COMMON_CONFIG PciConfig;
1025  ULONG DataSize;
1027  ULONG FunctionNumber;
1028  CHAR VendorIdString[8];
1029  CHAR DeviceIdString[8];
1031  NTSTATUS Status;
1032 
1033  SlotNumber.u.AsULONG = 0;
1034 
1035  /* Loop through all devices */
1036  for (DeviceNumber = NextSlotNumber->u.bits.DeviceNumber; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
1037  {
1038  SlotNumber.u.bits.DeviceNumber = DeviceNumber;
1039 
1040  /* Loop through all functions */
1041  for (FunctionNumber = NextSlotNumber->u.bits.FunctionNumber; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
1042  {
1043  SlotNumber.u.bits.FunctionNumber = FunctionNumber;
1044 
1045  /* Get PCI config bytes */
1048  BusNumber,
1049  SlotNumber.u.AsULONG,
1050  &PciConfig,
1051  0,
1052  sizeof(ULONG));
1053 
1054  /* If result of HalGetBusData is 0, then the bus is wrong */
1055  if (DataSize == 0)
1056  return FALSE;
1057 
1058  /* If result is PCI_INVALID_VENDORID, then this device has no more
1059  "Functions" */
1060  if (PciConfig.VendorID == PCI_INVALID_VENDORID)
1061  break;
1062 
1063  sprintf(VendorIdString, "%04hx", PciConfig.VendorID);
1064  sprintf(DeviceIdString, "%04hx", PciConfig.DeviceID);
1065 
1066  if (_strnicmp(VendorIdString, HwInitializationData->VendorId, HwInitializationData->VendorIdLength) ||
1067  _strnicmp(DeviceIdString, HwInitializationData->DeviceId, HwInitializationData->DeviceIdLength))
1068  {
1069  /* It is not our device */
1070  continue;
1071  }
1072 
1073  TRACE( "Found device 0x%04hx 0x%04hx at %1lu %2lu %1lu\n",
1074  PciConfig.VendorID, PciConfig.DeviceID,
1075  BusNumber,
1076  SlotNumber.u.bits.DeviceNumber, SlotNumber.u.bits.FunctionNumber);
1077 
1079  NULL,
1080  NULL,
1081  NULL,
1082  PCIBus,
1083  BusNumber,
1084  SlotNumber.u.AsULONG,
1085  &ResourceList);
1086 
1087  if (!NT_SUCCESS(Status))
1088  break;
1089 
1090  /* Create configuration information */
1092  ResourceList->List,
1093  PortConfig);
1094 
1095  /* Free the resource list */
1097 
1098  /* Set dev & fn numbers */
1099  NextSlotNumber->u.bits.DeviceNumber = DeviceNumber;
1100  NextSlotNumber->u.bits.FunctionNumber = FunctionNumber + 1;
1101 
1102  /* Save the slot number */
1103  PortConfig->SlotNumber = SlotNumber.u.AsULONG;
1104 
1105  return TRUE;
1106  }
1107  NextSlotNumber->u.bits.FunctionNumber = 0;
1108  }
1109 
1110  NextSlotNumber->u.bits.DeviceNumber = 0;
1111 
1112  return FALSE;
1113 }
#define TRUE
Definition: types.h:120
static VOID SpiResourceToConfig(IN PHW_INITIALIZATION_DATA HwInitializationData, IN PCM_FULL_RESOURCE_DESCRIPTOR ResourceDescriptor, IN OUT PPORT_CONFIGURATION_INFORMATION PortConfig)
Definition: scsiport.c:936
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
#define TRACE(s)
Definition: solgame.cpp:4
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3245
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_MAX_DEVICES
Definition: iotypes.h:3242
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
Status
Definition: gdiplustypes.h:24
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3243
unsigned int ULONG
Definition: retypes.h:1
NTHALAPI NTSTATUS NTAPI HalAssignSlotResources(PUNICODE_STRING, PUNICODE_STRING, PDRIVER_OBJECT, PDEVICE_OBJECT, INTERFACE_TYPE, ULONG, ULONG, PCM_RESOURCE_LIST *)
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:664

Referenced by ScsiPortInitialize().

◆ SpiResourceToConfig()

static VOID SpiResourceToConfig ( IN PHW_INITIALIZATION_DATA  HwInitializationData,
IN PCM_FULL_RESOURCE_DESCRIPTOR  ResourceDescriptor,
IN OUT PPORT_CONFIGURATION_INFORMATION  PortConfig 
)
static

Definition at line 936 of file scsiport.c.

940 {
941  PACCESS_RANGE AccessRange;
943  ULONG RangeNumber;
944  ULONG Index;
945 
946  RangeNumber = 0;
947 
948  /* Loop through all entries */
949  for (Index = 0; Index < ResourceDescriptor->PartialResourceList.Count; Index++)
950  {
951  PartialData = &ResourceDescriptor->PartialResourceList.PartialDescriptors[Index];
952 
953  switch (PartialData->Type)
954  {
955  case CmResourceTypePort:
956  /* Copy access ranges */
957  if (RangeNumber < HwInitializationData->NumberOfAccessRanges)
958  {
959  TRACE("Got port at 0x%I64x, len 0x%x\n",
960  PartialData->u.Port.Start.QuadPart, PartialData->u.Port.Length);
961  AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]);
962 
963  AccessRange->RangeStart = PartialData->u.Port.Start;
964  AccessRange->RangeLength = PartialData->u.Port.Length;
965 
966  AccessRange->RangeInMemory = FALSE;
967  RangeNumber++;
968  }
969  break;
970 
972  /* Copy access ranges */
973  if (RangeNumber < HwInitializationData->NumberOfAccessRanges)
974  {
975  TRACE("Got memory at 0x%I64x, len 0x%x\n",
976  PartialData->u.Memory.Start.QuadPart, PartialData->u.Memory.Length);
977  AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]);
978 
979  AccessRange->RangeStart = PartialData->u.Memory.Start;
980  AccessRange->RangeLength = PartialData->u.Memory.Length;
981 
982  AccessRange->RangeInMemory = TRUE;
983  RangeNumber++;
984  }
985  break;
986 
988  /* Copy interrupt data */
989  TRACE("Got interrupt level %d, vector %d\n",
990  PartialData->u.Interrupt.Level, PartialData->u.Interrupt.Vector);
991  PortConfig->BusInterruptLevel = PartialData->u.Interrupt.Level;
992  PortConfig->BusInterruptVector = PartialData->u.Interrupt.Vector;
993 
994  /* Set interrupt mode accordingly to the resource */
995  if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LATCHED)
996  {
997  PortConfig->InterruptMode = Latched;
998  }
999  else if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE)
1000  {
1001  PortConfig->InterruptMode = LevelSensitive;
1002  }
1003  break;
1004 
1005  case CmResourceTypeDma:
1006  TRACE("Got DMA channel %d, port %d\n",
1007  PartialData->u.Dma.Channel, PartialData->u.Dma.Port);
1008  PortConfig->DmaChannel = PartialData->u.Dma.Channel;
1009  PortConfig->DmaPort = PartialData->u.Dma.Port;
1010  break;
1011  }
1012  }
1013 }
#define TRUE
Definition: types.h:120
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@374 Interrupt
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@376 Memory
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@373 Port
#define TRACE(s)
Definition: solgame.cpp:4
static const UCHAR Index[8]
Definition: usbohci.c:18
SCSI_PHYSICAL_ADDRESS RangeStart
Definition: srb.h:41
BOOLEAN RangeInMemory
Definition: srb.h:43
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@377 Dma
ULONG RangeLength
Definition: srb.h:42
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by SpiGetPciConfigData().

◆ SpiScanAdapter()

static VOID SpiScanAdapter ( IN PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  ScsiBus,
IN UCHAR  PathId 
)
static

Definition at line 861 of file scsiport.c.

865 {
866  CHAR ArcName[64];
868  PCDB Cdb;
869  INQUIRYDATA InquiryBuffer;
870  UCHAR TargetId;
871  UCHAR Lun;
872 
873  if (!DeviceExtension->HwResetBus(DeviceExtension->MiniPortDeviceExtension, PathId))
874  {
875  return;
876  }
877 
878  /* Remember the extension */
879  ScsiDeviceExtensions[ScsiBus] = DeviceExtension;
880 
881  for (TargetId = 0; TargetId < DeviceExtension->MaxTargedIds; TargetId++)
882  {
883  Lun = 0;
884  do
885  {
886  TRACE("Scanning SCSI device %d.%d.%d\n",
887  ScsiBus, TargetId, Lun);
888 
890  if (!Srb)
891  break;
893  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
894  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
895  Srb->PathId = PathId;
896  Srb->TargetId = TargetId;
897  Srb->Lun = Lun;
898  Srb->CdbLength = 6;
899  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
900  Srb->DataTransferLength = INQUIRYDATABUFFERSIZE;
901  Srb->TimeOutValue = 5; /* in seconds */
902  Srb->DataBuffer = &InquiryBuffer;
903  Cdb = (PCDB)Srb->Cdb;
904  Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY;
905  Cdb->CDB6INQUIRY.LogicalUnitNumber = Srb->Lun;
906  Cdb->CDB6INQUIRY.AllocationLength = (UCHAR)Srb->DataTransferLength;
907  if (!SpiSendSynchronousSrb(DeviceExtension, Srb))
908  {
909  /* Don't check next LUNs */
910  break;
911  }
912 
913  /* Device exists, create its ARC name */
914  if (InquiryBuffer.RemovableMedia)
915  {
916  sprintf(ArcName, "scsi(%ld)cdrom(%d)fdisk(%d)",
917  ScsiBus, TargetId, Lun);
918  FsRegisterDevice(ArcName, &DiskVtbl);
919  }
920  else
921  {
922  sprintf(ArcName, "scsi(%ld)disk(%d)rdisk(%d)",
923  ScsiBus, TargetId, Lun);
924  /* Now, check if it has partitions */
925  SpiScanDevice(DeviceExtension, ArcName, PathId, TargetId, Lun);
926  }
927 
928  /* Check next LUN */
929  Lun++;
930  } while (Lun < SCSI_MAXIMUM_LOGICAL_UNITS);
931  }
932 }
PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]
Definition: scsiport.c:109
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1117
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1117
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1117
#define SCSI_MAXIMUM_LOGICAL_UNITS
Definition: srb.h:21
char CHAR
Definition: xmlstorage.h:175
Definition: cdrw_hw.h:28
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
#define sprintf(buf, format,...)
Definition: sprintf.c:55
UCHAR RemovableMedia
Definition: cdrw_hw.h:1119
#define INQUIRYDATABUFFERSIZE
Definition: cdrw_hw.h:1113
union _CDB * PCDB
#define SCSIOP_INQUIRY
Definition: cdrw_hw.h:888
#define TRACE(s)
Definition: solgame.cpp:4
static const DEVVTBL DiskVtbl
Definition: scsiport.c:404
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:383
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static BOOLEAN SpiSendSynchronousSrb(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: scsiport.c:130
struct _CDB::_CDB6INQUIRY CDB6INQUIRY
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
static VOID SpiScanDevice(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN PCHAR ArcName, IN ULONG ScsiBus, IN ULONG TargetId, IN ULONG Lun)
Definition: scsiport.c:817

Referenced by ScsiPortInitialize().

◆ SpiScanDevice()

static VOID SpiScanDevice ( IN PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
IN PCHAR  ArcName,
IN ULONG  ScsiBus,
IN ULONG  TargetId,
IN ULONG  Lun 
)
static

Definition at line 817 of file scsiport.c.

823 {
824  ULONG FileId, i;
826  NTSTATUS ret;
828  CHAR PartitionName[64];
829 
830  /* Register device with partition(0) suffix */
831  RtlStringCbPrintfA(PartitionName, sizeof(PartitionName), "%spartition(0)", ArcName);
832  FsRegisterDevice(PartitionName, &DiskVtbl);
833 
834  /* Read device partition table */
835  Status = ArcOpen(PartitionName, OpenReadOnly, &FileId);
836  if (Status == ESUCCESS)
837  {
838  ret = HALDISPATCH->HalIoReadPartitionTable((PDEVICE_OBJECT)FileId, 512, FALSE, &PartitionBuffer);
839  if (NT_SUCCESS(ret))
840  {
841  for (i = 0; i < PartitionBuffer->PartitionCount; i++)
842  {
843  if (PartitionBuffer->PartitionEntry[i].PartitionType != PARTITION_ENTRY_UNUSED)
844  {
845  RtlStringCbPrintfA(PartitionName,
846  sizeof(PartitionName),
847  "%spartition(%lu)",
848  ArcName,
849  PartitionBuffer->PartitionEntry[i].PartitionNumber);
850  FsRegisterDevice(PartitionName, &DiskVtbl);
851  }
852  }
854  }
855  ArcClose(FileId);
856  }
857 }
Definition: arc.h:32
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
ULONG ARC_STATUS
Definition: arc.h:4
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ BOOLEAN _Out_ struct _DRIVE_LAYOUT_INFORMATION ** PartitionBuffer
Definition: iofuncs.h:2048
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const DEVVTBL DiskVtbl
Definition: scsiport.c:404
int ret
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:383
Status
Definition: gdiplustypes.h:24
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
unsigned int ULONG
Definition: retypes.h:1
#define HALDISPATCH
Definition: haltypes.h:278
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by SpiScanAdapter().

◆ SpiSendSynchronousSrb()

static BOOLEAN SpiSendSynchronousSrb ( IN PSCSI_PORT_DEVICE_EXTENSION  DeviceExtension,
IN PSCSI_REQUEST_BLOCK  Srb 
)
static

Definition at line 130 of file scsiport.c.

133 {
134  BOOLEAN ret;
135 
136  ASSERT(!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE));
137 
138  /* HACK: handle lack of interrupts */
139  while (!(DeviceExtension->InterruptFlags & SCSI_PORT_NEXT_REQUEST_READY))
140  {
141  KeStallExecutionProcessor(100 * 1000);
142  DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension);
143  }
144 
145  DeviceExtension->InterruptFlags &= ~SCSI_PORT_NEXT_REQUEST_READY;
146  Srb->SrbFlags |= SRB_FLAGS_IS_ACTIVE;
147 
148  if (!DeviceExtension->HwStartIo(
149  DeviceExtension->MiniPortDeviceExtension,
150  Srb))
151  {
152  ExFreePool(Srb);
153  return FALSE;
154  }
155 
156  /* HACK: handle lack of interrupts */
157  while (Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE)
158  {
159  KeStallExecutionProcessor(100 * 1000);
160  DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension);
161  }
162 
163  ret = SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS;
164  ExFreePool(Srb);
165 
166  return ret;
167 }
#define SRB_FLAGS_IS_ACTIVE
Definition: srb.h:399
#define SRB_STATUS(Status)
Definition: srb.h:381
#define SCSI_PORT_NEXT_REQUEST_READY
Definition: scsiport.c:54
unsigned char BOOLEAN
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by DiskOpen(), DiskRead(), and SpiScanAdapter().

Variable Documentation

◆ __ImageBase

char __ImageBase

Definition at line 17 of file mstscax.cpp.

Referenced by LoadBootDeviceDriver().

◆ DiskVtbl

const DEVVTBL DiskVtbl
static
Initial value:
=
{
}
static ARC_STATUS DiskGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: scsiport.c:176
static ARC_STATUS DiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: scsiport.c:265
static ARC_STATUS DiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: scsiport.c:195
static ARC_STATUS DiskClose(ULONG FileId)
Definition: scsiport.c:169
static ARC_STATUS DiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: scsiport.c:375

Definition at line 404 of file scsiport.c.

Referenced by SpiScanAdapter(), and SpiScanDevice().

◆ ScsiDeviceExtensions

Definition at line 109 of file scsiport.c.

Referenced by DiskOpen(), and SpiScanAdapter().