summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-02-20 21:43:02 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-02-20 21:43:02 +0000
commitb95aedf3b4c152a949c7ec5f99fb8efaa67ef4be (patch)
tree6ccdfd87721c9597565d456f0dd0571d5ced676e
parent20b349f15f4a52b87f86524f27a55db627f87cba (diff)
downloadrtems-b95aedf3b4c152a949c7ec5f99fb8efaa67ef4be.tar.bz2
2003-02-20 Till Straumann <strauman@slac.stanford.edu>
PR 349/bsps * vme/.cvsignore, vme/Makefile.am, vme/VME.h, vme/VMEConfig.h, vme/vmeconfig.c: Add glue to the powerpc/shared BSP to use the vmeUniverse VME-PCI bridge driver.
-rw-r--r--c/src/lib/libbsp/powerpc/shared/ChangeLog7
-rw-r--r--c/src/lib/libbsp/powerpc/shared/vme/.cvsignore2
-rw-r--r--c/src/lib/libbsp/powerpc/shared/vme/Makefile.am13
-rw-r--r--c/src/lib/libbsp/powerpc/shared/vme/VME.h98
-rw-r--r--c/src/lib/libbsp/powerpc/shared/vme/VMEConfig.h29
-rw-r--r--c/src/lib/libbsp/powerpc/shared/vme/vmeconfig.c109
6 files changed, 258 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/shared/ChangeLog b/c/src/lib/libbsp/powerpc/shared/ChangeLog
index 1c122761e0..a141cacfe8 100644
--- a/c/src/lib/libbsp/powerpc/shared/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/shared/ChangeLog
@@ -1,6 +1,13 @@
2003-02-20 Till Straumann <strauman@slac.stanford.edu>
PR 349/bsps
+ * vme/.cvsignore, vme/Makefile.am, vme/VME.h, vme/VMEConfig.h,
+ vme/vmeconfig.c: Add glue to the powerpc/shared BSP to use
+ the vmeUniverse VME-PCI bridge driver.
+
+2003-02-20 Till Straumann <strauman@slac.stanford.edu>
+
+ PR 349/bsps
* console/console.c, console/uart.c, console/uart.h: implement
IOCTLs for the serial (UART) console to install/retrieve a BREAK-IRQ
callback. The callback routine (if installed) is invoked from the
diff --git a/c/src/lib/libbsp/powerpc/shared/vme/.cvsignore b/c/src/lib/libbsp/powerpc/shared/vme/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/shared/vme/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/powerpc/shared/vme/Makefile.am b/c/src/lib/libbsp/powerpc/shared/vme/Makefile.am
new file mode 100644
index 0000000000..178eaf21a2
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/shared/vme/Makefile.am
@@ -0,0 +1,13 @@
+##
+## $Id$
+##
+
+AUTOMAKE_OPTIONS = foreign 1.4
+
+H_FILES = VMEConfig.h VME.h
+
+C_FILES = vmeconfig.c
+
+EXTRA_DIST = vmeconfig.c
+
+include $(top_srcdir)/../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/shared/vme/VME.h b/c/src/lib/libbsp/powerpc/shared/vme/VME.h
new file mode 100644
index 0000000000..a7aea8a3bd
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/shared/vme/VME.h
@@ -0,0 +1,98 @@
+#ifndef RTEMS_BSP_VME_UNIVERSE_H
+#define RTEMS_BSP_VME_UNIVERSE_H
+/* $Id$ */
+
+/* SVGM et al. BSP's VME support */
+/* Author: Till Straumann, <strauman@slac.stanford.edu> */
+
+/* pull in bsp.h */
+#include <bsp.h>
+/* our VME bridge */
+#include <bsp/vmeUniverse.h>
+/* our address space configuration */
+#include <bsp/VMEConfig.h>
+
+/* VME related declarations */
+/* how to map a VME address to the CPU local bus.
+ * Note that this traverses two bridges:
+ * the grackle and the universe. For the
+ * Universe, there is a lookup procedure while
+ * we assume a 1:1 mapping for the grackle...
+ */
+
+/* NOTE about the fast mapping macros:
+ * using these macros is only safe if the user app
+ * does _NOT_ change the universe mappings!
+ * While changing the PCI windows probably doesn't
+ * make much sense (involves changing the MMU/DBATs as well),
+ * The user might wish to change the VME address
+ * layout, i.e. by remapping _VME_A32_WIN0_ON_VME
+ * and _VME_DRAM_OFFSET...
+ * Hence, using the A24 and A16 macros is probably safe.
+ */
+
+#define BSP_vme_init() \
+ vmeUniverseInit
+
+/* translate through host bridge and vme master window of vme bridge */
+static inline int
+BSP_vme2local_adrs(unsigned am, unsigned long vmeaddr, unsigned long *plocaladdr)
+{
+int rval=vmeUniverseXlateAddr(1,0,am,vmeaddr,plocaladdr);
+ *plocaladdr+=PCI_MEM_BASE;
+ return rval;
+}
+
+/* when using this macro, the universe setup MUST NOT BE
+ * CHANGED by the application...
+ */
+#define BSP_vme2local_A32_fast(vmeaddr) \
+ ((vmeaddr)-_VME_A32_WIN0_ON_VME + _VME_A32_WIN0_ON_PCI + PCI_MEM_BASE)
+#define BSP_vme2local_A24_fast(vmeaddr) \
+ (((vmeaddr)&0x7ffffff)+_VME_A24_ON_PCI + PCI_MEM_BASE)
+#define BSP_vme2local_A16_fast(vmeaddr) \
+ (((vmeaddr)&0xffff)+_VME_A16_ON_PCI + PCI_MEM_BASE)
+
+/* how a CPU address is mapped to the VME bus (if at all)
+ */
+static inline int
+BSP_local2vme_adrs(unsigned am, unsigned long localaddr, unsigned long *pvmeaddr)
+{
+return vmeUniverseXlateAddr(0, 0, am,localaddr+PCI_DRAM_OFFSET,pvmeaddr);
+}
+
+#define BSP_localdram2vme_fast(localaddr) \
+ ((localaddr)+_VME_DRAM_OFFSET)
+
+/* interrupt handlers and levels */
+typedef void (*BSP_VME_ISR_t)(void *usrArg, unsigned long vector);
+
+#define BSP_installVME_isr(vector, handler, arg) \
+ vmeUniverseInstallISR(vector, handler, arg)
+
+#define BSP_removeVME_isr(vector, handler, arg) \
+ vmeUniverseRemoveISR(vector, handler, arg)
+
+/* retrieve the currently installed ISR for a given vector */
+#define BSP_getVME_isr(vector, parg) \
+ vmeUniverseISRGet(vector, parg)
+
+#define BSP_enableVME_int_lvl(level) \
+ vmeUniverseIntEnable(level)
+
+#define BSP_disableVME_int_lvl(level) \
+ vmeUniverseIntDisable(level)
+
+/* Tell the interrupt manager that the universe driver
+ * already called openpic_eoi() and that this step hence
+ * must be omitted.
+ */
+#define BSP_PCI_VME_DRIVER_DOES_EOI
+extern int _BSP_vme_bridge_irq;
+/* don't reference vmeUniverse0PciIrqLine directly here - leave it up to
+ * bspstart() to set BSP_vme_bridge_irq. That way, we can generate variants
+ * of the BSP with / without the universe driver...
+ */
+#define BSP_PCI_VME_BRIDGE_IRQ _BSP_vme_bridge_irq
+
+#endif
diff --git a/c/src/lib/libbsp/powerpc/shared/vme/VMEConfig.h b/c/src/lib/libbsp/powerpc/shared/vme/VMEConfig.h
new file mode 100644
index 0000000000..04347d270a
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/shared/vme/VMEConfig.h
@@ -0,0 +1,29 @@
+#ifndef RTEMS_BSP_VME_CONFIG_H
+#define RTEMS_BSP_VME_CONFIG_H
+/* $Id$ */
+
+/* BSP specific address space configuration parameters */
+
+/*
+ * The BSP maps VME address ranges into
+ * one BAT.
+ * NOTE: the BSP (startup/bspstart.c) uses
+ * hardcoded window lengths that match this
+ * layout:
+ */
+#define _VME_A32_WIN0_ON_PCI 0x10000000
+#define _VME_A24_ON_PCI 0x1f000000
+#define _VME_A16_ON_PCI 0x1fff0000
+
+/* start of the A32 window on the VME bus
+ * TODO: this should perhaps be a configuration option
+ */
+#define _VME_A32_WIN0_ON_VME 0x20000000
+
+/* if _VME_DRAM_OFFSET is defined, the BSP
+ * will map our RAM onto the VME bus, starting
+ * at _VME_DRAM_OFFSET
+ */
+#define _VME_DRAM_OFFSET 0xc0000000
+
+#endif
diff --git a/c/src/lib/libbsp/powerpc/shared/vme/vmeconfig.c b/c/src/lib/libbsp/powerpc/shared/vme/vmeconfig.c
new file mode 100644
index 0000000000..9092680067
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/shared/vme/vmeconfig.c
@@ -0,0 +1,109 @@
+/* $Id$ */
+
+/* Standard VME bridge configuration for VGM type boards */
+
+/* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002 */
+
+#include <bsp.h>
+#include <bsp/VME.h>
+#include <bsp/irq.h>
+#include <libcpu/bat.h>
+#include <libcpu/spr.h>
+#include <bsp/motorola.h>
+
+/* Use a weak alias for the VME configuration.
+ * This permits individual applications to override
+ * this routine.
+ * They may even create an 'empty'
+ *
+ * void BSP_vme_config(void) {}
+ *
+ * which will avoid linking in the Universe driver
+ * at all :-).
+ */
+
+void BSP_vme_config(void) __attribute__ (( weak, alias("__BSP_default_vme_config") ));
+
+int _BSP_vme_bridge_irq = -1;
+
+SPR_RO(DBAT0U)
+
+void
+__BSP_default_vme_config(void)
+{
+union {
+ struct _BATU bat;
+ unsigned long batbits;
+} dbat0u;
+
+ if (currentBoard < MVME_2300 || currentBoard >= MVME_1600) {
+ printk("VME bridge for this board is unknown - if it's a Tundra Universe, add the board to 'shared/vme/vmeconfig.c'\n");
+ printk("Skipping VME initialization...\n");
+ return;
+ }
+
+ vmeUniverseInit();
+ vmeUniverseReset();
+
+ /* setup a PCI area to map the VME bus */
+
+ dbat0u.batbits = _read_DBAT0U();
+
+ /* if we have page tables, BAT0 is available */
+ if (dbat0u.bat.vs || dbat0u.bat.vp) {
+ printk("WARNING: BAT0 is taken (no pagetables?); VME bridge must share PCI range for VME access\n");
+ printk("Skipping VME initialization...\n");
+ return;
+ }
+
+ setdbat(0,
+ PCI_MEM_BASE + _VME_A32_WIN0_ON_PCI,
+ PCI_MEM_BASE + _VME_A32_WIN0_ON_PCI,
+ 0x10000000,
+ IO_PAGE);
+
+ /* map VME address ranges */
+ vmeUniverseMasterPortCfg(
+ 0,
+ VME_AM_EXT_SUP_DATA,
+ _VME_A32_WIN0_ON_VME,
+ _VME_A32_WIN0_ON_PCI,
+ 0x0F000000);
+ vmeUniverseMasterPortCfg(
+ 1,
+ VME_AM_STD_SUP_DATA,
+ 0x00000000,
+ _VME_A24_ON_PCI,
+ 0x00ff0000);
+ vmeUniverseMasterPortCfg(
+ 2,
+ VME_AM_SUP_SHORT_IO,
+ 0x00000000,
+ _VME_A16_ON_PCI,
+ 0x00010000);
+
+#ifdef _VME_DRAM_OFFSET
+ /* map our memory to VME */
+ vmeUniverseSlavePortCfg(
+ 0,
+ VME_AM_EXT_SUP_DATA,
+ _VME_DRAM_OFFSET,
+ PCI_DRAM_OFFSET,
+ BSP_mem_size);
+
+ /* make sure the host bridge PCI master is enabled */
+ vmeUniverseWriteReg(
+ vmeUniverseReadReg(UNIV_REGOFF_PCI_CSR) | UNIV_PCI_CSR_BM,
+ UNIV_REGOFF_PCI_CSR);
+#endif
+
+ /* stdio is not yet initialized; the driver will revert to printk */
+ vmeUniverseMasterPortsShow(0);
+ vmeUniverseSlavePortsShow(0);
+
+ /* install the VME insterrupt manager */
+ vmeUniverseInstallIrqMgr(0,5,1,6);
+ if (vmeUniverse0PciIrqLine<0)
+ BSP_panic("Unable to get interrupt line info from PCI config");
+ _BSP_vme_bridge_irq=BSP_PCI_IRQ_LOWEST_OFFSET+vmeUniverse0PciIrqLine;
+}