https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3bc71f9086e9176669f38…
commit 3bc71f9086e9176669f38f939fbe99fd0f1bef05
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Jun 14 22:08:33 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Jun 19 21:10:51 2023 +0200
[FREELDR][SCSIPORT][STORPORT] Use existing defines for some hardcoded max values.
See
https://www.osronline.com/article.cfm%5Earticle=538.htm
[SCSIPORT] Remove 'MaxBus' variable, deprecated since commit fc3d38d1c
(r26220).
---
boot/freeldr/freeldr/disk/scsiport.c | 6 ++++--
drivers/storage/port/scsiport/scsiport.c | 22 ++++++++++++----------
drivers/storage/port/storport/miniport.c | 14 ++++++++------
3 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/boot/freeldr/freeldr/disk/scsiport.c b/boot/freeldr/freeldr/disk/scsiport.c
index 97d85034a5c..63d81c3dab8 100644
--- a/boot/freeldr/freeldr/disk/scsiport.c
+++ b/boot/freeldr/freeldr/disk/scsiport.c
@@ -455,8 +455,10 @@ SpiCreatePortConfig(
ConfigInfo->AtdiskSecondaryClaimed = FALSE; // FIXME
/* Initiator bus id is not set */
- for (Bus = 0; Bus < 8; Bus++)
+ for (Bus = 0; Bus < RTL_NUMBER_OF(ConfigInfo->InitiatorBusId); Bus++)
+ {
ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE;
+ }
}
ConfigInfo->NumberOfPhysicalBreaks = 17;
@@ -644,7 +646,7 @@ ScsiPortGetPhysicalAddress(
else
{
/* Nothing */
- PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE);
+ PhysicalAddress.QuadPart = (LONGLONG)SP_UNINITIALIZED_VALUE;
}
*Length = BufferLength;
diff --git a/drivers/storage/port/scsiport/scsiport.c
b/drivers/storage/port/scsiport/scsiport.c
index 9b7f7f9d6df..655c4680676 100644
--- a/drivers/storage/port/scsiport/scsiport.c
+++ b/drivers/storage/port/scsiport/scsiport.c
@@ -569,7 +569,7 @@ ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension,
else
{
/* Nothing */
- PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE);
+ PhysicalAddress.QuadPart = (LONGLONG)SP_UNINITIALIZED_VALUE;
}
*Length = (ULONG)BufferLength;
@@ -852,7 +852,6 @@ ScsiPortInitialize(
BOOLEAN FirstConfigCall = TRUE;
ULONG Result;
NTSTATUS Status;
- ULONG MaxBus;
PCI_SLOT_NUMBER SlotNumber;
PDEVICE_OBJECT PortDeviceObject;
@@ -861,7 +860,7 @@ ScsiPortInitialize(
PCM_RESOURCE_LIST ResourceList;
- DPRINT ("ScsiPortInitialize() called!\n");
+ DPRINT("ScsiPortInitialize() called!\n");
/* Check params for validity */
if ((HwInitializationData->HwInitialize == NULL) ||
@@ -945,8 +944,8 @@ ScsiPortInitialize(
DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) +
HwInitializationData->DeviceExtensionSize;
- MaxBus = (HwInitializationData->AdapterInterfaceType == PCIBus) ? 8 : 1;
- DPRINT("MaxBus: %lu\n", MaxBus);
+ DPRINT("AdapterInterfaceType: %lu\n",
+ HwInitializationData->AdapterInterfaceType);
while (TRUE)
{
@@ -1080,7 +1079,8 @@ CreatePortConfig:
if ((HwInitializationData->AdapterInterfaceType == PCIBus) &&
(HwInitializationData->VendorIdLength > 0) &&
(HwInitializationData->VendorId != NULL) &&
- (HwInitializationData->DeviceIdLength > 0) &&
(HwInitializationData->DeviceId != NULL))
+ (HwInitializationData->DeviceIdLength > 0) &&
+ (HwInitializationData->DeviceId != NULL))
{
PortConfig->BusInterruptLevel = 0;
@@ -1360,7 +1360,7 @@ CreatePortConfig:
if (!Again)
ConfigInfo.BusNumber++;
- DPRINT("Bus: %lu MaxBus: %lu\n", ConfigInfo.BusNumber, MaxBus);
+ DPRINT(" Bus: %lu\n", ConfigInfo.BusNumber);
DeviceFound = TRUE;
}
@@ -2402,7 +2402,7 @@ SpiCreatePortConfig(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
ConfigInfo->DmaPort2 = SP_UNINITIALIZED_VALUE;
ConfigInfo->MaximumTransferLength = SP_UNINITIALIZED_VALUE;
ConfigInfo->NumberOfAccessRanges = HwInitData->NumberOfAccessRanges;
- ConfigInfo->MaximumNumberOfTargets = 8;
+ ConfigInfo->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS; // NOTE: Using
legacy value.
/* Store parameters */
ConfigInfo->NeedPhysicalAddresses = HwInitData->NeedPhysicalAddresses;
@@ -2418,8 +2418,10 @@ SpiCreatePortConfig(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
ConfigInfo->AtdiskSecondaryClaimed =
DdkConfigInformation->AtDiskSecondaryAddressClaimed;
/* Initiator bus id is not set */
- for (Bus = 0; Bus < 8; Bus++)
+ for (Bus = 0; Bus < RTL_NUMBER_OF(ConfigInfo->InitiatorBusId); Bus++)
+ {
ConfigInfo->InitiatorBusId[Bus] = (CCHAR)SP_UNINITIALIZED_VALUE;
+ }
}
ConfigInfo->NumberOfPhysicalBreaks = 17;
@@ -2690,7 +2692,7 @@ SpiParseDeviceInfo(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
/* Check / reset if needed */
if (ConfigInfo->InitiatorBusId[0] >
ConfigInfo->MaximumNumberOfTargets - 1)
- ConfigInfo->InitiatorBusId[0] = (CCHAR)-1;
+ ConfigInfo->InitiatorBusId[0] = (CCHAR)SP_UNINITIALIZED_VALUE;
DPRINT("InitiatorTargetId = %d\n",
ConfigInfo->InitiatorBusId[0]);
}
diff --git a/drivers/storage/port/storport/miniport.c
b/drivers/storage/port/storport/miniport.c
index 48fd9890b2f..54071f98345 100644
--- a/drivers/storage/port/storport/miniport.c
+++ b/drivers/storage/port/storport/miniport.c
@@ -41,9 +41,9 @@ InitializeConfiguration(
PortConfig->SlotNumber = SlotNumber;
PortConfig->AdapterInterfaceType = InitData->AdapterInterfaceType;
- PortConfig->MaximumTransferLength = -1; //SP_UNINITIALIZED_VALUE;
- PortConfig->DmaChannel = -1; //SP_UNINITIALIZED_VALUE;
- PortConfig->DmaPort = -1; //SP_UNINITIALIZED_VALUE;
+ PortConfig->MaximumTransferLength = SP_UNINITIALIZED_VALUE;
+ PortConfig->DmaChannel = SP_UNINITIALIZED_VALUE;
+ PortConfig->DmaPort = SP_UNINITIALIZED_VALUE;
PortConfig->InterruptMode = LevelSensitive;
@@ -61,7 +61,7 @@ InitializeConfiguration(
PortConfig->ReceiveEvent = InitData->ReceiveEvent;
PortConfig->RealModeInitialized = FALSE;
PortConfig->BufferAccessScsiPortControlled = TRUE;
- PortConfig->MaximumNumberOfTargets = 128;
+ PortConfig->MaximumNumberOfTargets = SCSI_MAXIMUM_TARGETS_PER_BUS;
PortConfig->SpecificLuExtensionSize = InitData->SpecificLuExtensionSize;
PortConfig->SrbExtensionSize = InitData->SrbExtensionSize;
@@ -82,8 +82,10 @@ InitializeConfiguration(
PortConfig->NumberOfAccessRanges * sizeof(ACCESS_RANGE));
}
- for (i = 0; i < 7; i++)
- PortConfig->InitiatorBusId[i] = 0xff;
+ for (i = 0; i < RTL_NUMBER_OF(PortConfig->InitiatorBusId); i++)
+ {
+ PortConfig->InitiatorBusId[i] = (CCHAR)SP_UNINITIALIZED_VALUE;
+ }
return STATUS_SUCCESS;
}