2006-12-11 Kazu Hirata <kazu@codesourcery.com>

Merge from newlib-csl-20060320-branch:
	2006-12-01  Nathan Sidwell  <nathan@codesourcery.com>
		    Kazu Hirata  <kazu@codesourcery.com>

	* m68k/Makefile.in (CF_ISRS): Use addprefix.

	2006-11-01 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in (CFLAGS): Do not clear.  Add to all compilations.
	(ARFLAGS): Remove commented out definition.


	* m68k/configure.in (DO) Set to list of target cpu families.
	* m68k/configure: Rebuilt.
	* m68k/Makefile.in (DO): New.
	(UNHOSTED_BSP, UNHOSTED_OBJS, HOSTED_BSP, HOSTED_OBJS): Move
	later.
	(m5208evb, m5213evb, m52235evb, m5235evb, m5273c3, m5275evb,
	m5282evb, m5329evb, m5485evb): Move earlier.
	(all): Add all_$DO dependencies.
	(all_cf, all_m68k): New targets, depend on cf & m68k bsps as
	appropriate.
	(m%-ram.ld, m%-rom.ld, m%-ram-hosted.ld, m%-rom-hosted.ld): Add
	'm' prefix.
	(install): Add install_$DO dependencies.
	(install_cf, install_m68k): New targets.  Perform cf and m68k
	installs as appropriate.
	(install_io): New, install the io libraries.


	2006-10-23 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in (CF_CRT0): Rename to CF_CRT0S, separate hosted
	& unhosted versions.
	(CF_OBJS): Add cf-isv.o.
	(CF_SOURCES): Add cf-isv.S.
	(cf-hosted-crt0.o, cf-unhosted-crt0.o): New targets.
	* m68k/cf-isv.S: New, broken out of ...
	* m68k/cf-crt0.S: ... here.  Add HOSTED & UNHOSTED differences.
	* m68k/cf-crt1.c (__start1): Add heap_limit argument.
	(__heap_limit): Define.
	* m68k/cf-sbrk.c (__heap_limit): Declare.
	(sbrk): Adjust for __heap_limit.
	* m68k/cf.sc: Use different crt0's for hosted & unhosted.
	Install a separate isv.o file.
	* m68k/io.h (HOSTED_PUTCHAR): Replace with ...
	(HOSTED_INIT_SIM): ... this.


	2006-10-20 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in (CF_BOARDS): Add m5275evb.
	(m5275evb): New board.


	2006-10-20 Vladimir Prus <vladimir@codesourcery.com>

	* m68k/cf.sc: Add linkonce sections and
	DWARF sections.


	2006-10-07 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in: Adjust Coldfire rules.
	(BDM_CRT0, BDM_BSP, BDM_OBJS, BDM_ISRS): Rename	to ...
	(CF_CRT0, CF_BSP, CF_OBJS, CF_ISRS): ... here.  Adjust.
	(BDM_OTHER_OBJS): Remove.
	(BDM_SYSOBJS): Rename to ...
	(UNHOSTED_OBJS): ... here.  Adjust.
	(UNHOSTED_BSP, HOSTED_OBJS, HOSTED_BSP): New.
	(CF_HOSTED_SCRIPTS): New.
	(CF_SCRIPTS, CF_SOURCES): Adjust.
	* m68k/cf.sc: Add IO library variable.
	* m68k/bdm-crt0.S, m68k/bdm-crt1.c, m68k/bdm-isrs.c,
	m68k/bdm-sbrk.c, m68k/bdm-semihost.S: Rename to ...
	* m68k/cf-crt0.S, m68k/cf-crt1.c, m68k/cf-isrs.c, m68k/cf-sbrk.c,
	m68k/cf-hosted.S: ... here.
	* m68k/cf-exit.c: New.
	* m68k/bdm-gdb.h, m68k/bdm-semihost.h: Merge into ...
	* m68k/io.h: ... here.  Add unhosted support.  Adjust conversion
	function names.
	* m68k/bdm-gdb.c: Rename to ...
	* m68k/io-gdb.c: ... here.  Adjust names of conversion functions.
	* m68k/bdm-close.c, m68k/bdm-exit.c, m68k/bdm-fstat.c,
	m68k/bdm-gettimeofday.c, m68k/bdm-isatty.c, m68k/bdm-lseek.c,
	m68k/bdm-open.c, m68k/bdm-read.c, m68k/bdm-rename.c,
	m68k/bdm-stat.c, m68k/bdm-system.c, m68k/bdm-time.c,
	m68k/bdm-unlink.c, m68k/bdm-write.c: Rename to ...
	* m68k/io-close.c, m68k/io-exit.c, m68k/io-fstat.c,
	m68k/io-gettimeofday.c, m68k/io-isatty.c, m68k/io-lseek.c,
	m68k/io-open.c, m68k/io-read.c, m68k/io-rename.c, m68k/io-stat.c,
	m68k/io-system.c, m68k/io-time.c, m68k/io-unlink.c,
	m68k/io-write.c: ... here.  Include io.h. Adjust for hosted &
	unhosted libraries.  Adjust names of gdb conversion functions.


	2006-09-29 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/bdm-semihost.S: Add more comments. Make instruction weirder.

	2006-09-22 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/bdm-crt1.c (hardware_init_hook): Use #defines for CACR bits.

	2006-09-18 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in: Don't force a frame pointer on the ISRs.
	* m68k/bdm-crt1.c (__start1): Don't set the VBR here.
	(hardeare_init_hook): Define weakly.  Set VBR here, enable caching
	if supported.


	* 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>

	* m68k/Makefile.in (BDM_OTHER_OBJS): Remove sbrk.o.
	(BDM_SYSOBJS): Add bdm-sbrk.o.
	* m68k/bdm-sbrk.c: New.


	2006-09-06 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/Makefile.in (CF_SOURCES): New.
	(install): Install them.


	2006-09-01 Nathan Sidwell <nathan@codesourcery.com>

	* m68k/cf.sc: Add .jcr section to .text.
