summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2006-09-18 07:41:02 +0000
committerNathan Sidwell <nathan@codesourcery.com>2006-09-18 07:41:02 +0000
commitcf7c22b5d8b97b12e0b2322ad979fbdf7e7425a7 (patch)
tree631415d5a6d716ce5779ab233c750393627faa73
parent5f87f7b44d1fd4819577a6fe2beec305990d09d9 (diff)
downloadcygnal-cf7c22b5d8b97b12e0b2322ad979fbdf7e7425a7.tar.gz
cygnal-cf7c22b5d8b97b12e0b2322ad979fbdf7e7425a7.tar.bz2
cygnal-cf7c22b5d8b97b12e0b2322ad979fbdf7e7425a7.zip
libgloss/
* m68k/Makefile.in (bdm-semihost.o): Build from bdm-semihost.S. * m68k/bdm-semihost.c: Remove. * m68k/bdm-semihost.S: New. * m68k/bdm-crt0.S: Don't install semihosting trap handler. * m68k/bdm-close.c, bdm-exit.c, bdm-fstat.c, bdm-gettimeofday.c, bdm-isatty.c, bdm-lseek.c, bdm-open.c, bdm-read.c, bdm-rename.c, bdm-stat.c, bdm-system.c, bdm-unlink.c, bdm-write.c): Update. * m68k/bdm-isrs.c: Update comment. * m68k/bdm-semihost.h (BDM_TRAPNUM, BDM_FUNC_REG, BDM_ARG_REG, BDM_TRAP): Remove. (__bdm_semihost): Declare.
-rw-r--r--ChangeLog.csl15
-rw-r--r--libgloss/m68k/Makefile.in9
-rw-r--r--libgloss/m68k/bdm-close.c2
-rw-r--r--libgloss/m68k/bdm-crt0.S2
-rw-r--r--libgloss/m68k/bdm-exit.c2
-rw-r--r--libgloss/m68k/bdm-fstat.c2
-rw-r--r--libgloss/m68k/bdm-gettimeofday.c2
-rw-r--r--libgloss/m68k/bdm-isatty.c2
-rw-r--r--libgloss/m68k/bdm-isrs.c5
-rw-r--r--libgloss/m68k/bdm-lseek.c2
-rw-r--r--libgloss/m68k/bdm-open.c2
-rw-r--r--libgloss/m68k/bdm-read.c2
-rw-r--r--libgloss/m68k/bdm-rename.c2
-rw-r--r--libgloss/m68k/bdm-semihost.S (renamed from libgloss/m68k/bdm-semihost.c)28
-rw-r--r--libgloss/m68k/bdm-semihost.h25
-rw-r--r--libgloss/m68k/bdm-stat.c2
-rw-r--r--libgloss/m68k/bdm-system.c2
-rw-r--r--libgloss/m68k/bdm-unlink.c2
-rw-r--r--libgloss/m68k/bdm-write.c2
19 files changed, 54 insertions, 56 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 6fe9d6c2d..f8072bfb7 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,18 @@
+2006-09-18 Nathan Sidwell <nathan@codesourcery.com>
+
+ libgloss/
+ * m68k/Makefile.in (bdm-semihost.o): Build from bdm-semihost.S.
+ * m68k/bdm-semihost.c: Remove.
+ * m68k/bdm-semihost.S: New.
+ * m68k/bdm-crt0.S: Don't install semihosting trap handler.
+ * m68k/bdm-close.c, bdm-exit.c, bdm-fstat.c, bdm-gettimeofday.c,
+ bdm-isatty.c, bdm-lseek.c, bdm-open.c, bdm-read.c, bdm-rename.c,
+ bdm-stat.c, bdm-system.c, bdm-unlink.c, bdm-write.c): Update.
+ * m68k/bdm-isrs.c: Update comment.
+ * m68k/bdm-semihost.h (BDM_TRAPNUM, BDM_FUNC_REG, BDM_ARG_REG,
+ BDM_TRAP): Remove.
+ (__bdm_semihost): Declare.
+
2006-09-15 Nathan Sidwell <nathan@codesourcery.com>
libgloss/
diff --git a/libgloss/m68k/Makefile.in b/libgloss/m68k/Makefile.in
index 29492e34c..150a8c31e 100644
--- a/libgloss/m68k/Makefile.in
+++ b/libgloss/m68k/Makefile.in
@@ -124,10 +124,10 @@ BDM_CRT0= bdm-crt0.o
BDM_BSP= libbdm.a
BDM_OBJS= bdm-crt1.o bdm-semihost.o $(BDM_SYSOBJS) \
$(patsubst %,bdm-%.o,${BDM_ISRS})
-BDM_OTHER_OBJS= getpid.o kill.o sbrk.o
+BDM_OTHER_OBJS= getpid.o kill.o
BDM_SYSOBJS= bdm-close.o bdm-exit.o bdm-fstat.o bdm-gdb.o \
bdm-gettimeofday.o bdm-isatty.o bdm-lseek.o \
- bdm-open.o bdm-read.o bdm-rename.o \
+ bdm-open.o bdm-read.o bdm-rename.o bdm-sbrk.o \
bdm-stat.o bdm-system.o bdm-time.o bdm-unlink.o bdm-write.o
BDM_ISRS= other_interrupt reset access_error address_error \
illegal_instruction divide_by_zero privilege_violation \
@@ -193,9 +193,8 @@ bdm-crt0.o : bdm-crt0.S
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@
bdm-crt1.o : bdm-crt1.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@
-#We need to omit the frame pointer to ensure there is no prologue.
-bdm-semihost.o : bdm-semihost.c
- $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ -fomit-frame-pointer
+bdm-semihost.o : bdm-semihost.S
+ $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@
# We need to keep the frame pointer to make sure there's some
# prologue. Otherwise we get confused with the semihosting reoutine.
diff --git a/libgloss/m68k/bdm-close.c b/libgloss/m68k/bdm-close.c
index 40ddf9f5e..dced304b9 100644
--- a/libgloss/m68k/bdm-close.c
+++ b/libgloss/m68k/bdm-close.c
@@ -32,7 +32,7 @@ int close (int fd)
{
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) fd;
- BDM_TRAP (BDM_CLOSE, (uint32_t)parameters);
+ __bdm_semihost (BDM_CLOSE, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-crt0.S b/libgloss/m68k/bdm-crt0.S
index dac6ac421..a61919a4f 100644
--- a/libgloss/m68k/bdm-crt0.S
+++ b/libgloss/m68k/bdm-crt0.S
@@ -55,7 +55,7 @@ __interrupt_vector:
.long __trap12 /* 44 */
.long __trap13 /* 45 */
.long __trap14 /* 46 */
- .long __bdm_semihosting /* 47 */
+ .long __trap15 /* 47 */
.long __fp_branch_unordered /* 48 */
.long __fp_inexact_result /* 49 */
.long __fp_divide_by_zero /* 50 */
diff --git a/libgloss/m68k/bdm-exit.c b/libgloss/m68k/bdm-exit.c
index 5223bcd37..128d54710 100644
--- a/libgloss/m68k/bdm-exit.c
+++ b/libgloss/m68k/bdm-exit.c
@@ -27,7 +27,7 @@ void __attribute__ ((noreturn)) _exit (int code)
{
while (1)
{
- BDM_TRAP (BDM_EXIT, code);
+ __bdm_semihost (BDM_EXIT, (void *)code);
__reset ();
}
}
diff --git a/libgloss/m68k/bdm-fstat.c b/libgloss/m68k/bdm-fstat.c
index f93f854f6..e8fb67619 100644
--- a/libgloss/m68k/bdm-fstat.c
+++ b/libgloss/m68k/bdm-fstat.c
@@ -37,7 +37,7 @@ int fstat (int fd, struct stat *buf)
struct gdb_stat gbuf;
parameters[0] = (uint32_t) fd;
parameters[1] = (uint32_t) &gbuf;
- BDM_TRAP (BDM_FSTAT, (uint32_t)parameters);
+ __bdm_semihost (BDM_FSTAT, parameters);
convert_from_gdb_stat (&gbuf, buf);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
diff --git a/libgloss/m68k/bdm-gettimeofday.c b/libgloss/m68k/bdm-gettimeofday.c
index 154954244..5ed1331f8 100644
--- a/libgloss/m68k/bdm-gettimeofday.c
+++ b/libgloss/m68k/bdm-gettimeofday.c
@@ -40,7 +40,7 @@ int gettimeofday (struct timeval *tv, struct timezone *tz)
return -1;
}
parameters[0] = (uint32_t) &gtv;
- BDM_TRAP (BDM_GETTIMEOFDAY, (uint32_t)parameters);
+ __bdm_semihost (BDM_GETTIMEOFDAY, parameters);
convert_from_gdb_timeval (&gtv, tv);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
diff --git a/libgloss/m68k/bdm-isatty.c b/libgloss/m68k/bdm-isatty.c
index 1da79bc15..81cad1cdb 100644
--- a/libgloss/m68k/bdm-isatty.c
+++ b/libgloss/m68k/bdm-isatty.c
@@ -32,7 +32,7 @@ int isatty (int fd)
{
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) fd;
- BDM_TRAP (BDM_ISATTY, (uint32_t)parameters);
+ __bdm_semihost (BDM_ISATTY, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-isrs.c b/libgloss/m68k/bdm-isrs.c
index 7ee9fbaa0..2b80d6691 100644
--- a/libgloss/m68k/bdm-isrs.c
+++ b/libgloss/m68k/bdm-isrs.c
@@ -20,10 +20,7 @@
These interrupt handlers are entered whenever the associated
interrupt occurs. All they do is stop the debugger to give the user
- the opportunity to determine where the problem was.
-
- User trap BDM_TRAPNUM (15) is used for semi hosting support.
- If you replace this one, semihosting will cease to function. */
+ the opportunity to determine where the problem was. */
/* Each ISR is a loop containing a halt instruction */
diff --git a/libgloss/m68k/bdm-lseek.c b/libgloss/m68k/bdm-lseek.c
index b8308cbff..2ae7d667e 100644
--- a/libgloss/m68k/bdm-lseek.c
+++ b/libgloss/m68k/bdm-lseek.c
@@ -40,7 +40,7 @@ off_t lseek (int fd, off_t offset, int whence)
parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff);
parameters[2] = (uint32_t) (offset & 0xffffffff);
parameters[3] = convert_to_gdb_lseek_flags (whence);
- BDM_TRAP (BDM_LSEEK, (uint32_t)parameters);
+ __bdm_semihost (BDM_LSEEK, parameters);
errno = convert_from_gdb_errno (parameters[2]);
return ((uint64_t)parameters[0] << 32) | ((uint64_t)parameters[1]);
}
diff --git a/libgloss/m68k/bdm-open.c b/libgloss/m68k/bdm-open.c
index 878cff84d..10e9148ad 100644
--- a/libgloss/m68k/bdm-open.c
+++ b/libgloss/m68k/bdm-open.c
@@ -50,7 +50,7 @@ int open (const char *fname, int flags, ...)
}
else
parameters[3] = 0;
- BDM_TRAP (BDM_OPEN, (uint32_t)parameters);
+ __bdm_semihost (BDM_OPEN, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-read.c b/libgloss/m68k/bdm-read.c
index 441a7d249..805feeb5b 100644
--- a/libgloss/m68k/bdm-read.c
+++ b/libgloss/m68k/bdm-read.c
@@ -36,7 +36,7 @@ ssize_t read (int fd, void *buf, size_t count)
parameters[0] = (uint32_t) fd;
parameters[1] = (uint32_t) buf;
parameters[2] = (uint32_t) count;
- BDM_TRAP (BDM_READ, (uint32_t)parameters);
+ __bdm_semihost (BDM_READ, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-rename.c b/libgloss/m68k/bdm-rename.c
index 3e0acf3bb..2698b7290 100644
--- a/libgloss/m68k/bdm-rename.c
+++ b/libgloss/m68k/bdm-rename.c
@@ -39,7 +39,7 @@ int _rename (const char *oldpath, const char *newpath)
parameters[1] = (uint32_t) strlen (oldpath) + 1;
parameters[2] = (uint32_t) newpath;
parameters[3] = (uint32_t) strlen (newpath) + 1;
- BDM_TRAP (BDM_RENAME, (uint32_t)parameters);
+ __bdm_semihost (BDM_RENAME, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-semihost.c b/libgloss/m68k/bdm-semihost.S
index c0608e1fa..26336eb6a 100644
--- a/libgloss/m68k/bdm-semihost.c
+++ b/libgloss/m68k/bdm-semihost.S
@@ -1,5 +1,5 @@
/*
- * bdm-semihost.c --
+ * bdm-semihost.S --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@@ -14,12 +14,22 @@
* they apply.
*/
-/* Semihosting trap. The debugger intercepts this and
- performs the semihosting action. Then the program resumes as
- usual. This function must be compiled without a frame pointer, so
- we know the halt instruction is the very first instuction. */
+/* Semihosting function. The debugger intercepts the halt, and
+ determines that it is followed by the magic movec pattern. */
+
+ .globl __bdm_semihost
+__bdm_semihost:
+ linkw %fp,#0
+ movel %fp@(8),%d0
+ movel %fp@(12),%d1
+ .align 4
+ nop
+ halt
+
+ /* This sentinel instruction value must be aligned to a 4 byte
+ * boundary and be immediately after the halt instruction. The
+ * debugger will adjust the pc, so that it is never executed. */
-void __attribute__ ((interrupt_handler)) __bdm_semihosting (void)
-{
- __asm__ __volatile__ ("halt" ::: "memory");
-}
+ .long 0x4e7b0000
+ unlk %fp
+ rts
diff --git a/libgloss/m68k/bdm-semihost.h b/libgloss/m68k/bdm-semihost.h
index 4d6e2b9cc..d82027557 100644
--- a/libgloss/m68k/bdm-semihost.h
+++ b/libgloss/m68k/bdm-semihost.h
@@ -14,21 +14,6 @@
* they apply.
*/
-/* Semihosting uses a user trap handler containing a HALT
- instruction. This wakes the debugger to perform some action. */
-
-/* This is the semihosting trap hander */
-#define BDM_TRAPNUM 15
-
-/* This register holds the function enumeration for a semihosting
- command. */
-#define BDM_FUNC_REG "d0"
-
-/* This register holds the argument for the semihosting call. For most
- functions, this is a pointer to a block of memory that holds the input
- and output parameters for the remote file i/o operation. */
-#define BDM_ARG_REG "d1"
-
/* Codes for BDM_FUNC_REG. */
#define BDM_EXIT 0
@@ -46,12 +31,4 @@
#define BDM_ISATTY 12
#define BDM_SYSTEM 13
-/* Here is the macro that generates the trap. */
-
-#define BDM_TRAP(func, arg) \
- __asm__ __volatile__ ("move.l %0,%/" BDM_ARG_REG "\n" \
- "moveq %1,%/" BDM_FUNC_REG "\n" \
- "trap %2" \
- :: "rmi" (arg), "n" (func), "n" (BDM_TRAPNUM) \
- : BDM_FUNC_REG,BDM_ARG_REG,"memory")
-
+extern int __bdm_semihost (int func, void *args);
diff --git a/libgloss/m68k/bdm-stat.c b/libgloss/m68k/bdm-stat.c
index 536aeec5d..21c0ca3e5 100644
--- a/libgloss/m68k/bdm-stat.c
+++ b/libgloss/m68k/bdm-stat.c
@@ -41,7 +41,7 @@ int stat (const char *filename, struct stat *buf)
parameters[0] = (uint32_t) filename;
parameters[1] = (uint32_t) strlen (filename) + 1;
parameters[2] = (uint32_t) &gbuf;
- BDM_TRAP (BDM_STAT, (uint32_t)parameters);
+ __bdm_semihost (BDM_STAT, parameters);
convert_from_gdb_stat (&gbuf, buf);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
diff --git a/libgloss/m68k/bdm-system.c b/libgloss/m68k/bdm-system.c
index 75a82e2a7..6aab4b1ef 100644
--- a/libgloss/m68k/bdm-system.c
+++ b/libgloss/m68k/bdm-system.c
@@ -37,7 +37,7 @@ int _system (const char *command)
parameters[0] = (uint32_t) command;
parameters[1] = command ? (uint32_t) strlen (command) + 1 : 0;
- BDM_TRAP (BDM_SYSTEM, (uint32_t)parameters);
+ __bdm_semihost (BDM_SYSTEM, parameters);
errno = convert_from_gdb_errno (parameters[1]);
e = parameters[0];
if (e >= 0 && command)
diff --git a/libgloss/m68k/bdm-unlink.c b/libgloss/m68k/bdm-unlink.c
index 05098ae7a..29f807204 100644
--- a/libgloss/m68k/bdm-unlink.c
+++ b/libgloss/m68k/bdm-unlink.c
@@ -35,7 +35,7 @@ int unlink (const char *path)
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) path;
parameters[1] = (uint32_t) strlen (path) + 1;
- BDM_TRAP (BDM_UNLINK, (uint32_t)parameters);
+ __bdm_semihost (BDM_UNLINK, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}
diff --git a/libgloss/m68k/bdm-write.c b/libgloss/m68k/bdm-write.c
index 0280dcd7c..b532e4cb3 100644
--- a/libgloss/m68k/bdm-write.c
+++ b/libgloss/m68k/bdm-write.c
@@ -36,7 +36,7 @@ ssize_t write (int fd, const void *buf, size_t count)
parameters[0] = (uint32_t) fd;
parameters[1] = (uint32_t) buf;
parameters[2] = (uint32_t) count;
- BDM_TRAP (BDM_WRITE, (uint32_t)parameters);
+ __bdm_semihost (BDM_WRITE, parameters);
errno = convert_from_gdb_errno (parameters[1]);
return parameters[0];
}