summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2009-09-09 14:17:10 +0000
committerTill Straumann <strauman@slac.stanford.edu>2009-09-09 14:17:10 +0000
commit6597e5839f8fc39416e634fd0f68f163e2d272e2 (patch)
treef081c556711ae60be4bd68a1b5553b31ac6c86cd
parent32b09a90f44468eeeb9c8f9a84a0ea729a1cbbc3 (diff)
downloadrtems-6597e5839f8fc39416e634fd0f68f163e2d272e2.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.
-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 dd62ec3586..516c65df75 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-07-30 Eric Norum <norume@aps.anl.gov>
* include/bsp.h, network/network.c, startup/bspstart.c: Try enabling
diff --git a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
index 110ab9f94f..4d670bb887 100644
--- a/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
+++ b/c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c
@@ -188,6 +188,8 @@ void _CPU_cache_invalidate_1_data_line(const void *addr)
void bsp_libc_init( void *, uint32_t, int );
void bsp_pretasking_hook(void); /* m68k version */
+extern void bsp_fake_syscall();
+
/*
* The Arcturus boot ROM prints exception information improperly
* so use this default exception handler instead. This one also
@@ -260,6 +262,13 @@ void bsp_start( void )
if (i != (32+2)) /* Catch all but bootrom system calls */
*((void (**)(int))(i * 4)) = handler;
+ /*
+ * 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;
+
/*
* Need to "allocate" the memory for the RTEMS Workspace and
* tell the RTEMS configuration where it is. This memory is
@@ -419,6 +428,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.