This commit is contained in:
Jeff Johnston 2006-12-11 19:58:01 +00:00
parent 7dfad3a0c6
commit 12cb181da7
31 changed files with 1958 additions and 283 deletions

View File

@ -1,3 +1,147 @@
2006-12-11 Kazu Hirata <kazu@codesourcery.com>
Merge from newlib-csl-20060320-branch:
2006-12-01 Nathan Sidwell <nathan@codesourcery.com>
Kazu Hirata <kazu@codesourcery.com>
* m68k/Makefile.in (CF_ISRS): Use addprefix.
2006-11-01 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in (CFLAGS): Do not clear. Add to all compilations.
(ARFLAGS): Remove commented out definition.
* m68k/configure.in (DO) Set to list of target cpu families.
* m68k/configure: Rebuilt.
* m68k/Makefile.in (DO): New.
(UNHOSTED_BSP, UNHOSTED_OBJS, HOSTED_BSP, HOSTED_OBJS): Move
later.
(m5208evb, m5213evb, m52235evb, m5235evb, m5273c3, m5275evb,
m5282evb, m5329evb, m5485evb): Move earlier.
(all): Add all_$DO dependencies.
(all_cf, all_m68k): New targets, depend on cf & m68k bsps as
appropriate.
(m%-ram.ld, m%-rom.ld, m%-ram-hosted.ld, m%-rom-hosted.ld): Add
'm' prefix.
(install): Add install_$DO dependencies.
(install_cf, install_m68k): New targets. Perform cf and m68k
installs as appropriate.
(install_io): New, install the io libraries.
2006-10-23 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in (CF_CRT0): Rename to CF_CRT0S, separate hosted
& unhosted versions.
(CF_OBJS): Add cf-isv.o.
(CF_SOURCES): Add cf-isv.S.
(cf-hosted-crt0.o, cf-unhosted-crt0.o): New targets.
* m68k/cf-isv.S: New, broken out of ...
* m68k/cf-crt0.S: ... here. Add HOSTED & UNHOSTED differences.
* m68k/cf-crt1.c (__start1): Add heap_limit argument.
(__heap_limit): Define.
* m68k/cf-sbrk.c (__heap_limit): Declare.
(sbrk): Adjust for __heap_limit.
* m68k/cf.sc: Use different crt0's for hosted & unhosted.
Install a separate isv.o file.
* m68k/io.h (HOSTED_PUTCHAR): Replace with ...
(HOSTED_INIT_SIM): ... this.
2006-10-20 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in (CF_BOARDS): Add m5275evb.
(m5275evb): New board.
2006-10-20 Vladimir Prus <vladimir@codesourcery.com>
* m68k/cf.sc: Add linkonce sections and
DWARF sections.
2006-10-07 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in: Adjust Coldfire rules.
(BDM_CRT0, BDM_BSP, BDM_OBJS, BDM_ISRS): Rename to ...
(CF_CRT0, CF_BSP, CF_OBJS, CF_ISRS): ... here. Adjust.
(BDM_OTHER_OBJS): Remove.
(BDM_SYSOBJS): Rename to ...
(UNHOSTED_OBJS): ... here. Adjust.
(UNHOSTED_BSP, HOSTED_OBJS, HOSTED_BSP): New.
(CF_HOSTED_SCRIPTS): New.
(CF_SCRIPTS, CF_SOURCES): Adjust.
* m68k/cf.sc: Add IO library variable.
* m68k/bdm-crt0.S, m68k/bdm-crt1.c, m68k/bdm-isrs.c,
m68k/bdm-sbrk.c, m68k/bdm-semihost.S: Rename to ...
* m68k/cf-crt0.S, m68k/cf-crt1.c, m68k/cf-isrs.c, m68k/cf-sbrk.c,
m68k/cf-hosted.S: ... here.
* m68k/cf-exit.c: New.
* m68k/bdm-gdb.h, m68k/bdm-semihost.h: Merge into ...
* m68k/io.h: ... here. Add unhosted support. Adjust conversion
function names.
* m68k/bdm-gdb.c: Rename to ...
* m68k/io-gdb.c: ... here. Adjust names of conversion functions.
* m68k/bdm-close.c, m68k/bdm-exit.c, m68k/bdm-fstat.c,
m68k/bdm-gettimeofday.c, m68k/bdm-isatty.c, m68k/bdm-lseek.c,
m68k/bdm-open.c, m68k/bdm-read.c, m68k/bdm-rename.c,
m68k/bdm-stat.c, m68k/bdm-system.c, m68k/bdm-time.c,
m68k/bdm-unlink.c, m68k/bdm-write.c: Rename to ...
* m68k/io-close.c, m68k/io-exit.c, m68k/io-fstat.c,
m68k/io-gettimeofday.c, m68k/io-isatty.c, m68k/io-lseek.c,
m68k/io-open.c, m68k/io-read.c, m68k/io-rename.c, m68k/io-stat.c,
m68k/io-system.c, m68k/io-time.c, m68k/io-unlink.c,
m68k/io-write.c: ... here. Include io.h. Adjust for hosted &
unhosted libraries. Adjust names of gdb conversion functions.
2006-09-29 Nathan Sidwell <nathan@codesourcery.com>
* m68k/bdm-semihost.S: Add more comments. Make instruction weirder.
2006-09-22 Nathan Sidwell <nathan@codesourcery.com>
* m68k/bdm-crt1.c (hardware_init_hook): Use #defines for CACR bits.
2006-09-18 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in: Don't force a frame pointer on the ISRs.
* m68k/bdm-crt1.c (__start1): Don't set the VBR here.
(hardeare_init_hook): Define weakly. Set VBR here, enable caching
if supported.
* 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>
* m68k/Makefile.in (BDM_OTHER_OBJS): Remove sbrk.o.
(BDM_SYSOBJS): Add bdm-sbrk.o.
* m68k/bdm-sbrk.c: New.
2006-09-06 Nathan Sidwell <nathan@codesourcery.com>
* m68k/Makefile.in (CF_SOURCES): New.
(install): Install them.
2006-09-01 Nathan Sidwell <nathan@codesourcery.com>
* m68k/cf.sc: Add .jcr section to .text.
2006-12-11 Ben Elliston <bje@au.ibm.com>
* configure.in: Remove extra whitespace from config_testsuite =

