aboutsummaryrefslogtreecommitdiff
path: root/libgloss
diff options
context:
space:
mode:
authorKazu Hirata <kazu@codesourcery.com>2006-09-01 05:41:06 +0000
committerKazu Hirata <kazu@codesourcery.com>2006-09-01 05:41:06 +0000
commitc023e783e91748c9f1a8d6d19d98130c55389a3c (patch)
treeaf939ae3f785a4bca156931a8e7736d6ade7ba8b /libgloss
parent1202770601a3d1eff4901fcccf70ad9943e38dc0 (diff)
downloadnewlib-c023e783e91748c9f1a8d6d19d98130c55389a3c.zip
newlib-c023e783e91748c9f1a8d6d19d98130c55389a3c.tar.gz
newlib-c023e783e91748c9f1a8d6d19d98130c55389a3c.tar.bz2
libgloss/
Merge from newlib-csl-20060320-branch: 2006-08-31 Nathan Sidwell <nathan@codesourcery.com> * m68k/bdm-crt1.c: Call hardware_init_hook before copying initialized data. * m68k/Makefile.in (CF_BDM_SCRIPTS): Rename to CF_RAM_SCRIPTS. (CF_SCRIPTS): Update. (%-bdm.ld): Rename to %-ram.ld. 2006-08-25 Nathan Sidwell <nathan@codesourcery.com> * m68k/Makefile.in (DBUG_BSP, DBUG_OBJS): Remove. (BDM_CRT0): New. (BDM_OBJS): Add bdm-crt1.o. (BDM_OTHER_OBJS): Remove print.o putnum.o (CF_BOARDS): New. (CF_BDM_SCRIPTS): Generated name of ram scripts. (CF_ROM_SCRIPTS): Generated name of rom scripts. (CF_SCRIPTS): Adjust. (all): Add BDM_CRT0. (bdm-crt0.o, bdm-crt1.o): New targets. (bdm-isv.o): Remove. (m5208evb, m5213evb, m52235evb, m5235evb, m5273c3, m5282evb, m5329evb, m5485evb): New. (%-bdm.ld, %-rom.ld): New. Replace individual linker script rules. (install): Remove DBUG installs. * m68k/bdm-crt0.S: New. * m68k/bdm-crt1.c: New. * m68k/bdm-exit.c: Call __reset. * m68k/bdm-isv.c: Remove. * m68k/cf.sc: Adjust to produce either rom or ram images. * m68k/dbug-exit.S, m68k/dbug-inbyte.S, m68k/dbug-outbyte.S: Remove. 2006-07-24 Nathan Sidwell <nathan@codesourcery.com> Bug 844 * m68k/cf.sc: Set entry point to _start. * m68k/crt0.X (_start): New name for entrypoint (start): Weak alias for start. 2006-06-09 Nathan Sidwell <nathan@codesourcery.com> * m68k/bdm-system.c (_system): Support system(NULL). 2006-06-08 Nathan Sidwell <nathan@codesourcery.com> * m68k/bdm-system.c (_system): Properly encode non failure exit code. 2006-06-05 Nathan Sidwell <nathan@codesourcery.com> * m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-inbyte.o. Add bdm-time.o. * m68k/bdm-close.c: Add copyright notice. * m68k/bdm-fstat.c: Add copyright notice. * m68k/bdm-gettimeofday.c: Add copyright notice. * m68k/bdm-inbyte.c: Remove. * m68k/bdm-isatty.c: Add copyright notice. * m68k/bdm-lseek.c: Add copyright notice. Fix &/| thinko. * m68k/bdm-open.c: Add copyright notice. * m68k/bdm-read.c: Add copyright notice. * m68k/bdm-rename.c: Add copyright notice. * m68k/bdm-stat.c: Add copyright notice. * m68k/bdm-system.c: Add copyright notice. * m68k/bdm-time.c: New. * m68k/bdm-unlink.c: Add copyright notice. * m68k/bdm-write.c: Add copyright notice. 2006-05-25 Nathan Sidwell <nathan@codesourcery.com> * m68k/Makefile.in (m52235-dbug.ld, m52235-bdm.ld): New scripts. 2006-05-24 Nathan Sidwell <nathan@codesourcery.com> * m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-outbyte.o. * m68k/bdm-outbyte.c: Delete. * m68k/bdm-semihost.h (BDM_OUTBYTE): Mark as obsolete. 2006-05-22 Sandra Loosemore <sandra@codesourcery.com> * m68k/bdm-semihost.h: Add new constants for additional semihosting functions. Add new BDM_TRAP macro to encapsulate inline asm. * m68k/bdm-exit.c (_exit): Use new BDM_TRAP macro. * m68k/bdm-outbyte.c (outbyte): Ditto. * m68k/bdm-isrs.c, m68k/bdm-isv.c: Former BDM_TRAP now called BDM_TRAPNUM. * m68k/bdm-gdb.h, m68k/bdm-gdb.c: New files containing declarations and conversion functions for GDB's fileio protocol. * m68k/bdm-close.c: New file to define corresponding function. * m68k/bdm-fstat.c: Ditto. * m68k/bdm-gettimeofday.c: Ditto. * m68k/bdm-isatty.c: Ditto. * m68k/bdm-lseek.c: Ditto. * m68k/bdm-open.c: Ditto. * m68k/bdm-read.c: Ditto. * m68k/bdm-rename.c: Ditto. * m68k/bdm-stat.c: Ditto. * m68k/bdm-system.c: Ditto. * m68k/bdm-unlink.c: Ditto. * m68k/bdm-write.c Ditto. * m68k/Makefile.in: Add dependencies for new files. 2006-03-29 Nathan Sidwell <nathan@codesourcery.com> * m68k/bdm-isv.c (software_init_hook): Fix trap numbering. * m68k/Makefile.in (CF_SCRIPTS): Add m5329 board. Reorder. (*-dbug.ld, *-bdm.ld): Add appropriate IO definition. (m5329evb-dbug.ld, m5329evb-bdm.ld): New. * cf.sc (GROUP): Revert previous change. Add IO library. * m68k/Makefile.in (BDM_BSP, BDM_OBJS, BDM_ISRS): New. (CF_SCRIPTS): Rename dbug scripts. Add bdm scripts. Add m5485 scripts. (all): Add new targets. (BDM_BSP): New target. (bdm-isv.o, bdm-exit.o, bdm-outbyte.o, bdm-semihost.o): New targets. (BDM_ISRS): New targets. (m5208evb.ld, m5213evb.ld, m5235evb.ld, m5272c3.ld, m5282evb.ld): Rename and adjust. (m5485evb-dbug): New. (m5208evb-bdm.ld, m5213evb-bdm.ld, m5235evb-bdm.ld, m5272c3-bdm.ld, m5282evb-bdm.ld, m5485evb-bdm.ld): New. (install): Add BDM_BSP. * m68k/bdm-exit.c: New * m68k/bdm-inbyte.c: New * m68k/bdm-outbyte.c: New * m68k/bdm-semihost.c: New * m68k/bdm-semihost.h: New * m68k/bdm-isrs.c: New. * m68k/bdm-isv.c: New. * dbug-cf.sc: Renamed to ... * cf.sc: ... here. Add bdm flexibility. Remove GROUP 2006-05-22 Sandra Loosemore <sandra@codesourcery.com> * m68k/bdm-semihost.h: Add new constants for additional semihosting functions. Add new BDM_TRAP macro to encapsulate inline asm. * m68k/bdm-exit.c (_exit): Use new BDM_TRAP macro. * m68k/bdm-outbyte.c (outbyte): Ditto. * m68k/bdm-isrs.c, m68k/bdm-isv.c: Former BDM_TRAP now called BDM_TRAPNUM. * m68k/bdm-gdb.h, m68k/bdm-gdb.c: New files containing declarations and conversion functions for GDB's fileio protocol. * m68k/bdm-close.c: New file to define corresponding function. * m68k/bdm-fstat.c: Ditto. * m68k/bdm-gettimeofday.c: Ditto. * m68k/bdm-isatty.c: Ditto. * m68k/bdm-lseek.c: Ditto. * m68k/bdm-open.c: Ditto. * m68k/bdm-read.c: Ditto. * m68k/bdm-rename.c: Ditto. * m68k/bdm-stat.c: Ditto. * m68k/bdm-system.c: Ditto. * m68k/bdm-unlink.c: Ditto. * m68k/bdm-write.c Ditto. * m68k/Makefile.in: Add dependencies for new files. newlib/ Merge from newlib-csl-20060320-branch: 2006-05-22 Sandra Loosemore <sandra@codesourcery.com> * configure.host: Tell it we have _rename and _system when building m68k-unknown-elf.
Diffstat (limited to 'libgloss')
-rw-r--r--libgloss/ChangeLog168
-rw-r--r--libgloss/m68k/Makefile.in88
-rw-r--r--libgloss/m68k/bdm-close.c (renamed from libgloss/m68k/dbug-outbyte.S)38
-rw-r--r--libgloss/m68k/bdm-crt0.S85
-rw-r--r--libgloss/m68k/bdm-crt1.c64
-rw-r--r--libgloss/m68k/bdm-exit.c (renamed from libgloss/m68k/dbug-exit.S)30
-rw-r--r--libgloss/m68k/bdm-fstat.c44
-rw-r--r--libgloss/m68k/bdm-gdb.c140
-rw-r--r--libgloss/m68k/bdm-gdb.h128
-rw-r--r--libgloss/m68k/bdm-gettimeofday.c47
-rw-r--r--libgloss/m68k/bdm-isatty.c38
-rw-r--r--libgloss/m68k/bdm-isrs.c192
-rw-r--r--libgloss/m68k/bdm-lseek.c46
-rw-r--r--libgloss/m68k/bdm-open.c56
-rw-r--r--libgloss/m68k/bdm-read.c42
-rw-r--r--libgloss/m68k/bdm-rename.c45
-rw-r--r--libgloss/m68k/bdm-semihost.c (renamed from libgloss/m68k/dbug-inbyte.S)31
-rw-r--r--libgloss/m68k/bdm-semihost.h57
-rw-r--r--libgloss/m68k/bdm-stat.c48
-rw-r--r--libgloss/m68k/bdm-system.c55
-rw-r--r--libgloss/m68k/bdm-time.c21
-rw-r--r--libgloss/m68k/bdm-unlink.c41
-rw-r--r--libgloss/m68k/bdm-write.c42
-rw-r--r--libgloss/m68k/cf.sc (renamed from libgloss/m68k/dbug-cf.sc)63
-rw-r--r--libgloss/m68k/crt0.S10
25 files changed, 1508 insertions, 111 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog
index 86591ac..64266f6 100644
--- a/libgloss/ChangeLog
+++ b/libgloss/ChangeLog
@@ -1,3 +1,171 @@
+2006-09-01 Kazu Hirata <kazu@codesourcery.com>
+
+ Merge from newlib-csl-20060320-branch:
+ 2006-08-31 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/bdm-crt1.c: Call hardware_init_hook before copying
+ initialized data.
+
+ * m68k/Makefile.in (CF_BDM_SCRIPTS): Rename to CF_RAM_SCRIPTS.
+ (CF_SCRIPTS): Update.
+ (%-bdm.ld): Rename to %-ram.ld.
+
+ 2006-08-25 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/Makefile.in (DBUG_BSP, DBUG_OBJS): Remove.
+ (BDM_CRT0): New.
+ (BDM_OBJS): Add bdm-crt1.o.
+ (BDM_OTHER_OBJS): Remove print.o putnum.o
+ (CF_BOARDS): New.
+ (CF_BDM_SCRIPTS): Generated name of ram scripts.
+ (CF_ROM_SCRIPTS): Generated name of rom scripts.
+ (CF_SCRIPTS): Adjust.
+ (all): Add BDM_CRT0.
+ (bdm-crt0.o, bdm-crt1.o): New targets.
+ (bdm-isv.o): Remove.
+ (m5208evb, m5213evb, m52235evb, m5235evb, m5273c3, m5282evb,
+ m5329evb, m5485evb): New.
+ (%-bdm.ld, %-rom.ld): New. Replace individual linker script rules.
+ (install): Remove DBUG installs.
+ * m68k/bdm-crt0.S: New.
+ * m68k/bdm-crt1.c: New.
+ * m68k/bdm-exit.c: Call __reset.
+ * m68k/bdm-isv.c: Remove.
+ * m68k/cf.sc: Adjust to produce either rom or ram images.
+ * m68k/dbug-exit.S, m68k/dbug-inbyte.S, m68k/dbug-outbyte.S: Remove.
+
+ 2006-07-24 Nathan Sidwell <nathan@codesourcery.com>
+
+ Bug 844
+ * m68k/cf.sc: Set entry point to _start.
+ * m68k/crt0.X (_start): New name for entrypoint
+ (start): Weak alias for start.
+
+ 2006-06-09 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/bdm-system.c (_system): Support system(NULL).
+
+ 2006-06-08 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/bdm-system.c (_system): Properly encode non failure exit
+ code.
+
+ 2006-06-05 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-inbyte.o.
+ Add bdm-time.o.
+ * m68k/bdm-close.c: Add copyright notice.
+ * m68k/bdm-fstat.c: Add copyright notice.
+ * m68k/bdm-gettimeofday.c: Add copyright notice.
+ * m68k/bdm-inbyte.c: Remove.
+ * m68k/bdm-isatty.c: Add copyright notice.
+ * m68k/bdm-lseek.c: Add copyright notice. Fix &/| thinko.
+ * m68k/bdm-open.c: Add copyright notice.
+ * m68k/bdm-read.c: Add copyright notice.
+ * m68k/bdm-rename.c: Add copyright notice.
+ * m68k/bdm-stat.c: Add copyright notice.
+ * m68k/bdm-system.c: Add copyright notice.
+ * m68k/bdm-time.c: New.
+ * m68k/bdm-unlink.c: Add copyright notice.
+ * m68k/bdm-write.c: Add copyright notice.
+
+ 2006-05-25 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/Makefile.in (m52235-dbug.ld, m52235-bdm.ld): New
+ scripts.
+
+ 2006-05-24 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-outbyte.o.
+ * m68k/bdm-outbyte.c: Delete.
+ * m68k/bdm-semihost.h (BDM_OUTBYTE): Mark as obsolete.
+
+ 2006-05-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ * m68k/bdm-semihost.h: Add new constants for additional
+ semihosting functions. Add new BDM_TRAP macro to encapsulate
+ inline asm.
+ * m68k/bdm-exit.c (_exit): Use new BDM_TRAP macro.
+ * m68k/bdm-outbyte.c (outbyte): Ditto.
+ * m68k/bdm-isrs.c, m68k/bdm-isv.c: Former BDM_TRAP
+ now called BDM_TRAPNUM.
+ * m68k/bdm-gdb.h, m68k/bdm-gdb.c: New files
+ containing declarations and conversion functions for GDB's fileio
+ protocol.
+ * m68k/bdm-close.c: New file to define corresponding function.
+ * m68k/bdm-fstat.c: Ditto.
+ * m68k/bdm-gettimeofday.c: Ditto.
+ * m68k/bdm-isatty.c: Ditto.
+ * m68k/bdm-lseek.c: Ditto.
+ * m68k/bdm-open.c: Ditto.
+ * m68k/bdm-read.c: Ditto.
+ * m68k/bdm-rename.c: Ditto.
+ * m68k/bdm-stat.c: Ditto.
+ * m68k/bdm-system.c: Ditto.
+ * m68k/bdm-unlink.c: Ditto.
+ * m68k/bdm-write.c Ditto.
+ * m68k/Makefile.in: Add dependencies for new files.
+
+ 2006-03-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * m68k/bdm-isv.c (software_init_hook): Fix trap numbering.
+
+ * m68k/Makefile.in (CF_SCRIPTS): Add m5329 board.
+ Reorder.
+ (*-dbug.ld, *-bdm.ld): Add appropriate IO definition.
+ (m5329evb-dbug.ld, m5329evb-bdm.ld): New.
+ * cf.sc (GROUP): Revert previous change. Add IO library.
+
+ * m68k/Makefile.in (BDM_BSP, BDM_OBJS, BDM_ISRS): New.
+ (CF_SCRIPTS): Rename dbug scripts. Add bdm scripts. Add m5485
+ scripts.
+ (all): Add new targets.
+ (BDM_BSP): New target.
+ (bdm-isv.o, bdm-exit.o, bdm-outbyte.o, bdm-semihost.o): New
+ targets.
+ (BDM_ISRS): New targets.
+ (m5208evb.ld, m5213evb.ld, m5235evb.ld, m5272c3.ld, m5282evb.ld):
+ Rename and adjust.
+ (m5485evb-dbug): New.
+ (m5208evb-bdm.ld, m5213evb-bdm.ld, m5235evb-bdm.ld,
+ m5272c3-bdm.ld, m5282evb-bdm.ld, m5485evb-bdm.ld): New.
+ (install): Add BDM_BSP.
+ * m68k/bdm-exit.c: New
+ * m68k/bdm-inbyte.c: New
+ * m68k/bdm-outbyte.c: New
+ * m68k/bdm-semihost.c: New
+ * m68k/bdm-semihost.h: New
+ * m68k/bdm-isrs.c: New.
+ * m68k/bdm-isv.c: New.
+ * dbug-cf.sc: Renamed to ...
+ * cf.sc: ... here. Add bdm flexibility. Remove GROUP
+
+ 2006-05-22 Sandra Loosemore <sandra@codesourcery.com>
+
+ * m68k/bdm-semihost.h: Add new constants for additional
+ semihosting functions. Add new BDM_TRAP macro to encapsulate
+ inline asm.
+ * m68k/bdm-exit.c (_exit): Use new BDM_TRAP macro.
+ * m68k/bdm-outbyte.c (outbyte): Ditto.
+ * m68k/bdm-isrs.c, m68k/bdm-isv.c: Former BDM_TRAP
+ now called BDM_TRAPNUM.
+ * m68k/bdm-gdb.h, m68k/bdm-gdb.c: New files
+ containing declarations and conversion functions for GDB's fileio
+ protocol.
+ * m68k/bdm-close.c: New file to define corresponding function.
+ * m68k/bdm-fstat.c: Ditto.
+ * m68k/bdm-gettimeofday.c: Ditto.
+ * m68k/bdm-isatty.c: Ditto.
+ * m68k/bdm-lseek.c: Ditto.
+ * m68k/bdm-open.c: Ditto.
+ * m68k/bdm-read.c: Ditto.
+ * m68k/bdm-rename.c: Ditto.
+ * m68k/bdm-stat.c: Ditto.
+ * m68k/bdm-system.c: Ditto.
+ * m68k/bdm-unlink.c: Ditto.
+ * m68k/bdm-write.c Ditto.
+ * m68k/Makefile.in: Add dependencies for new files.
+
2006-08-30 Kazunori Asayama <asayama@sm.sony.co.jp>
* spu/syscalls.c: Add a new argument to _send_to_ppe() to
diff --git a/libgloss/m68k/Makefile.in b/libgloss/m68k/Makefile.in
index 8faf5ff..ad3f69f 100644
--- a/libgloss/m68k/Makefile.in
+++ b/libgloss/m68k/Makefile.in
@@ -118,12 +118,32 @@ IDPGDB_BSP= libidpgdb.a
IDPGDB_OBJS= leds.o idp-inbyte.o idp-gdb-outbyte.o mc68ec.o
#
-# here's all the DBUG target stuff
+# here's all the BDM semihosting stuff
#
-DBUG_BSP= libdbug.a
-DBUG_OBJS= dbug-exit.o dbug-inbyte.o dbug-outbyte.o
-
-CF_SCRIPTS= m5208evb.ld m5213evb.ld m5235evb.ld m5272c3.ld m5282evb.ld
+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_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-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 \
+ trace unimplemented_line_a_opcode unimplemented_line_f_opcode \
+ non_pc_breakpoint_debug_interrupt pc_breakpoint_debug_interrupt \
+ format_error spurious_interrupt trap0 trap1 trap2 trap3 trap4 \
+ trap5 trap6 trap7 trap8 trap9 trap10 trap11 trap12 trap13 trap14 \
+ trap15 fp_branch_unordered fp_inexact_result fp_divide_by_zero \
+ fp_underflow fp_operand_error fp_overflow fp_input_not_a_number \
+ fp_input_denormalized_number unsupported_instruction
+
+CF_BOARDS := m5208evb m5213evb m52235evb m5235evb m5272c3 m5282evb \
+ m5329evb m5485evb
+CF_RAM_SCRIPTS := $(patsubst %,%-ram.ld,$(CF_BOARDS))
+CF_ROM_SCRIPTS := $(patsubst %,%-rom.ld,$(CF_BOARDS))
+CF_SCRIPTS= $(CF_RAM_SCRIPTS) $(CF_ROM_SCRIPTS)
# Host specific makefile fragment comes in here.
@host_makefile_frag@
@@ -132,7 +152,8 @@ CF_SCRIPTS= m5208evb.ld m5213evb.ld m5235evb.ld m5272c3.ld m5282evb.ld
# build a test program for each target board. Just trying to get
# it to link is a good test, so we ignore all the errors for now.
#
-all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP} ${CF_SCRIPTS}
+all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} \
+ ${MVME135_BSP} ${MVME162_BSP} ${BDM_CRT0} ${BDM_BSP} ${CF_SCRIPTS}
#
# here's where we build the board support packages for each target
@@ -153,8 +174,8 @@ ${IDPGDB_BSP}: $(OBJS) ${IDPGDB_OBJS}
${AR} ${ARFLAGS} $@ $(OBJS) ${IDPGDB_OBJS}
${RANLIB} $@
-${DBUG_BSP}: $(OBJS) ${DBUG_OBJS}
- ${AR} ${ARFLAGS} $@ $(OBJS) ${DBUG_OBJS}
+${BDM_BSP}: $(BDM_OTHER_OBJS) ${BDM_OBJS}
+ ${AR} ${ARFLAGS} $@ $(BDM_OTHER_OBJS) ${BDM_OBJS}
${RANLIB} $@
${MVME135_BSP}: $(OBJS) ${MVME135_OBJS}
@@ -165,20 +186,37 @@ ${MVME162_BSP}: $(OBJS) ${MVME162_OBJS}
${AR} ${ARFLAGS} $@ $(OBJS) ${MVME162_OBJS}
${RANLIB} $@
-m5208evb.ld: dbug-cf.sc Makefile
- RAMSTART=1024M RAMSIZE=16M RAMDBUG=128K ${SHELL} $< > $@
-
-m5213evb.ld: dbug-cf.sc Makefile
- RAMSTART=512M RAMSIZE=32K RAMDBUG=8K ${SHELL} $< > $@
-
-m5235evb.ld: dbug-cf.sc Makefile
- RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
-
-m5272c3.ld: dbug-cf.sc Makefile
- RAMSTART=0M RAMSIZE=4M RAMDBUG=128K ${SHELL} $< > $@
-
-m5282evb.ld: dbug-cf.sc Makefile
- RAMSTART=0M RAMSIZE=16M RAMDBUG=64K ${SHELL} $< > $@
+$(BDM_SYSOBJS): %.o: %.c bdm-semihost.h bdm-gdb.h
+ $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@
+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
+
+# We need to keep the frame pointer to make sure there's some
+# prologue. Otherwise we get confused with the semihosting reoutine.
+$(patsubst %,bdm-%.o,${BDM_ISRS}) : bdm-isrs.c
+ $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ \
+ -DL_$(patsubst bdm-%.o,%,$@) -fno-omit-frame-pointer
+
+# RAM ROM
+m5208evb := 1024M 16M 0M 2M
+m5213evb := 512M 32K 0M 256K
+m52235evb := 512M 32K 0M 256K
+m5235evb := 0M 16M 0xFFE00000 2M
+m5273c3 := 0M 4M 0xFFE00000 2M
+m5282evb := 0M 16M 0xFFE00000 2M
+m5329evb := 1024M 32M 0M 2M
+m5485evb := 0M 64M 1024M 16M
+
+%-ram.ld : cf.sc Makefile
+ RAM=$(word 1,$($*)) RAM_SIZE=$(word 2,$($*)) ${SHELL} $< >$@
+%-rom.ld : cf.sc Makefile
+ RAM=$(word 1,$($*)) RAM_SIZE=$(word 2,$($*)) \
+ ROM=$(word 3,$($*)) ROM_SIZE=$(word 4,$($*)) ${SHELL} $< >$@
leds.o: ${srcdir}/leds.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
@@ -296,8 +334,10 @@ install:
# install MVME162lx stuff
$(INSTALL_PROGRAM) $(MVME162_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(MVME162_BSP)
$(INSTALL_DATA) ${srcdir}/mvme162.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/mvme162.ld
- # install DBUG stuff
- $(INSTALL_PROGRAM) $(DBUG_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(DBUG_BSP)
+ # install BDM stuff
+ $(INSTALL_PROGRAM) $(BDM_CRT0) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(BDM_CRT0)
+ $(INSTALL_PROGRAM) $(BDM_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(BDM_BSP)
+
$(INSTALL_DATA) ${srcdir}/sbc5204.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/sbc5204.ld
$(INSTALL_DATA) ${srcdir}/sbc5206.ld $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/sbc5206.ld
for script in $(CF_SCRIPTS) ; \
diff --git a/libgloss/m68k/dbug-outbyte.S b/libgloss/m68k/bdm-close.c
index 9d0c864..40ddf9f 100644
--- a/libgloss/m68k/dbug-outbyte.S
+++ b/libgloss/m68k/bdm-close.c
@@ -1,7 +1,7 @@
/*
- * dbug-outbyte.S --
+ * bdm-close.c --
*
- * Copyright (c) 1996 Cygnus Support
+ * Copyright (c) 2006 CodeSourcery Inc
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
@@ -14,21 +14,25 @@
* they apply.
*/
-#include "asm.h"
-
- .text
- .global SYM (outbyte)
- .global SYM (putDebugChar)
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
/*
- * outbyte -- sends a byte out the serial port
- * d0 - contains the byte to be sent
+ * close -- close a file descriptor.
+ * input parameters:
+ * 0 : file descriptor
+ * output parameters:
+ * 0 : result
+ * 1 : errno
*/
- .text
- .align 2
-SYM (putDebugChar): /* symbol name used by m68k-stub */
-SYM (outbyte):
- movel sp@(4),d1
- movl IMM(0x13),d0
- trap IMM(15)
- rts
+
+int close (int fd)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fd;
+ BDM_TRAP (BDM_CLOSE, (uint32_t)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
new file mode 100644
index 0000000..dac6ac4
--- /dev/null
+++ b/libgloss/m68k/bdm-crt0.S
@@ -0,0 +1,85 @@
+/* The interrupt table.
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+ #include "asm.h"
+ .text
+
+ .globl __interrupt_vector
+__interrupt_vector:
+ .long __stack /* 0 */
+ .long __reset /* 1 */
+ .long __access_error /* 2 */
+ .long __address_error /* 3 */
+ .long __illegal_instruction /* 4 */
+ .long __divide_by_zero /* 5 */
+ .long __other_interrupt /* 6 */
+ .long __other_interrupt /* 7 */
+ .long __privilege_violation /* 8 */
+ .long __trace /* 9 */
+ .long __unimplemented_line_a_opcode /* 10 */
+ .long __unimplemented_line_f_opcode /* 11 */
+ .long __non_pc_breakpoint_debug_interrupt /* 12 */
+ .long __pc_breakpoint_debug_interrupt /* 13 */
+ .long __format_error /* 14 */
+ .rept 24 - 15
+ .long __other_interrupt /* [15,24) */
+ .endr
+ .long __spurious_interrupt /* 24 */
+ .rept 32 - 25
+ .long __other_interrupt /* [25,32) */
+ .endr
+ .long __trap0 /* 32 */
+ .long __trap1 /* 33 */
+ .long __trap2 /* 34 */
+ .long __trap3 /* 35 */
+ .long __trap4 /* 36 */
+ .long __trap5 /* 37 */
+ .long __trap6 /* 38 */
+ .long __trap7 /* 39 */
+ .long __trap8 /* 40 */
+ .long __trap9 /* 41 */
+ .long __trap10 /* 42 */
+ .long __trap11 /* 43 */
+ .long __trap12 /* 44 */
+ .long __trap13 /* 45 */
+ .long __trap14 /* 46 */
+ .long __bdm_semihosting /* 47 */
+ .long __fp_branch_unordered /* 48 */
+ .long __fp_inexact_result /* 49 */
+ .long __fp_divide_by_zero /* 50 */
+ .long __fp_underflow /* 51 */
+ .long __fp_operand_error /* 52 */
+ .long __fp_overflow /* 53 */
+ .long __fp_input_not_a_number /* 54 */
+ .long __fp_input_denormalized_number /* 55 */
+ .rept 61 - 56
+ .long __other_interrupt /* [56,61) */
+ .endr
+ .long __unsupported_instruction /* 61 */
+ .rept 64 - 62
+ .long __other_interrupt /* [62,64) */
+ .endr
+ .rept 256-64
+ .long __other_interrupt /* [64,256) */
+ .endr
+
+ .extern __stack
+ .extern __start1
+ .globl __start
+__start:
+ /* Initialize stack */
+ movel IMM(__stack), sp
+ movel IMM(0), fp
+ jmp __start1
diff --git a/libgloss/m68k/bdm-crt1.c b/libgloss/m68k/bdm-crt1.c
new file mode 100644
index 0000000..159e86a
--- /dev/null
+++ b/libgloss/m68k/bdm-crt1.c
@@ -0,0 +1,64 @@
+/* Initialization code for coldfire boards.
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <stdlib.h>
+
+extern const int __interrupt_vector[];
+extern void __reset (void);
+
+extern const char __data_load[] __attribute__ ((aligned (4)));
+extern char __data_start[] __attribute__ ((aligned (4)));
+extern char __bss_start[] __attribute__ ((aligned (4)));
+extern char __end[] __attribute__ ((aligned (4)));
+
+extern void software_init_hook (void) __attribute__ ((weak));
+extern void hardware_init_hook (void) __attribute__ ((weak));
+extern void __INIT_SECTION__ (void);
+extern void __FINI_SECTION__ (void);
+
+extern int main (int, char **, char **);
+
+/* This is called from a tiny assembly stub that just initializes the
+ stack pointer. */
+void __start1 (void)
+{
+ unsigned ix;
+
+ if (hardware_init_hook)
+ hardware_init_hook ();
+
+ /* Set the VBR. */
+ __asm__ __volatile__ ("movec.l %0,%/vbr" :: "r" (__interrupt_vector));
+
+ /* Initialize memory */
+ if (__data_load != __data_start)
+ memcpy (__data_start, __data_load, __bss_start - __data_start);
+ memset (__bss_start, 0, __end - __bss_start);
+
+ if (software_init_hook)
+ software_init_hook ();
+
+ __INIT_SECTION__ ();
+
+ /* I'm not sure how useful it is to have a fini_section in an
+ embedded system. */
+ atexit (__FINI_SECTION__);
+
+ ix = main (0, NULL, NULL);
+ exit (ix);
+
+ while (1)
+ __reset ();
+}
diff --git a/libgloss/m68k/dbug-exit.S b/libgloss/m68k/bdm-exit.c
index 6baae8b..5223bcd 100644
--- a/libgloss/m68k/dbug-exit.S
+++ b/libgloss/m68k/bdm-exit.c
@@ -1,7 +1,7 @@
/*
- * dbug-exit.S --
+ * bdm-exit.c --
*
- * Copyright (c) 1996 Cygnus Support
+ * Copyright (c) 2006 CodeSourcery Inc
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
@@ -14,16 +14,20 @@
* they apply.
*/
-#include "asm.h"
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
- .text
- .global SYM (_exit)
-/*
- * _exit -- Exit from the application. Normally we cause a user trap
- * to return to the ROM monitor for another run.
+extern void __reset (void);
+
+/*
+ * _exit -- Exit from the application.
*/
- .text
- .align 2
-SYM (_exit):
- moveql IMM(0),d0
- trap IMM(15)
+
+void __attribute__ ((noreturn)) _exit (int code)
+{
+ while (1)
+ {
+ BDM_TRAP (BDM_EXIT, code);
+ __reset ();
+ }
+}
diff --git a/libgloss/m68k/bdm-fstat.c b/libgloss/m68k/bdm-fstat.c
new file mode 100644
index 0000000..f93f854
--- /dev/null
+++ b/libgloss/m68k/bdm-fstat.c
@@ -0,0 +1,44 @@
+/*
+ * bdm-fstat.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * fstat -- get file information
+ * input parameters:
+ * 0 : file descriptor
+ * 1 : stat buf ptr
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int fstat (int fd, struct stat *buf)
+{
+ gdb_parambuf_t parameters;
+ struct gdb_stat gbuf;
+ parameters[0] = (uint32_t) fd;
+ parameters[1] = (uint32_t) &gbuf;
+ BDM_TRAP (BDM_FSTAT, (uint32_t)parameters);
+ convert_from_gdb_stat (&gbuf, buf);
+ errno = convert_from_gdb_errno (parameters[1]);
+ return parameters[0];
+}
diff --git a/libgloss/m68k/bdm-gdb.c b/libgloss/m68k/bdm-gdb.c
new file mode 100644
index 0000000..7ad1ea1
--- /dev/null
+++ b/libgloss/m68k/bdm-gdb.c
@@ -0,0 +1,140 @@
+/*
+ * bdm support for GDB's remote fileio protocol
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-gdb.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+gdb_mode_t
+convert_to_gdb_mode_t (mode_t m)
+{
+ gdb_mode_t result = 0;
+ if (m & S_IFREG)
+ result |= GDB_S_IFREG;
+ if (m & S_IFDIR)
+ result |= GDB_S_IFDIR;
+ if (m & S_IRUSR)
+ result |= GDB_S_IRUSR;
+ if (m & S_IWUSR)
+ result |= GDB_S_IWUSR;
+ if (m & S_IXUSR)
+ result |= GDB_S_IXUSR;
+ if (m & S_IRGRP)
+ result |= GDB_S_IRGRP;
+ if (m & S_IWGRP)
+ result |= GDB_S_IWGRP;
+ if (m & S_IXGRP)
+ result |= GDB_S_IXGRP;
+ if (m & S_IROTH)
+ result |= GDB_S_IROTH;
+ if (m & S_IWOTH)
+ result |= GDB_S_IWOTH;
+ if (m & S_IXOTH)
+ result |= GDB_S_IXOTH;
+ return result;
+}
+
+int32_t
+convert_to_gdb_open_flags (int f)
+{
+ int32_t result = 0;
+ if (f & O_RDONLY)
+ result |= GDB_O_RDONLY;
+ if (f & O_WRONLY)
+ result |= GDB_O_WRONLY;
+ if (f & O_RDWR)
+ result |= GDB_O_RDWR;
+ if (f & O_APPEND)
+ result |= GDB_O_APPEND;
+ if (f & O_CREAT)
+ result |= GDB_O_CREAT;
+ if (f & O_TRUNC)
+ result |= GDB_O_TRUNC;
+ if (f & O_EXCL)
+ result |= GDB_O_EXCL;
+ return result;
+}
+
+int32_t
+convert_to_gdb_lseek_flags (int f)
+{
+ if (f == SEEK_CUR)
+ return GDB_SEEK_CUR;
+ else if (f == SEEK_END)
+ return GDB_SEEK_END;
+ else
+ return GDB_SEEK_SET;
+}
+
+void
+convert_from_gdb_stat (const struct gdb_stat *gs,
+ struct stat *s)
+{
+ s->st_dev = gs->st_dev;
+ s->st_ino = gs->st_ino;
+ s->st_mode = gs->st_mode;
+ s->st_nlink = gs->st_nlink;
+ s->st_uid = gs->st_uid;
+ s->st_gid = gs->st_gid;
+ s->st_rdev = gs->st_rdev;
+ s->st_size = gs->st_size;
+ s->st_blksize = gs->st_blksize;
+ s->st_blocks = gs->st_blocks;
+ s->st_atime = gs->st_atime;
+ s->st_mtime = gs->st_mtime;
+ s->st_ctime = gs->st_ctime;
+}
+
+void
+convert_from_gdb_timeval (const struct gdb_timeval *gt,
+ struct timeval *t)
+{
+ t->tv_sec = gt->tv_sec;
+ t->tv_usec = gt->tv_usec;
+}
+
+int
+convert_from_gdb_errno (int32_t err)
+{
+ switch (err)
+ {
+ case 0: return 0;
+ case GDB_EPERM: return EPERM;
+ case GDB_ENOENT: return ENOENT;
+ case GDB_EINTR: return EINTR;
+ case GDB_EBADF: return EBADF;
+ case GDB_EACCES: return EACCES;
+ case GDB_EFAULT: return EFAULT;
+ case GDB_EBUSY: return EBUSY;
+ case GDB_EEXIST: return EEXIST;
+ case GDB_ENODEV: return ENODEV;
+ case GDB_ENOTDIR: return ENOTDIR;
+ case GDB_EISDIR: return EISDIR;
+ case GDB_EINVAL: return EINVAL;
+ case GDB_ENFILE: return ENFILE;
+ case GDB_EMFILE: return EMFILE;
+ case GDB_EFBIG: return EFBIG;
+ case GDB_ENOSPC: return ENOSPC;
+ case GDB_ESPIPE: return ESPIPE;
+ case GDB_EROFS: return EROFS;
+ case GDB_ENAMETOOLONG: return ENAMETOOLONG;
+ case GDB_EUNKNOWN:
+ default:
+ return EIO;
+ }
+}
+
diff --git a/libgloss/m68k/bdm-gdb.h b/libgloss/m68k/bdm-gdb.h
new file mode 100644
index 0000000..a97479c
--- /dev/null
+++ b/libgloss/m68k/bdm-gdb.h
@@ -0,0 +1,128 @@
+/*
+ * bdm support for GDB's remote fileio protocol
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+
+/* Protocol specific representation of datatypes, as specified in D.9.11
+ * of the GDB manual.
+ * Note that since the m68k is big-endian, we can use native
+ * representations of integer datatypes in structured datatypes. */
+
+typedef uint32_t gdb_mode_t;
+typedef uint32_t gdb_time_t;
+
+struct gdb_stat {
+ uint32_t st_dev; /* device */
+ uint32_t st_ino; /* inode */
+ gdb_mode_t st_mode; /* protection */
+ uint32_t st_nlink; /* number of hard links */
+ uint32_t st_uid; /* user ID of owner */
+ uint32_t st_gid; /* group ID of owner */
+ uint32_t st_rdev; /* device type (if inode device) */
+ uint64_t st_size; /* total size, in bytes */
+ uint64_t st_blksize; /* blocksize for filesystem I/O */
+ uint64_t st_blocks; /* number of blocks allocated */
+ gdb_time_t st_atime; /* time of last access */
+ gdb_time_t st_mtime; /* time of last modification */
+ gdb_time_t st_ctime; /* time of last change */
+};
+
+struct gdb_timeval {
+ gdb_time_t tv_sec; /* second */
+ uint64_t tv_usec; /* microsecond */
+};
+
+
+/* Parameters are passed between the library and the debugging stub
+ * in a fixed-size buffer.
+ */
+
+typedef uint32_t gdb_parambuf_t[4];
+
+
+/* open flags */
+
+#define GDB_O_RDONLY 0x0
+#define GDB_O_WRONLY 0x1
+#define GDB_O_RDWR 0x2
+#define GDB_O_APPEND 0x8
+#define GDB_O_CREAT 0x200
+#define GDB_O_TRUNC 0x400
+#define GDB_O_EXCL 0x800
+
+/* mode_t values */
+
+#define GDB_S_IFREG 0100000
+#define GDB_S_IFDIR 040000
+#define GDB_S_IRUSR 0400
+#define GDB_S_IWUSR 0200
+#define GDB_S_IXUSR 0100
+#define GDB_S_IRGRP 040
+#define GDB_S_IWGRP 020
+#define GDB_S_IXGRP 010
+#define GDB_S_IROTH 04
+#define GDB_S_IWOTH 02
+#define GDB_S_IXOTH 01
+
+/* errno values */
+
+#define GDB_EPERM 1
+#define GDB_ENOENT 2
+#define GDB_EINTR 4
+#define GDB_EBADF 9
+#define GDB_EACCES 13
+#define GDB_EFAULT 14
+#define GDB_EBUSY 16
+#define GDB_EEXIST 17
+#define GDB_ENODEV 19
+#define GDB_ENOTDIR 20
+#define GDB_EISDIR 21
+#define GDB_EINVAL 22
+#define GDB_ENFILE 23
+#define GDB_EMFILE 24
+#define GDB_EFBIG 27
+#define GDB_ENOSPC 28
+#define GDB_ESPIPE 29
+#define GDB_EROFS 30
+#define GDB_ENAMETOOLONG 91
+#define GDB_EUNKNOWN 9999
+
+/* lseek flags */
+
+#define GDB_SEEK_SET 0
+#define GDB_SEEK_CUR 1
+#define GDB_SEEK_END 2
+
+
+/* conversion functions */
+
+extern gdb_mode_t convert_to_gdb_mode_t (mode_t m);
+extern int32_t convert_to_gdb_open_flags (int f);
+extern int32_t convert_to_gdb_lseek_flags (int f);
+
+extern void convert_from_gdb_stat (const struct gdb_stat *gs,
+ struct stat *s);
+extern void convert_from_gdb_timeval (const struct gdb_timeval *gt,
+ struct timeval *t);
+extern int convert_from_gdb_errno (int32_t err);
+
+
+
+
+
diff --git a/libgloss/m68k/bdm-gettimeofday.c b/libgloss/m68k/bdm-gettimeofday.c
new file mode 100644
index 0000000..1549542
--- /dev/null
+++ b/libgloss/m68k/bdm-gettimeofday.c
@@ -0,0 +1,47 @@
+/*
+ * bdm-gettimeofday.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/time.h>
+#include <errno.h>
+
+/*
+ * gettimeofday -- get the current time
+ * input parameters:
+ * 0 : timeval ptr
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+ gdb_parambuf_t parameters;
+ struct gdb_timeval gtv;
+ if (!tv)
+ return 0;
+ if (tz)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ parameters[0] = (uint32_t) &gtv;
+ BDM_TRAP (BDM_GETTIMEOFDAY, (uint32_t)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
new file mode 100644
index 0000000..1da79bc
--- /dev/null
+++ b/libgloss/m68k/bdm-isatty.c
@@ -0,0 +1,38 @@
+/*
+ * bdm-isatty.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * isatty -- check if fd is a terminal
+ * input parameters:
+ * 0 : file descriptor
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int isatty (int fd)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fd;
+ BDM_TRAP (BDM_ISATTY, (uint32_t)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
new file mode 100644
index 0000000..7ee9fba
--- /dev/null
+++ b/libgloss/m68k/bdm-isrs.c
@@ -0,0 +1,192 @@
+/*
+ * bdm-isv.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+/* This file contains default interrupt handlers code for the
+ interrupt vector. All but one of the interrupts are user
+ replaceable.
+
+ 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. */
+
+
+/* Each ISR is a loop containing a halt instruction */
+#define ISR_DEFINE(NAME) \
+void __attribute__((interrupt_handler)) NAME (void) \
+{ \
+ while (1) \
+ __asm__ __volatile__ ("halt" ::: "memory"); \
+} \
+struct eat_trailing_semicolon
+
+#if defined (L_other_interrupt)
+ISR_DEFINE (__other_interrupt);
+#endif
+
+#if defined (L_reset)
+ISR_DEFINE (__reset);
+#endif
+
+#if defined (L_access_error)
+ISR_DEFINE (__access_error);
+#endif
+
+#if defined (L_address_error)
+ISR_DEFINE (__address_error);
+#endif
+
+#if defined (L_illegal_instruction)
+ISR_DEFINE (__illegal_instruction);
+#endif
+
+#if defined (L_divide_by_zero)
+ISR_DEFINE (__divide_by_zero);
+#endif
+
+#if defined (L_privilege_violation)
+ISR_DEFINE (__privilege_violation);
+#endif
+
+#if defined (L_trace)
+ISR_DEFINE (__trace);
+#endif
+
+#if defined (L_unimplemented_line_a_opcode)
+ISR_DEFINE (__unimplemented_line_a_opcode);
+#endif
+
+#if defined (L_unimplemented_line_f_opcode)
+ISR_DEFINE (__unimplemented_line_f_opcode);
+#endif
+
+#if defined (L_non_pc_breakpoint_debug_interrupt)
+ISR_DEFINE (__non_pc_breakpoint_debug_interrupt);
+#endif
+
+#if defined (L_pc_breakpoint_debug_interrupt)
+ISR_DEFINE (__pc_breakpoint_debug_interrupt);
+#endif
+
+#if defined (L_format_error)
+ISR_DEFINE (__format_error);
+#endif
+
+#if defined (L_spurious_interrupt)
+ISR_DEFINE (__spurious_interrupt);
+#endif
+
+#if defined (L_trap0)
+ISR_DEFINE (__trap0);
+#endif
+
+#if defined (L_trap1)
+ISR_DEFINE (__trap1);
+#endif
+
+#if defined (L_trap2)
+ISR_DEFINE (__trap2);
+#endif
+
+#if defined (L_trap3)
+ISR_DEFINE (__trap3);
+#endif
+
+#if defined (L_trap4)
+ISR_DEFINE (__trap4);
+#endif
+
+#if defined (L_trap5)
+ISR_DEFINE (__trap5);
+#endif
+
+#if defined (L_trap6)
+ISR_DEFINE (__trap6);
+#endif
+
+#if defined (L_trap7)
+ISR_DEFINE (__trap7);
+#endif
+
+#if defined (L_trap8)
+ISR_DEFINE (__trap8);
+#endif
+
+#if defined (L_trap9)
+ISR_DEFINE (__trap9);
+#endif
+
+#if defined (L_trap10)
+ISR_DEFINE (__trap10);
+#endif
+
+#if defined (L_trap11)
+ISR_DEFINE (__trap11);
+#endif
+
+#if defined (L_trap12)
+ISR_DEFINE (__trap12);
+#endif
+
+#if defined (L_trap13)
+ISR_DEFINE (__trap13);
+#endif
+
+#if defined (L_trap14)
+ISR_DEFINE (__trap14);
+#endif
+
+#if defined (L_trap15)
+ISR_DEFINE (__trap15);
+#endif
+
+#if defined (L_fp_branch_unordered)
+ISR_DEFINE (__fp_branch_unordered);
+#endif
+
+#if defined (L_fp_inexact_result)
+ISR_DEFINE (__fp_inexact_result);
+#endif
+
+#if defined (L_fp_divide_by_zero)
+ISR_DEFINE (__fp_divide_by_zero);
+#endif
+
+#if defined (L_fp_underflow)
+ISR_DEFINE (__fp_underflow);
+#endif
+
+#if defined (L_fp_operand_error)
+ISR_DEFINE (__fp_operand_error);
+#endif
+
+#if defined (L_fp_overflow)
+ISR_DEFINE (__fp_overflow);
+#endif
+
+#if defined (L_fp_input_not_a_number)
+ISR_DEFINE (__fp_input_not_a_number);
+#endif
+
+#if defined (L_fp_input_denormalized_number)
+ISR_DEFINE (__fp_input_denormalized_number);
+#endif
+
+#if defined (L_unsupported_instruction)
+ISR_DEFINE (__unsupported_instruction);
+#endif
diff --git a/libgloss/m68k/bdm-lseek.c b/libgloss/m68k/bdm-lseek.c
new file mode 100644
index 0000000..b8308cb
--- /dev/null
+++ b/libgloss/m68k/bdm-lseek.c
@@ -0,0 +1,46 @@
+/*
+ * bdm-lseek.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * lseek -- reposition a file descriptor
+ * input parameters:
+ * 0 : file descriptor
+ * 1 : high word of offset
+ * 2 : low word of offset
+ * 3 : seek flag
+ * output parameters:
+ * 0 : high word of result
+ * 1 : low word of result
+ * 2 : errno
+ */
+
+off_t lseek (int fd, off_t offset, int whence)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fd;
+ 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);
+ 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
new file mode 100644
index 0000000..878cff8
--- /dev/null
+++ b/libgloss/m68k/bdm-open.c
@@ -0,0 +1,56 @@
+/*
+ * bdm-open.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * open -- Open a file.
+ * input parameters:
+ * 0 : fname ptr
+ * 1 : fname length
+ * 2 : flags
+ * 3 : mode
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int open (const char *fname, int flags, ...)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fname;
+ parameters[1] = strlen (fname) + 1;
+ parameters[2] = convert_to_gdb_open_flags (flags);
+ if (flags & O_CREAT)
+ {
+ va_list ap;
+ va_start (ap, flags);
+ parameters[3] = convert_to_gdb_mode_t (va_arg (ap, mode_t));
+ va_end (ap);
+ }
+ else
+ parameters[3] = 0;
+ BDM_TRAP (BDM_OPEN, (uint32_t)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
new file mode 100644
index 0000000..441a7d2
--- /dev/null
+++ b/libgloss/m68k/bdm-read.c
@@ -0,0 +1,42 @@
+/*
+ * bdm-read.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * read -- read from a file descriptor
+ * input parameters:
+ * 0 : file descriptor
+ * 1 : buf ptr
+ * 2 : count
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+ssize_t read (int fd, void *buf, size_t count)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fd;
+ parameters[1] = (uint32_t) buf;
+ parameters[2] = (uint32_t) count;
+ BDM_TRAP (BDM_READ, (uint32_t)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
new file mode 100644
index 0000000..3e0acf3
--- /dev/null
+++ b/libgloss/m68k/bdm-rename.c
@@ -0,0 +1,45 @@
+/*
+ * bdm-rename.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * rename -- rename a file
+ * input parameters:
+ * 0 : oldname ptr
+ * 1 : oldname length
+ * 2 : newname ptr
+ * 3 : newname length
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int _rename (const char *oldpath, const char *newpath)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) oldpath;
+ 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);
+ errno = convert_from_gdb_errno (parameters[1]);
+ return parameters[0];
+}
diff --git a/libgloss/m68k/dbug-inbyte.S b/libgloss/m68k/bdm-semihost.c
index 128c260..c0608e1 100644
--- a/libgloss/m68k/dbug-inbyte.S
+++ b/libgloss/m68k/bdm-semihost.c
@@ -1,7 +1,7 @@
/*
- * dbug-inbyte.S --
+ * bdm-semihost.c --
*
- * Copyright (c) 1996 Cygnus Support
+ * Copyright (c) 2006 CodeSourcery Inc
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
@@ -14,21 +14,12 @@
* they apply.
*/
-#include "asm.h"
-
- .text
- .global SYM (inbyte)
- .global SYM (getDebugChar)
-
-/*
- * inbyte -- get a byte from the serial port
- * d0 - contains the byte read in
- */
- .text
- .align 2
-SYM (getDebugChar): /* symbol name used by m68k-stub */
-SYM (inbyte):
- movel IMM(0x10),d0
- trap IMM(15)
- movel d1,d0
- rts
+/* 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. */
+
+void __attribute__ ((interrupt_handler)) __bdm_semihosting (void)
+{
+ __asm__ __volatile__ ("halt" ::: "memory");
+}
diff --git a/libgloss/m68k/bdm-semihost.h b/libgloss/m68k/bdm-semihost.h
new file mode 100644
index 0000000..4d6e2b9
--- /dev/null
+++ b/libgloss/m68k/bdm-semihost.h
@@ -0,0 +1,57 @@
+/*
+ * bdm semihosting support.
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * 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
+#define BDM_PUTCHAR 1 /* Obsolete */
+#define BDM_OPEN 2
+#define BDM_CLOSE 3
+#define BDM_READ 4
+#define BDM_WRITE 5
+#define BDM_LSEEK 6
+#define BDM_RENAME 7
+#define BDM_UNLINK 8
+#define BDM_STAT 9
+#define BDM_FSTAT 10
+#define BDM_GETTIMEOFDAY 11
+#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")
+
diff --git a/libgloss/m68k/bdm-stat.c b/libgloss/m68k/bdm-stat.c
new file mode 100644
index 0000000..536aeec
--- /dev/null
+++ b/libgloss/m68k/bdm-stat.c
@@ -0,0 +1,48 @@
+/*
+ * bdm-stat.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * stat -- get file information
+ * input parameters:
+ * 0 : filename ptr
+ * 1 : filename length
+ * 2 : stat buf ptr
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+
+int stat (const char *filename, struct stat *buf)
+{
+ gdb_parambuf_t parameters;
+ struct gdb_stat gbuf;
+ parameters[0] = (uint32_t) filename;
+ parameters[1] = (uint32_t) strlen (filename) + 1;
+ parameters[2] = (uint32_t) &gbuf;
+ BDM_TRAP (BDM_STAT, (uint32_t)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
new file mode 100644
index 0000000..75a82e2
--- /dev/null
+++ b/libgloss/m68k/bdm-system.c
@@ -0,0 +1,55 @@
+/*
+ * bdm-system.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/wait.h>
+/*
+ * system: execute command on (remote) host
+ * input parameters:
+ * 0 : command ptr
+ * 1 : command length
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+int _system (const char *command)
+{
+ int e;
+ gdb_parambuf_t parameters;
+
+ parameters[0] = (uint32_t) command;
+ parameters[1] = command ? (uint32_t) strlen (command) + 1 : 0;
+ BDM_TRAP (BDM_SYSTEM, (uint32_t)parameters);
+ errno = convert_from_gdb_errno (parameters[1]);
+ e = parameters[0];
+ if (e >= 0 && command)
+ {
+ /* We have to convert e, an exit status to the encoded status of
+ the command. To avoid hard coding the exit status, we simply
+ loop until we find the right position. */
+ int exit_code;
+
+ for (exit_code = e; e && WEXITSTATUS (e) != exit_code; e <<= 1)
+ continue;
+ }
+
+ return e;
+}
diff --git a/libgloss/m68k/bdm-time.c b/libgloss/m68k/bdm-time.c
new file mode 100644
index 0000000..02fbfab
--- /dev/null
+++ b/libgloss/m68k/bdm-time.c
@@ -0,0 +1,21 @@
+#include <sys/time.h>
+
+/*
+ * time -- get the current time
+ * input parameters:
+ * 0 : timeval ptr
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+time_t time (time_t *t)
+{
+ struct timeval tv;
+
+ if (gettimeofday (&tv, NULL))
+ return -1;
+ if (t)
+ *t = tv.tv_sec;
+ return tv.tv_sec;
+}
diff --git a/libgloss/m68k/bdm-unlink.c b/libgloss/m68k/bdm-unlink.c
new file mode 100644
index 0000000..05098ae
--- /dev/null
+++ b/libgloss/m68k/bdm-unlink.c
@@ -0,0 +1,41 @@
+/*
+ * bdm-unlink.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * unlink -- unlink (delete) a file
+ * input parameters:
+ * 0 : filename ptr
+ * 1 : filename length
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+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);
+ errno = convert_from_gdb_errno (parameters[1]);
+ return parameters[0];
+}
diff --git a/libgloss/m68k/bdm-write.c b/libgloss/m68k/bdm-write.c
new file mode 100644
index 0000000..0280dcd
--- /dev/null
+++ b/libgloss/m68k/bdm-write.c
@@ -0,0 +1,42 @@
+/*
+ * bdm-write.c --
+ *
+ * Copyright (c) 2006 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include "bdm-semihost.h"
+#include "bdm-gdb.h"
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * write -- write to a file descriptor
+ * input parameters:
+ * 0 : file descriptor
+ * 1 : buf ptr
+ * 2 : count
+ * output parameters:
+ * 0 : result
+ * 1 : errno
+ */
+
+ssize_t write (int fd, const void *buf, size_t count)
+{
+ gdb_parambuf_t parameters;
+ parameters[0] = (uint32_t) fd;
+ parameters[1] = (uint32_t) buf;
+ parameters[2] = (uint32_t) count;
+ BDM_TRAP (BDM_WRITE, (uint32_t)parameters);
+ errno = convert_from_gdb_errno (parameters[1]);
+ return parameters[0];
+}
diff --git a/libgloss/m68k/dbug-cf.sc b/libgloss/m68k/cf.sc
index 0342ed1..b19dce4 100644
--- a/libgloss/m68k/dbug-cf.sc
+++ b/libgloss/m68k/cf.sc
@@ -1,46 +1,34 @@
# a linker script template.
-# RAMSTART - start of board's ram
-# RAMSIZE - size of board's ram
-# RAMDBUG - bytes at start of RAM for DBUG use
+# RAM - start of board's ram
+# RAM_SIZE - size of board's ram
+# ROM - start of board's rom
+# ROM_SIZE - size of board's rom
+
+test -z "${ROM:+1}" && NOROM=1
cat <<EOF
-STARTUP(crt0.o)
+STARTUP(bdm-crt0.o)
OUTPUT_ARCH(m68k)
-/* DBUG loads SREC files */
-/*OUTPUT_FORMAT(srec)*/
-ENTRY(start)
+ENTRY(__start)
SEARCH_DIR(.)
-GROUP(-ldbug -lc -lgcc -ldbug)
+GROUP(-lc -lbdm)
__DYNAMIC = 0;
MEMORY
{
- ram (rwx) : ORIGIN = ${RAMSTART} + ${RAMDBUG:-0},
- LENGTH = ${RAMSIZE} - ${RAMDBUG:-0}
+ ${ROM:+rom (rx) : ORIGIN = ${ROM}, LENGTH = ${ROM_SIZE}}
+ ram (rwx) : ORIGIN = ${RAM}, LENGTH = ${RAM_SIZE}
}
-PROVIDE (__stack = ${RAMSTART} + ${RAMSIZE});
-
-/*
- * Initalize some symbols to be zero so we can reference them in the
- * crt0 without core dumping. These functions are all optional, but
- * we do this so we can have our crt0 always use them if they exist.
- * This is so BSPs work better when using the crt0 installed gcc.
- * We have to initalize them twice, so we cover a.out (which prepends
- * an underscore) and coff object file formats.
- */
-PROVIDE (hardware_init_hook = 0);
-PROVIDE (_hardware_init_hook = 0);
-PROVIDE (software_init_hook = 0);
-PROVIDE (_software_init_hook = 0);
-/*
- * stick everything in ram (of course)
- */
+/* Place the stack at the end of memory, unless specified otherwise. */
+PROVIDE (__stack = ${RAM} + ${RAM_SIZE});
+
SECTIONS
{
.text :
{
CREATE_OBJECT_SYMBOLS
+ bdm-crt0.o(.text)
*(.text .text.*)
. = ALIGN(0x4);
@@ -48,11 +36,11 @@ SECTIONS
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
- KEEP (*(.ctors))
+ KEEP (*crtend.o(.ctors))
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
- KEEP (*(.dtors))
+ KEEP (*crtend.o(.dtors))
*(.rodata .rodata.*)
@@ -76,28 +64,33 @@ SECTIONS
SHORT (0x4e5e) /* unlk %fp */
SHORT (0x4e75) /* rts */
- _etext = .;
*(.lit)
- } > ram
+
+ . = ALIGN(4);
+ _etext = .;
+ } >${ROM:+rom}${NOROM:+ram}
.data :
{
+ __data_load = LOADADDR (.data);
+ __data_start = .;
*(.got.plt) *(.got)
*(.shdata)
*(.data .data.*)
+ . = ALIGN (4);
_edata = .;
- } > ram
+ } >ram ${ROM:+AT>rom}
.bss :
{
- . = ALIGN(0x4);
__bss_start = . ;
*(.shbss)
*(.bss .bss.*)
*(COMMON)
- _end = ALIGN (0x8);
+ . = ALIGN (8);
+ _end = .;
__end = _end;
- } > ram
+ } >ram ${ROM:+AT>rom}
.stab 0 (NOLOAD) :
{
diff --git a/libgloss/m68k/crt0.S b/libgloss/m68k/crt0.S
index 1aa0dd6..4c91628 100644
--- a/libgloss/m68k/crt0.S
+++ b/libgloss/m68k/crt0.S
@@ -52,11 +52,17 @@ SYM (environ):
.extern _end
/*
- * set things up so the application will run. This *must* be called start.
+ * Set things up so the application will run. For historical reasons
+ * this is called 'start'. We set things up to provide '_start'
+ * as with other systems, but also provide a weak alias called
+ * 'start' for compatibility with existing linker scripts.
*/
.global SYM (start)
+ .weak SYM (start)
+ .set SYM (start),SYM(_start)
-SYM (start):
+ .global SYM (_start)
+SYM (_start):
/*
* put any hardware init code here
*/