ReactOS  0.4.13-dev-249-gcba1a2f
scsiport.c File Reference
#include <freeldr.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 <debug.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 13 of file scsiport.c.

◆ SCSI_PORT_NEXT_REQUEST_READY

#define SCSI_PORT_NEXT_REQUEST_READY   0x0008

Definition at line 53 of file scsiport.c.

◆ TAG_SCSI_ACCESS_RANGES

#define TAG_SCSI_ACCESS_RANGES   'AscS'

Definition at line 56 of file scsiport.c.

◆ TAG_SCSI_DEVEXT

#define TAG_SCSI_DEVEXT   'DscS'

Definition at line 55 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 170 of file scsiport.c.

171 {
173 
175  return ESUCCESS;
176 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:474
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ DiskGetFileInformation()

static ARC_STATUS DiskGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 178 of file scsiport.c.

179 {
181 
183  Information->EndingAddress.QuadPart = Context->SectorCount * Context->SectorSize;
184  Information->CurrentAddress.QuadPart = Context->SectorNumber * Context->SectorSize;
185 
186  return ESUCCESS;
187 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:474
#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 189 of file scsiport.c.

190 {
192  PCDB Cdb;
193  READ_CAPACITY_DATA ReadCapacityBuffer;
194 
196  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
197  ULONG ScsiBus, PathId, TargetId, Lun, Partition, PathSyntax;
201 
202  /* Parse ARC path */
203  if (!DissectArcPath2(Path, &ScsiBus, &TargetId, &Lun, &Partition, &PathSyntax))
204  return EINVAL;
205  if (PathSyntax != 0) /* scsi() format */
206  return EINVAL;
207  DeviceExtension = ScsiDeviceExtensions[ScsiBus];
208  PathId = ScsiBus - DeviceExtension->BusNum;
209 
210  /* Get disk capacity and sector size */
212  if (!Srb)
213  return ENOMEM;
215  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
216  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
217  Srb->PathId = (UCHAR)PathId;
218  Srb->TargetId = (UCHAR)TargetId;
219  Srb->Lun = (UCHAR)Lun;
220  Srb->CdbLength = 10;
221  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
222  Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA);
223  Srb->TimeOutValue = 5; /* in seconds */
224  Srb->DataBuffer = &ReadCapacityBuffer;
225  Cdb = (PCDB)Srb->Cdb;
226  Cdb->CDB10.OperationCode = SCSIOP_READ_CAPACITY;
227  if (!SpiSendSynchronousSrb(DeviceExtension, Srb))
228  {
229  return EIO;
230  }
231 
232  /* Transform result to host endianness */
233  SectorCount = ntohl(ReadCapacityBuffer.LogicalBlockAddress);
234  SectorSize = ntohl(ReadCapacityBuffer.BytesPerBlock);
235 
236  if (Partition != 0)
237  {
238  /* Need to offset start of disk and length */
240  return EIO;
241  }
242 
244  if (!Context)
245  return ENOMEM;
246  Context->DeviceExtension = DeviceExtension;
247  Context->PathId = (UCHAR)PathId;
248  Context->TargetId = (UCHAR)TargetId;
249  Context->Lun = (UCHAR)Lun;
250  Context->SectorSize = SectorSize;
251  Context->SectorOffset = SectorOffset;
252  Context->SectorCount = SectorCount;
253  Context->SectorNumber = 0;
254  FsSetDeviceSpecific(*FileId, Context);
255 
256  return ESUCCESS;
257 }
PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]
Definition: scsiport.c:110
_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:115
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:467
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
BOOLEAN DissectArcPath2(IN CHAR *ArcPath, OUT ULONG *x, OUT ULONG *y, OUT ULONG *z, OUT ULONG *Partition, OUT ULONG *PathSyntax)
Definition: arcname.c:103
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:1012
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:131
_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 259 of file scsiport.c.

260 {
263  PCDB Cdb;
264  ULONG FullSectors, NbSectors;
265  ULONG Lba;
266 
267  *Count = 0;
268 
269  if (N == 0)
270  return ESUCCESS;
271 
272  FullSectors = N / Context->SectorSize;
273  NbSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
274  if (Context->SectorNumber + NbSectors >= Context->SectorCount)
275  return EINVAL;
276  if (FullSectors > 0xffff)
277  return EINVAL;
278 
279  /* Read full sectors */
280  ASSERT(Context->SectorNumber < 0xFFFFFFFF);
281  Lba = (ULONG)Context->SectorNumber;
282  if (FullSectors > 0)
283  {
285  if (!Srb)
286  return ENOMEM;
287 
289  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
290  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
291  Srb->PathId = Context->PathId;
292  Srb->TargetId = Context->TargetId;
293  Srb->Lun = Context->Lun;
294  Srb->CdbLength = 10;
295  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
296  Srb->DataTransferLength = FullSectors * Context->SectorSize;
297  Srb->TimeOutValue = 5; /* in seconds */
298  Srb->DataBuffer = Buffer;
299  Cdb = (PCDB)Srb->Cdb;
300  Cdb->CDB10.OperationCode = SCSIOP_READ;
301  Cdb->CDB10.LogicalUnitNumber = Srb->Lun;
302  Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff;
303  Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff;
304  Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff;
305  Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff;
306  Cdb->CDB10.TransferBlocksMsb = (FullSectors >> 8) & 0xff;
307  Cdb->CDB10.TransferBlocksLsb = FullSectors & 0xff;
308  if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb))
309  {
310  return EIO;
311  }
312  Buffer = (PUCHAR)Buffer + FullSectors * Context->SectorSize;
313  N -= FullSectors * Context->SectorSize;
314  *Count += FullSectors * Context->SectorSize;
315  Lba += FullSectors;
316  }
317 
318  /* Read incomplete last sector */
319  if (N > 0)
320  {
321  PUCHAR Sector;
322 
323  Sector = ExAllocatePool(PagedPool, Context->SectorSize);
324  if (!Sector)
325  return ENOMEM;
326 
328  if (!Srb)
329  {
330  ExFreePool(Sector);
331  return ENOMEM;
332  }
333 
335  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
336  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
337  Srb->PathId = Context->PathId;
338  Srb->TargetId = Context->TargetId;
339  Srb->Lun = Context->Lun;
340  Srb->CdbLength = 10;
341  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
342  Srb->DataTransferLength = Context->SectorSize;
343  Srb->TimeOutValue = 5; /* in seconds */
344  Srb->DataBuffer = Sector;
345  Cdb = (PCDB)Srb->Cdb;
346  Cdb->CDB10.OperationCode = SCSIOP_READ;
347  Cdb->CDB10.LogicalUnitNumber = Srb->Lun;
348  Cdb->CDB10.LogicalBlockByte0 = (Lba >> 24) & 0xff;
349  Cdb->CDB10.LogicalBlockByte1 = (Lba >> 16) & 0xff;
350  Cdb->CDB10.LogicalBlockByte2 = (Lba >> 8) & 0xff;
351  Cdb->CDB10.LogicalBlockByte3 = Lba & 0xff;
352  Cdb->CDB10.TransferBlocksMsb = 0;
353  Cdb->CDB10.TransferBlocksLsb = 1;
354  if (!SpiSendSynchronousSrb(Context->DeviceExtension, Srb))
355  {
356  ExFreePool(Sector);
357  return EIO;
358  }
359  RtlCopyMemory(Buffer, Sector, N);
360  *Count += N;
361  ExFreePool(Sector);
362  }
363 
364  return ESUCCESS;
365 }
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:474
Definition: arc.h:48
Definition: bidi.c:97
#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:131
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 367 of file scsiport.c.

