[PATCH] FT32: add support in libgloss
James Bowman
james.bowman@ftdichip.com
Fri Sep 4 16:34:00 GMT 2015
FT32 is a new high performance 32-bit RISC core developed by FTDI for
embedded applications.
Support for FT32 has already been added to binutils, gdb and gcc.
This patch adds libgloss support.
I also propose to update config.sub from the gnuconfig project.
Please can someone review it, and if appropriate approve it for commit?
The FSF have acknowledged receipt of FTDI's copyright assignment papers.
Thanks very much.
--
James Bowman
FTDI Open Source Liaison
From: James Bowman <james.bowman@ftdichip.com>
Date: Fri, 4 Sep 2015 09:02:25 -0700
Subject: [PATCH] libgloss FT32 support
---
libgloss/configure.in | 3 ++
libgloss/ft32/Makefile.in | 129 ++++++++++++++++++++++++++++++++++++++++++++
libgloss/ft32/configure.in | 55 +++++++++++++++++++
libgloss/ft32/crt0.S | 73 +++++++++++++++++++++++++
libgloss/ft32/fstat.c | 30 +++++++++++
libgloss/ft32/getpid.c | 25 +++++++++
libgloss/ft32/isatty.c | 27 ++++++++++
libgloss/ft32/kill.c | 30 +++++++++++
libgloss/ft32/sbrk.c | 45 ++++++++++++++++
libgloss/ft32/sim-close.S | 37 +++++++++++++
libgloss/ft32/sim-exit.S | 34 ++++++++++++
libgloss/ft32/sim-inbyte.c | 26 +++++++++
libgloss/ft32/sim-lseek.S | 32 +++++++++++
libgloss/ft32/sim-lseek.c | 32 +++++++++++
libgloss/ft32/sim-open.S | 39 ++++++++++++++
libgloss/ft32/sim-read.S | 39 ++++++++++++++
libgloss/ft32/sim-time.c | 47 ++++++++++++++++
libgloss/ft32/sim-unlink.S | 37 +++++++++++++
libgloss/ft32/sim-write.S | 56 +++++++++++++++++++
libgloss/ft32/sim.ld | 56 +++++++++++++++++++
libgloss/ft32/stat.c | 30 +++++++++++
21 files changed, 882 insertions(+)
create mode 100644 libgloss/ft32/Makefile.in
create mode 100644 libgloss/ft32/configure.in
create mode 100644 libgloss/ft32/crt0.S
create mode 100644 libgloss/ft32/fstat.c
create mode 100644 libgloss/ft32/getpid.c
create mode 100644 libgloss/ft32/isatty.c
create mode 100644 libgloss/ft32/kill.c
create mode 100644 libgloss/ft32/sbrk.c
create mode 100644 libgloss/ft32/sim-close.S
create mode 100644 libgloss/ft32/sim-exit.S
create mode 100644 libgloss/ft32/sim-inbyte.c
create mode 100644 libgloss/ft32/sim-lseek.S
create mode 100644 libgloss/ft32/sim-lseek.c
create mode 100644 libgloss/ft32/sim-open.S
create mode 100644 libgloss/ft32/sim-read.S
create mode 100644 libgloss/ft32/sim-time.c
create mode 100644 libgloss/ft32/sim-unlink.S
create mode 100644 libgloss/ft32/sim-write.S
create mode 100644 libgloss/ft32/sim.ld
create mode 100644 libgloss/ft32/stat.c
diff --git a/libgloss/configure.in b/libgloss/configure.in
index ab3224a..e11eb7d 100644
--- a/libgloss/configure.in
+++ b/libgloss/configure.in
@@ -105,6 +105,9 @@ case "${target}" in
frv*-*-*)
AC_CONFIG_SUBDIRS([frv])
;;
+ ft32*-*-*)
+ AC_CONFIG_SUBDIRS([ft32])
+ ;;
lm32*-*-*)
AC_CONFIG_SUBDIRS([lm32])
;;
diff --git a/libgloss/ft32/Makefile.in b/libgloss/ft32/Makefile.in
new file mode 100644
index 0000000..21f9e82
--- /dev/null
+++ b/libgloss/ft32/Makefile.in
@@ -0,0 +1,129 @@
+# Copyright (C) 2015 FTDI (support@ftdichip.com)
+#
+# 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.
+
+# Makefile for libgloss/spro. This is the board support code for the
+# ft32 target.
+
+DESTDIR =
+VPATH = @srcdir@ @srcdir@/..
+srcdir = @srcdir@
+objdir = .
+srcroot = $(srcdir)/../..
+objroot = $(objdir)/../..
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(exec_prefix)/$(target_alias)
+
+# Multilib support variables.
+# TOP is used instead of MULTI{BUILD,SRC}TOP.
+MULTIDIRS =
+MULTISUBDIR =
+MULTIDO = true
+MULTICLEAN = true
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+SHELL = /bin/sh
+
+CC = @CC@
+
+AS = @AS@
+AR = @AR@
+LD = @LD@
+RANLIB = @RANLIB@
+AR_FLAGS = rc
+
+OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
+ then echo ${objroot}/../binutils/objdump ; \
+ else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
+OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
+ then echo ${objroot}/../binutils/objcopy ; \
+ else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
+
+LD_SCRIPTS = ft32-elf-common.ld sim.ld
+
+CRT0 = crt0.o
+SIM_BSP = libsim.a
+SIM_OBJS = fstat.o \
+ getpid.o \
+ isatty.o \
+ kill.o \
+ sbrk.o \
+ sim-close.o \
+ sim-exit.o \
+ sim-inbyte.o \
+ sim-lseek.o \
+ sim-open.o \
+ sim-read.o \
+ sim-time.o \
+ sim-unlink.o \
+ sim-write.o \
+ stat.o
+
+#### Host specific Makefile fragment comes in here.
+@host_makefile_frag@
+
+all: $(CRT0) $(SIM_BSP)
+
+$(SIM_BSP): $(SIM_OBJS)
+ $(AR) $(ARFLAGS) $@ $?
+ $(RANLIB) $@
+
+fstat.o: $(srcdir)/fstat.c
+getpid.o: $(srcdir)/getpid.c
+isatty.o: $(srcdir)/isatty.c
+kill.o: $(srcdir)/kill.c
+putnum.o: $(srcdir)/putnum.c
+sbrk.o: $(srcdir)/sbrk.c
+sim-close.o: $(srcdir)/sim-close.S
+sim-exit.o: $(srcdir)/sim-exit.S
+sim-inbyte.o: $(srcdir)/sim-inbyte.c
+sim-lseek.o: $(srcdir)/sim-lseek.c
+sim-open.o: $(srcdir)/sim-open.S
+sim-read.o: $(srcdir)/sim-read.S
+sim-time.o: $(srcdir)/sim-time.c
+sim-unlink.o: $(srcdir)/sim-unlink.S
+sim-write.o: $(srcdir)/sim-write.S
+stat.o: $(srcdir)/stat.c
+
+install: $($(CPU)_INSTALL)
+ $(INSTALL_DATA) $(CRT0) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(CRT0)
+ $(INSTALL_DATA) $(SIM_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
+ for x in ${LD_SCRIPTS}; do \
+ ${INSTALL_DATA} ${srcdir}/$$x $(DESTDIR)${tooldir}/lib/$$x; \
+ done;
+
+clean mostlyclean:
+ rm -f *.o *.a
+
+distclean maintainer-clean realclean: clean
+ rm -f Makefile config.cache config.log config.status
+
+.PHONY: info dvi doc install-info clean-info
+info doc dvi:
+install-info:
+clean-info:
+
+Makefile: Makefile.in config.status @host_makefile_frag_path@
+ $(SHELL) config.status
+
+config.status: configure
+ $(SHELL) config.status --recheck
diff --git a/libgloss/ft32/configure.in b/libgloss/ft32/configure.in
new file mode 100644
index 0000000..04169f1
--- /dev/null
+++ b/libgloss/ft32/configure.in
@@ -0,0 +1,55 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.59)
+AC_INIT(crt0.S)
+
+if test "${enable_shared}" = "yes" ; then
+ echo "Shared libraries not supported for cross compiling, ignored"
+fi
+
+if test "$srcdir" = "." ; then
+ if test "${with_target_subdir}" != "." ; then
+ libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
+ else
+ libgloss_topdir="${srcdir}/${with_multisrctop}../.."
+ fi
+else
+ libgloss_topdir="${srcdir}/../.."
+fi
+AC_CONFIG_AUX_DIR($libgloss_topdir)
+
+AC_CANONICAL_SYSTEM
+AC_ARG_PROGRAM
+
+AC_PROG_INSTALL
+
+LIB_AC_PROG_CC
+
+AS=${AS-as}
+AC_SUBST(AS)
+AR=${AR-ar}
+AC_SUBST(AR)
+LD=${LD-ld}
+AC_SUBST(LD)
+AC_PROG_RANLIB
+LIB_AM_PROG_AS
+
+host_makefile_frag=${srcdir}/../config/default.mh
+
+dnl We have to assign the same value to other variables because autoconf
+dnl doesn't provide a mechanism to substitute a replacement keyword with
+dnl arbitrary data or pathnames.
+dnl
+host_makefile_frag_path=$host_makefile_frag
+AC_SUBST(host_makefile_frag_path)
+AC_SUBST_FILE(host_makefile_frag)
+
+AC_CONFIG_FILES(Makefile,
+. ${libgloss_topdir}/config-ml.in,
+srcdir=${srcdir}
+target=${target}
+with_multisubdir=${with_multisubdir}
+ac_configure_args="${ac_configure_args} --enable-multilib"
+CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+libgloss_topdir=${libgloss_topdir}
+)
+AC_OUTPUT
diff --git a/libgloss/ft32/crt0.S b/libgloss/ft32/crt0.S
new file mode 100644
index 0000000..bb09d65
--- /dev/null
+++ b/libgloss/ft32/crt0.S
@@ -0,0 +1,73 @@
+/* crt0.S -- startup file for FT32
+ *
+ * Copyright (c) 2015 FTDI
+ *
+ * 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.
+ */
+
+ .globl __start
+ .weak _start
+ .text
+ .type __start,@function
+
+__start:
+_start:
+
+ jmp truestart
+ jmp truestart
+
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+ reti
+
+truestart:
+ ldk.l $sp, 0xfffc /* set the top of stack */
+ ldk.l $fp,0 /* zero fp to allow unwinders to stop */
+
+ /* Set argc and argv to zero */
+ ldk.l $r0, 0
+ ldk.l $r1, 0
+
+ sub.l $sp,$sp,24 # room for the args to main
+ call main
+ call exit
+
+.Lend:
+ .size __start,(.Lend-__start)
diff --git a/libgloss/ft32/fstat.c b/libgloss/ft32/fstat.c
new file mode 100644
index 0000000..208a5cd
--- /dev/null
+++ b/libgloss/ft32/fstat.c
@@ -0,0 +1,30 @@
+/* fstat.c -- get status of a file.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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/stat.h>
+#include "glue.h"
+
+/*
+ * fstat -- Since we have no file system, we just return an error.
+ */
+int
+_DEFUN (_fstat, (fd, buf),
+ int fd _AND
+ struct stat *buf)
+{
+ buf->st_mode = S_IFCHR; /* Always pretend to be a tty */
+ buf->st_blksize = 0;
+
+ return (0);
+}
diff --git a/libgloss/ft32/getpid.c b/libgloss/ft32/getpid.c
new file mode 100644
index 0000000..b4f520a
--- /dev/null
+++ b/libgloss/ft32/getpid.c
@@ -0,0 +1,25 @@
+/* getpid.c -- get the current process id.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "glue.h"
+
+/*
+ * getpid -- only one process, so just return 1.
+ */
+int
+_DEFUN (_getpid, (),
+ )
+{
+ return __MYPID;
+}
diff --git a/libgloss/ft32/isatty.c b/libgloss/ft32/isatty.c
new file mode 100644
index 0000000..449410e
--- /dev/null
+++ b/libgloss/ft32/isatty.c
@@ -0,0 +1,27 @@
+/* isatty.c -- chek the terminal device.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "glue.h"
+
+/*
+ * isatty -- returns 1 if connected to a terminal device,
+ * returns 0 if not. Since we're hooked up to a
+ * serial port, we'll say yes _AND return a 1.
+ */
+int
+_DEFUN (_isatty, (fd),
+ int fd)
+{
+ return (1);
+}
diff --git a/libgloss/ft32/kill.c b/libgloss/ft32/kill.c
new file mode 100644
index 0000000..258785f
--- /dev/null
+++ b/libgloss/ft32/kill.c
@@ -0,0 +1,30 @@
+/* kill.c -- remove a process.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "glue.h"
+
+extern void _exit (int) __attribute__((__noreturn__));
+
+/*
+ * kill -- go out via exit...
+ */
+int
+_DEFUN (_kill, (pid, sig),
+ int pid _AND
+ int sig)
+{
+ if(pid == __MYPID)
+ _exit(sig);
+ return 0;
+}
diff --git a/libgloss/ft32/sbrk.c b/libgloss/ft32/sbrk.c
new file mode 100644
index 0000000..8e6743e
--- /dev/null
+++ b/libgloss/ft32/sbrk.c
@@ -0,0 +1,45 @@
+/* sbrk.c -- allocate memory dynamically.
+ *
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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>
+#include "glue.h"
+
+char *__heap_ptr = (char *)&_end;
+
+/*
+ * sbrk -- changes heap size size. Get nbytes more
+ * RAM. We just increment a pointer in what's
+ * left of memory on the board.
+ */
+char *
+_sbrk (nbytes)
+ int nbytes;
+{
+ char *base;
+ char *sp;
+ char canary;
+
+ if ((__heap_ptr + nbytes) < (&canary - 2000))
+ {
+ base = __heap_ptr;
+ __heap_ptr += nbytes;
+ return base;
+ }
+ else
+ {
+ errno = ENOMEM;
+ return ((char *)-1);
+ }
+}
diff --git a/libgloss/ft32/sim-close.S b/libgloss/ft32/sim-close.S
new file mode 100644
index 0000000..8dbd5c0
--- /dev/null
+++ b/libgloss/ft32/sim-close.S
@@ -0,0 +1,37 @@
+/*
+ * sim-close.S -- close interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+/*
+ * Input:
+ * $r0 -- File descriptor to close.
+ *
+ * Output:
+ * $r0 -- 0 or -1.
+ * errno -- Set if an error
+ */
+
+ .globl _close
+ .type _close,@function
+ .weak close
+ .text
+_close:
+close:
+# swi SYS_close
+ return
+.Lend:
+ .size _close,.Lend-_close
diff --git a/libgloss/ft32/sim-exit.S b/libgloss/ft32/sim-exit.S
new file mode 100644
index 0000000..7e6d90a
--- /dev/null
+++ b/libgloss/ft32/sim-exit.S
@@ -0,0 +1,34 @@
+/*
+ * sim-exit.S -- _exit interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+/*
+ * Input:
+ * $r0 -- exit value
+ *
+ * Output:
+ * none
+ */
+
+ .globl _exit
+ .type _exit,@function
+ .text
+_exit:
+ # swi SYS_exit
+ sta.l 0x1fffc,$r0
+.Lend:
+ .size _exit,.Lend-_exit
diff --git a/libgloss/ft32/sim-inbyte.c b/libgloss/ft32/sim-inbyte.c
new file mode 100644
index 0000000..9df0e1f
--- /dev/null
+++ b/libgloss/ft32/sim-inbyte.c
@@ -0,0 +1,26 @@
+/*
+ * sim-inbyte.c -- read a character from standard input.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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.
+ */
+
+int
+inbyte ()
+{
+ char c;
+
+ if (read (0, &c, 1) <= 0)
+ return -1;
+
+ return c;
+}
diff --git a/libgloss/ft32/sim-lseek.S b/libgloss/ft32/sim-lseek.S
new file mode 100644
index 0000000..2dfde16
--- /dev/null
+++ b/libgloss/ft32/sim-lseek.S
@@ -0,0 +1,32 @@
+/*
+ * sim-lseek.S -- write interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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/types.h>
+#include <errno.h>
+
+/*
+ * lseek -- Since a simulated serial port is non-seekable, we return
+ * an error.
+ */
+off_t
+_DEFUN (_lseek, (fd, offset, whence),
+ int fd _AND
+ off_t offset _AND
+ int whence)
+{
+ errno = ESPIPE;
+ return ((off_t)-1);
+}
diff --git a/libgloss/ft32/sim-lseek.c b/libgloss/ft32/sim-lseek.c
new file mode 100644
index 0000000..297de2b
--- /dev/null
+++ b/libgloss/ft32/sim-lseek.c
@@ -0,0 +1,32 @@
+/*
+ * sim-lseek.S -- write interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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/types.h>
+#include <errno.h>
+
+/*
+ * lseek -- Since a simulated serial port is non-seekable, we return
+ * an error.
+ */
+off_t
+_DEFUN (_lseek, (fd, offset, whence),
+ int fd _AND
+ off_t offset _AND
+ int whence)
+{
+ /* errno = ESPIPE; */
+ return ((off_t)-1);
+}
diff --git a/libgloss/ft32/sim-open.S b/libgloss/ft32/sim-open.S
new file mode 100644
index 0000000..8ec4a9e
--- /dev/null
+++ b/libgloss/ft32/sim-open.S
@@ -0,0 +1,39 @@
+/*
+ * sim-open.S -- open interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+/*
+ * Input:
+ * $r0 -- File name to open.
+ * $r1 -- open mode.
+ * -0x12($fp) -- optionally, the permission bits to set the file to.
+ *
+ * Output:
+ * $r0 -- file descriptor or -1.
+ * errno -- Set if an error
+ */
+
+ .globl _open
+ .type _open,@function
+ .weak open
+ .text
+_open:
+open:
+ # swi SYS_open
+ return
+.Lend:
+ .size _open,.Lend-_open
diff --git a/libgloss/ft32/sim-read.S b/libgloss/ft32/sim-read.S
new file mode 100644
index 0000000..d078de3
--- /dev/null
+++ b/libgloss/ft32/sim-read.S
@@ -0,0 +1,39 @@
+/*
+ * sim-read.S -- read interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+/*
+ * Input:
+ * $r0 -- File descriptor.
+ * $r1 -- Buffer to be read into.
+ * -0x12($fp) -- Length of the buffer.
+ *
+ * Output:
+ * $r0 -- Length read or -1.
+ * errno -- Set if an error
+ */
+
+ .globl _read
+ .type _read,@function
+ .weak read
+ .text
+_read:
+read:
+ # swi SYS_read
+ return
+.Lend:
+ .size _read,.Lend-_read
diff --git a/libgloss/ft32/sim-time.c b/libgloss/ft32/sim-time.c
new file mode 100644
index 0000000..b04c19f
--- /dev/null
+++ b/libgloss/ft32/sim-time.c
@@ -0,0 +1,47 @@
+/* sim-time.c -- stubs so clock can be linked in.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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>
+#include <sys/time.h>
+#include <sys/times.h>
+#include "glue.h"
+
+/*
+ * _times -- no clock, so return an error.
+ */
+int
+_DEFUN (_times, _times (buf),
+ struct tms *buf)
+{
+ errno = EINVAL;
+ return (-1);
+}
+
+/*
+ * _gettimeofday -- implement in terms of time, which means we can't return the
+ * microseconds.
+ */
+int
+_DEFUN (_gettimeofday, _gettimeofday (tv, tz),
+ struct timeval *tv _AND
+ void *tzvp)
+{
+ struct timezone *tz = tzvp;
+ if (tz)
+ tz->tz_minuteswest = tz->tz_dsttime = 0;
+
+ tv->tv_usec = 0;
+ tv->tv_sec = 0;
+ return 0;
+}
diff --git a/libgloss/ft32/sim-unlink.S b/libgloss/ft32/sim-unlink.S
new file mode 100644
index 0000000..db125e2
--- /dev/null
+++ b/libgloss/ft32/sim-unlink.S
@@ -0,0 +1,37 @@
+/*
+ * sim-unlink.S -- write interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+ .globl _unlink
+ .type _unlink,@function
+ .weak unlink
+ .text
+_unlink:
+unlink:
+ return
+.Lend:
+ .size _unlink,.Lend-_unlink
+
+ .globl _link
+ .type _link,@function
+ .weak link
+ .text
+_link:
+link:
+ return
+.Lend1:
+ .size _link,.Lend1-_link
diff --git a/libgloss/ft32/sim-write.S b/libgloss/ft32/sim-write.S
new file mode 100644
index 0000000..68cd36d
--- /dev/null
+++ b/libgloss/ft32/sim-write.S
@@ -0,0 +1,56 @@
+/*
+ * sim-write.S -- write interface for FT32 simulator
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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 "syscall.h"
+
+/*
+ * Input:
+ * $r0 -- File descriptor.
+ * $r1 -- String to be printed.
+ * $r2 -- Length of the string.
+ *
+ * Output:
+ * $r0 -- Length written or -1.
+ * errno -- Set if an error
+ */
+
+ .globl _write
+ .type _write,@function
+ .weak write
+ .text
+_write:
+write:
+
+# LDI.l $r1,$r0,0
+# STA.l MAGIC,$r1
+# jmp .f
+#
+# .loop:
+# sta.l 0x10000,$r2
+# add.l $r0,$r0,1
+# .f:
+# ldi.b $r2,$r0,0
+# cmp.b $r2,0
+# jmpc nz,.loop
+
+ ldk.l $r3,0x10000
+ streamout.b $r3,$r1,$r2
+ move.l $r0,$r2
+
+ return
+
+.Lend:
+ .size _write,.Lend-_write
diff --git a/libgloss/ft32/sim.ld b/libgloss/ft32/sim.ld
new file mode 100644
index 0000000..58de031
--- /dev/null
+++ b/libgloss/ft32/sim.ld
@@ -0,0 +1,56 @@
+OUTPUT_FORMAT("elf32-ft32")
+OUTPUT_ARCH(ft32)
+
+SEARCH_DIR(.)
+GROUP(-lsim -lc -lgcc -lsim)
+
+MEMORY
+{
+ flash (rx) : ORIGIN = 0, LENGTH = 256K
+ ram (rw!x) : ORIGIN = 0x800000, LENGTH = 64K
+}
+SECTIONS
+{
+ .text :
+ {
+ *(.text*)
+ *(.strings)
+ *(._pm*)
+ *(.init)
+ *(.fini)
+ _etext = . ;
+ } > flash
+ .tors :
+ {
+ ___ctors = . ;
+ *(.ctors)
+ ___ctors_end = . ;
+ ___dtors = . ;
+ *(.dtors)
+ ___dtors_end = . ;
+ } > ram
+ .data : AT (ADDR (.text) + SIZEOF (.text))
+ {
+ *(.data)
+ *(.rodata)
+ *(.rodata*)
+ _edata = . ;
+ } > ram
+ .bss SIZEOF(.data) + ADDR(.data) :
+ {
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ _end = . ;
+ } > ram
+ __data_load_start = LOADADDR(.data);
+ __data_load_end = __data_load_start + SIZEOF(.data);
+ .stab 0 (NOLOAD) :
+ {
+ *(.stab)
+ }
+ .stabstr 0 (NOLOAD) :
+ {
+ *(.stabstr)
+ }
+}
diff --git a/libgloss/ft32/stat.c b/libgloss/ft32/stat.c
new file mode 100644
index 0000000..580e2ca
--- /dev/null
+++ b/libgloss/ft32/stat.c
@@ -0,0 +1,30 @@
+/* stat.c -- Get the status of a file.
+ *
+ * Copyright (C) 2015 FTDI (support@ftdichip.com)
+ *
+ * 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/stat.h>
+#include <errno.h>
+#include "glue.h"
+
+/*
+ * stat -- Since we have no file system, we just return an error.
+ */
+int
+_DEFUN (_stat, (path, buf),
+ const char *path _AND
+ struct stat *buf)
+{
+ errno = EIO;
+ return (-1);
+}
+
--
1.7.9.5
More information about the Newlib
mailing list