summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-03-25 18:22:04 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-03-25 18:22:04 +0000
commit58f7c3490496f2a0ec38e618a146d660c0bc5a9f (patch)
tree14d2babbcc03b0dd7f4ffe59642e6d74896266df /c
parent2003-03-25 Thomas Doerfler <Thomas.Doerfler@imd-systems.de> (diff)
downloadrtems-58f7c3490496f2a0ec38e618a146d660c0bc5a9f.tar.bz2
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.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/ChangeLog9
-rw-r--r--c/src/lib/libbsp/i386/pc386/Makefile.am2
-rw-r--r--c/src/lib/libbsp/i386/pc386/configure.ac1
-rw-r--r--c/src/lib/libbsp/i386/pc386/ide/Makefile.am32
-rw-r--r--c/src/lib/libbsp/i386/pc386/ide/ide.c317
-rw-r--r--c/src/lib/libbsp/i386/pc386/ide/idecfg.c54
-rw-r--r--c/src/lib/libbsp/i386/pc386/include/bsp.h5
-rw-r--r--c/src/lib/libbsp/i386/pc386/startup/ldsegs.S6
-rw-r--r--c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am2
9 files changed, 425 insertions, 3 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog
index f1c9c692f8..1c443144dd 100644
--- a/c/src/lib/libbsp/i386/pc386/ChangeLog
+++ b/c/src/lib/libbsp/i386/pc386/ChangeLog
@@ -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.
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am
index 670d5903b9..4c89614e63 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -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
diff --git a/c/src/lib/libbsp/i386/pc386/configure.ac b/c/src/lib/libbsp/i386/pc386/configure.ac
index 4f65069a4e..8b7cc19c96 100644
--- a/c/src/lib/libbsp/i386/pc386/configure.ac
+++ b/c/src/lib/libbsp/i386/pc386/configure.ac
@@ -37,5 +37,6 @@ timer/Makefile
3c509/Makefile
ne2000/Makefile
wd8003/Makefile
+ide/Makefile
wrapup/Makefile])
AC_OUTPUT
diff --git a/c/src/lib/libbsp/i386/pc386/ide/Makefile.am b/c/src/lib/libbsp/i386/pc386/ide/Makefile.am
new file mode 100644
index 0000000000..b29c0bb55a
--- /dev/null
+++ b/c/src/lib/libbsp/i386/pc386/ide/Makefile.am
@@ -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
diff --git a/c/src/lib/libbsp/i386/pc386/ide/ide.c b/c/src/lib/libbsp/i386/pc386/ide/ide.c
new file mode 100644
index 0000000000..0dd13feec3
--- /dev/null
+++ b/c/src/lib/libbsp/i386/pc386/ide/ide.c
@@ -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
+};
+
diff --git a/c/src/lib/libbsp/i386/pc386/ide/idecfg.c b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c
new file mode 100644
index 0000000000..e232a68046
--- /dev/null
+++ b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c
@@ -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]);
+
+
diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h
index 1bf4fb3619..e8a1d94a39 100644
--- a/c/src/lib/libbsp/i386/pc386/include/bsp.h
+++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h
@@ -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);
diff --git a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
index 5bd600635b..81857df07a 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
+++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
@@ -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)
diff --git a/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am b/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am
index b152212ebd..24e4973fef 100644
--- a/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.am
@@ -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))) \