368 {
370 
371  if (SeekMode != SeekAbsolute)
372  return EINVAL;
373  if (Position->QuadPart & (Context->SectorSize - 1))
374  return EINVAL;
375 
376  Context->SectorNumber = Position->QuadPart / Context->SectorSize;
377  return ESUCCESS;
378 }
Definition: arc.h:32
Definition: arc.h:39
static COORD Position
Definition: mouse.c:34
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:474

◆ LoadBootDeviceDriver()

ULONG LoadBootDeviceDriver ( VOID  )

Definition at line 1591 of file scsiport.c.

1592 {
1593  PIMAGE_NT_HEADERS NtHeaders;
1595  PIMAGE_IMPORT_DESCRIPTOR ImportTable;
1596  ULONG ImportTableSize;
1597  PLDR_DATA_TABLE_ENTRY BootDdDTE, FreeldrDTE;
1598  CHAR NtBootDdPath[MAX_PATH];
1599  PVOID ImageBase = NULL;
1600  ULONG (NTAPI *EntryPoint)(IN PVOID DriverObject, IN PVOID RegistryPath);
1601  BOOLEAN Success;
1602 
1603  // FIXME: Must be done *INSIDE* the HAL!
1604 #ifdef _M_IX86
1607 #endif
1608 
1609  /* Initialize the loaded module list */
1611 
1612  /* Create full ntbootdd.sys path */
1613  MachDiskGetBootPath(NtBootDdPath, sizeof(NtBootDdPath));
1614  strcat(NtBootDdPath, "\\NTBOOTDD.SYS");
1615 
1616  /* Load file */
1617  Success = WinLdrLoadImage(NtBootDdPath, LoaderBootDriver, &ImageBase);
1618  if (!Success)
1619  {
1620  /* That's OK. File simply doesn't exist */
1621  return ESUCCESS;
1622  }
1623 
1624  /* Allocate a DTE for ntbootdd */
1626  "NTBOOTDD.SYS", ImageBase, &BootDdDTE);
1627  if (!Success)
1628  return EIO;
1629 
1630  /* Add the PE part of freeldr.sys to the list of loaded executables, it
1631  contains Scsiport* exports, imported by ntbootdd.sys */
1633  "FREELDR.SYS", &__ImageBase, &FreeldrDTE);
1634  if (!Success)
1635  {
1636  RemoveEntryList(&BootDdDTE->InLoadOrderLinks);
1637  return EIO;
1638  }
1639 
1640  /* Fix imports */
1642 
1643  /* Now unlinkt the DTEs, they won't be valid later */
1644  RemoveEntryList(&BootDdDTE->InLoadOrderLinks);
1645  RemoveEntryList(&FreeldrDTE->InLoadOrderLinks);
1646 
1647  if (!Success)
1648  return EIO;
1649 
1650  /* Change imports to PA */
1652  TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ImportTableSize);
1653  for (;(ImportTable->Name != 0) && (ImportTable->FirstThunk != 0);ImportTable++)
1654  {
1655  PIMAGE_THUNK_DATA ThunkData = (PIMAGE_THUNK_DATA)VaToPa(RVA(BootDdDTE->DllBase, ImportTable->FirstThunk));
1656 
1657  while (((PIMAGE_THUNK_DATA)ThunkData)->u1.AddressOfData != 0)
1658  {
1659  ThunkData->u1.Function = (ULONG)VaToPa((PVOID)ThunkData->u1.Function);
1660  ThunkData++;
1661  }
1662  }
1663 
1664  /* Relocate image to PA */
1665  NtHeaders = RtlImageNtHeader(VaToPa(BootDdDTE->DllBase));
1666  if (!NtHeaders)
1667  return EIO;
1669  NtHeaders->OptionalHeader.ImageBase - (ULONG_PTR)BootDdDTE->DllBase,
1670  "FreeLdr",
1671  TRUE,
1672  TRUE, /* in case of conflict still return success */
1673  FALSE);
1674  if (!Success)
1675  return EIO;
1676 
1677  /* Call the entrypoint */
1678  EntryPoint = VaToPa(BootDdDTE->EntryPoint);
1679  (*EntryPoint)(NULL, NULL);
1680 
1681  return ESUCCESS;
1682 }
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
VOID NTAPI HalpInitBusHandler(VOID)
Definition: bushndlr.c:420
BOOLEAN WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BasePA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
Definition: peloader.c:172
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:1818
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
BOOLEAN WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:101
#define RtlImageDirectoryEntryToData
Definition: compat.h:460
Definition: btrfs_drv.h:1814
Definition: typedefs.h:117
LIST_ENTRY InLoadOrderLinks
Definition: ldrtypes.h:137
#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
#define MachDiskGetBootPath(Path, Size)
Definition: machine.h:118
BOOLEAN WinLdrLoadImage(IN PCHAR FileName, TYPE_OF_MEMORY MemoryType, OUT PVOID *ImageBasePA)
Definition: peloader.c:268
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
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
LIST_ENTRY * ModuleListHead
Definition: kdpacket.c:23
PIMAGE_THUNK_DATA32 PIMAGE_THUNK_DATA
Definition: ntimage.h:566
union _IMAGE_THUNK_DATA32::@2046 u1

