summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2004-11-22 22:30:59 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2004-11-22 22:30:59 +0000
commit561f53b71e981a8dec9c2d3ffa5d53fd342b0ab4 (patch)
treebaebe93296988f6aeeca4003cfc2b170b607b28a
parent2004-11-22 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-561f53b71e981a8dec9c2d3ffa5d53fd342b0ab4.tar.bz2
2004-11-22 Jennifer Averett <jennifer@OARcorp.com>
PR 581/bsps * Makefile.am, bsp_specs, configure.ac, clock/Makefile.am, include/bsp.h, start/Makefile.am, start/start.S, startup/Makefile.am, startup/bspstart.c, startup/linkcmds, vectors/Makefile.am, vectors/vectors.S, wrapup/Makefile.am: Convert PSIM to new exception model. * irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c: New files. * clock/clock.c: Removed.
-rw-r--r--c/src/lib/libbsp/powerpc/psim/ChangeLog12
-rw-r--r--c/src/lib/libbsp/powerpc/psim/Makefile.am2
-rw-r--r--c/src/lib/libbsp/powerpc/psim/bsp_specs8
-rw-r--r--c/src/lib/libbsp/powerpc/psim/clock/Makefile.am13
-rw-r--r--c/src/lib/libbsp/powerpc/psim/clock/clock.c51
-rw-r--r--c/src/lib/libbsp/powerpc/psim/configure.ac3
-rw-r--r--c/src/lib/libbsp/powerpc/psim/include/bsp.h63
-rw-r--r--c/src/lib/libbsp/powerpc/psim/irq/Makefile.am41
-rw-r--r--c/src/lib/libbsp/powerpc/psim/irq/irq.c25
-rw-r--r--c/src/lib/libbsp/powerpc/psim/irq/irq_asm.S2
-rw-r--r--c/src/lib/libbsp/powerpc/psim/start/Makefile.am20
-rw-r--r--c/src/lib/libbsp/powerpc/psim/start/start.S10
-rw-r--r--c/src/lib/libbsp/powerpc/psim/startup/Makefile.am4
-rw-r--r--c/src/lib/libbsp/powerpc/psim/startup/bspstart.c123
-rw-r--r--c/src/lib/libbsp/powerpc/psim/startup/linkcmds22
-rw-r--r--c/src/lib/libbsp/powerpc/psim/vectors/Makefile.am27
-rw-r--r--c/src/lib/libbsp/powerpc/psim/vectors/vectors.S251
-rw-r--r--c/src/lib/libbsp/powerpc/psim/wrapup/Makefile.am22
18 files changed, 431 insertions, 268 deletions
diff --git a/c/src/lib/libbsp/powerpc/psim/ChangeLog b/c/src/lib/libbsp/powerpc/psim/ChangeLog
index ce71f920ed..5543e2c65e 100644
--- a/c/src/lib/libbsp/powerpc/psim/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/psim/ChangeLog
@@ -1,3 +1,15 @@
+2004-11-22 Jennifer Averett <jennifer@OARcorp.com>
+
+ PR 581/bsps
+ * Makefile.am, bsp_specs, configure.ac, clock/Makefile.am,
+ include/bsp.h, start/Makefile.am, start/start.S, startup/Makefile.am,
+ startup/bspstart.c, startup/linkcmds, vectors/Makefile.am,
+ vectors/vectors.S, wrapup/Makefile.am: Convert PSIM to new exception
+ model.
+ * irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_asm.S,
+ irq/irq_init.c: New files.
+ * clock/clock.c: Removed.
+
2003-12-16 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
PR 533/bsps
diff --git a/c/src/lib/libbsp/powerpc/psim/Makefile.am b/c/src/lib/libbsp/powerpc/psim/Makefile.am
index 0feb29f6c3..f91ba28a0b 100644
--- a/c/src/lib/libbsp/powerpc/psim/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/Makefile.am
@@ -6,7 +6,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 start clock console startup shmsupp timer vectors \
+SUBDIRS = include start irq clock console startup shmsupp timer vectors\
@exceptions@ wrapup \
tools
diff --git a/c/src/lib/libbsp/powerpc/psim/bsp_specs b/c/src/lib/libbsp/powerpc/psim/bsp_specs
index 3d69146dfd..3fcb25a195 100644
--- a/c/src/lib/libbsp/powerpc/psim/bsp_specs
+++ b/c/src/lib/libbsp/powerpc/psim/bsp_specs
@@ -10,13 +10,13 @@
%{!qnolinkcmds: -T linkcmds%s}}}
*startfile:
-%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: ecrti%O%s \
+%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: ecrti%O%s rtems_crti%O%s crtbegin.o%s \
%{!qrtems_debug: start.o%s} \
%{qrtems_debug: start_g.o%s}}}
-*endfile:
-%{!qrtems: %(old_endfile)} %{qrtems: ecrtn%O%s}
-
*link:
%{!qrtems: %(old_link)} %{qrtems: -Qy -dp -Bstatic -e _start -u __vectors}
+*endfile:
+%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s ecrtn.o%s}
+
diff --git a/c/src/lib/libbsp/powerpc/psim/clock/Makefile.am b/c/src/lib/libbsp/powerpc/psim/clock/Makefile.am
index 83ef4e5ad1..c4b3986840 100644
--- a/c/src/lib/libbsp/powerpc/psim/clock/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/clock/Makefile.am
@@ -3,9 +3,9 @@
##
-PGM = $(ARCH)/clock.rel
+VPATH = @srcdir@:@srcdir@/../../shared/clock
-C_FILES = clock.c
+C_FILES = p_clock.c
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
OBJS = $(C_O_FILES)
@@ -17,15 +17,8 @@ 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 = clock.c
+all-local: $(ARCH) $(OBJS)
include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/clock/clock.c b/c/src/lib/libbsp/powerpc/psim/clock/clock.c
deleted file mode 100644
index 8fd08cb2c0..0000000000
--- a/c/src/lib/libbsp/powerpc/psim/clock/clock.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Instantiate the clock driver shell for psim based
- * on the decrementer register.
- *
- * $Id$
- */
-
-#include <rtems.h>
-
-/*
- * If defined, speed up the clock ticks while the idle task is running so
- * time spent in the idle task is minimized. This significantly reduces
- * the wall time required to execute the RTEMS test suites.
- */
-
-/* #define CLOCK_DRIVER_USE_FAST_IDLE */
-
-#define CLOCK_VECTOR PPC_IRQ_DECREMENTER
-
-/* On psim, each click of the decrementer register corresponds
- * to 1 instruction. By setting this to 100, we are indicating
- * that we are assuming it can execute 100 instructions per
- * microsecond. This corresponds to sustaining 1 instruction
- * per cycle at 100 Mhz. Whether this is a good guess or not
- * is anyone's guess.
- */
-
-extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
-
-unsigned int PPC_DECREMENTER_CLICKS;
-
-#define Clock_driver_support_install_isr( _new, _old ) \
- do { \
- _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
- PPC_DECREMENTER_CLICKS = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND; \
- PPC_DECREMENTER_CLICKS *= rtems_configuration_get_microseconds_per_tick(); \
- /* PPC_DECREMENTER_CLICKS = 5000; */ \
- } while(0)
-
-#define Clock_driver_support_initialize_hardware() \
- do { \
- unsigned int _clicks = PPC_DECREMENTER_CLICKS; \
- PPC_Set_decrementer( _clicks ); \
- } while (0)
-
-#define Clock_driver_support_at_tick() \
- Clock_driver_support_initialize_hardware()
-
-#define Clock_driver_support_shutdown_hardware()
-
-#include "../../../shared/clockdrv_shell.c"
diff --git a/c/src/lib/libbsp/powerpc/psim/configure.ac b/c/src/lib/libbsp/powerpc/psim/configure.ac
index bca3f1820a..bb4ceb1d06 100644
--- a/c/src/lib/libbsp/powerpc/psim/configure.ac
+++ b/c/src/lib/libbsp/powerpc/psim/configure.ac
@@ -38,6 +38,7 @@ AC_CONFIG_FILES([Makefile
clock/Makefile
console/Makefile
include/Makefile
+irq/Makefile
shmsupp/Makefile
start/Makefile
startup/Makefile
@@ -45,6 +46,6 @@ timer/Makefile
vectors/Makefile
wrapup/Makefile])
-RTEMS_PPC_EXCEPTIONS([old])
+RTEMS_PPC_EXCEPTIONS([new])
AC_OUTPUT
diff --git a/c/src/lib/libbsp/powerpc/psim/include/bsp.h b/c/src/lib/libbsp/powerpc/psim/include/bsp.h
index d566935519..a3a6573272 100644
--- a/c/src/lib/libbsp/powerpc/psim/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/psim/include/bsp.h
@@ -54,30 +54,39 @@ extern "C" {
#else
#include <rtems.h>
#include <console.h>
+#include <libcpu/io.h>
#include <clockdrv.h>
-#include <console.h>
#include <iosupp.h>
-
-/*
- * Define the time limits for RTEMS Test Suite test durations.
- * Long test and short test duration limits are provided. These
- * values are in seconds and need to be converted to ticks for the
- * application.
- *
- */
-
-#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
-#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
-
+#include <bsp/vectors.h>
/*
* Stuff for Time Test 27
*/
+#if defined(RTEMS_TM27)
+
+#include <bsp/irq.h>
#define MUST_WAIT_FOR_INTERRUPT 1
-#define Install_tm27_vector( _handler ) \
- set_vector( (_handler), PPC_IRQ_DECREMENTER, 1 )
+/* #define Install_tm27_vector( _handler ) \
+ set_vector( (_handler), PPC_IRQ_DECREMENTER, 1 ) */
+
+void nullFunc() {}
+static rtems_irq_connect_data clockIrqData = {BSP_DECREMENTER,
+ 0,
+ (rtems_irq_enable)nullFunc,
+ (rtems_irq_disable)nullFunc,
+ (rtems_irq_is_enabled) nullFunc};
+
+void Install_tm27_vector(void (*_handler)())
+{
+ clockIrqData.hdl = _handler;
+ if (!BSP_install_rtems_irq_handler (&clockIrqData)) {
+ printk("Error installing clock interrupt handler!\n");
+ rtems_fatal_error_occurred(1);
+ }
+}
+
#define Cause_tm27_intr() \
do { \
@@ -100,6 +109,7 @@ extern "C" {
_msr |= 0x8002; \
asm volatile( "mtmsr %0 ;" : "=r" (_msr) : "r" (_msr) ); \
} while (0)
+#endif
/* Constants */
@@ -120,23 +130,13 @@ extern "C" {
* Information placed in the linkcmds file.
*/
-extern int RAM_START;
extern int RAM_END;
-extern int RAM_SIZE;
-
-extern int PROM_START;
-extern int PROM_END;
-extern int PROM_SIZE;
-
-extern int CLOCK_SPEED;
-
extern int end; /* last address in the program */
-/* functions */
-void bsp_start( void );
+#define BSP_Convert_decrementer( _value ) ( (unsigned long long) _value )
-void bsp_cleanup( void );
+/* functions */
rtems_isr_entry set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */
@@ -144,18 +144,11 @@ rtems_isr_entry set_vector( /* returns old vector */
int type /* RTEMS or RAW intr */
);
-void DEBUG_puts( char *string );
-
-void BSP_fatal_return( void );
-
-void bsp_spurious_initialize( void );
+void bsp_cleanup( void );
extern rtems_configuration_table BSP_Configuration; /* owned by BSP */
-
extern rtems_cpu_table Cpu_table; /* owned by BSP */
-extern rtems_unsigned32 bsp_isr_level;
-
#endif /* ASM */
#ifdef __cplusplus
diff --git a/c/src/lib/libbsp/powerpc/psim/irq/Makefile.am b/c/src/lib/libbsp/powerpc/psim/irq/Makefile.am
new file mode 100644
index 0000000000..f8c415c6d9
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/psim/irq/Makefile.am
@@ -0,0 +1,41 @@
+##
+## Makefile.am,v 1.5 2002/12/17 13:37:41 ralf Exp
+##
+
+
+include_bspdir = $(includedir)/bsp
+
+C_FILES = irq.c irq_init.c
+OBJS = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+include_bsp_HEADERS = irq.h
+
+S_FILES = irq_asm.S
+OBJS += $(S_FILES:%.S=$(ARCH)/%.$(OBJEXT))
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+$(PROJECT_INCLUDE)/bsp:
+ $(mkinstalldirs) $@
+
+$(PROJECT_INCLUDE)/bsp/%.h: %.h
+ $(INSTALL_DATA) $< $@
+
+PREINSTALL_FILES = $(PROJECT_INCLUDE)/bsp \
+ $(include_bsp_HEADERS:%=$(PROJECT_INCLUDE)/bsp/%)
+
+#
+# (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: $(PREINSTALL_FILES) $(ARCH) $(OBJS) $(PGM)
+
+EXTRA_DIST = irq.c irq.h irq_asm.S irq_init.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/irq/irq.c b/c/src/lib/libbsp/powerpc/psim/irq/irq.c
index 6572d3c467..69199326db 100644
--- a/c/src/lib/libbsp/powerpc/psim/irq/irq.c
+++ b/c/src/lib/libbsp/powerpc/psim/irq/irq.c
@@ -86,6 +86,31 @@ static inline int is_processor_irq(const rtems_irq_symbolic_name irqLine)
*/
/*
+ * Caution : this function assumes the variable "internal_config"
+ * is already set and that the tables it contains are still valid
+ * and accessible.
+ */
+static void compute_i8259_masks_from_prio ()
+{
+ int i;
+ int j;
+ /*
+ * Always mask at least current interrupt to prevent re-entrance
+ */
+ for (i=BSP_ISA_IRQ_LOWEST_OFFSET; i < BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER; i++) {
+ * ((unsigned short*) &irq_mask_or_tbl[i]) = (1 << i);
+ for (j = BSP_ISA_IRQ_LOWEST_OFFSET; j < BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER; j++) {
+ /*
+ * Mask interrupts at i8259 level that have a lower priority
+ */
+ if (internal_config->irqPrioTbl [i] > internal_config->irqPrioTbl [j]) {
+ * ((unsigned short*) &irq_mask_or_tbl[i]) |= (1 << j);
+ }
+ }
+ }
+}
+
+/*
* This function check that the value given for the irq line
* is valid.
*/
diff --git a/c/src/lib/libbsp/powerpc/psim/irq/irq_asm.S b/c/src/lib/libbsp/powerpc/psim/irq/irq_asm.S
index dfaba64ab7..4bde4d5ee2 100644
--- a/c/src/lib/libbsp/powerpc/psim/irq/irq_asm.S
+++ b/c/src/lib/libbsp/powerpc/psim/irq/irq_asm.S
@@ -16,7 +16,7 @@
* irq_asm.S,v 1.5.4.3 2003/09/04 18:45:20 joel Exp
*/
-#include <rtems/asm.h>
+#include <asm.h>
#include <rtems/score/cpu.h>
#include <bsp/vectors.h>
#include <libcpu/raw_exception.h>
diff --git a/c/src/lib/libbsp/powerpc/psim/start/Makefile.am b/c/src/lib/libbsp/powerpc/psim/start/Makefile.am
index ab006bacdd..74d402ace2 100644
--- a/c/src/lib/libbsp/powerpc/psim/start/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/start/Makefile.am
@@ -2,7 +2,9 @@
## $Id$
##
-S_FILES = start.S
+VPATH = @srcdir@:@srcdir@/../../shared/start
+
+S_FILES = start.S rtems_crti.S
S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.$(OBJEXT))
OBJS = $(S_O_FILES)
@@ -13,20 +15,22 @@ include $(top_srcdir)/../../../../../../automake/lib.am
#
# (OPTIONAL) Add local stuff here using +=
#
-
-install-data-local: $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT)
- @$(mkinstalldirs) $(DESTDIR)$(bsplibdir)
- $(INSTALL_DATA) $< $(DESTDIR)$(bsplibdir)
+bsplib_DATA = $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT)
+bsplib_DATA += $(PROJECT_RELEASE)/lib/rtems_crti.$(OBJEXT)
$(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT): $(ARCH)/start.$(OBJEXT)
$(INSTALL_DATA) $< $@
+$(PROJECT_RELEASE)/lib/rtems_crti.$(OBJEXT): $(ARCH)/rtems_crti.$(OBJEXT)
+ $(INSTALL_DATA) $< $@
+
TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT)
+TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/rtems_crti.$(OBJEXT)
-all-local: $(ARCH) $(OBJS) $(ARCH)/start.$(OBJEXT) $(TMPINSTALL_FILES)
+all-local: $(ARCH) $(OBJS) $(ARCH)/start.$(OBJEXT) $(ARCH)/rtems_crti.$(OBJEXT) $(TMPINSTALL_FILES)
-.PRECIOUS: $(ARCH)/start.$(OBJEXT)
+$(OBJS): $(ARCH)
-EXTRA_DIST = start.S
+.PRECIOUS: $(ARCH)/start.$(OBJEXT) $(ARCH)/rtems_crti.$(OBJEXT)
include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/start/start.S b/c/src/lib/libbsp/powerpc/psim/start/start.S
index 12bbb120a9..872698866d 100644
--- a/c/src/lib/libbsp/powerpc/psim/start/start.S
+++ b/c/src/lib/libbsp/powerpc/psim/start/start.S
@@ -17,6 +17,9 @@
* $Id$
*/
+#include <asm.h>
+#include <rtems/score/cpu.h>
+#include <libcpu/io.h>
#include "ppc-asm.h"
.file "startsim.s"
@@ -53,9 +56,14 @@ FUNC_NAME(__atexit): /* tell C's eabi-ctor's we have an atexit function */
.Lptr:
.long .LCTOC1-.Laddr
+ .globl __rtems_entry_point
+ .type __rtems_entry_point,@function
+__rtems_entry_point:
+#if 1
.globl _start
.type _start,@function
_start:
+#endif
bl .Laddr /* get current address */
.Laddr:
mflr r4 /* real address of .Laddr */
@@ -64,6 +72,7 @@ _start:
lwz r4,.Ltable(r5) /* get linker's idea of where .Laddr is */
subf r4,r4,r5 /* calculate difference between where linked and current */
+ bl __eabi /* setup EABI and SYSV environment */
/* clear bss */
lwz r6,.Lbss_start(r5) /* calculate beginning of the BSS */
lwz r7,.Lend(r5) /* calculate end of the BSS */
@@ -100,6 +109,7 @@ _start:
la r5,environ@l(r5) /* environp */
li r4, 0 /* argv */
li r3, 0 /* argc */
+
/* Let her rip */
bl FUNC_NAME(boot_card)
diff --git a/c/src/lib/libbsp/powerpc/psim/startup/Makefile.am b/c/src/lib/libbsp/powerpc/psim/startup/Makefile.am
index 873272a8b2..7d991183d5 100644
--- a/c/src/lib/libbsp/powerpc/psim/startup/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/startup/Makefile.am
@@ -8,7 +8,7 @@ VPATH = @srcdir@:@srcdir@/../../../shared
PGM = $(ARCH)/startup.rel
C_FILES = bspclean.c bsplibc.c bsppost.c bspstart.c bootcard.c main.c sbrk.c \
- setvec.c gnatinstallhandler.c
+ gnatinstallhandler.c
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
OBJS = $(C_O_FILES)
@@ -38,6 +38,6 @@ all-local: $(ARCH) $(OBJS) $(PGM) $(TMPINSTALL_FILES)
.PRECIOUS: $(PGM)
-EXTRA_DIST = bspclean.c bspstart.c device-tree linkcmds setvec.c
+EXTRA_DIST = bspclean.c bspstart.c device-tree linkcmds
include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
index 2f94755485..582b116ca9 100644
--- a/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
@@ -16,37 +16,85 @@
#include <string.h>
#include <fcntl.h>
-
#include <bsp.h>
+#include <bsp/irq.h>
#include <rtems/libio.h>
#include <rtems/libcsupport.h>
#include <rtems/bspIo.h>
+#include <libcpu/cpuIdent.h>
+#include <libcpu/spr.h>
+
+SPR_RW(SPRG0)
+SPR_RW(SPRG1)
+
+
+extern unsigned long __rtems_end[];
+
+void initialize_exceptions(void);
+
+/* On psim, each click of the decrementer register corresponds
+ * to 1 instruction. By setting this to 100, we are indicating
+ * that we are assuming it can execute 100 instructions per
+ * microsecond. This corresponds to sustaining 1 instruction
+ * per cycle at 100 Mhz. Whether this is a good guess or not
+ * is anyone's guess.
+ */
+
+extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
/*
* The original table from the application and our copy of it with
* some changes.
*/
-
+
extern rtems_configuration_table Configuration;
rtems_configuration_table BSP_Configuration;
-
rtems_cpu_table Cpu_table;
-rtems_unsigned32 bsp_isr_level;
/*
* Tells us where to put the workspace in case remote debugger is present.
*/
#if 0
-extern rtems_unsigned32 rdb_start;
+extern uint32_t rdb_start;
#endif
/*
+ * PCI Bus Frequency
+ */
+ unsigned int BSP_bus_frequency;
+ /*
+ * * Time base divisior (how many tick for 1 second).
+ * */
+ unsigned int BSP_time_base_divisor;
+
+
+
+/*
* Use the shared implementations of the following routines
*/
-
+
void bsp_postdriver_hook(void);
-void bsp_libc_init( void *, unsigned32, int );
+void bsp_libc_init( void *, uint32_t, int );
+
+/*
+ * system init stack and soft ir stack size
+ */
+#define INIT_STACK_SIZE 0x1000
+#define INTR_STACK_SIZE CONFIGURE_INTERRUPT_STACK_MEMORY
+
+
+void BSP_panic(char *s)
+{
+ printk("%s PANIC %s\n",_RTEMS_version, s);
+ __asm__ __volatile ("sc");
+}
+
+void _BSP_Fatal_error(unsigned int v)
+{
+ printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
+ __asm__ __volatile ("sc");
+}
/*
* bsp_pretasking_hook
@@ -58,10 +106,10 @@ void bsp_libc_init( void *, unsigned32, int );
void bsp_pretasking_hook(void)
{
extern int end;
- rtems_unsigned32 heap_start;
- rtems_unsigned32 heap_size;
+ uint32_t heap_start;
+ uint32_t heap_size;
- heap_start = (rtems_unsigned32) &end;
+ heap_start = (uint32_t) &end;
if (heap_start & (CPU_ALIGNMENT-1))
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
@@ -84,16 +132,14 @@ void bsp_pretasking_hook(void)
void bsp_start( void )
{
- unsigned char *work_space_start;
+ unsigned char *work_space_start;
+ register uint32_t intrStack;
+ register uint32_t *intrStackPtr;
-#if 0
- /*
- * Set MSR to show vectors at 0 XXX
+ /*
+ * Note we can not get CPU identification dynamically, so force current_ppc_cpu.
*/
- _CPU_MSR_Value( msr_value );
- msr_value &= ~PPC_MSR_EP;
- _CPU_MSR_SET( msr_value );
-#endif
+ current_ppc_cpu = PPC_PSIM;
/*
* Set up our hooks
@@ -118,15 +164,18 @@ void bsp_start( void )
Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
+ BSP_bus_frequency = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND;
+ BSP_time_base_divisor = 1;
+
/*
- * The monitor likes the exception table to be at 0x0.
+ * The simulator likes the exception table to be at 0xfff00000.
*/
- Cpu_table.exceptions_in_RAM = TRUE;
+ Cpu_table.exceptions_in_RAM = FALSE;
BSP_Configuration.work_space_size += 1024;
- work_space_start =
+ work_space_start =
(unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
if ( work_space_start <= (unsigned char *)&end ) {
@@ -136,4 +185,36 @@ void bsp_start( void )
BSP_Configuration.work_space_start = work_space_start;
+ /*
+ * Initialize the interrupt related settings
+ * SPRG1 = software managed IRQ stack
+ *
+ * This could be done latter (e.g in IRQ_INIT) but it helps to understand
+ * some settings below...
+ */
+ intrStack = ((uint32_t) __rtems_end) +
+ INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
+
+ /* make sure it's properly aligned */
+ intrStack &= ~(CPU_STACK_ALIGNMENT-1);
+
+ /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
+ intrStackPtr = (uint32_t*) intrStack;
+ *intrStackPtr = 0;
+
+ _write_SPRG1(intrStack);
+
+ /* signal them that we have fixed PR288 - eventually, this should go away */
+ _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
+
+ /*
+ * Initialize default raw exception hanlders. See vectors/vectors_init.c
+ */
+ initialize_exceptions();
+
+ /*
+ * Initalize RTEMS IRQ system
+ */
+ BSP_rtems_irq_mng_init(0);
+
}
diff --git a/c/src/lib/libbsp/powerpc/psim/startup/linkcmds b/c/src/lib/libbsp/powerpc/psim/startup/linkcmds
index e16a2450ce..1c1f11b1d6 100644
--- a/c/src/lib/libbsp/powerpc/psim/startup/linkcmds
+++ b/c/src/lib/libbsp/powerpc/psim/startup/linkcmds
@@ -16,7 +16,7 @@ OUTPUT_ARCH(powerpc)
ENTRY(_start)
/* Do we need any of these for elf?
__DYNAMIC = 0; */
-PROVIDE (PSIM_INSTRUCTIONS_PER_MICROSECOND = 100);
+PROVIDE (PSIM_INSTRUCTIONS_PER_MICROSECOND = 10000); /* 100); */
PROVIDE (CPU_PPC_CLICKS_PER_MS = 16667);
MEMORY
{
@@ -26,10 +26,10 @@ MEMORY
SECTIONS
{
- .vectors 0xFFF00100 :
+ .entry_point_section :
{
- *(.vectors)
- } >EPROM
+ *(.entry_point_section)
+ } > EPROM
/* Read-only sections, merged into text segment: */
/* . = 0x40000 + SIZEOF_HEADERS; */
@@ -74,8 +74,15 @@ SECTIONS
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} >RAM
- .init : { _init = .; __init = .; *(.init) } >RAM
- .fini : { _fini = .; __fini = .; *(.fini) } >RAM
+ .init :
+ {
+ KEEP (*(.init))
+ } >RAM =0
+ .fini :
+ {
+ _fini = .;
+ KEEP (*(.fini))
+ } >RAM =0
.rodata : { *(.rodata*) *(.gnu.linkonce.r*) } >RAM
.rodata1 : { *(.rodata1) } >RAM
.eh_frame : { *.(eh_frame) } >RAM
@@ -143,6 +150,8 @@ SECTIONS
PROVIDE (_GOT_END_ = .);
PROVIDE (__GOT_END__ = .);
+ .jcr : { KEEP (*(.jcr)) } > RAM
+
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
@@ -170,6 +179,7 @@ SECTIONS
*(COMMON)
} >RAM
. = ALIGN(8) + 0x8000;
+ __rtems_end = . ;
PROVIDE(__stack = .);
PROVIDE(_end = .);
PROVIDE(end = .);
diff --git a/c/src/lib/libbsp/powerpc/psim/vectors/Makefile.am b/c/src/lib/libbsp/powerpc/psim/vectors/Makefile.am
index 0cc69ebddd..7b32d80542 100644
--- a/c/src/lib/libbsp/powerpc/psim/vectors/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/vectors/Makefile.am
@@ -3,12 +3,17 @@
##
-PGM = $(ARCH)/vectors.rel
+VPATH = @srcdir@:@srcdir@/../console:@srcdir@/../../shared/vectors
-S_FILES = align_h.S vectors.S
+C_FILES = vectors_init.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+H_FILES = ../../shared/vectors/vectors.h
+
+S_FILES = vectors.S
S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.$(OBJEXT))
-OBJS = $(S_O_FILES)
+OBJS = $(S_O_FILES) $(C_O_FILES)
include $(top_srcdir)/../../../../../../automake/compile.am
include $(top_srcdir)/../../../../../../automake/lib.am
@@ -20,12 +25,20 @@ include $(top_srcdir)/../../../../../../automake/lib.am
$(PGM): $(OBJS)
$(make-rel)
-# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+include_bspdir = $(includedir)/bsp
+include_bsp_HEADERS = ../../shared/vectors/vectors.h
+
+$(PROJECT_INCLUDE)/bsp:
+ $(mkinstalldirs) $@
-all-local: $(ARCH) $(OBJS) $(PGM)
+$(PROJECT_INCLUDE)/bsp/vectors.h: ../../shared/vectors/vectors.h
+ $(INSTALL_DATA) $< $@
-.PRECIOUS: $(PGM)
+TMPINSTALL_FILES += $(PROJECT_INCLUDE)
+TMPINSTALL_FILES += $(PROJECT_INCLUDE)/bsp
+TMPINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vectors.h
-EXTRA_DIST = README align_h.S vectors.S
+all-local: $(ARCH) $(TMPINSTALL_FILES) $(OBJS)
+include $(top_srcdir)/../../../../../../automake/force-preinstall.am
include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/vectors/vectors.S b/c/src/lib/libbsp/powerpc/psim/vectors/vectors.S
index ab5867d4ce..7a9c2d8d9f 100644
--- a/c/src/lib/libbsp/powerpc/psim/vectors/vectors.S
+++ b/c/src/lib/libbsp/powerpc/psim/vectors/vectors.S
@@ -1,123 +1,160 @@
-/* vectors.s 1.1 - 95/12/04
- *
- * This file contains the assembly code for the PowerPC
- * interrupt vectors for RTEMS.
- *
- * COPYRIGHT (c) 1989-1999.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- *
- * $Id$
- */
-
/*
- * The issue with this file is getting it loaded at the right place.
- * The first vector MUST be at address 0x????0100.
- * How this is achieved is dependant on the tool chain.
+ * (c) 1999, Eric Valette valette@crf.canon.fr
*
- * However the basic mechanism for ELF assemblers is to create a
- * section called ".vectors", which will be loaded to an address
- * between 0x????0000 and 0x????0100 (inclusive) via a link script.
*
- * The basic mechanism for XCOFF assemblers is to place it in the
- * normal text section, and arrange for this file to be located
- * at an appropriate position on the linker command line.
+ * This file contains the assembly code for the PowerPC
+ * exception veneers for RTEMS.
*
- * The variable 'PPC_VECTOR_FILE_BASE' must be defined to be the
- * offset from 0x????0000 to the first location in the file. This
- * will usually be 0x0000 or 0x0100.
+ * vectors.S,v 1.3.4.1 2003/02/20 21:48:25 joel Exp
*/
+
-#include <bsp.h>
-#include "asm.h"
-
-#ifndef PPC_VECTOR_FILE_BASE
-#error "PPC_VECTOR_FILE_BASE is not defined."
-#endif
-
- /* Where this file will be loaded */
- .set file_base, PPC_VECTOR_FILE_BASE
-
- /* Offset to store reg 0 */
-
- .set IP_LINK, 0
-#if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27)
- .set IP_0, (IP_LINK + 56)
-#else
- .set IP_0, (IP_LINK + 8)
-#endif
- .set IP_2, (IP_0 + 4)
- .set IP_3, (IP_2 + 4)
- .set IP_4, (IP_3 + 4)
- .set IP_5, (IP_4 + 4)
- .set IP_6, (IP_5 + 4)
-
- .set IP_7, (IP_6 + 4)
- .set IP_8, (IP_7 + 4)
- .set IP_9, (IP_8 + 4)
- .set IP_10, (IP_9 + 4)
+#include <asm.h>
+#include <rtems/score/cpu.h>
+#include <bsp/vectors.h>
- .set IP_11, (IP_10 + 4)
- .set IP_12, (IP_11 + 4)
- .set IP_13, (IP_12 + 4)
- .set IP_28, (IP_13 + 4)
+
+#define SYNC \
+ sync; \
+ isync
- .set IP_29, (IP_28 + 4)
- .set IP_30, (IP_29 + 4)
- .set IP_31, (IP_30 + 4)
- .set IP_CR, (IP_31 + 4)
+ PUBLIC_VAR (__rtems_start)
+ .section .entry_point_section,"awx",@progbits
+/*
+ * Entry point information used by bootloader code
+ */
+SYM (__rtems_start):
+ .long __rtems_entry_point
+
+ /*
+ * end of special Entry point section
+ */
+ .text
+ .p2align 5
+
+PUBLIC_VAR(default_exception_vector_code_prolog)
+SYM (default_exception_vector_code_prolog):
+ /*
+ * let room for exception frame
+ */
+ stwu r1, - (EXCEPTION_FRAME_END)(r1)
+ stw r3, GPR3_OFFSET(r1)
+ /* R2 should never change (EABI: pointer to .sdata2) - we
+ * save it nevertheless..
+ */
+ stw r2, GPR2_OFFSET(r1)
+ mflr r3
+ stw r3, EXC_LR_OFFSET(r1)
+ bl 0f
+0: /*
+ * r3 = exception vector entry point
+ * (256 * vector number) + few instructions
+ */
+ mflr r3
+ /*
+ * r3 = r3 >> 8 = vector
+ */
+ srwi r3,r3,8
+ ba push_normalized_frame
- .set IP_CTR, (IP_CR + 4)
- .set IP_XER, (IP_CTR + 4)
- .set IP_LR, (IP_XER + 4)
- .set IP_PC, (IP_LR + 4)
+ PUBLIC_VAR (default_exception_vector_code_prolog_size)
- .set IP_MSR, (IP_PC + 4)
+ default_exception_vector_code_prolog_size= . - default_exception_vector_code_prolog
- .set IP_END, (IP_MSR + 16)
-
- /* Vector offsets */
- .set begin_vector,0xFFF00000
- .set crit_vector,0xFFF00100
- .set mach_vector,0xFFF00200
- .set prot_vector,0xFFF00300
- .set ext_vector,0xFFF00500
- .set align_vector,0xFFF00600
- .set prog_vector,0xFFF00700
- .set dec_vector,0xFFF00900
- .set sys_vector,0xFFF00C00
- .set pit_vector,0xFFF01000
- .set fit_vector,0xFFF01010
- .set wadt_vector,0xFFF01020
- .set debug_vector,0xFFF02000
+ .p2align 5
+PUBLIC_VAR (push_normalized_frame)
+SYM (push_normalized_frame):
+ stw r3, EXCEPTION_NUMBER_OFFSET(r1)
+ stw r0, GPR0_OFFSET(r1)
+ mfsrr0 r3
+ stw r3, SRR0_FRAME_OFFSET(r1)
+ mfsrr1 r3
+ stw r3, SRR1_FRAME_OFFSET(r1)
+ /*
+ * Save general purpose registers
+ * Already saved in prolog : R1, R2, R3, LR.
+ * Saved a few line above : R0
+ *
+ * Manual says that "stmw" instruction may be slower than
+ * series of individual "stw" but who cares about performance
+ * for the DEFAULT exception handler?
+ */
+ stmw r4, GPR4_OFFSET(r1) /* save R4->R31 */
-/* Go to the right section */
-#if PPC_ASM == PPC_ASM_ELF
- .section .vectors,"awx",@progbits
-#elif PPC_ASM == PPC_ASM_XCOFF
- .csect .text[PR]
-#endif
-
- PUBLIC_VAR (__vectors)
-SYM (__vectors):
+ mfcr r31
+ stw r31, EXC_CR_OFFSET(r1)
+ mfctr r30
+ stw r30, EXC_CTR_OFFSET(r1)
+ mfxer r28
+ stw r28, EXC_XER_OFFSET(r1)
+ mfmsr r28
+ stw r28, EXC_MSR_OFFSET(r1)
+ mfdar r28
+ stw r28, EXC_DAR_OFFSET(r1)
+ /*
+ * compute SP at exception entry
+ */
+ addi r3, r1, EXCEPTION_FRAME_END
+ /*
+ * store it at the right place
+ */
+ stw r3, GPR1_OFFSET(r1)
+ /*
+ * Enable data and instruction address translation, exception nesting
+ */
+ mfmsr r3
+ ori r3,r3, MSR_RI /* | MSR_IR | MSR_DR */
+ mtmsr r3
+ SYNC
-/* Decrementer interrupt */
- .org dec_vector - file_base
-#if (PPC_ABI == PPC_ABI_POWEROPEN || PPC_ABI == PPC_ABI_GCC27)
-#if (PPC_HAS_FPU)
- stwu r1, -(20*4 + 18*8 + IP_END)(r1)
-#else
- stwu r1, -(20*4 + IP_END)(r1)
-#endif
-#else
- stwu r1, -(IP_END)(r1)
-#endif
- stw r0, IP_0(r1)
+ /*
+ * Call C exception handler
+ */
+ /*
+ * store the execption frame address in r3 (first param)
+ */
+ addi r3, r1, 0x8
+ /*
+ * globalExceptHdl(r3)
+ */
+ addis r4, 0, globalExceptHdl@ha
+ lwz r5, globalExceptHdl@l(r4)
+ mtlr r5
+ blrl
+ /*
+ * Restore registers status
+ */
+ lwz r31, EXC_CR_OFFSET(r1)
+ mtcr r31
+ lwz r30, EXC_CTR_OFFSET(r1)
+ mtctr r30
+ lwz r29, EXC_LR_OFFSET(r1)
+ mtlr r29
+ lwz r28, EXC_XER_OFFSET(r1)
+ mtxer r28
- li r0, PPC_IRQ_DECREMENTER
- b PROC (_ISR_Handler)
+ lmw r4, GPR4_OFFSET(r1)
+ lwz r2, GPR2_OFFSET(r1)
+ lwz r0, GPR0_OFFSET(r1)
+ /*
+ * Disable data and instruction translation. Make path non recoverable...
+ */
+ mfmsr r3
+ xori r3, r3, MSR_RI | MSR_IR | MSR_DR
+ mtmsr r3
+ SYNC
+ /*
+ * Restore rfi related settings
+ */
+
+ lwz r3, SRR1_FRAME_OFFSET(r1)
+ mtsrr1 r3
+ lwz r3, SRR0_FRAME_OFFSET(r1)
+ mtsrr0 r3
+
+ lwz r3, GPR3_OFFSET(r1)
+ addi r1,r1, EXCEPTION_FRAME_END
+ SYNC
+ rfi
diff --git a/c/src/lib/libbsp/powerpc/psim/wrapup/Makefile.am b/c/src/lib/libbsp/powerpc/psim/wrapup/Makefile.am
index 662610ab55..73cc0afaa8 100644
--- a/c/src/lib/libbsp/powerpc/psim/wrapup/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/wrapup/Makefile.am
@@ -2,25 +2,19 @@
## $Id$
##
-include $(top_srcdir)/../../../../../../automake/compile.am
-include $(top_srcdir)/../../../../../../automake/lib.am
-
-if HAS_MP
-GENERIC_MP_REL_PIECES = shmdr
-endif
-GENERIC_PIECES = $(GENERIC_MP_REL_PIECES)
-
-if HAS_MP
-BSP_MP_O_PIECES = shmsupp
-endif
-BSP_PIECES = startup clock console timer vectors $(BSP_MP_O_PIECES)
+BSP_PIECES = startup clock console irq vectors
# bummer; have to use $foreach since % pattern subst rules only replace 1x
-OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.$(OBJEXT))) \
+OBJS = $(foreach piece, $(BSP_PIECES), ../$(piece)/$(ARCH)/*.$(OBJEXT)) \
+ $(wildcard ../../../../libcpu/$(RTEMS_CPU)/shared/*/$(ARCH)/*.$(OBJEXT)) \
+ $(wildcard ../../../../libcpu/$(RTEMS_CPU)/mpc6xx/*/$(ARCH)/*.$(OBJEXT)) \
../@exceptions@/$(ARCH)/rtems-cpu.rel \
- $(foreach piece, $(GENERIC_PIECES), ../../../$(piece)/$(ARCH)/$(piece).rel)
+ $(wildcard ../../../../libcpu/$(RTEMS_CPU)/$(RTEMS_CPU_MODEL)/*/$(ARCH)/*.$(OBJEXT))
LIB = $(ARCH)/libbsp.a
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
#
# (OPTIONAL) Add local stuff here using +=
#