summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2009-09-09 05:34:44 +0000
committerTill Straumann <strauman@slac.stanford.edu>2009-09-09 05:34:44 +0000
commitddfae71ab0062a264bad82655a872afc9d643183 (patch)
tree4398a75ecfd0a2acd896e689407ff914568ea2d3 /c
parent2009-09-07 Sebastian Huber <Sebastian.Huber@embedded-brains.de> (diff)
downloadrtems-ddfae71ab0062a264bad82655a872afc9d643183.tar.bz2
2009-09-09 Till Straumann <strauman@slac.stanford.edu>
* startup/bspstart.c: Added dummy implementation of firmware syscalls for use with QEMU. Dummy handler is installed if no pre-existing firmware handler is found.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/m68k/uC5282/ChangeLog6
-rw-r--r--c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c40
2 files changed, 46 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/uC5282/ChangeLog b/c/src/lib/libbsp/m68k/uC5282/ChangeLog
index 38978773df..063549ad19 100644
--- a/c/src/lib/libbsp/m68k/uC5282/ChangeLog
+++ b/c/src/lib/libbsp/m68k/uC5282/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-09 Till Straumann <strauman@slac.stanford.edu>
+
+ * startup/bspstart.c: Added dummy implementation of firmware
+ syscalls for use with QEMU. Dummy handler is installed if no
+ pre-existing firmware handler is found.
+
2009-08-26 Joel Sherrill <joel.sherrill@oarcorp.com>
* clock/clock.c, include/bsp.h: Rename BSP specific idle thread to
diff --git a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
index 8d93ce1f06..708dedfa12 100644
--- a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
+++ b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
@@ -184,6 +184,8 @@ void _CPU_cache_invalidate_1_data_line(const void *addr)
#endif
}
+extern void bsp_fake_syscall();
+
/*
* The Arcturus boot ROM prints exception information improperly
* so use this default exception handler instead. This one also
@@ -264,6 +266,13 @@ void bsp_start( void )
m68k_set_acr0(mcf5282_acr0_mode);
/*
+ * Qemu has no trap handler; install our fake syscall
+ * implementation if there is no existing handler.
+ */
+ if ( 0 == *((void (**)(int))((32+2) * 4)) )
+ *((void (**)(int))((32+2) * 4)) = bsp_fake_syscall;
+
+ /*
* Enable the cache
*/
m68k_set_cacr(mcf5282_cacr_mode);
@@ -394,6 +403,37 @@ syscall_2(int, program, bsp_mnode_t *, chain, int, flags)
syscall_3(int, flash_erase_range, volatile unsigned short *, flashptr, int, start, int, end);
syscall_3(int, flash_write_range, volatile unsigned short *, flashptr, bsp_mnode_t *, chain, int, offset);
+/* Provide a dummy-implementation of these syscalls
+ * for qemu (which lacks the firmware).
+ */
+
+#define __STR(x) #x
+#define __STRSTR(x) __STR(x)
+#define ERRVAL __STRSTR(EACCES)
+
+/* reset-control register */
+#define RCR "__IPSBAR + 0x110000"
+
+asm(
+ "bsp_fake_syscall: \n"
+ " cmpl #0, %d0 \n" /* sysreset */
+ " bne 1f \n"
+ " moveb #0x80, %d0 \n"
+ " moveb %d0, "RCR" \n" /* reset-controller */
+ /* should never get here - but we'd return -EACCESS if we do */
+ "1: \n"
+ " cmpl #12, %d0 \n" /* gethwaddr */
+ " beq 2f \n"
+ " cmpl #14, %d0 \n" /* getbenv */
+ " beq 2f \n"
+ " movel #-"ERRVAL", %d0 \n" /* return -EACCESS */
+ " rte \n"
+ "2: \n"
+ " movel #0, %d0 \n" /* return NULL */
+ " rte \n"
+);
+
+
/*
* 'Extended BSP' routines
* Should move to cpukit/score/cpu/m68k/cpu.c someday.