forked from Imagelibrary/rtems
2008-07-29 Chris Johns <chrisj@rtems.org>
* libchip/i2c/spi-sd-card.c: Updated to the libblock changes. * libchip/ide/ata.c: Change to use a mutex rather than disable pre-emption. Updated to the libblock changes. * libchip/ide/ata_internal.h: Updated to the new chains API. * libchip/ide/ide_controller.c: Updated to the libblock changes. Added come debug tracing. * libchip/ide/ide_ctrl_cfg.h, libchip/ide/ide_ctrl_io.h: Updated to the libblock changes.
This commit is contained in:
@@ -1,3 +1,18 @@
|
|||||||
|
2008-07-29 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
|
* libchip/i2c/spi-sd-card.c: Updated to the libblock changes.
|
||||||
|
|
||||||
|
* libchip/ide/ata.c: Change to use a mutex rather than disable
|
||||||
|
pre-emption. Updated to the libblock changes.
|
||||||
|
|
||||||
|
* libchip/ide/ata_internal.h: Updated to the new chains API.
|
||||||
|
|
||||||
|
* libchip/ide/ide_controller.c: Updated to the libblock
|
||||||
|
changes. Added come debug tracing.
|
||||||
|
|
||||||
|
* libchip/ide/ide_ctrl_cfg.h, libchip/ide/ide_ctrl_io.h: Updated
|
||||||
|
to the libblock changes.
|
||||||
|
|
||||||
2008-07-27 Ralf Corsépius <ralf.corsepius@rtems.org>
|
2008-07-27 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||||
|
|
||||||
* configure.ac: Remove RPCGEN, RPCTOOLS.
|
* configure.ac: Remove RPCGEN, RPCTOOLS.
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ static inline rtems_status_code sd_card_stop( sd_card_driver_entry *e)
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int sd_card_disk_block_read( sd_card_driver_entry *e, blkdev_request *r)
|
static int sd_card_disk_block_read( sd_card_driver_entry *e, rtems_blkdev_request *r)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
@@ -648,7 +648,7 @@ sd_card_disk_block_read_cleanup:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_card_disk_block_write( sd_card_driver_entry *e, blkdev_request *r)
|
static int sd_card_disk_block_write( sd_card_driver_entry *e, rtems_blkdev_request *r)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
@@ -749,14 +749,14 @@ sd_card_disk_block_write_cleanup:
|
|||||||
static int sd_card_disk_ioctl( dev_t dev, uint32_t req, void *arg)
|
static int sd_card_disk_ioctl( dev_t dev, uint32_t req, void *arg)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT( "dev = %u, req = %u, arg = 0x08%x\n", dev, req, arg);
|
DEBUG_PRINT( "dev = %u, req = %u, arg = 0x08%x\n", dev, req, arg);
|
||||||
if (req == BLKIO_REQUEST) {
|
if (req == RTEMS_BLKIO_REQUEST) {
|
||||||
rtems_device_minor_number minor = rtems_filesystem_dev_minor_t( dev);
|
rtems_device_minor_number minor = rtems_filesystem_dev_minor_t( dev);
|
||||||
sd_card_driver_entry *e = &sd_card_driver_table [minor];
|
sd_card_driver_entry *e = &sd_card_driver_table [minor];
|
||||||
blkdev_request *r = (blkdev_request *) arg;
|
rtems_blkdev_request *r = (rtems_blkdev_request *) arg;
|
||||||
switch (r->req) {
|
switch (r->req) {
|
||||||
case BLKDEV_REQ_READ:
|
case RTEMS_BLKDEV_REQ_READ:
|
||||||
return sd_card_disk_block_read( e, r);
|
return sd_card_disk_block_read( e, r);
|
||||||
case BLKDEV_REQ_WRITE:
|
case RTEMS_BLKDEV_REQ_WRITE:
|
||||||
return sd_card_disk_block_write( e, r);
|
return sd_card_disk_block_write( e, r);
|
||||||
default:
|
default:
|
||||||
errno = EBADRQC;
|
errno = EBADRQC;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <libchip/ide_ctrl_cfg.h>
|
#include <libchip/ide_ctrl_cfg.h>
|
||||||
#include "ata_internal.h"
|
#include "ata_internal.h"
|
||||||
#include <libchip/ata.h>
|
#include <libchip/ata.h>
|
||||||
/* #define DEBUG */
|
//#define DEBUG
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -57,9 +57,42 @@ int ata_irq_chain_cnt = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAFE
|
#define SAFE
|
||||||
|
#define SAFE_MUTEX
|
||||||
|
|
||||||
#ifdef SAFE
|
#ifdef SAFE
|
||||||
|
#ifdef SAFE_MUTEX
|
||||||
|
static rtems_id ata_lock;
|
||||||
|
static void
|
||||||
|
rtems_ata_lock ()
|
||||||
|
{
|
||||||
|
rtems_status_code sc = rtems_semaphore_obtain (ata_lock,
|
||||||
|
RTEMS_WAIT,
|
||||||
|
RTEMS_NO_TIMEOUT);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rtems_ata_unlock ()
|
||||||
|
{
|
||||||
|
rtems_status_code sc = rtems_semaphore_release (ata_lock);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RTEMS_ATA_LOCK_ATTRIBS \
|
||||||
|
(RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | \
|
||||||
|
RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
|
||||||
|
|
||||||
|
#define PREEMPTION_KEY(key)
|
||||||
|
#define DISABLE_PREEMPTION(key) rtems_ata_lock ()
|
||||||
|
#define ENABLE_PREEMPTION(key) rtems_ata_unlock ()
|
||||||
|
|
||||||
|
#else /* !SAFE_MUTEX */
|
||||||
typedef rtems_mode preemption_key;
|
typedef rtems_mode preemption_key;
|
||||||
|
|
||||||
|
#define PREEMPTION_KEY(key) preemption_key key
|
||||||
|
|
||||||
#define DISABLE_PREEMPTION(key) \
|
#define DISABLE_PREEMPTION(key) \
|
||||||
do { \
|
do { \
|
||||||
rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &(key)); \
|
rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &(key)); \
|
||||||
@@ -70,11 +103,12 @@ typedef rtems_mode preemption_key;
|
|||||||
rtems_mode temp; \
|
rtems_mode temp; \
|
||||||
rtems_task_mode((key), RTEMS_PREEMPT_MASK, &temp); \
|
rtems_task_mode((key), RTEMS_PREEMPT_MASK, &temp); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
#else
|
#else /* !SAFE */
|
||||||
|
|
||||||
typedef boolean preemption_key;
|
typedef boolean preemption_key;
|
||||||
|
|
||||||
|
#define PREEMPTION_KEY(key) preemption_key key
|
||||||
|
|
||||||
#define DISABLE_PREEMPTION(key) \
|
#define DISABLE_PREEMPTION(key) \
|
||||||
do { \
|
do { \
|
||||||
(key) = _Thread_Executing->is_preemptible; \
|
(key) = _Thread_Executing->is_preemptible; \
|
||||||
@@ -95,8 +129,8 @@ typedef boolean preemption_key;
|
|||||||
|
|
||||||
/* Block device request with a single buffer provided */
|
/* Block device request with a single buffer provided */
|
||||||
typedef struct blkdev_request1 {
|
typedef struct blkdev_request1 {
|
||||||
blkdev_request req;
|
rtems_blkdev_request req;
|
||||||
blkdev_sg_buffer sg[1];
|
rtems_blkdev_sg_buffer sg[1];
|
||||||
} blkdev_request1;
|
} blkdev_request1;
|
||||||
|
|
||||||
|
|
||||||
@@ -152,7 +186,7 @@ ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
|||||||
* error occured
|
* error occured
|
||||||
*/
|
*/
|
||||||
static rtems_status_code
|
static rtems_status_code
|
||||||
ata_io_data_request(dev_t device, blkdev_request *req)
|
ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||||
{
|
{
|
||||||
ata_req_t *areq; /* ATA request */
|
ata_req_t *areq; /* ATA request */
|
||||||
rtems_device_minor_number rel_minor; /* relative minor which indexes
|
rtems_device_minor_number rel_minor; /* relative minor which indexes
|
||||||
@@ -194,15 +228,19 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
|||||||
{
|
{
|
||||||
/* XXX: never has been tested */
|
/* XXX: never has been tested */
|
||||||
areq->type = ATA_COMMAND_TYPE_DMA;
|
areq->type = ATA_COMMAND_TYPE_DMA;
|
||||||
if (req->req == BLKDEV_REQ_READ)
|
if (req->req == RTEMS_BLKDEV_REQ_READ)
|
||||||
areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_READ_DMA;
|
areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_READ_DMA;
|
||||||
else
|
else
|
||||||
areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_WRITE_DMA;
|
areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_WRITE_DMA;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (req->req == BLKDEV_REQ_READ)
|
if (req->req == RTEMS_BLKDEV_REQ_READ)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_io_data_request: type: READ: %d, %d\n",
|
||||||
|
req->bufs[0].block, req->count);
|
||||||
|
#endif
|
||||||
areq->type = ATA_COMMAND_TYPE_PIO_IN;
|
areq->type = ATA_COMMAND_TYPE_PIO_IN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -220,6 +258,10 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_io_data_request: type: WRITE: %d, %d\n",
|
||||||
|
req->bufs[0].block, req->count);
|
||||||
|
#endif
|
||||||
areq->type = ATA_COMMAND_TYPE_PIO_OUT;
|
areq->type = ATA_COMMAND_TYPE_PIO_OUT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -242,15 +284,16 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
|||||||
*/
|
*/
|
||||||
if (ATA_DEV_INFO(ctrl_minor, dev).lba_avaible)
|
if (ATA_DEV_INFO(ctrl_minor, dev).lba_avaible)
|
||||||
{
|
{
|
||||||
areq->regs.regs[IDE_REGISTER_LBA0] = (uint8_t)req->start;
|
uint32_t start = req->bufs[0].block;
|
||||||
areq->regs.regs[IDE_REGISTER_LBA1] = (uint8_t)(req->start >> 8);
|
areq->regs.regs[IDE_REGISTER_LBA0] = (uint8_t)start;
|
||||||
areq->regs.regs[IDE_REGISTER_LBA2] = (uint8_t)(req->start >> 16);
|
areq->regs.regs[IDE_REGISTER_LBA1] = (uint8_t)(start >> 8);
|
||||||
areq->regs.regs[IDE_REGISTER_LBA3] |= (uint8_t) (req->start >> 24);
|
areq->regs.regs[IDE_REGISTER_LBA2] = (uint8_t)(start >> 16);
|
||||||
|
areq->regs.regs[IDE_REGISTER_LBA3] |= (uint8_t) (start >> 24);
|
||||||
areq->regs.regs[IDE_REGISTER_LBA3] |= IDE_REGISTER_LBA3_L;
|
areq->regs.regs[IDE_REGISTER_LBA3] |= IDE_REGISTER_LBA3_L;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32_t count = req->start;
|
uint32_t count = req->bufs[0].block;
|
||||||
|
|
||||||
areq->regs.regs[IDE_REGISTER_SECTOR_NUMBER] =
|
areq->regs.regs[IDE_REGISTER_SECTOR_NUMBER] =
|
||||||
(count % ATA_DEV_INFO(ctrl_minor, dev).sectors) + 1;
|
(count % ATA_DEV_INFO(ctrl_minor, dev).sectors) + 1;
|
||||||
@@ -459,6 +502,10 @@ ata_process_request(rtems_device_minor_number ctrl_minor)
|
|||||||
ide_controller_write_register(ctrl_minor, i, areq->regs.regs[i]);
|
ide_controller_write_register(ctrl_minor, i, areq->regs.regs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_process_request: type: %d\n", areq->type);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* continue to execute ATA protocols depending on type of request */
|
/* continue to execute ATA protocols depending on type of request */
|
||||||
if (areq->type == ATA_COMMAND_TYPE_PIO_OUT)
|
if (areq->type == ATA_COMMAND_TYPE_PIO_OUT)
|
||||||
{
|
{
|
||||||
@@ -521,23 +568,27 @@ static inline void
|
|||||||
ata_request_done(ata_req_t *areq, rtems_device_minor_number ctrl_minor,
|
ata_request_done(ata_req_t *areq, rtems_device_minor_number ctrl_minor,
|
||||||
rtems_status_code status, int error)
|
rtems_status_code status, int error)
|
||||||
{
|
{
|
||||||
preemption_key key;
|
|
||||||
|
|
||||||
assert(areq);
|
assert(areq);
|
||||||
|
|
||||||
DISABLE_PREEMPTION(key);
|
#ifdef DEBUG
|
||||||
|
printf("ata_request_done: entry\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
ATA_EXEC_CALLBACK(areq, status, error);
|
ATA_EXEC_CALLBACK(areq, status, error);
|
||||||
rtems_chain_extract(&areq->link);
|
rtems_chain_extract(&areq->link);
|
||||||
|
|
||||||
if (!rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
|
if (!rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
|
||||||
{
|
{
|
||||||
ENABLE_PREEMPTION(key);
|
|
||||||
free(areq);
|
free(areq);
|
||||||
ata_process_request(ctrl_minor);
|
ata_process_request(ctrl_minor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ENABLE_PREEMPTION(key);
|
|
||||||
free(areq);
|
free(areq);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_request_done: exit\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ata_non_data_request_done --
|
/* ata_non_data_request_done --
|
||||||
@@ -577,6 +628,10 @@ static void
|
|||||||
ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
||||||
ata_req_t *areq)
|
ata_req_t *areq)
|
||||||
{
|
{
|
||||||
|
PREEMPTION_KEY(key);
|
||||||
|
|
||||||
|
DISABLE_PREEMPTION(key);
|
||||||
|
|
||||||
rtems_chain_append(&ata_ide_ctrls[ctrl_minor].reqs, &areq->link);
|
rtems_chain_append(&ata_ide_ctrls[ctrl_minor].reqs, &areq->link);
|
||||||
if (rtems_chain_has_only_one_node(&ata_ide_ctrls[ctrl_minor].reqs))
|
if (rtems_chain_has_only_one_node(&ata_ide_ctrls[ctrl_minor].reqs))
|
||||||
{
|
{
|
||||||
@@ -597,6 +652,8 @@ ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
|||||||
#endif
|
#endif
|
||||||
ATA_SEND_EVT(msg, ATA_MSG_PROCESS_NEXT_EVT, ctrl_minor, 0);
|
ATA_SEND_EVT(msg, ATA_MSG_PROCESS_NEXT_EVT, ctrl_minor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENABLE_PREEMPTION(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -636,7 +693,6 @@ ata_interrupt_handler(rtems_vector_number vec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void ata_interrupt_handler(rtems_irq_hdl_param handle)
|
void ata_interrupt_handler(rtems_irq_hdl_param handle)
|
||||||
{
|
{
|
||||||
int ata_irq_chain_index = (int) handle;
|
int ata_irq_chain_index = (int) handle;
|
||||||
@@ -773,6 +829,10 @@ ata_pio_out_protocol(rtems_device_minor_number ctrl_minor, ata_req_t *areq)
|
|||||||
uint32_t min_val;
|
uint32_t min_val;
|
||||||
ata_queue_msg_t msg;
|
ata_queue_msg_t msg;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_pio_out_protocol:\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
dev = areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
|
dev = areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
|
||||||
IDE_REGISTER_DEVICE_HEAD_DEV;
|
IDE_REGISTER_DEVICE_HEAD_DEV;
|
||||||
|
|
||||||
@@ -827,8 +887,14 @@ ata_queue_task(rtems_task_argument arg)
|
|||||||
rtems_status_code rc;
|
rtems_status_code rc;
|
||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
|
|
||||||
|
PREEMPTION_KEY(key);
|
||||||
|
|
||||||
|
DISABLE_PREEMPTION(key);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
ENABLE_PREEMPTION(key);
|
||||||
|
|
||||||
/* get event which has happend */
|
/* get event which has happend */
|
||||||
rc = rtems_message_queue_receive(ata_queue_id, &msg, &size, RTEMS_WAIT,
|
rc = rtems_message_queue_receive(ata_queue_id, &msg, &size, RTEMS_WAIT,
|
||||||
RTEMS_NO_TIMEOUT);
|
RTEMS_NO_TIMEOUT);
|
||||||
@@ -838,6 +904,8 @@ ata_queue_task(rtems_task_argument arg)
|
|||||||
/* get controller on which event has happend */
|
/* get controller on which event has happend */
|
||||||
ctrl_minor = msg.ctrl_minor;
|
ctrl_minor = msg.ctrl_minor;
|
||||||
|
|
||||||
|
DISABLE_PREEMPTION(key);
|
||||||
|
|
||||||
/* get current request to the controller */
|
/* get current request to the controller */
|
||||||
_ISR_Disable(level);
|
_ISR_Disable(level);
|
||||||
areq = (ata_req_t *)(ata_ide_ctrls[ctrl_minor].reqs.first);
|
areq = (ata_req_t *)(ata_ide_ctrls[ctrl_minor].reqs.first);
|
||||||
@@ -925,6 +993,10 @@ ata_queue_task(rtems_task_argument arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("ata_queue_task: internal error\n");
|
||||||
|
rtems_task_delete (RTEMS_SELF);
|
||||||
|
#endif
|
||||||
rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
|
rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -963,14 +1035,19 @@ ata_ioctl(dev_t device, int cmd, void *argp)
|
|||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case BLKIO_REQUEST:
|
case RTEMS_BLKIO_REQUEST:
|
||||||
status = ata_io_data_request(device, (blkdev_request *)argp);
|
status = ata_io_data_request(device, (rtems_blkdev_request *)argp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ATAIO_SET_MULTIPLE_MODE:
|
case ATAIO_SET_MULTIPLE_MODE:
|
||||||
status = ata_non_data_request(device, cmd, argp);
|
status = ata_non_data_request(device, cmd, argp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RTEMS_BLKDEV_CAPABILITIES:
|
||||||
|
*((uint32_t*) argp) = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
|
||||||
|
status = RTEMS_SUCCESSFUL;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errno = EBADRQC;
|
errno = EBADRQC;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -999,7 +1076,7 @@ ata_ioctl(dev_t device, int cmd, void *argp)
|
|||||||
* error occured
|
* error occured
|
||||||
*/
|
*/
|
||||||
rtems_device_driver
|
rtems_device_driver
|
||||||
ata_initialize(rtems_device_major_number major,
|
rtems_ata_initialize(rtems_device_major_number major,
|
||||||
rtems_device_minor_number minor_arg,
|
rtems_device_minor_number minor_arg,
|
||||||
void *args)
|
void *args)
|
||||||
{
|
{
|
||||||
@@ -1028,6 +1105,16 @@ ata_initialize(rtems_device_major_number major,
|
|||||||
if (status != RTEMS_SUCCESSFUL)
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
#ifdef SAFE
|
||||||
|
#ifdef SAFE_MUTEX
|
||||||
|
status = rtems_semaphore_create (rtems_build_name ('A', 'T', 'A', 'L'),
|
||||||
|
1, RTEMS_ATA_LOCK_ATTRIBS, 0,
|
||||||
|
&ata_lock);
|
||||||
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
|
return status;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* create queue for asynchronous requests handling */
|
/* create queue for asynchronous requests handling */
|
||||||
status = rtems_message_queue_create(
|
status = rtems_message_queue_create(
|
||||||
rtems_build_name('A', 'T', 'A', 'Q'),
|
rtems_build_name('A', 'T', 'A', 'Q'),
|
||||||
@@ -1047,11 +1134,11 @@ ata_initialize(rtems_device_major_number major,
|
|||||||
*/
|
*/
|
||||||
status = rtems_task_create(
|
status = rtems_task_create(
|
||||||
rtems_build_name ('A', 'T', 'A', 'T'),
|
rtems_build_name ('A', 'T', 'A', 'T'),
|
||||||
((ata_driver_task_priority > 0)
|
((rtems_ata_driver_task_priority > 0)
|
||||||
? ata_driver_task_priority
|
? rtems_ata_driver_task_priority
|
||||||
: ATA_DRIVER_TASK_DEFAULT_PRIORITY),
|
: ATA_DRIVER_TASK_DEFAULT_PRIORITY),
|
||||||
ATA_DRIVER_TASK_STACK_SIZE,
|
ATA_DRIVER_TASK_STACK_SIZE,
|
||||||
RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR |
|
RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |
|
||||||
RTEMS_INTERRUPT_LEVEL(0),
|
RTEMS_INTERRUPT_LEVEL(0),
|
||||||
RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
|
RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
|
||||||
&ata_task_id);
|
&ata_task_id);
|
||||||
@@ -1215,7 +1302,7 @@ ata_initialize(rtems_device_major_number major,
|
|||||||
ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
|
ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
|
||||||
areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
|
areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_ERROR);
|
||||||
|
|
||||||
areq.breq = (blkdev_request *)&breq;
|
areq.breq = (rtems_blkdev_request *)&breq;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process the request. Special processing of requests on
|
* Process the request. Special processing of requests on
|
||||||
@@ -1276,7 +1363,7 @@ ata_initialize(rtems_device_major_number major,
|
|||||||
areq.regs.regs[IDE_REGISTER_COMMAND] =
|
areq.regs.regs[IDE_REGISTER_COMMAND] =
|
||||||
ATA_COMMAND_IDENTIFY_DEVICE;
|
ATA_COMMAND_IDENTIFY_DEVICE;
|
||||||
areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
|
areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
|
||||||
areq.breq = (blkdev_request *)&breq;
|
areq.breq = (rtems_blkdev_request *)&breq;
|
||||||
|
|
||||||
areq.cnt = breq.req.count;
|
areq.cnt = breq.req.count;
|
||||||
|
|
||||||
@@ -1363,7 +1450,7 @@ ata_initialize(rtems_device_major_number major,
|
|||||||
(ATA_DEV_INFO(ctrl_minor, dev).heads *
|
(ATA_DEV_INFO(ctrl_minor, dev).heads *
|
||||||
ATA_DEV_INFO(ctrl_minor, dev).cylinders *
|
ATA_DEV_INFO(ctrl_minor, dev).cylinders *
|
||||||
ATA_DEV_INFO(ctrl_minor, dev).sectors),
|
ATA_DEV_INFO(ctrl_minor, dev).sectors),
|
||||||
(block_device_ioctl) ata_ioctl, name);
|
(rtems_block_device_ioctl) ata_ioctl, name);
|
||||||
if (status != RTEMS_SUCCESSFUL)
|
if (status != RTEMS_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
ata_devs[ata_devs_number].device = ATA_UNDEFINED_VALUE;
|
ata_devs[ata_devs_number].device = ATA_UNDEFINED_VALUE;
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ extern "C" {
|
|||||||
|
|
||||||
#include <rtems/blkdev.h>
|
#include <rtems/blkdev.h>
|
||||||
|
|
||||||
rtems_device_driver ata_initialize(
|
rtems_device_driver rtems_ata_initialize(
|
||||||
rtems_device_major_number major,
|
rtems_device_major_number major,
|
||||||
rtems_device_minor_number minor,
|
rtems_device_minor_number minor,
|
||||||
void *args);
|
void *args);
|
||||||
|
|
||||||
#define ATA_DRIVER_TABLE_ENTRY \
|
#define ATA_DRIVER_TABLE_ENTRY \
|
||||||
{ata_initialize, GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES}
|
{rtems_ata_initialize, RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES}
|
||||||
|
|
||||||
/* ATA IOCTL request codes */
|
/* ATA IOCTL request codes */
|
||||||
#define ATAIO_SET_MULTIPLE_MODE _IO('A', 1)
|
#define ATAIO_SET_MULTIPLE_MODE _IO('A', 1)
|
||||||
@@ -43,7 +43,7 @@ rtems_device_driver ata_initialize(
|
|||||||
#define ATA_DRIVER_MESSAGE_QUEUE_SIZE 50
|
#define ATA_DRIVER_MESSAGE_QUEUE_SIZE 50
|
||||||
#define ATA_DRIVER_TASK_STACK_SIZE 16*1024
|
#define ATA_DRIVER_TASK_STACK_SIZE 16*1024
|
||||||
#define ATA_DRIVER_TASK_DEFAULT_PRIORITY 140
|
#define ATA_DRIVER_TASK_DEFAULT_PRIORITY 140
|
||||||
extern rtems_task_priority ata_driver_task_priority;
|
extern rtems_task_priority rtems_ata_driver_task_priority;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -197,13 +197,13 @@ typedef struct ata_registers_s {
|
|||||||
|
|
||||||
/* ATA request */
|
/* ATA request */
|
||||||
typedef struct ata_req_s {
|
typedef struct ata_req_s {
|
||||||
Chain_Node link; /* link in requests chain */
|
rtems_chain_node link; /* link in requests chain */
|
||||||
char type; /* request type */
|
char type; /* request type */
|
||||||
ata_registers_t regs; /* ATA command */
|
ata_registers_t regs; /* ATA command */
|
||||||
uint32_t cnt; /* Number of sectors to be exchanged */
|
uint32_t cnt; /* Number of sectors to be exchanged */
|
||||||
uint32_t cbuf; /* number of current buffer from breq in use */
|
uint32_t cbuf; /* number of current buffer from breq in use */
|
||||||
uint32_t pos; /* current position in 'cbuf' */
|
uint32_t pos; /* current position in 'cbuf' */
|
||||||
blkdev_request *breq; /* blkdev_request which corresponds to the
|
rtems_blkdev_request *breq; /* blkdev_request which corresponds to the
|
||||||
* ata request
|
* ata request
|
||||||
*/
|
*/
|
||||||
rtems_id sema; /* semaphore which is used if synchronous
|
rtems_id sema; /* semaphore which is used if synchronous
|
||||||
@@ -258,7 +258,7 @@ typedef struct ata_queue_msg_s {
|
|||||||
* mapping of IDE controllers and interrupt vectors
|
* mapping of IDE controllers and interrupt vectors
|
||||||
*/
|
*/
|
||||||
typedef struct ata_int_st_s {
|
typedef struct ata_int_st_s {
|
||||||
Chain_Node link;
|
rtems_chain_node link;
|
||||||
rtems_device_minor_number ctrl_minor;
|
rtems_device_minor_number ctrl_minor;
|
||||||
} ata_int_st_t;
|
} ata_int_st_t;
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ typedef struct ata_dev_s {
|
|||||||
typedef struct ata_ide_ctrl_s {
|
typedef struct ata_ide_ctrl_s {
|
||||||
rtems_boolean present; /* controller state */
|
rtems_boolean present; /* controller state */
|
||||||
ata_dev_t device[2]; /* ata diveces description */
|
ata_dev_t device[2]; /* ata diveces description */
|
||||||
Chain_Control reqs; /* requests chain */
|
rtems_chain_control reqs; /* requests chain */
|
||||||
} ata_ide_ctrl_t;
|
} ata_ide_ctrl_t;
|
||||||
|
|
||||||
#endif /* __ATA_INTERNAL_H__ */
|
#endif /* __ATA_INTERNAL_H__ */
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define IDE_CONTROLLER_TRACE 0
|
||||||
|
|
||||||
#include <rtems/chain.h>
|
#include <rtems/chain.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <rtems/blkdev.h>
|
#include <rtems/blkdev.h>
|
||||||
@@ -21,6 +24,10 @@
|
|||||||
#include <libchip/ide_ctrl_cfg.h>
|
#include <libchip/ide_ctrl_cfg.h>
|
||||||
#include <libchip/ide_ctrl_io.h>
|
#include <libchip/ide_ctrl_io.h>
|
||||||
|
|
||||||
|
#if IDE_CONTROLLER_TRACE
|
||||||
|
int ide_controller_trace;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ide_controller_initialize --
|
* ide_controller_initialize --
|
||||||
* Initializes all configured IDE controllers. Controllers configuration
|
* Initializes all configured IDE controllers. Controllers configuration
|
||||||
@@ -86,10 +93,14 @@ ide_controller_initialize(rtems_device_major_number major,
|
|||||||
void
|
void
|
||||||
ide_controller_read_data_block(rtems_device_minor_number minor,
|
ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||||
uint16_t block_size,
|
uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs,
|
rtems_blkdev_sg_buffer *bufs,
|
||||||
uint32_t *cbuf,
|
uint32_t *cbuf,
|
||||||
uint32_t *pos)
|
uint32_t *pos)
|
||||||
{
|
{
|
||||||
|
#if IDE_CONTROLLER_TRACE
|
||||||
|
if (ide_controller_trace)
|
||||||
|
printk ("IDE data block read: %d:%d\n", *cbuf, bufs[*cbuf].block);
|
||||||
|
#endif
|
||||||
IDE_Controller_Table[minor].fns->ctrl_read_block(minor, block_size, bufs,
|
IDE_Controller_Table[minor].fns->ctrl_read_block(minor, block_size, bufs,
|
||||||
cbuf, pos);
|
cbuf, pos);
|
||||||
}
|
}
|
||||||
@@ -111,11 +122,15 @@ ide_controller_read_data_block(rtems_device_minor_number minor,
|
|||||||
void
|
void
|
||||||
ide_controller_write_data_block(rtems_device_minor_number minor,
|
ide_controller_write_data_block(rtems_device_minor_number minor,
|
||||||
uint16_t block_size,
|
uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs,
|
rtems_blkdev_sg_buffer *bufs,
|
||||||
uint32_t *cbuf,
|
uint32_t *cbuf,
|
||||||
uint32_t *pos)
|
uint32_t *pos)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if IDE_CONTROLLER_TRACE
|
||||||
|
if (ide_controller_trace)
|
||||||
|
printk ("IDE data block write: %d:%d\n", *cbuf, bufs[*cbuf].block);
|
||||||
|
#endif
|
||||||
IDE_Controller_Table[minor].fns->ctrl_write_block(minor, block_size, bufs,
|
IDE_Controller_Table[minor].fns->ctrl_write_block(minor, block_size, bufs,
|
||||||
cbuf, pos);
|
cbuf, pos);
|
||||||
}
|
}
|
||||||
@@ -138,6 +153,10 @@ ide_controller_read_register(rtems_device_minor_number minor,
|
|||||||
uint16_t *value)
|
uint16_t *value)
|
||||||
{
|
{
|
||||||
IDE_Controller_Table[minor].fns->ctrl_reg_read(minor, reg, value);
|
IDE_Controller_Table[minor].fns->ctrl_reg_read(minor, reg, value);
|
||||||
|
#if IDE_CONTROLLER_TRACE
|
||||||
|
if (ide_controller_trace)
|
||||||
|
printk ("IDE read reg: %d => %04x\n", reg, *value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -156,6 +175,10 @@ void
|
|||||||
ide_controller_write_register(rtems_device_minor_number minor, int reg,
|
ide_controller_write_register(rtems_device_minor_number minor, int reg,
|
||||||
uint16_t value)
|
uint16_t value)
|
||||||
{
|
{
|
||||||
|
#if IDE_CONTROLLER_TRACE
|
||||||
|
if (ide_controller_trace)
|
||||||
|
printk ("IDE write reg: %d => %04x\n", reg, value);
|
||||||
|
#endif
|
||||||
IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);
|
IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ typedef struct ide_ctrl_fns_s {
|
|||||||
* functions calls
|
* functions calls
|
||||||
*/
|
*/
|
||||||
void (*ctrl_read_block)(int minor, uint16_t block_size,
|
void (*ctrl_read_block)(int minor, uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs, uint32_t *cbuf,
|
rtems_blkdev_sg_buffer *bufs, uint32_t *cbuf,
|
||||||
uint32_t *pos);
|
uint32_t *pos);
|
||||||
void (*ctrl_write_block)(int minor, uint16_t block_size,
|
void (*ctrl_write_block)(int minor, uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs, uint32_t *cbuf,
|
rtems_blkdev_sg_buffer *bufs, uint32_t *cbuf,
|
||||||
uint32_t *pos);
|
uint32_t *pos);
|
||||||
|
|
||||||
rtems_status_code (*ctrl_config_io_speed)(int minor,
|
rtems_status_code (*ctrl_config_io_speed)(int minor,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ extern "C" {
|
|||||||
void
|
void
|
||||||
ide_controller_read_data_block(rtems_device_minor_number minor,
|
ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||||
uint16_t block_size,
|
uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs,
|
rtems_blkdev_sg_buffer *bufs,
|
||||||
uint32_t *cbuf,
|
uint32_t *cbuf,
|
||||||
uint32_t *pos);
|
uint32_t *pos);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ ide_controller_read_data_block(rtems_device_minor_number minor,
|
|||||||
void
|
void
|
||||||
ide_controller_write_data_block(rtems_device_minor_number minor,
|
ide_controller_write_data_block(rtems_device_minor_number minor,
|
||||||
uint16_t block_size,
|
uint16_t block_size,
|
||||||
blkdev_sg_buffer *bufs,
|
rtems_blkdev_sg_buffer *bufs,
|
||||||
uint32_t *cbuf,
|
uint32_t *cbuf,
|
||||||
uint32_t *pos);
|
uint32_t *pos);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user