forked from Imagelibrary/rtems
2008-08-02 Chris Johns <chrisj@rtems.org>
* libchip/i2c/spi-sd-card.c, libchip/ide/ata.c: Remove rtems_blkdev_request count and start references. Use RTEMS_BLKDEV_START_BLOCK.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2008-08-02 Chris Johns <chrisj@rtems.org>
|
||||
|
||||
* libchip/i2c/spi-sd-card.c, libchip/ide/ata.c: Remove
|
||||
rtems_blkdev_request count and start references. Use
|
||||
RTEMS_BLKDEV_START_BLOCK.
|
||||
|
||||
2008-07-29 Chris Johns <chrisj@rtems.org>
|
||||
|
||||
* libchip/i2c/spi-sd-card.c: Updated to the libblock changes.
|
||||
|
||||
@@ -562,20 +562,17 @@ static int sd_card_disk_block_read( sd_card_driver_entry *e, rtems_blkdev_reques
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
int rv = 0;
|
||||
uint32_t start_address = r->start << e->block_size_shift;
|
||||
uint32_t start_address = RTEMS_BLKDEV_START_BLOCK (r) << e->block_size_shift;
|
||||
uint32_t i = 0;
|
||||
|
||||
DEBUG_PRINT( "start = %u, count = %u, bufnum = %u\n", r->start, r->count, r->bufnum);
|
||||
DEBUG_PRINT( "start = %u, bufnum = %u\n", r->start, r->bufnum);
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Check request */
|
||||
if (r->count != r->bufnum) {
|
||||
SYSLOG_ERROR( "Block count and buffer number are not equal");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
} else if (r->start >= e->block_number) {
|
||||
if (r->bufs[0].block >= e->block_number) {
|
||||
SYSLOG_ERROR( "Start block number out of range");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
} else if (r->count > e->block_number - r->start) {
|
||||
} else if (r->bufnum > e->block_number - RTEMS_BLKDEV_START_BLOCK (r)) {
|
||||
SYSLOG_ERROR( "Block count out of range");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -585,7 +582,7 @@ static int sd_card_disk_block_read( sd_card_driver_entry *e, rtems_blkdev_reques
|
||||
sc = sd_card_start( e);
|
||||
CLEANUP_SCRV( sc, rv, sd_card_disk_block_read_cleanup, "Start");
|
||||
|
||||
if (r->count == 1) {
|
||||
if (r->bufnum == 1) {
|
||||
#ifdef DEBUG
|
||||
/* Check buffer */
|
||||
if (r->bufs [0].length != e->block_size) {
|
||||
@@ -605,7 +602,7 @@ static int sd_card_disk_block_read( sd_card_driver_entry *e, rtems_blkdev_reques
|
||||
CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
|
||||
|
||||
/* Multiple block read */
|
||||
for (i = 0; i < r->count; ++i) {
|
||||
for (i = 0; i < r->bufnum; ++i) {
|
||||
#ifdef DEBUG
|
||||
/* Check buffer */
|
||||
if (r->bufs [i].length != e->block_size) {
|
||||
@@ -652,20 +649,17 @@ static int sd_card_disk_block_write( sd_card_driver_entry *e, rtems_blkdev_reque
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
int rv = 0;
|
||||
uint32_t start_address = r->start << e->block_size_shift;
|
||||
uint32_t start_address = RTEMS_BLKDEV_START_BLOCK (r) << e->block_size_shift;
|
||||
uint32_t i = 0;
|
||||
|
||||
DEBUG_PRINT( "start = %u, count = %u, bufnum = %u\n", r->start, r->count, r->bufnum);
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Check request */
|
||||
if (r->count != r->bufnum) {
|
||||
SYSLOG_ERROR( "Block count and buffer number are not equal");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
} else if (r->start >= e->block_number) {
|
||||
if (r->bufs[0].block >= e->block_number) {
|
||||
SYSLOG_ERROR( "Start block number out of range");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
} else if (r->count > e->block_number - r->start) {
|
||||
} else if (r->bufnum > e->block_number - RTEMS_BLKDEV_START_BLOCK (r)) {
|
||||
SYSLOG_ERROR( "Block count out of range");
|
||||
return -RTEMS_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -675,7 +669,7 @@ static int sd_card_disk_block_write( sd_card_driver_entry *e, rtems_blkdev_reque
|
||||
sc = sd_card_start( e);
|
||||
CLEANUP_SCRV( sc, rv, sd_card_disk_block_write_cleanup, "Start");
|
||||
|
||||
if (r->count == 1) {
|
||||
if (r->bufnum == 1) {
|
||||
#ifdef DEBUG
|
||||
/* Check buffer */
|
||||
if (r->bufs [0].length != e->block_size) {
|
||||
@@ -695,7 +689,7 @@ static int sd_card_disk_block_write( sd_card_driver_entry *e, rtems_blkdev_reque
|
||||
CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
|
||||
|
||||
/* Multiple block write */
|
||||
for (i = 0; i < r->count; ++i) {
|
||||
for (i = 0; i < r->bufnum; ++i) {
|
||||
#ifdef DEBUG
|
||||
/* Check buffer */
|
||||
if (r->bufs [i].length != e->block_size) {
|
||||
@@ -758,6 +752,9 @@ static int sd_card_disk_ioctl( dev_t dev, uint32_t req, void *arg)
|
||||
return sd_card_disk_block_read( e, r);
|
||||
case RTEMS_BLKDEV_REQ_WRITE:
|
||||
return sd_card_disk_block_write( e, r);
|
||||
case RTEMS_BLKDEV_CAPABILITIES:
|
||||
*((uint32_t*) arg) = RTEMS_BLKDEV_CAP_MULTISECTOR_CONT;
|
||||
return 0;
|
||||
default:
|
||||
errno = EBADRQC;
|
||||
return -1;
|
||||
|
||||
@@ -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>
|
||||
@@ -211,7 +211,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
}
|
||||
|
||||
areq->breq = req;
|
||||
areq->cnt = req->count;
|
||||
areq->cnt = req->bufnum;
|
||||
areq->cbuf = 0;
|
||||
areq->pos = 0;
|
||||
|
||||
@@ -239,7 +239,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("ata_io_data_request: type: READ: %d, %d\n",
|
||||
req->bufs[0].block, req->count);
|
||||
req->bufs[0].block, req->bufnum);
|
||||
#endif
|
||||
areq->type = ATA_COMMAND_TYPE_PIO_IN;
|
||||
|
||||
@@ -251,7 +251,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
*/
|
||||
areq->regs.regs[IDE_REGISTER_COMMAND] =
|
||||
((ATA_DEV_INFO(ctrl_minor, dev).max_multiple) &&
|
||||
(req->count > 1) &&
|
||||
(req->bufnum > 1) &&
|
||||
(ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ?
|
||||
ATA_COMMAND_READ_MULTIPLE :
|
||||
ATA_COMMAND_READ_SECTORS;
|
||||
@@ -260,7 +260,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("ata_io_data_request: type: WRITE: %d, %d\n",
|
||||
req->bufs[0].block, req->count);
|
||||
req->bufs[0].block, req->bufnum);
|
||||
#endif
|
||||
areq->type = ATA_COMMAND_TYPE_PIO_OUT;
|
||||
|
||||
@@ -272,7 +272,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
*/
|
||||
areq->regs.regs[IDE_REGISTER_COMMAND] =
|
||||
((ATA_DEV_INFO(ctrl_minor, dev).max_multiple) &&
|
||||
(req->count > 1) &&
|
||||
(req->bufnum > 1) &&
|
||||
(ATA_DEV_INFO(ctrl_minor, dev).current_multiple > 1)) ?
|
||||
ATA_COMMAND_WRITE_MULTIPLE :
|
||||
ATA_COMMAND_WRITE_SECTORS;
|
||||
@@ -312,7 +312,7 @@ ata_io_data_request(dev_t device, rtems_blkdev_request *req)
|
||||
}
|
||||
|
||||
/* fill sector count register */
|
||||
areq->regs.regs[IDE_REGISTER_SECTOR_COUNT] = areq->breq->count;
|
||||
areq->regs.regs[IDE_REGISTER_SECTOR_COUNT] = areq->breq->bufnum;
|
||||
|
||||
/* add request to the queue of awaiting requests to the controller */
|
||||
ata_add_to_controller_queue(ctrl_minor, areq);
|
||||
@@ -1196,7 +1196,6 @@ rtems_ata_initialize(rtems_device_major_number major,
|
||||
breq.req.req_done = NULL;
|
||||
breq.req.done_arg = &breq;
|
||||
breq.req.bufnum = 1;
|
||||
breq.req.count = 1;
|
||||
breq.req.bufs[0].length = ATA_SECTOR_SIZE;
|
||||
breq.req.bufs[0].buffer = buffer;
|
||||
|
||||
@@ -1365,7 +1364,7 @@ rtems_ata_initialize(rtems_device_major_number major,
|
||||
areq.regs.to_read = ATA_REGISTERS_VALUE(IDE_REGISTER_STATUS);
|
||||
areq.breq = (rtems_blkdev_request *)&breq;
|
||||
|
||||
areq.cnt = breq.req.count;
|
||||
areq.cnt = breq.req.bufnum;
|
||||
|
||||
areq.regs.regs[IDE_REGISTER_DEVICE_HEAD] |=
|
||||
(dev << IDE_REGISTER_DEVICE_HEAD_DEV_POS);
|
||||
|
||||
Reference in New Issue
Block a user