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:
Axel Dörfler
2004-11-30 17:24:04 +00:00
parent 4e9c28deed
commit d99c404f77
7 changed files with 682 additions and 645 deletions
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -25,30 +25,40 @@
// maximum number send tries before giving up // maximum number send tries before giving up
#define MAX_FAILED_SEND 1 #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); return ide_wait(device, ide_status_drq, 0, true, 10000000);
} }
// busy-wait for data request going low /** busy-wait for data request going low */
bool wait_for_drqdown( ide_device_info *device )
bool
wait_for_drqdown(ide_device_info *device)
{ {
return ide_wait(device, 0, ide_status_drq, true, 1000000); return ide_wait(device, 0, ide_status_drq, true, 1000000);
} }
// busy-wait for device ready /** busy-wait for device ready */
bool wait_for_drdy( ide_device_info *device )
bool
wait_for_drdy(ide_device_info *device)
{ {
return ide_wait(device, ide_status_drdy, ide_status_bsy, false, 5000000); return ide_wait(device, ide_status_drdy, ide_status_bsy, false, 5000000);
} }
// reset entire IDE bus /** reset entire IDE bus
// all active request apart from <ignore> are resubmitted * all active request apart from <ignore> are resubmitted
bool reset_bus( ide_device_info *device, ide_qrequest *ignore ) */
bool
reset_bus(ide_device_info *device, ide_qrequest *ignore)
{ {
ide_bus_info *bus = device->bus; ide_bus_info *bus = device->bus;
ide_controller_interface *controller = bus->controller; ide_controller_interface *controller = bus->controller;
@@ -76,8 +86,7 @@ bool reset_bus( ide_device_info *device, ide_qrequest *ignore )
spin(5); spin(5);
if( controller->write_device_control( channel, if (controller->write_device_control(channel, ide_devctrl_nien | ide_devctrl_bit3) != B_OK)
ide_devctrl_nien | ide_devctrl_bit3 ) != B_OK )
goto err0; goto err0;
// let devices wake up // 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! // ouch, we have to wait up to 31 seconds!
if (!ide_wait(device, 0, ide_status_bsy, true, 31000000)) { if (!ide_wait(device, 0, ide_status_bsy, true, 31000000)) {
// as we don't know which of the devices is broken // as we don't know which of the devices is broken
// we leave them both alive // we leave them both alive
if (controller->write_device_control(channel, ide_devctrl_bit3) != B_OK) if (controller->write_device_control(channel, ide_devctrl_bit3) != B_OK)
@@ -115,10 +123,13 @@ err1:
} }
// execute packet device reset. /** execute packet device reset.
// resets entire bus on fail or if device is not atapi; * resets entire bus on fail or if device is not atapi;
// all requests but <ignore> are resubmitted * all requests but <ignore> are resubmitted
bool reset_device( ide_device_info *device, ide_qrequest *ignore ) */
bool
reset_device(ide_device_info *device, ide_qrequest *ignore)
{ {
ide_bus_info *bus = device->bus; ide_bus_info *bus = device->bus;
status_t res; status_t res;
@@ -169,9 +180,12 @@ err:
return reset_bus(device, ignore); return reset_bus(device, ignore);
} }
// new_state must be either accessing, async_waiting or sync_waiting /** new_state must be either accessing, async_waiting or sync_waiting
// param_mask must not include command register * param_mask must not include command register
bool send_command( ide_device_info *device, ide_qrequest *qrequest, */
bool
send_command(ide_device_info *device, ide_qrequest *qrequest,
bool need_drdy, uint32 timeout, ide_bus_state new_state) bool need_drdy, uint32 timeout, ide_bus_state new_state)
{ {
ide_bus_info *bus = device->bus; ide_bus_info *bus = device->bus;
@@ -240,9 +254,8 @@ retry:
return false; return false;
} }
if( need_drdy && if (need_drdy
(bus->controller->get_altstatus( bus->channel ) & ide_status_drdy) == 0 ) && (bus->controller->get_altstatus(bus->channel) & ide_status_drdy) == 0) {
{
SHOW_FLOW0(3, "drdy not set"); SHOW_FLOW0(3, "drdy not set");
device->subsys_status = SCSI_SEQUENCE_FAIL; device->subsys_status = SCSI_SEQUENCE_FAIL;
return false; return false;
@@ -266,7 +279,6 @@ retry:
// waiting at least 50 µs seems(!) to solve this // waiting at least 50 µs seems(!) to solve this
while (system_time() - irq_disabled_at < MAX_IRQ_DELAY) while (system_time() - irq_disabled_at < MAX_IRQ_DELAY)
spin(1); spin(1);
} }
// if we will start waiting once the command is sent, we have to // if we will start waiting once the command is sent, we have to
@@ -293,9 +305,8 @@ retry:
goto err1; goto err1;
// start waiting now; also un-blocks IRQ handler (see above) // 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); start_waiting(bus, timeout, new_state);
}
return true; return true;
@@ -311,13 +322,16 @@ err:
} }
// busy-wait for device /** busy-wait for device
// mask - bits of status register that must be set * mask - bits of status register that must be set
// not_mask - bits of status register that must not be set * not_mask - bits of status register that must not be set
// check_err - abort if error bit is set * check_err - abort if error bit is set
// timeout - waiting timeout * timeout - waiting timeout
// return: true on success * return: true on success
bool ide_wait( ide_device_info *device, int mask, int not_mask, */
bool
ide_wait(ide_device_info *device, int mask, int not_mask,
bool check_err, bigtime_t timeout) bool check_err, bigtime_t timeout)
{ {
ide_bus_info *bus = device->bus; 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); status = bus->controller->get_altstatus(bus->channel);
if( (status & mask) == mask && if ((status & mask) == mask && (status & not_mask) == 0)
(status & not_mask) == 0 )
return true; return true;
if (check_err && (status & ide_status_err) != 0) { 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 /** tell device to continue queued command
// on return, no waiting is active! * on return, no waiting is active!
// tag - will contain tag of command to be continued * tag - will contain tag of command to be continued
// return: true - request continued * return: true - request continued
// false - something went wrong; sense set * false - something went wrong; sense set
bool device_start_service( ide_device_info *device, int *tag ) */
bool
device_start_service(ide_device_info *device, int *tag)
{ {
ide_bus_info *bus = device->bus; 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; *tag = device->tf.queued.tag;
FAST_LOG2(bus->log, ev_ide_device_start_service2, device->is_device1, *tag); FAST_LOG2(bus->log, ev_ide_device_start_service2, device->is_device1, *tag);
return true; return true;
err: err:
@@ -418,8 +433,10 @@ err:
} }
// check device whether it wants to continue queued request /** check device whether it wants to continue queued request */
bool check_service_req( ide_device_info *device )
bool
check_service_req(ide_device_info *device)
{ {
ide_bus_info *bus = device->bus; ide_bus_info *bus = device->bus;
int status; int status;
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
+9 -11
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the Haiku License. * 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 disconnect_worker( ide_bus_info *bus, void *arg );
static void set_check_condition( ide_qrequest *qrequest ); 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]; 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 // for atapi, all commands could be queued, but all
// atapi devices I know don't support queuing anyway // atapi devices I know don't support queuing anyway
if( opcode == SCSI_OP_READ_6 || return opcode == SCSI_OP_READ_6 || opcode == SCSI_OP_WRITE_6
opcode == SCSI_OP_WRITE_6 || || opcode == SCSI_OP_READ_10 || opcode == SCSI_OP_WRITE_10;
opcode == SCSI_OP_READ_10 ||
opcode == SCSI_OP_WRITE_10 )
return true;
else
return false;
} }
+42 -25
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002-04, Thomas Kurschel. All rights reserved. * Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -46,8 +46,11 @@
// internal error code if scatter gather table is too short // internal error code if scatter gather table is too short
#define ERR_TOO_BIG (B_ERRORS_END + 1) #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, ""); 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; 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) bool write, int *transferred)
{ {
ide_bus_info *bus = device->bus; 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) if (device->has_odd_byte)
device->odd_byte = *virt_addr; device->odd_byte = *virt_addr;
} else { } else {
// if we read one byte too much last time, push it into current chunk // if we read one byte too much last time, push it into current chunk
if (device->has_odd_byte) { 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 static inline status_t
transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr, transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr,
int length, bool write, int *transferred) 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, err = transfer_PIO_virtcont(device, (char *)virt_addr,
cur_len, write, transferred); cur_len, write, transferred);
if (err != B_OK) { if (err != B_OK) {
unmap_mainmemory(virt_addr); unmap_mainmemory(virt_addr);
return err; return err;
@@ -178,9 +183,10 @@ transfer_PIO_physcont(ide_device_info *device, addr_t phys_addr,
} }
// transfer PIO block from/to buffer /** transfer PIO block from/to buffer */
static inline int transfer_PIO_block( ide_device_info *device, int length, bool write,
int *transferred ) 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 // data is usually split up into multiple scatter/gather blocks
while (length > 0) { while (length > 0) {
@@ -219,8 +225,11 @@ static inline int transfer_PIO_block( ide_device_info *device, int length, bool
return B_OK; 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; ide_bus_info *bus = device->bus;
uint8 buffer[32]; 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) /** 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 )
static void
read_discard_PIO(ide_device_info *device, int length)
{ {
ide_bus_info *bus = device->bus; ide_bus_info *bus = device->bus;
uint8 buffer[32]; uint8 buffer[32];
@@ -264,12 +275,15 @@ static void read_discard_PIO( ide_device_info *device, int length )
} }
// write PIO data /** write PIO data
// return: there are 3 possible results * return: there are 3 possible results
// NO_ERROR - everything's nice and groovy * NO_ERROR - everything's nice and groovy
// ERR_TOO_BIG - data buffer was too short, remaining data got discarded * ERR_TOO_BIG - data buffer was too short, remaining data got discarded
// B_ERROR - something serious went wrong, sense data was set * B_ERROR - something serious went wrong, sense data was set
status_t write_PIO_block( ide_qrequest *qrequest, int length ) */
status_t
write_PIO_block(ide_qrequest *qrequest, int length)
{ {
ide_device_info *device = qrequest->device; ide_device_info *device = qrequest->device;
int transferred; int transferred;
@@ -312,9 +326,12 @@ status_t write_PIO_block( ide_qrequest *qrequest, int length )
} }
// read PIO data /** read PIO data
// return: see write_PIO_block * return: see write_PIO_block
status_t read_PIO_block( ide_qrequest *qrequest, int length ) */
status_t
read_PIO_block(ide_qrequest *qrequest, int length)
{ {
ide_device_info *device = qrequest->device; ide_device_info *device = qrequest->device;
int transferred; int transferred;
+72 -66
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * 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_mode_param_header_10 param_header;
scsi_modepage_contr contr; scsi_modepage_contr contr;
scsi_mode_param_block_desc block_desc; scsi_mode_param_block_desc block_desc;
size_t total_length = size_t total_length = sizeof(scsi_mode_param_header_10)
sizeof(scsi_mode_param_header_10) + + sizeof(scsi_mode_param_block_desc)
sizeof(scsi_mode_param_block_desc) + + sizeof(scsi_modepage_contr);
sizeof(scsi_modepage_contr);
scsi_mode_param_dev_spec_da devspec = { scsi_mode_param_dev_spec_da devspec = {
res0_0 : 0, res0_0 : 0,
DPOFUA : 0, DPOFUA : 0,
res0_6 : 0, res0_6 : 0,
WP : 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) allocation_length = ((int16)cmd->high_allocation_length << 8)
| cmd->low_allocation_length; | cmd->low_allocation_length;
// we answer control page requests and "all pages" requests // we answer control page requests and "all pages" requests
// (as the latter are the same as the first) // (as the latter are the same as the first)
if( (cmd->page_code != SCSI_MODEPAGE_CONTROL && if ((cmd->page_code != SCSI_MODEPAGE_CONTROL && cmd->page_code != SCSI_MODEPAGE_ALL)
cmd->page_code != SCSI_MODEPAGE_ALL) || || (cmd->PC != SCSI_MODE_SENSE_PC_CURRENT && cmd->PC != SCSI_MODE_SENSE_PC_SAVED)) {
(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); set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_CDB_FIELD);
return; 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.low_block_desc_len = sizeof(scsi_mode_param_block_desc);
param_header.high_block_desc_len = 0; param_header.high_block_desc_len = 0;
copy_sg_data( request, 0, allocation_length, copy_sg_data(request, 0, allocation_length, &param_header, sizeof(param_header), false);
&param_header, sizeof( param_header ), false );
/*block_desc = (scsi_mode_param_block_desc *)(request->data /*block_desc = (scsi_mode_param_block_desc *)(request->data
+ sizeof(*param_header));*/ + sizeof(*param_header));*/
@@ -86,16 +81,15 @@ ata_mode_sense_10(ide_device_info *device, ide_qrequest *qrequest)
memset(&contr, 0, sizeof(contr)); memset(&contr, 0, sizeof(contr));
contr.RLEC = false; contr.RLEC = false;
contr.DQue = !device->CQ_enabled; 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 // lost commands automagically
contr.QAM = SCSI_QAM_UNRESTRICTED; contr.QAM = SCSI_QAM_UNRESTRICTED;
copy_sg_data( request, copy_sg_data(request, sizeof(param_header)
sizeof( param_header )
+ ((uint16)param_header.high_block_desc_len << 8) + ((uint16)param_header.high_block_desc_len << 8)
+ param_header.low_block_desc_len, + param_header.low_block_desc_len,
allocation_length, allocation_length, &contr, sizeof(contr), false);
&contr, sizeof( contr ), false );
// the number of bytes that were transferred to buffer is // the number of bytes that were transferred to buffer is
// restricted by allocation length and by request data buffer size // 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); total_length = min(total_length, request->data_len);
request->data_resid = request->data_len - total_length; request->data_resid = request->data_len - total_length;
return;
} }
// emulate modifying control page /** emulate modifying control page */
static bool ata_mode_select_contrpage( ide_device_info *device, ide_qrequest *qrequest,
static bool
ata_mode_select_control_page(ide_device_info *device, ide_qrequest *qrequest,
scsi_modepage_contr *page) scsi_modepage_contr *page)
{ {
if (page->header.page_length != sizeof(*page) - sizeof(page->header)) { 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 /** emulate MODE SELECT 10 command */
static void ata_mode_select_10( ide_device_info *device, ide_qrequest *qrequest )
static void
ata_mode_select_10(ide_device_info *device, ide_qrequest *qrequest)
{ {
scsi_ccb *request = qrequest->request; scsi_ccb *request = qrequest->request;
scsi_cmd_mode_select_10 *cmd = (scsi_cmd_mode_select_10 *)request->cdb; scsi_cmd_mode_select_10 *cmd = (scsi_cmd_mode_select_10 *)request->cdb;
scsi_mode_param_header_10 param_header; scsi_mode_param_header_10 param_header;
scsi_modepage_header page_header; scsi_modepage_header page_header;
int total_length; uint32 total_length;
uint modepage_offset; uint32 modepage_offset;
char modepage_buffer[64]; // !!! enlarge this to support longer mode pages char modepage_buffer[64]; // !!! enlarge this to support longer mode pages
if (cmd->SP || cmd->PF != 1) { 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, 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 // first, retrieve page header to get size of different chunks
//param_header = (scsi_mode_param_header_10 *)request->data; //param_header = (scsi_mode_param_header_10 *)request->data;
if( !copy_sg_data( request, 0, total_length, if (!copy_sg_data(request, 0, total_length, &param_header, sizeof(param_header), true))
&param_header, sizeof( param_header ), true ))
goto err; goto err;
total_length = min( total_length, total_length = min(total_length, (((uint16)param_header.high_mode_data_len << 8)
(((uint16)param_header.high_mode_data_len << 8) | param_header.low_mode_data_len) + 1 ); | param_header.low_mode_data_len) + 1UL);
// this is the start of the first mode page; // this is the start of the first mode page;
// we ignore the block descriptor silently // we ignore the block descriptor silently
modepage_offset = modepage_offset = sizeof(param_header) + (((uint16)param_header.high_block_desc_len << 8)
sizeof( param_header ) + | param_header.low_block_desc_len);
(((uint16)param_header.high_block_desc_len << 8) | param_header.low_block_desc_len);
// go through list of pages // go through list of pages
while (modepage_offset < total_length) { while (modepage_offset < total_length) {
int page_len; uint32 page_len;
// get header to know how long page is // get header to know how long page is
if (!copy_sg_data(request, modepage_offset, total_length, 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 // currently, we only support the control mode page
switch (page_header.page_code) { switch (page_header.page_code) {
case SCSI_MODEPAGE_CONTROL: case SCSI_MODEPAGE_CONTROL:
if( !ata_mode_select_contrpage( device, qrequest, if (!ata_mode_select_control_page(device, qrequest,
(scsi_modepage_contr *)modepage_buffer)) (scsi_modepage_contr *)modepage_buffer))
return; return;
break; break;
default: default:
set_sense( device, set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_PARAM_LIST_FIELD);
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_PARAM_LIST_FIELD );
return; 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 // if we arrive here, data length was incorrect
err: err:
set_sense( device, set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_PARAM_LIST_LENGTH_ERR);
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_PARAM_LIST_LENGTH_ERR );
} }
// emulate TEST UNIT READY /** emulate TEST UNIT READY */
static bool ata_tur( ide_device_info *device, ide_qrequest *qrequest )
static bool
ata_test_unit_ready(ide_device_info *device, ide_qrequest *qrequest)
{ {
SHOW_FLOW0(3, ""); SHOW_FLOW0(3, "");
if( !device->infoblock.RMSN_supported || if (!device->infoblock.RMSN_supported
device->infoblock._127_RMSN_support != 1 ) || device->infoblock._127_RMSN_support != 1)
return true; return true;
// ask device about status // 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 // we don't want to loose media change (request) reports
if (!check_output(device, true, if (!check_output(device, true,
ide_error_nm | ide_error_abrt | ide_error_mcr | ide_error_mc, 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)" // SCSI spec is unclear here: we shouldn't report "media change (request)"
// but what to do if there is one? anyway - we report them // 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 /** flush internal device cache */
static bool ata_flush_cache( ide_device_info *device, ide_qrequest *qrequest )
static bool
ata_flush_cache(ide_device_info *device, ide_qrequest *qrequest)
{ {
// we should also ask for FLUSH CACHE support, but everyone denies it // we should also ask for FLUSH CACHE support, but everyone denies it
// (looks like they cheat to gain some performance advantage, but // (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 or eject medium
// load = true - load medium * load = true - load medium
static bool ata_load_eject( ide_device_info *device, ide_qrequest *qrequest, bool load ) */
static bool
ata_load_eject(ide_device_info *device, ide_qrequest *qrequest, bool load)
{ {
if (load) { if (load) {
// ATA doesn't support loading // 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 /** emulate PREVENT ALLOW command */
static bool ata_prevent_allow( ide_device_info *device, bool prevent )
static bool
ata_prevent_allow(ide_device_info *device, bool prevent)
{ {
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_ILL_FUNCTION); set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_ILL_FUNCTION);
return false; return false;
} }
// emulate INQUIRY command /** emulate INQUIRY command */
static void ata_inquiry( ide_device_info *device, ide_qrequest *qrequest )
static void
ata_inquiry(ide_device_info *device, ide_qrequest *qrequest)
{ {
scsi_ccb *request = qrequest->request; scsi_ccb *request = qrequest->request;
scsi_res_inquiry data; scsi_res_inquiry data;
scsi_cmd_inquiry *cmd = (scsi_cmd_inquiry *)request->cdb; scsi_cmd_inquiry *cmd = (scsi_cmd_inquiry *)request->cdb;
uint allocation_length = cmd->allocation_length; uint32 allocation_length = cmd->allocation_length;
int transfer_size; uint32 transfer_size;
if (cmd->EVPD || cmd->page_code) { if (cmd->EVPD || cmd->page_code) {
set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_CDB_FIELD); 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]) { switch (request->cdb[0]) {
case SCSI_OP_TUR: case SCSI_OP_TUR:
ata_tur( device, qrequest ); ata_test_unit_ready(device, qrequest);
break; break;
case SCSI_OP_REQUEST_SENSE: case SCSI_OP_REQUEST_SENSE:
@@ -463,13 +466,15 @@ ata_exec_io(ide_device_info *device, ide_qrequest *qrequest)
if (cmd->LoEj) if (cmd->LoEj)
ata_load_eject(device, qrequest, cmd->start); ata_load_eject(device, qrequest, cmd->start);
break; } break;
}
case SCSI_OP_PREVENT_ALLOW: { case SCSI_OP_PREVENT_ALLOW: {
scsi_cmd_prevent_allow *cmd = (scsi_cmd_prevent_allow *)request->cdb; scsi_cmd_prevent_allow *cmd = (scsi_cmd_prevent_allow *)request->cdb;
ata_prevent_allow(device, cmd->prevent); ata_prevent_allow(device, cmd->prevent);
break; } break;
}
case SCSI_OP_READ_CAPACITY: case SCSI_OP_READ_CAPACITY:
read_capacity(device, qrequest); 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; 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); ata_send_rw(device, qrequest, pos, length, cmd->opcode == SCSI_OP_WRITE_6);
return; } return;
}
case SCSI_OP_READ_10: case SCSI_OP_READ_10:
case SCSI_OP_WRITE_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) // we cannot transfer zero blocks (apart from LBA48)
finish_request(qrequest, false); finish_request(qrequest, false);
} }
return; } return;
}
default: default:
set_sense( device, set_sense(device, SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_OPCODE);
SCSIS_KEY_ILLEGAL_REQUEST, SCSIS_ASC_INV_OPCODE );
} }
finish_checksense(qrequest); finish_checksense(qrequest);
+5 -6
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -19,7 +19,7 @@
//#define TRACE_SYNC //#define TRACE_SYNC
#ifdef TRACE_SYNC #ifdef TRACE_SYNC
# define TRACE(x) dprintf x # define TRACE(x) { dprintf("%s(): ", __FUNCTION__); dprintf x ; }
#else #else
# define TRACE(x) ; # define TRACE(x) ;
#endif #endif
@@ -34,7 +34,7 @@ ide_dpc(void *arg)
ide_qrequest *qrequest; ide_qrequest *qrequest;
ide_device_info *device; ide_device_info *device;
TRACE(("ide_dpc()\n")); TRACE(("\n"));
//snooze(500000); //snooze(500000);
@@ -69,7 +69,6 @@ ide_dpc(void *arg)
FAST_LOG0(bus->log, ev_ide_dpc_service); FAST_LOG0(bus->log, ev_ide_dpc_service);
device = get_current_device(bus); device = get_current_device(bus);
if (device == NULL) { if (device == NULL) {
// got an interrupt from a non-existing device // got an interrupt from a non-existing device
// either this is a spurious interrupt or there *is* a 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; ide_device_info *device;
TRACE(("ide_irq_handler()\n")); TRACE(("\n"));
FAST_LOG0(bus->log, ev_ide_irq_handle); FAST_LOG0(bus->log, ev_ide_irq_handle);
// we need to lock bus to have a solid bus state // we need to lock bus to have a solid bus state
@@ -43,15 +43,15 @@
#endif #endif
#ifndef debug_level_flow #ifndef debug_level_flow
# define debug_level_flow 3 # define debug_level_flow 4
#endif #endif
#ifndef debug_level_info #ifndef debug_level_info
# define debug_level_info 2 # define debug_level_info 4
#endif #endif
#ifndef debug_level_error #ifndef debug_level_error
# define debug_level_error 1 # define debug_level_error 4
#endif #endif
#define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": " #define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": "