OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/or1ksim/or1ksim-0.5.0rc1/peripheral/channels
    from Rev 346 to Rev 347
    Reverse comparison

Rev 346 → Rev 347

/Makefile.in
0,0 → 1,531
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
 
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
 
@SET_MAKE@
 
# Makefile -- Makefile for peripherals channels to host
#
# Copyright (C) 2002 Richard Prescott <rip@step.polymtl.ca>
# Copyright (C) 2008 Embecosm Limited
#
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
#
# This file is part of OpenRISC 1000 Architectural Simulator.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
 
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = peripheral/channels
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libchannels_la_LIBADD =
am_libchannels_la_OBJECTS = channel.lo fd.lo file.lo generic.lo tcp.lo \
tty.lo xterm.lo
libchannels_la_OBJECTS = $(am_libchannels_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libchannels_la_SOURCES)
DIST_SOURCES = $(libchannels_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
ARFLAGS = @ARFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_DIR = @BUILD_DIR@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPU_ARCH = @CPU_ARCH@
CYGPATH_W = @CYGPATH_W@
DEBUGFLAGS = @DEBUGFLAGS@
DEFS = @DEFS@
DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INCLUDES = @INCLUDES@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
LOCAL_DEFS = @LOCAL_DEFS@
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POW_LIB = @POW_LIB@
RANLIB = @RANLIB@
RUNTESTDEFAULTFLAGS = @RUNTESTDEFAULTFLAGS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SUMVERSION = @SUMVERSION@
TERMCAP_LIB = @TERMCAP_LIB@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libchannels.la
libchannels_la_SOURCES = channel.c \
fd.c \
file.c \
generic.c \
tcp.c \
tty.c \
xterm.c \
channel.h \
fd.h \
file.h \
generic.h \
tcp.h \
tty.h \
xterm.h
 
all: all-am
 
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu peripheral/channels/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu peripheral/channels/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
 
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
 
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libchannels.la: $(libchannels_la_OBJECTS) $(libchannels_la_DEPENDENCIES)
$(LINK) $(libchannels_la_OBJECTS) $(libchannels_la_LIBADD) $(LIBS)
 
mostlyclean-compile:
-rm -f *.$(OBJEXT)
 
distclean-compile:
-rm -f *.tab.c
 
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tty.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xterm.Plo@am__quote@
 
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
 
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
 
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
 
mostlyclean-libtool:
-rm -f *.lo
 
clean-libtool:
-rm -rf .libs _libs
 
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
 
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
 
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
 
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
 
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
 
clean-generic:
 
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
 
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
 
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
 
dvi: dvi-am
 
dvi-am:
 
html: html-am
 
html-am:
 
info: info-am
 
info-am:
 
install-data-am:
 
install-dvi: install-dvi-am
 
install-dvi-am:
 
install-exec-am:
 
install-html: install-html-am
 
install-html-am:
 
install-info: install-info-am
 
install-info-am:
 
install-man:
 
install-pdf: install-pdf-am
 
install-pdf-am:
 
install-ps: install-ps-am
 
install-ps-am:
 
installcheck-am:
 
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
 
mostlyclean: mostlyclean-am
 
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
 
pdf: pdf-am
 
pdf-am:
 
ps: ps-am
 
ps-am:
 
uninstall-am:
 
.MAKE: install-am install-strip
 
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am
 
 
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
/xterm.c
0,0 → 1,288
/* xterm.c -- Definition of functions and structures for
peripheral to communicate with host through an xterm.
Inspired from SWI-Prolog by Jan Wielemaker (GPL too)
even if there is really few in common.
Copyright (C) 2002 Richard Prescott <rip@step.polymtl.ca>
Copyright (C) 2008 Embecosm Limited
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
This file is part of OpenRISC 1000 Architectural Simulator.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>. */
 
 
/* This program is commented throughout in a fashion suitable for processing
with Doxygen. */
 
 
/* Autoconf and/or portability configuration */
#include "config.h"
#include "port.h"
 
/* System includes */
#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) && defined(HAVE_PTSNAME)
#endif
 
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <termios.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
 
#if HAVE_SYS_STROPTS_H
#include <sys/stropts.h> /* I_PUSH ioctl */
#endif
 
#if HAVE_BASENAME
#include <libgen.h> /* basename() */
#endif
 
/* Package includes */
#include "channel.h"
#include "generic.h"
#include "fd.h"
 
/*! Data structure to represent the connection to the xterm */
struct xterm_channel
{
struct fd_channel fds;
int pid;
char **argv;
};
 
/* Forward declaration of static functions */
static void xterm_close (void *data);
static void *xterm_init (const char *input);
static int xterm_open (void *data);
 
/*! Global data structure with the xterm interface functions */
struct channel_ops xterm_channel_ops = {
.init = xterm_init,
.open = xterm_open,
.close = xterm_close,
.read = fd_read,
.write = fd_write,
.free = generic_free,
};
 
 
#if !(HAVE_BASENAME)
static char *
basename (const char *filename)
{
char *p = strrchr (filename, '/');
 
return p ? p + 1 : (char *) filename;
}
#endif /* HAVE_BASENAME */
 
static void
xterm_close (void *data)
{
struct xterm_channel *xt = data;
 
if (!xt)
return;
 
if (xt->fds.fdin != -1)
close (xt->fds.fdin);
 
if (xt->pid != -1)
{
kill (xt->pid, SIGKILL);
waitpid (xt->pid, NULL, 0);
}
 
if (xt->argv)
free (xt->argv);
 
xt->fds.fdin = -1;
xt->fds.fdout = -1;
xt->pid = -1;
xt->argv = NULL;
 
}
 
#if defined(HAVE_ON_EXIT)
static void
xterm_exit (int i, void *data)
{
xterm_close (data);
}
#endif
 
#define MAX_XTERM_ARGS 100
static void *
xterm_init (const char *input)
{
struct xterm_channel *retval = malloc (sizeof (struct xterm_channel));
if (retval)
{
int i;
char *arglist;
 
retval->fds.fdin = -1;
retval->fds.fdout = -1;
retval->pid = -1;
 
#if defined(HAVE_ON_EXIT)
/* reset cause exit(1), leaving an xterm opened */
on_exit (xterm_exit, retval);
#endif
 
i = 2;
arglist = (char *) input;
retval->argv = malloc (sizeof (char *) * MAX_XTERM_ARGS);
if (!retval->argv)
{
free (retval);
return NULL;
}
/* Assume xterm arguments are separated by whitespace */
while ((retval->argv[i++] = strtok (arglist, " \t\n")))
{
arglist = NULL;
if (i == MAX_XTERM_ARGS - 1)
{
free (retval);
return NULL;
}
}
 
}
return (void *) retval;
}
 
 
 
static int
xterm_open (void *data)
{
#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) && defined(HAVE_PTSNAME)
struct xterm_channel *xt = data;
int master, retval;
char *slavename;
struct termios termio;
char arg[64], *fin;
 
if (!data)
{
errno = ENODEV;
return -1;
}
 
master = open ("/dev/ptmx", O_RDWR);
 
if (master < 0)
return -1;
 
grantpt (master);
unlockpt (master);
slavename = (char *) ptsname (master);
 
if (!slavename)
{
errno = ENOTTY;
goto closemastererror;
}
 
xt->fds.fdout = xt->fds.fdin = open (slavename, O_RDWR);
if (xt->fds.fdout < 0)
goto closemastererror;
 
#if HAVE_DECL_I_PUSH
/* These modules must be pushed onto the stream for some non-Linux and
non-Cygwin operating systems. */
retval = ioctl (xt->fds.fdin, I_PUSH, "ptem");
if (retval < 0)
goto closeslaveerror;
 
retval = ioctl (xt->fds.fdin, I_PUSH, "ldterm");
if (retval < 0)
goto closeslaveerror;
#endif
 
retval = tcgetattr (xt->fds.fdin, &termio);
if (retval < 0)
goto closeslaveerror;
termio.c_lflag &= ~ECHO;
retval = tcsetattr (xt->fds.fdin, TCSADRAIN, &termio);
if (retval < 0)
goto closeslaveerror;
 
xt->pid = fork ();
 
if (xt->pid == -1)
goto closeslaveerror;
 
if (xt->pid == 0)
{
/* Ctrl-C on sim still kill the xterm, grrr */
signal (SIGINT, SIG_IGN);
 
fin = slavename + strlen (slavename) - 2;
if (strchr (fin, '/'))
{
sprintf (arg, "-S%s/%d", basename (slavename), master);
}
else
{
sprintf (arg, "-S%c%c%d", fin[0], fin[1], master);
}
xt->argv[0] = "xterm";
xt->argv[1] = arg;
execvp ("xterm", xt->argv);
if (write (master, "\n", 1) < 0) /* Don't ignore result */
{
printf ("ERROR: xterm: write failed\n");
}
exit (1);
}
 
do
retval = read (xt->fds.fdin, &arg, 1);
while (retval >= 0 && arg[0] != '\n');
if (retval < 0)
goto closeslaveerror;
 
termio.c_lflag |= ECHO;
retval = tcsetattr (xt->fds.fdin, TCSADRAIN, &termio);
 
if (retval < 0)
goto closeslaveerror;
 
return 0;
 
closeslaveerror:
close (xt->fds.fdin);
 
closemastererror:
close (master);
xt->pid = xt->fds.fdin = xt->fds.fdout = -1;
return -1;
 
#else
/* I don't see how this stuff should be working on a system that doesn't know
grantpt(), unlockpt(), ptsname(). Mac OS X also does not have /dev/ptmx.
-hpanther
*/
return -1;
#endif
}
xterm.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fd.h =================================================================== --- fd.h (nonexistent) +++ fd.h (revision 347) @@ -0,0 +1,50 @@ +/* fd.h -- Declaration of functions for peripheral to + * communicate with host through file descriptors + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef FD__H +#define FD__H + +/*! Data structure to represent a channel through file descriptors */ +struct fd_channel +{ + int fdin; + int fdout; +}; + +/* Global data structures */ +extern struct channel_ops fd_channel_ops; + +/* Function prototypes for external use */ +extern int fd_read (void *data, + char *buffer, + int size); +extern int fd_write (void *data, + const char *buffer, + int size); + +#endif /* FD__H */ +
fd.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: xterm.h =================================================================== --- xterm.h (nonexistent) +++ xterm.h (revision 347) @@ -0,0 +1,31 @@ +/* xterm.h -- peripheral communication with host through an xterm header + + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef XTERM__H +#define XTERM__H + +extern struct channel_ops xterm_channel_ops; + +#endif /* XTERM__H */
xterm.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: channel.c =================================================================== --- channel.c (nonexistent) +++ channel.c (revision 347) @@ -0,0 +1,194 @@ +/* channel.c -- Definition of types and structures for + peripherals to communicate with host. Adapted from UML. + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include + +/* Package includes */ +#include "channel.h" +#include "fd.h" +#include "file.h" +#include "tcp.h" +#include "tty.h" +#include "xterm.h" + +struct channel_factory +{ + const char *name; + const struct channel_ops *ops; + struct channel_factory *next; +}; + +static struct channel_factory preloaded[] = { + {"fd", &fd_channel_ops, &preloaded[1]}, + {"file", &file_channel_ops, &preloaded[2]}, + {"xterm", &xterm_channel_ops, &preloaded[3]}, + {"tcp", &tcp_channel_ops, &preloaded[4]}, + {"tty", &tty_channel_ops, NULL} +}; + +static struct channel_factory *head = &preloaded[0]; + +/* Forward declaration of static functions */ +static struct channel_factory *find_channel_factory (const char *name); + +struct channel * +channel_init (const char *descriptor) +{ + struct channel *retval; + struct channel_factory *current; + char *args, *name; + int count; + + if (!descriptor) + { + return NULL; + } + + retval = (struct channel *) calloc (1, sizeof (struct channel)); + + if (!retval) + { + perror (descriptor); + exit (1); + } + + args = strchr (descriptor, ':'); + + if (args) + { + count = args - descriptor; + args++; + } + else + { + count = strlen (descriptor); + } + + name = (char *) strndup (descriptor, count); + + if (!name) + { + perror (name); + exit (1); + } + + current = find_channel_factory (name); + + if (!current) + { + errno = ENODEV; + perror (descriptor); + exit (1); + } + + retval->ops = current->ops; + + free (name); + + if (!retval->ops) + { + errno = ENODEV; + perror (descriptor); + exit (1); + } + + if (retval->ops->init) + { + retval->data = (retval->ops->init) (args); + + if (!retval->data) + { + perror (descriptor); + exit (1); + } + } + + return retval; +} + +int +channel_open (struct channel *channel) +{ + if (channel && channel->ops && channel->ops->open) + { + return (channel->ops->open) (channel->data); + } + errno = ENOSYS; + return -1; +} + +int +channel_read (struct channel *channel, char *buffer, int size) +{ + if (channel && channel->ops && channel->ops->read) + { + return (channel->ops->read) (channel->data, buffer, size); + } + errno = ENOSYS; + return -1; +} + +int +channel_write (struct channel *channel, const char *buffer, int size) +{ + if (channel && channel->ops && channel->ops->write) + { + return (channel->ops->write) (channel->data, buffer, size); + } + errno = ENOSYS; + return -1; +} + +void +channel_close (struct channel *channel) +{ + if (channel && channel->ops && channel->ops->close) + { + (channel->ops->close) (channel->data); + } +} + +static struct channel_factory * +find_channel_factory (const char *name) +{ + struct channel_factory *current = head; + + current = head; + while (current && strcmp (current->name, name)) + { + current = current->next; + } + + return current; +}
channel.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: generic.c =================================================================== --- generic.c (nonexistent) +++ generic.c (revision 347) @@ -0,0 +1,62 @@ +/* generic.c -- Definition of generic functions for peripheral to + * communicate with host + + Copyright (C) 2002 Richard Prescott + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" + +/* System includes */ +#include +#include + + +int +generic_open (void *data) +{ + if (data) + { + return 0; + } + errno = ENODEV; + return -1; +} + + +void +generic_close (void *data) +{ + return; +} + + +void +generic_free (void *data) +{ + if (data) + { + free (data); + } +}
generic.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: channel.h =================================================================== --- channel.h (nonexistent) +++ channel.h (revision 347) @@ -0,0 +1,63 @@ +/* channel.h -- Definition of types and structures for + peripheral to communicate with host. Addapted from UML. + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef CHANNEL__H +#define CHANNEL__H + +/*! A data structure representing all the functions required on a channel */ +struct channel_ops +{ + void *(*init) (const char *); + int (*open) (void *); + void (*close) (void *); + int (*read) (void *, char *, int); + int (*write) (void *, const char *, int); + void (*free) (void *); + int (*isok) (void *); + char *(*status) (void *); +}; + +/*! A data structure representing a channel. Its operations and data */ +struct channel +{ + const struct channel_ops *ops; + void *data; +}; + + +/* Function prototypes for external use */ +extern struct channel *channel_init (const char *descriptor); +extern int channel_open (struct channel *channel); +extern int channel_read (struct channel *channel, + char *buffer, + int size); +extern int channel_write (struct channel *channel, + const char *buffer, + int size); +extern void channel_close (struct channel *channel); + +#endif /* CHANNEL__H */
channel.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: file.c =================================================================== --- file.c (nonexistent) +++ file.c (revision 347) @@ -0,0 +1,172 @@ +/* file.c -- Definition of functions and structures for + peripheral to communicate with host through files + + Copyright (C) 2002 Richard Prescott + Copyright (C) 1999 Damjan Lampret, lampret@opencores.org + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include +#include + +/* Package includes */ +#include "channel.h" +#include "fd.h" + +/*! Data structure representing a channel to/from a file */ +struct file_channel +{ + struct fd_channel fds; + char *namein; + char *nameout; +}; + + +/* Forward declarations of static routines */ +static void *file_init (const char *args); +static int file_open (void *data); +static void file_close (void *data); +static void file_free (void *data); + +/*! Data structure with all the operations for communicating with a file + channel */ +struct channel_ops file_channel_ops = { + .init = file_init, + .open = file_open, + .close = file_close, + .read = fd_read, + .write = fd_write, + .free = file_free, +}; + + +static void * +file_init (const char *args) +{ + struct file_channel *retval; + char *nameout; + + if (!args) + { + errno = EINVAL; + return NULL; + } + + retval = (struct file_channel *) calloc (1, sizeof (struct file_channel)); + + if (!retval) + { + return NULL; + } + + retval->fds.fdin = -1; + retval->fds.fdout = -1; + + nameout = strchr (args, ','); + + if (nameout) + { + retval->namein = strndup (args, nameout - args); + retval->nameout = strdup (nameout + 1); + } + else + { + retval->nameout = retval->namein = strdup (args); + } + + return (void *) retval; +} + +static int +file_open (void *data) +{ + struct file_channel *files = (struct file_channel *) data; + + if (!files) + { + errno = ENODEV; + return -1; + } + + if (files->namein == files->nameout) + { + /* if we have the same name in and out + * it cannot (logically) be a regular files. + * so we wont create one + */ + files->fds.fdin = files->fds.fdout = open (files->namein, O_RDWR); + + return files->fds.fdin < 0 ? -1 : 0; + } + + + files->fds.fdin = open (files->namein, O_RDONLY | O_CREAT, 0664); + + if (files->fds.fdin < 0) + return -1; + + files->fds.fdout = open (files->nameout, O_WRONLY | O_CREAT, 0664); + + if (files->fds.fdout < 0) + { + close (files->fds.fdout); + files->fds.fdout = -1; + return -1; + } + + return 0; +} + +static void +file_close (void *data) +{ + struct file_channel *files = (struct file_channel *) data; + + if (files->fds.fdin != files->fds.fdout) + close (files->fds.fdin); + + close (files->fds.fdout); + + files->fds.fdin = -1; + files->fds.fdout = -1; +} + +static void +file_free (void *data) +{ + struct file_channel *files = (struct file_channel *) data; + + if (files->namein != files->nameout) + free (files->namein); + + free (files->nameout); + + free (files); +}
file.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tty.c =================================================================== --- tty.c (nonexistent) +++ tty.c (revision 347) @@ -0,0 +1,222 @@ +/* tty.c -- Definition of functions for peripheral to + * communicate with host via a tty. + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include +#include +#include + +/* Package includes */ +#include "channel.h" +#include "generic.h" +#include "fd.h" + +/* Default parameters if not specified in config file */ +#define DEFAULT_BAUD B19200 +#define DEFAULT_TTY_DEVICE "/dev/ttyS0" + +/*! Data structure representing a TTY channel */ +struct tty_channel +{ + struct fd_channel fds; +}; + +/*! Table of Baud rates */ +static const struct +{ + char *name; + int value; +} baud_table[] = +{ + { + "50", B50}, + { + "2400", B2400}, + { + "4800", B4800}, + { + "9600", B9600}, + { + "19200", B19200}, + { + "38400", B38400}, + { + "115200", B115200}, + { + "230400", B230400}, + { + 0, 0} +}; + +/* Forward declaration of static functions */ +static void *tty_init (const char *input); +static int tty_open (void *data); + +/*! Global data structure representing the operations on a TTY channel */ +struct channel_ops tty_channel_ops = { + .init = tty_init, + .open = tty_open, + .close = generic_close, + .read = fd_read, + .write = fd_write, + .free = generic_free, +}; + + +/* Convert baud rate string to termio baud rate constant */ +static int +parse_baud (char *baud_string) +{ + int i; + for (i = 0; baud_table[i].name; i++) + { + if (!strcmp (baud_table[i].name, baud_string)) + return baud_table[i].value; + } + + fprintf (stderr, "Error: unknown baud rate: %s\n", baud_string); + fprintf (stderr, " Known baud rates: "); + + for (i = 0; baud_table[i].name; i++) + { + fprintf (stderr, "%s%s", baud_table[i].name, + baud_table[i + 1].name ? ", " : "\n"); + } + return B0; +} + +static void * +tty_init (const char *input) +{ + int fd = 0, baud; + char *param_name, *param_value, *device; + struct termios options; + struct tty_channel *channel; + + channel = (struct tty_channel *) malloc (sizeof (struct tty_channel)); + if (!channel) + return NULL; + + /* Make a copy of config string, because we're about to mutate it */ + input = strdup (input); + if (!input) + goto error; + + baud = DEFAULT_BAUD; + device = DEFAULT_TTY_DEVICE; + + /* Parse command-line parameters + Command line looks like name1=value1,name2,name3=value3,... */ + while ((param_name = strtok ((char *) input, ","))) + { + + input = NULL; + + /* Parse a parameter's name and value */ + param_value = strchr (param_name, '='); + if (param_value != NULL) + { + *param_value = '\0'; + param_value++; /* Advance past '=' character */ + } + + if (!strcmp (param_name, "baud") && param_value) + { + baud = parse_baud (param_value); + if (baud == B0) + { + goto error; + } + } + else if (!strcmp (param_name, "device")) + { + device = param_value; + } + else + { + fprintf (stderr, "error: unknown tty channel parameter \"%s\"\n", + param_name); + goto error; + } + } + + fd = open (device, O_RDWR); + if (fd < 0) + goto error; + + /* Get the current options for the port... */ + if (tcgetattr (fd, &options) < 0) + goto error; + + /* Set the serial baud rate */ + cfsetispeed (&options, baud); + cfsetospeed (&options, baud); + + /* Enable the receiver and set local mode... */ + + /* cfmakeraw(&options); + * + * cygwin lacks cfmakeraw(), just do it explicitly + */ + options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON); + options.c_oflag &= ~OPOST; + options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + options.c_cflag &= ~(CSIZE | PARENB); + options.c_cflag |= CS8; + + options.c_cflag |= (CLOCAL | CREAD); + + + /* Set the new options for the port... */ + if (tcsetattr (fd, TCSANOW, &options) < 0) + goto error; + + channel->fds.fdin = channel->fds.fdout = fd; + free ((void *) input); + return channel; + +error: + if (fd > 0) + close (fd); + free (channel); + if (input) + free ((void *) input); + return NULL; +} + +static int +tty_open (void *data) +{ + return 0; +}
tty.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: generic.h =================================================================== --- generic.h (nonexistent) +++ generic.h (revision 347) @@ -0,0 +1,35 @@ +/* generic.h -- Declaration of generic functions for peripheral to + communicate with host + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +#ifndef GENERIC__H +#define GENERIC__H + +/* Function prototypes for external use */ +extern int generic_open (void *data); +extern void generic_close (void *data); +extern void generic_free (void *data); + +#endif /* GENERIC__H */
generic.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: file.h =================================================================== --- file.h (nonexistent) +++ file.h (revision 347) @@ -0,0 +1,32 @@ +/* file.h -- Header for functions and structures for + peripheral to communicate with host through files + + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + +#ifndef FILE__H +#define FILE__H + +/* Global data structures for external use */ +extern struct channel_ops file_channel_ops; + +#endif /* FILE__H */
file.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tty.h =================================================================== --- tty.h (nonexistent) +++ tty.h (revision 347) @@ -0,0 +1,33 @@ +/* tty.h -- Header for functions for peripheral to + * communicate with host via a tty. + + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef TTY__H +#define TTY__H + +/* Global data structures for external use */ +extern struct channel_ops tty_channel_ops; + +#endif /* TTY__H */
tty.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tcp.c =================================================================== --- tcp.c (nonexistent) +++ tcp.c (revision 347) @@ -0,0 +1,211 @@ +/* tcp.c -- Definition of functions for peripheral to + * communicate with host via a tcp socket. + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* Package includes */ +#include "channel.h" +#include "generic.h" +#include "fd.h" + +/*! Structure to represent a TCP/IP channel */ +struct tcp_channel +{ + struct fd_channel fds; + int socket_fd; /* Socket to listen to */ + int port_number; /* TCP port number */ + int connected; /* If 0, no remote endpoint yet */ + int nonblocking; /* If 0, read/write will block until + remote client connects */ +}; + +/* Forward declarations of static functions */ +static void *tcp_init (const char *input); +static int tcp_open (void *data); +static int tcp_read (void *data, + char *buffer, + int size); +static int tcp_write (void *data, + const char *buffer, + int size); + +/*! Data structure holding all the operations for a TCP/IP channel */ +struct channel_ops tcp_channel_ops = { + .init = tcp_init, + .open = tcp_open, + .close = generic_close, + .read = tcp_read, + .write = tcp_write, + .free = generic_free, +}; + +static void * +tcp_init (const char *input) +{ + int port_number, fd, flags; + struct sockaddr_in local_ip; + struct tcp_channel *channel = + (struct tcp_channel *) malloc (sizeof (struct tcp_channel)); + if (!channel) + return NULL; + + fd = 0; + channel->nonblocking = 1; + channel->fds.fdin = -1; + channel->fds.fdout = -1; + channel->socket_fd = -1; + channel->port_number = -1; + + port_number = atoi (input); + if (port_number == 0) + goto error; + + fd = socket (AF_INET, SOCK_STREAM, 0); + if (fd < 0) + goto error; + + flags = 1; + if (setsockopt + (fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &flags, sizeof (int)) < 0) + { + perror ("Can not set SO_REUSEADDR option on channel socket"); + goto error; + } + + memset (&local_ip, 0, sizeof (local_ip)); + local_ip.sin_family = AF_INET; + local_ip.sin_addr.s_addr = htonl (INADDR_ANY); + local_ip.sin_port = htons (port_number); + if (bind (fd, (struct sockaddr *) &local_ip, sizeof (local_ip)) < 0) + { + perror ("Can't bind local address"); + goto error; + } + + if (channel->nonblocking) + { + if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0) + { + perror ("Can not make channel socket non-blocking"); + goto error; + } + } + + if (listen (fd, 1) < 0) + goto error; + + channel->socket_fd = fd; + channel->port_number = port_number; + channel->connected = 0; + return (void *) channel; + +error: + if (fd) + close (fd); + free (channel); + return NULL; +} + +static int +tcp_open (void *data) +{ + /* Socket is opened lazily, upon first read or write, so do nothing here */ + return 0; +} + + +static int +wait_for_tcp_connect (struct tcp_channel *channel) +{ + int fd; + socklen_t sizeof_remote_ip; + struct sockaddr_in remote_ip; + + sizeof_remote_ip = sizeof (remote_ip); + fd = + accept (channel->socket_fd, (struct sockaddr *) &remote_ip, + &sizeof_remote_ip); + if (fd < 0) + { + if (channel->nonblocking) + { + /* Not an error if there is not yet a remote connection - try again later */ + if (errno == EAGAIN) + return 0; + } + perror ("Couldn't accept connection"); + return -1; + } + + channel->fds.fdin = channel->fds.fdout = fd; + close (channel->socket_fd); + channel->socket_fd = -1; + channel->connected = 1; + return 1; +} + +static int +tcp_read (void *data, char *buffer, int size) +{ + struct tcp_channel *channel = data; + + /* Lazily connect to tcp partner on read/write */ + if (!channel->connected) + { + int retval = wait_for_tcp_connect (data); + if (retval <= 0) + return retval; + } + return fd_read (data, buffer, size); +} + +static int +tcp_write (void *data, const char *buffer, int size) +{ + struct tcp_channel *channel = data; + + /* Lazily connect to tcp partner on read/write */ + if (!channel->connected) + { + int retval = wait_for_tcp_connect (data); + if (retval < 0) + return retval; + } + return fd_write (data, buffer, size); +}
tcp.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: Makefile.am =================================================================== --- Makefile.am (nonexistent) +++ Makefile.am (revision 347) @@ -0,0 +1,38 @@ +# Makefile -- Makefile for peripherals channels to host +# +# Copyright (C) 2002 Richard Prescott +# Copyright (C) 2008 Embecosm Limited +# +# Contributor Jeremy Bennett +# +# This file is part of OpenRISC 1000 Architectural Simulator. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + + +noinst_LTLIBRARIES = libchannels.la +libchannels_la_SOURCES = channel.c \ + fd.c \ + file.c \ + generic.c \ + tcp.c \ + tty.c \ + xterm.c \ + channel.h \ + fd.h \ + file.h \ + generic.h \ + tcp.h \ + tty.h \ + xterm.h
Makefile.am Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fd.c =================================================================== --- fd.c (nonexistent) +++ fd.c (revision 347) @@ -0,0 +1,187 @@ +/* fd.c -- Definition of functions and structures for + peripheral to communicate with host through file descriptors + + Copyright (C) 2002 Richard Prescott + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +/* Autoconf and/or portability configuration */ +#include "config.h" +#include "port.h" + +/* System includes */ +#include +#include +#include +#include +#include +#include + +/* Package includes */ +#include "fd.h" +#include "channel.h" +#include "generic.h" + + +/* Forward declarations of static functions */ +static void *fd_init (const char *args); +static int fd_isok (void *data); +static char *fd_status (void *data); + +/*! Global data structure representing the operations for communicating + through a file descriptor channel */ +struct channel_ops fd_channel_ops = { + .init = fd_init, + .open = generic_open, + .close = generic_close, + .read = fd_read, + .write = fd_write, + .free = generic_free, + .isok = fd_isok, + .status = fd_status, +}; + + +static void * +fd_init (const char *args) +{ + struct fd_channel *retval; + + retval = (struct fd_channel *) calloc (1, sizeof (struct fd_channel)); + + if (!retval) + { + return NULL; + } + + + retval->fdin = atoi (args); /* so 0 if garbage */ + /* TODO: strtoul */ + + args = strchr (args, ','); + + if (args) + { + retval->fdout = atoi (args + 1); + } + else + { + retval->fdout = retval->fdin; + } + + return (void *) retval; +} + +int +fd_read (void *data, char *buffer, int size) +{ + struct fd_channel *fds = (struct fd_channel *) data; + struct timeval timeout = { 0, 0 }; + fd_set rfds; + int retval; + + if (!fds) + { + errno = ENODEV; + return -1; + } + + /* Loop, to allow for select being interrupted */ + do + { + FD_ZERO (&rfds); + FD_SET (fds->fdin, &rfds); + + retval = select (fds->fdin + 1, &rfds, NULL, NULL, &timeout); + } + while ((retval < 0) && (EINTR == errno)); + + if (retval <= 0) + return retval; + + /* Loop, to allow for select being interrupted */ + do + { + retval = read (fds->fdin, buffer, size); + } + while ((retval < 0) && (EINTR == errno)); + + return retval; +} + +int +fd_write (void *data, const char *buffer, int size) +{ + struct fd_channel *fds = (struct fd_channel *) data; + if (fds) + { + return write (fds->fdout, buffer, size); + } + errno = ENODEV; + return -1; +} + +static int +fd_isok (void *data) +{ + struct fd_channel *fds = (struct fd_channel *) data; + if (fds) + { + return fds->fdout != -1 && fds->fdin != -1; + } + return 0; +} + +static int +fd_status_fd (int fd, char *str, int size) +{ + if (fd == -1) + return snprintf (str, size, "closed"); + + return snprintf (str, size, "opened(fd=%d)", fd); +} + +static char * +fd_status (void *data) +{ + static char retval[256]; + int index = 0; + + struct fd_channel *fds = (struct fd_channel *) data; + if (fds) + { + index += snprintf (retval + index, sizeof (retval) - index, "in "); + index += + fd_status_fd (fds->fdin, retval + index, sizeof (retval) - index); + + index += snprintf (retval + index, sizeof (retval) - index, "out "); + index += + fd_status_fd (fds->fdout, retval + index, sizeof (retval) - index); + } + else + { + snprintf (retval, sizeof (retval), "(null)"); + } + return retval; +} +
fd.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: tcp.h =================================================================== --- tcp.h (nonexistent) +++ tcp.h (revision 347) @@ -0,0 +1,33 @@ +/* tcp.h -- Header for functions for peripheral to + communicate with host via a TCP/IP socket. + + Copyright (C) 2008 Embecosm Limited + + Contributor Jeremy Bennett + + This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . */ + +/* This program is commented throughout in a fashion suitable for processing + with Doxygen. */ + + +#ifndef TCP__H +#define TCP__H + +/* Global data structures for external use */ +extern struct channel_ops tcp_channel_ops; + +#endif /* TCP__H */
tcp.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: .cvsignore =================================================================== --- .cvsignore (nonexistent) +++ .cvsignore (revision 347) @@ -0,0 +1,2 @@ +Makefile +.deps

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.