Referenced by RunLoader().

◆ ntohl()

ULONG ntohl ( IN ULONG  Value)

Definition at line 115 of file scsiport.c.

117 {
118  FOUR_BYTE Dest;
120 
121  Dest.Byte0 = Source->Byte3;
122  Dest.Byte1 = Source->Byte2;
123  Dest.Byte2 = Source->Byte1;
124  Dest.Byte3 = Source->Byte0;
125 
126  return Dest.AsULong;
127 }
UCHAR Byte0
Definition: tools.h:16
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 437 of file scsiport.c.

441 {
442  va_list ap;
443  CHAR Buffer[512];
444  ULONG Length;
445 
446  if (DebugPrintLevel > 10)
447  return;
448 
449  va_start(ap, DebugMessage);
450 
451  /* Construct a string */
452  Length = _vsnprintf(Buffer, 512, DebugMessage, ap);
453 
454  /* Check if we went past the buffer */
455  if (Length == MAXULONG)
456  {
457  /* Terminate it if we went over-board */
458  Buffer[sizeof(Buffer) - 1] = '\0';
459 
460  /* Put maximum */
461  Length = sizeof(Buffer);
462  }
463 
464  /* Print the message */
465  TRACE("%s", Buffer);
466 
467  /* Cleanup */
468  va_end(ap);
469 }
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 473 of file scsiport.c.

479 {
480  // FIXME
482 }
#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 487 of file scsiport.c.

489 {
490  return Address.LowPart;
491 }
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 506 of file scsiport.c.