View File

@ -1,4 +1,4 @@
# Copyright (c) 1995, 1996, 2001 Cygnus Support
# Copyright (c) 1995, 1996, 2001 Cygnus Support -*- mode:makefile -*-
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose, provided
@ -66,9 +66,8 @@ OBJS = close.o fstat.o getpid.o isatty.o kill.o \
lseek.o open.o print.o putnum.o read.o sbrk.o stat.o \
unlink.o write.o
CFLAGS = -g
# ARFLAGS = rv
# What targets to build for. This is a list of {m68k,cf}
DO = @DO@
# Here is all of the simulator stuff
SIM_SCRIPTS = sim.ld
@ -118,46 +117,72 @@ IDPGDB_BSP= libidpgdb.a
IDPGDB_OBJS= leds.o idp-inbyte.o idp-gdb-outbyte.o mc68ec.o
#
# here's all the BDM semihosting stuff
# here's all the ColdFire boards
#
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 \
CF_CRT0S= cf-hosted-crt0.o cf-unhosted-crt0.o
CF_BSP= libcf.a
CF_OBJS= cf-isv.o cf-crt1.o cf-hosted.o getpid.o kill.o cf-sbrk.o \
cf-exit.o $(patsubst %,cf-%.o,${CF_ISRS})
CF_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
format_error spurious_interrupt 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 \
$(addprefix trap,0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
CF_BOARDS := m5208evb m5213evb m52235evb m5235evb m5272c3 m5282evb \
m5329evb m5485evb
# 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
m5275evb := 0M 16M 0xFFE00000 2M
m5282evb := 0M 16M 0xFFE00000 2M
m5329evb := 1024M 32M 0M 2M
m5485evb := 0M 64M 1024M 16M
CF_BOARDS := m5208evb m5213evb m52235evb m5235evb m5272c3 m5275evb \
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)
CF_HOSTED_SCRIPTS := $(patsubst %.ld,%-hosted.ld,$(CF_RAM_SCRIPTS) $(CF_ROM_SCRIPTS))
CF_SCRIPTS = $(CF_RAM_SCRIPTS) $(CF_ROM_SCRIPTS) $(CF_HOSTED_SCRIPTS)
CF_SOURCES = cf-isv.S cf-crt0.S cf-crt1.c asm.h
#
# here's all the unhosted stuff
#
UNHOSTED_BSP= libunhosted.a
UNHOSTED_OBJS= unhosted-close.o unhosted-fstat.o \
unhosted-gettimeofday.o unhosted-isatty.o unhosted-lseek.o \
unhosted-open.o unhosted-read.o unhosted-rename.o \
unhosted-stat.o unhosted-system.o unhosted-time.o \
unhosted-unlink.o unhosted-write.o
#
# here's all the hosted stuff
#
HOSTED_BSP= libhosted.a
HOSTED_OBJS= hosted-gdb.o hosted-exit.o $(patsubst un%,%,$(UNHOSTED_OBJS))
# Host specific makefile fragment comes in here.
@host_makefile_frag@
#
# 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} ${BDM_CRT0} ${BDM_BSP} ${CF_SCRIPTS}
all :: $(DO:%=all_%)
#
# here's where we build the board support packages for each target
#
.PHONY: all_m68k
all_m68k :: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} \
${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP}
.PHONY: all_cf
all_cf :: ${CF_CRT0S} ${CF_BSP} ${CF_SCRIPTS} ${HOSTED_BSP} ${UNHOSTED_BSP}
${SIM_BSP}: ${SIM_OBJS}
${AR} ${ARFLAGS} $@ ${SIM_OBJS}
${RANLIB} $@
@ -174,10 +199,6 @@ ${IDPGDB_BSP}: $(OBJS) ${IDPGDB_OBJS}
${AR} ${ARFLAGS} $@ $(OBJS) ${IDPGDB_OBJS}
${RANLIB} $@
${BDM_BSP}: $(BDM_OTHER_OBJS) ${BDM_OBJS}
${AR} ${ARFLAGS} $@ $(BDM_OTHER_OBJS) ${BDM_OBJS}
${RANLIB} $@
${MVME135_BSP}: $(OBJS) ${MVME135_OBJS}
${AR} ${ARFLAGS} $@ $(OBJS) ${MVME135_OBJS}
${RANLIB} $@
@ -186,52 +207,59 @@ ${MVME162_BSP}: $(OBJS) ${MVME162_OBJS}
${AR} ${ARFLAGS} $@ $(OBJS) ${MVME162_OBJS}
${RANLIB} $@
$(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
# build hosted library
$(HOSTED_OBJS): hosted%.o: io%.c io.h
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -DHOSTED=1 $(INCLUDES) -c $< -o $@
$(HOSTED_BSP): $(HOSTED_OBJS)
${AR} ${ARFLAGS} $@ $^
${RANLIB} $@
cf-hosted-crt0.o: cf-crt0.S
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -DHOSTED=1 $(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.
$(patsubst %,bdm-%.o,${BDM_ISRS}) : bdm-isrs.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $< -o $@ \
-DL_$(patsubst bdm-%.o,%,$@) -fno-omit-frame-pointer
# build unhosted library
$(UNHOSTED_OBJS): unhosted%.o: io%.c io.h
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -DHOSTED=0 $(INCLUDES) -c $< -o $@
$(UNHOSTED_BSP): $(UNHOSTED_OBJS)
${AR} ${ARFLAGS} $@ $^
${RANLIB} $@
cf-unhosted-crt0.o: cf-crt0.S
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -DHOSTED=0 $(INCLUDES) -c $< -o $@
# 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
# build coldfire library
$(patsubst %,cf-%.o,${CF_ISRS}) : cf-isrs.c
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -c $< -o $@ \
-DL_$(patsubst cf-%.o,%,$@)
$(CF_BSP): $(CF_OBJS)
${AR} ${ARFLAGS} $@ $^
${RANLIB} $@
%-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} $< >$@
m%-ram.ld : cf.sc Makefile
IO=unhosted RAM=$(word 1,$(m$*)) RAM_SIZE=$(word 2,$(m$*)) \
${SHELL} $< >$@
m%-rom.ld : cf.sc Makefile
IO=unhosted RAM=$(word 1,$(m$*)) RAM_SIZE=$(word 2,$(m$*)) \
ROM=$(word 3,$(m$*)) ROM_SIZE=$(word 4,$(m$*)) ${SHELL} $< >$@
m%-ram-hosted.ld : cf.sc Makefile
IO=hosted RAM=$(word 1,$(m$*)) RAM_SIZE=$(word 2,$(m$*)) \
${SHELL} $< >$@
m%-rom-hosted.ld : cf.sc Makefile
IO=hosted RAM=$(word 1,$(m$*)) RAM_SIZE=$(word 2,$(m$*)) \
ROM=$(word 3,$(m$*)) ROM_SIZE=$(word 4,$(m$*)) ${SHELL} $< >$@
leds.o: ${srcdir}/leds.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -c $<
idp-inbyte.o: ${srcdir}/idp-inbyte.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -c $<
idp-outbyte.o: ${srcdir}/idp-outbyte.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -c $<
idp-gdb-outbyte.o: ${srcdir}/idp-outbyte.c
$(CC) $(CFLAGS_FOR_TARGET) -DGDB_MONITOR_OUTPUT $(INCLUDES) -c $< -o $@
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -DGDB_MONITOR_OUTPUT $(INCLUDES) -c $< -o $@
mc68ec.o: ${srcdir}/mc68ec.c
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -c $<
test.o: ${srcdir}/test.c
@ -250,7 +278,7 @@ test: $(OBJS) idp-test.srec mvme135-test.srec bcc-test.srec \
# symbols will get fully resolved.
idp-test.x: test.o ${CRT0} Makefile ${IDP_BSP}
${CC} $(CFLAGS_FOR_TARGET) -L${srcdir} -L${objdir} \
${CC} $(CFLAGS_FOR_TARGET) $(CFLAGS) -L${srcdir} -L${objdir} \
test.o -o $@ $(LDFLAGS_FOR_TARGET) -N -Wl,-Tidp.ld
idp-test.srec: idp-test.x
$(OBJCOPY) -O srec idp-test.x $@
@ -260,7 +288,7 @@ idp-test.dis: idp-test.x
idp-test: idp-test.srec idp-test.dis
idpgdb-test.x: test.o ${CRT0} Makefile ${IDPGDB_BSP}
${CC} $(CFLAGS_FOR_TARGET) -L${srcdir} -L${objdir} \
${CC} $(CFLAGS_FOR_TARGET) $(CFLAGS) -L${srcdir} -L${objdir} \
test.o -o $@ $(LDFLAGS_FOR_TARGET) -N -Wl,-Tidpgdb.ld
idpgdb-test.srec: idpgdb-test.x
$(OBJCOPY) -O srec idpgdb-test.x $@
@ -301,7 +329,7 @@ bcc-test: bcc-test.srec bcc-test.dis
# a C++ test case
dtor.o: $(srcdir)/dtor.C
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -o $@ -c $<
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -o $@ -c $<
dtor.dis: dtor.x
@rm -fr dtor.dis
$(OBJDUMP) -d dtor.x > $@
@ -312,7 +340,11 @@ dtor.x: dtor.o ${CRT0} ${srcdir}/mvme135.ld Makefile ${MVME135_BSP}
unlink.o: $(srcdir)/../unlink.c
.PHONY: install info dvi doc install-info clean-info
install:
install:: $(DO:%=install_%)
.PHONY:install_m68k
install_m68k::
# install SIM stuff
$(INSTALL_PROGRAM) $(SIM_CRT0) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(SIM_CRT0)
$(INSTALL_PROGRAM) $(SIM_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
@ -334,15 +366,28 @@ 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 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
.PHONY: install_cf
install_cf:: install_io
# install CF stuff
for crt in $(CF_CRT0S) ; \
do $(INSTALL_DATA) $$crt $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$$crt ; \
done
$(INSTALL_DATA) $(CF_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(CF_BSP)
for script in $(CF_SCRIPTS) ; \
do $(INSTALL_DATA) $$script $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$$script ; \
done
for src in $(CF_SOURCES) ; \
do $(INSTALL_DATA) ${srcdir}/$$src $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$$src ; \
done
.PHONY: install_io
install_io::
# install IO stuff
$(INSTALL_DATA) $(HOSTED_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(HOSTED_BSP)
$(INSTALL_DATA) $(UNHOSTED_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(UNHOSTED_BSP)
# target specific makefile fragment comes in here.
@target_makefile_frag@

View File

@ -79,6 +79,7 @@
#define sp REG (sp)
#define usp REG (usp)
#define vbr REG (vbr)
#define mbb REG (mbb)
#define sr REG (sr)
#define fpcr REG (fpcr)
#define fpsr REG (fpsr)

View File

@ -1,57 +0,0 @@
/*
* 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")

View File

@ -1,21 +0,0 @@
#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;
}

47
libgloss/m68k/cf-crt0.S Normal file
View File

@ -0,0 +1,47 @@
/* Initial boot
*
* 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
.extern __stack
.extern __heap_end
.weak __heap_end
.extern __start1
.globl __start
__start:
/* Initialize stack */
move.l IMM(__stack), sp
move.l IMM(0), fp
move.l IMM(__heap_end), d1
#if HOSTED
/* INIT_SIM syscall. Allows changing sp & d1. */
move.l IMM(1),d0
.align 4
/* The halt sequence must be 'nop; halt' and aligned to a 4 byte
boundary. */
nop
halt
/* This sentinel instruction value must be immediately after
the halt instruction. The debugger will adjust the pc, so
that it is never executed. This instruction is
'movec %sp,0'. */
.long 0x4e7bf000
#endif
move.l d1,sp@-
move.l fp,sp@- /* Dummy return address */
jmp __start1

View File

@ -22,7 +22,7 @@ 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)));
void *__heap_limit;
extern void software_init_hook (void) __attribute__ ((weak));
extern void hardware_init_hook (void) __attribute__ ((weak));
extern void __INIT_SECTION__ (void);
@ -30,23 +30,21 @@ 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)
/* This is called from a tiny assembly stub. */
void __start1 (void *heap_limit)
{
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);
__heap_limit = heap_limit;
if (software_init_hook)
software_init_hook ();
@ -62,3 +60,20 @@ void __start1 (void)
while (1)
__reset ();
}
/* A default hardware init hook. */
void __attribute__ ((weak)) hardware_init_hook (void)
{
/* Set the VBR. */
__asm__ __volatile__ ("movec.l %0,%/vbr" :: "r" (__interrupt_vector));
#ifndef __mcf_family_5213
/* Flush & enable the caches */
#define CACR_CINV (1 << 24)
#define CACR_CENB (1 << 31)
__asm__ __volatile__ ("movec.l %0,%/cacr" :: "r" (CACR_CINV | CACR_CENB));
#endif
/* Should we drop into user mode here? */
}

