* Fixed wrong indentation, and number of blank lines.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30367 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,18 +9,20 @@
|
||||
|
||||
#include "ATAPrivate.h"
|
||||
|
||||
|
||||
ATAChannel::ATAChannel(device_node *node)
|
||||
: fNode(node),
|
||||
fChannelID(0),
|
||||
fController(NULL),
|
||||
fCookie(NULL),
|
||||
fExpectsInterrupt(false),
|
||||
fStatus(B_NO_INIT),
|
||||
fSCSIBus(NULL),
|
||||
fDeviceCount(0),
|
||||
fDevices(NULL),
|
||||
fUseDMA(true),
|
||||
fRequest(NULL)
|
||||
:
|
||||
fNode(node),
|
||||
fChannelID(0),
|
||||
fController(NULL),
|
||||
fCookie(NULL),
|
||||
fExpectsInterrupt(false),
|
||||
fStatus(B_NO_INIT),
|
||||
fSCSIBus(NULL),
|
||||
fDeviceCount(0),
|
||||
fDevices(NULL),
|
||||
fUseDMA(true),
|
||||
fRequest(NULL)
|
||||
{
|
||||
B_INITIALIZE_SPINLOCK(&fInterruptLock);
|
||||
fInterruptCondition.Init(this, "ata dma transfer");
|
||||
@@ -64,7 +66,7 @@ ATAChannel::ATAChannel(device_node *node)
|
||||
|
||||
uint8 maxDevices = 2;
|
||||
if (gDeviceManager->get_attr_uint8(node, ATA_CONTROLLER_MAX_DEVICES_ITEM,
|
||||
&maxDevices, true) != B_OK) {
|
||||
&maxDevices, true) != B_OK) {
|
||||
maxDevices = 2;
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ ATAChannel::PathInquiry(scsi_path_inquiry *info)
|
||||
|
||||
const char *controllerName = NULL;
|
||||
if (gDeviceManager->get_attr_string(fNode,
|
||||
SCSI_DESCRIPTION_CONTROLLER_NAME, &controllerName, true) == B_OK)
|
||||
SCSI_DESCRIPTION_CONTROLLER_NAME, &controllerName, true) == B_OK)
|
||||
strlcpy(info->hba_vid, controllerName, SCSI_HBA_ID);
|
||||
else
|
||||
strlcpy(info->hba_vid, "unknown", SCSI_HBA_ID);
|
||||
@@ -336,7 +338,7 @@ ATAChannel::Reset(bool *presence, uint16 *signatures)
|
||||
|
||||
ata_task_file taskFile;
|
||||
if (_ReadRegs(&taskFile, ATA_MASK_LBA_MID | ATA_MASK_LBA_HIGH
|
||||
| ATA_MASK_ERROR) != B_OK) {
|
||||
| ATA_MASK_ERROR) != B_OK) {
|
||||
TRACE_ERROR("reading status failed\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -497,7 +499,7 @@ ATAChannel::SendRequest(ATARequest *request, uint32 flags)
|
||||
}
|
||||
|
||||
if (_WriteRegs(device->TaskFile(), device->RegisterMask()
|
||||
| ATA_MASK_COMMAND) != B_OK) {
|
||||
| ATA_MASK_COMMAND) != B_OK) {
|
||||
TRACE_ERROR("can't write command\n");
|
||||
request->SetStatus(SCSI_HBA_ERR);
|
||||
return B_ERROR;
|
||||
@@ -551,7 +553,7 @@ ATAChannel::FinishRequest(ATARequest *request, uint32 flags, uint8 errorMask)
|
||||
return B_OK;
|
||||
|
||||
if ((taskFile->read.error & ATA_ERROR_MEDIUM_CHANGED)
|
||||
!= ATA_ERROR_MEDIUM_CHANGED) {
|
||||
!= ATA_ERROR_MEDIUM_CHANGED) {
|
||||
TRACE_ERROR("command failed, error bit is set: 0x%02x\n",
|
||||
taskFile->read.error);
|
||||
}
|
||||
@@ -897,7 +899,7 @@ ATAChannel::_TransferPIOPhysical(ATARequest *request, addr_t physicalAddress,
|
||||
void *handle;
|
||||
addr_t virtualAddress;
|
||||
if (vm_get_physical_page_current_cpu(physicalAddress, &virtualAddress,
|
||||
&handle) != B_OK) {
|
||||
&handle) != B_OK) {
|
||||
thread_unpin_from_current_cpu(thread);
|
||||
// ouch: this should never ever happen
|
||||
return B_ERROR;
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
|
||||
|
||||
ATADevice::ATADevice(ATAChannel *channel, uint8 index)
|
||||
: fChannel(channel),
|
||||
fRegisterMask(0),
|
||||
fUseDMA(channel->UseDMA()),
|
||||
fDMAMode(0),
|
||||
fDMAFailures(0),
|
||||
fIndex(index),
|
||||
fUse48Bits(false),
|
||||
fTotalSectors(0)
|
||||
:
|
||||
fChannel(channel),
|
||||
fRegisterMask(0),
|
||||
fUseDMA(channel->UseDMA()),
|
||||
fDMAMode(0),
|
||||
fDMAFailures(0),
|
||||
fIndex(index),
|
||||
fUse48Bits(false),
|
||||
fTotalSectors(0)
|
||||
{
|
||||
memset(&fInfoBlock, 0, sizeof(fInfoBlock));
|
||||
memset(&fTaskFile, 0, sizeof(fTaskFile));
|
||||
@@ -45,7 +46,7 @@ ATADevice::TestUnitReady(ATARequest *request)
|
||||
return result;
|
||||
}
|
||||
|
||||
return fChannel->FinishRequest(request, ATA_WAIT_FINISH
|
||||
return fChannel->FinishRequest(request, ATA_WAIT_FINISH
|
||||
| ATA_DEVICE_READY_REQUIRED, ATA_ERROR_NO_MEDIA | ATA_ERROR_ABORTED
|
||||
| ATA_ERROR_MEDIA_CHANGE_REQUESTED | ATA_ERROR_MEDIUM_CHANGED);
|
||||
}
|
||||
@@ -63,8 +64,8 @@ ATADevice::SynchronizeCache(ATARequest *request)
|
||||
return B_OK;
|
||||
|
||||
fRegisterMask = 0;
|
||||
fTaskFile.lba.command = fUse48Bits ? ATA_COMMAND_FLUSH_CACHE_EXT
|
||||
: ATA_COMMAND_FLUSH_CACHE;
|
||||
fTaskFile.lba.command
|
||||
= fUse48Bits ? ATA_COMMAND_FLUSH_CACHE_EXT : ATA_COMMAND_FLUSH_CACHE;
|
||||
|
||||
request->SetTimeout(60 * 1000 * 1000);
|
||||
status_t result = fChannel->SendRequest(request, ATA_DEVICE_READY_REQUIRED);
|
||||
@@ -254,7 +255,7 @@ ATADevice::ExecuteIO(ATARequest *request)
|
||||
case SCSI_OP_WRITE_6:
|
||||
{
|
||||
scsi_cmd_rw_6 *command = (scsi_cmd_rw_6 *)ccb->cdb;
|
||||
uint32 address = ((uint32)command->high_lba << 16)
|
||||
uint32 address = ((uint32)command->high_lba << 16)
|
||||
| ((uint32)command->mid_lba << 8) | (uint32)command->low_lba;
|
||||
|
||||
request->SetIsWrite(command->opcode == SCSI_OP_WRITE_6);
|
||||
@@ -320,15 +321,14 @@ ATADevice::SetFeature(int feature)
|
||||
fTaskFile.write.command = ATA_COMMAND_SET_FEATURES;
|
||||
fRegisterMask = ATA_MASK_FEATURES;
|
||||
|
||||
status_t result = fChannel->SendRequest(&request,
|
||||
ATA_DEVICE_READY_REQUIRED);
|
||||
status_t result = fChannel->SendRequest(&request, ATA_DEVICE_READY_REQUIRED);
|
||||
if (result != B_OK) {
|
||||
TRACE_ERROR("sending set feature request failed\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = fChannel->FinishRequest(&request, ATA_WAIT_FINISH
|
||||
| ATA_DEVICE_READY_REQUIRED, ATA_ERROR_ABORTED);
|
||||
result = fChannel->FinishRequest(&request,
|
||||
ATA_WAIT_FINISH | ATA_DEVICE_READY_REQUIRED, ATA_ERROR_ABORTED);
|
||||
if (result != B_OK) {
|
||||
TRACE_ERROR("set feature request failed\n");
|
||||
return result;
|
||||
@@ -469,27 +469,27 @@ ATADevice::Identify()
|
||||
fTaskFile.write.command = IsATAPI() ? ATA_COMMAND_IDENTIFY_PACKET_DEVICE
|
||||
: ATA_COMMAND_IDENTIFY_DEVICE;
|
||||
|
||||
if (fChannel->SendRequest(&request, IsATAPI() ? 0
|
||||
: ATA_DEVICE_READY_REQUIRED) != B_OK) {
|
||||
if (fChannel->SendRequest(&request,
|
||||
IsATAPI() ? 0 : ATA_DEVICE_READY_REQUIRED) != B_OK) {
|
||||
TRACE_ERROR("sending identify request failed\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (fChannel->Wait(ATA_STATUS_BUSY | ATA_STATUS_DATA_REQUEST, 0,
|
||||
ATA_WAIT_ANY_BIT, 100 * 1000) != B_OK) {
|
||||
ATA_WAIT_ANY_BIT, 100 * 1000) != B_OK) {
|
||||
TRACE_ALWAYS("no data request and not busy within 100ms, assuming "
|
||||
"no device present\n");
|
||||
return B_TIMED_OUT;
|
||||
}
|
||||
|
||||
if (fChannel->Wait(ATA_STATUS_DATA_REQUEST, ATA_STATUS_BUSY,
|
||||
ATA_CHECK_ERROR_BIT | ATA_CHECK_DEVICE_FAULT, IsATAPI()
|
||||
? 20 * 1000 * 1000 : 500 * 1000) != B_OK) {
|
||||
ATA_CHECK_ERROR_BIT | ATA_CHECK_DEVICE_FAULT,
|
||||
IsATAPI() ? 20 * 1000 * 1000 : 500 * 1000) != B_OK) {
|
||||
TRACE_ERROR("timeout waiting for identify request\n");
|
||||
return B_TIMED_OUT;
|
||||
}
|
||||
|
||||
// get the infoblock
|
||||
// get the infoblock
|
||||
fChannel->ReadPIO((uint8 *)&fInfoBlock, sizeof(fInfoBlock));
|
||||
|
||||
if (fChannel->WaitDataRequest(false) != B_OK) {
|
||||
@@ -497,8 +497,9 @@ ATADevice::Identify()
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (fChannel->FinishRequest(&request, ATA_WAIT_FINISH | (IsATAPI() ? 0
|
||||
: ATA_DEVICE_READY_REQUIRED), ATA_ERROR_ABORTED) != B_OK) {
|
||||
if (fChannel->FinishRequest(&request,
|
||||
ATA_WAIT_FINISH | (IsATAPI() ? 0 : ATA_DEVICE_READY_REQUIRED),
|
||||
ATA_ERROR_ABORTED) != B_OK) {
|
||||
TRACE_ERROR("failed to finish identify request\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -523,8 +524,8 @@ ATADevice::ExecuteReadWrite(ATARequest *request, uint64 address,
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t result = fChannel->SendRequest(request, IsATAPI()
|
||||
? 0 : ATA_DEVICE_READY_REQUIRED);
|
||||
status_t result = fChannel->SendRequest(request,
|
||||
IsATAPI() ? 0 : ATA_DEVICE_READY_REQUIRED);
|
||||
if (result != B_OK) {
|
||||
TRACE_ERROR("failed to send transfer request\n");
|
||||
if (request->UseDMA())
|
||||
@@ -558,7 +559,7 @@ ATADevice::ExecuteReadWrite(ATARequest *request, uint64 address,
|
||||
}
|
||||
} else {
|
||||
if (fChannel->Wait(ATA_STATUS_DATA_REQUEST, 0, ATA_CHECK_ERROR_BIT
|
||||
| ATA_CHECK_DEVICE_FAULT, request->Timeout()) != B_OK) {
|
||||
| ATA_CHECK_DEVICE_FAULT, request->Timeout()) != B_OK) {
|
||||
TRACE_ERROR("timeout waiting for device to request data\n");
|
||||
request->SetStatus(SCSI_CMD_TIMEOUT);
|
||||
return B_TIMED_OUT;
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
|
||||
#include "ATAPrivate.h"
|
||||
|
||||
|
||||
scsi_for_sim_interface *gSCSIModule = NULL;
|
||||
device_manager_info *gDeviceManager = NULL;
|
||||
|
||||
|
||||
static status_t
|
||||
ata_sim_init_bus(device_node *node, void **cookie)
|
||||
{
|
||||
@@ -175,8 +177,7 @@ ata_channel_added(device_node *parent)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
device_attr attributes[] =
|
||||
{
|
||||
device_attr attributes[] = {
|
||||
{
|
||||
B_DEVICE_FIXED_CHILD, B_STRING_TYPE,
|
||||
{ string: SCSI_FOR_SIM_MODULE_NAME }
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
|
||||
#include "ATAPrivate.h"
|
||||
|
||||
|
||||
ATARequest::ATARequest(bool hasLock)
|
||||
: fHasLock(hasLock),
|
||||
fDevice(NULL),
|
||||
fTimeout(0),
|
||||
fBytesLeft(0),
|
||||
fIsWrite(false),
|
||||
fUseDMA(false),
|
||||
fCCB(NULL)
|
||||
:
|
||||
fHasLock(hasLock),
|
||||
fDevice(NULL),
|
||||
fTimeout(0),
|
||||
fBytesLeft(0),
|
||||
fIsWrite(false),
|
||||
fUseDMA(false),
|
||||
fCCB(NULL)
|
||||
{
|
||||
if (hasLock)
|
||||
mutex_init(&fLock, "ata request");
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
static char sTraceBuffer[256];
|
||||
static uint32 sTraceBufferOffset = 0;
|
||||
|
||||
|
||||
void
|
||||
ata_trace_printf(uint32 flags, const char *format, ...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user