Author: fireball
Date: Fri Mar 30 23:24:11 2007
New Revision: 26212
URL:
http://svn.reactos.org/svn/reactos?rev=26212&view=rev
Log:
- Fix ScsiPortGetDeviceBase() / ScsiPortSetDeviceBase().
Modified:
trunk/reactos/drivers/storage/scsiport-new/scsiport.c
trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h
Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
==============================================================================
--- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original)
+++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Fri Mar 30 23:24:11 2007
@@ -306,35 +306,45 @@
ScsiPortFreeDeviceBase(IN PVOID HwDeviceExtension,
IN PVOID MappedAddress)
{
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
- PSCSI_PORT_DEVICE_BASE DeviceBase;
- PLIST_ENTRY Entry;
-
- //DPRINT("ScsiPortFreeDeviceBase() called\n");
-
- DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
- SCSI_PORT_DEVICE_EXTENSION,
- MiniPortDeviceExtension);
- if (IsListEmpty(&DeviceExtension->DeviceBaseListHead))
- return;
-
- Entry = DeviceExtension->DeviceBaseListHead.Flink;
- while (Entry != &DeviceExtension->DeviceBaseListHead)
- {
- DeviceBase = CONTAINING_RECORD(Entry,
- SCSI_PORT_DEVICE_BASE,
- List);
- if (DeviceBase->MappedAddress == MappedAddress)
- {
- MmUnmapIoSpace(DeviceBase->MappedAddress,
- DeviceBase->NumberOfBytes);
- RemoveEntryList(Entry);
- ExFreePool(DeviceBase);
-
- return;
- }
-
- Entry = Entry->Flink;
+ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ PMAPPED_ADDRESS NextMa, LastMa;
+
+ //DPRINT("ScsiPortFreeDeviceBase() called\n");
+
+ DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
+
+ /* Initialize our pointers */
+ NextMa = DeviceExtension->MappedAddressList;
+ LastMa = NextMa;
+
+ while (NextMa)
+ {
+ if (NextMa->MappedAddress == MappedAddress)
+ {
+ /* Unmap it first */
+ MmUnmapIoSpace(MappedAddress, NextMa->NumberOfBytes);
+
+ /* Remove it from the list */
+ if (NextMa == DeviceExtension->MappedAddressList)
+ {
+ /* Remove the first entry */
+ DeviceExtension->MappedAddressList = NextMa->NextMappedAddress;
+ }
+ else
+ {
+ LastMa->NextMappedAddress = NextMa->NextMappedAddress;
+ }
+
+ /* Free the resources and quit */
+ ExFreePool(NextMa);
+
+ return;
+ }
+ else
+ {
+ LastMa = NextMa;
+ NextMa = NextMa->NextMappedAddress;
+ }
}
}
@@ -369,50 +379,51 @@
IN ULONG NumberOfBytes,
IN BOOLEAN InIoSpace)
{
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
- PHYSICAL_ADDRESS TranslatedAddress;
- PSCSI_PORT_DEVICE_BASE DeviceBase;
- ULONG AddressSpace;
- PVOID MappedAddress;
-
- //DPRINT ("ScsiPortGetDeviceBase() called\n");
-
- AddressSpace = (ULONG)InIoSpace;
- if (HalTranslateBusAddress(BusType,
- SystemIoBusNumber,
- IoAddress,
- &AddressSpace,
- &TranslatedAddress) == FALSE)
- return NULL;
-
- /* i/o space */
- if (AddressSpace != 0)
- return((PVOID)TranslatedAddress.u.LowPart);
-
- MappedAddress = MmMapIoSpace(TranslatedAddress,
- NumberOfBytes,
- FALSE);
-
- DeviceBase = ExAllocatePool(NonPagedPool,
- sizeof(SCSI_PORT_DEVICE_BASE));
- if (DeviceBase == NULL)
- return(MappedAddress);
-
- DeviceBase->MappedAddress = MappedAddress;
- DeviceBase->NumberOfBytes = NumberOfBytes;
- DeviceBase->IoAddress = IoAddress;
- DeviceBase->SystemIoBusNumber = SystemIoBusNumber;
-
- DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
- SCSI_PORT_DEVICE_EXTENSION,
- MiniPortDeviceExtension);
-
- InsertHeadList(&DeviceExtension->DeviceBaseListHead,
- &DeviceBase->List);
-
- return(MappedAddress);
-}
-
+ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ PHYSICAL_ADDRESS TranslatedAddress;
+ PMAPPED_ADDRESS DeviceBase;
+ ULONG AddressSpace;
+ PVOID MappedAddress;
+
+ //DPRINT ("ScsiPortGetDeviceBase() called\n");
+
+ DeviceExtension = ((PSCSI_PORT_DEVICE_EXTENSION)HwDeviceExtension) - 1;
+
+ AddressSpace = (ULONG)InIoSpace;
+ if (HalTranslateBusAddress(BusType,
+ SystemIoBusNumber,
+ IoAddress,
+ &AddressSpace,
+ &TranslatedAddress) == FALSE)
+ {
+ return NULL;
+ }
+
+ /* i/o space */
+ if (AddressSpace != 0)
+ return((PVOID)TranslatedAddress.u.LowPart);
+
+ MappedAddress = MmMapIoSpace(TranslatedAddress,
+ NumberOfBytes,
+ FALSE);
+
+ DeviceBase = ExAllocatePool(NonPagedPool,
+ sizeof(MAPPED_ADDRESS));
+
+ if (DeviceBase == NULL)
+ return MappedAddress;
+
+ DeviceBase->MappedAddress = MappedAddress;
+ DeviceBase->NumberOfBytes = NumberOfBytes;
+ DeviceBase->IoAddress = IoAddress;
+ DeviceBase->BusNumber = SystemIoBusNumber;
+
+ /* Link it to the Device Extension list */
+ DeviceBase->NextMappedAddress = DeviceExtension->MappedAddressList;
+ DeviceExtension->MappedAddressList = DeviceBase;
+
+ return MappedAddress;
+}
/*
* @implemented
Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
==============================================================================
--- trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h (original)
+++ trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Fri Mar 30 23:24:11 2007
@@ -216,7 +216,7 @@
KTIMER MiniportTimer;
KDPC MiniportTimerDpc;
- LIST_ENTRY DeviceBaseListHead;
+ PMAPPED_ADDRESS MappedAddressList;
ULONG LunExtensionSize;
PSCSI_PORT_LUN_EXTENSION LunExtensionList[LUS_NUMBER];