initial push
This commit is contained in:
5
m68k/server/.cvsignore
Normal file
5
m68k/server/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
bdmd
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
||||
19
m68k/server/ChangeLog
Normal file
19
m68k/server/ChangeLog
Normal file
@@ -0,0 +1,19 @@
|
||||
2000-11-15 Chris Johns <cjohns@cybertec.com.au>
|
||||
|
||||
* bdmServer.c:
|
||||
Make the ioctl table independent of the operating system.
|
||||
|
||||
2000-08-31 Chris Johns <ccj@acm.org>
|
||||
|
||||
* bdmServer.c: Made the ioctl numbers os independent.
|
||||
|
||||
* Makefile: Cleaned up.
|
||||
|
||||
22000-05-15 Chris Johns <ccj@acm.org>
|
||||
|
||||
* bdmServer.c: Added the failing path the open error message.
|
||||
|
||||
2000-03-30 Chris Johns <ccj@acm.org>
|
||||
|
||||
* bdmServer.c, Makefile, README, xmalloc.c: New file.
|
||||
|
||||
28
m68k/server/Makefile.am
Normal file
28
m68k/server/Makefile.am
Normal file
@@ -0,0 +1,28 @@
|
||||
##
|
||||
## $Id: Makefile.am,v 1.4 2008/03/06 10:35:40 cjohns Exp $
|
||||
##
|
||||
## This file is part of a free BDM package
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/../lib -I$(srcdir)/../driver
|
||||
|
||||
if TBLCF_USB
|
||||
TBLCF_USB_LIB = $(top_builddir)/tblcf/libtblcf.a
|
||||
endif
|
||||
|
||||
if LIBUSB_PATH
|
||||
AM_CPPFLAGS += -I@LIBUSB_INCLUDE_DIR@
|
||||
AM_LDFLAGS = -L@LIBUSB_LIB_DIR@
|
||||
endif
|
||||
|
||||
sbin_PROGRAMS = bdmd
|
||||
|
||||
bdmd_SOURCES = \
|
||||
bdmServer.c \
|
||||
xmalloc.c
|
||||
bdmd_LDADD = ../lib/libBDM.a $(TBLCF_USB_LIB)
|
||||
444
m68k/server/Makefile.in
Normal file
444
m68k/server/Makefile.in
Normal file
@@ -0,0 +1,444 @@
|
||||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006 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@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@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@
|
||||
@LIBUSB_PATH_TRUE@am__append_1 = -I@LIBUSB_INCLUDE_DIR@
|
||||
sbin_PROGRAMS = bdmd$(EXEEXT)
|
||||
subdir = server
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(sbindir)"
|
||||
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(sbin_PROGRAMS)
|
||||
am_bdmd_OBJECTS = bdmServer.$(OBJEXT) xmalloc.$(OBJEXT)
|
||||
bdmd_OBJECTS = $(am_bdmd_OBJECTS)
|
||||
bdmd_DEPENDENCIES = ../lib/libBDM.a $(TBLCF_USB_LIB)
|
||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(bdmd_SOURCES)
|
||||
DIST_SOURCES = $(bdmd_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BDM_SUBDIRS = @BDM_SUBDIRS@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FLASH_PLUGIN_GCC = @FLASH_PLUGIN_GCC@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LEX = @LEX@
|
||||
LEXLIB = @LEXLIB@
|
||||
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBUSB_INCLUDE_DIR = @LIBUSB_INCLUDE_DIR@
|
||||
LIBUSB_LIB_DIR = @LIBUSB_LIB_DIR@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
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@
|
||||
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@
|
||||
flash_plugin_cc = @flash_plugin_cc@
|
||||
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@
|
||||
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_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CPPFLAGS = -I$(srcdir)/../lib -I$(srcdir)/../driver $(am__append_1)
|
||||
@TBLCF_USB_TRUE@TBLCF_USB_LIB = $(top_builddir)/tblcf/libtblcf.a
|
||||
@LIBUSB_PATH_TRUE@AM_LDFLAGS = -L@LIBUSB_LIB_DIR@
|
||||
bdmd_SOURCES = \
|
||||
bdmServer.c \
|
||||
xmalloc.c
|
||||
|
||||
bdmd_LDADD = ../lib/libBDM.a $(TBLCF_USB_LIB)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .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 \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign server/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign server/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
|
||||
install-sbinPROGRAMS: $(sbin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
|
||||
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
|
||||
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
if test -f $$p \
|
||||
; then \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-sbinPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f '$(DESTDIR)$(sbindir)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(sbindir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-sbinPROGRAMS:
|
||||
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
|
||||
bdmd$(EXEEXT): $(bdmd_OBJECTS) $(bdmd_DEPENDENCIES)
|
||||
@rm -f bdmd$(EXEEXT)
|
||||
$(LINK) $(bdmd_OBJECTS) $(bdmd_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bdmServer.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ mv -f $(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@ mv -f $(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) '$<'`
|
||||
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& 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 $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$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 $(PROGRAMS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(sbindir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
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)
|
||||
|
||||
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-sbinPROGRAMS 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
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am: install-sbinPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: 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
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-sbinPROGRAMS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-sbinPROGRAMS ctags distclean distclean-compile \
|
||||
distclean-generic 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-sbinPROGRAMS install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-sbinPROGRAMS
|
||||
|
||||
# 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:
|
||||
769
m68k/server/bdmServer.c
Normal file
769
m68k/server/bdmServer.c
Normal file
@@ -0,0 +1,769 @@
|
||||
/*
|
||||
* Motorola Background Debug Mode Remote Server
|
||||
* Copyright (C) 1994, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
* Contributed by Chris Johns
|
||||
*
|
||||
* Pieces of code are taken from the gnatsd amd gdbserver.
|
||||
*
|
||||
* 31-11-1999 Chris Johns (ccj@acm.org)
|
||||
*
|
||||
* Chris Johns
|
||||
* Objective Design Systems
|
||||
* 35 Cairo Street
|
||||
* Cammeray, Sydney, 2062, Australia
|
||||
*
|
||||
* ccj@acm.org
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <BDMlib.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __CYGWIN32__
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
char *xmalloc (unsigned n);
|
||||
void xfree (char *p);
|
||||
|
||||
/*
|
||||
* This should be the same as the client.
|
||||
*/
|
||||
|
||||
#define BDM_SERVER_TIMEOUT (5)
|
||||
#define BDM_SERVER_BUF_SIZE (4096)
|
||||
|
||||
/*
|
||||
* Local data.
|
||||
*/
|
||||
static const char *version_string = "1.0.0";
|
||||
static char myname[MAXHOSTNAMELEN];
|
||||
static char *current_host;
|
||||
static char *current_addr;
|
||||
static char *program_name;
|
||||
static int debug = 0;
|
||||
|
||||
/*
|
||||
* Define the messages between the client and the server.
|
||||
*/
|
||||
|
||||
enum bdm_message_id
|
||||
{
|
||||
HELO,
|
||||
SRVCTL,
|
||||
IOINT,
|
||||
IOCMD,
|
||||
IOIO,
|
||||
READ,
|
||||
WRITE,
|
||||
QUIT,
|
||||
INVALID
|
||||
};
|
||||
|
||||
struct bdm_message
|
||||
{
|
||||
char *label;
|
||||
enum bdm_message_id id;
|
||||
};
|
||||
|
||||
struct bdm_message messages[] =
|
||||
{
|
||||
{ "HELO", HELO },
|
||||
{ "SRVCTL", SRVCTL },
|
||||
{ "IOINT", IOINT },
|
||||
{ "IOCMD", IOCMD },
|
||||
{ "IOIO", IOIO},
|
||||
{ "READ", READ },
|
||||
{ "WRITE", WRITE },
|
||||
{ "QUIT", QUIT }
|
||||
};
|
||||
|
||||
/*
|
||||
* Ioctl code translation.
|
||||
*/
|
||||
static const int ioctl_code_table[] = {
|
||||
BDM_INIT,
|
||||
BDM_RESET_CHIP,
|
||||
BDM_RESTART_CHIP,
|
||||
BDM_STOP_CHIP,
|
||||
BDM_STEP_CHIP,
|
||||
BDM_GET_STATUS,
|
||||
BDM_SPEED,
|
||||
BDM_DEBUG,
|
||||
BDM_RELEASE_CHIP,
|
||||
BDM_GO,
|
||||
BDM_READ_REG,
|
||||
BDM_READ_SYSREG,
|
||||
BDM_READ_LONGWORD,
|
||||
BDM_READ_WORD,
|
||||
BDM_READ_BYTE,
|
||||
BDM_WRITE_REG,
|
||||
BDM_WRITE_SYSREG,
|
||||
BDM_WRITE_LONGWORD,
|
||||
BDM_WRITE_WORD,
|
||||
BDM_WRITE_BYTE,
|
||||
BDM_GET_DRV_VER,
|
||||
BDM_GET_CPU_TYPE,
|
||||
BDM_GET_IF_TYPE,
|
||||
BDM_GET_CF_PST, /* At the end to not break existing servers. */
|
||||
BDM_SET_CF_PST,
|
||||
BDM_READ_CTLREG,
|
||||
BDM_WRITE_CTLREG,
|
||||
BDM_READ_DBREG,
|
||||
BDM_WRITE_DBREG
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the name of the host.
|
||||
*/
|
||||
|
||||
char *
|
||||
get_name (struct in_addr *host)
|
||||
{
|
||||
char *buf;
|
||||
int i;
|
||||
struct hostent *hp;
|
||||
#ifdef h_addr
|
||||
char **pp;
|
||||
#endif
|
||||
|
||||
hp = gethostbyaddr ((char *) host, sizeof (host), AF_INET);
|
||||
|
||||
if (hp == NULL)
|
||||
return NULL;
|
||||
|
||||
i = strlen (hp->h_name);
|
||||
buf = (char *) xmalloc (i + 1);
|
||||
strcpy (buf, hp->h_name);
|
||||
hp = gethostbyname (buf);
|
||||
if (hp == NULL)
|
||||
return NULL;
|
||||
|
||||
#ifdef h_addr
|
||||
for (pp = hp->h_addr_list; *pp; pp++)
|
||||
if (memcmp ((char *) &host->s_addr, (char *) *pp, hp->h_length) == 0)
|
||||
break;
|
||||
if (*pp == NULL)
|
||||
return NULL;
|
||||
#else
|
||||
if (memcmp ((char *) &host->s_addr, (char *) hp->h_addr, hp->h_length) != 0)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start an inetd connection.
|
||||
*/
|
||||
|
||||
void
|
||||
start_connection ()
|
||||
{
|
||||
struct sockaddr_in s;
|
||||
unsigned int len;
|
||||
|
||||
len = sizeof (s);
|
||||
|
||||
if (getpeername (0, (struct sockaddr *) &s, &len) < 0)
|
||||
{
|
||||
if (!isatty (0))
|
||||
{
|
||||
syslog (LOG_ERR, "%s: can't get peername %m", "?");
|
||||
exit (1);
|
||||
}
|
||||
current_host = "stdin";
|
||||
current_addr = current_host;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s.sin_family != AF_INET)
|
||||
{
|
||||
syslog (LOG_ERR, "%s: bad address family %ld",
|
||||
"?", (long) s.sin_family);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
current_addr = (char *) inet_ntoa (s.sin_addr);
|
||||
current_host = get_name (&s.sin_addr);
|
||||
|
||||
if (!current_host) {
|
||||
current_host = current_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Message the message from the input handle.
|
||||
*/
|
||||
|
||||
int
|
||||
get_message (char *buf, int buf_len)
|
||||
{
|
||||
int numfds;
|
||||
fd_set readfds;
|
||||
|
||||
while (1) {
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (0, &readfds);
|
||||
|
||||
numfds = select (0 + 1, &readfds, 0, 0, 0);
|
||||
|
||||
if (numfds > 0) {
|
||||
int ret = read (0, buf, buf_len-1);
|
||||
if (ret>=0) buf[ret]=0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode the id to an ioctl number.
|
||||
*
|
||||
* Note, watch checking the return value. Check for -1 not < 0.
|
||||
*
|
||||
* We should have version number checks between the client and server
|
||||
* to avoid these numbers skewing.
|
||||
*/
|
||||
|
||||
int
|
||||
decode_id (unsigned long id)
|
||||
{
|
||||
if (id < (sizeof (ioctl_code_table) / sizeof (ioctl_code_table[0])))
|
||||
return ioctl_code_table[id];
|
||||
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode a message.
|
||||
*/
|
||||
|
||||
enum bdm_message_id
|
||||
decode_message (char *message)
|
||||
{
|
||||
unsigned id;
|
||||
char *c;
|
||||
char *s;
|
||||
|
||||
/*
|
||||
* Make the first field (the message label) uppercase.
|
||||
*/
|
||||
|
||||
s = strchr (message, ' ');
|
||||
if (!s)
|
||||
s = message + strlen (message);
|
||||
for (c = message; c < s; c++)
|
||||
*c = toupper (*c);
|
||||
|
||||
for (id = 0; id < (sizeof messages / sizeof (struct bdm_message)); id++)
|
||||
if (strncmp (message, messages[id].label, strlen (messages[id].label)) == 0)
|
||||
return messages[id].id;
|
||||
|
||||
syslog (LOG_INFO, "invalid message: %s", message);
|
||||
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the port using the requested device.
|
||||
*/
|
||||
|
||||
void
|
||||
helo (char *device)
|
||||
{
|
||||
device += sizeof "HELO";
|
||||
|
||||
if (bdmOpen (device) < 0) {
|
||||
syslog (LOG_INFO, "open error: %s (%d), opening `%s'",
|
||||
bdmErrorString (), errno, device);
|
||||
}
|
||||
printf ("HELO %d %s BDM server %s ready.", errno, myname, version_string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Server Control.
|
||||
*/
|
||||
|
||||
void
|
||||
server_control (char *message)
|
||||
{
|
||||
char *s = message + sizeof "SRVCTL";
|
||||
|
||||
if (strncmp (s, "DEBUG", sizeof "DEBUG" - 1) == 0) {
|
||||
s = strchr (s, '=');
|
||||
if (!s) {
|
||||
syslog (LOG_INFO, "srv-ctl error: invalid debug syntax (%s)", message);
|
||||
return;
|
||||
}
|
||||
s++;
|
||||
debug = strtoul (s, NULL, 0);
|
||||
syslog (LOG_INFO, "srv-ctl: debug level is %d", debug);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IO Int read/write.
|
||||
*/
|
||||
|
||||
void
|
||||
ioint (char *message)
|
||||
{
|
||||
int id;
|
||||
int code;
|
||||
int var;
|
||||
|
||||
message += sizeof "IOINT";
|
||||
id = strtoul (message, NULL, 0);
|
||||
message = strchr (message, ',') + 1;
|
||||
var = strtoul (message, NULL, 0);
|
||||
|
||||
code = decode_id (id);
|
||||
if (code == -1) {
|
||||
syslog (LOG_INFO, "ioint error: invalid ioctl id decode (%d)", errno);
|
||||
}
|
||||
|
||||
if (bdmIoctlInt (code, &var) < 0) {
|
||||
syslog (LOG_INFO, "ioint error: %s (%d)", bdmErrorString (), errno);
|
||||
}
|
||||
|
||||
printf ("IOINT %d,0x%x.", errno, var);
|
||||
}
|
||||
|
||||
/*
|
||||
* IO Command.
|
||||
*/
|
||||
|
||||
void
|
||||
iocmd (char *message)
|
||||
{
|
||||
int id;
|
||||
int code;
|
||||
|
||||
message += sizeof "IOCMD";
|
||||
id = strtoul (message, NULL, 0);
|
||||
|
||||
code = decode_id (id);
|
||||
if (code == -1) {
|
||||
syslog (LOG_INFO, "iocmd error: invalid ioctl id decode (%d)", errno);
|
||||
}
|
||||
|
||||
if (bdmIoctlCommand (code) < 0) {
|
||||
syslog (LOG_INFO, "iocmd error: %s (%d)", bdmErrorString (), errno);
|
||||
}
|
||||
|
||||
printf ("IOCMD %d.", errno);
|
||||
}
|
||||
|
||||
/*
|
||||
* IO ioctl addressed access.
|
||||
*/
|
||||
|
||||
void
|
||||
ioio (char *message)
|
||||
{
|
||||
int id;
|
||||
int code;
|
||||
struct BDMioctl ioc;
|
||||
|
||||
message += sizeof "IOIO";
|
||||
id = strtoul (message, NULL, 0);
|
||||
message = strchr (message, ',') + 1;
|
||||
ioc.address = strtoul (message, NULL, 0);
|
||||
message = strchr (message, ',') + 1;
|
||||
ioc.value = strtoul (message, NULL, 0);
|
||||
|
||||
code = decode_id (id);
|
||||
if (code == -1) {
|
||||
syslog (LOG_INFO, "ioio error: invalid ioctl id decode (%d)", errno);
|
||||
}
|
||||
|
||||
if (bdmIoctlIo (code, &ioc) < 0) {
|
||||
syslog (LOG_INFO, "ioio error: %s (%d)", bdmErrorString (), errno);
|
||||
}
|
||||
|
||||
printf ("IOIO %d,0x%x,0x%x.", errno, ioc.address, ioc.value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a block of memory.
|
||||
*/
|
||||
|
||||
void
|
||||
bdm_read (char *message)
|
||||
{
|
||||
long read_nbytes;
|
||||
unsigned char *buf;
|
||||
unsigned long nbytes;
|
||||
unsigned long byte;
|
||||
|
||||
message += sizeof "READ";
|
||||
nbytes = strtoul (message, NULL, 0);
|
||||
buf = (unsigned char*) xmalloc ((unsigned) nbytes);
|
||||
|
||||
read_nbytes = bdmRead (buf, nbytes);
|
||||
|
||||
if (debug)
|
||||
syslog (LOG_INFO, "read: nbytes %ld (%ld), have read %ld",
|
||||
nbytes, nbytes * 2, read_nbytes);
|
||||
|
||||
if (read_nbytes < 0) {
|
||||
syslog (LOG_INFO, "read error: %s (%d)", bdmErrorString (), errno);
|
||||
}
|
||||
|
||||
printf ("READ %d,%ld,", errno, read_nbytes);
|
||||
|
||||
if (read_nbytes > 0) {
|
||||
for (byte = 0; byte < read_nbytes; byte++)
|
||||
printf ("%02x", buf[byte]);
|
||||
}
|
||||
|
||||
xfree ((char*) buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a block of memory.
|
||||
*/
|
||||
|
||||
void
|
||||
bdm_write (char *message, int msg_len, int msg_buf_len)
|
||||
{
|
||||
long written_nbytes;
|
||||
unsigned char *buf;
|
||||
unsigned long nbytes;
|
||||
unsigned long byte;
|
||||
unsigned long msg_bytes;
|
||||
int msg_index;
|
||||
unsigned char octet = 0;
|
||||
char *msg;
|
||||
|
||||
nbytes = strtoul (message + sizeof "WRITE", &msg, 0);
|
||||
if (*msg == ',')
|
||||
msg++;
|
||||
|
||||
buf = (unsigned char*) xmalloc ((unsigned) nbytes);
|
||||
byte = 0;
|
||||
msg_bytes = 0;
|
||||
|
||||
msg_len -= msg - message;
|
||||
msg_buf_len -= msg - message;
|
||||
|
||||
if (debug)
|
||||
syslog (LOG_INFO, "write: nbytes %ld (%ld)", nbytes, nbytes * 2);
|
||||
|
||||
while (byte < nbytes) {
|
||||
msg_index = 0;
|
||||
if (msg_len < 2) {
|
||||
int new_read;
|
||||
new_read = get_message (msg + msg_len, msg_buf_len - msg_len);
|
||||
if (new_read < 0) {
|
||||
syslog (LOG_INFO, "write error: client timeout");
|
||||
xfree ((char*) buf);
|
||||
return;
|
||||
}
|
||||
msg_len += new_read;
|
||||
}
|
||||
|
||||
if ((msg_len > 0) && !msg[msg_len - 1])
|
||||
msg_len--;
|
||||
|
||||
if (debug) {
|
||||
syslog (LOG_INFO, "write read: msg len is %d (%ld/%ld)",
|
||||
msg_len, msg_bytes, msg_len + msg_bytes);
|
||||
syslog (LOG_INFO, "write read msg: %s", msg + msg_index);
|
||||
if (msg_len > 900)
|
||||
syslog (LOG_INFO, "write read msg end: %s",
|
||||
msg + msg_len - 100);
|
||||
}
|
||||
|
||||
while ((byte < nbytes) && ((msg_len - msg_index) > 1)) {
|
||||
if ((msg[msg_index] >= '0') && (msg[msg_index] <= '9'))
|
||||
octet = msg[msg_index] - '0';
|
||||
else if ((msg[msg_index] >= 'a') && (msg[msg_index] <= 'f')) {
|
||||
msg[msg_index] = tolower (msg[msg_index]);
|
||||
octet = msg[msg_index] - 'a' + 10;
|
||||
}
|
||||
else {
|
||||
syslog (LOG_INFO,
|
||||
"write read: hbyte %ld msg bytes %ld, len:%d index:%d,"
|
||||
" invalid data %#2x",
|
||||
byte, msg_bytes, msg_len, msg_index, msg[msg_index]);
|
||||
}
|
||||
|
||||
msg_index++;
|
||||
msg_bytes++;
|
||||
|
||||
octet <<= 4;
|
||||
|
||||
if ((msg[msg_index] >= '0') && (msg[msg_index] <= '9'))
|
||||
octet |= msg[msg_index] - '0';
|
||||
else if ((msg[msg_index] >= 'a') && (msg[msg_index] <= 'f')) {
|
||||
msg[msg_index] = tolower (msg[msg_index]);
|
||||
octet |= msg[msg_index] - 'a' + 10;
|
||||
}
|
||||
else {
|
||||
syslog (LOG_INFO,
|
||||
"write read: lbyte %ld msg bytes %ld, len:%d index:%d,"
|
||||
" invalid data %#2x",
|
||||
byte, msg_bytes, msg_len, msg_index, msg[msg_index]);
|
||||
}
|
||||
|
||||
msg_index++;
|
||||
msg_bytes++;
|
||||
|
||||
buf[byte] = octet;
|
||||
|
||||
byte++;
|
||||
}
|
||||
|
||||
memcpy (msg, msg + msg_index, msg_len - msg_index);
|
||||
msg_len -= msg_index;
|
||||
}
|
||||
|
||||
written_nbytes = bdmWrite (buf, nbytes);
|
||||
|
||||
if (written_nbytes < 0) {
|
||||
syslog (LOG_INFO, "write error: %s (%d)", bdmErrorString (), errno);
|
||||
}
|
||||
|
||||
printf ("WRITE %d,%ld", errno, written_nbytes);
|
||||
|
||||
xfree ((char*) buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up and exit.
|
||||
*/
|
||||
|
||||
void
|
||||
quit ()
|
||||
{
|
||||
bdmClose ();
|
||||
if (debug)
|
||||
syslog (LOG_INFO, "host finished: %s (%s)", current_host, current_addr);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a message.
|
||||
*/
|
||||
|
||||
void
|
||||
process_message (char *message, int msg_len, int msg_buf_len)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
switch (decode_message (message)) {
|
||||
case HELO:
|
||||
helo (message);
|
||||
break;
|
||||
|
||||
case SRVCTL:
|
||||
server_control (message);
|
||||
break;
|
||||
|
||||
case IOINT:
|
||||
ioint (message);
|
||||
break;
|
||||
|
||||
case IOCMD:
|
||||
iocmd (message);
|
||||
break;
|
||||
|
||||
case IOIO:
|
||||
ioio (message);
|
||||
break;
|
||||
|
||||
case READ:
|
||||
bdm_read (message);
|
||||
break;
|
||||
|
||||
case WRITE:
|
||||
bdm_write (message, msg_len, msg_buf_len);
|
||||
break;
|
||||
|
||||
case QUIT:
|
||||
quit ();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usage ()
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Usage: %s [-h] [-n] [-V] [-d]\n",
|
||||
program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
version ()
|
||||
{
|
||||
printf ("bdmd %s\n", version_string);
|
||||
}
|
||||
|
||||
/*
|
||||
* The server can be run from inetd or run from the
|
||||
* a tty allow debug to be watched.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct hostent *hp;
|
||||
int optc;
|
||||
int not_inetd = 0;
|
||||
char buf[BDM_SERVER_BUF_SIZE];
|
||||
int cread;
|
||||
|
||||
program_name = argv[0];
|
||||
|
||||
while ((optc = getopt (argc, argv, "dnVh")) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 'd':
|
||||
debug++;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
not_inetd = 1;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
version ();
|
||||
exit (0);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process options.
|
||||
*/
|
||||
|
||||
umask (022);
|
||||
|
||||
/*
|
||||
* chdir
|
||||
*/
|
||||
|
||||
fflush (stderr);
|
||||
fflush (stdout);
|
||||
|
||||
closelog ();
|
||||
|
||||
#ifdef LOG_DAEMON
|
||||
openlog ("bdmd", (LOG_PID|LOG_CONS), LOG_DAEMON);
|
||||
#else
|
||||
openlog ("bdmd", LOG_PID);
|
||||
#endif
|
||||
|
||||
if (gethostname (myname, MAXHOSTNAMELEN)) {
|
||||
fprintf (stderr, "%s: cannot find out the name of this host\n",
|
||||
program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
myname[MAXHOSTNAMELEN - 1] = 0;
|
||||
|
||||
/*
|
||||
* Now see if we can get a FQDN for this host.
|
||||
*/
|
||||
|
||||
hp = gethostbyname (myname);
|
||||
if (hp && (strlen (hp->h_name) > strlen (myname)))
|
||||
strncpy (myname, hp->h_name, MAXHOSTNAMELEN);
|
||||
myname[MAXHOSTNAMELEN - 1] = 0;
|
||||
|
||||
bdmLogSyslog ();
|
||||
|
||||
/*
|
||||
* Don't pay attention to SIGPIPE; read will give us the problem
|
||||
* if it happens.
|
||||
*/
|
||||
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
|
||||
if (!not_inetd)
|
||||
start_connection ();
|
||||
else
|
||||
{
|
||||
current_host = myname;
|
||||
if (hp)
|
||||
current_addr = (char *) inet_ntoa (*(struct in_addr *) hp->h_addr);
|
||||
else
|
||||
current_addr = myname;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
syslog (LOG_INFO, "host connected: %s (%s)", current_host, current_addr);
|
||||
|
||||
/*
|
||||
* Say hello to the remote end. It will be waiting.
|
||||
*/
|
||||
|
||||
while (1) {
|
||||
cread = get_message (buf, BDM_SERVER_BUF_SIZE);
|
||||
|
||||
if (cread == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (cread > 0) {
|
||||
if (debug > 1) {
|
||||
int len = strlen (buf);
|
||||
syslog (LOG_INFO, "msg: %s", buf);
|
||||
if (len>900)
|
||||
syslog (LOG_INFO, "msg end: %s", buf + len - 100);
|
||||
}
|
||||
|
||||
process_message (buf, cread, BDM_SERVER_BUF_SIZE);
|
||||
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
|
||||
bdmClose ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
82
m68k/server/xmalloc.c
Normal file
82
m68k/server/xmalloc.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
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 2, 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
char *realloc ();
|
||||
void free ();
|
||||
void abort();
|
||||
#endif
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
char *
|
||||
xmalloc (n)
|
||||
unsigned n;
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
p = malloc (n);
|
||||
if (p == 0)
|
||||
{
|
||||
syslog (LOG_INFO, "xmalloc: request for %d bytes failed\n", n);
|
||||
abort ();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking.
|
||||
If P is NULL, run xmalloc.
|
||||
If N is 0, run free and return NULL. */
|
||||
|
||||
char *
|
||||
xrealloc (p, n)
|
||||
char *p;
|
||||
unsigned n;
|
||||
{
|
||||
if (p == 0)
|
||||
return xmalloc (n);
|
||||
if (n == 0)
|
||||
{
|
||||
free (p);
|
||||
return 0;
|
||||
}
|
||||
p = realloc (p, n);
|
||||
if (p == 0)
|
||||
{
|
||||
syslog (LOG_INFO, "xrealloc: request for %d bytes failed\n", n);
|
||||
abort ();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
xfree (p)
|
||||
char *p;
|
||||
{
|
||||
if (p != 0)
|
||||
free (p);
|
||||
}
|
||||
Reference in New Issue
Block a user