Fixed all warnings in scsi2ata.c.
Style cleanup. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10297 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -25,30 +25,40 @@
|
||||
// maximum number send tries before giving up
|
||||
#define MAX_FAILED_SEND 1
|
||||
|
||||
// busy-wait for data request going high
|
||||
bool wait_for_drq( ide_device_info *device )
|
||||
|
||||
/** busy-wait for data request going high */
|
||||
|
||||
bool
|
||||
wait_for_drq(ide_device_info *device)
|
||||
{
|
||||
return ide_wait(device, ide_status_drq, 0, true, 10000000);
|
||||
}
|
||||
|
||||
|
||||
// busy-wait for data request going low
|
||||
bool wait_for_drqdown( ide_device_info *device )
|
||||
/** busy-wait for data request going low */
|
||||
|
||||
bool
|
||||
wait_for_drqdown(ide_device_info *device)
|
||||
{
|
||||
return ide_wait(device, 0, ide_status_drq, true, 1000000);
|
||||
}
|
||||
|
||||
|
||||
// busy-wait for device ready
|
||||
bool wait_for_drdy( ide_device_info *device )
|
||||
/** busy-wait for device ready */
|
||||
|
||||
bool
|
||||
wait_for_drdy(ide_device_info *device)
|
||||
{
|
||||
return ide_wait(device, ide_status_drdy, ide_status_bsy, false, 5000000);
|
||||
}
|
||||
|
||||
|
||||
// reset entire IDE bus
|
||||
// all active request apart from <ignore> are resubmitted
|
||||
bool reset_bus( ide_device_info *device, ide_qrequest *ignore )
|
||||
/** reset entire IDE bus
|
||||
* all active request apart from <ignore> are resubmitted
|
||||
*/
|
||||
|
||||
bool
|
||||
reset_bus(ide_device_info *device, ide_qrequest *ignore)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
ide_controller_interface *controller = bus->controller;
|
||||
@@ -76,8 +86,7 @@ bool reset_bus( ide_device_info *device, ide_qrequest *ignore )
|
||||
|
||||
spin(5);
|
||||
|
||||
if( controller->write_device_control( channel,
|
||||
ide_devctrl_nien | ide_devctrl_bit3 ) != B_OK )
|
||||
if (controller->write_device_control(channel, ide_devctrl_nien | ide_devctrl_bit3) != B_OK)
|
||||
goto err0;
|
||||
|
||||
// let devices wake up
|
||||
@@ -85,7 +94,6 @@ bool reset_bus( ide_device_info *device, ide_qrequest *ignore )
|
||||
|
||||
// ouch, we have to wait up to 31 seconds!
|
||||
if (!ide_wait(device, 0, ide_status_bsy, true, 31000000)) {
|
||||
|
||||
// as we don't know which of the devices is broken
|
||||
// we leave them both alive
|
||||
if (controller->write_device_control(channel, ide_devctrl_bit3) != B_OK)
|
||||
@@ -115,10 +123,13 @@ err1:
|
||||
}
|
||||
|
||||
|
||||
// execute packet device reset.
|
||||
// resets entire bus on fail or if device is not atapi;
|
||||
// all requests but <ignore> are resubmitted
|
||||
bool reset_device( ide_device_info *device, ide_qrequest *ignore )
|
||||
/** execute packet device reset.
|
||||
* resets entire bus on fail or if device is not atapi;
|
||||
* all requests but <ignore> are resubmitted
|
||||
*/
|
||||
|
||||
bool
|
||||
reset_device(ide_device_info *device, ide_qrequest *ignore)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
status_t res;
|
||||
@@ -169,9 +180,12 @@ err:
|
||||
return reset_bus(device, ignore);
|
||||
}
|
||||
|
||||
// new_state must be either accessing, async_waiting or sync_waiting
|
||||
// param_mask must not include command register
|
||||
bool send_command( ide_device_info *device, ide_qrequest *qrequest,
|
||||
/** new_state must be either accessing, async_waiting or sync_waiting
|
||||
* param_mask must not include command register
|
||||
*/
|
||||
|
||||
bool
|
||||
send_command(ide_device_info *device, ide_qrequest *qrequest,
|
||||
bool need_drdy, uint32 timeout, ide_bus_state new_state)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
@@ -240,9 +254,8 @@ retry:
|
||||
return false;
|
||||
}
|
||||
|
||||
if( need_drdy &&
|
||||
(bus->controller->get_altstatus( bus->channel ) & ide_status_drdy) == 0 )
|
||||
{
|
||||
if (need_drdy
|
||||
&& (bus->controller->get_altstatus(bus->channel) & ide_status_drdy) == 0) {
|
||||
SHOW_FLOW0(3, "drdy not set");
|
||||
device->subsys_status = SCSI_SEQUENCE_FAIL;
|
||||
return false;
|
||||
@@ -266,7 +279,6 @@ retry:
|
||||
// waiting at least 50 µs seems(!) to solve this
|
||||
while (system_time() - irq_disabled_at < MAX_IRQ_DELAY)
|
||||
spin(1);
|
||||
|
||||
}
|
||||
|
||||
// if we will start waiting once the command is sent, we have to
|
||||
@@ -293,9 +305,8 @@ retry:
|
||||
goto err1;
|
||||
|
||||
// start waiting now; also un-blocks IRQ handler (see above)
|
||||
if( new_state != ide_state_accessing ) {
|
||||
if (new_state != ide_state_accessing)
|
||||
start_waiting(bus, timeout, new_state);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -311,13 +322,16 @@ err:
|
||||
}
|
||||
|
||||
|
||||
// busy-wait for device
|
||||
// mask - bits of status register that must be set
|
||||
// not_mask - bits of status register that must not be set
|
||||
// check_err - abort if error bit is set
|
||||
// timeout - waiting timeout
|
||||
// return: true on success
|
||||
bool ide_wait( ide_device_info *device, int mask, int not_mask,
|
||||
/** busy-wait for device
|
||||
* mask - bits of status register that must be set
|
||||
* not_mask - bits of status register that must not be set
|
||||
* check_err - abort if error bit is set
|
||||
* timeout - waiting timeout
|
||||
* return: true on success
|
||||
*/
|
||||
|
||||
bool
|
||||
ide_wait(ide_device_info *device, int mask, int not_mask,
|
||||
bool check_err, bigtime_t timeout)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
@@ -333,8 +347,7 @@ bool ide_wait( ide_device_info *device, int mask, int not_mask,
|
||||
|
||||
status = bus->controller->get_altstatus(bus->channel);
|
||||
|
||||
if( (status & mask) == mask &&
|
||||
(status & not_mask) == 0 )
|
||||
if ((status & mask) == mask && (status & not_mask) == 0)
|
||||
return true;
|
||||
|
||||
if (check_err && (status & ide_status_err) != 0) {
|
||||
@@ -357,12 +370,15 @@ bool ide_wait( ide_device_info *device, int mask, int not_mask,
|
||||
}
|
||||
|
||||
|
||||
// tell device to continue queued command
|
||||
// on return, no waiting is active!
|
||||
// tag - will contain tag of command to be continued
|
||||
// return: true - request continued
|
||||
// false - something went wrong; sense set
|
||||
bool device_start_service( ide_device_info *device, int *tag )
|
||||
/** tell device to continue queued command
|
||||
* on return, no waiting is active!
|
||||
* tag - will contain tag of command to be continued
|
||||
* return: true - request continued
|
||||
* false - something went wrong; sense set
|
||||
*/
|
||||
|
||||
bool
|
||||
device_start_service(ide_device_info *device, int *tag)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
|
||||
@@ -409,7 +425,6 @@ bool device_start_service( ide_device_info *device, int *tag )
|
||||
*tag = device->tf.queued.tag;
|
||||
|
||||
FAST_LOG2(bus->log, ev_ide_device_start_service2, device->is_device1, *tag);
|
||||
|
||||
return true;
|
||||
|
||||
err:
|
||||
@@ -418,8 +433,10 @@ err:
|
||||
}
|
||||
|
||||
|
||||
// check device whether it wants to continue queued request
|
||||
bool check_service_req( ide_device_info *device )
|
||||
/** check device whether it wants to continue queued request */
|
||||
|
||||
bool
|
||||
check_service_req(ide_device_info *device)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
int status;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the Haiku License.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -66,8 +66,11 @@ static fast_log_event_type ide_events[] =
|
||||
static void disconnect_worker( ide_bus_info *bus, void *arg );
|
||||
static void set_check_condition( ide_qrequest *qrequest );
|
||||
|
||||
// check whether this request can be within device
|
||||
static inline bool is_queuable( ide_device_info *device, scsi_ccb *request )
|
||||
|
||||
/** check whether this request can be within device */
|
||||
|
||||
static inline bool
|
||||
is_queuable(ide_device_info *device, scsi_ccb *request)
|
||||
{
|
||||
int opcode = request->cdb[0];
|
||||
|
||||
@@ -81,13 +84,8 @@ static inline bool is_queuable( ide_device_info *device, scsi_ccb *request )
|
||||
|
||||
// for atapi, all commands could be queued, but all
|
||||
// atapi devices I know don't support queuing anyway
|
||||
if( opcode == SCSI_OP_READ_6 ||
|
||||
opcode == SCSI_OP_WRITE_6 ||
|
||||
opcode == SCSI_OP_READ_10 ||
|
||||
opcode == SCSI_OP_WRITE_10 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return opcode == SCSI_OP_READ_6 || opcode == SCSI_OP_WRITE_6
|
||||
|| opcode == SCSI_OP_READ_10 || opcode == SCSI_OP_WRITE_10;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -46,8 +46,11 @@
|
||||
// internal error code if scatter gather table is too short
|
||||
#define ERR_TOO_BIG (B_ERRORS_END + 1)
|
||||
|
||||
// prepare PIO transfer
|
||||
void prep_PIO_transfer( ide_device_info *device, ide_qrequest *qrequest )
|
||||
|
||||
/** prepare PIO transfer */
|
||||
|
||||
void
|
||||
prep_PIO_transfer(ide_device_info *device, ide_qrequest *qrequest)
|
||||
{
|
||||
SHOW_FLOW0(4, "");
|
||||
|
||||
@@ -58,8 +61,11 @@ void prep_PIO_transfer( ide_device_info *device, ide_qrequest *qrequest )
|
||||
qrequest->request->data_resid = qrequest->request->data_len;
|
||||
}
|
||||
|
||||
// transfer virtually continuous data
|
||||
static inline status_t transfer_PIO_virtcont( ide_device_info *device, char *virt_addr, int length,
|
||||
|
||||
/** transfer virtually continuous data */
|
||||
|
||||
static inline status_t
|
||||
transfer_PIO_virtcont(ide_device_info *device, char *virt_addr, int length,
|
||||
bool write, int *transferred)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
@@ -92,7 +98,6 @@ static inline status_t transfer_PIO_virtcont( ide_device_info *device, char *vir
|
||||
|
||||
if (device->has_odd_byte)
|
||||
device->odd_byte = *virt_addr;
|
||||
|
||||
} else {
|
||||
// if we read one byte too much last time, push it into current chunk
|
||||
if (device->has_odd_byte) {
|
||||
@@ -129,7 +134,8 @@ static inline status_t transfer_PIO_virtcont( ide_device_info *device, char *vir
|
||||
}
|
||||
|
||||
|
||||
// transmit physically continuous data
|
||||
/** transmit physically continuous data */
|
||||
|
||||
static inline status_t
|
||||
transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr,
|
||||
int length, bool write, int *transferred)
|
||||
@@ -162,7 +168,6 @@ transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr,
|
||||
|
||||
err = transfer_PIO_virtcont(device, (char *)virt_addr,
|
||||
cur_len, write, transferred);
|
||||
|
||||
if (err != B_OK) {
|
||||
unmap_mainmemory(virt_addr);
|
||||
return err;
|
||||
@@ -178,9 +183,10 @@ transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr,
|
||||
}
|
||||
|
||||
|
||||
// transfer PIO block from/to buffer
|
||||
static inline int transfer_PIO_block( ide_device_info *device, int length, bool write,
|
||||
int *transferred )
|
||||
/** transfer PIO block from/to buffer */
|
||||
|
||||
static inline int
|
||||
transfer_PIO_block(ide_device_info *device, int length, bool write, int *transferred)
|
||||
{
|
||||
// data is usually split up into multiple scatter/gather blocks
|
||||
while (length > 0) {
|
||||
@@ -219,8 +225,11 @@ static inline int transfer_PIO_block( ide_device_info *device, int length, bool
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// write zero data (required for ATAPI if we ran out of data)
|
||||
static void write_discard_PIO( ide_device_info *device, int length )
|
||||
|
||||
/** write zero data (required for ATAPI if we ran out of data) */
|
||||
|
||||
static void
|
||||
write_discard_PIO(ide_device_info *device, int length)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
uint8 buffer[32];
|
||||
@@ -244,8 +253,10 @@ static void write_discard_PIO( ide_device_info *device, int length )
|
||||
}
|
||||
|
||||
|
||||
// read PIO data and discard it (required for ATAPI if buffer was too small)
|
||||
static void read_discard_PIO( ide_device_info *device, int length )
|
||||
/** read PIO data and discard it (required for ATAPI if buffer was too small) */
|
||||
|
||||
static void
|
||||
read_discard_PIO(ide_device_info *device, int length)
|
||||
{
|
||||
ide_bus_info *bus = device->bus;
|
||||
uint8 buffer[32];
|
||||
@@ -264,12 +275,15 @@ static void read_discard_PIO( ide_device_info *device, int length )
|
||||
}
|
||||
|
||||
|
||||
// write PIO data
|
||||
// return: there are 3 possible results
|
||||
// NO_ERROR - everything's nice and groovy
|
||||
// ERR_TOO_BIG - data buffer was too short, remaining data got discarded
|
||||
// B_ERROR - something serious went wrong, sense data was set
|
||||
status_t write_PIO_block( ide_qrequest *qrequest, int length )
|
||||
/** write PIO data
|
||||
* return: there are 3 possible results
|
||||
* NO_ERROR - everything's nice and groovy
|
||||
* ERR_TOO_BIG - data buffer was too short, remaining data got discarded
|
||||
* B_ERROR - something serious went wrong, sense data was set
|
||||
*/
|
||||
|
||||
status_t
|
||||
write_PIO_block(ide_qrequest *qrequest, int length)
|
||||
{
|
||||
ide_device_info *device = qrequest->device;
|
||||
int transferred;
|
||||
@@ -312,9 +326,12 @@ status_t write_PIO_block( ide_qrequest *qrequest, int length )
|
||||
}
|
||||
|
||||
|
||||
// read PIO data
|
||||
// return: see write_PIO_block
|
||||
status_t read_PIO_block( ide_qrequest *qrequest, int length )
|
||||
/** read PIO data
|
||||
* return: see write_PIO_block
|
||||
*/
|
||||
|
||||
status_t
|
||||
read_PIO_block(ide_qrequest *qrequest, int length)
|
||||
{
|
||||
ide_device_info *device = qrequest->device;
|
||||
int transferred;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -27,30 +27,26 @@ ata_mode_sense_10(ide_device_info *device, ide_qrequest *qrequest)
|
||||
scsi_mode_param_header_10 param_header;
|
||||
scsi_modepage_contr contr;
|
||||
scsi_mode_param_block_desc block_desc;
|
||||
size_t total_length =
|
||||
sizeof(scsi_mode_param_header_10) +
|
||||
sizeof(scsi_mode_param_block_desc) +
|
||||
sizeof(scsi_modepage_contr);
|
||||
size_t total_length = sizeof(scsi_mode_param_header_10)
|
||||
+ sizeof(scsi_mode_param_block_desc)
|
||||
+ sizeof(scsi_modepage_contr);
|
||||
scsi_mode_param_dev_spec_da devspec = {
|
||||
res0_0 : 0,
|
||||
DPOFUA : 0,
|
||||
res0_6 : 0,
|
||||
WP : 0
|
||||
};
|
||||
int allocation_length;
|
||||
uint32 allocation_length;
|
||||
|
||||
SHOW_ERROR0( 0, "Hi!" );
|
||||
SHOW_FLOW0(1, "Hi!");
|
||||
|
||||
allocation_length = ((int16)cmd->high_allocation_length << 8)
|
||||
| cmd->low_allocation_length;
|
||||
|
||||
// we answer control page requests and "all pages" requests
|
||||
// (as the latter are the same as the first)
|
||||
if( (cmd->page_code != SCSI_MODEPAGE_CONTROL &&
|
||||
cmd->page_code != SCSI_MODEPAGE_ALL) ||
|
||||
(cmd->PC != SCSI_MODE_SENSE_PC_CURRENT &&
|
||||
cmd->PC != SCSI_MODE_SENSE_PC_SAVED))
|
||||
{
|
||||
if ((cmd->page_code != SCSI_MODEPAGE_CONTROL && cmd->page_code != SCSI_MODEPAGE_ALL)
|
||||
|| (cmd->PC != SCSI_MODE_SENSE_PC_CURRENT && cmd->PC != SCSI_MODE_SENSE_PC_SAVED)) {
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_CDB_FIELD);
|
||||
return;
|
||||
}
|
||||
@@ -63,8 +59,7 @@ ata_mode_sense_10(ide_device_info *device, ide_qrequest *qrequest)
|
||||
param_header.low_block_desc_len = sizeof(scsi_mode_param_block_desc);
|
||||
param_header.high_block_desc_len = 0;
|
||||
|
||||
copy_sg_data( request, 0, allocation_length,
|
||||
¶m_header, sizeof( param_header ), false );
|
||||
copy_sg_data(request, 0, allocation_length, ¶m_header, sizeof(param_header), false);
|
||||
|
||||
/*block_desc = (scsi_mode_param_block_desc *)(request->data
|
||||
+ sizeof(*param_header));*/
|
||||
@@ -86,16 +81,15 @@ ata_mode_sense_10(ide_device_info *device, ide_qrequest *qrequest)
|
||||
memset(&contr, 0, sizeof(contr));
|
||||
contr.RLEC = false;
|
||||
contr.DQue = !device->CQ_enabled;
|
||||
contr.QErr = false; // when a command fails we requeue all
|
||||
contr.QErr = false;
|
||||
// when a command fails we requeue all
|
||||
// lost commands automagically
|
||||
contr.QAM = SCSI_QAM_UNRESTRICTED;
|
||||
|
||||
copy_sg_data( request,
|
||||
sizeof( param_header )
|
||||
copy_sg_data(request, sizeof(param_header)
|
||||
+ ((uint16)param_header.high_block_desc_len << 8)
|
||||
+ param_header.low_block_desc_len,
|
||||
allocation_length,
|
||||
&contr, sizeof( contr ), false );
|
||||
allocation_length, &contr, sizeof(contr), false);
|
||||
|
||||
// the number of bytes that were transferred to buffer is
|
||||
// restricted by allocation length and by request data buffer size
|
||||
@@ -103,12 +97,13 @@ ata_mode_sense_10(ide_device_info *device, ide_qrequest *qrequest)
|
||||
total_length = min(total_length, request->data_len);
|
||||
|
||||
request->data_resid = request->data_len - total_length;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// emulate modifying control page
|
||||
static bool ata_mode_select_contrpage( ide_device_info *device, ide_qrequest *qrequest,
|
||||
/** emulate modifying control page */
|
||||
|
||||
static bool
|
||||
ata_mode_select_control_page(ide_device_info *device, ide_qrequest *qrequest,
|
||||
scsi_modepage_contr *page)
|
||||
{
|
||||
if (page->header.page_length != sizeof(*page) - sizeof(page->header)) {
|
||||
@@ -122,15 +117,17 @@ static bool ata_mode_select_contrpage( ide_device_info *device, ide_qrequest *qr
|
||||
}
|
||||
|
||||
|
||||
// emulate MODE SELECT 10 command
|
||||
static void ata_mode_select_10( ide_device_info *device, ide_qrequest *qrequest )
|
||||
/** emulate MODE SELECT 10 command */
|
||||
|
||||
static void
|
||||
ata_mode_select_10(ide_device_info *device, ide_qrequest *qrequest)
|
||||
{
|
||||
scsi_ccb *request = qrequest->request;
|
||||
scsi_cmd_mode_select_10 *cmd = (scsi_cmd_mode_select_10 *)request->cdb;
|
||||
scsi_mode_param_header_10 param_header;
|
||||
scsi_modepage_header page_header;
|
||||
int total_length;
|
||||
uint modepage_offset;
|
||||
uint32 total_length;
|
||||
uint32 modepage_offset;
|
||||
char modepage_buffer[64]; // !!! enlarge this to support longer mode pages
|
||||
|
||||
if (cmd->SP || cmd->PF != 1) {
|
||||
@@ -139,26 +136,24 @@ static void ata_mode_select_10( ide_device_info *device, ide_qrequest *qrequest
|
||||
}
|
||||
|
||||
total_length = min(request->data_len,
|
||||
((uint16)cmd->high_param_list_length << 8) | cmd->low_param_list_length);
|
||||
((uint16)cmd->high_param_list_length << 8) | (uint32)cmd->low_param_list_length);
|
||||
|
||||
// first, retrieve page header to get size of different chunks
|
||||
//param_header = (scsi_mode_param_header_10 *)request->data;
|
||||
if( !copy_sg_data( request, 0, total_length,
|
||||
¶m_header, sizeof( param_header ), true ))
|
||||
if (!copy_sg_data(request, 0, total_length, ¶m_header, sizeof(param_header), true))
|
||||
goto err;
|
||||
|
||||
total_length = min( total_length,
|
||||
(((uint16)param_header.high_mode_data_len << 8) | param_header.low_mode_data_len) + 1 );
|
||||
total_length = min(total_length, (((uint16)param_header.high_mode_data_len << 8)
|
||||
| param_header.low_mode_data_len) + 1UL);
|
||||
|
||||
// this is the start of the first mode page;
|
||||
// we ignore the block descriptor silently
|
||||
modepage_offset =
|
||||
sizeof( param_header ) +
|
||||
(((uint16)param_header.high_block_desc_len << 8) | param_header.low_block_desc_len);
|
||||
modepage_offset = sizeof(param_header) + (((uint16)param_header.high_block_desc_len << 8)
|
||||
| param_header.low_block_desc_len);
|
||||
|
||||
// go through list of pages
|
||||
while (modepage_offset < total_length) {
|
||||
int page_len;
|
||||
uint32 page_len;
|
||||
|
||||
// get header to know how long page is
|
||||
if (!copy_sg_data(request, modepage_offset, total_length,
|
||||
@@ -181,14 +176,13 @@ static void ata_mode_select_10( ide_device_info *device, ide_qrequest *qrequest
|
||||
// currently, we only support the control mode page
|
||||
switch (page_header.page_code) {
|
||||
case SCSI_MODEPAGE_CONTROL:
|
||||
if( !ata_mode_select_contrpage( device, qrequest,
|
||||
if (!ata_mode_select_control_page(device, qrequest,
|
||||
(scsi_modepage_contr *)modepage_buffer))
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
set_sense( device,
|
||||
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_PARAM_LIST_FIELD );
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_PARAM_LIST_FIELD);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,18 +197,19 @@ static void ata_mode_select_10( ide_device_info *device, ide_qrequest *qrequest
|
||||
|
||||
// if we arrive here, data length was incorrect
|
||||
err:
|
||||
set_sense( device,
|
||||
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_PARAM_LIST_LENGTH_ERR );
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_PARAM_LIST_LENGTH_ERR);
|
||||
}
|
||||
|
||||
|
||||
// emulate TEST UNIT READY
|
||||
static bool ata_tur( ide_device_info *device, ide_qrequest *qrequest )
|
||||
/** emulate TEST UNIT READY */
|
||||
|
||||
static bool
|
||||
ata_test_unit_ready(ide_device_info *device, ide_qrequest *qrequest)
|
||||
{
|
||||
SHOW_FLOW0(3, "");
|
||||
|
||||
if( !device->infoblock.RMSN_supported ||
|
||||
device->infoblock._127_RMSN_support != 1 )
|
||||
if (!device->infoblock.RMSN_supported
|
||||
|| device->infoblock._127_RMSN_support != 1)
|
||||
return true;
|
||||
|
||||
// ask device about status
|
||||
@@ -229,8 +224,7 @@ static bool ata_tur( ide_device_info *device, ide_qrequest *qrequest )
|
||||
// we don't want to loose media change (request) reports
|
||||
if (!check_output(device, true,
|
||||
ide_error_nm | ide_error_abrt | ide_error_mcr | ide_error_mc,
|
||||
false ))
|
||||
{
|
||||
false)) {
|
||||
// SCSI spec is unclear here: we shouldn't report "media change (request)"
|
||||
// but what to do if there is one? anyway - we report them
|
||||
;
|
||||
@@ -240,8 +234,10 @@ static bool ata_tur( ide_device_info *device, ide_qrequest *qrequest )
|
||||
}
|
||||
|
||||
|
||||
// flush internal device cache
|
||||
static bool ata_flush_cache( ide_device_info *device, ide_qrequest *qrequest )
|
||||
/** flush internal device cache */
|
||||
|
||||
static bool
|
||||
ata_flush_cache(ide_device_info *device, ide_qrequest *qrequest)
|
||||
{
|
||||
// we should also ask for FLUSH CACHE support, but everyone denies it
|
||||
// (looks like they cheat to gain some performance advantage, but
|
||||
@@ -263,9 +259,12 @@ static bool ata_flush_cache( ide_device_info *device, ide_qrequest *qrequest )
|
||||
}
|
||||
|
||||
|
||||
// load or eject medium
|
||||
// load = true - load medium
|
||||
static bool ata_load_eject( ide_device_info *device, ide_qrequest *qrequest, bool load )
|
||||
/** load or eject medium
|
||||
* load = true - load medium
|
||||
*/
|
||||
|
||||
static bool
|
||||
ata_load_eject(ide_device_info *device, ide_qrequest *qrequest, bool load)
|
||||
{
|
||||
if (load) {
|
||||
// ATA doesn't support loading
|
||||
@@ -285,22 +284,26 @@ static bool ata_load_eject( ide_device_info *device, ide_qrequest *qrequest, boo
|
||||
}
|
||||
|
||||
|
||||
// emulate PREVENT ALLOW command
|
||||
static bool ata_prevent_allow( ide_device_info *device, bool prevent )
|
||||
/** emulate PREVENT ALLOW command */
|
||||
|
||||
static bool
|
||||
ata_prevent_allow(ide_device_info *device, bool prevent)
|
||||
{
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_ILL_FUNCTION);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// emulate INQUIRY command
|
||||
static void ata_inquiry( ide_device_info *device, ide_qrequest *qrequest )
|
||||
/** emulate INQUIRY command */
|
||||
|
||||
static void
|
||||
ata_inquiry(ide_device_info *device, ide_qrequest *qrequest)
|
||||
{
|
||||
scsi_ccb *request = qrequest->request;
|
||||
scsi_res_inquiry data;
|
||||
scsi_cmd_inquiry *cmd = (scsi_cmd_inquiry *)request->cdb;
|
||||
uint allocation_length = cmd->allocation_length;
|
||||
int transfer_size;
|
||||
uint32 allocation_length = cmd->allocation_length;
|
||||
uint32 transfer_size;
|
||||
|
||||
if (cmd->EVPD || cmd->page_code) {
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_CDB_FIELD);
|
||||
@@ -408,7 +411,7 @@ ata_exec_io(ide_device_info *device, ide_qrequest *qrequest)
|
||||
|
||||
switch (request->cdb[0]) {
|
||||
case SCSI_OP_TUR:
|
||||
ata_tur( device, qrequest );
|
||||
ata_test_unit_ready(device, qrequest);
|
||||
break;
|
||||
|
||||
case SCSI_OP_REQUEST_SENSE:
|
||||
@@ -463,13 +466,15 @@ ata_exec_io(ide_device_info *device, ide_qrequest *qrequest)
|
||||
if (cmd->LoEj)
|
||||
ata_load_eject(device, qrequest, cmd->start);
|
||||
|
||||
break; }
|
||||
break;
|
||||
}
|
||||
|
||||
case SCSI_OP_PREVENT_ALLOW: {
|
||||
scsi_cmd_prevent_allow *cmd = (scsi_cmd_prevent_allow *)request->cdb;
|
||||
|
||||
ata_prevent_allow(device, cmd->prevent);
|
||||
break; }
|
||||
break;
|
||||
}
|
||||
|
||||
case SCSI_OP_READ_CAPACITY:
|
||||
read_capacity(device, qrequest);
|
||||
@@ -499,10 +504,11 @@ ata_exec_io(ide_device_info *device, ide_qrequest *qrequest)
|
||||
|
||||
length = cmd->length != 0 ? cmd->length : 256;
|
||||
|
||||
SHOW_FLOW( 3, "READ6/WRITE6 pos=%ux, length=%ux", (uint)pos, (uint)length );
|
||||
SHOW_FLOW(3, "READ6/WRITE6 pos=%lx, length=%lx", pos, length);
|
||||
|
||||
ata_send_rw(device, qrequest, pos, length, cmd->opcode == SCSI_OP_WRITE_6);
|
||||
return; }
|
||||
return;
|
||||
}
|
||||
|
||||
case SCSI_OP_READ_10:
|
||||
case SCSI_OP_WRITE_10: {
|
||||
@@ -521,11 +527,11 @@ ata_exec_io(ide_device_info *device, ide_qrequest *qrequest)
|
||||
// we cannot transfer zero blocks (apart from LBA48)
|
||||
finish_request(qrequest, false);
|
||||
}
|
||||
return; }
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
set_sense( device,
|
||||
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_OPCODE );
|
||||
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_OPCODE);
|
||||
}
|
||||
|
||||
finish_checksense(qrequest);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the Haiku License.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
//#define TRACE_SYNC
|
||||
#ifdef TRACE_SYNC
|
||||
# define TRACE(x) dprintf x
|
||||
# define TRACE(x) { dprintf("%s(): ", __FUNCTION__); dprintf x ; }
|
||||
#else
|
||||
# define TRACE(x) ;
|
||||
#endif
|
||||
@@ -34,7 +34,7 @@ ide_dpc(void *arg)
|
||||
ide_qrequest *qrequest;
|
||||
ide_device_info *device;
|
||||
|
||||
TRACE(("ide_dpc()\n"));
|
||||
TRACE(("\n"));
|
||||
|
||||
//snooze(500000);
|
||||
|
||||
@@ -69,7 +69,6 @@ ide_dpc(void *arg)
|
||||
FAST_LOG0(bus->log, ev_ide_dpc_service);
|
||||
|
||||
device = get_current_device(bus);
|
||||
|
||||
if (device == NULL) {
|
||||
// got an interrupt from a non-existing device
|
||||
// either this is a spurious interrupt or there *is* a device
|
||||
@@ -99,7 +98,7 @@ ide_irq_handler(ide_bus_info *bus, uint8 status)
|
||||
{
|
||||
ide_device_info *device;
|
||||
|
||||
TRACE(("ide_irq_handler()\n"));
|
||||
TRACE(("\n"));
|
||||
FAST_LOG0(bus->log, ev_ide_irq_handle);
|
||||
|
||||
// we need to lock bus to have a solid bus state
|
||||
|
||||
@@ -43,15 +43,15 @@
|
||||
#endif
|
||||
|
||||
#ifndef debug_level_flow
|
||||
# define debug_level_flow 3
|
||||
# define debug_level_flow 4
|
||||
#endif
|
||||
|
||||
#ifndef debug_level_info
|
||||
# define debug_level_info 2
|
||||
# define debug_level_info 4
|
||||
#endif
|
||||
|
||||
#ifndef debug_level_error
|
||||
# define debug_level_error 1
|
||||
# define debug_level_error 4
|
||||
#endif
|
||||
|
||||
#define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": "
|
||||
|
||||
Reference in New Issue
Block a user