View File

@ -1,5 +1,5 @@
/*
* bdm-exit.c --
* cf-exit.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,9 +14,6 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
extern void __reset (void);
/*
@ -27,7 +24,7 @@ void __attribute__ ((noreturn)) _exit (int code)
{
while (1)
{
BDM_TRAP (BDM_EXIT, code);
__asm__ __volatile__ ("halt" ::: "memory");
__reset ();
}
}

38
libgloss/m68k/cf-hosted.S Normal file
View File

@ -0,0 +1,38 @@
/*
* cf-hosted.S --
*
* 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 function. The debugger intercepts the halt, and
determines that it is followed by the sentinel pattern. */
.globl __hosted
__hosted:
linkw %fp,#0
movel %fp@(8),%d0
movel %fp@(12),%d1
.align 4
/* The halt sequence must be 'nop; halt' and aligned to a 4 byte
boundary. */
nop
halt
/* This sentinel instruction value must be immediately after
the halt instruction. The debugger will adjust the pc, so
that it is never executed. This instruction is
'movec %sp,0'. */
.long 0x4e7bf000
unlk %fp
rts

View File

@ -1,5 +1,5 @@
/*
* bdm-isv.c --
* cf-isv.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -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 */

View File

@ -13,7 +13,6 @@
* they apply.
*/
#include "asm.h"
.text
.globl __interrupt_vector
@ -55,7 +54,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 */
@ -74,12 +73,3 @@ __interrupt_vector:
.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

