* Style and automatic whitespace cleanup, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36410 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-04-22 12:03:47 +00:00
parent 8af2493444
commit a2f2499840
2 changed files with 91 additions and 75 deletions

View File

@ -3,20 +3,23 @@
* Distributed under the terms of the MIT License.
*/
#include "ahci_port.h"
#include "ahci_controller.h"
#include "util.h"
#include "ata_cmds.h"
#include "scsi_cmds.h"
#include "sata_request.h"
#include <KernelExport.h>
#include <ByteOrder.h>
#include "ahci_port.h"
#include <new>
#include <stdio.h>
#include <string.h>
#include <new>
#include <ByteOrder.h>
#include <KernelExport.h>
#include "ahci_controller.h"
#include "ahci_tracing.h"
#include "ata_cmds.h"
#include "sata_request.h"
#include "scsi_cmds.h"
#include "util.h"
#define TRACE_AHCI
#ifdef TRACE_AHCI
@ -31,7 +34,8 @@
AHCIPort::AHCIPort(AHCIController *controller, int index)
: fController(controller),
:
fController(controller),
fIndex(index),
fRegs(&controller->fRegs->port[index]),
fArea(-1),
@ -679,7 +683,8 @@ AHCIPort::ScsiReadCapacity(scsi_ccb *request)
scsiData.block_size = B_HOST_TO_BENDIAN_INT32(fSectorSize);
scsiData.lba = B_HOST_TO_BENDIAN_INT32(fSectorCount - 1);
if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
if (sg_memcpy(request->sg_list, request->sg_count, &scsiData,
sizeof(scsiData)) < B_OK) {
request->subsys_status = SCSI_DATA_RUN_ERR;
} else {
request->subsys_status = SCSI_REQ_CMP;
@ -690,10 +695,12 @@ AHCIPort::ScsiReadCapacity(scsi_ccb *request)
void
AHCIPort::ScsiReadWrite(scsi_ccb *request, uint64 lba, size_t sectorCount, bool isWrite)
AHCIPort::ScsiReadWrite(scsi_ccb *request, uint64 lba, size_t sectorCount,
bool isWrite)
{
RWTRACE("[%lld] %ld ScsiReadWrite: position %llu, size %lu, isWrite %d\n",
system_time(), find_thread(NULL), lba * 512, sectorCount * 512, isWrite);
system_time(), find_thread(NULL), lba * 512, sectorCount * 512,
isWrite);
#if 0
if (isWrite) {
@ -709,14 +716,18 @@ AHCIPort::ScsiReadWrite(scsi_ccb *request, uint64 lba, size_t sectorCount, bool
sata_request *sreq = new(std::nothrow) sata_request(request);
if (fUse48BitCommands) {
if (sectorCount > 65536)
panic("ahci: ScsiReadWrite length too large, %lu sectors", sectorCount);
if (sectorCount > 65536) {
panic("ahci: ScsiReadWrite length too large, %lu sectors",
sectorCount);
}
if (lba > MAX_SECTOR_LBA_48)
panic("achi: ScsiReadWrite position too large for 48-bit LBA\n");
sreq->set_ata48_cmd(isWrite ? 0x35 : 0x25, lba, sectorCount);
} else {
if (sectorCount > 256)
panic("ahci: ScsiReadWrite length too large, %lu sectors", sectorCount);
if (sectorCount > 256) {
panic("ahci: ScsiReadWrite length too large, %lu sectors",
sectorCount);
}
if (lba > MAX_SECTOR_LBA_28)
panic("achi: ScsiReadWrite position too large for normal LBA\n");
sreq->set_ata28_cmd(isWrite ? 0xca : 0xc8, lba, sectorCount);
@ -735,14 +746,14 @@ AHCIPort::ExecuteSataRequest(sata_request *request, bool isWrite)
int prdEntrys;
if (request->ccb() && request->ccb()->data_length)
if (request->ccb() && request->ccb()->data_length) {
FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT,
request->ccb()->sg_list, request->ccb()->sg_count,
request->ccb()->data_length);
else if (request->data() && request->size())
} else if (request->data() && request->size()) {
FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT,
request->data(), request->size());
else
} else
prdEntrys = 0;
FLOW("prdEntrys %d\n", prdEntrys);
@ -885,7 +896,8 @@ AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
case SCSI_OP_WRITE_6:
{
scsi_cmd_rw_6 *cmd = (scsi_cmd_rw_6 *)request->cdb;
uint32 position = ((uint32)cmd->high_lba << 16) | ((uint32)cmd->mid_lba << 8) | (uint32)cmd->low_lba;
uint32 position = ((uint32)cmd->high_lba << 16)
| ((uint32)cmd->mid_lba << 8) | (uint32)cmd->low_lba;
size_t length = cmd->length != 0 ? cmd->length : 256;
bool isWrite = request->cdb[0] == SCSI_OP_WRITE_6;
ScsiReadWrite(request, position, length, isWrite);
@ -901,7 +913,8 @@ AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
if (length) {
ScsiReadWrite(request, position, length, isWrite);
} else {
TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
TRACE("AHCIPort::ScsiExecuteRequest error: transfer without "
"data!\n");
request->subsys_status = SCSI_REQ_INVALID;
gSCSI->finished(request, 1);
}
@ -917,14 +930,16 @@ AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
if (length) {
ScsiReadWrite(request, position, length, isWrite);
} else {
TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
TRACE("AHCIPort::ScsiExecuteRequest error: transfer without "
"data!\n");
request->subsys_status = SCSI_REQ_INVALID;
gSCSI->finished(request, 1);
}
break;
}
default:
TRACE("AHCIPort::ScsiExecuteRequest port %d unsupported request opcode 0x%02x\n", fIndex, request->cdb[0]);
TRACE("AHCIPort::ScsiExecuteRequest port %d unsupported request "
"opcode 0x%02x\n", fIndex, request->cdb[0]);
request->subsys_status = SCSI_REQ_ABORTED;
gSCSI->finished(request, 1);
}
@ -954,11 +969,12 @@ AHCIPort::ScsiResetDevice()
void
AHCIPort::ScsiGetRestrictions(bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks)
AHCIPort::ScsiGetRestrictions(bool *isATAPI, bool *noAutoSense,
uint32 *maxBlocks)
{
*isATAPI = fIsATAPI;
*noAutoSense = fIsATAPI; // emulated auto sense for ATA, but not ATAPI
*maxBlocks = fUse48BitCommands ? 65536 : 256;
TRACE("AHCIPort::ScsiGetRestrictions port %d: isATAPI %d, noAutoSense %d, maxBlocks %lu\n",
fIndex, *isATAPI, *noAutoSense, *maxBlocks);
TRACE("AHCIPort::ScsiGetRestrictions port %d: isATAPI %d, noAutoSense %d, "
"maxBlocks %lu\n", fIndex, *isATAPI, *noAutoSense, *maxBlocks);
}

View File

@ -3,28 +3,33 @@
* Distributed under the terms of the MIT License.
*/
#include "sata_request.h"
#include "scsi_cmds.h"
#include <string.h>
#include "sata_request.h"
#include "scsi_cmds.h"
sata_request::sata_request()
: fCcb(NULL)
, fIsATAPI(false)
, fCompletionSem(create_sem(0, "sata completion"))
, fCompletionStatus(0)
, fData(NULL)
, fDataSize(0)
:
fCcb(NULL),
fIsATAPI(false),
fCompletionSem(create_sem(0, "sata completion")),
fCompletionStatus(0),
fData(NULL),
fDataSize(0)
{
}
sata_request::sata_request(scsi_ccb *ccb)
: fCcb(ccb)
, fIsATAPI(false)
, fCompletionSem(-1)
, fCompletionStatus(0)
, fData(NULL)
, fDataSize(0)
:
fCcb(ccb),
fIsATAPI(false),
fCompletionSem(-1),
fCompletionStatus(0),
fData(NULL),
fDataSize(0)
{
}
@ -122,13 +127,14 @@ sata_request::finish(int tfd, size_t bytesTransfered)
fCcb->subsys_status = SCSI_REQ_CMP_ERR;
if (fIsATAPI) {
if (!is_test_unit_ready()) {
dprintf("ahci: sata_request::finish ATAPI packet %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x (len %d)\n",
dprintf("ahci: sata_request::finish ATAPI packet %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x (len %d)\n",
fCcb->cdb[0], fCcb->cdb[1], fCcb->cdb[2], fCcb->cdb[3],
fCcb->cdb[4], fCcb->cdb[5], fCcb->cdb[6], fCcb->cdb[7],
fCcb->cdb[8], fCcb->cdb[9], fCcb->cdb[10], fCcb->cdb[11],
fCcb->cdb[12], fCcb->cdb[13], fCcb->cdb[14], fCcb->cdb[15],
fCcb->cdb_length);
fCcb->cdb[8], fCcb->cdb[9], fCcb->cdb[10],
fCcb->cdb[11], fCcb->cdb[12], fCcb->cdb[13],
fCcb->cdb[14], fCcb->cdb[15], fCcb->cdb_length);
}
fCcb->device_status = SCSI_STATUS_CHECK_CONDITION;
@ -189,9 +195,3 @@ sata_request::completition_status()
if (fCcb) panic("wrong usage");
return fCompletionStatus;
}