mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
2003-03-25 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
PR 368/filesystems * startup/ldsegs.S: Increase alignment. * Makefile.am, configure.ac, include/bsp.h, wrapup/Makefile.am: Added IDE supporting infrastructure. * ide/Makefile.am, ide/ide.c, ide/idecfg.c: New files. Added BSP support for libchip standard ide driver.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2003-03-25 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
|
||||
|
||||
PR 368/filesystems
|
||||
* startup/ldsegs.S: Increase alignment.
|
||||
* Makefile.am, configure.ac, include/bsp.h, wrapup/Makefile.am:
|
||||
Added IDE supporting infrastructure.
|
||||
* ide/Makefile.am, ide/ide.c, ide/idecfg.c: New files. Added
|
||||
BSP support for libchip standard ide driver.
|
||||
|
||||
2003-03-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
|
||||
|
||||
* configure.ac: Remove AC_CONFIG_AUX_DIR.
|
||||
|
||||
@@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../../../../../../aclocal
|
||||
# wrapup is the one that actually builds and installs the library
|
||||
# from the individual .rel files built in other directories
|
||||
SUBDIRS = . include tools start startup clock console timer ne2000 wd8003 \
|
||||
3c509 wrapup
|
||||
3c509 ide wrapup
|
||||
|
||||
include $(top_srcdir)/../../bsp.am
|
||||
|
||||
|
||||
@@ -37,5 +37,6 @@ timer/Makefile
|
||||
3c509/Makefile
|
||||
ne2000/Makefile
|
||||
wd8003/Makefile
|
||||
ide/Makefile
|
||||
wrapup/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
32
c/src/lib/libbsp/i386/pc386/ide/Makefile.am
Normal file
32
c/src/lib/libbsp/i386/pc386/ide/Makefile.am
Normal file
@@ -0,0 +1,32 @@
|
||||
##
|
||||
## Makefile.am,v 1.5 2002/08/11 06:59:03 ralf Exp
|
||||
##
|
||||
|
||||
|
||||
PGM =
|
||||
|
||||
C_FILES = idecfg.c ide.c
|
||||
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
|
||||
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../../../../automake/lib.am
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
$(PGM): $(OBJS)
|
||||
$(make-rel)
|
||||
|
||||
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
|
||||
|
||||
all-local: $(ARCH) $(OBJS) $(PGM)
|
||||
|
||||
.PRECIOUS: $(PGM)
|
||||
|
||||
EXTRA_DIST = idecfg.c
|
||||
|
||||
include $(top_srcdir)/../../../../../../automake/local.am
|
||||
317
c/src/lib/libbsp/i386/pc386/ide/ide.c
Normal file
317
c/src/lib/libbsp/i386/pc386/ide/ide.c
Normal file
@@ -0,0 +1,317 @@
|
||||
/*===============================================================*\
|
||||
| Project: RTEMS PC386 IDE harddisc driver |
|
||||
+-----------------------------------------------------------------+
|
||||
| File: ide.c |
|
||||
+-----------------------------------------------------------------+
|
||||
| Copyright (c) 2003 IMD |
|
||||
| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler |
|
||||
| <Thomas.Doerfler@imd-systems.de> |
|
||||
| all rights reserved |
|
||||
+-----------------------------------------------------------------+
|
||||
| this file contains the BSP layer for IDE access below the |
|
||||
| libchip IDE harddisc driver |
|
||||
| based on a board specific driver from |
|
||||
| Eugeny S. Mints, Oktet |
|
||||
| |
|
||||
| The license and distribution terms for this file may be |
|
||||
| found in the file LICENSE in this distribution or at |
|
||||
| http://www.OARcorp.com/rtems/license.html. |
|
||||
| |
|
||||
+-----------------------------------------------------------------+
|
||||
| date history ID |
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||
| 01.14.03 creation doe |
|
||||
\*===============================================================*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <libchip/ide_ctrl.h>
|
||||
#include <libchip/ide_ctrl_cfg.h>
|
||||
#include <libchip/ide_ctrl_io.h>
|
||||
|
||||
/* #define DEBUG_OUT */
|
||||
/*
|
||||
* support functions for IDE harddisk IF
|
||||
*/
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
boolean pc386_ide_probe
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| This function should probe, whether a IDE disk is available |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| TRUE, when flash disk available |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
boolean ide_card_plugged = TRUE; /* assume: we have a disk here */
|
||||
|
||||
return ide_card_plugged;
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void pc386_ide_initialize
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| initialize IDE access |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor /* controller minor number */
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
/*
|
||||
* FIXME: enable interrupts, if needed
|
||||
*/
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void pc386_ide_read_reg
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| read a IDE controller register |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor, /* controller minor number */
|
||||
int reg, /* register index to access */
|
||||
unsigned16 *value /* ptr to return value location */
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
unsigned32 port = IDE_Controller_Table[minor].port1;
|
||||
unsigned8 bval1,bval2;
|
||||
|
||||
if (reg == IDE_REGISTER_DATA_WORD) {
|
||||
inport_byte(port+reg, bval1);
|
||||
inport_byte(port+reg+1, bval2);
|
||||
*value = bval1 + (bval2 << 8);
|
||||
}
|
||||
else {
|
||||
inport_byte(port+reg, bval1);
|
||||
*value = bval1;
|
||||
}
|
||||
#ifdef DEBUG_OUT
|
||||
printk("pc386_ide_read_reg (0x%x)=0x%x\r\n",reg,*value & 0xff);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void pc386_ide_write_reg
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| write a IDE controller register |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor, /* controller minor number */
|
||||
int reg, /* register index to access */
|
||||
unsigned16 value /* value to write */
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
unsigned32 port = IDE_Controller_Table[minor].port1;
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
printk("pc386_ide_write_reg(0x%x,0x%x)\r\n",reg,value & 0xff);
|
||||
#endif
|
||||
if (reg == IDE_REGISTER_DATA_WORD) {
|
||||
outport_word(port+reg,value);
|
||||
}
|
||||
else {
|
||||
outport_byte(port+reg,value);
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void pc386_ide_read_block
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| read a IDE controller data block |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor,
|
||||
unsigned16 block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
rtems_unsigned32 *cbuf,
|
||||
rtems_unsigned32 *pos
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
unsigned32 port = IDE_Controller_Table[minor].port1;
|
||||
unsigned16 cnt = 0;
|
||||
unsigned32 llength = bufs[(*cbuf)].length;
|
||||
unsigned8 status_val;
|
||||
unsigned16 *lbuf = (unsigned16 *)
|
||||
((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));
|
||||
|
||||
inport_byte(port+IDE_REGISTER_STATUS,status_val);
|
||||
while ((status_val & IDE_REGISTER_STATUS_DRQ) &&
|
||||
(cnt < block_size)) {
|
||||
inport_word(port+IDE_REGISTER_DATA,*lbuf);
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
printk("0x%x ",*lbuf);
|
||||
#endif
|
||||
lbuf++;
|
||||
cnt += sizeof(*lbuf);
|
||||
(*pos) += sizeof(*lbuf);
|
||||
if ((*pos) == llength) {
|
||||
(*pos) = 0;
|
||||
(*cbuf)++;
|
||||
lbuf = bufs[(*cbuf)].buffer;
|
||||
llength = bufs[(*cbuf)].length;
|
||||
}
|
||||
inport_byte(port+IDE_REGISTER_STATUS,status_val);
|
||||
}
|
||||
#ifdef DEBUG_OUT
|
||||
printk("pc386_ide_read_block()\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void pc386_ide_write_block
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| write a IDE controller data block |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor,
|
||||
unsigned16 block_size,
|
||||
blkdev_sg_buffer *bufs,
|
||||
rtems_unsigned32 *cbuf,
|
||||
rtems_unsigned32 *pos
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
unsigned32 port = IDE_Controller_Table[minor].port1;
|
||||
unsigned16 cnt = 0;
|
||||
unsigned32 llength = bufs[(*cbuf)].length;
|
||||
unsigned8 status_val;
|
||||
unsigned16 *lbuf = (unsigned16 *)
|
||||
((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
printk("pc386_ide_write_block()\r\n");
|
||||
#endif
|
||||
inport_byte(port+IDE_REGISTER_STATUS,status_val);
|
||||
while ((status_val & IDE_REGISTER_STATUS_DRQ) &&
|
||||
(cnt < block_size)) {
|
||||
#ifdef DEBUG_OUT
|
||||
printk("0x%x ",*lbuf);
|
||||
#endif
|
||||
outport_word(port+IDE_REGISTER_DATA,*lbuf);
|
||||
lbuf++;
|
||||
cnt += sizeof(*lbuf);
|
||||
(*pos) += sizeof(*lbuf);
|
||||
if ((*pos) == llength) {
|
||||
(*pos) = 0;
|
||||
(*cbuf)++;
|
||||
lbuf = bufs[(*cbuf)].buffer;
|
||||
llength = bufs[(*cbuf)].length;
|
||||
}
|
||||
inport_byte(port+IDE_REGISTER_STATUS,status_val);
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int pc386_ide_control
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| control interface for controller |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor, /* controller minor number */
|
||||
unsigned32 cmd, /* command to send */
|
||||
void * arg /* optional argument */
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| <none> |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*=========================================================================*\
|
||||
| Function: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
rtems_status_code pc386_ide_config_io_speed
|
||||
(
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Purpose: |
|
||||
| set up transfer speed, if possible |
|
||||
+---------------------------------------------------------------------------+
|
||||
| Input Parameters: |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int minor, /* controller minor number */
|
||||
unsigned8 modes_avail /* optional argument */
|
||||
)
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Return Value: |
|
||||
| rtems_status_code |
|
||||
\*=========================================================================*/
|
||||
{
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following table configures the functions used for IDE drivers
|
||||
* in this BSP.
|
||||
*/
|
||||
|
||||
ide_ctrl_fns_t pc386_ide_ctrl_fns = {
|
||||
pc386_ide_probe,
|
||||
pc386_ide_initialize,
|
||||
pc386_ide_control,
|
||||
pc386_ide_read_reg,
|
||||
pc386_ide_write_reg,
|
||||
pc386_ide_read_block,
|
||||
pc386_ide_write_block,
|
||||
pc386_ide_config_io_speed
|
||||
};
|
||||
|
||||
54
c/src/lib/libbsp/i386/pc386/ide/idecfg.c
Normal file
54
c/src/lib/libbsp/i386/pc386/ide/idecfg.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*===============================================================*\
|
||||
| Project: RTEMS PC386 IDE harddisc driver tables |
|
||||
+-----------------------------------------------------------------+
|
||||
| File: idecfg.c |
|
||||
+-----------------------------------------------------------------+
|
||||
| Copyright (c) 2003 IMD |
|
||||
| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler |
|
||||
| <Thomas.Doerfler@imd-systems.de> |
|
||||
| all rights reserved |
|
||||
+-----------------------------------------------------------------+
|
||||
| this file contains the table of functions for the BSP layer |
|
||||
| for IDE access below the libchip IDE harddisc driver |
|
||||
| |
|
||||
+-----------------------------------------------------------------+
|
||||
| date history ID |
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||
| 01.14.03 creation doe |
|
||||
\*===============================================================*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <libchip/ide_ctrl.h>
|
||||
#include <libchip/ide_ctrl_cfg.h>
|
||||
#include <libchip/ide_ctrl_io.h>
|
||||
|
||||
|
||||
/*
|
||||
* The following table configures the functions used for IDE drivers
|
||||
* in this BSP.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following table configures the IDE drivers used in this BSP.
|
||||
*/
|
||||
extern ide_ctrl_fns_t pc386_ide_ctrl_fns;
|
||||
|
||||
/* IDE controllers Table */
|
||||
ide_controller_bsp_table_t IDE_Controller_Table[] = {
|
||||
{"/dev/ide",
|
||||
IDE_STD, /* standard IDE controller */
|
||||
&pc386_ide_ctrl_fns,
|
||||
NULL, /* probe for IDE standard registers */
|
||||
FALSE, /* not (yet) initialized */
|
||||
0x1f0, /* base I/O address for first IDE controller */
|
||||
FALSE,0, /* not (yet) interrupt driven */
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/* Number of rows in IDE_Controller_Table */
|
||||
unsigned long IDE_Controller_Count =
|
||||
sizeof(IDE_Controller_Table)/sizeof(IDE_Controller_Table[0]);
|
||||
|
||||
|
||||
@@ -217,6 +217,11 @@ void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c' */
|
||||
#define BSP_CONSOLE_PORT_COM1 (BSP_UART_COM1)
|
||||
#define BSP_CONSOLE_PORT_COM2 (BSP_UART_COM2)
|
||||
|
||||
/*
|
||||
* indicate, that BSP has IDE driver
|
||||
*/
|
||||
#define RTEMS_BSP_HAS_IDE_DRIVER
|
||||
|
||||
/* GDB stub stuff */
|
||||
void i386_stub_glue_init(int uart);
|
||||
void i386_stub_glue_init_breakin(void);
|
||||
|
||||
@@ -216,6 +216,7 @@ SYM (gdtdesc):
|
||||
/*---------------------------------------------------------------------------+
|
||||
| IDT itself
|
||||
+---------------------------------------------------------------------------*/
|
||||
BEGIN_DATA
|
||||
.p2align 4
|
||||
|
||||
PUBLIC(Interrupt_descriptor_table)
|
||||
@@ -223,10 +224,13 @@ SYM(Interrupt_descriptor_table):
|
||||
.rept 256
|
||||
.word 0,0,0,0
|
||||
.endr
|
||||
|
||||
END_DATA
|
||||
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Descriptor of IDT
|
||||
+--------------------------------------------------------------------------*/
|
||||
BEGIN_CODE
|
||||
.p2align 4
|
||||
SYM(idtdesc):
|
||||
.word (256*8 - 1)
|
||||
.long SYM (Interrupt_descriptor_table)
|
||||
|
||||
@@ -8,7 +8,7 @@ if HAS_NETWORKING
|
||||
NETWORK = ne2000 wd8003 3c509
|
||||
endif
|
||||
|
||||
BSP_FILES = startup clock console timer $(NETWORK)
|
||||
BSP_FILES = startup clock console timer $(NETWORK) ide
|
||||
|
||||
# bummer; have to use $foreach since % pattern subst rules only replace 1x
|
||||
OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.$(OBJEXT))) \
|
||||
|
||||
Reference in New Issue
Block a user