50
libgloss/m68k/cf-sbrk.c Normal file
View File

@ -0,0 +1,50 @@
/*
* cf-sbrk.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 <errno.h>
/*
* sbrk -- changes heap size size. Get nbytes more
* RAM. We just increment a pointer in what's
* left of memory on the board.
*/
extern char __end[] __attribute__ ((aligned (4)));
/* End of heap, if non NULL. */
extern void *__heap_limit;
void *
sbrk (int nbytes)
{
static char *heap = __end;
char *end = __heap_limit;
char *base = heap;
char *new_heap = heap + nbytes;
if (!end)
{
/* Use sp - 256 as the heap limit. */
__asm__ __volatile__ ("move.l %/sp,%0" : "=r"(end));
end -= 256;
}
if (nbytes < 0 || (long)(end - new_heap) < 0)
{
errno = ENOMEM;
return (void *)-1;
}
heap = new_heap;
return base;
}

View File

@ -3,15 +3,16 @@
# RAM_SIZE - size of board's ram
# ROM - start of board's rom
# ROM_SIZE - size of board's rom
# IO - io library name
test -z "${ROM:+1}" && NOROM=1
cat <<EOF
STARTUP(bdm-crt0.o)
STARTUP(cf-${IO}-crt0.o)
OUTPUT_ARCH(m68k)
ENTRY(__start)
SEARCH_DIR(.)
GROUP(-lc -lbdm)
GROUP(-lc -l${IO} -lcf)
__DYNAMIC = 0;
MEMORY
@ -28,8 +29,10 @@ SECTIONS
.text :
{
CREATE_OBJECT_SYMBOLS
bdm-crt0.o(.text)
KEEP (*cf-isv.o(.text))
cf-${IO}-crt0.o(.text)
*(.text .text.*)
*(.gnu.linkonce.t.*)
. = ALIGN(0x4);
/* These are for running static constructors and destructors under ELF. */
@ -42,7 +45,13 @@ SECTIONS
KEEP (*(SORT(.dtors.*)))
KEEP (*crtend.o(.dtors))
. = ALIGN(0x4);
KEEP (*crtbegin.o(.jcr))
KEEP (*(EXCLUDE_FILE (*crtend.o) .jcr))
KEEP (*crtend.o(.jcr))
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x4);
*(.gcc_except_table)
@ -77,6 +86,7 @@ SECTIONS
*(.got.plt) *(.got)
*(.shdata)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN (4);
_edata = .;
} >ram ${ROM:+AT>rom}
@ -86,6 +96,7 @@ SECTIONS
__bss_start = . ;
*(.shbss)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (8);
_end = .;
@ -101,5 +112,27 @@ SECTIONS
{
*(.stabstr)
}
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}
EOF

