From b6b82488dfda5ae59f0a48b5371c8a24fb4a24aa Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 18 Apr 2009 23:08:44 +0000 Subject: [PATCH] Apply block count maximum according to device capability. If the device supports LBA48 we can allow a maximum block count of 65535 as we have a 16bit sector count field available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30254 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp | 9 +++------ src/add-ons/kernel/bus_managers/ata/ATADevice.cpp | 14 ++++++++++++++ src/add-ons/kernel/bus_managers/ata/ATAModule.cpp | 4 ++-- src/add-ons/kernel/bus_managers/ata/ATAPrivate.h | 3 +++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp index 1d6e3ced6a..f4c2835628 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp +++ b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp @@ -197,13 +197,10 @@ ATAChannel::GetRestrictions(uint8 targetID, bool *isATAPI, bool *noAutoSense, // we always indicate ATAPI so we have to emulate fewer commands *isATAPI = true; *noAutoSense = false; + *maxBlocks = 0x100; - if (targetID < fDeviceCount && fDevices[targetID] != NULL - && fDevices[targetID]->IsATAPI()) { - *noAutoSense = true; - } - - *maxBlocks = 255; + if (targetID < fDeviceCount && fDevices[targetID] != NULL) + fDevices[targetID]->GetRestrictions(noAutoSense, maxBlocks); } diff --git a/src/add-ons/kernel/bus_managers/ata/ATADevice.cpp b/src/add-ons/kernel/bus_managers/ata/ATADevice.cpp index b1f2dd0229..bb2d77eadd 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATADevice.cpp +++ b/src/add-ons/kernel/bus_managers/ata/ATADevice.cpp @@ -286,6 +286,20 @@ ATADevice::ExecuteIO(ATARequest *request) } +void +ATADevice::GetRestrictions(bool *noAutoSense, uint32 *maxBlocks) +{ + if (IsATAPI()) + *noAutoSense = true; + else { + if (fUse48Bits) + *maxBlocks = 0xffff; + else + *maxBlocks = 0x100; + } +} + + status_t ATADevice::Select() { diff --git a/src/add-ons/kernel/bus_managers/ata/ATAModule.cpp b/src/add-ons/kernel/bus_managers/ata/ATAModule.cpp index eda3c92a71..9a1c40ca5f 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATAModule.cpp +++ b/src/add-ons/kernel/bus_managers/ata/ATAModule.cpp @@ -190,9 +190,9 @@ ata_channel_added(device_node *parent) // maximum number of blocks per transmission: // - ATAPI uses packets, i.e. normal SCSI limits apply // but I'm not sure about controller restrictions - // - ATA allows up to 256 blocks + // - ATA allows up to 256 blocks for LBA28 and 65535 for LBA48 // to fix specific drive bugs use ATAChannel::GetRestrictions() - { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 255 } }, + { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 0xffff } }, { ATA_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channelID } }, { NULL } }; diff --git a/src/add-ons/kernel/bus_managers/ata/ATAPrivate.h b/src/add-ons/kernel/bus_managers/ata/ATAPrivate.h index 3ed1a1da62..90526b66da 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATAPrivate.h +++ b/src/add-ons/kernel/bus_managers/ata/ATAPrivate.h @@ -173,6 +173,9 @@ virtual ~ATADevice(); status_t ReadCapacity(ATARequest *request); virtual status_t ExecuteIO(ATARequest *request); + void GetRestrictions(bool *noAutoSense, + uint32 *maxBlocks); + // ATA stuff virtual bool IsATAPI() { return false; };