mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +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
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -275,7 +275,6 @@ CdromClassFindDevices(IN PDRIVER_OBJECT DriverObject,
|
|||
DPRINT("CdromClassFindDevices() done\n");
|
||||
|
||||
return(FoundDevice);
|
||||
// return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,6 +461,10 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
/* Initialize lookaside list for SRBs */
|
||||
ScsiClassInitializeSrbLookasideList(DiskDeviceExtension,
|
||||
4);
|
||||
|
||||
/* Get disk geometry */
|
||||
DiskDeviceExtension->DiskGeometry = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DISK_GEOMETRY));
|
||||
|
@ -469,6 +472,8 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
{
|
||||
DPRINT1("Failed to allocate geometry buffer!\n");
|
||||
|
||||
ExDeleteNPagedLookasideList(&DiskDeviceExtension->SrbLookasideListHead);
|
||||
|
||||
IoDeleteDevice(DiskDeviceObject);
|
||||
|
||||
/* Release (unclaim) the disk */
|
||||
|
@ -511,6 +516,7 @@ CdromClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME
|
||||
* CdromClassReadTocEntry
|
||||
|
@ -543,14 +549,15 @@ CdromClassReadTocEntry(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer,
|
|||
Cdb->READ_TOC.AllocationLength[0] = Length >> 8;
|
||||
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
||||
Cdb->READ_TOC.Msf = 1;
|
||||
|
||||
return ScsiClassSendSrbSynchronous(DeviceObject,
|
||||
|
||||
return(ScsiClassSendSrbSynchronous(DeviceObject,
|
||||
&Srb,
|
||||
Buffer,
|
||||
Length,
|
||||
FALSE);
|
||||
FALSE));
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer, UINT Length)
|
||||
{
|
||||
|
@ -569,14 +576,15 @@ CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffe
|
|||
Cdb->READ_TOC.AllocationLength[0] = Length >> 8;
|
||||
Cdb->READ_TOC.AllocationLength[1] = Length & 0xff;
|
||||
Cdb->READ_TOC.Msf = 0;
|
||||
|
||||
return ScsiClassSendSrbSynchronous(DeviceObject,
|
||||
|
||||
return(ScsiClassSendSrbSynchronous(DeviceObject,
|
||||
&Srb,
|
||||
Buffer,
|
||||
Length,
|
||||
FALSE);
|
||||
FALSE));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* CdromClassDeviceControl
|
||||
|
@ -649,62 +657,73 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_CDROM_READ_TOC:
|
||||
DPRINT("IOCTL_CDROM_READ_TOC\n");
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_TOC))
|
||||
DPRINT("IOCTL_CDROM_READ_TOC\n");
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_TOC))
|
||||
{
|
||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
PCDROM_TOC TocBuffer;
|
||||
USHORT Length;
|
||||
PCDROM_TOC TocBuffer;
|
||||
USHORT Length;
|
||||
|
||||
TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
/* First read the lead out */
|
||||
Length = 4 + sizeof(TRACK_DATA);
|
||||
Status = CdromClassReadTocEntry(DeviceObject, 0xaa, TocBuffer, Length);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
/* First read the lead out */
|
||||
Length = 4 + sizeof(TRACK_DATA);
|
||||
Status = CdromClassReadTocEntry(DeviceObject,
|
||||
0xAA,
|
||||
TocBuffer,
|
||||
Length);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
if (TocBuffer->FirstTrack == 0xaa)
|
||||
{
|
||||
if (TocBuffer->FirstTrack == 0xaa)
|
||||
{
|
||||
/* there is an empty cd */
|
||||
Information = Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
Information = Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* read the toc */
|
||||
Length = 4 + sizeof(TRACK_DATA) * (TocBuffer->LastTrack - TocBuffer->FirstTrack + 2);
|
||||
Status = CdromClassReadTocEntry(DeviceObject, TocBuffer->FirstTrack, TocBuffer, Length);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Information = Length;
|
||||
}
|
||||
}
|
||||
Status = CdromClassReadTocEntry(DeviceObject,
|
||||
TocBuffer->FirstTrack,
|
||||
TocBuffer, Length);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Information = Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IOCTL_CDROM_GET_LAST_SESSION:
|
||||
DPRINT("IOCTL_CDROM_GET_LAST_SESSION\n");
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < 4 + sizeof(TRACK_DATA))
|
||||
{
|
||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
USHORT Length;
|
||||
PCDROM_TOC TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
break;
|
||||
|
||||
Length = 4 + sizeof(TRACK_DATA);
|
||||
Status = CdromClassReadLastSession(DeviceObject, 0, TocBuffer, Length);
|
||||
if (NT_SUCCESS(Status))
|
||||
case IOCTL_CDROM_GET_LAST_SESSION:
|
||||
DPRINT("IOCTL_CDROM_GET_LAST_SESSION\n");
|
||||
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < 4 + sizeof(TRACK_DATA))
|
||||
{
|
||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
PCDROM_TOC TocBuffer;
|
||||
USHORT Length;
|
||||
|
||||
TocBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
Length = 4 + sizeof(TRACK_DATA);
|
||||
Status = CdromClassReadLastSession(DeviceObject,
|
||||
0,
|
||||
TocBuffer,
|
||||
Length);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Information = Length;
|
||||
Information = Length;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Call the common device control function */
|
||||
return(ScsiClassDeviceControl(DeviceObject, Irp));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -160,9 +160,7 @@ ScsiClassBuildRequest(PDEVICE_OBJECT DeviceObject,
|
|||
DPRINT("Logical block address: %lu\n", LogicalBlockAddress);
|
||||
|
||||
/* Allocate and initialize an SRB */
|
||||
/* FIXME: use lookaside list instead */
|
||||
Srb = ExAllocatePool(NonPagedPool,
|
||||
sizeof(SCSI_REQUEST_BLOCK));
|
||||
Srb = ExAllocateFromNPagedLookasideList(&DeviceExtension->SrbLookasideListHead);
|
||||
|
||||
Srb->SrbFlags = 0;
|
||||
Srb->Length = sizeof(SCSI_REQUEST_BLOCK); //SCSI_REQUEST_BLOCK_SIZE;
|
||||
|
@ -929,9 +927,9 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: use lookaside list instead */
|
||||
DPRINT("Freed SRB %p\n", IrpStack->Parameters.Scsi.Srb);
|
||||
ExFreePool(IrpStack->Parameters.Scsi.Srb);
|
||||
/* Free the SRB */
|
||||
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||
Srb);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -1011,9 +1009,9 @@ ScsiClassIoCompleteAssociated(PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: use lookaside list instead */
|
||||
DPRINT("Freed SRB %p\n", IrpStack->Parameters.Scsi.Srb);
|
||||
ExFreePool(IrpStack->Parameters.Scsi.Srb);
|
||||
/* Free the SRB */
|
||||
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||
Srb);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -491,6 +491,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
DiskDeviceExtension->TargetId = InquiryData->TargetId;
|
||||
DiskDeviceExtension->Lun = InquiryData->Lun;
|
||||
|
||||
/* Initialize the lookaside list for SRBs */
|
||||
ScsiClassInitializeSrbLookasideList(DiskDeviceExtension,
|
||||
4);
|
||||
|
||||
/* zero-out disk data */
|
||||
DiskData = (PDISK_DATA)(DiskDeviceExtension + 1);
|
||||
RtlZeroMemory(DiskData,
|
||||
|
@ -503,6 +507,8 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
{
|
||||
DPRINT("Failed to allocate geometry buffer!\n");
|
||||
|
||||
ExDeleteNPagedLookasideList(&DiskDeviceExtension->SrbLookasideListHead);
|
||||
|
||||
IoDeleteDevice(DiskDeviceObject);
|
||||
|
||||
/* Release (unclaim) the disk */
|
||||
|
@ -552,41 +558,41 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Read partition table */
|
||||
Status = IoReadPartitionTable(DiskDeviceObject,
|
||||
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||
TRUE,
|
||||
&PartitionList);
|
||||
/* Read partition table */
|
||||
Status = IoReadPartitionTable(DiskDeviceObject,
|
||||
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||
TRUE,
|
||||
&PartitionList);
|
||||
|
||||
DPRINT("IoReadPartitionTable(): Status: %lx\n", Status);
|
||||
DPRINT("IoReadPartitionTable(): Status: %lx\n", Status);
|
||||
|
||||
if ((!NT_SUCCESS(Status) || PartitionList->PartitionCount == 0) &&
|
||||
DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA)
|
||||
{
|
||||
if (!NT_SUCCESS(Status))
|
||||
if ((!NT_SUCCESS(Status) || PartitionList->PartitionCount == 0) &&
|
||||
DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA)
|
||||
{
|
||||
/* Drive is not ready. */
|
||||
DPRINT("Drive not ready\n");
|
||||
DiskData->DriveNotReady = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExFreePool(PartitionList);
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Drive is not ready. */
|
||||
DPRINT("Drive not ready\n");
|
||||
DiskData->DriveNotReady = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExFreePool(PartitionList);
|
||||
}
|
||||
|
||||
/* Allocate a partition list for a single entry. */
|
||||
PartitionList = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||
if (PartitionList != NULL)
|
||||
{
|
||||
RtlZeroMemory(PartitionList,
|
||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||
PartitionList->PartitionCount = 1;
|
||||
/* Allocate a partition list for a single entry. */
|
||||
PartitionList = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||
if (PartitionList != NULL)
|
||||
{
|
||||
RtlZeroMemory(PartitionList,
|
||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||
PartitionList->PartitionCount = 1;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -642,6 +648,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
|||
PartitionDeviceExtension->Lun = InquiryData->Lun;
|
||||
PartitionDeviceExtension->SectorShift = DiskDeviceExtension->SectorShift;
|
||||
|
||||
/* Initialize lookaside list for SRBs */
|
||||
ScsiClassInitializeSrbLookasideList(PartitionDeviceExtension,
|
||||
8);
|
||||
|
||||
DiskData = (PDISK_DATA)(PartitionDeviceExtension + 1);
|
||||
DiskData->PartitionType = PartitionEntry->PartitionType;
|
||||
DiskData->PartitionNumber = PartitionNumber + 1;
|
||||
|
|
Loading…
Reference in a new issue