1244
libgloss/m68k/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,23 @@ AC_SUBST(LD)
AC_PROG_RANLIB
LIB_AM_PROG_AS
AC_MSG_CHECKING([target cpu family])
DO=m68k
dnl Temporarily modify LDFLAGS so that link tests will succeed without
dnl a C library. Note that we may not have a C librabry yet and that
dnl autoconf automatically adds script to check whether we can create
dnl an executable or not.
dnl
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="-nostdlib -e main"
AC_PREPROC_IFELSE([#ifndef __mcoldfire__
#error we are not coldfire
#endif],
DO="cf",)
LDFLAGS=$saved_LDFLAGS
AC_MSG_RESULT($DO)
AC_SUBST(DO)
host_makefile_frag=${srcdir}/../config/default.mh
target_makefile_frag=${srcdir}/../config/default.mt

View File

@ -1,5 +1,5 @@
/*
* bdm-close.c --
* io-close.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,10 +14,10 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <unistd.h>
#include <errno.h>
#define IO close
#include "io.h"
/*
* close -- close a file descriptor.
@ -30,9 +30,13 @@
int close (int fd)
{
#if HOSTED
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) fd;
BDM_TRAP (BDM_CLOSE, (uint32_t)parameters);
errno = convert_from_gdb_errno (parameters[1]);
__hosted (HOSTED_CLOSE, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
return 0;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-semihost.c --
* io-exit.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,12 +14,16 @@
* 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. */
void __attribute__ ((interrupt_handler)) __bdm_semihosting (void)
#if HOSTED
#include "io.h"
/*
* _exit -- Exit from the application.
*/
void __attribute__ ((noreturn)) _exit (int code)
{
__asm__ __volatile__ ("halt" ::: "memory");
while (1)
__hosted (HOSTED_EXIT, (void *)code);
}
#endif

View File

@ -1,5 +1,5 @@
/*
* bdm-fstat.c --
* io-fstat.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,12 +14,12 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#define IO fstat
#include "io.h"
/*
* fstat -- get file information
@ -33,12 +33,17 @@
int fstat (int fd, struct stat *buf)
{
#if HOSTED
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]);
__hosted (HOSTED_FSTAT, parameters);
__hosted_from_gdb_stat (&gbuf, buf);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm support for GDB's remote fileio protocol
* hosted io support for GDB's remote fileio protocol
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,13 +14,13 @@
* they apply.
*/
#include "bdm-gdb.h"
#include "io.h"
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
gdb_mode_t
convert_to_gdb_mode_t (mode_t m)
__hosted_to_gdb_mode_t (mode_t m)
{
gdb_mode_t result = 0;
if (m & S_IFREG)
@ -49,7 +49,7 @@ convert_to_gdb_mode_t (mode_t m)
}
int32_t
convert_to_gdb_open_flags (int f)
__hosted_to_gdb_open_flags (int f)
{
int32_t result = 0;
if (f & O_RDONLY)
@ -70,7 +70,7 @@ convert_to_gdb_open_flags (int f)
}
int32_t
convert_to_gdb_lseek_flags (int f)
__hosted_to_gdb_lseek_flags (int f)
{
if (f == SEEK_CUR)
return GDB_SEEK_CUR;
@ -81,8 +81,8 @@ convert_to_gdb_lseek_flags (int f)
}
void
convert_from_gdb_stat (const struct gdb_stat *gs,
struct stat *s)
__hosted_from_gdb_stat (const struct gdb_stat *gs,
struct stat *s)
{
s->st_dev = gs->st_dev;
s->st_ino = gs->st_ino;
@ -100,15 +100,15 @@ convert_from_gdb_stat (const struct gdb_stat *gs,
}
void
convert_from_gdb_timeval (const struct gdb_timeval *gt,
struct timeval *t)
__hosted_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)
__hosted_from_gdb_errno (int32_t err)
{
switch (err)
{

View File

@ -1,5 +1,5 @@
/*
* bdm-gettimeofday.c --
* io-gettimeofday.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,10 +14,10 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <sys/time.h>
#include <errno.h>
#define IO gettimeofday
#include "io.h"
/*
* gettimeofday -- get the current time
@ -30,6 +30,7 @@
int gettimeofday (struct timeval *tv, struct timezone *tz)
{
#if HOSTED
gdb_parambuf_t parameters;
struct gdb_timeval gtv;
if (!tv)
@ -40,8 +41,12 @@ int gettimeofday (struct timeval *tv, struct timezone *tz)
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]);
__hosted (HOSTED_GETTIMEOFDAY, parameters);
__hosted_from_gdb_timeval (&gtv, tv);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-isatty.c --
* io-isatty.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,10 +14,10 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <unistd.h>
#include <errno.h>
#define IO isatty
#include "io.h"
/*
* isatty -- check if fd is a terminal
@ -30,9 +30,13 @@
int isatty (int fd)
{
#if HOSTED
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) fd;
BDM_TRAP (BDM_ISATTY, (uint32_t)parameters);
errno = convert_from_gdb_errno (parameters[1]);
__hosted (HOSTED_ISATTY, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
return 1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-lseek.c --
* io-lseek.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,11 +14,11 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#define IO lseek
#include "io.h"
/*
* lseek -- reposition a file descriptor
@ -35,12 +35,17 @@
off_t lseek (int fd, off_t offset, int whence)
{
#if HOSTED
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]);
parameters[3] = __hosted_to_gdb_lseek_flags (whence);
__hosted (HOSTED_LSEEK, parameters);
errno = __hosted_from_gdb_errno (parameters[2]);
return ((uint64_t)parameters[0] << 32) | ((uint64_t)parameters[1]);
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-open.c --
* io-open.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,14 +14,14 @@
* 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>
#define IO open
#include "io.h"
/*
* open -- Open a file.
@ -37,20 +37,25 @@
int open (const char *fname, int flags, ...)
{
#if HOSTED
gdb_parambuf_t parameters;
parameters[0] = (uint32_t) fname;
parameters[1] = strlen (fname) + 1;
parameters[2] = convert_to_gdb_open_flags (flags);
parameters[2] = __hosted_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));
parameters[3] = __hosted_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]);
__hosted (HOSTED_OPEN, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-read.c --
* io-read.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,10 +14,10 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <unistd.h>
#include <errno.h>
#define IO read
#include "io.h"
/*
* read -- read from a file descriptor
@ -32,11 +32,16 @@
ssize_t read (int fd, void *buf, size_t count)
{
#if HOSTED
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]);
__hosted (HOSTED_READ, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-rename.c --
* io-rename.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,11 +14,11 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define IO rename
#include "io.h"
/*
* rename -- rename a file
@ -34,12 +34,17 @@
int _rename (const char *oldpath, const char *newpath)
{
#if HOSTED
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]);
__hosted (HOSTED_RENAME, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-stat.c --
* io-stat.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,13 +14,13 @@
* 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>
#define IO stat
#include "io.h"
/*
* stat -- get file information
@ -36,13 +36,18 @@
int stat (const char *filename, struct stat *buf)
{
#if HOSTED
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]);
__hosted (HOSTED_STAT, parameters);
__hosted_from_gdb_stat (&gbuf, buf);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-system.c --
* io-system.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,12 +14,13 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
#define IO _system
#include "io.h"
/*
* system: execute command on (remote) host
* input parameters:
@ -32,13 +33,14 @@
int _system (const char *command)
{
#if HOSTED
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]);
__hosted (HOSTED_SYSTEM, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
e = parameters[0];
if (e >= 0 && command)
{
@ -52,4 +54,10 @@ int _system (const char *command)
}
return e;
#else
if (!command)
return 0;
errno = ENOSYS;
return -1;
#endif
}

45
libgloss/m68k/io-time.c Normal file
View File

@ -0,0 +1,45 @@
/*
* io-time.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 <sys/time.h>
#include <errno.h>
#define IO time
#include "io.h"
/*
* time -- get the current time
* input parameters:
* 0 : timeval ptr
* output parameters:
* 0 : result
* 1 : errno
*/
time_t time (time_t *t)
{
#if HOSTED
struct timeval tv;
if (gettimeofday (&tv, NULL))
return -1;
if (t)
*t = tv.tv_sec;
return tv.tv_sec;
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-unlink.c --
* io-unlink.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,11 +14,11 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define IO unlink
#include "io.h"
/*
* unlink -- unlink (delete) a file
@ -32,10 +32,15 @@
int unlink (const char *path)
{
#if HOSTED
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]);
__hosted (HOSTED_UNLINK, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm-write.c --
* io-write.c --
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,10 +14,10 @@
* they apply.
*/
#include "bdm-semihost.h"
#include "bdm-gdb.h"
#include <unistd.h>
#include <errno.h>
#define IO write
#include "io.h"
/*
* write -- write to a file descriptor
@ -32,11 +32,16 @@
ssize_t write (int fd, const void *buf, size_t count)
{
#if HOSTED
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]);
__hosted (HOSTED_WRITE, parameters);
errno = __hosted_from_gdb_errno (parameters[1]);
return parameters[0];
#else
errno = ENOSYS;
return -1;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* bdm support for GDB's remote fileio protocol
* hosted & unhosted io support.
*
* Copyright (c) 2006 CodeSourcery Inc
*
@ -14,11 +14,31 @@
* they apply.
*/
#if HOSTED
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#define HOSTED_EXIT 0
#define HOSTED_INIT_SIM 1
#define HOSTED_OPEN 2
#define HOSTED_CLOSE 3
#define HOSTED_READ 4
#define HOSTED_WRITE 5
#define HOSTED_LSEEK 6
#define HOSTED_RENAME 7
#define HOSTED_UNLINK 8
#define HOSTED_STAT 9
#define HOSTED_FSTAT 10
#define HOSTED_GETTIMEOFDAY 11
#define HOSTED_ISATTY 12
#define HOSTED_SYSTEM 13
/* This function is provided by the board's BSP, because the precise
mechanism of informing gdb is board specific. */
extern int __io_hosted (int func, void *args);
/* 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
@ -55,7 +75,6 @@ struct gdb_timeval {
typedef uint32_t gdb_parambuf_t[4];
/* open flags */
#define GDB_O_RDONLY 0x0
@ -112,17 +131,25 @@ typedef uint32_t gdb_parambuf_t[4];
/* 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);
extern gdb_mode_t __hosted_to_gdb_mode_t (mode_t m);
extern int32_t __hosted_to_gdb_open_flags (int f);
extern int32_t __hosted_to_gdb_lseek_flags (int f);
extern void __hosted_from_gdb_stat (const struct gdb_stat *gs,
struct stat *s);
extern void __hosted_from_gdb_timeval (const struct gdb_timeval *gt,
struct timeval *t);
extern int __hosted_from_gdb_errno (int32_t err);
#else
#ifdef IO
#define IO_NAME_(IO) __hosted_##IO
#define IO_NAME(IO) IO_NAME_(IO)
#define IO_STRING_(IO) #IO
#define IO_STRING(IO) IO_STRING_(IO)
/* Emit an object that causes a gnu linker warning. */
static const char IO_NAME (IO) []
__attribute__ ((section (".gnu.warning"), used)) =
"IO function '" IO_STRING (IO) "' used";
#endif
#endif