508 {
509  // FIXME
511 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortFreeDeviceBase()

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

Definition at line 515 of file scsiport.c.

518 {
519  // Nothing to do
520 }

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 524 of file scsiport.c.

531 {
532  return HalGetBusDataByOffset(BusDataType, SystemIoBusNumber, SlotNumber, Buffer, 0, Length);
533 }
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 537 of file scsiport.c.

544 {
547 
548  AddressSpace = (ULONG)InIoSpace;
550  SystemIoBusNumber,
551  IoAddress,
552  &AddressSpace,
554  {
555  return NULL;
556  }
557 
558  /* I/O space */
559  if (AddressSpace != 0)
560  return (PVOID)TranslatedAddress.u.LowPart;
561 
562  // FIXME
564  return (PVOID)IoAddress.LowPart;
565 }
_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
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
struct _LARGE_INTEGER::@2192 u
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 569 of file scsiport.c.

574 {
575  // FIXME
577  return NULL;
578 }
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 582 of file scsiport.c.

587 {
588  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
590  ULONG BufferLength = 0;
591  ULONG Offset;
592 
593  TRACE("ScsiPortGetPhysicalAddress(%p %p %p %p)\n",
594  HwDeviceExtension, Srb, VirtualAddress, Length);
595 
596  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
597 
598  if (Srb == NULL || Srb->SenseInfoBuffer == VirtualAddress)
599  {
600  /* Simply look it up in the allocated common buffer */
601  Offset = (PUCHAR)VirtualAddress - (PUCHAR)DeviceExtension->SrbExtensionBuffer;
602 
603  BufferLength = DeviceExtension->CommonBufferLength - Offset;
605  }
606  else
607  {
608  /* Nothing */
610  }
611 
612  *Length = BufferLength;
613  return PhysicalAddress;
614 }
#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:1060
_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 618 of file scsiport.c.

624 {
625  // FIXME
627  return NULL;
628 }
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 696 of file scsiport.c.

700 {
701  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
703  ULONG MapRegistersCount;
705 
706  TRACE("ScsiPortGetUncachedExtension(%p %p %lu)\n",
707  HwDeviceExtension, ConfigInfo, NumberOfBytes);
708 
709  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
710 
711  /* Check for allocated common DMA buffer */
712  if (DeviceExtension->SrbExtensionBuffer != NULL)
713  {
714  return NULL;
715  }
716 
717  /* Check for DMA adapter object */
718  if (DeviceExtension->AdapterObject == NULL)
719  {
720  /* Initialize DMA adapter description */
722 
724  DeviceDescription.Master = ConfigInfo->Master;
725  DeviceDescription.ScatterGather = ConfigInfo->ScatterGather;
726  DeviceDescription.DemandMode = ConfigInfo->DemandMode;
727  DeviceDescription.Dma32BitAddresses = ConfigInfo->Dma32BitAddresses;
728  DeviceDescription.BusNumber = ConfigInfo->SystemIoBusNumber;
729  DeviceDescription.DmaChannel = ConfigInfo->DmaChannel;
730  DeviceDescription.InterfaceType = ConfigInfo->AdapterInterfaceType;
731  DeviceDescription.DmaWidth = ConfigInfo->DmaWidth;
732  DeviceDescription.DmaSpeed = ConfigInfo->DmaSpeed;
733  DeviceDescription.MaximumLength = ConfigInfo->MaximumTransferLength;
734  DeviceDescription.DmaPort = ConfigInfo->DmaPort;
735 
736  /* Get a DMA adapter object */
737 #if 0
738  DeviceExtension->AdapterObject =
739  HalGetAdapter(&DeviceDescription, &MapRegistersCount);
740 
741  /* Fail in case of error */
742  if (DeviceExtension->AdapterObject == NULL)
743  {
744  return NULL;
745  }
746 #else
747  MapRegistersCount = 0;
748 #endif
749 
750  /* Set number of physical breaks */
751  if (ConfigInfo->NumberOfPhysicalBreaks != 0 &&
752  MapRegistersCount > ConfigInfo->NumberOfPhysicalBreaks)
753  {
754  DeviceExtension->PortCapabilities.MaximumPhysicalPages =
755  ConfigInfo->NumberOfPhysicalBreaks;
756  }
757  else
758  {
759  DeviceExtension->PortCapabilities.MaximumPhysicalPages = MapRegistersCount;
760  }
761  }
762 
763  /* Update Srb extension size */
764  if (DeviceExtension->SrbExtensionSize != ConfigInfo->SrbExtensionSize)
765  DeviceExtension->SrbExtensionSize = ConfigInfo->SrbExtensionSize;
766 
767  /* Allocate a common DMA buffer */
768  Status = SpiAllocateCommonBuffer(DeviceExtension, NumberOfBytes);
769 
770  if (!NT_SUCCESS(Status))
771  {
772  TRACE("SpiAllocateCommonBuffer() failed with Status = 0x%08X!\n", Status);
773  return NULL;
774  }
775 
776  return DeviceExtension->NonCachedExtension;
777 }
IO_SCSI_CAPABILITIES PortCapabilities
Definition: scsiport.c:80
struct SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
DMA_SPEED DmaSpeed
Definition: iotypes.h:2037
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2019
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2029
_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:2027
BOOLEAN ScatterGather
Definition: iotypes.h:2026
DMA_WIDTH DmaWidth
Definition: iotypes.h:2036
Status
Definition: gdiplustypes.h:24
PADAPTER_OBJECT AdapterObject
Definition: scsiport.c:88
static NTSTATUS SpiAllocateCommonBuffer(IN OUT PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, IN ULONG NonCachedSize)
Definition: scsiport.c:632
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2035
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:997
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 781 of file scsiport.c.

784 {
785  // FIXME
787  return NULL;
788 }
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 1089 of file scsiport.c.

1094 {
1095  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
1096  ULONG DeviceExtensionSize;
1097  PORT_CONFIGURATION_INFORMATION PortConfig;
1098  BOOLEAN Again;
1099  BOOLEAN FirstConfigCall = TRUE;
1101  UCHAR ScsiBus;
1102  NTSTATUS Status;
1103 
1104  if (HwInitializationData->HwInitializationDataSize != sizeof(HW_INITIALIZATION_DATA))
1105  {
1106  return STATUS_INVALID_PARAMETER;
1107  }
1108 
1109  /* Check params for validity */
1110  if ((HwInitializationData->HwInitialize == NULL) ||
1111  (HwInitializationData->HwStartIo == NULL) ||
1112  (HwInitializationData->HwInterrupt == NULL) ||
1113  (HwInitializationData->HwFindAdapter == NULL) ||
1114  (HwInitializationData->HwResetBus == NULL))
1115  {
1116  return STATUS_INVALID_PARAMETER;
1117  }
1118 
1119  /* Zero starting slot number */
1120  SlotNumber.u.AsULONG = 0;
1121 
1122  while (TRUE)
1123  {
1124  Again = FALSE;
1125 
1126  DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize;
1127  DeviceExtension = FrLdrTempAlloc(DeviceExtensionSize, TAG_SCSI_DEVEXT);
1128  if (!DeviceExtension)
1129  {
1130  return STATUS_NO_MEMORY;
1131  }
1132  RtlZeroMemory(DeviceExtension, DeviceExtensionSize);
1133  DeviceExtension->InterruptFlags = SCSI_PORT_NEXT_REQUEST_READY;
1134  DeviceExtension->HwInitialize = HwInitializationData->HwInitialize;
1135  DeviceExtension->HwStartIo = HwInitializationData->HwStartIo;
1136  DeviceExtension->HwInterrupt = HwInitializationData->HwInterrupt;
1137  DeviceExtension->HwResetBus = HwInitializationData->HwResetBus;
1138  DeviceExtension->MiniPortDeviceExtension = (PVOID)(DeviceExtension + 1);
1139 
1140  Status = SpiCreatePortConfig(DeviceExtension,
1142  &PortConfig,
1143  FirstConfigCall);
1144  if (Status != STATUS_SUCCESS)
1145  {
1146  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1147  return Status;
1148  }
1149 
1150  PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges;
1151  PortConfig.AccessRanges = FrLdrTempAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges,
1153  if (!PortConfig.AccessRanges)
1154  {
1155  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1156  return STATUS_NO_MEMORY;
1157  }
1158  RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges);
1159 
1160  /* Search for matching PCI device */
1161  if ((HwInitializationData->AdapterInterfaceType == PCIBus) &&
1162  (HwInitializationData->VendorIdLength > 0) &&
1163  (HwInitializationData->VendorId != NULL) &&
1164  (HwInitializationData->DeviceIdLength > 0) &&
1165  (HwInitializationData->DeviceId != NULL))
1166  {
1167  PortConfig.BusInterruptLevel = 0;
1168 
1169  /* Get PCI device data */
1170  TRACE("VendorId '%.*s' DeviceId '%.*s'\n",
1171  HwInitializationData->VendorIdLength,
1172  HwInitializationData->VendorId,
1173  HwInitializationData->DeviceIdLength,
1174  HwInitializationData->DeviceId);
1175 
1177  &PortConfig,
1178  0, /* FIXME */
1179  &SlotNumber))
1180  {
1181  /* Continue to the next bus, nothing here */
1182  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1183  return STATUS_INTERNAL_ERROR;
1184  }
1185 
1186  if (!PortConfig.BusInterruptLevel)
1187  {
1188  /* Bypass this slot, because no interrupt was assigned */
1189  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1190  return STATUS_INTERNAL_ERROR;
1191  }
1192  }
1193 
1194  if (HwInitializationData->HwFindAdapter(
1195  DeviceExtension->MiniPortDeviceExtension,
1196  HwContext,
1197  NULL,
1198  NULL,
1199  &PortConfig,
1200  &Again) != SP_RETURN_FOUND)
1201  {
1202  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1203  return STATUS_INTERNAL_ERROR;
1204  }
1205 
1206  /* Copy all stuff which we ever need from PortConfig to the DeviceExtension */
1208  DeviceExtension->MaxTargedIds = SCSI_MAXIMUM_TARGETS_PER_BUS;
1209  else
1210  DeviceExtension->MaxTargedIds = PortConfig.MaximumNumberOfTargets;
1211 
1212  DeviceExtension->BusNum = PortConfig.SystemIoBusNumber;
1213 
1214  TRACE("Adapter found: buses = %d, targets = %d\n",
1215  PortConfig.NumberOfBuses, DeviceExtension->MaxTargedIds);
1216 
1217  /* Initialize adapter */
1218  if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension))
1219  {
1220  FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
1221  return STATUS_INTERNAL_ERROR;
1222  }
1223 
1224  /* Scan bus */
1225  for (ScsiBus = 0; ScsiBus < PortConfig.NumberOfBuses; ScsiBus++)
1226  {
1227  SpiScanAdapter(DeviceExtension, PortConfig.SystemIoBusNumber, ScsiBus);
1228  PortConfig.SystemIoBusNumber++;
1229  }
1230 
1231  FirstConfigCall = FALSE;
1232  if (!Again)
1233  {
1234  break;
1235  }
1236  }
1237 
1238  return STATUS_SUCCESS;
1239 }
#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:390
#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:989
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:53
PHW_INITIALIZE HwInitialize
Definition: scsiport.c:82
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:56
#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:833
Status
Definition: gdiplustypes.h:24
PHW_RESET_BUS HwResetBus
Definition: scsiport.c:85
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
PHW_INTERRUPT HwInterrupt
Definition: scsiport.c:84
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define TAG_SCSI_DEVEXT
Definition: scsiport.c:55
_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 1243 of file scsiport.c.

