mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
Use lookaside list to allocate SRBs.
svn path=/trunk/; revision=3878
This commit is contained in:
parent
35ccf47588
commit
d774049979
3 changed files with 114 additions and 87 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: cdrom.c,v 1.17 2002/09/19 16:17:48 ekohl Exp $
|
/* $Id: cdrom.c,v 1.18 2002/12/15 14:34:43 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -275,7 +275,6 @@ CdromClassFindDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
DPRINT("CdromClassFindDevices() done\n");
|
DPRINT("CdromClassFindDevices() done\n");
|
||||||
|
|
||||||
return(FoundDevice);
|
return(FoundDevice);
|
||||||
// return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,6 +461,10 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize lookaside list for SRBs */
|
||||||
|
ScsiClassInitializeSrbLookasideList(DiskDeviceExtension,
|
||||||
|
4);
|
||||||
|
|
||||||
/* Get disk geometry */
|
/* Get disk geometry */
|
||||||
DiskDeviceExtension->DiskGeometry = ExAllocatePool(NonPagedPool,
|
DiskDeviceExtension->DiskGeometry = ExAllocatePool(NonPagedPool,
|
||||||
sizeof(DISK_GEOMETRY));
|
sizeof(DISK_GEOMETRY));
|
||||||
|
@ -469,6 +472,8 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to allocate geometry buffer!\n");
|
DPRINT1("Failed to allocate geometry buffer!\n");
|
||||||
|
|
||||||
|
ExDeleteNPagedLookasideList(&DiskDeviceExtension->SrbLookasideListHead);
|
||||||
|
|
||||||
IoDeleteDevice(DiskDeviceObject);
|
IoDeleteDevice(DiskDeviceObject);
|
||||||
|
|
||||||
/* Release (unclaim) the disk */
|
/* Release (unclaim) the disk */
|
||||||
|
@ -511,6 +516,7 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME
|
* NAME
|
||||||
* CdromClassReadTocEntry
|
* CdromClassReadTocEntry
|
||||||
|
@ -544,13 +550,14 @@ CdromClassReadTocEntry(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer,
|
||||||
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
||||||
Cdb->READ_TOC.Msf = 1;
|
Cdb->READ_TOC.Msf = 1;
|
||||||
|
|
||||||
return ScsiClassSendSrbSynchronous(DeviceObject,
|
return(ScsiClassSendSrbSynchronous(DeviceObject,
|
||||||
&Srb,
|
&Srb,
|
||||||
Buffer,
|
Buffer,
|
||||||
Length,
|
Length,
|
||||||
FALSE);
|
FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer, UINT Length)
|
CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer, UINT Length)
|
||||||
{
|
{
|
||||||
|
@ -570,13 +577,14 @@ CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffe
|
||||||
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
||||||
Cdb->READ_TOC.Msf = 0;
|
Cdb->READ_TOC.Msf = 0;
|
||||||
|
|
||||||
return ScsiClassSendSrbSynchronous(DeviceObject,
|
return(ScsiClassSendSrbSynchronous(DeviceObject,
|
||||||
&Srb,
|
&Srb,
|
||||||
Buffer,
|
Buffer,
|
||||||
Length,
|
Length,
|
||||||
FALSE);
|
FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* CdromClassDeviceControl
|
* CdromClassDeviceControl
|
||||||
|
@ -649,6 +657,7 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_CDROM_READ_TOC:
|
case IOCTL_CDROM_READ_TOC:
|
||||||
DPRINT("IOCTL_CDROM_READ_TOC\n");
|
DPRINT("IOCTL_CDROM_READ_TOC\n");
|
||||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_TOC))
|
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_TOC))
|
||||||
|
@ -664,8 +673,10 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
/* First read the lead out */
|
/* First read the lead out */
|
||||||
Length = 4 + sizeof(TRACK_DATA);
|
Length = 4 + sizeof(TRACK_DATA);
|
||||||
Status = CdromClassReadTocEntry(DeviceObject, 0xaa, TocBuffer, Length);
|
Status = CdromClassReadTocEntry(DeviceObject,
|
||||||
|
0xAA,
|
||||||
|
TocBuffer,
|
||||||
|
Length);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if (TocBuffer->FirstTrack == 0xaa)
|
if (TocBuffer->FirstTrack == 0xaa)
|
||||||
|
@ -677,7 +688,9 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
/* read the toc */
|
/* read the toc */
|
||||||
Length = 4 + sizeof(TRACK_DATA) * (TocBuffer->LastTrack - TocBuffer->FirstTrack + 2);
|
Length = 4 + sizeof(TRACK_DATA) * (TocBuffer->LastTrack - TocBuffer->FirstTrack + 2);
|
||||||
Status = CdromClassReadTocEntry(DeviceObject, TocBuffer->FirstTrack, TocBuffer, Length);
|
Status = CdromClassReadTocEntry(DeviceObject,
|
||||||
|
TocBuffer->FirstTrack,
|
||||||
|
TocBuffer, Length);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Information = Length;
|
Information = Length;
|
||||||
|
@ -686,6 +699,7 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_CDROM_GET_LAST_SESSION:
|
case IOCTL_CDROM_GET_LAST_SESSION:
|
||||||
DPRINT("IOCTL_CDROM_GET_LAST_SESSION\n");
|
DPRINT("IOCTL_CDROM_GET_LAST_SESSION\n");
|
||||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < 4 + sizeof(TRACK_DATA))
|
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < 4 + sizeof(TRACK_DATA))
|
||||||
|
@ -694,17 +708,22 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
PCDROM_TOC TocBuffer;
|
||||||
USHORT Length;
|
USHORT Length;
|
||||||
PCDROM_TOC TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
|
||||||
|
|
||||||
|
TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
Length = 4 + sizeof(TRACK_DATA);
|
Length = 4 + sizeof(TRACK_DATA);
|
||||||
Status = CdromClassReadLastSession(DeviceObject, 0, TocBuffer, Length);
|
Status = CdromClassReadLastSession(DeviceObject,
|
||||||
|
0,
|
||||||
|
TocBuffer,
|
||||||
|
Length);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Information = Length;
|
Information = Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Call the common device control function */
|
/* Call the common device control function */
|
||||||
return(ScsiClassDeviceControl(DeviceObject, Irp));
|
return(ScsiClassDeviceControl(DeviceObject, Irp));
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: class2.c,v 1.27 2002/11/18 22:40:32 ekohl Exp $
|
/* $Id: class2.c,v 1.28 2002/12/15 14:33:09 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -160,9 +160,7 @@ ScsiClassBuildRequest(PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("Logical block address: %lu\n", LogicalBlockAddress);
|
DPRINT("Logical block address: %lu\n", LogicalBlockAddress);
|
||||||
|
|
||||||
/* Allocate and initialize an SRB */
|
/* Allocate and initialize an SRB */
|
||||||
/* FIXME: use lookaside list instead */
|
Srb = ExAllocateFromNPagedLookasideList(&DeviceExtension->SrbLookasideListHead);
|
||||||
Srb = ExAllocatePool(NonPagedPool,
|
|
||||||
sizeof(SCSI_REQUEST_BLOCK));
|
|
||||||
|
|
||||||
Srb->SrbFlags = 0;
|
Srb->SrbFlags = 0;
|
||||||
Srb->Length = sizeof(SCSI_REQUEST_BLOCK); //SCSI_REQUEST_BLOCK_SIZE;
|
Srb->Length = sizeof(SCSI_REQUEST_BLOCK); //SCSI_REQUEST_BLOCK_SIZE;
|
||||||
|
@ -929,9 +927,9 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: use lookaside list instead */
|
/* Free the SRB */
|
||||||
DPRINT("Freed SRB %p\n", IrpStack->Parameters.Scsi.Srb);
|
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||||
ExFreePool(IrpStack->Parameters.Scsi.Srb);
|
Srb);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -1011,9 +1009,9 @@ ScsiClassIoCompleteAssociated(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: use lookaside list instead */
|
/* Free the SRB */
|
||||||
DPRINT("Freed SRB %p\n", IrpStack->Parameters.Scsi.Srb);
|
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||||
ExFreePool(IrpStack->Parameters.Scsi.Srb);
|
Srb);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: disk.c,v 1.19 2002/09/19 16:18:14 ekohl Exp $
|
/* $Id: disk.c,v 1.20 2002/12/15 14:34:06 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -491,6 +491,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
DiskDeviceExtension->TargetId = InquiryData->TargetId;
|
DiskDeviceExtension->TargetId = InquiryData->TargetId;
|
||||||
DiskDeviceExtension->Lun = InquiryData->Lun;
|
DiskDeviceExtension->Lun = InquiryData->Lun;
|
||||||
|
|
||||||
|
/* Initialize the lookaside list for SRBs */
|
||||||
|
ScsiClassInitializeSrbLookasideList(DiskDeviceExtension,
|
||||||
|
4);
|
||||||
|
|
||||||
/* zero-out disk data */
|
/* zero-out disk data */
|
||||||
DiskData = (PDISK_DATA)(DiskDeviceExtension + 1);
|
DiskData = (PDISK_DATA)(DiskDeviceExtension + 1);
|
||||||
RtlZeroMemory(DiskData,
|
RtlZeroMemory(DiskData,
|
||||||
|
@ -503,6 +507,8 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
{
|
{
|
||||||
DPRINT("Failed to allocate geometry buffer!\n");
|
DPRINT("Failed to allocate geometry buffer!\n");
|
||||||
|
|
||||||
|
ExDeleteNPagedLookasideList(&DiskDeviceExtension->SrbLookasideListHead);
|
||||||
|
|
||||||
IoDeleteDevice(DiskDeviceObject);
|
IoDeleteDevice(DiskDeviceObject);
|
||||||
|
|
||||||
/* Release (unclaim) the disk */
|
/* Release (unclaim) the disk */
|
||||||
|
@ -642,6 +648,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
PartitionDeviceExtension->Lun = InquiryData->Lun;
|
PartitionDeviceExtension->Lun = InquiryData->Lun;
|
||||||
PartitionDeviceExtension->SectorShift = DiskDeviceExtension->SectorShift;
|
PartitionDeviceExtension->SectorShift = DiskDeviceExtension->SectorShift;
|
||||||
|
|
||||||
|
/* Initialize lookaside list for SRBs */
|
||||||
|
ScsiClassInitializeSrbLookasideList(PartitionDeviceExtension,
|
||||||
|
8);
|
||||||
|
|
||||||
DiskData = (PDISK_DATA)(PartitionDeviceExtension + 1);
|
DiskData = (PDISK_DATA)(PartitionDeviceExtension + 1);
|
||||||
DiskData->PartitionType = PartitionEntry->PartitionType;
|
DiskData->PartitionType = PartitionEntry->PartitionType;
|
||||||
DiskData->PartitionNumber = PartitionNumber + 1;
|
DiskData->PartitionNumber = PartitionNumber + 1;
|
||||||
|
|
Loading…
Reference in a new issue