2008-07-29 Chris Johns <chrisj@rtems.org>

* ide/ide.c: Updated to the rtems_* libblock changed.
This commit is contained in:
Chris Johns
2008-07-29 02:22:22 +00:00
parent 3899a5379f
commit c4bd98c04d
2 changed files with 320 additions and 316 deletions

View File

@@ -1,3 +1,7 @@
2008-07-29 Chris Johns <chrisj@rtems.org>
* ide/ide.c: Updated to the rtems_* libblock changed.
2008-05-23 Joel Sherrill <joel.sherrill@OARcorp.com> 2008-05-23 Joel Sherrill <joel.sherrill@OARcorp.com>
* console/console.c, console/serial_mouse.c: Eliminate copies of * console/console.c, console/serial_mouse.c: Eliminate copies of

View File

@@ -1,316 +1,316 @@
/*===============================================================*\ /*===============================================================*\
| Project: RTEMS PC386 IDE harddisc driver | | Project: RTEMS PC386 IDE harddisc driver |
+-----------------------------------------------------------------+ +-----------------------------------------------------------------+
| File: ide.c | | File: ide.c |
+-----------------------------------------------------------------+ +-----------------------------------------------------------------+
| Copyright (c) 2003 IMD | | Copyright (c) 2003 IMD |
| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | | Ingenieurbuero fuer Microcomputertechnik Th. Doerfler |
| <Thomas.Doerfler@imd-systems.de> | | <Thomas.Doerfler@imd-systems.de> |
| all rights reserved | | all rights reserved |
+-----------------------------------------------------------------+ +-----------------------------------------------------------------+
| this file contains the BSP layer for IDE access below the | | this file contains the BSP layer for IDE access below the |
| libchip IDE harddisc driver | | libchip IDE harddisc driver |
| based on a board specific driver from | | based on a board specific driver from |
| Eugeny S. Mints, Oktet | | Eugeny S. Mints, Oktet |
| | | |
| The license and distribution terms for this file may be | | The license and distribution terms for this file may be |
| found in the file LICENSE in this distribution or at | | found in the file LICENSE in this distribution or at |
| http://www.rtems.com/license/LICENSE. | | http://www.rtems.com/license/LICENSE. |
| | | |
+-----------------------------------------------------------------+ +-----------------------------------------------------------------+
| date history ID | | date history ID |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 01.14.03 creation doe | | 01.14.03 creation doe |
\*===============================================================*/ \*===============================================================*/
#include <rtems.h> #include <rtems.h>
#include <bsp.h> #include <bsp.h>
#include <libchip/ide_ctrl.h> #include <libchip/ide_ctrl.h>
#include <libchip/ide_ctrl_cfg.h> #include <libchip/ide_ctrl_cfg.h>
#include <libchip/ide_ctrl_io.h> #include <libchip/ide_ctrl_io.h>
/* #define DEBUG_OUT */ /* #define DEBUG_OUT */
/* /*
* support functions for IDE harddisk IF * support functions for IDE harddisk IF
*/ */
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
boolean pc386_ide_probe boolean pc386_ide_probe
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| This function should probe, whether a IDE disk is available | | This function should probe, whether a IDE disk is available |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor int minor
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| TRUE, when flash disk available | | TRUE, when flash disk available |
\*=========================================================================*/ \*=========================================================================*/
{ {
boolean ide_card_plugged = TRUE; /* assume: we have a disk here */ boolean ide_card_plugged = TRUE; /* assume: we have a disk here */
return ide_card_plugged; return ide_card_plugged;
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
void pc386_ide_initialize void pc386_ide_initialize
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| initialize IDE access | | initialize IDE access |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor /* controller minor number */ int minor /* controller minor number */
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
/* /*
* FIXME: enable interrupts, if needed * FIXME: enable interrupts, if needed
*/ */
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
void pc386_ide_read_reg void pc386_ide_read_reg
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| read a IDE controller register | | read a IDE controller register |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, /* controller minor number */ int minor, /* controller minor number */
int reg, /* register index to access */ int reg, /* register index to access */
uint16_t *value /* ptr to return value location */ uint16_t *value /* ptr to return value location */
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
uint32_t port = IDE_Controller_Table[minor].port1; uint32_t port = IDE_Controller_Table[minor].port1;
uint8_t bval1,bval2; uint8_t bval1,bval2;
if (reg == IDE_REGISTER_DATA_WORD) { if (reg == IDE_REGISTER_DATA_WORD) {
inport_byte(port+reg, bval1); inport_byte(port+reg, bval1);
inport_byte(port+reg+1, bval2); inport_byte(port+reg+1, bval2);
*value = bval1 + (bval2 << 8); *value = bval1 + (bval2 << 8);
} }
else { else {
inport_byte(port+reg, bval1); inport_byte(port+reg, bval1);
*value = bval1; *value = bval1;
} }
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("pc386_ide_read_reg (0x%x)=0x%x\r\n",reg,*value & 0xff); printk("pc386_ide_read_reg (0x%x)=0x%x\r\n",reg,*value & 0xff);
#endif #endif
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
void pc386_ide_write_reg void pc386_ide_write_reg
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| write a IDE controller register | | write a IDE controller register |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, /* controller minor number */ int minor, /* controller minor number */
int reg, /* register index to access */ int reg, /* register index to access */
uint16_t value /* value to write */ uint16_t value /* value to write */
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
uint32_t port = IDE_Controller_Table[minor].port1; uint32_t port = IDE_Controller_Table[minor].port1;
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("pc386_ide_write_reg(0x%x,0x%x)\r\n",reg,value & 0xff); printk("pc386_ide_write_reg(0x%x,0x%x)\r\n",reg,value & 0xff);
#endif #endif
if (reg == IDE_REGISTER_DATA_WORD) { if (reg == IDE_REGISTER_DATA_WORD) {
outport_word(port+reg,value); outport_word(port+reg,value);
} }
else { else {
outport_byte(port+reg,value); outport_byte(port+reg,value);
} }
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
void pc386_ide_read_block void pc386_ide_read_block
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| read a IDE controller data block | | read a IDE controller data block |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, int 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
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
uint32_t port = IDE_Controller_Table[minor].port1; uint32_t port = IDE_Controller_Table[minor].port1;
uint16_t cnt = 0; uint16_t cnt = 0;
uint32_t llength = bufs[(*cbuf)].length; uint32_t llength = bufs[(*cbuf)].length;
uint8_t status_val; uint8_t status_val;
uint16_t *lbuf = (uint16_t*) uint16_t *lbuf = (uint16_t*)
((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos)); ((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos));
inport_byte(port+IDE_REGISTER_STATUS,status_val); inport_byte(port+IDE_REGISTER_STATUS,status_val);
while ((status_val & IDE_REGISTER_STATUS_DRQ) && while ((status_val & IDE_REGISTER_STATUS_DRQ) &&
(cnt < block_size)) { (cnt < block_size)) {
inport_word(port+IDE_REGISTER_DATA,*lbuf); inport_word(port+IDE_REGISTER_DATA,*lbuf);
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("0x%x ",*lbuf); printk("0x%x ",*lbuf);
#endif #endif
lbuf++; lbuf++;
cnt += sizeof(*lbuf); cnt += sizeof(*lbuf);
(*pos) += sizeof(*lbuf); (*pos) += sizeof(*lbuf);
if ((*pos) == llength) { if ((*pos) == llength) {
(*pos) = 0; (*pos) = 0;
(*cbuf)++; (*cbuf)++;
lbuf = bufs[(*cbuf)].buffer; lbuf = bufs[(*cbuf)].buffer;
llength = bufs[(*cbuf)].length; llength = bufs[(*cbuf)].length;
} }
inport_byte(port+IDE_REGISTER_STATUS,status_val); inport_byte(port+IDE_REGISTER_STATUS,status_val);
} }
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("pc386_ide_read_block()\r\n"); printk("pc386_ide_read_block()\r\n");
#endif #endif
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
void pc386_ide_write_block void pc386_ide_write_block
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| write a IDE controller data block | | write a IDE controller data block |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, int 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
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
uint32_t port = IDE_Controller_Table[minor].port1; uint32_t port = IDE_Controller_Table[minor].port1;
uint16_t cnt = 0; uint16_t cnt = 0;
uint32_t llength = bufs[(*cbuf)].length; uint32_t llength = bufs[(*cbuf)].length;
uint8_t status_val; uint8_t status_val;
uint16_t *lbuf = (uint16_t*) uint16_t *lbuf = (uint16_t*)
((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos)); ((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos));
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("pc386_ide_write_block()\r\n"); printk("pc386_ide_write_block()\r\n");
#endif #endif
inport_byte(port+IDE_REGISTER_STATUS,status_val); inport_byte(port+IDE_REGISTER_STATUS,status_val);
while ((status_val & IDE_REGISTER_STATUS_DRQ) && while ((status_val & IDE_REGISTER_STATUS_DRQ) &&
(cnt < block_size)) { (cnt < block_size)) {
#ifdef DEBUG_OUT #ifdef DEBUG_OUT
printk("0x%x ",*lbuf); printk("0x%x ",*lbuf);
#endif #endif
outport_word(port+IDE_REGISTER_DATA,*lbuf); outport_word(port+IDE_REGISTER_DATA,*lbuf);
lbuf++; lbuf++;
cnt += sizeof(*lbuf); cnt += sizeof(*lbuf);
(*pos) += sizeof(*lbuf); (*pos) += sizeof(*lbuf);
if ((*pos) == llength) { if ((*pos) == llength) {
(*pos) = 0; (*pos) = 0;
(*cbuf)++; (*cbuf)++;
lbuf = bufs[(*cbuf)].buffer; lbuf = bufs[(*cbuf)].buffer;
llength = bufs[(*cbuf)].length; llength = bufs[(*cbuf)].length;
} }
inport_byte(port+IDE_REGISTER_STATUS,status_val); inport_byte(port+IDE_REGISTER_STATUS,status_val);
} }
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int pc386_ide_control int pc386_ide_control
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| control interface for controller | | control interface for controller |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, /* controller minor number */ int minor, /* controller minor number */
uint32_t cmd, /* command to send */ uint32_t cmd, /* command to send */
void * arg /* optional argument */ void * arg /* optional argument */
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| <none> | | <none> |
\*=========================================================================*/ \*=========================================================================*/
{ {
return 0; return 0;
} }
/*=========================================================================*\ /*=========================================================================*\
| Function: | | Function: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
rtems_status_code pc386_ide_config_io_speed rtems_status_code pc386_ide_config_io_speed
( (
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Purpose: | | Purpose: |
| set up transfer speed, if possible | | set up transfer speed, if possible |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------------------+
| Input Parameters: | | Input Parameters: |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int minor, /* controller minor number */ int minor, /* controller minor number */
uint16_t modes_avail /* optional argument */ uint16_t modes_avail /* optional argument */
) )
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Return Value: | | Return Value: |
| rtems_status_code | | rtems_status_code |
\*=========================================================================*/ \*=========================================================================*/
{ {
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }
/* /*
* The following table configures the functions used for IDE drivers * The following table configures the functions used for IDE drivers
* in this BSP. * in this BSP.
*/ */
ide_ctrl_fns_t pc386_ide_ctrl_fns = { ide_ctrl_fns_t pc386_ide_ctrl_fns = {
pc386_ide_probe, pc386_ide_probe,
pc386_ide_initialize, pc386_ide_initialize,
pc386_ide_control, pc386_ide_control,
pc386_ide_read_reg, pc386_ide_read_reg,
pc386_ide_write_reg, pc386_ide_write_reg,
pc386_ide_read_block, pc386_ide_read_block,
pc386_ide_write_block, pc386_ide_write_block,
pc386_ide_config_io_speed pc386_ide_config_io_speed
}; };