1248 {
1249  // FIXME
1250  UNIMPLEMENTED;
1251 }
#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 1255 of file scsiport.c.

1263 {
1264  // FIXME
1265  UNIMPLEMENTED;
1266 }
#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 1270 of file scsiport.c.

1274 {
1276 }
#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 1280 of file scsiport.c.

1284 {
1285  PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
1287  va_list ap;
1288 
1289  DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
1290 
1291  va_start(ap, HwDeviceExtension);
1292 
1293  switch (NotificationType)
1294  {
1295  case RequestComplete:
1296  /* Mask the SRB as completed */
1298  Srb->SrbFlags &= ~SRB_FLAGS_IS_ACTIVE;
1299  break;
1300 
1301  case NextRequest:
1302  /* Say that device is ready */
1303  DeviceExtension->InterruptFlags |= SCSI_PORT_NEXT_REQUEST_READY;
1304  break;
1305 
1306  default:
1307  // FIXME
1308  UNIMPLEMENTED;
1309  }
1310 
1311  va_end(ap);
1312 }
#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:53
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 1316 of file scsiport.c.

1320 {
1322 }
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 1326 of file scsiport.c.

1330 {
1332 }
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 1336 of file scsiport.c.

1340 {
1342 }
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 1346 of file scsiport.c.

1348 {
1349  TRACE("ScsiPortReadPortUchar(%p)\n", Port);
1350 
1351  return READ_PORT_UCHAR(Port);
1352 }
CPPORT Port[4]
Definition: headless.c:34
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
#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 1356 of file scsiport.c.

1358 {
1359  return READ_PORT_ULONG(Port);
1360 }
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 1364 of file scsiport.c.

1366 {
1367  return READ_PORT_USHORT(Port);
1368 }
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 1372 of file scsiport.c.

