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>
|
||||
|
||||
* 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;
|
||||
int rv = 0;
|
||||
@@ -648,7 +648,7 @@ sd_card_disk_block_read_cleanup:
|
||||
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;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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) {
|
||||
case BLKDEV_REQ_READ:
|
||||
case RTEMS_BLKDEV_REQ_READ:
|
||||
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);
|
||||
default:
|
||||
errno = EBADRQC;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <libchip/ide_ctrl_cfg.h>
|
||||
#include "ata_internal.h"
|
||||
#include <libchip/ata.h>
|
||||
/* #define DEBUG */
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
@@ -57,10 +57,43 @@ int ata_irq_chain_cnt = 0;
|
||||
#endif
|
||||
|
||||
#define SAFE
|
||||
#define SAFE_MUTEX
|
||||
|
||||
#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;
|
||||
|
||||
#define DISABLE_PREEMPTION(key) \
|
||||
#define PREEMPTION_KEY(key) preemption_key key
|
||||
|
||||
#define DISABLE_PREEMPTION(key) \
|
||||
do { \
|
||||
rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &(key)); \
|
||||
} while (0)
|
||||
@@ -70,11 +103,12 @@ typedef rtems_mode preemption_key;
|
||||
rtems_mode temp; \
|
||||
rtems_task_mode((key), RTEMS_PREEMPT_MASK, &temp); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
#else /* !SAFE */
|
||||
typedef boolean preemption_key;
|
||||
|
||||
#define PREEMPTION_KEY(key) preemption_key key
|
||||
|
||||
#define DISABLE_PREEMPTION(key) \
|
||||
do { \
|
||||
(key) = _Thread_Executing->is_preemptible; \
|
||||
@@ -95,8 +129,8 @@ typedef boolean preemption_key;
|
||||
|
||||
/* Block device request with a single buffer provided */
|
||||
typedef struct blkdev_request1 {
|
||||
blkdev_request req;
|
||||
blkdev_sg_buffer sg[1];
|
||||
rtems_blkdev_request req;
|
||||
rtems_blkdev_sg_buffer sg[1];
|
||||
} blkdev_request1;
|
||||
|
||||
|
||||
@@ -152,7 +186,7 @@ ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
||||
* error occured
|
||||
*/
|
||||
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 */
|
||||
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 */
|
||||
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;
|
||||
else
|
||||
areq->regs.regs[IDE_REGISTER_COMMAND] = ATA_COMMAND_WRITE_DMA;
|
||||
}
|
||||
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;
|
||||
|
||||
/*
|
||||
@@ -220,6 +258,10 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
||||
}
|
||||
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;
|
||||
|
||||
/*
|
||||
@@ -242,15 +284,16 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
||||
*/
|
||||
if (ATA_DEV_INFO(ctrl_minor, dev).lba_avaible)
|
||||
{
|
||||
areq->regs.regs[IDE_REGISTER_LBA0] = (uint8_t)req->start;
|
||||
areq->regs.regs[IDE_REGISTER_LBA1] = (uint8_t)(req->start >> 8);
|
||||
areq->regs.regs[IDE_REGISTER_LBA2] = (uint8_t)(req->start >> 16);
|
||||
areq->regs.regs[IDE_REGISTER_LBA3] |= (uint8_t) (req->start >> 24);
|
||||
uint32_t start = req->bufs[0].block;
|
||||
areq->regs.regs[IDE_REGISTER_LBA0] = (uint8_t)start;
|
||||
areq->regs.regs[IDE_REGISTER_LBA1] = (uint8_t)(start >> 8);
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t count = req->start;
|
||||
uint32_t count = req->bufs[0].block;
|
||||
|
||||
areq->regs.regs[IDE_REGISTER_SECTOR_NUMBER] =
|
||||
(count % ATA_DEV_INFO(ctrl_minor, dev).sectors) + 1;
|
||||
@@ -273,7 +316,7 @@ ata_io_data_request(dev_t device, blkdev_request *req)
|
||||
|
||||
/* add request to the queue of awaiting requests to the controller */
|
||||
ata_add_to_controller_queue(ctrl_minor, areq);
|
||||
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -424,7 +467,7 @@ ata_process_request(rtems_device_minor_number ctrl_minor)
|
||||
* data block
|
||||
*/
|
||||
ISR_Level level;
|
||||
|
||||
|
||||
/* if no requests to controller then do nothing */
|
||||
if (rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
|
||||
return;
|
||||
@@ -459,6 +502,10 @@ ata_process_request(rtems_device_minor_number ctrl_minor)
|
||||
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 */
|
||||
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,
|
||||
rtems_status_code status, int error)
|
||||
{
|
||||
preemption_key key;
|
||||
|
||||
assert(areq);
|
||||
|
||||
DISABLE_PREEMPTION(key);
|
||||
#ifdef DEBUG
|
||||
printf("ata_request_done: entry\n");
|
||||
#endif
|
||||
|
||||
ATA_EXEC_CALLBACK(areq, status, error);
|
||||
rtems_chain_extract(&areq->link);
|
||||
|
||||
|
||||
if (!rtems_chain_is_empty(&ata_ide_ctrls[ctrl_minor].reqs))
|
||||
{
|
||||
ENABLE_PREEMPTION(key);
|
||||
free(areq);
|
||||
free(areq);
|
||||
ata_process_request(ctrl_minor);
|
||||
return;
|
||||
}
|
||||
ENABLE_PREEMPTION(key);
|
||||
|
||||
free(areq);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("ata_request_done: exit\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ata_non_data_request_done --
|
||||
@@ -577,6 +628,10 @@ static void
|
||||
ata_add_to_controller_queue(rtems_device_minor_number ctrl_minor,
|
||||
ata_req_t *areq)
|
||||
{
|
||||
PREEMPTION_KEY(key);
|
||||
|
||||
DISABLE_PREEMPTION(key);
|
||||
|
||||
rtems_chain_append(&ata_ide_ctrls[ctrl_minor].reqs, &areq->link);
|
||||
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
|
||||
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
|
||||
|
||||
void ata_interrupt_handler(rtems_irq_hdl_param 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;
|
||||
ata_queue_msg_t msg;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("ata_pio_out_protocol:\n");
|
||||
#endif
|
||||
|
||||
dev = areq->regs.regs[IDE_REGISTER_DEVICE_HEAD] &
|
||||
IDE_REGISTER_DEVICE_HEAD_DEV;
|
||||
|
||||
@@ -826,9 +886,15 @@ ata_queue_task(rtems_task_argument arg)
|
||||
uint16_t val1;
|
||||
rtems_status_code rc;
|
||||
ISR_Level level;
|
||||
|
||||
PREEMPTION_KEY(key);
|
||||
|
||||
DISABLE_PREEMPTION(key);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ENABLE_PREEMPTION(key);
|
||||
|
||||
/* get event which has happend */
|
||||
rc = rtems_message_queue_receive(ata_queue_id, &msg, &size, RTEMS_WAIT,
|
||||
RTEMS_NO_TIMEOUT);
|
||||
@@ -838,11 +904,13 @@ ata_queue_task(rtems_task_argument arg)
|
||||
/* get controller on which event has happend */
|
||||
ctrl_minor = msg.ctrl_minor;
|
||||
|
||||
DISABLE_PREEMPTION(key);
|
||||
|
||||
/* get current request to the controller */
|
||||
_ISR_Disable(level);
|
||||
areq = (ata_req_t *)(ata_ide_ctrls[ctrl_minor].reqs.first);
|
||||
_ISR_Enable(level);
|
||||
|
||||
|
||||
switch(msg.type)
|
||||
{
|
||||
case ATA_MSG_PROCESS_NEXT_EVT:
|
||||
@@ -925,6 +993,10 @@ ata_queue_task(rtems_task_argument arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
printf("ata_queue_task: internal error\n");
|
||||
rtems_task_delete (RTEMS_SELF);
|
||||
#endif
|
||||
rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR);
|
||||
break;
|
||||
}
|
||||
@@ -963,14 +1035,19 @@ ata_ioctl(dev_t device, int cmd, void *argp)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BLKIO_REQUEST:
|
||||
status = ata_io_data_request(device, (blkdev_request *)argp);
|
||||
case RTEMS_BLKIO_REQUEST:
|
||||
status = ata_io_data_request(device, (rtems_blkdev_request *)argp);
|
||||
break;
|
||||
|
||||
case ATAIO_SET_MULTIPLE_MODE:
|
||||
status = ata_non_data_request(device, cmd, argp);
|
||||
break;
|
||||
|
||||
case RTEMS_BLKDEV_CAPABILITIES:
|
||||
*((uint32_t*) argp) = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
|
||||
status = RTEMS_SUCCESSFUL;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EBADRQC;
|
||||
return -1;
|
||||
@@ -999,9 +1076,9 @@ ata_ioctl(dev_t device, int cmd, void *argp)
|
||||
* error occured
|
||||
*/
|
||||
rtems_device_driver
|
||||
ata_initialize(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor_arg,
|
||||
void *args)
|
||||
rtems_ata_initialize(rtems_device_major_number major,
|
||||
rtems_device_minor_number minor_arg,
|
||||
void *args)
|
||||
{
|
||||
uint32_t ctrl_minor;
|
||||
rtems_status_code status;
|
||||
@@ -1028,6 +1105,16 @@ ata_initialize(rtems_device_major_number major,
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
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 */
|
||||
status = rtems_message_queue_create(
|
||||
rtems_build_name('A', 'T', 'A', 'Q'),
|
||||
@@ -1047,11 +1134,11 @@ ata_initialize(rtems_device_major_number major,
|
||||
*/
|
||||
status = rtems_task_create(
|
||||
rtems_build_name ('A', 'T', 'A', 'T'),
|
||||
((ata_driver_task_priority > 0)
|
||||
? ata_driver_task_priority
|
||||
((rtems_ata_driver_task_priority > 0)
|
||||
? rtems_ata_driver_task_priority
|
||||
: ATA_DRIVER_TASK_DEFAULT_PRIORITY),
|
||||
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_NO_FLOATING_POINT | RTEMS_LOCAL,
|
||||
&ata_task_id);
|
||||
@@ -1215,7 +1302,7 @@ ata_initialize(rtems_device_major_number major,
|
||||
ATA_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC;
|
||||
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
|
||||
@@ -1276,7 +1363,7 @@ ata_initialize(rtems_device_major_number major,
|
||||
areq.regs.regs[IDE_REGISTER_COMMAND] =
|
||||
ATA_COMMAND_IDENTIFY_DEVICE;
|
||||
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;
|
||||
|
||||
@@ -1363,7 +1450,7 @@ ata_initialize(rtems_device_major_number major,
|
||||
(ATA_DEV_INFO(ctrl_minor, dev).heads *
|
||||
ATA_DEV_INFO(ctrl_minor, dev).cylinders *
|
||||
ATA_DEV_INFO(ctrl_minor, dev).sectors),
|
||||
(block_device_ioctl) ata_ioctl, name);
|
||||
(rtems_block_device_ioctl) ata_ioctl, name);
|
||||
if (status != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
ata_devs[ata_devs_number].device = ATA_UNDEFINED_VALUE;
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
/*
|
||||
* ata.h
|
||||
*
|
||||
* ATA RTEMS driver header file. This file should be included from an
|
||||
* application.
|
||||
*
|
||||
* Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#ifndef __ATA_H__
|
||||
#define __ATA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <rtems/blkdev.h>
|
||||
|
||||
rtems_device_driver ata_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *args);
|
||||
|
||||
#define ATA_DRIVER_TABLE_ENTRY \
|
||||
{ata_initialize, GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES}
|
||||
|
||||
/* ATA IOCTL request codes */
|
||||
#define ATAIO_SET_MULTIPLE_MODE _IO('A', 1)
|
||||
|
||||
/*
|
||||
* ATA driver configuration parameters
|
||||
* FIXME: should be configured more easy...
|
||||
*/
|
||||
#define ATA_DRIVER_MESSAGE_QUEUE_SIZE 50
|
||||
#define ATA_DRIVER_TASK_STACK_SIZE 16*1024
|
||||
#define ATA_DRIVER_TASK_DEFAULT_PRIORITY 140
|
||||
extern rtems_task_priority ata_driver_task_priority;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ATA_H__ */
|
||||
/*
|
||||
* ata.h
|
||||
*
|
||||
* ATA RTEMS driver header file. This file should be included from an
|
||||
* application.
|
||||
*
|
||||
* Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#ifndef __ATA_H__
|
||||
#define __ATA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <rtems/blkdev.h>
|
||||
|
||||
rtems_device_driver rtems_ata_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *args);
|
||||
|
||||
#define ATA_DRIVER_TABLE_ENTRY \
|
||||
{rtems_ata_initialize, RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES}
|
||||
|
||||
/* ATA IOCTL request codes */
|
||||
#define ATAIO_SET_MULTIPLE_MODE _IO('A', 1)
|
||||
|
||||
/*
|
||||
* ATA driver configuration parameters
|
||||
* FIXME: should be configured more easy...
|
||||
*/
|
||||
#define ATA_DRIVER_MESSAGE_QUEUE_SIZE 50
|
||||
#define ATA_DRIVER_TASK_STACK_SIZE 16*1024
|
||||
#define ATA_DRIVER_TASK_DEFAULT_PRIORITY 140
|
||||
extern rtems_task_priority rtems_ata_driver_task_priority;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ATA_H__ */
|
||||
|
||||
@@ -197,13 +197,13 @@ typedef struct ata_registers_s {
|
||||
|
||||
/* ATA request */
|
||||
typedef struct ata_req_s {
|
||||
Chain_Node link; /* link in requests chain */
|
||||
rtems_chain_node link; /* link in requests chain */
|
||||
char type; /* request type */
|
||||
ata_registers_t regs; /* ATA command */
|
||||
uint32_t cnt; /* Number of sectors to be exchanged */
|
||||
uint32_t cbuf; /* number of current buffer from breq in use */
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
typedef struct ata_int_st_s {
|
||||
Chain_Node link;
|
||||
rtems_chain_node link;
|
||||
rtems_device_minor_number ctrl_minor;
|
||||
} ata_int_st_t;
|
||||
|
||||
@@ -275,7 +275,7 @@ typedef struct ata_ide_dev_s {
|
||||
* ATA device description
|
||||
*/
|
||||
typedef struct ata_dev_s {
|
||||
int8_t present; /* 1 -- present, 0 -- not present, */
|
||||
int8_t present; /* 1 -- present, 0 -- not present, */
|
||||
/* -1 -- non-initialized */
|
||||
uint16_t cylinders;
|
||||
uint16_t heads;
|
||||
@@ -300,7 +300,7 @@ typedef struct ata_dev_s {
|
||||
typedef struct ata_ide_ctrl_s {
|
||||
rtems_boolean present; /* controller state */
|
||||
ata_dev_t device[2]; /* ata diveces description */
|
||||
Chain_Control reqs; /* requests chain */
|
||||
rtems_chain_control reqs; /* requests chain */
|
||||
} ata_ide_ctrl_t;
|
||||
|
||||
#endif /* __ATA_INTERNAL_H__ */
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#define IDE_CONTROLLER_TRACE 0
|
||||
|
||||
#include <rtems/chain.h>
|
||||
#include <assert.h>
|
||||
#include <rtems/blkdev.h>
|
||||
@@ -21,6 +24,10 @@
|
||||
#include <libchip/ide_ctrl_cfg.h>
|
||||
#include <libchip/ide_ctrl_io.h>
|
||||
|
||||
#if IDE_CONTROLLER_TRACE
|
||||
int ide_controller_trace;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ide_controller_initialize --
|
||||
* Initializes all configured IDE controllers. Controllers configuration
|
||||
@@ -86,10 +93,14 @@ ide_controller_initialize(rtems_device_major_number major,
|
||||
void
|
||||
ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||
uint16_t block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos)
|
||||
rtems_blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
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,
|
||||
cbuf, pos);
|
||||
}
|
||||
@@ -111,11 +122,15 @@ ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||
void
|
||||
ide_controller_write_data_block(rtems_device_minor_number minor,
|
||||
uint16_t block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos)
|
||||
rtems_blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
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,
|
||||
cbuf, pos);
|
||||
}
|
||||
@@ -138,6 +153,10 @@ ide_controller_read_register(rtems_device_minor_number minor,
|
||||
uint16_t *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,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,10 +74,10 @@ typedef struct ide_ctrl_fns_s {
|
||||
* functions calls
|
||||
*/
|
||||
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);
|
||||
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);
|
||||
|
||||
rtems_status_code (*ctrl_config_io_speed)(int minor,
|
||||
|
||||
@@ -104,9 +104,9 @@ extern "C" {
|
||||
void
|
||||
ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||
uint16_t block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos);
|
||||
rtems_blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos);
|
||||
|
||||
/*
|
||||
* ide_controller_write_data_block --
|
||||
@@ -125,9 +125,9 @@ ide_controller_read_data_block(rtems_device_minor_number minor,
|
||||
void
|
||||
ide_controller_write_data_block(rtems_device_minor_number minor,
|
||||
uint16_t block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos);
|
||||
rtems_blkdev_sg_buffer *bufs,
|
||||
uint32_t *cbuf,
|
||||
uint32_t *pos);
|
||||
|
||||
/*
|
||||
* ide_controller_read_register --
|
||||
|
||||
Reference in New Issue
Block a user