1376 {
1377  // FIXME
1378  UNIMPLEMENTED;
1379 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterBufferUlong()

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

Definition at line 1383 of file scsiport.c.

1387 {
1388  // FIXME
1389  UNIMPLEMENTED;
1390 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterBufferUshort()

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

Definition at line 1394 of file scsiport.c.

1398 {
1399  // FIXME
1400  UNIMPLEMENTED;
1401 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortReadRegisterUchar()

UCHAR NTAPI ScsiPortReadRegisterUchar ( IN PUCHAR  Register)

Definition at line 1405 of file scsiport.c.

1407 {
1408  return READ_REGISTER_UCHAR(Register);
1409 }
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)

◆ ScsiPortReadRegisterUlong()

ULONG NTAPI ScsiPortReadRegisterUlong ( IN PULONG  Register)

Definition at line 1413 of file scsiport.c.

1415 {
1416  return READ_REGISTER_ULONG(Register);
1417 }
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)

◆ ScsiPortReadRegisterUshort()

USHORT NTAPI ScsiPortReadRegisterUshort ( IN PUSHORT  Register)

Definition at line 1421 of file scsiport.c.

1423 {
1424  return READ_REGISTER_USHORT(Register);
1425 }
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 1429 of file scsiport.c.

1437 {
1438  // FIXME
1439  UNIMPLEMENTED;
1440  return 0;
1441 }
#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 1453 of file scsiport.c.

1460 {
1461  // FIXME
1462  UNIMPLEMENTED;
1463  return TRUE;
1464 }
#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 1473 of file scsiport.c.

1477 {
1479 }
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 1483 of file scsiport.c.

1487 {
1489 }
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 1493 of file scsiport.c.

1497 {
1499 }
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 1512 of file scsiport.c.

1515 {
1517 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 1521 of file scsiport.c.

1524 {
1526 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 1530 of file scsiport.c.

1534 {
1535  // FIXME
1536  UNIMPLEMENTED;
1537 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterBufferUlong()

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

Definition at line 1541 of file scsiport.c.

1545 {
1546  // FIXME
1547  UNIMPLEMENTED;
1548 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterBufferUshort()

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

Definition at line 1552 of file scsiport.c.

1556 {
1557  // FIXME
1558  UNIMPLEMENTED;
1559 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ ScsiPortWriteRegisterUchar()

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

Definition at line 1563 of file scsiport.c.

1566 {
1567  WRITE_REGISTER_UCHAR(Register, Value);
1568 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 1572 of file scsiport.c.

1575 {
1576  WRITE_REGISTER_ULONG(Register, Value);
1577 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 1581 of file scsiport.c.

1584 {
1585  WRITE_REGISTER_USHORT(Register, Value);
1586 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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 632 of file scsiport.c.

635 {
636  PVOID CommonBuffer;
637  ULONG CommonBufferLength, BufSize;
638 
639  /* If size is 0, set it to 16 */
640  if (!DeviceExtension->SrbExtensionSize)
641  DeviceExtension->SrbExtensionSize = 16;
642 
643  /* Calculate size */
644  BufSize = DeviceExtension->SrbExtensionSize;
645 
646  /* Round it */
647  BufSize = (BufSize + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1);
648 
649  /* Sum up into the total common buffer length, and round it to page size */
650  CommonBufferLength =
651  ROUND_TO_PAGES(NonCachedSize);
652 
653  /* Allocate it */
654  if (!DeviceExtension->AdapterObject)
655  {
656  /* From nonpaged pool if there is no DMA */
657  CommonBuffer = ExAllocatePool(NonPagedPool, CommonBufferLength);
658  }
659  else
660  {
661  /* Perform a full request since we have a DMA adapter*/
663  CommonBuffer = NULL;
664  }
665 
666  /* Fail in case of error */
667  if (!CommonBuffer)
669 
670  /* Zero it */
671  RtlZeroMemory(CommonBuffer, CommonBufferLength);
672 
673  /* Store its size in Device Extension */
674  DeviceExtension->CommonBufferLength = CommonBufferLength;
675 
676  /* SrbExtension buffer is located at the beginning of the buffer */
677  DeviceExtension->SrbExtensionBuffer = CommonBuffer;
678 
679  /* Non-cached extension buffer is located at the end of
680  the common buffer */
681  if (NonCachedSize)
682  {
683  CommonBufferLength -= NonCachedSize;
684  DeviceExtension->NonCachedExtension = (PUCHAR)CommonBuffer + CommonBufferLength;
685  }
686  else
687  {
688  DeviceExtension->NonCachedExtension = NULL;
689  }
690 
691  return STATUS_SUCCESS;
692 }
#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:2745

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 390 of file scsiport.c.

395 {
396  ULONG Bus;
397 
398  /* Zero out the struct if told so */
399  if (ZeroStruct)
400  {
401  /* First zero the portconfig */
402  RtlZeroMemory(ConfigInfo, sizeof(PORT_CONFIGURATION_INFORMATION));
403 
404  /* Initialize the struct */
405  ConfigInfo->Length = sizeof(PORT_CONFIGURATION_INFORMATION);
406  ConfigInfo->AdapterInterfaceType = HwInitData->AdapterInterfaceType;
407  ConfigInfo->InterruptMode = Latched;
408  ConfigInfo->DmaChannel = SP_UNINITIALIZED_VALUE;
409  ConfigInfo->DmaPort = SP_UNINITIALIZED_VALUE;
410  ConfigInfo->MaximumTransferLength = SP_UNINITIALIZED_VALUE;
411  ConfigInfo->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS_PER_BUS;
412 
413  /* Store parameters */
414  ConfigInfo->NeedPhysicalAddresses = HwInitData->NeedPhysicalAddresses;
415  ConfigInfo->MapBuffers = HwInitData->MapBuffers;
416  ConfigInfo->AutoRequestSense = HwInitData->AutoRequestSense;
417  ConfigInfo->ReceiveEvent = HwInitData->ReceiveEvent;
418  ConfigInfo->TaggedQueuing = HwInitData->TaggedQueuing;
419  ConfigInfo->MultipleRequestPerLu = HwInitData->MultipleRequestPerLu;
420 
421  /* Get the disk usage */
422  ConfigInfo->AtdiskPrimaryClaimed = FALSE; // FIXME
423  ConfigInfo->AtdiskSecondaryClaimed = FALSE; // FIXME
424 
425  /* Initiator bus id is not set */
426  for (Bus = 0; Bus < 8; Bus++)
427  ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE;
428  }
429 
430  ConfigInfo->NumberOfPhysicalBreaks = 17;
431 
432  return STATUS_SUCCESS;
433 }
#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:2745

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 989 of file scsiport.c.

994 {
995  PCI_COMMON_CONFIG PciConfig;
997  ULONG DataSize;
999  ULONG FunctionNumber;
1000  CHAR VendorIdString[8];
1001  CHAR DeviceIdString[8];
1003  NTSTATUS Status;
1004 
1005  SlotNumber.u.AsULONG = 0;
1006 
1007  /* Loop through all devices */
1008  for (DeviceNumber = NextSlotNumber->u.bits.DeviceNumber; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
1009  {
1010  SlotNumber.u.bits.DeviceNumber = DeviceNumber;
1011 
1012  /* Loop through all functions */
1013  for (FunctionNumber = NextSlotNumber->u.bits.FunctionNumber; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
1014  {
1015  SlotNumber.u.bits.FunctionNumber = FunctionNumber;
1016 
1017  /* Get PCI config bytes */
1020  BusNumber,
1021  SlotNumber.u.AsULONG,
1022  &PciConfig,
1023  0,
1024  sizeof(ULONG));
1025 
1026  /* If result of HalGetBusData is 0, then the bus is wrong */
1027  if (DataSize == 0)
1028  return FALSE;
1029 
1030  /* If result is PCI_INVALID_VENDORID, then this device has no more
1031  "Functions" */
1032  if (PciConfig.VendorID == PCI_INVALID_VENDORID)
1033  break;
1034 
1035  sprintf(VendorIdString, "%04hx", PciConfig.VendorID);
1036  sprintf(DeviceIdString, "%04hx", PciConfig.DeviceID);
1037 
1038  if (_strnicmp(VendorIdString, HwInitializationData->VendorId, HwInitializationData->VendorIdLength) ||
1039  _strnicmp(DeviceIdString, HwInitializationData->DeviceId, HwInitializationData->DeviceIdLength))
1040  {
1041  /* It is not our device */
1042  continue;
1043  }
1044 
1045  TRACE( "Found device 0x%04hx 0x%04hx at %1lu %2lu %1lu\n",
1046  PciConfig.VendorID, PciConfig.DeviceID,
1047  BusNumber,
1048  SlotNumber.u.bits.DeviceNumber, SlotNumber.u.bits.FunctionNumber);
1049 
1051  NULL,
1052  NULL,
1053  NULL,
1054  PCIBus,
1055  BusNumber,
1056  SlotNumber.u.AsULONG,
1057  &ResourceList);
1058 
1059  if (!NT_SUCCESS(Status))
1060  break;
1061 
1062  /* Create configuration information */
1064  ResourceList->List,
1065  PortConfig);
1066 
1067  /* Free the resource list */
1069 
1070  /* Set dev & fn numbers */
1071  NextSlotNumber->u.bits.DeviceNumber = DeviceNumber;
1072  NextSlotNumber->u.bits.FunctionNumber = FunctionNumber + 1;
1073 
1074  /* Save the slot number */
1075  PortConfig->SlotNumber = SlotNumber.u.AsULONG;
1076 
1077  return TRUE;
1078  }
1079  NextSlotNumber->u.bits.FunctionNumber = 0;
1080  }
1081 
1082  NextSlotNumber->u.bits.DeviceNumber = 0;
1083 
1084  return FALSE;
1085 }
#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:908
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:3244
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_MAX_DEVICES
Definition: iotypes.h:3241
_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:3242
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 908 of file scsiport.c.

912 {
913  PACCESS_RANGE AccessRange;
915  ULONG RangeNumber;
916  ULONG Index;
917 
918  RangeNumber = 0;
919 
920  /* Loop through all entries */
921  for (Index = 0; Index < ResourceDescriptor->PartialResourceList.Count; Index++)
922  {
923  PartialData = &ResourceDescriptor->PartialResourceList.PartialDescriptors[Index];
924 
925  switch (PartialData->Type)
926  {
927  case CmResourceTypePort:
928  /* Copy access ranges */
929  if (RangeNumber < HwInitializationData->NumberOfAccessRanges)
930  {
931  TRACE("Got port at 0x%I64x, len 0x%x\n",
932  PartialData->u.Port.Start.QuadPart, PartialData->u.Port.Length);
933  AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]);
934 
935  AccessRange->RangeStart = PartialData->u.Port.Start;
936  AccessRange->RangeLength = PartialData->u.Port.Length;
937 
938  AccessRange->RangeInMemory = FALSE;
939  RangeNumber++;
940  }
941  break;
942 
944  /* Copy access ranges */
945  if (RangeNumber < HwInitializationData->NumberOfAccessRanges)
946  {
947  TRACE("Got memory at 0x%I64x, len 0x%x\n",
948  PartialData->u.Memory.Start.QuadPart, PartialData->u.Memory.Length);
949  AccessRange = &((*(PortConfig->AccessRanges))[RangeNumber]);
950 
951  AccessRange->RangeStart = PartialData->u.Memory.Start;
952  AccessRange->RangeLength = PartialData->u.Memory.Length;
953 
954  AccessRange->RangeInMemory = TRUE;
955  RangeNumber++;
956  }
957  break;
958 
960  /* Copy interrupt data */
961  TRACE("Got interrupt level %d, vector %d\n",
962  PartialData->u.Interrupt.Level, PartialData->u.Interrupt.Vector);
963  PortConfig->BusInterruptLevel = PartialData->u.Interrupt.Level;
964  PortConfig->BusInterruptVector = PartialData->u.Interrupt.Vector;
965 
966  /* Set interrupt mode accordingly to the resource */
967  if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LATCHED)
968  {
969  PortConfig->InterruptMode = Latched;
970  }
971  else if (PartialData->Flags == CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE)
972  {
973  PortConfig->InterruptMode = LevelSensitive;
974  }
975  break;
976 
977  case CmResourceTypeDma:
978  TRACE("Got DMA channel %d, port %d\n",
979  PartialData->u.Dma.Channel, PartialData->u.Dma.Port);
980  PortConfig->DmaChannel = PartialData->u.Dma.Channel;
981  PortConfig->DmaPort = PartialData->u.Dma.Port;
982  break;
983  }
984  }
985 }
#define TRUE
Definition: types.h:120
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@371 Port
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@375 Dma
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@372 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@374 Memory
#define CmResourceTypePort
Definition: hwresource.cpp:123
#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
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 833 of file scsiport.c.

837 {
838  CHAR ArcName[64];
840  PCDB Cdb;
841  INQUIRYDATA InquiryBuffer;
842  UCHAR TargetId;
843  UCHAR Lun;
844 
845  if (!DeviceExtension->HwResetBus(DeviceExtension->MiniPortDeviceExtension, PathId))
846  {
847  return;
848  }
849 
850  /* Remember the extension */
851  ScsiDeviceExtensions[ScsiBus] = DeviceExtension;
852 
853  for (TargetId = 0; TargetId < DeviceExtension->MaxTargedIds; TargetId++)
854  {
855  Lun = 0;
856  do
857  {
858  TRACE("Scanning SCSI device %d.%d.%d\n",
859  ScsiBus, TargetId, Lun);
860 
862  if (!Srb)
863  break;
865  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
866  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
867  Srb->PathId = PathId;
868  Srb->TargetId = TargetId;
869  Srb->Lun = Lun;
870  Srb->CdbLength = 6;
871  Srb->SrbFlags = SRB_FLAGS_DATA_IN;
872  Srb->DataTransferLength = INQUIRYDATABUFFERSIZE;
873  Srb->TimeOutValue = 5; /* in seconds */
874  Srb->DataBuffer = &InquiryBuffer;
875  Cdb = (PCDB)Srb->Cdb;
876  Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY;
877  Cdb->CDB6INQUIRY.LogicalUnitNumber = Srb->Lun;
878  Cdb->CDB6INQUIRY.AllocationLength = (UCHAR)Srb->DataTransferLength;
879  if (!SpiSendSynchronousSrb(DeviceExtension, Srb))
880  {
881  /* Don't check next LUNs */
882  break;
883  }
884 
885  /* Device exists, create its ARC name */
886  if (InquiryBuffer.RemovableMedia)
887  {
888  sprintf(ArcName, "scsi(%ld)cdrom(%d)fdisk(%d)",
889  ScsiBus, TargetId, Lun);
890  FsRegisterDevice(ArcName, &DiskVtbl);
891  }
892  else
893  {
894  sprintf(ArcName, "scsi(%ld)disk(%d)rdisk(%d)",
895  ScsiBus, TargetId, Lun);
896  /* Now, check if it has partitions */
897  SpiScanDevice(DeviceExtension, ArcName, PathId, TargetId, Lun);
898  }
899 
900  /* Check next LUN */
901  Lun++;
902  } while (Lun < SCSI_MAXIMUM_LOGICAL_UNITS);
903  }
904 }
PSCSI_PORT_DEVICE_EXTENSION ScsiDeviceExtensions[SCSI_MAXIMUM_BUSES]
Definition: scsiport.c:110
_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:380
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:441
#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:131
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:792

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 792 of file scsiport.c.

798 {
799  ULONG FileId, i;
801  NTSTATUS ret;
803  CHAR PartitionName[64];
804 
805  /* Register device with partition(0) suffix */
806  sprintf(PartitionName, "%spartition(0)", ArcName);
807  FsRegisterDevice(PartitionName, &DiskVtbl);
808 
809  /* Read device partition table */
810  Status = ArcOpen(PartitionName, OpenReadOnly, &FileId);
811  if (Status == ESUCCESS)
812  {
813  ret = HALDISPATCH->HalIoReadPartitionTable((PDEVICE_OBJECT)FileId, 512, FALSE, &PartitionBuffer);
814  if (NT_SUCCESS(ret))
815  {
816  for (i = 0; i < PartitionBuffer->PartitionCount; i++)
817  {
818  if (PartitionBuffer->PartitionEntry[i].PartitionType != PARTITION_ENTRY_UNUSED)
819  {
820  sprintf(PartitionName, "%spartition(%lu)",
821  ArcName, PartitionBuffer->PartitionEntry[i].PartitionNumber);
822  FsRegisterDevice(PartitionName, &DiskVtbl);
823  }
824  }
826  }
827  ArcClose(FileId);
828  }
829 }
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
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const DEVVTBL DiskVtbl
Definition: scsiport.c:380
int ret
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:441
Status
Definition: gdiplustypes.h:24
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:219
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:57
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 131 of file scsiport.c.

134 {
135  BOOLEAN ret;
136 
137  ASSERT(!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE));
138 
139  /* HACK: handle lack of interrupts */
140  while (!(DeviceExtension->InterruptFlags & SCSI_PORT_NEXT_REQUEST_READY))
141  {
142  KeStallExecutionProcessor(100 * 1000);
143  DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension);
144  }
145 
146  DeviceExtension->InterruptFlags &= ~SCSI_PORT_NEXT_REQUEST_READY;
147  Srb->SrbFlags |= SRB_FLAGS_IS_ACTIVE;
148 
149  if (!DeviceExtension->HwStartIo(
150  DeviceExtension->MiniPortDeviceExtension,
151  Srb))
152  {
153  ExFreePool(Srb);
154  return FALSE;
155  }
156 
157  /* HACK: handle lack of interrupts */
158  while (Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE)
159  {
160  KeStallExecutionProcessor(100 * 1000);
161  DeviceExtension->HwInterrupt(DeviceExtension->MiniPortDeviceExtension);
162  }
163 
164  ret = SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS;
165  ExFreePool(Srb);
166 
167  return ret;
168 }
#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:53
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:178
static ARC_STATUS DiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: scsiport.c:259
static ARC_STATUS DiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: scsiport.c:189
static ARC_STATUS DiskClose(ULONG FileId)
Definition: scsiport.c:170
static ARC_STATUS DiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: scsiport.c:367

Definition at line 380 of file scsiport.c.

Referenced by SpiScanAdapter(), and SpiScanDevice().

◆ ScsiDeviceExtensions

Definition at line 110 of file scsiport.c.

Referenced by DiskOpen(), and SpiScanAdapter().