diff --git a/Makefile b/Makefile index 3457c776..b72606ee 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 472 2013-01-06 14:39:10Z mueller $ +# $Id: Makefile 489 2013-02-17 10:58:02Z mueller $ # # 'Meta Makefile' for whole retro project # allows to make all synthesis targets @@ -52,12 +52,18 @@ SIM_all += rtl/w11a/tb .PHONY : $(SYN_all) $(SIM_all) # all : - @echo "no default action defined, use" - @echo " make -j 4 all_sim" - @echo " make -j 4 all_syn" - @echo " make clean" - @echo " make clean_sim" - @echo " make clean_syn" + @echo "no default action defined." + @echo " for VHDL simulation/synthesis use:" + @echo " make -j 4 all_sim" + @echo " make -j 4 all_syn" + @echo " make clean" + @echo " make clean_sim" + @echo " make clean_syn" + @echo " for tool/documentation generation use:" + @echo " make -j 4 all_lib" + @echo " make clean_lib" + @echo " make all_tcl" + @echo " make all_dox" # # clean : clean_sim clean_syn @@ -85,3 +91,15 @@ $(SIM_all): $(SYN_all): $(MAKE) -j 1 -C $@ # +all_lib : + $(MAKE) -C tools/src +clean_lib : + $(MAKE) -C tools/src distclean +# +all_tcl : + (cd tools/tcl; setup_packages) +# +all_dox : + (cd tools/dox; make_doxy) +# +all_all : all_sim all_syn all_lib all_tcl diff --git a/doc/INSTALL.txt b/doc/INSTALL.txt index 9b9b0337..d339f6bf 100644 --- a/doc/INSTALL.txt +++ b/doc/INSTALL.txt @@ -1,4 +1,4 @@ -# $Id: INSTALL.txt 467 2013-01-02 19:49:05Z mueller $ +# $Id: INSTALL.txt 504 2013-04-13 15:37:24Z mueller $ Guide to install and build w11a systems, test benches and support software @@ -22,6 +22,7 @@ Guide to install and build w11a systems, test benches and support software a. General instructions b. Configuring FPGAs c. Available systems + 9. Generate Doxygen based source code view 1. Download --------------------------------------------------------------- @@ -75,6 +76,9 @@ Guide to install and build w11a systems, test benches and support software - ghdl -> see INSTALL_ghdl.txt for the unfortunately gory details + - for doxygen documentation an up-to-date installation of doxygen is + required, version 1.8.3.1 or later + - optional but very useful is: - gtkwave -> package: gtkwave @@ -89,13 +93,15 @@ Guide to install and build w11a systems, test benches and support software - the definition of the environment variables: - RETROBASE: must refer to the installation root directory - - BOOSTINC: pathname for includes of boost library - TCLINC: pathname for includes of Tcl runtime library - RETRO_FX2_VID and RETRO_FX2_PID: default USB VID/PID, see below - that the tools binary directory is in the path - that the tools library directory is in the library path + - optional environment variables: + - BOOSTINC: pathname for includes of boost library + - BOOSTLIB: pathname for libraries of boost library + {Note: Either both must be undefined, or both must be defined} - For bash and alike use export RETROBASE= @@ -105,9 +111,10 @@ Guide to install and build w11a systems, test benches and support software In most cases the boost library version coming with the distribution will work, similar for Tcl, in those cases simply use - export BOOSTINC=/usr/include export TCLINC=/usr/include/tcl8.5 + and don't setup BOOSTINC and BOOSTLIB. + After that building functional model based test benches will work. If you want to also build post-xst or post-par test benches read next section. @@ -378,3 +385,22 @@ Guide to install and build w11a systems, test benches and support software cd $RETROBASE/rtl/sys_gen/w11a/nexys3 make sys_w11a_n3.bit + +9. Generate Doxygen based source code view -------------------------------- + + Currently there is not much real documentation included in the source + files. The doxygen generated html output is nevertheless very useful + to browse the code. C++, Tcl and Vhdl source are covered by setup files + contained in the project files. + + To generate the html files + + cd $RETROBASE/tools/dox + export RETRODOXY + ./make_doxy + + If RETRODOXY is not defined '/tmp' is used. To view the docs use + + firefox $RETRODOXY/w11/cpp/html/index.html & + firefox $RETRODOXY/w11/tcl/html/index.html & + firefox $RETRODOXY/w11/vhd/html/index.html & diff --git a/doc/README.txt b/doc/README.txt index d1fcdc0c..c4f51d5a 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -1,4 +1,4 @@ -# $Id: README.txt 472 2013-01-06 14:39:10Z mueller $ +# $Id: README.txt 504 2013-04-13 15:37:24Z mueller $ Release notes for w11a @@ -8,7 +8,6 @@ Release notes for w11a 2. Files 3. Change Log - 1. Documentation ------------------------------------------------------------- More detailed information on installation, build and test can be found @@ -58,6 +57,9 @@ Release notes for w11a rtl/vlib/xlib - Xilinx specific components rtl/w11a - w11a core tools helper programs + tools/asm-11 - pdp-11 assembler code + tools/asm-11/tests - test bench for asm-11 + tools/asm-11/tests-err - test bench for asm-11 (error check part) tools/bin - scripts and binaries tools/dox - Doxygen documentation configuration tools/make - make includes @@ -71,10 +73,51 @@ Release notes for w11a tools/src/librtcltools - support classes to implement Tcl bindings tools/src/librtools - general support classes and methods tools/src/librutiltpp - Tcl support commands implemented in C++ + tools/src/librw11 - w11 over rlink interface + tools/src/librwxxtpp - C++ to tcl binding for w11 over rlink iface + tools/tbench - w11 CPU test bench tools/tcl - Tcl scripts 3. Change Log ---------------------------------------------------------------- +- trunk (2013-06-13: svn rev 19(oc) 505(wfjm); untagged w11a_V0.562) +++++++++ + + - Summary + - V0.53 introduced a new C++ and Tcl based backend server, but only the + very basic rlink handling layer. This step release add now many support + classes for interfacing to w11 system designs, and the associated Tcl + bindings. + - add 'asm-11', a simple, Macro-11 syntax subset combatible, assembler. + Can be used stand-alone to generate 'absolute loader' format files, + but also integrates tightly into the Tcl environment and is used as + building block in the creation of CPU test benches. + - use now doxygen 1.8.3.1, generate c++,tcl, and vhdl source docs + See section 9. in INSTALL.txt for details. + + - New features + - new directory trees for + - tools/asm-11 - asm-11 code + - tools/asm-11/tests - test bench for asm-11 + - tools/asm-11/tests-err - test bench for asm-11 (error check part) + - tools/src/librw11 - w11 over rlink interface + - tools/src/librwxxtpp - C++ to tcl binding for w11 over rlink iface + - tools/tbench - w11 CPU test bench + - new modules + - tools/bin + - asm-11 - simple, Macro-11 syntax subset compatible, assembler + - asm-11_expect - expect checker for asm-11 test bench + - tools/dox + - *.Doxyfile - new descriptors c++,tcl,vhdl docs + - make_dox - driver script to generate c++,tcl,vhdl doxygen docs + + - Changes + - vhdl module renames: + vlib/serport -> vlib/serportlib + - vhdl module splits: + bplib/bpgen/bpgenlib -> bpgenlib + bpgenrbuslib + - C++ class splits + librtcltools/RtclProxyBase -> RtclCmdBase + RtclProxyBase + - trunk (2013-01-06: svn rev 18(oc) 472(wfjm); untagged w11a_V0.561) +++++++++ - Summary diff --git a/doc/w11a_tb_guide.txt b/doc/w11a_tb_guide.txt index 3c8d59dd..1f39c6b4 100644 --- a/doc/w11a_tb_guide.txt +++ b/doc/w11a_tb_guide.txt @@ -1,4 +1,4 @@ -# $Id: w11a_tb_guide.txt 443 2011-12-23 11:21:03Z mueller $ +# $Id: w11a_tb_guide.txt 504 2013-04-13 15:37:24Z mueller $ Guide to running w11a test benches @@ -159,11 +159,6 @@ Guide to running w11a test benches simulation, or via a serial port to a FPGA board. This way the same tests can be executed in simulation and on real hardware. - Currently two backend implementations are available: - - pi_rri: written in perl (old, slow, but full functionality) - - ti_tti: written in C++ and Tcl (new, fast, but as of V0.55 only with - limited functionality; will replace pi_rri). - 4. Available system tests benches ----------------------------------------- 4a. serport tester -- -------------------------------------------- @@ -217,8 +212,8 @@ Guide to running w11a test benches time ti_rri --run="tbw tb_tst_rlink_s3" --fifo --logl=3 -- \ "package require tst_rlink" "tst_rlink::setup" "tst_rlink::test_all" |\ tee tb_tst_rlink_s3_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 1822195.0 ns 91100: DONE - -> real 0m13.281s + -> 960540.0 ns 48017: DONE + -> real 0m4.470s - sys_tst_rlink_n2 test bench @@ -227,8 +222,8 @@ Guide to running w11a test benches time ti_rri --run="tbw tb_tst_rlink_n2" --fifo --logl=3 -- \ "package require tst_rlink" "tst_rlink::setup" "tst_rlink::test_all" |\ tee tb_tst_rlink_n2_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 1769140.0 ns 88446: DONE - -> real 0m15.289s + -> 960560.0 ns 48017: DONE + -> real 0m4.717s - sys_tst_rlink_n3 test bench @@ -237,8 +232,8 @@ Guide to running w11a test benches time ti_rri --run="tbw tb_tst_rlink_n3" --fifo --logl=3 -- \ "package require tst_rlink" "tst_rlink::setup" "tst_rlink::test_all" |\ tee tb_tst_rlink_n3_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 893590.0 ns 89338: DONE - -> real 0m9.510s + -> 480380.0 ns 48017: DONE + -> real 0m4.860s 4c. w11a systems ----------------------------------------------------- @@ -253,32 +248,44 @@ Guide to running w11a test benches cd $RETROBASE/rtl/sys_gen/w11a/s3board/tb make tb_w11a_s3 - time pi_rri --fifo --timeout=40. --cmax=3 \ - --run="tbw tb_w11a_s3" -- \ - @../../../../w11a/tb/tb_pdp11core_stim.dat |\ + time ti_rri --pack=rw11a --run="tbw tb_w11a_s3" --fifo --logl=3 -- \ + "rw11a::setup_cpu" \ + "rw11a::run_pdpcp ../../../../w11a/tb/tb_pdp11core_stim.dat" |\ tee tb_w11a_s3_stim2_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 7852095.0 ns 392595: DONE - -> real 0m49.835s user 0m50.203s sys 0m00.696s + -> 10225140.0 ns 511247: DONE + -> real 0m52.105s user 0m0.260s sys 0m0.132s - sys_w11a_n2 test bench cd $RETROBASE/rtl/sys_gen/w11a/nexys2/tb make tb_w11a_n2 - time pi_rri --fifo --timeout=40. --cmax=3 \ - --run="tbw tb_w11a_n2" -- \ - @../../../../w11a/tb/tb_pdp11core_stim.dat |\ + time ti_rri --pack=rw11a --run="tbw tb_w11a_n2" --fifo --logl=3 -- \ + "rw11a::setup_cpu" \ + "rw11a::run_pdpcp ../../../../w11a/tb/tb_pdp11core_stim.dat" |\ tee tb_w11a_n2_stim2_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 7836580.0 ns 391818: DONE - -> real 1m0.854s user 1m1.332s sys 0m0.800s + -> 10278380.0 ns 513908: DONE + -> real 1m26.388s user 0m0.312s sys 0m0.156s - sys_w11a_n3 test bench cd $RETROBASE/rtl/sys_gen/w11a/nexys3/tb make tb_w11a_n3 - time pi_rri --fifo --timeout=40. --cmax=3 \ - --run="tbw tb_w11a_n3" -- \ - @../../../../w11a/tb/tb_pdp11core_stim.dat |\ + time ti_rri --pack=rw11a --run="tbw tb_w11a_n3" --fifo --logl=3 -- \ + "rw11a::setup_cpu" \ + "rw11a::run_pdpcp ../../../../w11a/tb/tb_pdp11core_stim.dat" |\ tee tb_w11a_n3_stim2_dsim.log | egrep "(-[EFW]:|FAIL|PEND|DONE)" - -> 3956540.0 ns 395633: DONE - -> real 1m13.811s user 1m14.389s sys 0m0.948s + -> 5167410.0 ns 516720: DONE + -> real 1m26.611s user 0m0.248s sys 0m0.196s + A new, modular w11a test bench is under construction. So far it is very + incomplete. This very preliminary version can be executed with + + - sys_w11a_n2 test bench + + cd $RETROBASE/rtl/sys_gen/w11a/nexys2/tb + make tb_w11a_n2 + time ti_rri --pack=rw11a --run="tbw tb_w11a_n2" --fifo --logl=3 -- \ + "rw11a::setup_cpu" "rw11a::tbench @w11a_all.dat" | \ + tee w11a_tbench_dsim.log | egrep "(-[EFW]:|FAIL|PASS|DONE)" + -> 904180.0 ns 45198: DONE + -> real 0m5.739s user 0m0.576s sys 0m0.076s diff --git a/rtl/bplib/bpgen/Makefile b/rtl/bplib/bpgen/Makefile index 14685b7a..f83e9a54 100644 --- a/rtl/bplib/bpgen/Makefile +++ b/rtl/bplib/bpgen/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,7 +9,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -21,5 +21,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/bplib/bpgen/bpgenlib.vbom b/rtl/bplib/bpgen/bpgenlib.vbom index 3ae84b23..80e3d3e8 100644 --- a/rtl/bplib/bpgen/bpgenlib.vbom +++ b/rtl/bplib/bpgen/bpgenlib.vbom @@ -1,4 +1,3 @@ # libs ../../vlib/slvtypes.vhd -../../vlib/rbus/rblib.vhd bpgenlib.vhd diff --git a/rtl/bplib/bpgen/bpgenlib.vhd b/rtl/bplib/bpgen/bpgenlib.vhd index 30602a7b..ecec9e56 100644 --- a/rtl/bplib/bpgen/bpgenlib.vhd +++ b/rtl/bplib/bpgen/bpgenlib.vhd @@ -1,4 +1,4 @@ --- $Id: bpgenlib.vhd 472 2013-01-06 14:39:10Z mueller $ +-- $Id: bpgenlib.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011-2013 by Walter F.J. Mueller -- @@ -12,13 +12,14 @@ -- for complete details. -- ------------------------------------------------------------------------------ --- Package Name: bpliblib +-- Package Name: bpgenlib -- Description: Generic Board/Part components -- -- Dependencies: - -- Tool versions: 12.1, 13.3; ghdl 0.26-0.29 -- Revision History: -- Date Rev Version Comment +-- 2013-01-26 476 1.1 moved rbus depended components to bpgenrbuslib -- 2013-01-06 472 1.0.7 add sn_humanio_demu_rbus -- 2011-11-16 426 1.0.6 now numeric_std clean -- 2011-10-10 413 1.0.5 add sn_humanio_demu @@ -34,7 +35,6 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.rblib.all; package bpgenlib is @@ -101,28 +101,6 @@ component bp_swibtnled is -- generic SWI, BTN and LED handling ); end component; -component bp_swibtnled_rbus is -- swi,btn,led handling /w rbus icept - generic ( - SWIDTH : positive := 4; -- SWI port width - BWIDTH : positive := 4; -- BTN port width - LWIDTH : positive := 4; -- LED port width - DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN - RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); - port ( - CLK : in slbit; -- clock - RESET : in slbit := '0'; -- reset - CE_MSEC : in slbit; -- 1 ms clock enable - RB_MREQ : in rb_mreq_type; -- rbus: request - RB_SRES : out rb_sres_type; -- rbus: response - SWI : out slv(SWIDTH-1 downto 0); -- switch settings, debounced - BTN : out slv(BWIDTH-1 downto 0); -- button settings, debounced - LED : in slv(LWIDTH-1 downto 0); -- led data - I_SWI : in slv(SWIDTH-1 downto 0); -- pad-i: switches - I_BTN : in slv(BWIDTH-1 downto 0); -- pad-i: buttons - O_LED : out slv(LWIDTH-1 downto 0) -- pad-o: leds - ); -end component; - component sn_4x7segctl is -- Quad 7 segment display controller generic ( CDWIDTH : positive := 6); -- clk divider width (must be >= 5) @@ -174,49 +152,4 @@ component sn_humanio_demu is -- human i/o handling: swi,btn,led only ); end component; -component sn_humanio_rbus is -- human i/o handling /w rbus intercept - generic ( - BWIDTH : positive := 4; -- BTN port width - DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN - RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); - port ( - CLK : in slbit; -- clock - RESET : in slbit := '0'; -- reset - CE_MSEC : in slbit; -- 1 ms clock enable - RB_MREQ : in rb_mreq_type; -- rbus: request - RB_SRES : out rb_sres_type; -- rbus: response - SWI : out slv8; -- switch settings, debounced - BTN : out slv(BWIDTH-1 downto 0); -- button settings, debounced - LED : in slv8; -- led data - DSP_DAT : in slv16; -- display data - DSP_DP : in slv4; -- display decimal points - I_SWI : in slv8; -- pad-i: switches - I_BTN : in slv(BWIDTH-1 downto 0); -- pad-i: buttons - O_LED : out slv8; -- pad-o: leds - O_ANO_N : out slv4; -- pad-o: 7 seg disp: anodes (act.low) - O_SEG_N : out slv8 -- pad-o: 7 seg disp: segments (act.low) - ); -end component; - -component sn_humanio_demu_rbus is -- human i/o swi,btn,led only /w rbus - generic ( - DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN - RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); - port ( - CLK : in slbit; -- clock - RESET : in slbit := '0'; -- reset - CE_MSEC : in slbit; -- 1 ms clock enable - RB_MREQ : in rb_mreq_type; -- rbus: request - RB_SRES : out rb_sres_type; -- rbus: response - SWI : out slv8; -- switch settings, debounced - BTN : out slv4; -- button settings, debounced - LED : in slv8; -- led data - DSP_DAT : in slv16; -- display data - DSP_DP : in slv4; -- display decimal points - I_SWI : in slv8; -- pad-i: switches - I_BTN : in slv6; -- pad-i: buttons - O_LED : out slv8 -- pad-o: leds - ); -end component; - end package bpgenlib; diff --git a/rtl/bplib/bpgen/bpgenrbuslib.vbom b/rtl/bplib/bpgen/bpgenrbuslib.vbom new file mode 100644 index 00000000..0dfeb33d --- /dev/null +++ b/rtl/bplib/bpgen/bpgenrbuslib.vbom @@ -0,0 +1,4 @@ +# libs +../../vlib/slvtypes.vhd +../../vlib/rbus/rblib.vhd +bpgenrbuslib.vhd diff --git a/rtl/bplib/bpgen/bpgenrbuslib.vhd b/rtl/bplib/bpgen/bpgenrbuslib.vhd new file mode 100644 index 00000000..875e4d39 --- /dev/null +++ b/rtl/bplib/bpgen/bpgenrbuslib.vhd @@ -0,0 +1,101 @@ +-- $Id: bpgenrbuslib.vhd 476 2013-01-26 22:23:53Z mueller $ +-- +-- Copyright 2013- by Walter F.J. Mueller +-- +-- This program is free software; you may redistribute 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 complete details. +-- +------------------------------------------------------------------------------ +-- Package Name: bpgenrbuslib +-- Description: Generic Board/Part components using rbus +-- +-- Dependencies: - +-- Tool versions: 12.1, 13.3; ghdl 0.26-0.29 +-- Revision History: +-- Date Rev Version Comment +-- 2013-01-26 476 1.0 Initial version (extracted from bpgenlib) +------------------------------------------------------------------------------ + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.slvtypes.all; +use work.rblib.all; + +package bpgenrbuslib is + +component bp_swibtnled_rbus is -- swi,btn,led handling /w rbus icept + generic ( + SWIDTH : positive := 4; -- SWI port width + BWIDTH : positive := 4; -- BTN port width + LWIDTH : positive := 4; -- LED port width + DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN + RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); + port ( + CLK : in slbit; -- clock + RESET : in slbit := '0'; -- reset + CE_MSEC : in slbit; -- 1 ms clock enable + RB_MREQ : in rb_mreq_type; -- rbus: request + RB_SRES : out rb_sres_type; -- rbus: response + SWI : out slv(SWIDTH-1 downto 0); -- switch settings, debounced + BTN : out slv(BWIDTH-1 downto 0); -- button settings, debounced + LED : in slv(LWIDTH-1 downto 0); -- led data + I_SWI : in slv(SWIDTH-1 downto 0); -- pad-i: switches + I_BTN : in slv(BWIDTH-1 downto 0); -- pad-i: buttons + O_LED : out slv(LWIDTH-1 downto 0) -- pad-o: leds + ); +end component; + +component sn_humanio_rbus is -- human i/o handling /w rbus intercept + generic ( + BWIDTH : positive := 4; -- BTN port width + DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN + RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); + port ( + CLK : in slbit; -- clock + RESET : in slbit := '0'; -- reset + CE_MSEC : in slbit; -- 1 ms clock enable + RB_MREQ : in rb_mreq_type; -- rbus: request + RB_SRES : out rb_sres_type; -- rbus: response + SWI : out slv8; -- switch settings, debounced + BTN : out slv(BWIDTH-1 downto 0); -- button settings, debounced + LED : in slv8; -- led data + DSP_DAT : in slv16; -- display data + DSP_DP : in slv4; -- display decimal points + I_SWI : in slv8; -- pad-i: switches + I_BTN : in slv(BWIDTH-1 downto 0); -- pad-i: buttons + O_LED : out slv8; -- pad-o: leds + O_ANO_N : out slv4; -- pad-o: 7 seg disp: anodes (act.low) + O_SEG_N : out slv8 -- pad-o: 7 seg disp: segments (act.low) + ); +end component; + +component sn_humanio_demu_rbus is -- human i/o swi,btn,led only /w rbus + generic ( + DEBOUNCE : boolean := true; -- instantiate debouncer for SWI,BTN + RB_ADDR : slv8 := slv(to_unsigned(2#10000000#,8))); + port ( + CLK : in slbit; -- clock + RESET : in slbit := '0'; -- reset + CE_MSEC : in slbit; -- 1 ms clock enable + RB_MREQ : in rb_mreq_type; -- rbus: request + RB_SRES : out rb_sres_type; -- rbus: response + SWI : out slv8; -- switch settings, debounced + BTN : out slv4; -- button settings, debounced + LED : in slv8; -- led data + DSP_DAT : in slv16; -- display data + DSP_DP : in slv4; -- display decimal points + I_SWI : in slv8; -- pad-i: switches + I_BTN : in slv6; -- pad-i: buttons + O_LED : out slv8 -- pad-o: leds + ); +end component; + +end package bpgenrbuslib; diff --git a/rtl/bplib/fx2lib/Makefile b/rtl/bplib/fx2lib/Makefile index 1694cfd9..037acbd0 100644 --- a/rtl/bplib/fx2lib/Makefile +++ b/rtl/bplib/fx2lib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,7 +8,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -20,5 +20,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/bplib/issi/Makefile b/rtl/bplib/issi/Makefile index 246f76dc..d10a02db 100644 --- a/rtl/bplib/issi/Makefile +++ b/rtl/bplib/issi/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -16,5 +16,7 @@ include $(RETROBASE)/rtl/make/generic_ghdl.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/bplib/nexys2/Makefile b/rtl/bplib/nexys2/Makefile index 1694cfd9..037acbd0 100644 --- a/rtl/bplib/nexys2/Makefile +++ b/rtl/bplib/nexys2/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,7 +8,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -20,5 +20,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/bplib/nexys2/tb/Makefile b/rtl/bplib/nexys2/tb/Makefile index b076264d..e9dd01b3 100644 --- a/rtl/bplib/nexys2/tb/Makefile +++ b/rtl/bplib/nexys2/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 467 2013-01-02 19:49:05Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -13,7 +13,7 @@ EXE_all = tb_nexys2_dummy EXE_all += tb_nexys2_fusp_dummy EXE_all += tb_nexys2_fusp_cuff_dummy # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -31,8 +31,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_core.vbom b/rtl/bplib/nexys2/tb/tb_nexys2_core.vbom index 650cc815..62976481 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_core.vbom +++ b/rtl/bplib/nexys2/tb/tb_nexys2_core.vbom @@ -1,6 +1,6 @@ # libs ../../../vlib/slvtypes.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/simlib/simbus.vhd # components ../../../vlib/serport/serport_uart_rx.vbom diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_core.vhd b/rtl/bplib/nexys2/tb/tb_nexys2_core.vhd index 1b91f2f9..8c6b8a2b 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_core.vhd +++ b/rtl/bplib/nexys2/tb/tb_nexys2_core.vhd @@ -1,4 +1,4 @@ --- $Id: tb_nexys2_core.vhd 433 2011-11-27 22:04:39Z mueller $ +-- $Id: tb_nexys2_core.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -36,7 +36,7 @@ use ieee.std_logic_textio.all; use std.textio.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.simbus.all; entity tb_nexys2_core is diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vbom b/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vbom index f68b4dc0..e9f0c76f 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vbom +++ b/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vbom @@ -6,7 +6,7 @@ ../../../vlib/slvtypes.vhd ../../../vlib/rlink/rlinklib.vbom ../../../vlib/rlink/tb/rlinktblib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/xlib/xlib.vhd ../nexys2lib.vhd ../../../vlib/simlib/simlib.vhd diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vhd b/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vhd index e5ed778d..a74b6578 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vhd +++ b/rtl/bplib/nexys2/tb/tb_nexys2_fusp.vhd @@ -1,4 +1,4 @@ --- $Id: tb_nexys2_fusp.vhd 467 2013-01-02 19:49:05Z mueller $ +-- $Id: tb_nexys2_fusp.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -49,7 +49,7 @@ use std.textio.all; use work.slvtypes.all; use work.rlinklib.all; use work.rlinktblib.all; -use work.serport.all; +use work.serportlib.all; use work.xlib.all; use work.nexys2lib.all; use work.simlib.all; diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vbom b/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vbom index bb42ba75..b8979c8e 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vbom +++ b/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vbom @@ -6,7 +6,7 @@ ../../../vlib/slvtypes.vhd ../../../vlib/rlink/rlinklib.vbom ../../../vlib/rlink/tb/rlinktblib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/xlib/xlib.vhd ../nexys2lib.vhd ../../../vlib/simlib/simlib.vhd diff --git a/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vhd b/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vhd index f799b533..64ba41df 100644 --- a/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vhd +++ b/rtl/bplib/nexys2/tb/tb_nexys2_fusp_cuff.vhd @@ -1,4 +1,4 @@ --- $Id: tb_nexys2_fusp_cuff.vhd 469 2013-01-05 12:29:44Z mueller $ +-- $Id: tb_nexys2_fusp_cuff.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2013- by Walter F.J. Mueller -- @@ -44,7 +44,7 @@ use std.textio.all; use work.slvtypes.all; use work.rlinklib.all; use work.rlinktblib.all; -use work.serport.all; +use work.serportlib.all; use work.xlib.all; use work.nexys2lib.all; use work.simlib.all; diff --git a/rtl/bplib/nexys3/tb/Makefile b/rtl/bplib/nexys3/tb/Makefile index ecb935e2..124dbb6a 100644 --- a/rtl/bplib/nexys3/tb/Makefile +++ b/rtl/bplib/nexys3/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 433 2011-11-27 22:04:39Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,10 +6,7 @@ # EXE_all = tb_nexys3_fusp_dummy # -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -27,8 +24,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/bplib/nexys3/tb/tb_nexys3_core.vbom b/rtl/bplib/nexys3/tb/tb_nexys3_core.vbom index 9c3f6384..8349482e 100644 --- a/rtl/bplib/nexys3/tb/tb_nexys3_core.vbom +++ b/rtl/bplib/nexys3/tb/tb_nexys3_core.vbom @@ -1,6 +1,6 @@ # libs ../../../vlib/slvtypes.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/simlib/simbus.vhd # components ../../../vlib/serport/serport_uart_rx.vbom diff --git a/rtl/bplib/nexys3/tb/tb_nexys3_core.vhd b/rtl/bplib/nexys3/tb/tb_nexys3_core.vhd index 83bc5a14..cc790c05 100644 --- a/rtl/bplib/nexys3/tb/tb_nexys3_core.vhd +++ b/rtl/bplib/nexys3/tb/tb_nexys3_core.vhd @@ -1,4 +1,4 @@ --- $Id: tb_nexys3_core.vhd 432 2011-11-25 20:16:28Z mueller $ +-- $Id: tb_nexys3_core.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -33,7 +33,7 @@ use ieee.std_logic_textio.all; use std.textio.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.simbus.all; entity tb_nexys3_core is diff --git a/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vbom b/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vbom index fb2dfaea..c78a06ba 100644 --- a/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vbom +++ b/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vbom @@ -6,7 +6,7 @@ ../../../vlib/slvtypes.vhd ../../../vlib/rlink/rlinklib.vbom ../../../vlib/rlink/tb/rlinktblib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/xlib/xlib.vhd ../nexys3lib.vhd ../../../vlib/simlib/simlib.vhd diff --git a/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vhd b/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vhd index c23b8336..41aae95f 100644 --- a/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vhd +++ b/rtl/bplib/nexys3/tb/tb_nexys3_fusp.vhd @@ -1,4 +1,4 @@ --- $Id: tb_nexys3_fusp.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_nexys3_fusp.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -43,7 +43,7 @@ use std.textio.all; use work.slvtypes.all; use work.rlinklib.all; use work.rlinktblib.all; -use work.serport.all; +use work.serportlib.all; use work.xlib.all; use work.nexys3lib.all; use work.simlib.all; diff --git a/rtl/bplib/nxcramlib/Makefile b/rtl/bplib/nxcramlib/Makefile index 44f457e8..ebd74f0b 100644 --- a/rtl/bplib/nxcramlib/Makefile +++ b/rtl/bplib/nxcramlib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 433 2011-11-27 22:04:39Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -19,5 +19,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/bplib/nxcramlib/tb/Makefile b/rtl/bplib/nxcramlib/tb/Makefile index fccf0bdd..e22fe7df 100644 --- a/rtl/bplib/nxcramlib/tb/Makefile +++ b/rtl/bplib/nxcramlib/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 433 2011-11-27 22:04:39Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,7 +6,7 @@ # EXE_all = tb_nx_cram_memctl_as # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -24,8 +24,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/bplib/s3board/Makefile b/rtl/bplib/s3board/Makefile index 14685b7a..f83e9a54 100644 --- a/rtl/bplib/s3board/Makefile +++ b/rtl/bplib/s3board/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,7 +9,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -21,5 +21,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/bplib/s3board/tb/Makefile b/rtl/bplib/s3board/tb/Makefile index 1e42efc3..4eb9ad41 100644 --- a/rtl/bplib/s3board/tb/Makefile +++ b/rtl/bplib/s3board/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 444 2011-12-25 10:04:58Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -13,7 +13,7 @@ EXE_all = tb_s3board_dummy EXE_all += tb_s3board_fusp_dummy EXE_all += tb_s3_sram_memctl # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all all_ssim all_tsim clean # @@ -31,8 +31,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/bplib/s3board/tb/tb_s3board_core.vbom b/rtl/bplib/s3board/tb/tb_s3board_core.vbom index d0331f93..72ab0ac2 100644 --- a/rtl/bplib/s3board/tb/tb_s3board_core.vbom +++ b/rtl/bplib/s3board/tb/tb_s3board_core.vbom @@ -1,6 +1,6 @@ # libs ../../../vlib/slvtypes.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/simlib/simbus.vhd # components ../../../vlib/serport/serport_uart_rx.vbom diff --git a/rtl/bplib/s3board/tb/tb_s3board_core.vhd b/rtl/bplib/s3board/tb/tb_s3board_core.vhd index 3644f442..21390749 100644 --- a/rtl/bplib/s3board/tb/tb_s3board_core.vhd +++ b/rtl/bplib/s3board/tb/tb_s3board_core.vhd @@ -1,4 +1,4 @@ --- $Id: tb_s3board_core.vhd 427 2011-11-19 21:04:11Z mueller $ +-- $Id: tb_s3board_core.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -35,7 +35,7 @@ use ieee.std_logic_textio.all; use std.textio.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.simbus.all; entity tb_s3board_core is diff --git a/rtl/bplib/s3board/tb/tb_s3board_fusp.vbom b/rtl/bplib/s3board/tb/tb_s3board_fusp.vbom index dd8d0abf..36784c8e 100644 --- a/rtl/bplib/s3board/tb/tb_s3board_fusp.vbom +++ b/rtl/bplib/s3board/tb/tb_s3board_fusp.vbom @@ -6,7 +6,7 @@ ../../../vlib/slvtypes.vhd ../../../vlib/rlink/rlinklib.vbom ../../../vlib/rlink/tb/rlinktblib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../s3boardlib.vbom ../../../vlib/simlib/simlib.vhd ../../../vlib/simlib/simbus.vhd diff --git a/rtl/bplib/s3board/tb/tb_s3board_fusp.vhd b/rtl/bplib/s3board/tb/tb_s3board_fusp.vhd index 1c7d2c21..6b26933b 100644 --- a/rtl/bplib/s3board/tb/tb_s3board_fusp.vhd +++ b/rtl/bplib/s3board/tb/tb_s3board_fusp.vhd @@ -1,4 +1,4 @@ --- $Id: tb_s3board_fusp.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_s3board_fusp.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -47,7 +47,7 @@ use std.textio.all; use work.slvtypes.all; use work.rlinklib.all; use work.rlinktblib.all; -use work.serport.all; +use work.serportlib.all; use work.s3boardlib.all; use work.simlib.all; use work.simbus.all; diff --git a/rtl/ibus/Makefile b/rtl/ibus/Makefile index 718b2efd..49cb4782 100644 --- a/rtl/ibus/Makefile +++ b/rtl/ibus/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,6 +8,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -18,5 +21,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/make/dontincdep.mk b/rtl/make/dontincdep.mk new file mode 100644 index 00000000..fd65fcac --- /dev/null +++ b/rtl/make/dontincdep.mk @@ -0,0 +1,21 @@ +# $Id: dontincdep.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +# +# DONTINCDEP controls whether dependency files are included. Set it if +# any of the 'clean' type targets is involved +# +ifneq ($(findstring clean, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifneq ($(findstring realclean, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifneq ($(findstring distclean, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifdef DONTINCDEP +$(info DONTINCDEP set, *.dep files not included) +endif diff --git a/rtl/make/generic_ghdl.mk b/rtl/make/generic_ghdl.mk index 824f944e..46123c46 100644 --- a/rtl/make/generic_ghdl.mk +++ b/rtl/make/generic_ghdl.mk @@ -1,7 +1,8 @@ -# $Id: generic_ghdl.mk 405 2011-08-14 08:16:28Z mueller $ +# $Id: generic_ghdl.mk 477 2013-01-27 14:07:10Z mueller $ # # Revision History: -# Date Rev Version Comment +# Date Rev Version Comment +# 2013-01-27 477 1.3.1 use dontincdep.mk to suppress .dep include on clean # 2011-08-13 405 1.3 renamed, moved to rtl/make; # 2007-11-04 95 1.2.2 fix find statement in ghdl_tmp_clean # 2007-11-02 94 1.2.1 don't delete cext_*.o in ghdl_tmp_clean @@ -33,6 +34,8 @@ LINK.vhd = $(GHDL) -e $(GHDLIEEE) %.dep_ghdl: %.vbom vbomconv --dep_ghdl $< > $@ # +include $(RETROBASE)/rtl/make/dontincdep.mk +# .PHONY: ghdl_clean ghdl_tmp_clean # ghdl_clean: ghdl_tmp_clean diff --git a/rtl/make/generic_isim.mk b/rtl/make/generic_isim.mk index a1716b76..a58c4bab 100644 --- a/rtl/make/generic_isim.mk +++ b/rtl/make/generic_isim.mk @@ -1,7 +1,8 @@ -# $Id: generic_isim.mk 405 2011-08-14 08:16:28Z mueller $ +# $Id: generic_isim.mk 477 2013-01-27 14:07:10Z mueller $ # # Revision History: -# Date Rev Version Comment +# Date Rev Version Comment +# 2013-01-27 477 1.2.1 use dontincdep.mk to suppress .dep include on clean # 2011-08-13 405 1.2 renamed, moved to rtl/make; # 2010-04-26 284 1.1 add _[sft]sim support # 2009-11-22 252 1.0 Initial version @@ -35,6 +36,8 @@ FUSE = fuse %.dep_isim: %.vbom vbomconv --dep_isim $< > $@ # +include $(RETROBASE)/rtl/make/dontincdep.mk +# .PHONY: isim_clean isim_tmp_clean # isim_clean: isim_tmp_clean diff --git a/rtl/make/generic_xflow.mk b/rtl/make/generic_xflow.mk index 45a41ddf..86522464 100644 --- a/rtl/make/generic_xflow.mk +++ b/rtl/make/generic_xflow.mk @@ -1,7 +1,9 @@ -# $Id: generic_xflow.mk 470 2013-01-05 17:28:46Z mueller $ +# $Id: generic_xflow.mk 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment +# 2013-01-27 477 1.8 remove defaults for ISE_(BOARD|PATH) and XFLOWOPT_* +# use dontincdep.mk to suppress .dep include on clean # 2013-01-05 470 1.7.6 remove '-r' from all non-dir clean rm's # 2012-02-05 456 1.7.5 use vbomvonv --get_top for xflow calls # 2012-01-08 451 1.7.4 use xilinx_ghdl_sdf_filter @@ -40,11 +42,11 @@ # setup default board (for impact), device and userid (for bitgen) # ifndef ISE_BOARD -ISE_BOARD = s3board +$(error ISE_BOARD is not defined) endif # ifndef ISE_PATH -ISE_PATH = xc3s1000-ft256-4 +$(error ISE_PATH is not defined) endif # ifndef ISE_USERID @@ -54,11 +56,11 @@ endif # setup defaults for xflow option files for synthesis and implementation # ifndef XFLOWOPT_SYN -XFLOWOPT_SYN = syn_s3_speed.opt +$(error XFLOWOPT_SYN is not defined) endif # ifndef XFLOWOPT_IMP -XFLOWOPT_IMP = imp_s3_speed.opt +$(error XFLOWOPT_IMP is not defined) endif # XFLOW = xflow -p ${ISE_PATH} @@ -298,6 +300,8 @@ endif cpp -I${RETROBASE}/rtl -MM $*.ucf_cpp |\ sed 's/\.o:/\.ucf:/' > $*.dep_ucf_cpp # +include $(RETROBASE)/rtl/make/dontincdep.mk +# .PHONY : ise_clean ise_tmp_clean # ise_clean: ise_tmp_clean diff --git a/rtl/make/xflow_default_atlys.mk b/rtl/make/xflow_default_atlys.mk new file mode 100644 index 00000000..16007abf --- /dev/null +++ b/rtl/make/xflow_default_atlys.mk @@ -0,0 +1,24 @@ +# $Id: xflow_default_atlys.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +#--- +# +# Setup for Digilent Atlys +# +# setup default board (for impact), device and userid (for bitgen) +# +ISE_BOARD = atlys +ISE_PATH = xc6slx45-csg324-2 +# +# setup defaults for xflow option files for synthesis and implementation +# +ifndef XFLOWOPT_SYN +XFLOWOPT_SYN = syn_s6_speed.opt +endif +# +ifndef XFLOWOPT_IMP +XFLOWOPT_IMP = imp_s6_speed.opt +endif +# diff --git a/rtl/make/xflow_default_nexys2.mk b/rtl/make/xflow_default_nexys2.mk new file mode 100644 index 00000000..e35d34dc --- /dev/null +++ b/rtl/make/xflow_default_nexys2.mk @@ -0,0 +1,24 @@ +# $Id: xflow_default_nexys2.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +#--- +# +# Setup for Digilent Nexys2 +# +# setup default board (for impact), device and userid (for bitgen) +# +ISE_BOARD = nexys2 +ISE_PATH = xc3s1200e-fg320-4 +# +# setup defaults for xflow option files for synthesis and implementation +# +ifndef XFLOWOPT_SYN +XFLOWOPT_SYN = syn_s3_speed.opt +endif +# +ifndef XFLOWOPT_IMP +XFLOWOPT_IMP = imp_s3_speed.opt +endif +# diff --git a/rtl/make/xflow_default_nexys3.mk b/rtl/make/xflow_default_nexys3.mk new file mode 100644 index 00000000..0c2e15b4 --- /dev/null +++ b/rtl/make/xflow_default_nexys3.mk @@ -0,0 +1,24 @@ +# $Id: xflow_default_nexys3.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +#--- +# +# Setup for Digilent Nexys3 +# +# setup default board (for impact), device and userid (for bitgen) +# +ISE_BOARD = nexys3 +ISE_PATH = xc6slx16-csg324-2 +# +# setup defaults for xflow option files for synthesis and implementation +# +ifndef XFLOWOPT_SYN +XFLOWOPT_SYN = syn_s6_speed.opt +endif +# +ifndef XFLOWOPT_IMP +XFLOWOPT_IMP = imp_s6_speed.opt +endif +# diff --git a/rtl/make/xflow_default_s3board.mk b/rtl/make/xflow_default_s3board.mk new file mode 100644 index 00000000..79996183 --- /dev/null +++ b/rtl/make/xflow_default_s3board.mk @@ -0,0 +1,24 @@ +# $Id: xflow_default_s3board.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +#--- +# +# Setup for Digilent S3BOARD (with 1000 die size) +# +# setup default board (for impact), device and userid (for bitgen) +# +ISE_BOARD = s3board +ISE_PATH = xc3s1000-ft256-4 +# +# setup defaults for xflow option files for synthesis and implementation +# +ifndef XFLOWOPT_SYN +XFLOWOPT_SYN = syn_s3_speed.opt +endif +# +ifndef XFLOWOPT_IMP +XFLOWOPT_IMP = imp_s3_speed.opt +endif +# diff --git a/rtl/make/xflow_default_s3board_200.mk b/rtl/make/xflow_default_s3board_200.mk new file mode 100644 index 00000000..968068b5 --- /dev/null +++ b/rtl/make/xflow_default_s3board_200.mk @@ -0,0 +1,24 @@ +# $Id: xflow_default_s3board_200.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +#--- +# +# Setup for Digilent S3BOARD (with 200 die size) +# +# setup default board (for impact), device and userid (for bitgen) +# +ISE_BOARD = s3board +ISE_PATH = xc3s200-ft256-4 +# +# setup defaults for xflow option files for synthesis and implementation +# +ifndef XFLOWOPT_SYN +XFLOWOPT_SYN = syn_s3_speed.opt +endif +# +ifndef XFLOWOPT_IMP +XFLOWOPT_IMP = imp_s3_speed.opt +endif +# diff --git a/rtl/sys_gen/tst_fx2loop/Makefile b/rtl/sys_gen/tst_fx2loop/Makefile index da6f21b2..dfaf7b53 100644 --- a/rtl/sys_gen/tst_fx2loop/Makefile +++ b/rtl/sys_gen/tst_fx2loop/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 470 2013-01-05 17:28:46Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,7 +9,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean realclean # @@ -34,5 +34,7 @@ tst_fx2loop_si : tst_fx2loop_si.c # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/sys_gen/tst_fx2loop/nexys2/ic/Makefile b/rtl/sys_gen/tst_fx2loop/nexys2/ic/Makefile index 3771c659..9c7758d9 100644 --- a/rtl/sys_gen/tst_fx2loop/nexys2/ic/Makefile +++ b/rtl/sys_gen/tst_fx2loop/nexys2/ic/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 453 2012-01-15 17:51:18Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk FX2_FILE = nexys2_jtag_2fifo_ic.ihx # .PHONY : all clean @@ -24,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_fx2loop/nexys2/ic3/Makefile b/rtl/sys_gen/tst_fx2loop/nexys2/ic3/Makefile index 7d0c3f7e..49ddfc32 100644 --- a/rtl/sys_gen/tst_fx2loop/nexys2/ic3/Makefile +++ b/rtl/sys_gen/tst_fx2loop/nexys2/ic3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 453 2012-01-15 17:51:18Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk FX2_FILE = nexys2_jtag_3fifo_ic.ihx # .PHONY : all clean @@ -24,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/Makefile b/rtl/sys_gen/tst_rlink/Makefile index 93aa6e89..9e35b1db 100644 --- a/rtl/sys_gen/tst_rlink/Makefile +++ b/rtl/sys_gen/tst_rlink/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 438 2011-12-11 23:40:52Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean realclean # @@ -20,5 +20,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/sys_gen/tst_rlink/nexys2/Makefile b/rtl/sys_gen/tst_rlink/nexys2/Makefile index 2e0dae61..f220dbd7 100644 --- a/rtl/sys_gen/tst_rlink/nexys2/Makefile +++ b/rtl/sys_gen/tst_rlink/nexys2/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -23,6 +22,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vbom b/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vbom index 3a753d32..baa4cca0 100644 --- a/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vbom +++ b/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vbom @@ -2,10 +2,11 @@ ../../../vlib/slvtypes.vhd ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ${sys_conf := sys_conf.vhd} # components diff --git a/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vhd b/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vhd index 0aa92a7a..74204e70 100644 --- a/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vhd +++ b/rtl/sys_gen/tst_rlink/nexys2/sys_tst_rlink_n2.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_n2.vhd 465 2012-12-27 21:29:38Z mueller $ +-- $Id: sys_tst_rlink_n2.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -74,10 +74,11 @@ use ieee.std_logic_1164.all; use work.slvtypes.all; use work.xlib.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.nxcramlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_rlink/nexys2/tb/Makefile b/rtl/sys_gen/tst_rlink/nexys2/tb/Makefile index fc5ad330..7d03fc43 100644 --- a/rtl/sys_gen/tst_rlink/nexys2/tb/Makefile +++ b/rtl/sys_gen/tst_rlink/nexys2/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ # EXE_all = tb_tst_rlink_n2 # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -25,7 +25,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/nexys3/Makefile b/rtl/sys_gen/tst_rlink/nexys3/Makefile index 9e419ba2..6e4efee7 100644 --- a/rtl/sys_gen/tst_rlink/nexys3/Makefile +++ b/rtl/sys_gen/tst_rlink/nexys3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all clean # @@ -25,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vbom b/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vbom index e3efcdd4..b8f4eb72 100644 --- a/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vbom +++ b/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vbom @@ -2,10 +2,11 @@ ../../../vlib/slvtypes.vhd ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ${sys_conf := sys_conf.vhd} # components diff --git a/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vhd b/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vhd index d002d69b..d9cdb60c 100644 --- a/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vhd +++ b/rtl/sys_gen/tst_rlink/nexys3/sys_tst_rlink_n3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_n3.vhd 442 2011-12-23 10:03:28Z mueller $ +-- $Id: sys_tst_rlink_n3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -65,10 +65,11 @@ use ieee.std_logic_1164.all; use work.slvtypes.all; use work.xlib.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.nxcramlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_rlink/nexys3/tb/Makefile b/rtl/sys_gen/tst_rlink/nexys3/tb/Makefile index 054791cb..c562ec3d 100644 --- a/rtl/sys_gen/tst_rlink/nexys3/tb/Makefile +++ b/rtl/sys_gen/tst_rlink/nexys3/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 433 2011-11-27 22:04:39Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,11 +6,7 @@ # EXE_all = tb_tst_rlink_n3 # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -28,7 +24,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/s3board/Makefile b/rtl/sys_gen/tst_rlink/s3board/Makefile index ef7e408c..7fd792d0 100644 --- a/rtl/sys_gen/tst_rlink/s3board/Makefile +++ b/rtl/sys_gen/tst_rlink/s3board/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = s3board -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -22,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vbom b/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vbom index 194c40e5..6fef3b55 100644 --- a/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vbom +++ b/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vbom @@ -1,10 +1,11 @@ # libs ../../../vlib/slvtypes.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../bplib/s3board/s3boardlib.vbom ${sys_conf := sys_conf.vhd} # components diff --git a/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vhd b/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vhd index 40121d29..c4bf874f 100644 --- a/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vhd +++ b/rtl/sys_gen/tst_rlink/s3board/sys_tst_rlink_s3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_s3.vhd 442 2011-12-23 10:03:28Z mueller $ +-- $Id: sys_tst_rlink_s3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -60,10 +60,11 @@ use ieee.std_logic_1164.all; use work.slvtypes.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.s3boardlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_rlink/s3board/tb/Makefile b/rtl/sys_gen/tst_rlink/s3board/tb/Makefile index 6cc24536..f6c161f5 100644 --- a/rtl/sys_gen/tst_rlink/s3board/tb/Makefile +++ b/rtl/sys_gen/tst_rlink/s3board/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 442 2011-12-23 10:03:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,7 +6,7 @@ # EXE_all = tb_tst_rlink_s3 # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all all_ssim all_tsim clean # @@ -24,7 +24,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/Makefile b/rtl/sys_gen/tst_rlink_cuff/Makefile index 31be037d..46e5bec5 100644 --- a/rtl/sys_gen/tst_rlink_cuff/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 466 2012-12-30 13:26:55Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean realclean # @@ -20,5 +20,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/atlys/ic/Makefile b/rtl/sys_gen/tst_rlink_cuff/atlys/ic/Makefile index 66fd1148..5ffd541c 100644 --- a/rtl/sys_gen/tst_rlink_cuff/atlys/ic/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/atlys/ic/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 472 2013-01-06 14:39:10Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,13 +8,9 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = atlys -ISE_PATH = xc6slx45-csg324-2 +include $(RETROBASE)/rtl/make/xflow_default_atlys.mk FX2_FILE = nexys3_jtag_2fifo_ic.ihx # -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt -# .PHONY : all clean # all : $(BIT_all) @@ -27,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vbom b/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vbom index fccd98e9..8fae2a61 100644 --- a/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vbom +++ b/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vbom @@ -9,6 +9,7 @@ ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../vlib/rbus/rblib.vhd ../../../bplib/fx2lib/fx2lib.vhd ${sys_conf} diff --git a/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vhd b/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vhd index cdd1edcb..95b45ab3 100644 --- a/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vhd +++ b/rtl/sys_gen/tst_rlink_cuff/atlys/sys_tst_rlink_cuff_atlys.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_cuff_atlys.vhd 472 2013-01-06 14:39:10Z mueller $ +-- $Id: sys_tst_rlink_cuff_atlys.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2013- by Walter F.J. Mueller -- @@ -18,7 +18,7 @@ -- Dependencies: vlib/xlib/dcm_sfs -- vlib/genlib/clkdivce -- bplib/bpgen/bp_rs232_2l4l_iob --- bplib/bpgen/sn_humanio_rbus +-- bplib/bpgen/sn_humanio_demu_rbus -- bplib/fx2lib/fx2_2fifoctl_as [sys_conf_fx2_type="as2"] -- bplib/fx2lib/fx2_2fifoctl_ic [sys_conf_fx2_type="ic2"] -- bplib/fx2lib/fx2_3fifoctl_ic [sys_conf_fx2_type="ic3"] @@ -40,7 +40,7 @@ ------------------------------------------------------------------------------ -- Usage of Atlys Switches, Buttons, LEDs: -- --- SWI(7:3) no function (only connected to sn_humanio_rbus) +-- SWI(7:3) no function (only connected to sn_humanio_demu_rbus) -- (2) 0 -> int/ext RS242 port for rlink -- 1 -> use USB interface for rlink -- (1) 1 enable XON @@ -48,7 +48,7 @@ -- 1 -> Pmod B/top RS232 port / -- -- LED(7) SER_MONI.abact --- (6:2) no function (only connected to sn_humanio_rbus) +-- (6:2) no function (only connected to sn_humanio_demu_rbus) -- (0) timer 0 busy -- (1) timer 1 busy -- @@ -73,6 +73,7 @@ use work.slvtypes.all; use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.rblib.all; use work.fx2lib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/Makefile b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/Makefile index d395bf92..83a7500b 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 466 2012-12-30 13:26:55Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk FX2_FILE = nexys2_jtag_2fifo_ic.ihx # .PHONY : all clean @@ -24,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/tb/Makefile b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/tb/Makefile index 6881acd7..cf7527e9 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/tb/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 467 2013-01-02 19:49:05Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,7 +6,7 @@ # EXE_all = tb_tst_rlink_cuff_ic_n2 # -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -24,7 +24,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic3/Makefile b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic3/Makefile index 2913e044..aeaf7575 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys2/ic3/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/nexys2/ic3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 466 2012-12-30 13:26:55Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk FX2_FILE = nexys2_jtag_3fifo_ic.ihx # .PHONY : all clean @@ -24,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vbom b/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vbom index aaf6c761..95be5712 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vbom +++ b/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vbom @@ -9,6 +9,7 @@ ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../vlib/rbus/rblib.vhd ../../../bplib/fx2lib/fx2lib.vhd ../../../bplib/nxcramlib/nxcramlib.vhd diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vhd b/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vhd index d23224a2..049a1d74 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vhd +++ b/rtl/sys_gen/tst_rlink_cuff/nexys2/sys_tst_rlink_cuff_n2.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_cuff_n2.vhd 469 2013-01-05 12:29:44Z mueller $ +-- $Id: sys_tst_rlink_cuff_n2.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2012-2013 by Walter F.J. Mueller -- @@ -77,6 +77,7 @@ use work.slvtypes.all; use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.rblib.all; use work.fx2lib.all; use work.nxcramlib.all; diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys3/ic/Makefile b/rtl/sys_gen/tst_rlink_cuff/nexys3/ic/Makefile index 90439ff9..a1dbee51 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys3/ic/Makefile +++ b/rtl/sys_gen/tst_rlink_cuff/nexys3/ic/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 469 2013-01-05 12:29:44Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,13 +8,9 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk FX2_FILE = nexys3_jtag_2fifo_ic.ihx # -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt -# .PHONY : all clean # all : $(BIT_all) @@ -27,6 +23,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vbom b/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vbom index e6730df4..40c1f70a 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vbom +++ b/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vbom @@ -9,6 +9,7 @@ ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../vlib/rbus/rblib.vhd ../../../bplib/fx2lib/fx2lib.vhd ../../../bplib/nxcramlib/nxcramlib.vhd diff --git a/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vhd b/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vhd index ac60d156..dba61d71 100644 --- a/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vhd +++ b/rtl/sys_gen/tst_rlink_cuff/nexys3/sys_tst_rlink_cuff_n3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_rlink_cuff_n3.vhd 469 2013-01-05 12:29:44Z mueller $ +-- $Id: sys_tst_rlink_cuff_n3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2013- by Walter F.J. Mueller -- @@ -74,6 +74,7 @@ use work.slvtypes.all; use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.rblib.all; use work.fx2lib.all; use work.nxcramlib.all; diff --git a/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vbom b/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vbom index 4153ad63..57f06713 100644 --- a/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vbom +++ b/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vbom @@ -3,7 +3,7 @@ ../../vlib/genlib/genlib.vhd ../../vlib/rbus/rblib.vhd ../../vlib/rlink/rlinklib.vbom -../../vlib/serport/serport.vhd +../../vlib/serport/serportlib.vbom ../../bplib/fx2lib/fx2lib.vhd ${sys_conf := nexys2/as/sys_conf.vhd} # components diff --git a/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vhd b/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vhd index 0a987907..281deb35 100644 --- a/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vhd +++ b/rtl/sys_gen/tst_rlink_cuff/tst_rlink_cuff.vhd @@ -1,4 +1,4 @@ --- $Id: tst_rlink_cuff.vhd 467 2013-01-02 19:49:05Z mueller $ +-- $Id: tst_rlink_cuff.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2012-2013 by Walter F.J. Mueller -- @@ -41,7 +41,7 @@ use work.slvtypes.all; use work.genlib.all; use work.rblib.all; use work.rlinklib.all; -use work.serport.all; +use work.serportlib.all; use work.fx2lib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_serloop/Makefile b/rtl/sys_gen/tst_serloop/Makefile index 19afe4f0..53be7e89 100644 --- a/rtl/sys_gen/tst_serloop/Makefile +++ b/rtl/sys_gen/tst_serloop/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 441 2011-12-20 17:01:16Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean realclean # @@ -22,5 +22,7 @@ realclean : # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/sys_gen/tst_serloop/nexys2/Makefile b/rtl/sys_gen/tst_serloop/nexys2/Makefile index 953ee4c6..e4824818 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/Makefile +++ b/rtl/sys_gen/tst_serloop/nexys2/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -22,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vbom b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vbom index 8da2105d..3b404c42 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vbom +++ b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vbom @@ -3,7 +3,7 @@ ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom ../tst_serlooplib.vbom -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ${sys_conf := sys_conf1.vhd} # components diff --git a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vhd b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vhd index cfb83e70..03d2c914 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vhd +++ b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop1_n2.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_serloop1_n2.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: sys_tst_serloop1_n2.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -48,7 +48,7 @@ use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; use work.tst_serlooplib.all; -use work.serport.all; +use work.serportlib.all; use work.nxcramlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vbom b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vbom index 60362187..5f3ac20a 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vbom +++ b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vbom @@ -4,7 +4,7 @@ ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom ../tst_serlooplib.vbom -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ${sys_conf := sys_conf2.vhd} # components diff --git a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vhd b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vhd index 92ec5b5c..c9feb43e 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vhd +++ b/rtl/sys_gen/tst_serloop/nexys2/sys_tst_serloop2_n2.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_serloop2_n2.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: sys_tst_serloop2_n2.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -56,7 +56,7 @@ use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; use work.tst_serlooplib.all; -use work.serport.all; +use work.serportlib.all; use work.nxcramlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_serloop/nexys2/tb/Makefile b/rtl/sys_gen/tst_serloop/nexys2/tb/Makefile index cd05f47b..73ecc537 100644 --- a/rtl/sys_gen/tst_serloop/nexys2/tb/Makefile +++ b/rtl/sys_gen/tst_serloop/nexys2/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ EXE_all = tb_tst_serloop1_n2 EXE_all += tb_tst_serloop2_n2 # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -26,8 +25,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/nexys3/Makefile b/rtl/sys_gen/tst_serloop/nexys3/Makefile index 669f1aae..7430a779 100644 --- a/rtl/sys_gen/tst_serloop/nexys3/Makefile +++ b/rtl/sys_gen/tst_serloop/nexys3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all clean # @@ -25,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vbom b/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vbom index 615064ab..57e800a1 100644 --- a/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vbom +++ b/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vbom @@ -4,7 +4,7 @@ ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom ../tst_serlooplib.vbom -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ${sys_conf := sys_conf1.vhd} # components diff --git a/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vhd b/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vhd index 3184b0fa..8e38b1e9 100644 --- a/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vhd +++ b/rtl/sys_gen/tst_serloop/nexys3/sys_tst_serloop1_n3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_serloop1_n3.vhd 441 2011-12-20 17:01:16Z mueller $ +-- $Id: sys_tst_serloop1_n3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -47,7 +47,7 @@ use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; use work.tst_serlooplib.all; -use work.serport.all; +use work.serportlib.all; use work.nxcramlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_serloop/nexys3/tb/Makefile b/rtl/sys_gen/tst_serloop/nexys3/tb/Makefile index f5bb4f0d..ef77128b 100644 --- a/rtl/sys_gen/tst_serloop/nexys3/tb/Makefile +++ b/rtl/sys_gen/tst_serloop/nexys3/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ # EXE_all = tb_tst_serloop1_n3 # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -29,8 +25,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/s3board/Makefile b/rtl/sys_gen/tst_serloop/s3board/Makefile index a4051d3d..3d02f4c7 100644 --- a/rtl/sys_gen/tst_serloop/s3board/Makefile +++ b/rtl/sys_gen/tst_serloop/s3board/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = s3board -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -22,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vbom b/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vbom index 68118ad8..64a123f6 100644 --- a/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vbom +++ b/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vbom @@ -4,7 +4,7 @@ ../../../vlib/genlib/genlib.vhd ../../../bplib/bpgen/bpgenlib.vbom ../tst_serlooplib.vbom -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../bplib/s3board/s3boardlib.vbom ${sys_conf := sys_conf.vhd} # components diff --git a/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vhd b/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vhd index d1afcc2b..ee2bef9d 100644 --- a/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vhd +++ b/rtl/sys_gen/tst_serloop/s3board/sys_tst_serloop_s3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_tst_serloop_s3.vhd 441 2011-12-20 17:01:16Z mueller $ +-- $Id: sys_tst_serloop_s3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -52,7 +52,7 @@ use work.xlib.all; use work.genlib.all; use work.bpgenlib.all; use work.tst_serlooplib.all; -use work.serport.all; +use work.serportlib.all; use work.s3boardlib.all; use work.sys_conf.all; diff --git a/rtl/sys_gen/tst_serloop/s3board/tb/Makefile b/rtl/sys_gen/tst_serloop/s3board/tb/Makefile index b552b780..daaba848 100644 --- a/rtl/sys_gen/tst_serloop/s3board/tb/Makefile +++ b/rtl/sys_gen/tst_serloop/s3board/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 441 2011-12-20 17:01:16Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,6 +6,8 @@ # EXE_all = tb_tst_serloop_s3 # +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk +# .PHONY : all all_ssim all_tsim clean # all : $(EXE_all) @@ -22,8 +24,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vbom b/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vbom index b38ba85f..85efd037 100644 --- a/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vbom +++ b/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vbom @@ -1,7 +1,7 @@ # libs ../../../vlib/slvtypes.vhd ../../../vlib/simlib/simlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom # components ../../../vlib/simlib/simclkcnt.vbom ../../../vlib/serport/serport_uart_rxtx.vbom diff --git a/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vhd b/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vhd index b986d52c..7fb6ffe8 100644 --- a/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vhd +++ b/rtl/sys_gen/tst_serloop/tb/tb_tst_serloop.vhd @@ -1,4 +1,4 @@ --- $Id: tb_tst_serloop.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_tst_serloop.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -38,7 +38,7 @@ use std.textio.all; use work.slvtypes.all; use work.simlib.all; -use work.serport.all; +use work.serportlib.all; entity tb_tst_serloop is port ( diff --git a/rtl/sys_gen/tst_serloop/tst_serloop.vbom b/rtl/sys_gen/tst_serloop/tst_serloop.vbom index 53353984..b20f17dc 100644 --- a/rtl/sys_gen/tst_serloop/tst_serloop.vbom +++ b/rtl/sys_gen/tst_serloop/tst_serloop.vbom @@ -1,6 +1,6 @@ # libs ../../vlib/slvtypes.vhd -../../vlib/serport/serport.vhd +../../vlib/serport/serportlib.vbom tst_serlooplib.vhd # components # design diff --git a/rtl/sys_gen/tst_serloop/tst_serloop.vhd b/rtl/sys_gen/tst_serloop/tst_serloop.vhd index fcffb285..477ca50f 100644 --- a/rtl/sys_gen/tst_serloop/tst_serloop.vhd +++ b/rtl/sys_gen/tst_serloop/tst_serloop.vhd @@ -1,4 +1,4 @@ --- $Id: tst_serloop.vhd 441 2011-12-20 17:01:16Z mueller $ +-- $Id: tst_serloop.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -34,7 +34,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.tst_serlooplib.all; -- ---------------------------------------------------------------------------- diff --git a/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vbom b/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vbom index 5bbc805a..77f1eed2 100644 --- a/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vbom +++ b/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vbom @@ -1,6 +1,6 @@ # libs ../../vlib/slvtypes.vhd -../../vlib/serport/serport.vhd +../../vlib/serport/serportlib.vbom tst_serlooplib.vbom # components # design diff --git a/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vhd b/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vhd index 803665a3..71daa637 100644 --- a/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vhd +++ b/rtl/sys_gen/tst_serloop/tst_serloop_hiomap.vhd @@ -1,4 +1,4 @@ --- $Id: tst_serloop_hiomap.vhd 441 2011-12-20 17:01:16Z mueller $ +-- $Id: tst_serloop_hiomap.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -81,7 +81,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.tst_serlooplib.all; -- ---------------------------------------------------------------------------- diff --git a/rtl/sys_gen/tst_serloop/tst_serlooplib.vbom b/rtl/sys_gen/tst_serloop/tst_serlooplib.vbom index 049f81a0..00df7b17 100644 --- a/rtl/sys_gen/tst_serloop/tst_serlooplib.vbom +++ b/rtl/sys_gen/tst_serloop/tst_serlooplib.vbom @@ -1,3 +1,3 @@ # libs ../../vlib/slvtypes.vhd -../../vlib/serport/serport.vhd +../../vlib/serport/serportlib.vbom diff --git a/rtl/sys_gen/tst_serloop/tst_serlooplib.vhd b/rtl/sys_gen/tst_serloop/tst_serlooplib.vhd index f8a877c3..83cbbfcb 100644 --- a/rtl/sys_gen/tst_serloop/tst_serlooplib.vhd +++ b/rtl/sys_gen/tst_serloop/tst_serlooplib.vhd @@ -1,4 +1,4 @@ --- $Id: tst_serlooplib.vhd 441 2011-12-20 17:01:16Z mueller $ +-- $Id: tst_serlooplib.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -28,7 +28,7 @@ library ieee; use ieee.std_logic_1164.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; package tst_serlooplib is diff --git a/rtl/sys_gen/tst_snhumanio/Makefile b/rtl/sys_gen/tst_snhumanio/Makefile index 5fa96b75..0f685d42 100644 --- a/rtl/sys_gen/tst_snhumanio/Makefile +++ b/rtl/sys_gen/tst_snhumanio/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 410 2011-09-18 11:23:09Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,7 +7,7 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -19,5 +19,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/sys_gen/tst_snhumanio/atlys/Makefile b/rtl/sys_gen/tst_snhumanio/atlys/Makefile index 3dd572ba..de97a319 100644 --- a/rtl/sys_gen/tst_snhumanio/atlys/Makefile +++ b/rtl/sys_gen/tst_snhumanio/atlys/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = atlys -ISE_PATH = xc6slx45-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_atlys.mk # .PHONY : all clean # @@ -25,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_snhumanio/nexys2/Makefile b/rtl/sys_gen/tst_snhumanio/nexys2/Makefile index 894078e9..cf224cad 100644 --- a/rtl/sys_gen/tst_snhumanio/nexys2/Makefile +++ b/rtl/sys_gen/tst_snhumanio/nexys2/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -22,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_snhumanio/nexys3/Makefile b/rtl/sys_gen/tst_snhumanio/nexys3/Makefile index 669f1aae..7430a779 100644 --- a/rtl/sys_gen/tst_snhumanio/nexys3/Makefile +++ b/rtl/sys_gen/tst_snhumanio/nexys3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all clean # @@ -25,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/tst_snhumanio/s3board/Makefile b/rtl/sys_gen/tst_snhumanio/s3board/Makefile index 7103ed5d..cb71cff2 100644 --- a/rtl/sys_gen/tst_snhumanio/s3board/Makefile +++ b/rtl/sys_gen/tst_snhumanio/s3board/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = s3board -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -22,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/nexys2/Makefile b/rtl/sys_gen/w11a/nexys2/Makefile index a0e7d44e..3eb61892 100644 --- a/rtl/sys_gen/w11a/nexys2/Makefile +++ b/rtl/sys_gen/w11a/nexys2/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -8,8 +8,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys2 -ISE_PATH = xc3s1200e-fg320-4 +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all clean # @@ -28,6 +27,8 @@ sys_w11a_n2.mcs : sys_w11a_n2.bit include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vbom b/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vbom index 8f66523f..c35c87bd 100644 --- a/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vbom +++ b/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vbom @@ -2,10 +2,11 @@ ../../../vlib/slvtypes.vhd ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ../../../ibus/iblib.vhd ../../../ibus/ibdlib.vhd diff --git a/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vhd b/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vhd index 7c92ed6f..fb5791bd 100644 --- a/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vhd +++ b/rtl/sys_gen/w11a/nexys2/sys_w11a_n2.vhd @@ -1,4 +1,4 @@ --- $Id: sys_w11a_n2.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: sys_w11a_n2.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2010-2011 by Walter F.J. Mueller -- @@ -127,10 +127,11 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.xlib.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.nxcramlib.all; use work.iblib.all; use work.ibdlib.all; diff --git a/rtl/sys_gen/w11a/nexys2/tb/Makefile b/rtl/sys_gen/w11a/nexys2/tb/Makefile index 2336b4c4..95d57d98 100644 --- a/rtl/sys_gen/w11a/nexys2/tb/Makefile +++ b/rtl/sys_gen/w11a/nexys2/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,8 +7,7 @@ # EXE_all = tb_w11a_n2 # -ISE_PATH = xc3s1200e-fg320-4 -# +include $(RETROBASE)/rtl/make/xflow_default_nexys2.mk # .PHONY : all all_ssim all_tsim clean # @@ -25,7 +24,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/nexys3/Makefile b/rtl/sys_gen/w11a/nexys3/Makefile index 22546b0a..cd1f1847 100644 --- a/rtl/sys_gen/w11a/nexys3/Makefile +++ b/rtl/sys_gen/w11a/nexys3/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -7,11 +7,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = nexys3 -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all clean # @@ -25,6 +21,8 @@ clean : ise_clean include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vbom b/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vbom index d11b114f..7373844f 100644 --- a/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vbom +++ b/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vbom @@ -2,10 +2,11 @@ ../../../vlib/slvtypes.vhd ../../../vlib/xlib/xlib.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom +../../../bplib/bpgen/bpgenrbuslib.vbom ../../../bplib/nxcramlib/nxcramlib.vhd ../../../ibus/iblib.vhd ../../../ibus/ibdlib.vhd diff --git a/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vhd b/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vhd index ff1e379f..e236a77e 100644 --- a/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vhd +++ b/rtl/sys_gen/w11a/nexys3/sys_w11a_n3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_w11a_n3.vhd 440 2011-12-18 20:08:09Z mueller $ +-- $Id: sys_w11a_n3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -88,10 +88,11 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.xlib.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; +use work.bpgenrbuslib.all; use work.nxcramlib.all; use work.iblib.all; use work.ibdlib.all; diff --git a/rtl/sys_gen/w11a/nexys3/tb/Makefile b/rtl/sys_gen/w11a/nexys3/tb/Makefile index 6e887665..9dcfb7d9 100644 --- a/rtl/sys_gen/w11a/nexys3/tb/Makefile +++ b/rtl/sys_gen/w11a/nexys3/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 432 2011-11-25 20:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -6,11 +6,7 @@ # EXE_all = tb_w11a_n3 # -ISE_PATH = xc6slx16-csg324-2 -# -XFLOWOPT_SYN = syn_s6_speed.opt -XFLOWOPT_IMP = imp_s6_speed.opt -# +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -27,7 +23,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/s3board/Makefile b/rtl/sys_gen/w11a/s3board/Makefile index 9aa614cf..7346ae69 100644 --- a/rtl/sys_gen/w11a/s3board/Makefile +++ b/rtl/sys_gen/w11a/s3board/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 448 2012-01-02 21:55:11Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -13,8 +13,7 @@ VBOM_all = $(wildcard *.vbom) BIT_all = $(VBOM_all:.vbom=.bit) # -ISE_BOARD = s3board -ISE_PATH = xc3s1000-ft256-4 +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all clean # @@ -33,6 +32,8 @@ sys_w11a_s3.mcs : sys_w11a_s3.bit include $(RETROBASE)/rtl/make/generic_xflow.mk include $(RETROBASE)/rtl/make/generic_ghdl.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vbom b/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vbom index f02b629e..1edcf187 100644 --- a/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vbom +++ b/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vbom @@ -1,7 +1,7 @@ # libs ../../../vlib/slvtypes.vhd ../../../vlib/genlib/genlib.vhd -../../../vlib/serport/serport.vhd +../../../vlib/serport/serportlib.vbom ../../../vlib/rbus/rblib.vhd ../../../vlib/rlink/rlinklib.vbom ../../../bplib/bpgen/bpgenlib.vbom diff --git a/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vhd b/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vhd index d9809cbf..ddd5ba63 100644 --- a/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vhd +++ b/rtl/sys_gen/w11a/s3board/sys_w11a_s3.vhd @@ -1,4 +1,4 @@ --- $Id: sys_w11a_s3.vhd 442 2011-12-23 10:03:28Z mueller $ +-- $Id: sys_w11a_s3.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -155,7 +155,7 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; use work.rblib.all; use work.rlinklib.all; use work.bpgenlib.all; diff --git a/rtl/sys_gen/w11a/s3board/tb/Makefile b/rtl/sys_gen/w11a/s3board/tb/Makefile index 1f45854a..6e29026f 100644 --- a/rtl/sys_gen/w11a/s3board/tb/Makefile +++ b/rtl/sys_gen/w11a/s3board/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,8 +9,7 @@ # EXE_all = tb_w11a_s3 # -ISE_PATH = xc3s1000-ft256-4 -# +include $(RETROBASE)/rtl/make/xflow_default_s3board.mk # .PHONY : all all_ssim all_tsim clean # @@ -27,7 +26,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/sys_gen/w11a/tb/dorri b/rtl/sys_gen/w11a/tb/dorri index c3e580b6..033b85d8 100755 --- a/rtl/sys_gen/w11a/tb/dorri +++ b/rtl/sys_gen/w11a/tb/dorri @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: dorri 435 2011-12-04 20:15:25Z mueller $ +# $Id: dorri 503 2013-04-06 19:44:13Z mueller $ # # Revision History: # Date Rev Version Comment @@ -22,7 +22,7 @@ sub print_usage; autoflush STDOUT 1; # autoflush, so noting lost on exec later my $opt_b; -my $opt_io; +my $opt_io = ''; my $opt_tmu; my $pirri; my $val_cmax="3"; diff --git a/rtl/vlib/comlib/Makefile b/rtl/vlib/comlib/Makefile index df93ae92..bf603668 100644 --- a/rtl/vlib/comlib/Makefile +++ b/rtl/vlib/comlib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/comlib/misc/Makefile b/rtl/vlib/comlib/misc/Makefile index 345eff06..e58a5066 100644 --- a/rtl/vlib/comlib/misc/Makefile +++ b/rtl/vlib/comlib/misc/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -20,7 +20,7 @@ include $(RETROBASE)/rtl/make/generic_ghdl.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_ghdl) -# -#----- +endif # diff --git a/rtl/vlib/genlib/Makefile b/rtl/vlib/genlib/Makefile index ae164457..ae5e9ab2 100644 --- a/rtl/vlib/genlib/Makefile +++ b/rtl/vlib/genlib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -10,6 +10,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -20,5 +23,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/memlib/Makefile b/rtl/vlib/memlib/Makefile index b11b5278..e06637fa 100644 --- a/rtl/vlib/memlib/Makefile +++ b/rtl/vlib/memlib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/rbus/Makefile b/rtl/vlib/rbus/Makefile index 7221555b..43781172 100644 --- a/rtl/vlib/rbus/Makefile +++ b/rtl/vlib/rbus/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/rlink/Makefile b/rtl/vlib/rlink/Makefile index 7221555b..43781172 100644 --- a/rtl/vlib/rlink/Makefile +++ b/rtl/vlib/rlink/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/rlink/rlink_sp1c.vbom b/rtl/vlib/rlink/rlink_sp1c.vbom index a690fe6d..8223d4e2 100644 --- a/rtl/vlib/rlink/rlink_sp1c.vbom +++ b/rtl/vlib/rlink/rlink_sp1c.vbom @@ -2,7 +2,7 @@ ../slvtypes.vhd ../rbus/rblib.vhd rlinklib.vbom -../serport/serport.vhd +../serport/serportlib.vbom # components rlink_core8.vbom ../serport/serport_1clock.vbom diff --git a/rtl/vlib/rlink/rlink_sp1c.vhd b/rtl/vlib/rlink/rlink_sp1c.vhd index ca92b311..2570f353 100644 --- a/rtl/vlib/rlink/rlink_sp1c.vhd +++ b/rtl/vlib/rlink/rlink_sp1c.vhd @@ -1,4 +1,4 @@ --- $Id: rlink_sp1c.vhd 437 2011-12-09 19:38:07Z mueller $ +-- $Id: rlink_sp1c.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -39,7 +39,7 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.rblib.all; use work.rlinklib.all; -use work.serport.all; +use work.serportlib.all; entity rlink_sp1c is -- rlink_core8+serport_1clock combo generic ( diff --git a/rtl/vlib/rlink/rlinklib.vbom b/rtl/vlib/rlink/rlinklib.vbom index 3595c692..48bbc30e 100644 --- a/rtl/vlib/rlink/rlinklib.vbom +++ b/rtl/vlib/rlink/rlinklib.vbom @@ -1,5 +1,5 @@ # libs ../slvtypes.vhd ../rbus/rblib.vhd -../serport/serport.vhd +../serport/serportlib.vbom rlinklib.vhd diff --git a/rtl/vlib/rlink/rlinklib.vhd b/rtl/vlib/rlink/rlinklib.vhd index d5a62c18..10fe8d2e 100644 --- a/rtl/vlib/rlink/rlinklib.vhd +++ b/rtl/vlib/rlink/rlinklib.vhd @@ -1,4 +1,4 @@ --- $Id: rlinklib.vhd 466 2012-12-30 13:26:55Z mueller $ +-- $Id: rlinklib.vhd 495 2013-03-06 17:13:48Z mueller $ -- -- Copyright 2007-2012 by Walter F.J. Mueller -- @@ -56,7 +56,7 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.rblib.all; -use work.serport.all; +use work.serportlib.all; package rlinklib is @@ -79,7 +79,7 @@ constant c_rlink_cmd_init : slv3 := "110"; constant c_rlink_iint_rbf_anena: integer := 15; -- anena flag constant c_rlink_iint_rbf_itoena: integer := 14; -- itoena flag -subtype c_rlink_iint_rbf_itoval is integer range 7 downto 0; -- command code +subtype c_rlink_iint_rbf_itoval is integer range 7 downto 0; -- itoval value subtype c_rlink_cmd_rbf_seq is integer range 7 downto 3; -- sequence number subtype c_rlink_cmd_rbf_code is integer range 2 downto 0; -- command code diff --git a/rtl/vlib/rlink/tb/Makefile b/rtl/vlib/rlink/tb/Makefile index 467ec3b2..07a4b24b 100644 --- a/rtl/vlib/rlink/tb/Makefile +++ b/rtl/vlib/rlink/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 442 2011-12-23 10:03:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -13,6 +13,8 @@ EXE_all = tb_rlink_direct EXE_all += tb_rlink_sp1c # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -30,8 +32,10 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # diff --git a/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vbom b/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vbom index 3dda956e..761c6b32 100644 --- a/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vbom +++ b/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vbom @@ -1,7 +1,7 @@ # libs ../../slvtypes.vhd ../../comlib/comlib.vhd -../../serport/serport.vhd +../../serport/serportlib.vbom ../../rbus/rblib.vhd ../rlinklib.vbom ../../simlib/simlib.vhd diff --git a/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vhd b/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vhd index e34812f0..762b06b4 100644 --- a/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vhd +++ b/rtl/vlib/rlink/tb/tbd_rlink_sp1c.vhd @@ -1,4 +1,4 @@ --- $Id: tbd_rlink_sp1c.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tbd_rlink_sp1c.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -63,7 +63,7 @@ use std.textio.all; use work.slvtypes.all; use work.rlinklib.all; use work.comlib.all; -use work.serport.all; +use work.serportlib.all; use work.simlib.all; use work.simbus.all; diff --git a/rtl/vlib/serport/Makefile b/rtl/vlib/serport/Makefile index 5086e35d..9ffe7042 100644 --- a/rtl/vlib/serport/Makefile +++ b/rtl/vlib/serport/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/vlib/serport/serport_1clock.vbom b/rtl/vlib/serport/serport_1clock.vbom index 2d9ded4a..5fdc17df 100644 --- a/rtl/vlib/serport/serport_1clock.vbom +++ b/rtl/vlib/serport/serport_1clock.vbom @@ -1,6 +1,6 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom ../memlib/memlib.vhd # components serport_uart_rxtx_ab.vbom diff --git a/rtl/vlib/serport/serport_1clock.vhd b/rtl/vlib/serport/serport_1clock.vhd index 9d264e53..8794a63d 100644 --- a/rtl/vlib/serport/serport_1clock.vhd +++ b/rtl/vlib/serport/serport_1clock.vhd @@ -1,4 +1,4 @@ --- $Id: serport_1clock.vhd 438 2011-12-11 23:40:52Z mueller $ +-- $Id: serport_1clock.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -40,7 +40,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.memlib.all; entity serport_1clock is -- serial port module, 1 clock domain diff --git a/rtl/vlib/serport/serport_2clock.vbom b/rtl/vlib/serport/serport_2clock.vbom index 7ab1b182..0dff738a 100644 --- a/rtl/vlib/serport/serport_2clock.vbom +++ b/rtl/vlib/serport/serport_2clock.vbom @@ -1,6 +1,6 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom ../genlib/genlib.vhd ../memlib/memlib.vhd # components diff --git a/rtl/vlib/serport/serport_2clock.vhd b/rtl/vlib/serport/serport_2clock.vhd index 457fe34f..1944ca62 100644 --- a/rtl/vlib/serport/serport_2clock.vhd +++ b/rtl/vlib/serport/serport_2clock.vhd @@ -1,4 +1,4 @@ --- $Id: serport_2clock.vhd 438 2011-12-11 23:40:52Z mueller $ +-- $Id: serport_2clock.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -41,7 +41,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; use work.genlib.all; use work.memlib.all; diff --git a/rtl/vlib/serport/serport_uart_rxtx.vbom b/rtl/vlib/serport/serport_uart_rxtx.vbom index cc39b2db..8172fe4a 100644 --- a/rtl/vlib/serport/serport_uart_rxtx.vbom +++ b/rtl/vlib/serport/serport_uart_rxtx.vbom @@ -1,6 +1,6 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom # components serport_uart_rx.vbom serport_uart_tx.vbom diff --git a/rtl/vlib/serport/serport_uart_rxtx.vhd b/rtl/vlib/serport/serport_uart_rxtx.vhd index 586d87bc..fb6d006b 100644 --- a/rtl/vlib/serport/serport_uart_rxtx.vhd +++ b/rtl/vlib/serport/serport_uart_rxtx.vhd @@ -1,4 +1,4 @@ --- $Id: serport_uart_rxtx.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: serport_uart_rxtx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -30,7 +30,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity serport_uart_rxtx is -- serial port uart: rx+tx combo generic ( diff --git a/rtl/vlib/serport/serport_uart_rxtx_ab.vbom b/rtl/vlib/serport/serport_uart_rxtx_ab.vbom index 5d13fcb3..84083944 100644 --- a/rtl/vlib/serport/serport_uart_rxtx_ab.vbom +++ b/rtl/vlib/serport/serport_uart_rxtx_ab.vbom @@ -1,6 +1,6 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom # components serport_uart_autobaud.vbom serport_uart_rxtx.vbom diff --git a/rtl/vlib/serport/serport_uart_rxtx_ab.vhd b/rtl/vlib/serport/serport_uart_rxtx_ab.vhd index fe6523f0..67fd43f2 100644 --- a/rtl/vlib/serport/serport_uart_rxtx_ab.vhd +++ b/rtl/vlib/serport/serport_uart_rxtx_ab.vhd @@ -1,4 +1,4 @@ --- $Id: serport_uart_rxtx_ab.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: serport_uart_rxtx_ab.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -37,7 +37,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity serport_uart_rxtx_ab is -- serial port uart: rx+tx+autobaud generic ( diff --git a/rtl/vlib/serport/serport_xonrx.vbom b/rtl/vlib/serport/serport_xonrx.vbom index ea8e2821..4c603498 100644 --- a/rtl/vlib/serport/serport_xonrx.vbom +++ b/rtl/vlib/serport/serport_xonrx.vbom @@ -1,5 +1,5 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom # design serport_xonrx.vhd diff --git a/rtl/vlib/serport/serport_xonrx.vhd b/rtl/vlib/serport/serport_xonrx.vhd index be9e54f5..4447e5d9 100644 --- a/rtl/vlib/serport/serport_xonrx.vhd +++ b/rtl/vlib/serport/serport_xonrx.vhd @@ -1,4 +1,4 @@ --- $Id: serport_xonrx.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: serport_xonrx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -29,7 +29,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity serport_xonrx is -- serial port: xon/xoff logic rx path port ( diff --git a/rtl/vlib/serport/serport_xontx.vbom b/rtl/vlib/serport/serport_xontx.vbom index e1475c8e..5b691728 100644 --- a/rtl/vlib/serport/serport_xontx.vbom +++ b/rtl/vlib/serport/serport_xontx.vbom @@ -1,5 +1,5 @@ # libs ../slvtypes.vhd -serport.vhd +serportlib.vbom # design serport_xontx.vhd diff --git a/rtl/vlib/serport/serport_xontx.vhd b/rtl/vlib/serport/serport_xontx.vhd index 29b16b1f..145ea1a0 100644 --- a/rtl/vlib/serport/serport_xontx.vhd +++ b/rtl/vlib/serport/serport_xontx.vhd @@ -1,4 +1,4 @@ --- $Id: serport_xontx.vhd 426 2011-11-18 18:14:08Z mueller $ +-- $Id: serport_xontx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2011- by Walter F.J. Mueller -- @@ -30,7 +30,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity serport_xontx is -- serial port: xon/xoff logic tx path port ( diff --git a/rtl/vlib/serport/serportlib.vbom b/rtl/vlib/serport/serportlib.vbom new file mode 100644 index 00000000..640c4119 --- /dev/null +++ b/rtl/vlib/serport/serportlib.vbom @@ -0,0 +1,3 @@ +# libs +../slvtypes.vhd +serportlib.vhd diff --git a/rtl/vlib/serport/serport.vhd b/rtl/vlib/serport/serportlib.vhd similarity index 97% rename from rtl/vlib/serport/serport.vhd rename to rtl/vlib/serport/serportlib.vhd index a07ed294..ec47be22 100644 --- a/rtl/vlib/serport/serport.vhd +++ b/rtl/vlib/serport/serportlib.vhd @@ -1,6 +1,6 @@ --- $Id: serport.vhd 437 2011-12-09 19:38:07Z mueller $ +-- $Id: serportlib.vhd 476 2013-01-26 22:23:53Z mueller $ -- --- Copyright 2007-2011 by Walter F.J. Mueller +-- Copyright 2007-2013 by Walter F.J. Mueller -- -- This program is free software; you may redistribute and/or modify it under -- the terms of the GNU General Public License as published by the Free @@ -12,7 +12,7 @@ -- for complete details. -- ------------------------------------------------------------------------------ --- Package Name: serport +-- Package Name: serportlib -- Description: serial port interface components -- -- Dependencies: - @@ -20,6 +20,7 @@ -- -- Revision History: -- Date Rev Version Comment +-- 2013-01-26 476 1.2.6 renamed package to serportlib -- 2011-12-09 437 1.2.5 rename stat->moni port -- 2011-10-23 419 1.2.4 remove serport_clkdiv_ consts; -- 2011-10-22 417 1.2.3 add serport_xon(rx|tx) defs @@ -35,7 +36,7 @@ use ieee.std_logic_1164.all; use work.slvtypes.all; -package serport is +package serportlib is constant c_serport_xon : slv8 := "00010001"; -- char xon: ^Q = hex 11 constant c_serport_xoff : slv8 := "00010011"; -- char xoff ^S = hex 13 @@ -233,4 +234,4 @@ component serport_2clock is -- serial port module, 2 clock domain ); end component; -end package serport; +end package serportlib; diff --git a/rtl/vlib/serport/tb/Makefile b/rtl/vlib/serport/tb/Makefile index 56e15643..54cd8c05 100644 --- a/rtl/vlib/serport/tb/Makefile +++ b/rtl/vlib/serport/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 444 2011-12-25 10:04:58Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -11,6 +11,9 @@ EXE_all = tb_serport_uart_rx EXE_all += tb_serport_uart_rxtx EXE_all += tb_serport_autobaud # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all all_ssim all_tsim clean # all : $(EXE_all) @@ -27,7 +30,9 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) +endif # diff --git a/rtl/vlib/serport/tb/tb_serport_autobaud.vbom b/rtl/vlib/serport/tb/tb_serport_autobaud.vbom index dd4771ed..069526b3 100644 --- a/rtl/vlib/serport/tb/tb_serport_autobaud.vbom +++ b/rtl/vlib/serport/tb/tb_serport_autobaud.vbom @@ -1,7 +1,7 @@ # libs ../../slvtypes.vhd ../../simlib/simlib.vhd -../serport.vhd +../serportlib.vbom # components ../../simlib/simclk.vbom ../../simlib/simclkcnt.vbom diff --git a/rtl/vlib/serport/tb/tb_serport_autobaud.vhd b/rtl/vlib/serport/tb/tb_serport_autobaud.vhd index 954b1cff..e5407103 100644 --- a/rtl/vlib/serport/tb/tb_serport_autobaud.vhd +++ b/rtl/vlib/serport/tb/tb_serport_autobaud.vhd @@ -1,4 +1,4 @@ --- $Id: tb_serport_autobaud.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_serport_autobaud.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -53,7 +53,7 @@ use std.textio.all; use work.slvtypes.all; use work.simlib.all; -use work.serport.all; +use work.serportlib.all; entity tb_serport_autobaud is end tb_serport_autobaud; diff --git a/rtl/vlib/serport/tb/tb_serport_uart_rx.vbom b/rtl/vlib/serport/tb/tb_serport_uart_rx.vbom index cbfb6284..746e6439 100644 --- a/rtl/vlib/serport/tb/tb_serport_uart_rx.vbom +++ b/rtl/vlib/serport/tb/tb_serport_uart_rx.vbom @@ -1,7 +1,7 @@ # libs ../../slvtypes.vhd ../../simlib/simlib.vhd -../serport.vhd +../serportlib.vbom # components ../../simlib/simclk.vbom ../../simlib/simclkcnt.vbom diff --git a/rtl/vlib/serport/tb/tb_serport_uart_rx.vhd b/rtl/vlib/serport/tb/tb_serport_uart_rx.vhd index c15fd527..890a7bbb 100644 --- a/rtl/vlib/serport/tb/tb_serport_uart_rx.vhd +++ b/rtl/vlib/serport/tb/tb_serport_uart_rx.vhd @@ -1,4 +1,4 @@ --- $Id: tb_serport_uart_rx.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_serport_uart_rx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -46,7 +46,7 @@ use std.textio.all; use work.slvtypes.all; use work.simlib.all; -use work.serport.all; +use work.serportlib.all; entity tb_serport_uart_rx is end tb_serport_uart_rx; diff --git a/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vbom b/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vbom index 5b3d6926..98c3fca1 100644 --- a/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vbom +++ b/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vbom @@ -1,7 +1,7 @@ # libs ../../slvtypes.vhd ../../simlib/simlib.vhd -../serport.vhd +../serportlib.vbom # components ../../simlib/simclk.vbom ../../simlib/simclkcnt.vbom diff --git a/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vhd b/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vhd index f7caec71..df1e0a47 100644 --- a/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vhd +++ b/rtl/vlib/serport/tb/tb_serport_uart_rxtx.vhd @@ -1,4 +1,4 @@ --- $Id: tb_serport_uart_rxtx.vhd 444 2011-12-25 10:04:58Z mueller $ +-- $Id: tb_serport_uart_rxtx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -50,7 +50,7 @@ use std.textio.all; use work.slvtypes.all; use work.simlib.all; -use work.serport.all; +use work.serportlib.all; entity tb_serport_uart_rxtx is end tb_serport_uart_rxtx; diff --git a/rtl/vlib/serport/tb/tbd_serport_autobaud.vbom b/rtl/vlib/serport/tb/tbd_serport_autobaud.vbom index 312968c2..9936d14f 100644 --- a/rtl/vlib/serport/tb/tbd_serport_autobaud.vbom +++ b/rtl/vlib/serport/tb/tbd_serport_autobaud.vbom @@ -1,7 +1,7 @@ # libs ../../slvtypes.vhd ../../genlib/genlib.vhd -../serport.vhd +../serportlib.vbom # components ../../genlib/clkdivce.vbom ../serport_uart_autobaud.vbom diff --git a/rtl/vlib/serport/tb/tbd_serport_autobaud.vhd b/rtl/vlib/serport/tb/tbd_serport_autobaud.vhd index 1ef82849..19f7d799 100644 --- a/rtl/vlib/serport/tb/tbd_serport_autobaud.vhd +++ b/rtl/vlib/serport/tb/tbd_serport_autobaud.vhd @@ -1,4 +1,4 @@ --- $Id: tbd_serport_autobaud.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: tbd_serport_autobaud.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -47,7 +47,7 @@ use ieee.numeric_std.all; use work.slvtypes.all; use work.genlib.all; -use work.serport.all; +use work.serportlib.all; entity tbd_serport_autobaud is -- serial port autobaud [tb design] port ( diff --git a/rtl/vlib/serport/tb/tbd_serport_uart_rx.vbom b/rtl/vlib/serport/tb/tbd_serport_uart_rx.vbom index 64b74c60..b4f45d34 100644 --- a/rtl/vlib/serport/tb/tbd_serport_uart_rx.vbom +++ b/rtl/vlib/serport/tb/tbd_serport_uart_rx.vbom @@ -1,6 +1,6 @@ # libs ../../slvtypes.vhd -../serport.vhd +../serportlib.vbom # components ../serport_uart_rx.vbom # design diff --git a/rtl/vlib/serport/tb/tbd_serport_uart_rx.vhd b/rtl/vlib/serport/tb/tbd_serport_uart_rx.vhd index 1098699c..56585a48 100644 --- a/rtl/vlib/serport/tb/tbd_serport_uart_rx.vhd +++ b/rtl/vlib/serport/tb/tbd_serport_uart_rx.vhd @@ -1,4 +1,4 @@ --- $Id: tbd_serport_uart_rx.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: tbd_serport_uart_rx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -41,7 +41,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity tbd_serport_uart_rx is -- serial port uart rx [tb design] -- generic: CDWIDTH=5 diff --git a/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vbom b/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vbom index fa4069c9..77301ddf 100644 --- a/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vbom +++ b/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vbom @@ -1,6 +1,6 @@ # libs ../../slvtypes.vhd -../serport.vhd +../serportlib.vbom # components ../serport_uart_rxtx.vbom # design diff --git a/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vhd b/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vhd index 88190737..0570e75f 100644 --- a/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vhd +++ b/rtl/vlib/serport/tb/tbd_serport_uart_rxtx.vhd @@ -1,4 +1,4 @@ --- $Id: tbd_serport_uart_rxtx.vhd 417 2011-10-22 10:30:29Z mueller $ +-- $Id: tbd_serport_uart_rxtx.vhd 476 2013-01-26 22:23:53Z mueller $ -- -- Copyright 2007-2011 by Walter F.J. Mueller -- @@ -41,7 +41,7 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.slvtypes.all; -use work.serport.all; +use work.serportlib.all; entity tbd_serport_uart_rxtx is -- serial port uart [tb design] -- generic: CDWIDTH=13 diff --git a/rtl/vlib/xlib/Makefile b/rtl/vlib/xlib/Makefile index 3d76c997..22b97664 100644 --- a/rtl/vlib/xlib/Makefile +++ b/rtl/vlib/xlib/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version omment @@ -8,6 +8,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -18,5 +21,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/w11a/Makefile b/rtl/w11a/Makefile index f88800e9..5366c852 100644 --- a/rtl/w11a/Makefile +++ b/rtl/w11a/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 405 2011-08-14 08:16:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -9,6 +9,9 @@ VBOM_all = $(wildcard *.vbom) NGC_all = $(VBOM_all:.vbom=.ngc) # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk +# .PHONY : all clean # all : $(NGC_all) @@ -19,5 +22,7 @@ clean : ise_clean # include $(RETROBASE)/rtl/make/generic_xflow.mk # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) +endif # diff --git a/rtl/w11a/tb/Makefile b/rtl/w11a/tb/Makefile index 7faec912..8e6576fc 100644 --- a/rtl/w11a/tb/Makefile +++ b/rtl/w11a/tb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile 442 2011-12-23 10:03:28Z mueller $ +# $Id: Makefile 477 2013-01-27 14:07:10Z mueller $ # # Revision History: # Date Rev Version Comment @@ -11,6 +11,8 @@ # EXE_all = tb_pdp11core # +# reference board for test synthesis is Spartan-6 based Nexys3 +include $(RETROBASE)/rtl/make/xflow_default_nexys3.mk # .PHONY : all all_ssim all_tsim clean # @@ -28,10 +30,12 @@ include $(RETROBASE)/rtl/make/generic_xflow.mk # VBOM_all = $(wildcard *.vbom) # +ifndef DONTINCDEP include $(VBOM_all:.vbom=.dep_xst) include $(VBOM_all:.vbom=.dep_ghdl) include $(VBOM_all:.vbom=.dep_isim) include $(wildcard *.o.dep_ghdl) +endif # #----- # time ~/misc_walter/p11_util/bin/pdp11 $*.scmd > $*.simh_raw_log diff --git a/tools/asm-11/tests-err/.cvsignore b/tools/asm-11/tests-err/.cvsignore new file mode 100644 index 00000000..39d19dfa --- /dev/null +++ b/tools/asm-11/tests-err/.cvsignore @@ -0,0 +1,3 @@ +*.lsterr +*.ldart +*.lstrt diff --git a/tools/asm-11/tests-err/Makefile b/tools/asm-11/tests-err/Makefile new file mode 100644 index 00000000..31522977 --- /dev/null +++ b/tools/asm-11/tests-err/Makefile @@ -0,0 +1,31 @@ +# +# Revision History: +# Date Rev Version Comment +# 2013-03-22 496 1.0 Initial version +#--- +# +MAC_all = $(wildcard *.mac) +LSTERR_all = $(MAC_all:.mac=.lsterr) +LDART_all = $(MAC_all:.mac=.ldart) +LSTRT_all = $(MAC_all:.mac=.lstrt) +# +include $(RETROBASE)/tools/make/generic_asm11.mk +# +.PHONY : def alllst allrt allexp clean cleanrt +# +def : alllst +# +alllst : $(LSTERR_all) +# +allrt : $(LSTRT_all) +# +allexp : $(LSTERR_all) + @ asm-11_expect $^ +# +clean : + @ rm -f $(LSTERR_all) + @ echo "Listing files removed" + +cleanrt : + @ rm -f $(LDART_all) $(LSTRT_all) + @ echo "RT-11 generated files removed" diff --git a/tools/asm-11/tests-err/testerr_0010_undef_label.mac b/tools/asm-11/tests-err/testerr_0010_undef_label.mac new file mode 100644 index 00000000..1c237bf0 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0010_undef_label.mac @@ -0,0 +1,26 @@ +; $Id: testerr_0010_undef_label.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test undefined label response +; + .asect + +; for normal labels + +zero: .word zero + .word one ;;!! U + .word two ;;!! U + +; for local labels (in scope) + +blk1: .word 0 +1$: .word blk1 + .word 1$ + .word 2$ ;;!! U + +; for local labels (out-of-scope) + +blk2: .word 0 +2$: .word 1$ ;;!! U + .word 2$ + + .end diff --git a/tools/asm-11/tests-err/testerr_0020_muldef_label.mac b/tools/asm-11/tests-err/testerr_0020_muldef_label.mac new file mode 100644 index 00000000..000edb9e --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0020_muldef_label.mac @@ -0,0 +1,23 @@ +; $Id: testerr_0020_muldef_label.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test multiple defined label response +; + .asect + +; for normal labels + +zero: .word zero ;;!! DM +one: .word one +zero: .word 0 ;;!! M + .word zero ;;!! D + +; for local labels (in scope) + +blk1: .word 0 +1$: .word 1 ;;!! M +2$: .word 2 +1$: .word 3 ;;!! M + .word 1$ ;;!! D + .word 2$ + + .end diff --git a/tools/asm-11/tests-err/testerr_0100_Berror.mac b/tools/asm-11/tests-err/testerr_0100_Berror.mac new file mode 100644 index 00000000..94ee7a0c --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0100_Berror.mac @@ -0,0 +1,29 @@ +; $Id: testerr_0100_Berror.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test B error code (bounding error) +; + .asect + .blkw 400 + +; word align code + +t1: inc r0 +1$: .byte 0 +2$: + inc r1 ;;!! B + +; word align .word + +t2: .word 0 +1$: .byte 1 +2$: + .word 2 ;;!! B + +; word align .blkw + +t3: .blkw 2 +1$: .blkb 3 +2$: + .blkw 2 ;;!! B + + .end diff --git a/tools/asm-11/tests-err/testerr_0110_Nerror.mac b/tools/asm-11/tests-err/testerr_0110_Nerror.mac new file mode 100644 index 00000000..eaa40573 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0110_Nerror.mac @@ -0,0 +1,32 @@ +; $Id: testerr_0110_Nerror.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test N error code (Number error) +; + .asect + .blkw 400 + +; octal, implicit + + .word 7 + .word 8 ;;!! N + .word 9 ;;!! N + +; octal, explicit ^o + + .word ^o7 + .word ^o8 ;;!! N + .word ^o9 ;;!! N + +; binary via ^b + + .word ^b101 + .word ^b2 ;;!! N + .word ^b3 ;;!! N + .word ^b4 ;;!! N + .word ^b5 ;;!! N + .word ^b6 ;;!! N + .word ^b7 ;;!! N + .word ^b8 ;;!! N + .word ^b9 ;;!! N + + .end diff --git a/tools/asm-11/tests-err/testerr_0120_Terror_const.mac b/tools/asm-11/tests-err/testerr_0120_Terror_const.mac new file mode 100644 index 00000000..cb5056c4 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0120_Terror_const.mac @@ -0,0 +1,45 @@ +; $Id: testerr_0120_Terror_const.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test T error code (Truncation) +; truncation of too large constants +; + .asect + .blkw 400 + +; octal, implicit + + .word 123456 + .word 177777 + .word 1234567 ;;!! T + +; octal, explicit ^o + + .word ^o123456 + .word ^o177777 + .word ^o1234567 ;;!! T + +; decimal, implicit trailing . + + .word 65535. + .word 65536. ;;!! T + .word 65537. ;;!! T + +; decimal, explicit ^d + + .word ^d65535 + .word ^d65536 ;;!! T + .word ^d65537 ;;!! T + +; binary + + .word ^b111111111111111 + .word ^b1111111111111111 + .word ^b11111111111111111 ;;!!T + +; hex + + .word ^xfff + .word ^xffff + .word ^x1ffff ;;!! T + + .end diff --git a/tools/asm-11/tests-err/testerr_0130_Terror_inst.mac b/tools/asm-11/tests-err/testerr_0130_Terror_inst.mac new file mode 100644 index 00000000..514ac536 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0130_Terror_inst.mac @@ -0,0 +1,21 @@ +; $Id: testerr_0130_Terror_inst.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test T error code (Truncation) +; truncation in instruction fields +; + .asect + .blkw 400 + + spl 7 + spl 17 ;;!! T + + mark 77 + mark 100 ;;!! T + + trap 377 + trap 400 ;;!! T + + emt 377 + emt 400 ;;!! T + + .end diff --git a/tools/asm-11/tests-err/testerr_0140_Terror_expr.mac b/tools/asm-11/tests-err/testerr_0140_Terror_expr.mac new file mode 100644 index 00000000..2a54ef1f --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0140_Terror_expr.mac @@ -0,0 +1,11 @@ +; $Id: testerr_0140_Terror_expr.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test T error code (Truncation) +; truncation in expressions +; + .asect + .blkw 400 + +; not yet implemented... + + .end diff --git a/tools/asm-11/tests-err/testerr_0150_Terror_fpp.mac b/tools/asm-11/tests-err/testerr_0150_Terror_fpp.mac new file mode 100644 index 00000000..a5bd68e9 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0150_Terror_fpp.mac @@ -0,0 +1,67 @@ +; $Id: testerr_0150_Terror_fpp.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test T error code (trunction) +; fpp cases: fpp ac reg>3 +; + .asect + .blkw 400 + +a: .word 0,0 + .word 0,0 + +; r0:r3 ok as fpp ac +; r4:r7 forbidden as fpp ac + +; test with gr type opcode, here addf + + addf a,r0 + addf a,r1 + addf a,r2 + addf a,r3 + + addf a,r4 ;;!! T + addf a,r5 ;;!! T + addf a,sp ;;!! T + addf a,pc ;;!! T + +; test with rg type opcode, here stf + + stf r0,a + stf r1,a + stf r2,a + stf r3,a + + stf r4,a ;;!! T + stf r5,a ;;!! T + stf sp,a ;;!! T + stf pc,a ;;!! T + +; for fsrc and fdst only register 0-5 +; are allowed, but the assembler doesn't +; check for this. + +; test with mulf + + mulf r0,r0 + mulf r1,r0 + mulf r2,r0 + mulf r3,r0 + mulf r4,r0 + mulf r5,r0 + + mulf sp,r0 ; ok, but traps + mulf pc,r0 ; ok, but traps + +; test with stf + + stf r0,r0 + stf r0,r1 + stf r0,r2 + stf r0,r3 + stf r0,r4 + stf r0,r5 + + stf r0,sp ; ok, but traps + stf r0,pc ; ok, but traps + + .end diff --git a/tools/asm-11/tests-err/testerr_0200_Aerror_branch.mac b/tools/asm-11/tests-err/testerr_0200_Aerror_branch.mac new file mode 100644 index 00000000..d2607396 --- /dev/null +++ b/tools/asm-11/tests-err/testerr_0200_Aerror_branch.mac @@ -0,0 +1,69 @@ +; $Id: testerr_0200_Aerror_branch.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test A error code (Assembly error) +; case: range of branch or sob exceeded +; + .asect + .blkw 400 + +; range of branch (-128...+127) + +; short range back +bb1: br bb1 + +; 2nd longest back branch +bb2: nop + .blkw 125. + br bb2 + +; longest back branch +bb3: nop + .blkw 126. + br bb3 + +; too long back branch +bb4: nop + .blkw 127. + br bb4 ;;!! A + +; short range forward + br bf1 +bf1: nop + +; 2nd longest forward branch + br bf2 + .blkw 126. +bf2: nop + +; longest forward branch + br bf3 + .blkw 127. +bf3: nop + +; too long forward branch + br bf4 ;;!! A + .blkw 128. +bf4: nop + +; range of sob (-63 ... 0) + +; short range sob + +s1: sob r1,s1 + +; 2nd longest sob +s2: nop + .blkw 60. + sob r2,s2 + +; longest sob +s3: nop + .blkw 61. + sob r3,s3 + +; too long sob +s4: nop + .blkw 62. + sob r4,s4 ;;!! A + + .end diff --git a/tools/asm-11/tests/.cvsignore b/tools/asm-11/tests/.cvsignore new file mode 100644 index 00000000..f11c8fba --- /dev/null +++ b/tools/asm-11/tests/.cvsignore @@ -0,0 +1,5 @@ +*.lda +*.cof +*.lst +*.ldart +*.lstrt diff --git a/tools/asm-11/tests/Makefile b/tools/asm-11/tests/Makefile new file mode 100644 index 00000000..eaf4d9c0 --- /dev/null +++ b/tools/asm-11/tests/Makefile @@ -0,0 +1,41 @@ +# +# Revision History: +# Date Rev Version Comment +# 2013-03-22 496 1.0 Initial version +#--- +# +MAC_all = $(wildcard *.mac) +LDA_all = $(MAC_all:.mac=.lda) +COF_all = $(MAC_all:.mac=.cof) +LST_all = $(MAC_all:.mac=.lst) +LDART_all = $(MAC_all:.mac=.ldart) +LSTRT_all = $(MAC_all:.mac=.lstrt) +# +include $(RETROBASE)/tools/make/generic_asm11.mk +# +.PHONY : def alllda allcof alllst allrt allexp clean cleanrt +# +def : alllda +# +alllda : $(LDA_all) +# +allcof : $(COF_all) +# +alllst : $(LST_all) +# +allrt : $(LSTRT_all) +# +allexp : $(LST_all) + @ asm-11_expect $^ +# +clean : + @ rm -f $(LDA_all) + @ echo "Object files removed" + @ rm -f $(COF_all) + @ echo "Compound files removed" + @ rm -f $(LST_all) + @ echo "Listing files removed" + +cleanrt : + @ rm -f $(LDART_all) $(LSTRT_all) + @ echo "RT-11 generated files removed" diff --git a/tools/asm-11/tests/test_0010_alloc.mac b/tools/asm-11/tests/test_0010_alloc.mac new file mode 100644 index 00000000..d3221b70 --- /dev/null +++ b/tools/asm-11/tests/test_0010_alloc.mac @@ -0,0 +1,48 @@ +; $Id: test_0010_alloc.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test basic label and allocation constructs +; .blkb +; .blkw +; .word +; .byte +; .even +; .odd +; normal and local labels +; +; .blkb and .blkw +; + + .asect + +zero: ;;!! 000000: + .blkb 1000 +stkbot: .blkw 400 ;;!! 001000: + +; .word and .byte + +w0: .word 101 ;;!! 002000: 000101 +w1: .word 102 ;;!! 002002: 000102 +b0: .byte 1 ;;!! 002004: 001 +b1: .byte 2 ;;!! 002005: 002 + +; .odd and .even + + .odd + .byte 3 ;;!! 002007: 003 + .byte 4 ;;!! 002010: 004 + .even + .word 103 ;;!! 002012: 000103 + +; normal and local labels (only backward refs) + +blk0: .word 0 ;;!! 002014: 000000 +1$: .word blk0 ;;!! 002016: 002014 +2$: .word 1$ +3$: .word 2$ +; +blk1: .word 0 +1$: .word blk1 +2$: .word 1$ +3$: .word 2$ + + .end ;;!! 000001 diff --git a/tools/asm-11/tests/test_0020_expr.mac b/tools/asm-11/tests/test_0020_expr.mac new file mode 100644 index 00000000..406956ff --- /dev/null +++ b/tools/asm-11/tests/test_0020_expr.mac @@ -0,0 +1,62 @@ +; $Id: test_0020_expr.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test assignment and expressions +; + .asect + + a1 = 100 ;;!! 000100 + a2 == 110 ;;!! 000110 + a3 =: 120 ;;!! 000120 + a4 ==: 130 ;;!! 000130 + +; unary operators + + u1 = +200 ;;!! 000200 + u2 = -300 ;;!! 177500 + u3 = +-300 ;;!! 177500 + u4 = -+-300 ;;!! 000300 + u5 = ^c300 ;;!! 177477 + u6 = ^c-300 ;;!! 000277 + +; binary operators + + b1 = 1100 + 100 ;;!! 001200 + b2 = 1311 - 100 ;;!! 001211 + b3 = 400 * 3 ;;!! 001400 + b4 = 2000 / 4 ;;!! 000400 + b5 = 1770 & 0077 ;;!! 000070 + b6 = 1000 ! 100 ;;!! 001100 + +; radix prefixes and suffixes + + r1 = 11 ;;!! 000011 + r2 = 11. ;;!! 000013 + r3 = ^b11 ;;!! 000003 + r4 = ^o11 ;;!! 000011 + r5 = ^d11 ;;!! 000013 + r6 = 99. ;;!! 000143 + r7 = ^d99 ;;!! 000143 +;; r8 = ^x1234 + +; other prefixes + + s1 = 'X ;;!! 000130 + s2 = "XY ;;!! 054530 + s3 = ^rabc ;;!! 003223 + +; long left-to-right expressions + + e1 = 100 + 20 * 2 + 1 ;;!! 000241 + e2 = 200 - 100 / 2 ;;!! 000040 + e3 = 777 * 2 & 77 ;;!! 000076 + +; nested expressions + + n1 = 400+200 ;;!! 000600 + n2 = <400+200> ;;!! 000600 + n3 = 400+ 2*100 ;;!! 040200 + n4 = 400+<2*100> ;;!! 000600 + n5 = 400+ 200-100 /2 ;;!! 000240 + n6 = 400+<<200-100>/2> ;;!! 000440 + + .end diff --git a/tools/asm-11/tests/test_0030_alloc.mac b/tools/asm-11/tests/test_0030_alloc.mac new file mode 100644 index 00000000..30cf354f --- /dev/null +++ b/tools/asm-11/tests/test_0030_alloc.mac @@ -0,0 +1,47 @@ +; $Id: test_0030_alloc.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test .word/.byte with expressions ect +; + .asect + .blkw 400 + +w0: .word 101 ;;!! 001000: 000101 +w1: .word 102 ;;!! 001002: 000102 +b0: .byte 1 ;;!! 001004: 001 +b1: .byte 2 ;;!! 001005: 002 + +; .word/.byte with expressions + + .word 100+77 ;;!! 000177 + .byte 2+<4*10> ;;!! 042 + .byte ^c0 ;;!! 377 + + .byte 'H,'e,'l,'l + .byte 'o,' ,'W,'o + .byte 'r,'l,'d,'!,0 + .even + .word "He,"ll,"o + .word "Wo,"rl,"d!,0 + + .word w1-w0 ;;!! 000002 + .byte /2 ;;!! 001 + .byte b1-b0 ;;!! 001 + +w2: .word . ;;!! 001052: 001052 + .word w0+2 ;;!! 001002 + .word w1-2 ;;!! 001000 + +; .word/.byte with empty ',' + + .word 1,2 ;;!! 000001 000002 + .word w0,w1 ;;!! 001000 001002 + .word w0, ;;!! 001000 000000 + .word w0,, ;;!! 001000 000000 000000 + .word ,w0 ;;!! 000000 001000 + .word ,,w0 ;;!! 000000 000000 001000 + .word ,w0, ;;!! 000000 001000 000000 + .word , ;;!! 000000 000000 + .word ,, ;;!! 000000 000000 000000 + .word w0,,w1 ;;!! 001000 000000 001002 + + .end diff --git a/tools/asm-11/tests/test_0040_asci.mac b/tools/asm-11/tests/test_0040_asci.mac new file mode 100644 index 00000000..d9e4120d --- /dev/null +++ b/tools/asm-11/tests/test_0040_asci.mac @@ -0,0 +1,26 @@ +; $Id: test_0040_asci.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test .ascii/.asciz +; + CR = 015 + LF = 012 +; + .asect + .blkw 400 + + .ascii /foobar/ + .asciz /fooba/ + +a0: .ascii /test/ +a1: .asciz /test1/ + +a2: .ascii /test/ +a3: .asciz /test/ + +a4: .asciz /retro/|computing| +a5: .ascii /Hello World!/ +a6: .asciz *Hello World!* +a7: .asciz <040><041><042> + + .even + .end diff --git a/tools/asm-11/tests/test_0050_iword.mac b/tools/asm-11/tests/test_0050_iword.mac new file mode 100644 index 00000000..49006547 --- /dev/null +++ b/tools/asm-11/tests/test_0050_iword.mac @@ -0,0 +1,27 @@ +; $Id: test_0050_iword.mac 502 2013-04-02 19:29:30Z mueller $ +; +; test implicit .word +; when a statement does not start with pst symbol (opcode or directive) +; assume an implicit .word +; + .asect + .blkw 400 + + 100 ;;!! 000100 + 200 ;;!! 000200 + 110,120 ;;!! 000110 000120 + 100, ;;!! 000100 000000 + ,200 ;;!! 000000 000200 + , ;;!! 000000 000000 + +w1: 1000 ;;!! 001000 +w2: 2000,2001,2002 ;;!! 002000 002001 002002 + + const = 10 ;;!! 000010 + const ;;!! 000010 + ;;!! 000010 + 2*const ;;!! 000020 + <3*const> ;;!! 000030 + + .even + .end diff --git a/tools/asm-11/tests/test_0100_op_g.mac b/tools/asm-11/tests/test_0100_op_g.mac new file mode 100644 index 00000000..f6af8b61 --- /dev/null +++ b/tools/asm-11/tests/test_0100_op_g.mac @@ -0,0 +1,71 @@ +; $Id: test_0100_op_g.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test opcodes with one general operand +; + .asect + .blkw 400 +; +a: .word 0 ;;!! 001000: 000000 +pa: .word a ;;!! 001002: 001000 + +; all modes with one opcode +p1: + inc r1 ;;!! 005201 + inc @r2 ;;!! 005212 + inc (r3) ;;!! 005213 + inc (r4)+ ;;!! 005224 + inc @(r5)+ ;;!! 005235 + inc -(r1) ;;!! 005241 + inc @-(r2) ;;!! 005252 + inc 1234(r3) ;;!! 005263 001234 + inc @1234(r4) ;;!! 005274 001234 + inc a ;;!! 005267 177742 + inc @pa ;;!! 005277 177740 + inc @#a ;;!! 005237 001000 + +; pc relative addressing + +b: .word 0 + inc b + inc c +c: .word 0 + +; all 'g' type opcodes, random modes +p2: + jmp @r2 ;;!! 000112 + swab (r3) ;;!! 000313 + clr (r4)+ ;;!! 005024 + com @(r5)+ ;;!! 005135 + dec -(r1) ;;!! 005341 + neg @-(r2) ;;!! 005452 + adc 1234(r3) ;;!! 005563 001234 + sbc @1234(r4) ;;!! 005674 001234 + tst a ;;!! 005767 177666 + ror @pa ;;!! 006077 177664 + rol @#a ;;!! 006137 001000 + asr @r2 ;;!! 006212 + asl (r3) ;;!! 006313 + mfpi (r4)+ ;;!! 006524 + mtpi @(r5)+ ;;!! 006635 + sxt -(r1) ;;!! 006741 +; csm @-(r2) ;;!! +; tstset 1234(r3) ;;!! +; wrtlck @1234(r4) ;;!! + clrb a ;;!! 105067 177640 + comb @pa ;;!! 105177 177636 + incb @#a ;;!! 105237 001000 + decb @r2 ;;!! 105312 + negb (r3) ;;!! 105413 + adcb (r4)+ ;;!! 105524 + sbcb @(r5)+ ;;!! 105635 + tstb -(r1) ;;!! 105741 + rorb @-(r2) ;;!! 106052 + rolb 1234(r3) ;;!! 106163 001234 + asrb @1234(r4) ;;!! 106274 001234 + aslb a ;;!! 106367 177600 + mtps @pa ;;!! 106477 177576 + mfpd @#a ;;!! 106537 001000 + mtpd @r2 ;;!! 106612 + mfps (r3) ;;!! 106713 + + .end diff --git a/tools/asm-11/tests/test_0110_op_gg.mac b/tools/asm-11/tests/test_0110_op_gg.mac new file mode 100644 index 00000000..c4bd9412 --- /dev/null +++ b/tools/asm-11/tests/test_0110_op_gg.mac @@ -0,0 +1,78 @@ +; $Id: test_0110_op_gg.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test opcodes with two general operands +; + .asect + .blkw 400 + +a: .word 0 ;;!! 001000: 000000 +b: .word 0 ;;!! 001002: 000000 +pa: .word a ;;!! 001004: 001000 +pb: .word b ;;!! 001006: 001002 + + const = 400 + +; all src modes to reg dst +p1: + add r1,r0 ;;!! 060100 + add @r2,r0 ;;!! 061200 + add (r3),r0 ;;!! 061300 + add (r4)+,r0 ;;!! 062400 + add @(r5)+,r0 ;;!! 063500 + add -(r1),r0 ;;!! 064100 + add @-(r2),r0 ;;!! 065200 + add 1234(r3),r0 ;;!! 066300 001234 + add @1234(r4),r0 ;;!! 067400 001234 + add a,r0 ;;!! 066700 177736 + add @pa,r0 ;;!! 067700 177736 + add @#a,r0 ;;!! 063700 001000 + add #const,r0 ;;!! 062700 000400 + +; all reg src to all dst modes +p2: + add r0,r1 ;;!! 060001 + add r0,@r2 ;;!! 060012 + add r0,(r3) ;;!! 060013 + add r0,(r4)+ ;;!! 060024 + add r0,@(r5)+ ;;!! 060035 + add r0,-(r1) ;;!! 060041 + add r0,@-(r2) ;;!! 060052 + add r0,1234(r3) ;;!! 060063 001234 + add r0,@1234(r4) ;;!! 060074 001234 + add r0,a ;;!! 060067 177670 + add r0,@pa ;;!! 060077 177670 + add r0,@#a ;;!! 060037 001000 + +; pc relative addressing + +c: .word 0 ;;!! 001120: 000000 +d: .word 0 ;;!! 001122: 000000 + add c,d ;;!! 001124: 066767 177770 177770 + add f,e ;;!! 001132: 066767 000004 000000 +e: .word 0 ;;!! 001140: 000000 +f: .word 0 ;;!! 001142: 000000 + +; some mixed cases +p3: + add r1,@r2 ;;!! 060112 + add (r3),(r4)+ ;;!! 061324 + add @(r5)+,-(r1) ;;!! 063541 + add @-(r2),1234(r3) ;;!! 065263 001234 + add @1234(r4),a ;;!! 067467 001234 177614 + add @pa,@#a ;;!! 067737 177614 001000 + add #1000,b ;;!! 062767 001000 177602 + +; all 'gg' type opcodes, random modes +p4: + mov @r2,(r3) ;;!! 011213 + cmp (r4)+,@(r5)+ ;;!! 022435 + bit -(r1),@-(r2) ;;!! 034152 + bic 1234(r3),@1234(r4) ;;!! 046374 001234 001234 + bis a,@pa ;;!! 056777 177560 177562 + movb @#a,(r3) ;;!! 113713 001000 + cmpb @(r5)+,@-(r2) ;;!! 123552 + bitb @1234(r4),@pa ;;!! 137477 001234 177546 + bicb -(r1),1234(r3) ;;!! 144163 001234 + bisb a,@#b ;;!! 156737 177532 001002 + + .end diff --git a/tools/asm-11/tests/test_0120_op_rg.mac b/tools/asm-11/tests/test_0120_op_rg.mac new file mode 100644 index 00000000..64904794 --- /dev/null +++ b/tools/asm-11/tests/test_0120_op_rg.mac @@ -0,0 +1,22 @@ +; $Id: test_0120_op_rg.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test opcodes with 1 1/2 operands +; + .asect + .blkw 400 + +a: .word 0 +pa: .word a + +sub: rts pc ;;!! 001004: 000207 + + jsr pc,sub ;;!! 001006: 004767 177772 + + xor r1,a ;;!! 074167 177762 + + mul a,r2 ;;!! 070267 177756 + div @pa,r2 ;;!! 071277 177754 + ash #12,r3 ;;!! 072327 000012 + ashc @#a,r4 ;;!! 073437 001000 + + .end diff --git a/tools/asm-11/tests/test_0130_op_n.mac b/tools/asm-11/tests/test_0130_op_n.mac new file mode 100644 index 00000000..ed02a98c --- /dev/null +++ b/tools/asm-11/tests/test_0130_op_n.mac @@ -0,0 +1,36 @@ +; $Id: test_0130_op_n.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test opcodes with no or numeric operands +; + .asect + .blkw 400 + +; no operands +p1: + halt ;;!! 000000 + wait ;;!! 000001 + rti ;;!! 000002 + bpt ;;!! 000003 + iot ;;!! 000004 + reset ;;!! 000005 + rtt ;;!! 000006 + mfpt ;;!! 000007 + nop ;;!! 000240 + clc ;;!! 000241 + clv ;;!! 000242 + clz ;;!! 000244 + cln ;;!! 000250 + sec ;;!! 000261 + sev ;;!! 000262 + sez ;;!! 000264 + sen ;;!! 000270 + scc ;;!! 000277 + +; numeric operands +p2: + spl 5 ;;!! 000235 + mark 13 ;;!! 006413 + emt 170 ;;!! 104170 + trap 77 ;;!! 104477 + + .end diff --git a/tools/asm-11/tests/test_0140_op_o.mac b/tools/asm-11/tests/test_0140_op_o.mac new file mode 100644 index 00000000..81292e54 --- /dev/null +++ b/tools/asm-11/tests/test_0140_op_o.mac @@ -0,0 +1,34 @@ +; $Id: test_0140_op_o.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test opcodes offset operands +; + .asect + .blkw 400 + +; branch + +start: br start + bne start + beq start + bge 2$ + blt 2$ + bgt 2$ +1$: ble 2$ + +2$: bpl 1$ + bmi 1$ + bhi 1$ + blos 1$ + bvc 1$ + bvs 1$ + bcc 1$ + bhis 3$ + bcs 3$ +3$: blo 3$ + +; sob + +loop: sob r1,loop + sob r2,loop + + .end diff --git a/tools/asm-11/tests/test_0180_pst.mac b/tools/asm-11/tests/test_0180_pst.mac new file mode 100644 index 00000000..857755b7 --- /dev/null +++ b/tools/asm-11/tests/test_0180_pst.mac @@ -0,0 +1,61 @@ +; $Id: test_0180_pst.mac 502 2013-04-02 19:29:30Z mueller $ +; +; test interaction pst <-> lst +; + .asect + .blkw 400 + +; defined constants based on opcodes + + c1 = inc ;;!! 005200 + c2 = inc + 67 ;;!! 005267 + +; use opcode values as constants + + mov #mov,r1 ;;!! 012701 010000 + mov #inc,r2 ;;!! 012702 005200 + +; combine opcodes, especially cc ops +; uses implicit .word mechanism, and that pst symbols can be used as constants + + sec ;;!! 000261 + sev ;;!! 000262 + sez ;;!! 000264 + sen ;;!! 000270 + + ;;!! 000263 + ;;!! 000267 + ;;!! 000277 + +; Note: sec!sev without <> will not work, the first sec will trigger operand +; parsing, and since sec doesn't have operands, flag an error + +; using self-defined compound opcodes + + scv = sec ! sev ;;!! 000263 + scv ;;!! 000263 + +; not check pst - lst interference +; opcodes are always looked-up from pst +; symbols are looked-up first in lst, than in pst + +; opcode name defined as const + cmp = 1234 ;;!! 001234 + +; instruction usage is unaltered, but usage as constant is redefined + + cmp r0,r0 ;;!! 020000 + mov #cmp,r0 ;;!! 012700 001234 + mov #cmp+77,r0 ;;!! 012700 001333 + +; and label with an opcode name, same concept + + clr r0 ;;!! 005000 + clr @#mov ;;!! 005037 010000 + clr @#cmp ;;!! 005037 001234 + clr @#clr ;;!! 005037 001060 +clr: clr @#mov ;;!! 001060: 005037 010000 + clr @#cmp ;;!! 005037 001234 + clr @#clr ;;!! 005037 001060 + + .end diff --git a/tools/asm-11/tests/test_0200_fpp_1op.mac b/tools/asm-11/tests/test_0200_fpp_1op.mac new file mode 100644 index 00000000..e74e5231 --- /dev/null +++ b/tools/asm-11/tests/test_0200_fpp_1op.mac @@ -0,0 +1,36 @@ +; $Id: test_0200_fpp_1op.mac 501 2013-03-30 13:53:39Z mueller $ +; +; test fpp opcodes with 0 or 1 operands +; + .asect + .blkw 400 + +a: .word 0,0 + .word 0,0 +pa: .word a +s: .word 0,0 +ps: .word s + +; 0 operand opcodes + + cfcc ;;!! 170000 + setf ;;!! 170001 + setd ;;!! 170011 + seti ;;!! 170002 + setl ;;!! 170012 + +; 1 operand opcodes + + ldfps s ;;!! 170167 177754 + stfps @#s ;;!! 170237 001012 + stst @ps ;;!! 170377 177750 + clrf r0 ;;!! 170400 + clrd @r1 ;;!! 170411 + tstf (r2)+ ;;!! 170522 + tstd @(r3)+ ;;!! 170533 + absf -(r4) ;;!! 170644 + absd @-(r5) ;;!! 170655 + negf a(r1) ;;!! 170761 001000 + negd @pa(r2) ;;!! 170772 001010 + + .end diff --git a/tools/asm-11/tests/test_0210_fpp_2op.mac b/tools/asm-11/tests/test_0210_fpp_2op.mac new file mode 100644 index 00000000..2220cf3e --- /dev/null +++ b/tools/asm-11/tests/test_0210_fpp_2op.mac @@ -0,0 +1,51 @@ +; $Id: test_0210_fpp_2op.mac 503 2013-04-06 19:44:13Z mueller $ +; +; test fpp opcodes with 2 operands +; + .asect + .blkw 400 + +a: .word 0,0 + .word 0,0 +pa: .word a +s: .word 0,0 +ps: .word s + +; 2 operand 'gr' opcodes + + mulf a,r0 ;;!! 171067 177754 + muld r5,r1 ;;!! 171105 + modf @r1,r2 ;;!! 171611 + modd (r2)+,r3 ;;!! 171722 + addf @(r3)+,r0 ;;!! 172033 + addd -(r4),r1 ;;!! 172144 + ldf @-(r5),r2 ;;!! 172655 + ldd a,r3 ;;!! 172767 177734 + subf @pa,r0 ;;!! 173077 177740 + subd 0(r1),r1 ;;!! 173161 000000 + cmpf @6(r4),r2 ;;!! 173674 000006 + cmpd r1,r3 ;;!! 173701 + divf @pa,r0 ;;!! 174477 177722 + divd r5,r1 ;;!! 174505 + + ldexp @r1,r0 ;;!! 176411 + ldcif (r2)+,r1 ;;!! 177122 + ldcid @(r2)+,r2 ;;!! 177232 + ldclf -(r3),r3 ;;!! 177343 + ldcld @-(r4),r0 ;;!! 177054 + ldcdf a,r1 ;;!! 177567 177672 + ldcfd @pa,r2 ;;!! 177677 177676 + +; 2 operand 'rg' opcodes + + stf r0,a ;;!! 174067 177662 + std r1,@pa ;;!! 174177 177666 + stexp r2,@ps ;;!! 175277 177670 + stcfi r3,(r1) ;;!! 175711 + stcfl r0,(r2)+ ;;!! 175422 + stcdi r1,@(r3)+ ;;!! 175533 + stcdl r2,-(r4) ;;!! 175644 + stcfd r3,@-(r4) ;;!! 176354 + stcdf r0,@pa ;;!! 176077 177644 + + .end diff --git a/tools/asm-11/tests/zbug_0001.mac b/tools/asm-11/tests/zbug_0001.mac new file mode 100644 index 00000000..4df6476f --- /dev/null +++ b/tools/asm-11/tests/zbug_0001.mac @@ -0,0 +1,23 @@ +; $Id: zbug_0001.mac 501 2013-03-30 13:53:39Z mueller $ +; +; ISSUE: .ascii without label failed with Q +; +; REASON: .ascii requests next token with a different mask. The label handling +; in state 'start' looks ahead with default mask and does a pushback. +; --> That clashed !! +; +; FIX: look to directive names in 'start' and branch to 'oper' immediately in +; this case. +; +; SIDES: prevents also creation of labels with the name of a directive. +; + .asect + .blkw 400 + + .word 0 + +a1: .ascii /test/ + .ascii /test/ ; failed with Q +a2: .ascii /test/ + + .end diff --git a/tools/asm-11/tests/zbug_0002.mac b/tools/asm-11/tests/zbug_0002.mac new file mode 100644 index 00000000..cc60c33b --- /dev/null +++ b/tools/asm-11/tests/zbug_0002.mac @@ -0,0 +1,15 @@ +; $Id: zbug_0002.mac 501 2013-03-30 13:53:39Z mueller $ +; +; ISSUE: phase error after fmt='-' type opcodes +; +; REASON: incdot(2) wasn't called in this case in pass 1. +; + .asect + .blkw 400 + +l1: nop + nop + nop +l2: + + .end diff --git a/tools/asm-11/tests/zbug_0003.mac b/tools/asm-11/tests/zbug_0003.mac new file mode 100644 index 00000000..622154b8 --- /dev/null +++ b/tools/asm-11/tests/zbug_0003.mac @@ -0,0 +1,23 @@ +; $Id: zbug_0003.mac 502 2013-04-02 19:29:30Z mueller $ +; +; for asm-11 prior rev 502 +; +; ISSUE: '-2(r0)','@-2(r0) and '-sym(r0)',@-sym(r0) gives Q error +; +; REASON: confused in parser with '-(r0)' and '@-(r0)' modes +; + .asect + .blkw 400 + + mov -2(r0),r5 + mov @-2(r0),r5 + mov r5,-2(r0) + mov r5,@-2(r0) + + off = 2 + mov -off(r0),r5 + mov @-off(r0),r5 + mov r5,-off(r0) + mov r5,@-off(r0) + + .end diff --git a/tools/asm-11/w11/sys/dl11/.cvsignore b/tools/asm-11/w11/sys/dl11/.cvsignore new file mode 100644 index 00000000..f11c8fba --- /dev/null +++ b/tools/asm-11/w11/sys/dl11/.cvsignore @@ -0,0 +1,5 @@ +*.lda +*.cof +*.lst +*.ldart +*.lstrt diff --git a/tools/asm-11/w11/sys/dl11/Makefile b/tools/asm-11/w11/sys/dl11/Makefile new file mode 100644 index 00000000..f9b6838a --- /dev/null +++ b/tools/asm-11/w11/sys/dl11/Makefile @@ -0,0 +1,29 @@ +# +# Revision History: +# Date Rev Version Comment +# 2013-03-22 496 1.0 Initial version +#--- +# +MAC_all = $(wildcard *.mac) +LDA_all = $(MAC_all:.mac=.lda) +COF_all = $(MAC_all:.mac=.cof) +# +include $(RETROBASE)/tools/make/generic_asm11.mk +# +.PHONY : alllda allcof alllst clean +# +def : alllda +# +alllda : $(LDA_all) +# +allcof : $(COF_all) +# +alllst : $(LST_all) +# +clean : + @ rm -f $(LDA_all) + @ echo "Object files removed" + @ rm -f $(COF_all) + @ echo "Compound files removed" + @ rm -f $(LST_all) + @ echo "Listing files removed" diff --git a/tools/asm-11/w11/sys/dl11/simple_echo.mac b/tools/asm-11/w11/sys/dl11/simple_echo.mac new file mode 100644 index 00000000..4730dfd2 --- /dev/null +++ b/tools/asm-11/w11/sys/dl11/simple_echo.mac @@ -0,0 +1,38 @@ +; $Id: simple_echo.mac 504 2013-04-13 15:37:24Z mueller $ +; +; simple echo test for DL11 interface +; + RCSR = 177560 + RBUF = 177562 + XCSR = 177564 + XBUF = 177566 +; + CR = 015 + LF = 012 +; +; transfer vector +; + .asect + . = 200 + jmp start +; +; test code +; + . = 1000 +; +start: mov #start,sp +; +1$: tstb @#RCSR ; input ready ? + bpl 1$ ; if not poll + movb @#RBUF,r0 ; get input char +2$: tstb @#XCSR ; output ready ? + bpl 2$ ; if not poll + movb r0,@#XBUF ; echo received char + cmpb #CR,r0 ; was it CR ? + bne 1$ ; if not, wait for next input +3$: tstb @#XCSR ; output ready ? + bpl 3$ + movb #LF,@#XBUF ; send LF + br 1$ +; + .end diff --git a/tools/asm-11/w11/sys/dl11/simple_out.mac b/tools/asm-11/w11/sys/dl11/simple_out.mac new file mode 100644 index 00000000..61e8349d --- /dev/null +++ b/tools/asm-11/w11/sys/dl11/simple_out.mac @@ -0,0 +1,34 @@ +; $Id: simple_out.mac 503 2013-04-06 19:44:13Z mueller $ +; +; simple output test for DL11 interface +; + RCSR = 177560 + RBUF = 177562 + XCSR = 177564 + XBUF = 177566 +; + CR = 015 + LF = 012 +; +; transfer vector +; + .asect + . = 200 + jmp start +; +; test code +; + . = 1000 +; +start: mov #start,sp + mov #hw, r0 +1$: tstb (r0) + beq start +2$: tstb @#XCSR + bpl 2$ + movb (r0)+,@#XBUF + br 1$ +; +hw: .asciz /Hello world!/ +; + .end diff --git a/tools/bin/asm-11 b/tools/bin/asm-11 new file mode 100755 index 00000000..a8447623 --- /dev/null +++ b/tools/bin/asm-11 @@ -0,0 +1,2468 @@ +#!/usr/bin/perl -w +# $Id: asm-11 503 2013-04-06 19:44:13Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# +# This program is free software; you may redistribute 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 complete details. +# +# Revision History: +# Date Rev Version Comment +# 2013-04-07 503 1.0.2 list dot for .even,.dot,.blkb,.blkw +# 2013-04-01 502 1.0.1 BUGFIX: -2(r0),@-2(r0) was broken, parser fixed +# add -lsm (lsmem format) output; add implicit .word +# 2013-03-29 501 1.0 Initial version +# 2013-03-22 498 0.5 Second draft (functional, but limited...) +# 2013-03-07 496 0.1 First draft +# + +use 5.10.0; # require Perl 5.10 or higher +use strict; # require strict checking +use FileHandle; + +use Getopt::Long; + +use constant TMASK_STRING => 0x0001; +use constant TMASK_STRINGEXP => 0x0002; + +my %opts = (); + +GetOptions(\%opts, "help", + "tpass1", "tpass2", + "dsym1", "dsym2", + "ttoken", "tparse", "temit", "tout", + "I=s@", + "lst", "olst=s", + "lda", "olda=s", + "cof", "ocof=s", + "lsm", "olsm=s" + ) + or exit 1; + +unshift @{$opts{I}}, "."; # ./ is first in include path +push @{$opts{I}}, "$ENV{RETROBASE}/tools/asm-11" if defined $ENV{RETROBASE}; + +sub create_fname; +sub read_file; +sub parse_line; +sub walign; +sub add_err; +sub prt_err; +sub setdot; +sub incdot; +sub getdot; +sub setsym; +sub getsym; +sub lst_checkmdef; +sub eval_exp; +sub check_llbl; +sub check_reg; +sub check_token; +sub pushback_token; +sub get_token; +sub get_token1; +sub to_rad50; +sub pass2; +sub pass2_out; +sub pass2_lst_beg; +sub pass2_lst_end; +sub pass2_lst_line; +sub out_w; +sub out_b; +sub out_opcode; +sub out_opcode_n; +sub out_opcode_o; +sub out_opdata; +sub emitw; +sub emitb; +sub write_lda; +sub write_cof; +sub write_lsm; +sub dump_rl; +sub dump_sym; +sub prt76o; +sub prt43o; +sub save66o; +sub savestr; +sub savestr1; +sub print_help; + +# Permanant symbol table +my %pst = ( +# directives + '.include' => {typ=>'dir'}, # + '.word' => {typ=>'dir'}, # + '.byte' => {typ=>'dir'}, # + '.blkw' => {typ=>'dir'}, # + '.blkb' => {typ=>'dir'}, # + '.ascii' => {typ=>'dir'}, # + '.asciz' => {typ=>'dir'}, # + '.even' => {typ=>'dir'}, # + '.odd' => {typ=>'dir'}, # + '.asect' => {typ=>'dir'}, # + '.end' => {typ=>'dir'}, # +#register defs + 'r0' => {typ=>'reg', val=>0}, + 'r1' => {typ=>'reg', val=>1}, + 'r2' => {typ=>'reg', val=>2}, + 'r3' => {typ=>'reg', val=>3}, + 'r4' => {typ=>'reg', val=>4}, + 'r5' => {typ=>'reg', val=>5}, + 'sp' => {typ=>'reg', val=>6}, + 'pc' => {typ=>'reg', val=>7}, +#opcodes + 'halt' => {typ=>'op', val=>0000000, fmt=>'-' }, + 'wait' => {typ=>'op', val=>0000001, fmt=>'-' }, + 'rti' => {typ=>'op', val=>0000002, fmt=>'-' }, + 'bpt' => {typ=>'op', val=>0000003, fmt=>'-' }, + 'iot' => {typ=>'op', val=>0000004, fmt=>'-' }, + 'reset' => {typ=>'op', val=>0000005, fmt=>'-' }, + 'rtt' => {typ=>'op', val=>0000006, fmt=>'-' }, + 'mfpt' => {typ=>'op', val=>0000007, fmt=>'-' }, + 'jmp' => {typ=>'op', val=>0000100, fmt=>'g' }, + 'rts' => {typ=>'op', val=>0000200, fmt=>'r' }, + 'spl' => {typ=>'op', val=>0000230, fmt=>'n3' }, + 'nop' => {typ=>'op', val=>0000240, fmt=>'-' }, + 'clc' => {typ=>'op', val=>0000241, fmt=>'-' }, + 'clv' => {typ=>'op', val=>0000242, fmt=>'-' }, + 'clz' => {typ=>'op', val=>0000244, fmt=>'-' }, + 'cln' => {typ=>'op', val=>0000250, fmt=>'-' }, + 'ccc' => {typ=>'op', val=>0000257, fmt=>'-' }, + 'sec' => {typ=>'op', val=>0000261, fmt=>'-' }, + 'sev' => {typ=>'op', val=>0000262, fmt=>'-' }, + 'sez' => {typ=>'op', val=>0000264, fmt=>'-' }, + 'sen' => {typ=>'op', val=>0000270, fmt=>'-' }, + 'scc' => {typ=>'op', val=>0000277, fmt=>'-' }, + 'swab' => {typ=>'op', val=>0000300, fmt=>'g' }, + 'br' => {typ=>'op', val=>0000400, fmt=>'s8' }, + 'bne' => {typ=>'op', val=>0001000, fmt=>'s8' }, + 'beq' => {typ=>'op', val=>0001400, fmt=>'s8' }, + 'bge' => {typ=>'op', val=>0002000, fmt=>'s8' }, + 'blt' => {typ=>'op', val=>0002400, fmt=>'s8' }, + 'bgt' => {typ=>'op', val=>0003000, fmt=>'s8' }, + 'ble' => {typ=>'op', val=>0003400, fmt=>'s8' }, + 'jsr' => {typ=>'op', val=>0004000, fmt=>'rg' }, + 'clr' => {typ=>'op', val=>0005000, fmt=>'g' }, + 'com' => {typ=>'op', val=>0005100, fmt=>'g' }, + 'inc' => {typ=>'op', val=>0005200, fmt=>'g' }, + 'dec' => {typ=>'op', val=>0005300, fmt=>'g' }, + 'neg' => {typ=>'op', val=>0005400, fmt=>'g' }, + 'adc' => {typ=>'op', val=>0005500, fmt=>'g' }, + 'sbc' => {typ=>'op', val=>0005600, fmt=>'g' }, + 'tst' => {typ=>'op', val=>0005700, fmt=>'g' }, + 'ror' => {typ=>'op', val=>0006000, fmt=>'g' }, + 'rol' => {typ=>'op', val=>0006100, fmt=>'g' }, + 'asr' => {typ=>'op', val=>0006200, fmt=>'g' }, + 'asl' => {typ=>'op', val=>0006300, fmt=>'g' }, + 'mark' => {typ=>'op', val=>0006400, fmt=>'n6' }, + 'mfpi' => {typ=>'op', val=>0006500, fmt=>'g' }, + 'mtpi' => {typ=>'op', val=>0006600, fmt=>'g' }, + 'sxt' => {typ=>'op', val=>0006700, fmt=>'g' }, + 'csm' => {typ=>'op', val=>0007000, fmt=>'g' }, + 'tstset' => {typ=>'op', val=>0007200, fmt=>'g' }, + 'wrtlck' => {typ=>'op', val=>0007300, fmt=>'g' }, + 'mov' => {typ=>'op', val=>0010000, fmt=>'gg' }, + 'cmp' => {typ=>'op', val=>0020000, fmt=>'gg' }, + 'bit' => {typ=>'op', val=>0030000, fmt=>'gg' }, + 'bic' => {typ=>'op', val=>0040000, fmt=>'gg' }, + 'bis' => {typ=>'op', val=>0050000, fmt=>'gg' }, + 'add' => {typ=>'op', val=>0060000, fmt=>'gg' }, + 'mul' => {typ=>'op', val=>0070000, fmt=>'gr' }, + 'div' => {typ=>'op', val=>0071000, fmt=>'gr' }, + 'ash' => {typ=>'op', val=>0072000, fmt=>'gr' }, + 'ashc' => {typ=>'op', val=>0073000, fmt=>'gr' }, + 'xor' => {typ=>'op', val=>0074000, fmt=>'rg' }, + 'sob' => {typ=>'op', val=>0077000, fmt=>'ru6'}, + 'bpl' => {typ=>'op', val=>0100000, fmt=>'s8' }, + 'bmi' => {typ=>'op', val=>0100400, fmt=>'s8' }, + 'bhi' => {typ=>'op', val=>0101000, fmt=>'s8' }, + 'blos' => {typ=>'op', val=>0101400, fmt=>'s8' }, + 'bvc' => {typ=>'op', val=>0102000, fmt=>'s8' }, + 'bvs' => {typ=>'op', val=>0102400, fmt=>'s8' }, + 'bcc' => {typ=>'op', val=>0103000, fmt=>'s8' }, + 'bhis' => {typ=>'op', val=>0103000, fmt=>'s8' }, #alias + 'bcs' => {typ=>'op', val=>0103400, fmt=>'s8' }, + 'blo' => {typ=>'op', val=>0103400, fmt=>'s8' }, #alias + 'emt' => {typ=>'op', val=>0104000, fmt=>'n8' }, + 'trap' => {typ=>'op', val=>0104400, fmt=>'n8' }, + 'clrb' => {typ=>'op', val=>0105000, fmt=>'g' }, + 'comb' => {typ=>'op', val=>0105100, fmt=>'g' }, + 'incb' => {typ=>'op', val=>0105200, fmt=>'g' }, + 'decb' => {typ=>'op', val=>0105300, fmt=>'g' }, + 'negb' => {typ=>'op', val=>0105400, fmt=>'g' }, + 'adcb' => {typ=>'op', val=>0105500, fmt=>'g' }, + 'sbcb' => {typ=>'op', val=>0105600, fmt=>'g' }, + 'tstb' => {typ=>'op', val=>0105700, fmt=>'g' }, + 'rorb' => {typ=>'op', val=>0106000, fmt=>'g' }, + 'rolb' => {typ=>'op', val=>0106100, fmt=>'g' }, + 'asrb' => {typ=>'op', val=>0106200, fmt=>'g' }, + 'aslb' => {typ=>'op', val=>0106300, fmt=>'g' }, + 'mtps' => {typ=>'op', val=>0106400, fmt=>'g' }, + 'mfpd' => {typ=>'op', val=>0106500, fmt=>'g' }, + 'mtpd' => {typ=>'op', val=>0106600, fmt=>'g' }, + 'mfps' => {typ=>'op', val=>0106700, fmt=>'g' }, + 'movb' => {typ=>'op', val=>0110000, fmt=>'gg' }, + 'cmpb' => {typ=>'op', val=>0120000, fmt=>'gg' }, + 'bitb' => {typ=>'op', val=>0130000, fmt=>'gg' }, + 'bicb' => {typ=>'op', val=>0140000, fmt=>'gg' }, + 'bisb' => {typ=>'op', val=>0150000, fmt=>'gg' }, + 'sub' => {typ=>'op', val=>0160000, fmt=>'gg' }, + 'cfcc' => {typ=>'op', val=>0170000, fmt=>'-' ,fpp=>1 }, + 'setf' => {typ=>'op', val=>0170001, fmt=>'-' ,fpp=>1 }, + 'setd' => {typ=>'op', val=>0170011, fmt=>'-' ,fpp=>1 }, + 'seti' => {typ=>'op', val=>0170002, fmt=>'-' ,fpp=>1 }, + 'setl' => {typ=>'op', val=>0170012, fmt=>'-' ,fpp=>1 }, + 'ldfps' => {typ=>'op', val=>0170100, fmt=>'g' ,fpp=>1 }, + 'stfps' => {typ=>'op', val=>0170200, fmt=>'g' ,fpp=>1 }, + 'stst' => {typ=>'op', val=>0170300, fmt=>'g' ,fpp=>1 }, + 'clrf' => {typ=>'op', val=>0170400, fmt=>'g' ,fpp=>1 }, + 'clrd' => {typ=>'op', val=>0170400, fmt=>'g' ,fpp=>1 }, # alias + 'tstf' => {typ=>'op', val=>0170500, fmt=>'g' ,fpp=>1 }, + 'tstd' => {typ=>'op', val=>0170500, fmt=>'g' ,fpp=>1 }, # alias + 'absf' => {typ=>'op', val=>0170600, fmt=>'g' ,fpp=>1 }, + 'absd' => {typ=>'op', val=>0170600, fmt=>'g' ,fpp=>1 }, # alias + 'negf' => {typ=>'op', val=>0170700, fmt=>'g' ,fpp=>1 }, + 'negd' => {typ=>'op', val=>0170700, fmt=>'g' ,fpp=>1 }, # alias + 'mulf' => {typ=>'op', val=>0171000, fmt=>'gr' ,fpp=>1 }, + 'muld' => {typ=>'op', val=>0171000, fmt=>'gr' ,fpp=>1 }, # alias + 'modf' => {typ=>'op', val=>0171400, fmt=>'gr' ,fpp=>1 }, + 'modd' => {typ=>'op', val=>0171400, fmt=>'gr' ,fpp=>1 }, # alias + 'addf' => {typ=>'op', val=>0172000, fmt=>'gr' ,fpp=>1 }, + 'addd' => {typ=>'op', val=>0172000, fmt=>'gr' ,fpp=>1 }, # alias + 'ldf' => {typ=>'op', val=>0172400, fmt=>'gr' ,fpp=>1 }, + 'ldd' => {typ=>'op', val=>0172400, fmt=>'gr' ,fpp=>1 }, # alias + 'subf' => {typ=>'op', val=>0173000, fmt=>'gr' ,fpp=>1 }, + 'subd' => {typ=>'op', val=>0173000, fmt=>'gr' ,fpp=>1 }, # alias + 'cmpf' => {typ=>'op', val=>0173400, fmt=>'gr' ,fpp=>1 }, + 'cmpd' => {typ=>'op', val=>0173400, fmt=>'gr' ,fpp=>1 }, # alias + 'stf' => {typ=>'op', val=>0174000, fmt=>'rg' ,fpp=>1 }, + 'std' => {typ=>'op', val=>0174000, fmt=>'rg' ,fpp=>1 }, # alias + 'divf' => {typ=>'op', val=>0174400, fmt=>'gr' ,fpp=>1 }, + 'divd' => {typ=>'op', val=>0174400, fmt=>'gr' ,fpp=>1 }, # alias + 'stexp' => {typ=>'op', val=>0175000, fmt=>'rg' ,fpp=>1 }, + 'stcfi' => {typ=>'op', val=>0175400, fmt=>'rg' ,fpp=>1 }, + 'stcfl' => {typ=>'op', val=>0175400, fmt=>'rg' ,fpp=>1 }, # alias + 'stcdi' => {typ=>'op', val=>0175400, fmt=>'rg' ,fpp=>1 }, # alias + 'stcdl' => {typ=>'op', val=>0175400, fmt=>'rg' ,fpp=>1 }, # alias + 'stcfd' => {typ=>'op', val=>0176000, fmt=>'rg' ,fpp=>1 }, + 'stcdf' => {typ=>'op', val=>0176000, fmt=>'rg' ,fpp=>1 }, # alias + 'ldexp' => {typ=>'op', val=>0176400, fmt=>'gr' ,fpp=>1 }, + 'ldcif' => {typ=>'op', val=>0177000, fmt=>'gr' ,fpp=>1 }, + 'ldcid' => {typ=>'op', val=>0177000, fmt=>'gr' ,fpp=>1 }, # alias + 'ldclf' => {typ=>'op', val=>0177000, fmt=>'gr' ,fpp=>1 }, # alias + 'ldcld' => {typ=>'op', val=>0177000, fmt=>'gr' ,fpp=>1 }, # alias + 'ldcdf' => {typ=>'op', val=>0177400, fmt=>'gr' ,fpp=>1 }, + 'ldcfd' => {typ=>'op', val=>0177400, fmt=>'gr' ,fpp=>1 } # alias +); + +# operand formats +my %opfmt = ( + '-' => [], # halt,... + 'n3' => [{typ=>'e', pref=>''}], # spl + 'n6' => [{typ=>'e', pref=>''}], # mark + 'n8' => [{typ=>'e', pref=>''}], # trap,emt + 'r' => [{typ=>'r', pref=>'o1'}], # rts + 'g' => [{typ=>'g', pref=>'o1'}], # inc,... + 'rg' => [{typ=>'r', pref=>'o1'}, {typ=>'g', pref=>'o2'}], # xor,jsr + 'gr' => [{typ=>'g', pref=>'o2'}, {typ=>'r', pref=>'o1'}], # ash,... + 'gg' => [{typ=>'g', pref=>'o1'}, {typ=>'g', pref=>'o2'}], # add,... + 's8' => [{typ=>'e', pref=>''}], # br,... + 'ru6' => [{typ=>'r', pref=>'o1'}, {typ=>'e', pref=>''}] # sob +); + +# psect table +my %psect = +('.abs.' => {dot=>0, dotmax=>0} +); +my $cur_psect = '.abs.'; # current psect + +# local symbol table +my %lst = +('.' => {name=>'.', typ=>'dot', val=>0, psect=>'.abs.'} +); +my $llbl_scope = '0'; # current local label scope +my $llbl_ascope = 0; # annonymous local label scope count + +# macro table +my %mst; + +my @flist; # list of filenames +my $fstem; # stem or last file name +my $lst_do; # generate listing +my $lst_fname; # listing file name +my $lda_do; # generate lda output +my $lda_fname; # lda file name +my $cof_do; # generate cof output +my $cof_fname; # cof file name +my $lsm_do; # generate lsm output +my $lsm_fname; # lsm file name + +my @src; +my %errcnt; # error tag counter +my $errcnt_tot=0; # total error count +my $pass; + +my @t_pushback; + +my $out_dot; # current . for output +my @out_data; # output data +my $out_start = 1; # absolute start address + +autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe + +if (exists $opts{help}) { + print_help; + exit 0; +} + +if (scalar(@ARGV) == 0) { + print STDERR "asm-11-F: no input files specified, quiting..\n"; + print_help; + exit 1; +} + +# find stem of last file name +$fstem = $ARGV[-1]; +$fstem =~ s|^.*/||; # drop leading dirs +$fstem =~ s|\.mac$||; # drop trailing '.mac' + +if ($opts{lst} || $opts{olst}) { + $lst_do = 1; + $lst_fname = create_fname($opts{olst},'.lst'); +} + +if ($opts{lda} || $opts{olda}) { + $lda_do = 1; + $lda_fname = create_fname($opts{olda},'.lda'); +} + +if ($opts{cof} || $opts{ocof}) { + $cof_do = 1; + $cof_fname = create_fname($opts{ocof},'.cof'); +} + +if ($opts{lsm} || $opts{olsm}) { + $lsm_do = 1; + $lsm_fname = create_fname($opts{olsm},'.lsm'); +} + +# do pass 1 +$pass = 1; +foreach my $fname (@ARGV) { + read_file($fname); +} +dump_sym() if $opts{dsym1}; + +# prepare pass 2 + +foreach (keys %psect) { + $psect{$_}{dot} = 0; +} + +$lst{'.'}->{val} = 0; +$lst{'.'}->{psect} = '.abs.'; + +$cur_psect = '.abs.'; +$llbl_scope = '0'; + +# do pass 2 +$pass = 2; +pass2(); +dump_sym() if $opts{dsym2}; + +# create object output files +write_lda($lda_fname) if $lda_do; +write_cof($cof_fname) if $cof_do; +write_lsm($lsm_fname) if $lsm_do; + +# and exit +if ($errcnt_tot > 0) { + print "asm-11-E: compilation errors:"; + foreach my $err (sort keys %errcnt) { + printf " %s: %d", $err, $errcnt{$err}; + } + print "\n"; + exit 1; +} +exit 0; + +#------------------------------------------------------------------------------- + +sub create_fname { + my ($fname,$suff) = @_; + if (defined $fname) { + $fname =~ s|\%|$fstem|; + return $fname; + } + $fname = $fstem; + $fname .= $suff unless $fname eq '-'; + return $fname; +} + +#------------------------------------------------------------------------------- + +sub read_file { + my ($fname) = @_; + my $fh; + if ($fname eq "-") { + $fh = *STDIN; + } else { + if (not -r $fname) { + print STDERR "asm-11-F: '$fname' not found or readable, quiting..\n"; + exit 1; + } + $fh = new FileHandle; + $fh->open($fname) or die "failed to open '$fname'"; + } + + push @flist, $fname; + + my $lineno = 0; + my $fileno = scalar(@flist); + while (<$fh>) { + chomp; + my $line = $_; + $lineno += 1; + my $rl = parse_line($fileno, $lineno, $line); + dump_rl($rl) if $opts{tpass1}; + push @src, $rl; + + # handle .include + if (defined $$rl{oper} && $$rl{oper} eq '.include' && defined $$rl{ifile}) { + my $fnam = $$rl{ifile}; + unless ($fnam =~ m|^/|) { + foreach (@{$opts{I}}) { + if (-r "$_/$fnam") { + $fnam = "$_/$fnam"; + last; + } + } + } + read_file($fnam); + } + + } + + return; +} + +#------------------------------------------------------------------------------- + +sub parse_line { + my ($fileno,$lineno,$line) = @_; + + my %l = ( fileno => $fileno, # file number + lineno => $lineno, # line number + line => $line, # line + cl => [split '',$line], # char list + tl => [], # token list + err => '', # error tags + psect => $cur_psect, # current psect + dot => getdot(), # current dot + outw => [], # output: words + outb => [] # output: bytes + ); + + my $state = 'start'; # parser state + + my $op_code; # op code + my $op_fmt; # op format + my $op_fpp; # true if floating opcode + my @op_ops; # list of operands + my $op_rop; # ref of current operand dsc + + my $s_incok; + my $op_ibeg; + my $op_creg; + my $op_cmod; + my $op_cmod_def; + + my @e_pbeg; + my $e_ibeg; + my $e_iend; + + my $a_sym; + my $a_typ; + + my $d_dire; + my @d_elist; + + my $c; + my $rt; + my $tmask = 0; + + my @stack; + + @t_pushback = (); + + printf "-- parse: '$line'\n" if $opts{tparse} || $opts{ttoken}; + + # quit if illegal character found (non 7 bit ascii in asm-11) + foreach my $c (@{$l{cl}}) { + if (ord($c) > 127) { + add_err(\%l, 'I'); + return \%l; + } + } + + while (1) { + if ($opts{tparse}) { + printf "-- state = $state"; + printf ", nest = %d", scalar(@e_pbeg) if $state =~ m/^e_/; + print "\n"; + } + + if ($state eq 'start') { # state: start ------------------- + $rt = get_token(\%l, $tmask); + + # end of line seen ? + if ($$rt{tag} eq 'EOL') { + last; + + # name seen + } elsif ($$rt{tag} eq 'SYM') { + # directive name seen ? + if (exists $pst{$$rt{val}} && $pst{$$rt{val}}{typ} eq 'dir') { + $state = 'oper'; + + # otherwise check for label or assignment + } else { + my $isllbl = check_llbl($$rt{val}); + $rt = get_token(\%l, $tmask); + # handle local labels + if ($isllbl) { + if ($$rt{tag} eq 'LBL') { + setsym(\%l, 'lbl' ,$l{tl}[-2]{val}, getdot()); + $l{lscope} = $llbl_scope; + $l{label} = $l{tl}[-2]{val}; + $state = 'start1'; + } else { + $state = 'q'; + } + # handle assignments + } elsif ($$rt{tag} eq 'ASS') { + $a_sym = $l{tl}[-2]{val}; + $a_typ = $l{tl}[-1]{val}; + push @stack, 'a_end'; + $state = 'e_beg'; + # handle normal labels + } elsif ($$rt{tag} eq 'LBL') { + setsym(\%l, 'lbl' ,$l{tl}[-2]{val}, getdot()); + $llbl_scope = $l{tl}[-2]{val}; + $l{lscope} = $l{tl}[-2]{val}; + $l{label} = $l{tl}[-2]{val}; + $state = 'start1'; + # if neither label or assigmnent, handle as operation or directive + } else { + pushback_token(\%l); + $state = 'oper'; + } + } + + # anything else seen, treat a implicit .word + } else { + pushback_token(\%l); + $state = 'iword'; + } + + } elsif ($state eq 'start1') { # state: start1 ------------------ + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'EOL') { + last; + } elsif ($$rt{tag} eq 'SYM') { + $state = 'oper'; + } else { # not symbol -> implicit .word + pushback_token(\%l); + $state = 'iword'; + } + + } elsif ($state eq 'oper') { # state: oper -------------------- + # Note: state oper is entered with token already on tl list !! + my $rt0 = $l{tl}[-1]; + my $op = $$rt0{val}; + $l{oper} = $op; + if (exists $pst{$op}) { + my $rs = $pst{$op}; + if ($$rs{typ} eq 'dir') { # directives ------------------ + $d_dire = $op; + if ($op eq '.word' || # .word + $op eq '.byte') { # .byte + $state = 'dl_beg'; + + } elsif ($op eq '.blkw' || # .blkw + $op eq '.blkb') { # .blkb + $state = 'dl_beg'; + + } elsif ($op eq '.ascii' || # .ascii + $op eq '.asciz') { # .asciz + $tmask = TMASK_STRING; + $state = 'al_next'; + + } elsif ($op eq '.even' || # .even + $op eq '.odd') { # .odd + my $dot = getdot(); + my $inc = 0; + $inc = 1 if $op eq '.even' && ($dot&01)==1; + $inc = 1 if $op eq '.odd' && ($dot&01)==0; + incdot(1) if $inc; + $l{typ} = 'data'; + $l{incdot} = $inc; + $l{lstdot} = 1; + $state = 'end'; + + } elsif ($op eq '.asect') { # .asect + # .asect is currently a noop because asect is start default + $l{lstdot} = 1; + $state = 'end'; + + } elsif ($op eq '.include') { # .include + $rt = get_token(\%l, TMASK_STRING); + if ($$rt{tag} eq 'STR') { + my $ifile = $$rt{val}; + my $rt = get_token(\%l, TMASK_STRING); + if ($$rt{tag} eq 'EOL') { + $l{ifile} = substr($ifile,1,-1) unless $l{err} ne ''; + $state = 'end'; + } else { + $state = 'q'; + } + } else { + $state = 'q'; + } + + } elsif ($op eq '.end') { # .end + $state = 'dl_beg'; + + } else { + die "BUGCHECK: op = '$op' in pst but no handler"; + } + + } elsif ($$rs{typ} eq 'op') { # or opcodes ------------------ + walign(\%l); + $l{typ} = 'code'; + $op_code = $$rs{val}; + $op_fmt = $$rs{fmt}; + $op_fpp = $$rs{fpp}; + die "BUGCHECK: op_fmt = '$op_fmt' unknown in opfmt" + unless defined $opfmt{$op_fmt}; + + $l{opcode} = $op_code; + $l{opfmt} = $op_fmt; + + @op_ops = @{$opfmt{$op_fmt}}; + + if (scalar(@op_ops) == 0) { + incdot(2); + $state = 'end'; + } else { + $op_rop = shift @op_ops; + $state = 'op_beg'; + } + + } + } else { # oper noy in pst --> implicit .word + pushback_token(\%l); + $state = 'iword'; + } + + } elsif ($state eq 'op_beg') { # state: op_beg ------------------ + $op_ibeg = scalar(@{$l{tl}}); + $op_creg = undef; + $op_cmod = undef; + $op_cmod_def = undef; + $e_ibeg = undef; + $e_iend = undef; + if ($$op_rop{typ} eq 'r') { # operand: register + $rt = get_token(\%l, $tmask); + $op_creg = check_reg($rt); + if (defined $op_creg) { + if ($op_fpp && $op_creg > 3) { # fpp ac must be r0:r3 + $op_creg &= 03; + add_err(\%l, 'T'); + } + $op_cmod = 0; + $state = 'op_end'; + } else { + $state = 'q'; + } + } elsif ($$op_rop{typ} eq 'e') { # operand: expression + push @stack, 'op_end'; + $state = 'e_beg'; + } elsif ($$op_rop{typ} eq 'g') { # operand: general + push @stack, 'op_end'; + $state = 'g_beg'; + } else { + die "BUGCHECK: unexpected op typ '$$op_rop{typ}'"; + } + + } elsif ($state eq 'op_end') { # state: op_end ------------------ + my $op_iend = scalar(@{$l{tl}})-1; + $l{tl}[$op_ibeg]->{om} = '<'; + $l{tl}[$op_iend]->{om} = ($l{tl}[$op_iend]->{om}) ? '<>' : '>'; + + my $pref = $$op_rop{pref}; + if ($$op_rop{typ} =~ m/^[gr]$/) { + $l{$pref.'reg'} = $op_creg; + $l{$pref.'mod'} = $op_cmod; + if (defined $e_ibeg) { + $l{$pref.'ebeg'} = $e_ibeg; + $l{$pref.'eend'} = $e_iend; + } + } elsif ($$op_rop{typ} eq 'e') { + if (defined $e_ibeg) { + $l{ebeg} = $e_ibeg; + $l{eend} = $e_iend; + } + } + + if (scalar(@op_ops)) { # second operand + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', ',')) { + $op_rop = shift @op_ops; + $state = 'op_beg'; + } else { + $state = 'q'; + } + + } else { # all operands seen + my $nword = 1; + $nword += 1 if defined $l{o1ebeg}; + $nword += 1 if defined $l{o2ebeg}; + incdot(2*$nword); + $state = 'end'; + } + + } elsif ($state eq 'g_beg') { # state: g_beg ------------------- + $rt = get_token(\%l, $tmask); + if (defined check_reg($rt)) { # R ! + $op_creg = check_reg($rt); + $op_cmod = 0; + $state = 'g_end'; + } elsif (check_token($rt, 'DEL', '(')) { # ( R),R)+ + $state = 'g_inc1'; + } elsif (check_token($rt, 'OP', '@')) { # @ R,(R)+,-(R),E(R),#E,E + $op_cmod_def = 1; + $state = 'g_def1'; + } elsif (check_token($rt, 'OP', '-')) { # - (R) + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', '(')) { # next ( + pushback_token(\%l); + $state = 'g_dec1'; # go for -(R) + } else { + pushback_token(\%l); + pushback_token(\%l); + push @stack, 'g_ind1'; # otherwise -E.. + $state = 'e_beg'; + } + } elsif (check_token($rt, 'OP', '#')) { # # E + push @stack, 'g_imm1'; + $state = 'e_beg'; + } else { + pushback_token(\%l); + push @stack, 'g_ind1'; # E ! (R) + $state = 'e_beg'; + } + + } elsif ($state eq 'g_inc1') { # state: g_inc1 ------------------ + $rt = get_token(\%l, $tmask); + $op_creg = check_reg($rt); + if (defined $op_creg) { + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', ')')) { + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'OP', '+')) { + $op_cmod = $op_cmod_def ? 3 : 2; + $state = 'g_end'; + } else { + if ($op_cmod_def) { + $state = 'q'; + } else { + pushback_token(\%l); + $op_cmod = 1; + $state = 'g_end'; + } + } + } else { + $state = 'q'; + } + } else { + $state = 'q'; + } + + } elsif ($state eq 'g_def1') { # state: g_def1 ------------------ + $rt = get_token(\%l, $tmask); + if (defined check_reg($rt)) { # R + $op_creg = check_reg($rt); + $op_cmod = 1; + $state = 'g_end'; + } elsif (check_token($rt, 'DEL', '(')) { # ( -> R+ + $state = 'g_inc1'; + } elsif (check_token($rt, 'OP', '-')) { # - -> (R) + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', '(')) { # next ( + pushback_token(\%l); + $state = 'g_dec1'; # go for -(R) + } else { + pushback_token(\%l); + pushback_token(\%l); + push @stack, 'g_ind1'; # otherwise -E.. + $state = 'e_beg'; + } + } elsif (check_token($rt, 'OP', '#')) { # # -> # + push @stack, 'g_imm1'; + $state = 'e_beg'; + } else { # E -> !, (R) + pushback_token(\%l); + push @stack, 'g_ind1'; + $state = 'e_beg'; + } + + } elsif ($state eq 'g_ind1') { # state: g_ind1 ------------------ + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', '(')) { + $rt = get_token(\%l, $tmask); + $op_creg = check_reg($rt); + if (defined $op_creg) { + $rt = get_token(\%l, $tmask); + $op_cmod = $op_cmod_def ? 7 : 6; + $state = check_token($rt, 'DEL', ')') ? 'g_end' : 'q'; + } else { + $state = 'q'; + } + } else { + pushback_token(\%l); + $op_creg = 7; + $op_cmod = $op_cmod_def ? 7 : 6; + $state = 'g_end'; + } + + } elsif ($state eq 'g_dec1') { # state: g_dec1 ------------------ + $rt = get_token(\%l, $tmask); + if (check_token($rt, 'DEL', '(')) { + $rt = get_token(\%l, $tmask); + $op_creg = check_reg($rt); + if (defined $op_creg) { + $rt = get_token(\%l, $tmask); + $op_cmod = $op_cmod_def ? 5 : 4; + $state = check_token($rt, 'DEL', ')') ? 'g_end' : 'q'; + } else { + $state = 'q'; + } + } else { + $state = 'q'; + } + + } elsif ($state eq 'g_imm1') { # state: g_imm1 ------------------ + $op_creg = 7; + $op_cmod = $op_cmod_def ? 3 : 2; + $state = 'g_end'; + + } elsif ($state eq 'g_end') { # state: g_end ------------------- + $state = pop @stack; + + } elsif ($state eq 'e_beg') { # state: e_beg ------------------- + $e_ibeg = scalar(@{$l{tl}}); + @e_pbeg = (); + $state = 'e_uop'; + + } elsif ($state eq 'e_uop') { # state: e_uop ------------------- + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'OP' && $$rt{typ}=~'u') { # OP(u) + $$rt{typ}='u'; + $state = 'e_uop'; + } elsif ($$rt{tag} eq 'NUM' || $$rt{tag} eq 'SYM') { + $state = 'e_bop'; + } elsif (check_token($rt, 'DEL', '<')) { + push @e_pbeg, scalar(@{$l{tl}})-1; + $state = 'e_uop'; + } else { + $state = 'q'; + } + + } elsif ($state eq 'e_bop') { # state: e_bop ------------------- + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'OP' && $$rt{typ}=~'b') { # OP(b) + $$rt{typ}='b'; + $state = 'e_bop1'; + } elsif (check_token($rt, 'DEL', '>')) { + if (scalar(@e_pbeg) == 0) { + $state = 'q'; + } else { + my $pbeg = pop @e_pbeg; + $l{tl}[$pbeg]->{pend} = scalar(@{$l{tl}})-1; + if ($tmask & TMASK_STRINGEXP) { + $state = 'e_end'; + } else { + $state = 'e_bop'; + } + } + } else { + pushback_token(\%l); + $state = 'e_end'; + } + + } elsif ($state eq 'e_bop1') { # state: e_bop1 ------------------ + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'NUM' || $$rt{tag} eq 'SYM') { + $state = 'e_bop'; + } elsif (check_token($rt, 'DEL', '<')) { + push @e_pbeg, scalar(@{$l{tl}})-1; + $state = 'e_uop'; + } else { + $state = 'q'; + } + + } elsif ($state eq 'e_end') { # state: e_end ------------------- + $e_iend = scalar(@{$l{tl}})-1; + $l{tl}[$e_ibeg]->{em} = '<>'; + if ($e_iend != $e_ibeg) { + $l{tl}[$e_ibeg]->{em} = '<'; + $l{tl}[$e_iend]->{em} = '>'; + } + $state = (scalar(@e_pbeg)==0) ? pop @stack : 'q'; + + } elsif ($state eq 'a_end') { # state: a_end ------------------- + my $val = eval_exp(\%l, $e_ibeg, $e_iend); + my $typ = ($a_typ =~ m/:/) ? 'pass' : 'ass'; + setsym(\%l, $typ, $a_sym, $val); + $l{typ} = 'ass'; + $l{atyp} = $typ; + $l{asym} = $a_sym; + $l{ebeg} = $e_ibeg; + $l{eend} = $e_iend; + $state = 'end'; + + } elsif ($state eq 'dl_beg') { # state: dl_beg ------------------ + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'EOL') { + $state = 'dl_end'; + } elsif (check_token($rt, 'DEL', ',')) { + pushback_token(\%l); + $e_ibeg = undef; + $e_iend = undef; + $state = 'dl_next'; + } else { + pushback_token(\%l); + $e_ibeg = undef; + $e_iend = undef; + push @stack, 'dl_next'; + $state = 'e_beg'; + } + + } elsif ($state eq 'dl_next') { # state: dl_next ----------------- + push @d_elist, {ibeg=>$e_ibeg, iend=>$e_iend}; + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'EOL') { + $state = 'dl_end'; + } elsif (check_token($rt, 'DEL', ',')) { + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'EOL' || check_token($rt, 'DEL', ',')) { + pushback_token(\%l); + $e_ibeg = undef; + $e_iend = undef; + $state = 'dl_next'; + } else { + pushback_token(\%l); + $e_ibeg = undef; + $e_iend = undef; + push @stack, 'dl_next'; + $state = 'e_beg'; + } + } else { + $state = 'q'; + } + + } elsif ($state eq 'dl_end') { # state: dl_end ------------------ + $state = 'end'; + if ($d_dire eq '.word') { + walign(\%l); + if (scalar(@d_elist)) { + $l{typ} = 'data'; + $l{delist} = \@d_elist; + incdot(2*scalar(@d_elist)); + } else { + $state = 'q'; + } + } elsif ($d_dire eq '.byte') { + if (scalar(@d_elist)) { + $l{typ} = 'data'; + $l{delist} = \@d_elist; + incdot(1*scalar(@d_elist)); + } else { + $state = 'q'; + } + } elsif ($d_dire eq '.blkw' || $d_dire eq '.blkb') { + $l{lstdot} = 1; + walign(\%l) if $d_dire eq '.blkw'; + my $val; + if (scalar(@d_elist) == 0) { + $val = 1; + } elsif (scalar(@d_elist) == 1) { + $val = eval_exp(\%l, $d_elist[0]{ibeg}, $d_elist[0]{iend}); + } else { + $state = 'q'; + } + + if (defined $val) { + my $size = ($d_dire eq '.blkw') ? 2 : 1; + incdot($size * $val); + $l{typ} = 'data'; + $l{incdot} = $size * $val; + } else { + add_err(\%l, 'A'); + } + + } elsif ($d_dire eq '.end') { + my $val; + if (scalar(@d_elist) == 0) { + $val = 1; + } elsif (scalar(@d_elist) == 1) { + $val = eval_exp(\%l, $d_elist[0]{ibeg}, $d_elist[0]{iend}); + } else { + $state = 'q'; + } + if (defined $val) { + $l{lstval} = $val; # set aval to get it in listing + $out_start = $val; + } else { + $l{lstval} = 0; + add_err(\%l, 'U'); + } + + } else { + die "BUGCHECK: unexpected d_dire = '$d_dire'"; + } + + } elsif ($state eq 'al_next') { # state: al_next ----------------- + $rt = get_token(\%l, $tmask); + if ($$rt{tag} eq 'STR') { + push @d_elist, {str=>$$rt{val}}; + } elsif ($$rt{tag} eq 'EOL') { + $state = 'al_end'; + } elsif (check_token($rt, 'DEL', '<')) { + pushback_token(\%l); + $tmask = TMASK_STRINGEXP; + push @stack, 'al_exp'; + $e_ibeg = undef; + $e_iend = undef; + $state = 'e_beg'; + } else { + $state = 'q'; + } + + } elsif ($state eq 'al_exp') { # state: al_exp ------------------ + push @d_elist, {ibeg=>$e_ibeg, iend=>$e_iend}; + $tmask = TMASK_STRING; + $state = 'al_next'; + + } elsif ($state eq 'al_end') { # state: al_end ------------------ + my $size = 0; + foreach (@d_elist) { + if (defined $$_{str}) { + $size += length($$_{str}) - 2; + } else { + $size += 1; + } + } + $size += 1 if $d_dire eq '.asciz'; + incdot($size); + $l{typ} = 'data'; + $l{delist} = \@d_elist; + $state = 'end'; + + } elsif ($state eq 'iword') { # state: iword ------------------- + $l{oper} = $d_dire = '.word'; # setup implicit .word directive + $state = 'dl_beg'; + + } elsif ($state eq 'end') { # state: end --------------------- + # unless EOL already seen fetch next token + if (scalar(@{$l{tl}}) && $l{tl}[-1]{tag} eq 'EOL') { + $rt = $l{tl}[-1]; + } else { + $rt = get_token(\%l, $tmask); + } + # if at EOL fine, otherwise mark syntax error + if ($$rt{tag} eq 'EOL') { + last; + } else { + $state = 'q'; + } + + } elsif ($state eq 'q') { # state: q ----------------------- + add_err(\%l, 'Q'); # set Q error flag + last; # and quit this line + + } else { + die "BUGCHECK: unexpected state '$state'\n"; + } + } + + return \%l; +} + +#------------------------------------------------------------------------------- + +sub walign { + my ($rl) = @_; + my $dot = getdot(); + if ($dot & 0x1) { # odd address ? + incdot(1); + add_err($rl, 'B'); + $$rl{dot} = getdot() if ($pass == 2); # fixup . in rl context in pass 2 + } + return; +} + +#------------------------------------------------------------------------------- + +sub add_err { + my ($rl,$err) = @_; + return if index($$rl{err}, $err) >= 0; # prevent multiple error tags + $$rl{err} .= $err; # set error tag + $errcnt{$err} += 1; # and count them + $errcnt_tot += 1; + return; +} + +#------------------------------------------------------------------------------- + +sub prt_err { + my ($rl) = @_; + return join '', sort split '', $$rl{err}; +} + +#------------------------------------------------------------------------------- + +sub setdot { + my ($val) = @_; + return unless defined $val; + $lst{'.'}->{val} = $val; + $psect{$cur_psect}{dot} = $val; + $psect{$cur_psect}{dotmax} = $val if $psect{$cur_psect}{dotmax} < $val; + return; +} + +#------------------------------------------------------------------------------- + +sub incdot { + my ($inc) = @_; + return unless defined $inc; + setdot(getdot() + $inc); + return; +} + +#------------------------------------------------------------------------------- + +sub getdot { + return $lst{'.'}{val}; +} + +#------------------------------------------------------------------------------- + +sub setsym { + my ($rl,$typ,$name,$val) = @_; + ##print "+++set: pass=$pass; $llbl_scope : $name; typ=$typ\n"; + if ($name eq '.') { + if ($typ eq 'ass') { + setdot($val); + } else { + add_err($rl, 'A'); + } + return; + } + + my $isllbl = check_llbl($name); + if (check_llbl($name)) { + if ($typ eq 'lbl') { + $name = $llbl_scope . ':' . $name if $isllbl; + $typ = 'llbl'; + } else { + die "BUGCHECK: name looks like local label, but typ=$typ"; + } + } + + my $namelc = lc($name); + + if ($typ ne 'ass' && exists $lst{$namelc} && + $lst{$namelc}{typ} ne 'udef' && $pass==1) { + # Note: 'M' etaging done in pass 2! + $lst{$namelc}{mdef} = 1; + return; + } + + $lst{$namelc}{name} = $name; + $lst{$namelc}{val} = $val; + $lst{$namelc}{typ} = $typ; + $lst{$namelc}{psect} = $cur_psect; + + return; +} + +#------------------------------------------------------------------------------- + +sub getsym { + my ($rl, $name, $noxref) = @_; + ##print "+++get: pass=$pass; $llbl_scope : $name\n"; + $name = $llbl_scope . ':' . $name if check_llbl($name); + my $namelc = lc($name); + + # if not yet defined, add it in lst with typ='udef' + if (not exists $lst{$namelc}) { # not yet in lst + if (exists $pst{$namelc} && # but known as opcode + $pst{$namelc}{typ} eq 'op') { + return $pst{$namelc}{val}; # return that value + } else { + $lst{$namelc} = { name => $name, + val => undef, + typ => 'udef', + psect => '' + }; + return undef; + } + } + + unless ($noxref) { + if ($lst{$namelc}{mdef}) { + add_err($rl, 'D'); + } + } + + return $lst{$namelc}{val}; +} + +#------------------------------------------------------------------------------- + +sub lst_checkmdef { + my ($name) = @_; + $name = $llbl_scope . ':' . $name if check_llbl($name); + my $namelc = lc($name); + return $lst{$namelc}{mdef}; +} + +#------------------------------------------------------------------------------- + +sub eval_exp { + my ($rl,$ibeg,$iend,$nest) = @_; + my $rtl = $$rl{tl}; + my @uop; + my $bop; + my @val; + + return undef unless defined $ibeg && defined $iend; + return undef unless defined $$rtl[$ibeg] || $nest; # FIXME_code: test em !! + + for (my $i=$ibeg; $i<=$iend; $i++) { + my $rt = $$rtl[$i]; + my $do_uop = 0; + if ($$rt{tag} eq 'NUM') { + push @val, $$rt{nval}; + + } elsif ($$rt{tag} eq 'SYM') { + push @val, getsym($rl, $$rt{val}); + + } elsif ($$rt{tag} eq 'OP' && $$rt{typ} eq 'u') { + push @uop, $$rt{val}; + + } elsif ($$rt{tag} eq 'OP' && $$rt{typ} eq 'b') { + $bop = $$rt{val}; + + } elsif ($$rt{val} eq '<') { + my $pend = $$rt{pend}; + die "BUGCHECK: pend not found for rtl[$i]" unless defined $pend; + push @val, eval_exp($rl,$i+1,$pend-1,1); + $i = $pend; + + } else { + die "BUGCHECK: tag='$$rt{tag}', val='$$rt{val}'\n"; + } + + # if stack non-empty: return undef on undef, apply unary operators + if (scalar(@val) > 0) { + return undef unless defined $val[-1]; + my $o; + while($o = pop @uop) { + my $v = pop @val; + if ($o eq '+') { + } elsif ($o eq '-') { + $v = -$v; + } elsif ($o eq '^c') { + $v = ~$v; + } else { + die "BUGCHECK: tag='OP(u)', val='$o'\n"; + } + push @val, (0177777 & $v); + } + } + + # if stack has 2 operands: apply binary operator + if (scalar(@val) == 2) { + die "BUGCHECK: bop not defined" unless defined $bop; + my $v2 = pop @val; + my $v1 = pop @val; + return undef unless defined $v1 && defined $v2; + if ($bop eq '+') { + push @val, int($v1) + int($v2); + } elsif ($bop eq '-') { + push @val, int($v1) - int($v2); + } elsif ($bop eq '*') { + push @val, int($v1) * int($v2); + } elsif ($bop eq '/') { + push @val, int(int($v1) / int($v2)); + } elsif ($bop eq '&') { + push @val, int($v1) & int($v2); + } elsif ($bop eq '!') { + push @val, int($v1) | int($v2); + } else { + die "BUGCHECK: tag='OP(b)', val='$bop'\n"; + } + $bop = undef; + } + + } + return pop @val; +} + +#------------------------------------------------------------------------------- +# returns true if symbol looks like a local label (1234$) + +sub check_llbl { + my ($name) = @_; + return ($name =~ m/^\d+\$/) ? 1 : 0; +} + +#------------------------------------------------------------------------------- +# returns register number if register symbol, or undef + +sub check_reg { + my ($rt) = @_; + return undef unless $$rt{tag} eq 'SYM'; + my $pse = $pst{$$rt{val}}; + return undef unless defined $pse; + return undef unless $$pse{typ} eq 'reg'; + return $$pse{val}; +} + +#------------------------------------------------------------------------------- +# returns true if token has specific tag/val + +sub check_token { + my ($rt, $tag, $val) = @_; + return undef unless $$rt{tag} eq $tag; + return $$rt{val} eq $val; +} + +#------------------------------------------------------------------------------- + +sub pushback_token { + my ($rl) = @_; + + my $rt = pop @{$$rl{tl}}; + push @t_pushback, $rt; + + if ($opts{ttoken}) { + printf "-- token-back: tag=%-3s val='%s'\n", + $$rt{tag}, savestr($$rt{val}); + } + + return; +} + +#------------------------------------------------------------------------------- + +sub get_token { + my ($rl, $tmask) = @_; + my $rt; + + if (scalar(@t_pushback)) { + $rt = pop @t_pushback; + if ($opts{ttoken}) { + printf "-- token-reget: tag=%-3s val='%s'\n", + $$rt{tag}, savestr($$rt{val}); + } + + } else { + $rt = get_token1($rl, $tmask); + if ($opts{ttoken}) { + printf "-- token-get: tag=%-3s val='%s'\n", + $$rt{tag}, savestr($$rt{val}); + } + } + + push @{$$rl{tl}}, $rt; + + return $rt; +} + +#------------------------------------------------------------------------------- + +sub finish_token { + my $rt = shift @_; + while (scalar(@_)) { + my $tag = shift @_; + my $val = shift @_; + $$rt{$tag} = $val; + } + return $rt; +} + +#------------------------------------------------------------------------------- + +sub get_token1 { + my ($rl, $tmask) = @_; + my $rcl = $$rl{cl}; + + my $val; + my $ws = ''; + + # drop any leading whitespace + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/\s/); + $ws .= shift @$rcl; + } + + my %t = (mask => $tmask, + ws => $ws + ); + + # end of line ? + unless (scalar(@$rcl)) { + return finish_token(\%t, tag=>'EOL', val=>$val); + } + + # get leading char + my $c = $$rcl[0]; + + # comment ? treated similar to end of line, comment saved in val + if($c eq ';') { + $val = join('',@$rcl); + @$rcl = (); + return finish_token(\%t, tag=>'EOL', val=>$val); + } + + # here context dependent tokens + if ($tmask & TMASK_STRING) { + my $del = shift @$rcl; + if ($del eq '<') { + return finish_token(\%t, tag=> 'DEL', val=> $del); + } else { + my $str = $del; + while (scalar(@$rcl)) { + my $c = shift @$rcl; + $str .= $c; + return finish_token(\%t, tag=> 'STR', val=> $str) if $c eq $del; + } + add_err($rl, 'A'); + return finish_token(\%t, tag=> 'STR', val=> $str); + } + } + + # looks like symbol ? + if ($c =~ m/[a-zA-Z\$\.]/) { + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[a-zA-Z0-9\$\.]/); + $val .= shift @$rcl; + } + return finish_token(\%t, tag=> 'SYM', val=> $val); + } + + # looks like number or local label ? + if ($c =~ m/[0-9]/) { + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[0-9]/); + $val .= shift @$rcl; + } + # check for local label + if (scalar(@$rcl) && $$rcl[0] eq '$') { + # FIXME_code: reject labels with numbers >64k-1 + $val .= shift @$rcl; + return finish_token(\%t, tag=> 'SYM', val=> $val); + } + # looks like numerical constant + my $nval = undef; + # if trailing '.' seen, add and handle as decimal, otherwise as octal + if (scalar(@$rcl) && $$rcl[0] eq '.') { + $nval =int($val); + $val .= shift @$rcl; + if ($nval > 65535) { + add_err($rl, 'T'); + $nval &= 0177777; + } + } else { + $nval = 0; + foreach my $cc (split '',$val) { + $nval = ($nval<<3) + int($cc); + add_err($rl, 'N') unless $cc =~ m/[0-7]/; + add_err($rl, 'T') unless $nval <= 0177777; + $nval &= 0177777; + } + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=>$nval); + } + + # looks like label delimiter (':' or '::') ? + if ($c eq ':') { + $val .= shift @$rcl; + $val .= shift @$rcl if (scalar(@$rcl) && $$rcl[0] eq ':'); + return finish_token(\%t, tag=> 'LBL', val=> $val); + } + + # looks assignment delimiter ('=','=:','==','==:') ? + if ($c eq '=') { + $val .= shift @$rcl; + $val .= shift @$rcl if (scalar(@$rcl) && $$rcl[0] eq '='); + $val .= shift @$rcl if (scalar(@$rcl) && $$rcl[0] eq ':'); + return finish_token(\%t, tag=> 'ASS', val=> $val); + } + + # operators + if ($c =~ m/^(\+|\-)$/ ) { # unary/binary operators + return finish_token(\%t, tag=> 'OP', typ=> 'ub', val=> shift @$rcl); + } + if ($c =~ m/^(\*|\/|\&|\!)$/ ) { # binary operators + return finish_token(\%t, tag=> 'OP', typ=> 'b', val=> shift @$rcl); + } + if ($c =~ m/^(\#|\@)$/ ) { # unary operators + return finish_token(\%t, tag=> 'OP', typ=> 'u', val=> shift @$rcl); + } + + # ' and " operator + if ($c eq "'") { + $val .= shift @$rcl; + $c = shift @$rcl; + if (not defined $c) { + return finish_token(\%t, tag=> 'BAD', val=> $val); + } + $val .= $c; + return finish_token(\%t, tag => 'NUM', val=> $val, nval=>ord($c)); + } + + if ($c eq '"') { + $val .= shift @$rcl; + my $c1 = shift @$rcl; + my $c2 = shift @$rcl; + if (! defined $c1 || ! defined $c2) { + return finish_token(\%t, tag=> 'BAD', val=> $val); + } + $val .= $c1; + $val .= $c2; + return finish_token(\%t, tag => 'NUM', val=> $val, + nval=>ord($c2)<<8|ord($c1)); + } + + # universal ^ operator + if ($c eq '^') { + $val .= shift @$rcl; + $c = shift @$rcl; + if (not defined $c) { + return finish_token(\%t, tag=> 'BAD', val=> $val); + } + $val .= $c; + $c = lc($c); + if ($c eq 'c') { + return finish_token(\%t, tag=> 'OP', typ=> 'u', val=> $val); + + } elsif ($c eq 'b') { + my $nval = 0; + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[0-9]/); + my $cc = shift @$rcl; + $nval = ($nval<<1) + int($cc); + add_err($rl, 'N') unless $cc =~ m/[0-1]/; + add_err($rl, 'T') unless $nval <= 0177777; + $nval &= 0177777; + $val .= $cc; + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=> $nval); + + } elsif ($c eq 'o') { + my $nval = 0; + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[0-9]/); + my $cc = shift @$rcl; + $nval = ($nval<<3) + int($cc); + add_err($rl, 'N') unless $cc =~ m/[0-7]/; + add_err($rl, 'T') unless $nval <= 0177777; + $nval &= 0177777; + $val .= $cc; + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=> $nval); + + } elsif ($c eq 'd') { + my $nval = 0; + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[0-9]/); + my $cc = shift @$rcl; + $nval = 10*$nval + int($cc); + add_err($rl, 'T') unless $nval <= 0177777; + $nval &= 0177777; + $val .= $cc; + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=> $nval); + + } elsif ($c eq 'x') { + my $nval = 0; + while (scalar(@$rcl)) { + last if ($$rcl[0] !~ m/[0-9a-fA-F]/); + my $cc = shift @$rcl; + $nval = ($nval<<4) + hex($cc); + add_err($rl, 'T') unless $nval <= 0177777; + $nval &= 0177777; + $val .= $cc; + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=> $nval); + + } elsif ($c eq 'r') { + my $nval = 0; + for (my $i=0; $i<3; $i++) { + last unless defined $$rcl[0]; + last unless $$rcl[0] =~ m/^[0-9a-zA-Z\.\$\ ]$/; + $nval = 050 * $nval + to_rad50($$rcl[0]); + $val .= shift @$rcl; + } + return finish_token(\%t, tag=> 'NUM', val=> $val, nval=>$nval); + + } else { + return finish_token(\%t, tag=> 'BAD', val=> $val); + } + } + + # delimiters + if ($c =~ m|^[\(\)\,\<\>]$|) { + return finish_token(\%t, tag=> 'DEL', val=> shift @$rcl); + } + + # can't handle stuff + $val = join('',@$rcl); + @$rcl = (); + return finish_token(\%t, tag=> 'BAD', val=> $val); +} + +#------------------------------------------------------------------------------- + +sub to_rad50 { + my ($c) = @_; + return undef unless defined $c; + $c = lc($c); + return 0 if $c eq ' '; + return 001 + ord($c)-ord('a') if $c =~ m/^[a-z]$/; + return 033 if $c eq '$'; + return 034 if $c eq '.'; + return 036 + ord($c)-ord('0') if $c =~ m/^[0-9]$/; + return undef; +} + +#------------------------------------------------------------------------------- + +sub pass2 { + + my $fh; + if ($lst_do) { + if ($lst_fname eq "-") { + $fh = *STDOUT; + } else { + $fh = new FileHandle; + unless (open($fh, ">", $lst_fname)) { + print STDERR "asm-11-F: '$lst_fname' not writable, quiting..\n"; + exit 1; + } + } + } + + pass2_lst_beg($fh) if $lst_do; + + foreach my $rl (@src) { + + $$rl{dot} = getdot(); + $llbl_scope = $$rl{lscope} if defined $$rl{lscope}; + + # handle label definitions + if (defined $$rl{label}) { + if (lst_checkmdef($$rl{label})) { + add_err($rl, 'M'); + } else { + my $val = getsym($rl, $$rl{label}, 1); + if (! defined $val || $val != getdot()) { + add_err($rl, 'P'); + } + } + } + + # generate output data + pass2_out($rl); + # listing requested + pass2_lst_line($rl, $fh) if $lst_do; + # pass 2 dump requested + dump_rl($rl) if $opts{tpass2}; + + } + + pass2_lst_end($fh) if $lst_do; + + return; +} + +#------------------------------------------------------------------------------- + +sub pass2_out { + my ($rl) = @_; + + # quit without code generation for 'questionable syntax' lines + return if $$rl{err} =~ m/[IQ]/; + + # return if no pass2 action (typ not defined) + return unless defined $$rl{typ}; + + # generate code + if ($$rl{typ} eq 'code') { + walign($rl); + my $opcode = $$rl{opcode}; + my $opfmt = $$rl{opfmt}; + + # printf "+++1 $$rl{typ},$$rl{oper},%s,%s\n", + # savestr($opcode), savestr($opfmt); + + if ($opfmt eq '-') { + out_opcode($rl, $opcode); + + } elsif ($opfmt eq 'g') { + out_opcode($rl, $opcode | $$rl{o1mod}<<3 | $$rl{o1reg}); + out_opdata($rl, $$rl{o1mod}, $$rl{o1reg}, + $$rl{o1ebeg}, $$rl{o1eend}); + + } elsif ($opfmt eq 'gg') { + out_opcode($rl, $opcode | $$rl{o1mod}<<9 | $$rl{o1reg}<<6 | + $$rl{o2mod}<<3 | $$rl{o2reg}); + out_opdata($rl, $$rl{o1mod}, $$rl{o1reg}, + $$rl{o1ebeg}, $$rl{o1eend}); + out_opdata($rl, $$rl{o2mod}, $$rl{o2reg}, + $$rl{o2ebeg}, $$rl{o2eend}); + } elsif ($opfmt eq 'r') { + out_opcode($rl, $opcode | $$rl{o1reg}); + } elsif ($opfmt eq 'rg' || $opfmt eq 'gr') { + out_opcode($rl, $opcode | $$rl{o1reg}<<6 | + $$rl{o2mod}<<3 | $$rl{o2reg}); + out_opdata($rl, $$rl{o2mod}, $$rl{o2reg}, + $$rl{o2ebeg}, $$rl{o2eend}); + } elsif ($opfmt eq 'n3') { + out_opcode_n($rl, $opcode, 07, $$rl{ebeg}, $$rl{eend}); + } elsif ($opfmt eq 'n6') { + out_opcode_n($rl, $opcode, 077, $$rl{ebeg}, $$rl{eend}); + } elsif ($opfmt eq 'n8') { + out_opcode_n($rl, $opcode, 0377, $$rl{ebeg}, $$rl{eend}); + } elsif ($opfmt eq 's8') { + out_opcode_o($rl, $opcode, 's8', $$rl{ebeg}, $$rl{eend}); + } elsif ($opfmt eq 'ru6') { + out_opcode_o($rl, $opcode|($$rl{o1reg}<<6), 'u6', + $$rl{ebeg}, $$rl{eend}); + } else { + die "BUGCHECK: unknown opfmt '$opfmt'"; + } + + # generate data + } elsif ($$rl{typ} eq 'data') { + if ($$rl{oper} eq '.word' || $$rl{oper} eq '.byte' ) { + walign($rl) if $$rl{oper} eq '.word'; + my $size = ($$rl{oper} eq '.word') ? 2 : 1; + my $mask = ($size == 2) ? 0177777 : 0377; + foreach (@{$$rl{delist}}) { + my $ibeg = $$_{ibeg}; + my $iend = $$_{iend}; + my $val = 0; + if (defined $ibeg) { + $val = eval_exp($rl, $ibeg, $iend); + if (not defined $val) { + $val = 0; + add_err($rl, 'U'); + } + } + # FIXME_code: handle T error here !! + $val &= $mask; + if ($$rl{oper} eq '.word') { + out_w($rl, $val); + } else { + out_b($rl, $val); + } + } + + } elsif ($$rl{oper} eq '.blkw' || $$rl{oper} eq '.blkb' ) { + walign($rl) if $$rl{oper} eq '.blkw'; + incdot($$rl{incdot}); + + } elsif ($$rl{oper} eq '.ascii' || $$rl{oper} eq '.asciz' ) { + foreach my $rd (@{$$rl{delist}}) { + if (defined $$rd{str}) { + my @chr = split '',$$rd{str}; + shift @chr; + pop @chr; + foreach (@chr) { + push @{$$rl{outb}}, ord($_); + } + } else { + my $val = eval_exp($rl, $$rd{ibeg}, $$rd{iend}); + if (not defined $val) { + $val = 0; + add_err($rl, 'U'); + } + if ($val < 0 || $val > 0377) { + $val &= 0377; + add_err($rl, 'T'); + } + push @{$$rl{outb}}, $val; + } + } + push @{$$rl{outb}}, 0 if $$rl{oper} eq '.asciz'; + incdot(scalar(@{$$rl{outb}})); + + } elsif ($$rl{oper} eq '.even' || $$rl{oper} eq '.odd' ) { + if ($$rl{incdot}) { + push @{$$rl{outb}}, 0; + incdot(1); + } + + } else { + die "BUGCHECK: unknown data oper '$$rl{oper}'"; + } + + # handle assignments + } elsif ($$rl{typ} eq 'ass') { + my $val = eval_exp($rl, $$rl{ebeg}, $$rl{eend}); + if (defined $val) { + $$rl{lstval} = $val; + setsym($rl, $$rl{atyp}, $$rl{asym}, $val); + } else { + $$rl{lstval} = 0; + add_err($rl, 'U'); + } + + } else { + die "BUGCHECK: unknown line typ '$$rl{typ}'"; + } + + if (scalar(@{$$rl{outw}})) { + emitw($$rl{dot}, $$rl{outw}); + } elsif (scalar(@{$$rl{outb}})) { + emitb($$rl{dot}, $$rl{outb}); + } + + return; +} + +#------------------------------------------------------------------------------- + +sub pass2_lst_beg { + my ($fh) = @_; + printf $fh "; Input file list:\n"; + my $fileno = 1; + foreach my $fname (@flist) { + $fname =~ s/^$ENV{RETROBASE}/\$RETROBASE/; + printf $fh "; %2d: %s\n", $fileno, $fname; + $fileno += 1; + } + print $fh ";\n"; + return; +} + +#------------------------------------------------------------------------------- + +sub pass2_lst_end { + my ($fh) = @_; + if ($errcnt_tot) { + print $fh ";\n"; + print $fh "; Error summary:\n"; + foreach my $err (sort keys %errcnt) { + printf $fh "; %s: %3d\n", $err, $errcnt{$err}; + } + } + return; +} + +#------------------------------------------------------------------------------- +# line format is +# er fn lnum dot source +# .. dd dddd oooooo oooooo oooooo oooooo +# .. ooo ooo ooo ooo ooo + +sub pass2_lst_line { + my ($rl,$fh) = @_; + + my @ow = @{$$rl{outw}}; + my @ob = @{$$rl{outb}}; + my $str = ''; + $str .= sprintf("%-2s", prt_err($rl)); + $str .= sprintf(" %2d", $$rl{fileno}); + $str .= sprintf(" %4d", $$rl{lineno}); + + # print dot if data is generated for this line, or label + my $prtdot = defined $$rl{lstdot} || + scalar(@{$$rl{outw}}) || + scalar(@{$$rl{outb}}) || + $$rl{label}; + if ($prtdot) { + $str .= prt76o($$rl{dot}); + } else { + $str .= ' '; + } + + if (defined $$rl{lstval}) { + $str .= prt76o($$rl{lstval}); + $str .= ' ' x 14; + } elsif (scalar(@ow)) { + for (my $i=0; $i<3; $i++) { $str .= prt76o(shift @ow); } + } elsif (scalar(@ob)) { + for (my $i=0; $i<5; $i++) { $str .= prt43o(shift @ob); } + $str .= ' '; + } else { + $str .= ' ' x 21; + } + + $str .= ' ' . $$rl{line} . "\n"; + print $fh $str; + if (1) { + while (scalar(@ow)) { + $str = ' '; + for (my $i=0; $i<3; $i++) { $str .= prt76o(shift @ow); } + print $fh $str . "\n"; + } + while (scalar(@ob)) { + $str = ' '; + for (my $i=0; $i<5; $i++) { $str .= prt43o(shift @ob); } + print $fh $str . "\n"; + } + } + return; +} + +#------------------------------------------------------------------------------- + +sub out_w { + my ($rl,$word) = @_; + push @{$$rl{outw}}, $word; + incdot(2); + return; +} + +#------------------------------------------------------------------------------- + +sub out_b { + my ($rl,$byte) = @_; + push @{$$rl{outb}}, $byte; + incdot(1); + return; +} + +#------------------------------------------------------------------------------- + +sub out_opcode { + my ($rl,$code) = @_; + out_w($rl, $code); + return; +} + +#------------------------------------------------------------------------------- + +sub out_opcode_n { + my ($rl,$code,$mask,$ebeg,$eend) = @_; + # FIXME_code: shouldn't we die here ? + return unless defined $ebeg; + + my $val = eval_exp($rl,$ebeg,$eend); + unless (defined $val) { + $val = 0; + add_err($rl, 'A'); + } + if ($val & ~$mask) { + $val &= $mask; + add_err($rl, 'T'); + } + out_w($rl, $code|$val); + return; +} + +#------------------------------------------------------------------------------- + +sub out_opcode_o { + my ($rl,$code,$typ,$ebeg,$eend) = @_; + # FIXME_code: shouldn't we die here ? + return unless defined $ebeg; + + my $val = eval_exp($rl,$ebeg,$eend); + my $off; + if (defined $val) { + $off = ($val - (getdot()+2)) / 2; + } else { + $off = -1; + add_err($rl, 'U'); + } + + if ($typ eq 's8') { + if ($off > 127 || $off < -128) { + add_err($rl, 'A'); + } + $off &= 0377; + } else { + $off = -$off; + if ($off > 63 || $off < 0) { + add_err($rl, 'A'); + } + $off &= 0077; + } + out_w($rl, $code|$off); + return; +} + +#------------------------------------------------------------------------------- + +sub out_opdata { + my ($rl,$mod,$reg,$ebeg,$eend) = @_; + # FIXME_code: shouldn't we die here ? + return unless defined $ebeg; + + my $val = eval_exp($rl,$ebeg,$eend); + unless (defined $val) { + out_w($rl, 0); + add_err($rl, 'U'); + return; + } + if ($mod>=6 && $reg==7) { + $val = ($val - (getdot()+2)) & 0177777; + } + out_w($rl, $val); + return; +} + +#------------------------------------------------------------------------------- + +sub emitw { + my ($baddr,$rwl) = @_; + if ($opts{temit}) { + printf "-- emit: w %6.6o:", $baddr; + foreach my $w (@$rwl) { printf " %6.6o", $w; } + print "\n"; + } + return unless scalar(@$rwl); + + if ((! defined $out_dot) || $out_dot!=$baddr || $out_data[-1]->{typ} ne 'w') { + push @out_data, {typ=> 'w', addr=>$baddr, data=>[@$rwl]}; + } else { + my $rdata = $out_data[-1]->{data}; + push @$rdata, @$rwl; + } + $out_dot = $baddr+2; + return; +} + +#------------------------------------------------------------------------------- + +sub emitb { + my ($baddr,$rbl) = @_; + if ($opts{temit}) { + printf "-- emit: b %6.6o:", $baddr; + foreach my $b (@$rbl) { printf " %3.3o", $b; } + print "\n"; + } + return unless scalar(@$rbl); + + if ((! defined $out_dot) || $out_dot!=$baddr || $out_data[-1]->{typ} ne 'b') { + push @out_data, {typ=> 'b', addr=>$baddr, data=>[@$rbl]}; + } else { + my $rdata = $out_data[-1]->{data}; + push @$rdata, @$rbl; + } + $out_dot = $baddr+1; + return; +} + +#------------------------------------------------------------------------------- + +sub write_lda_frame { + my ($fh,$addr,$rblist) = @_; + my $len = 6 + scalar(@$rblist); + my @f; + push @f, 0x01; + push @f, 0x00; + push @f, $len & 0xff; + push @f, ($len>>8) & 0xff; + push @f, $addr & 0xff; + push @f, ($addr>>8) & 0xff; + push @f, @$rblist if $len; + my $csum = 0; + foreach (@f) { $csum = ($csum + $_) & 0xff; } + push @f, (-$csum) & 0xff; + + if ($opts{tout}) { + my $nval = 0; + printf "-- out: %6.6o:", $addr; + foreach (@f) { + if ($nval == 16) { + printf "\n "; + $nval = 0; + } + printf " %3.3o", $_; + $nval += 1; + } + printf "\n"; + } + + my $buf = pack("C*", @f); + my $rc = syswrite($fh, $buf, length($buf)); + return; +} + +#------------------------------------------------------------------------------- + +sub write_lda { + my ($fname) = @_; + my $fh; + if ($fname eq "-") { + $fh = *STDOUT; + } else { + $fh = new FileHandle; + unless (open($fh, ">:raw", $fname)) { + print STDERR "asm-11-F: '$fname' not writable, quiting..\n"; + exit 1; + } + } + + my @blist; + my $base; + my $dot; + foreach my $rl (@src) { + die "BUGCHECK: both outb and outw contain data" + if scalar(@{$$rl{outb}}) && scalar(@{$$rl{outw}}); + + my @byt = @{$$rl{outb}}; + foreach (@{$$rl{outw}}) { + push @byt, $_ & 0xff; + push @byt, ($_>>8) & 0xff; + } + + next unless scalar(@byt); + + # flush frame if new data not adjacent to old + if (scalar(@blist) && $dot!=$$rl{dot}) { + write_lda_frame($fh, $base, \@blist); + @blist = (); + $base = undef; + $dot = undef; + } + + $dot = $base = $$rl{dot} unless defined $base; + + foreach (@byt) { + if (scalar(@blist) >= 2*168) { + write_lda_frame($fh, $base, \@blist); + @blist = (); + $base = $dot; + } + push @blist, $_ & 0xff; + $dot += 1; + } + + } + + # flush buffer + write_lda_frame($fh, $base, \@blist) if scalar(@blist); + @blist = (); + + # write terminating frame + write_lda_frame($fh, $out_start, \@blist); + + return; +} + +#------------------------------------------------------------------------------- + +sub write_cof_frame { + my ($fh,$typ,$addr,$rlist) = @_; + my $fmt = ($typ eq 'w') ? '%6.6o' : '%3.3o'; + my $max = ($typ eq 'w') ? 10 : 20 ; + + printf $fh "$typ %6.6o {\n", $addr; + my $i = 0; + foreach (@$rlist) { + $i += 1; + printf $fh "$fmt ", $_; + print $fh "\n" if $i%$max == 0; + } + print $fh "\n" unless $i%$max == 0; + print $fh "}\n"; + return; +} + +#------------------------------------------------------------------------------- + +sub write_cof { + my ($fname) = @_; + my $fh; + if ($fname eq "-") { + $fh = *STDOUT; + } else { + $fh = new FileHandle; + unless (open($fh, ">:raw", $fname)) { + print STDERR "asm-11-F: '$fname' not writable, quiting..\n"; + exit 1; + } + } + + print $fh "sym {\n"; + foreach my $key (sort keys %lst) { + next unless $lst{$key}{typ} =~ m/^(lbl|llbl)$/; + printf $fh "%s => %s\n", $lst{$key}{name}, save66o($lst{$key}{val}); + } + print $fh "}\n"; + print $fh "dat {\n"; + + my @list; + my $typ; + my $base; + my $dot; + + foreach my $rl (@src) { + + if (scalar(@{$$rl{outb}})) { + if (scalar(@list) && ($typ ne 'b' || $dot != $$rl{dot})) { + write_cof_frame($fh, $typ, $base, \@list); + @list = (); + } + unless (scalar(@list)) { + $typ = 'b'; + $base = $dot = $$rl{dot}; + } + push @list, @{$$rl{outb}}; + $dot += scalar(@{$$rl{outb}}); + } + + if (scalar(@{$$rl{outw}})) { + if (scalar(@list) && ($typ ne 'w' || $dot != $$rl{dot})) { + write_cof_frame($fh, $typ, $base, \@list); + @list = (); + } + unless (scalar(@list)) { + $typ = 'w'; + $base = $dot = $$rl{dot}; + } + push @list, @{$$rl{outw}}; + $dot += 2 * scalar(@{$$rl{outw}}); + } + } + + write_cof_frame($fh, $typ, $base, \@list) + if scalar(@list); + + print $fh "}\n"; + + return; +} + +#------------------------------------------------------------------------------- + +sub write_lsm { + my ($fname) = @_; + my $fh; + if ($fname eq "-") { + $fh = *STDOUT; + } else { + $fh = new FileHandle; + unless (open($fh, ">:raw", $fname)) { + print STDERR "asm-11-F: '$fname' not writable, quiting..\n"; + exit 1; + } + } + + my %mem; + + foreach my $rl (@src) { + + my $dot = $$rl{dot}; + if (scalar(@{$$rl{outb}})) { + foreach my $byte (@{$$rl{outb}}) { + my $addr = sprintf "%6.6o", $dot & 0xfffe; + $mem{$addr} = 0 unless exists $mem{$addr}; + if ($dot & 0x1) { # odd byte + $mem{$addr} = (($byte&0xff)<<8) | ($mem{$addr} & 0xff); + } else { # even byte + $mem{$addr} = ($mem{$addr} & 0xff00) | ($byte&0xff); + } + $dot += 1; + } + } + + if (scalar(@{$$rl{outw}})) { + foreach my $word (@{$$rl{outw}}) { + my $addr = sprintf "%6.6o", $dot; + $mem{$addr} = $word; + $dot += 2; + } + } + } + + foreach my $addr (sort keys %mem) { + printf $fh "%s : %6.6o\n", $addr, $mem{$addr}; + } + + return; +} + +#------------------------------------------------------------------------------- + +sub dump_rl { + my ($rl) = @_; + + printf "-- line: '%s'\n", $$rl{line}; + printf " err=%-3s, typ=%-4s, oper=%-6s, lineno=%3d, psect=%-6s, .=%6.6o\n", + prt_err($rl), savestr($$rl{typ}), savestr($$rl{oper}), $$rl{lineno}, + $$rl{psect}, $$rl{dot}; + my $i = 0; + foreach my $rt (@{$$rl{tl}}) { + printf " tl[%2d]: tag=%-4s, om=%-2s, em=%-2s, val='%s'", + $i, $$rt{tag}, savestr1($$rt{om}), savestr1($$rt{em}), + savestr($$rt{val}); + printf ", nval=%6.6o",$$rt{nval} if defined $$rt{nval}; + printf ", pend=%d",$$rt{pend} if defined $$rt{pend}; + printf "\n"; + $i += 1; + } + if (defined $$rl{delist}) { + $i = 0; + my $rdl = $$rl{delist}; + foreach my $rd (@$rdl) { + printf " dl[%2d]:", $i; + printf " str='%s'",$$rd{str} if defined $$rd{str}; + printf " ibeg=%s, iend=%s", savestr($$rd{ibeg}), savestr($$rd{iend}) + if exists $$rd{ibeg}; + printf "\n"; + $i += 1; + } + } + if (defined $$rl{opcode}) { + printf " code: %6.6o,fmt=%-2s", $$rl{opcode}, $$rl{opfmt}; + if (defined $$rl{o1mod}) { + printf ", o1=%s%s", $$rl{o1mod},$$rl{o1reg}; + printf ",ei=%d:%d,val=%s", $$rl{o1ebeg}, $$rl{o1eend}, + save66o(eval_exp($rl, $$rl{o1ebeg}, $$rl{o1eend})) + if defined $$rl{o1ebeg}; + } + if (defined $$rl{o2mod}) { + printf ", o2=%s%s", $$rl{o2mod},$$rl{o2reg}; + printf ",ei=%d:%d,val=%s", $$rl{o2ebeg}, $$rl{o2eend}, + save66o(eval_exp($rl, $$rl{o2ebeg}, $$rl{o2eend})) + if defined $$rl{o2ebeg}; + } + printf " ex=%d:%d,val=%s", $$rl{ebeg}, $$rl{eend}, + save66o(eval_exp($rl, $$rl{ebeg}, $$rl{eend})) + if defined $$rl{ebeg}; + print "\n"; + } + if (scalar(@{$$rl{outw}})) { + print " outw:"; + foreach (@{$$rl{outw}}) { printf " %6.6o", $_; } + print "\n"; + } + if (scalar(@{$$rl{outb}})) { + print " outb:"; + foreach (@{$$rl{outb}}) { printf " %3.3o", $_; } + print "\n"; + } + foreach my $key (sort keys %{$rl}) { + next if $key =~ m/^(line|err|typ|oper|lineno|psect|dot|opcode|opfmt|o[12](mod|reg|ebeg|eend)|ebeg|eend|tl|delist|outw|outb)$/; + printf " %-6s: %s\n", $key, savestr($$rl{$key}); + } + return; +} + +#------------------------------------------------------------------------------- + +sub dump_sym { + print "\n"; + print " psect dot dotmax\n"; + print "------ ------ ------\n"; + foreach my $ps (sort keys %psect) { + printf "%-6s %6.6o %6.6o\n", $ps, $psect{$ps}{dot}, $psect{$ps}{dotmax}; + } + + print "\n"; + print "scope symbol typ psect val\n"; + print "------ ------ ---- ------ ------\n"; + foreach my $key (sort keys %lst) { + my $sym = $lst{$key}{name}; + my $scope = ''; + my $name = $sym; + if ($sym =~ m/^(.+):(.+)$/) { + $scope = $1; + $name = $2; + } + printf "%-6s %-6s %-4s %-6s %s\n", $scope, $name, $lst{$key}{typ}, + $lst{$key}{psect}, save66o($lst{$key}{val}); + } + + return; +} + +#------------------------------------------------------------------------------- + +sub prt76o { + my ($val) = @_; + return ' ' unless defined $val; + return sprintf " %6.6o", $val; +} + +#------------------------------------------------------------------------------- + +sub prt43o { + my ($val) = @_; + return ' ' unless defined $val; + return sprintf " %3.3o", $val; +} + +#------------------------------------------------------------------------------- + +sub save66o { + my ($val) = @_; + return '' unless defined $val; + return sprintf "%6.6o", $val; +} + +#------------------------------------------------------------------------------- + +sub savestr { + my ($str) = @_; + return '' unless defined $str; + return $str; +} + +#------------------------------------------------------------------------------- + +sub savestr1 { + my ($str) = @_; + return '-' unless defined $str; + return $str; +} + +#------------------------------------------------------------------------------- + +sub print_help { + print "usage: asm-11 \n"; + print " --I path adds path to the .include search path\n"; + print " --lst create listing (default file name)\n"; + print " --olst=fnam create listing (concrete file name)\n"; + print " --lda create absolute loader output (default file name)\n"; + print " --olda create absolute loader output (concrete file name)\n"; + print " --cof create compound output (default file name)\n"; + print " --ocof=fnam create compound output (concrete file name)\n"; + print " --tpass1 trace line context in pass 1\n"; + print " --tpass2 trace line context in pass 2\n"; + print " --dsym1 dump psect and ust tables after pass 1\n"; + print " --dsym2 dump psect and ust tables after pass 2\n"; + print " --ttoken trace tokenizer\n"; + print " --tparse trace parser\n"; + print " --temit trace code emit\n"; + print " --tout trace output file write\n"; + print " --help print this text and exit\n"; + return; +} diff --git a/tools/bin/asm-11_expect b/tools/bin/asm-11_expect new file mode 100755 index 00000000..d735d4fb --- /dev/null +++ b/tools/bin/asm-11_expect @@ -0,0 +1,298 @@ +#!/usr/bin/perl -w +# $Id: asm-11_expect 501 2013-03-30 13:53:39Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# +# This program is free software; you may redistribute 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 complete details. +# +# Revision History: +# Date Rev Version Comment +# 2013-03-29 500 1.0 Initial version +# 2013-03-24 499 0.1 First draft +# + +use 5.10.0; # require Perl 5.10 or higher +use strict; # require strict checking +use FileHandle; + +use Getopt::Long; + +my %opts = (); + +GetOptions(\%opts, "help", + "tline", "tcheck" + ) + or exit 1; + +sub do_help; +sub print_help; + +my $errcnt; # total error count + +autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe + +if (exists $opts{help}) { + print_help; + exit 0; +} + +if (scalar(@ARGV) == 0) { + print STDERR "asm-11_expect-F: no input files specified, quiting..\n"; + print_help; + exit 1; +} + +foreach my $fname (@ARGV) { + do_file($fname); +} + +exit 1 if $errcnt > 0; +exit 0; + +#------------------------------------------------------------------------------- +# +#; Input file list: +# 1 6 ; comment +# 1 17 000000 zero: +# 1 23 002000 000101 w0: .word 101 +# 1 17 001011 377 .byte ^c0 +# 1 70 001206 046374 001234 001234 bic 1234(r3),@1234(r4) +# 1 24 001036 067527 066162 020544 .word "Wo,"rl,"d!,0 +# 000000 +#EEfnolinno dot... word1. word2. word2. +# +# 1 2 3 +#0123456789012345678901234567890123456789 +# + +sub do_file { + my ($fname) = @_; + my $fh; + if ($fname eq "-") { + $fh = *STDIN; + } else { + if (not -r $fname) { + print STDERR "asm-11_expect-F: '$fname' not found or readable. EXIT\n"; + exit 1; + } + $fh = new FileHandle; + $fh->open($fname) or die "failed to open '$fname'"; + } + + my @errmsg; # error message list + my $echeck = 0; + my $c_string; + my $c_pend; + + while (<$fh>) { + chomp; + next if m/^;/; + + print "$_\n" if $opts{tline}; + + my $line = $_; + my $rest = $_; + my $err; + if (substr($rest,2,1) =~ m/^[A-Z]$/) { + $rest =~ m/^([A-Z]+)$/; + $err = $1; + $rest = $'; + } else { + $err = substr($rest,0,2); + $err =~ s/\s//g; + $rest = substr($rest,2); + } + + my $fileno; + my $lineno; + + if (substr($rest,0,8) =~ m/^\s+(\d+)\s+(\d+)$/) { + $fileno = int($1); + $lineno = int($2); + $rest = substr($rest,8); + } else { + next; + } + + my $dot; + if (substr($rest,0,7) eq ' ') { + $rest = substr($rest,7); + } elsif (substr($rest,0,7) =~ m/^\s([0-7]{6})/) { + $dot = oct($1); + $rest = substr($rest,7); + } else { + next; + } + + my @dat; + my $isbyte; + + # words ? + if ($rest =~ m/^(\s([0-7]{6})){1,3}/) { + for (my $i=0; $i<3; $i++) { + last unless substr($rest,1,6) =~ m/[0-7]{6}/; + push @dat, oct(substr($rest,1,6)); + $rest = substr($rest,7); + } + # bytes ? + } elsif ($rest =~ m/^(\s([0-7]{3})){1,5}/) { + for (my $i=0; $i<5; $i++) { + last unless substr($rest,1,3) =~ m/[0-7]{3}/; + $isbyte = 1; + push @dat, oct(substr($rest,1,3)); + $rest = substr($rest,4); + } + $rest = substr($rest,1); + } + + # look for expect condition (unless one is pending) + if ($c_pend) { + $c_pend = undef; + } else { + if ($rest =~ m/;;!!(.*)$/) { + $c_string = $1; + if ($rest =~ m/^\s*;;!!/) { + $c_pend = 1; + next; + } + } + } + + # no expect condition defined: look for unexpected etags + unless (defined $c_string) { + if ($err ne '') { + push @errmsg, + {msg => sprintf("unexpected error '%s'", $err), + line => $line}; + } + next; + } + + # expect condition defined: parse it + my $c_err; + my $c_dot; + my @c_dat; + + my $c_rest = $c_string; + if ($c_rest =~ m/^\s*([A-Z]+)/) { + $c_err = $1; + $c_rest = $'; + } + if ($c_rest =~ m/^\s*([0-7]{6}:)/) { + $c_dot = oct($1); + $c_rest = $'; + } + while (length($c_rest)) { + last unless $c_rest =~ m/^\s*([0-7]+)/; + push @c_dat, oct($1); + $c_rest = $'; + } + + unless ($c_rest =~ m/^\s*$/) { + push @errmsg, + {msg => sprintf("can't parse expect, rest='%s'", $c_rest), + line => ';;!! ' . $c_string}; + $c_string = undef; + next; + } + + if ($opts{tcheck}) { + print "exp: "; + printf " err=%s", $c_err if defined $c_err; + printf " dot=%6.6o", $c_dot if defined $c_dot; + if (scalar(@c_dat)) { + print " dat="; + foreach (@c_dat) { + printf "%6.6o ", $_; + } + } + print "\n"; + } + + if (defined $c_err) { + if ($c_err ne $err) { + push @errmsg, + {msg => sprintf("error mismatch: found='%s', expect='%s'", + $err, $c_err), + line => $line}; + } + } + + if (defined $c_dot) { + if (defined $dot) { + if ($c_dot != $dot) { + push @errmsg, + {msg => sprintf(". mismatch: found=%6.6o, expect=%6.6o", + $dot, $c_dot), + line => $line}; + } + } else { + push @errmsg, + {msg => sprintf(". check miss: nothing found, expect=%6.6o", + $c_dot), + line => $line}; + } + } + + if (scalar(@c_dat)) { + my $nc = scalar(@c_dat); + $nc = scalar(@dat) if $nc < scalar(@dat); + for (my $i=0; $i<$nc; $i++) { + if (defined $c_dat[$i] && defined $dat[$i]) { + if ($c_dat[$i] != $dat[$i]) { + push @errmsg, + {msg => sprintf("data %d mismatch: found=%6.6o, expect=%6.6o", + $i, $dat[$i], $c_dat[$i]), + line => $line}; + } + } elsif (defined $c_dat[$i] && ! defined $dat[$i]) { + push @errmsg, + {msg => sprintf("data %d mismatch: nothing found, expected=%6.6o", + $i, $c_dat[$i]), + line => $line}; + } elsif (! defined $c_dat[$i] && defined $dat[$i]) { + push @errmsg, + {msg => sprintf("data %d mismatch: found=%6.6o, nothing expected", + $i, $dat[$i]), + line => $line}; + } + } + } + + # trace expects + if ($opts{tcheck} && $echeck != scalar(@errmsg)) { + $echeck = scalar(@errmsg); + printf "FAIL: %s\n", $errmsg[-1]{msg}; + } + + # invalidate expect condition + $c_string = undef; + } + + # done with file + my $verdict = scalar(@errmsg) ? 'FAILED' : 'OK'; + printf "asm-11_expect: %s %s\n", $fname, $verdict; + foreach (@errmsg) { + printf " FAIL: %s\n in: %s\n", $$_{msg}, $$_{line}; + } + + $errcnt += scalar(@errmsg); + + return; +} + +#------------------------------------------------------------------------------- + +sub print_help { + print "usage: asm-11_expect \n"; + print " --tline trace input lines\n"; + print " --tcheck trace expect checks\n"; + return; +} diff --git a/tools/bin/pi_rri b/tools/bin/pi_rri index 6304a94d..034dd478 100755 --- a/tools/bin/pi_rri +++ b/tools/bin/pi_rri @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: pi_rri 440 2011-12-18 20:08:09Z mueller $ +# $Id: pi_rri 499 2013-03-24 20:26:18Z mueller $ # # Copyright 2007-2011 by Walter F.J. Mueller # @@ -944,7 +944,7 @@ my $serv11_init_anena = 0x8000; # enable attn # -> {inithdl} address of controler init handler # -> {usethdl} address of unit setup handler # -> {attdethdl} address of attach/detach handler -# -> {attnhdl} address og attention handler +# -> {attnhdl} address of attention handler # -> {reglist} register list (array of regdsc's) # -> {regtbl} register table (by name, created by ...) # -> {partbl} parameter table (array of pardsc's) @@ -2765,9 +2765,9 @@ sub pdpcp_cexec { } $cmd =~ s/^rsp/rr6/; # rsp -> rr6 - $cmd =~ s/^rpc/rr7/; # rsp -> rr7 + $cmd =~ s/^rpc/rr7/; # rpc -> rr7 $cmd =~ s/^wsp/wr6/; # wsp -> wr6 - $cmd =~ s/^wpc/wr7/; # wsp -> wr7 + $cmd =~ s/^wpc/wr7/; # wpc -> wr7 $cmd_line = $cmd; $cmd_rest = ""; @@ -2825,7 +2825,7 @@ sub pdpcp_cexec { my $delay = int $1; rri_cmdlist_do(); # flush before waiting for (my $i = 0; $i < $delay; $i++) { - raw_snd9(D9IDLE); + raw_snd9(D9IDLE); } } elsif ($cmd =~ /^\.cclst/) { # .cclst ------------------------ @@ -3561,6 +3561,10 @@ sub serv11_cexec_ldabs { return if $rc != 1; my $byt = ord($buf); + + #printf "+++1 cn=%3d byt=%3.3o cnt=%4d addr=%6.6o sum=%3.3o\n", + # $chrnum, $byt&0377, $bytcnt, $ldaddr, $chksum; + $chksum = ($chksum + $byt) & 0377; if ($chrnum == 0) { # in blank tape diff --git a/tools/bin/ti_rri b/tools/bin/ti_rri index c4011a43..9f0fd309 100755 --- a/tools/bin/ti_rri +++ b/tools/bin/ti_rri @@ -1,6 +1,6 @@ #! /usr/bin/env tclsh # -*- tcl -*- -# $Id: ti_rri 467 2013-01-02 19:49:05Z mueller $ +# $Id: ti_rri 504 2013-04-13 15:37:24Z mueller $ # # Copyright 2011-2013 by Walter F.J. Mueller # @@ -15,6 +15,9 @@ # # Revision History: # Date Rev Version Comment +# 2013-04-12 504 1.1.4 add --pack; trailing '-' argv implies --int +# 2013-02-05 482 1.1.3 stop server is rls found +# 2013-01-27 478 1.1.2 use 'exec sh -c $cmd &' for --run implementation # 2013-01-02 467 1.1.1 call rlc close only when really open # 2012-12-27 465 1.1 add --cuff support # 2012-02-09 457 1.0.4 disable autoexec @@ -25,6 +28,7 @@ # 2011-03-19 371 0.1 First draft # # +# --pack=pname,... # --fifo[=name,opts,...] # --term[=name,baud,opts,...] # --cuff[=name,...] @@ -41,6 +45,7 @@ # array set opts { + pack_ "" fifo 0 fifo_ "" term 0 @@ -72,6 +77,9 @@ proc exit_cleanup {} { global opts global runpid + # check for rlink server, stop it + if { [info commands rls] eq "rls" } { rls server -stop } + # now close rlink connection if { $opts(fifo) || $opts(term) || $opts(cuff) } { if { [rlc open] ne "" } { rlc close } @@ -91,6 +99,7 @@ foreach arg $argv { continue } switch -regexp -- $arg { + ^--?pack=.+$ { regexp -- {=(.*)} $arg dummy opts(pack_) } ^--?fifo=?.*$ { set opts(fifo) 1; regexp -- {=(.*)} $arg dummy opts(fifo_) } ^--?term=?.*$ { set opts(term) 1; regexp -- {=(.*)} $arg dummy opts(term_) } ^--?cuff=?.*$ { set opts(cuff) 1; regexp -- {=(.*)} $arg dummy opts(cuff_) } @@ -109,11 +118,21 @@ foreach arg $argv { } } +# check whether last element in clist is plain '-' +if { [llength clist] } { + if { [lindex $clist end] eq "-" } { + set opts(int) 1 + set clist [lrange $clist 0 end-1] + } +} + if { $opts(help) } { # use {} as defimiter here to avoid that escaping of all [] puts {usage: ti_rri [OPTION]... [COMMAND]...} puts {} puts {Options:} + puts { --pack=PLIST load, with package require, additional packages} + puts { PLIST is comma separated list of package names} puts { --run=CMD exec's CMD as subprocess before the rlink port opened} puts { useful to start test benches, usually via 'tbw'} puts { --fifo[=ARGS] open fifo type rlink port. Optional arguments are:} @@ -173,6 +192,7 @@ if {![info exists env(RETROBASE)]} { return 1 } +# check consistency of connection open options set nopen 0; if { $opts(fifo) } { incr nopen } if { $opts(term) } { incr nopen } @@ -191,6 +211,15 @@ package require rutiltpp package require rlinktpp rlinkconnect rlc +rlinkserver rls rlc + +# load additional packages (if -pack given) +if { $opts(pack_) ne "" } { + foreach pack [split $opts(pack_) ","] { + package require $pack + } +} + # setup logging if { $opts(log_) ne "-" } { @@ -201,8 +230,11 @@ rlc config -logdumplevel $opts(dmpl_) rlc config -logtracelevel $opts(tiol_) # first start, if specified with --run, the test bench +# exec sh -c $cmd is used to execute a shell command including [], '',"" +# in a direct exec the tcl expansion logic will interfere... +# if { $opts(run_) ne "" } { - if { [catch {eval "exec $opts(run_) &" } runpid] } { + if { [catch {exec sh -c $opts(run_) &} runpid] } { puts "-E: failed to execute \"$opts(run_)\" with error message\n $runpid" puts "aborting..." return 1 diff --git a/tools/bin/ticonv_pdpcp b/tools/bin/ticonv_pdpcp new file mode 100755 index 00000000..511118f6 --- /dev/null +++ b/tools/bin/ticonv_pdpcp @@ -0,0 +1,208 @@ +#!/usr/bin/perl -w +# $Id: ticonv_pdpcp 504 2013-04-13 15:37:24Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# +# This program is free software; you may redistribute 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 complete details. +# +# Revision History: +# Date Rev Version Comment +# 2013-04-12 504 1.0.2 renamed from pi2ti_pdpcp; fix [rm]wi handling +# use wtcpu command; use wibrbbe command; +# 2013-02-05 483 1.0.1 make cpucmd parametrizable +# 2013-02-02 480 1.0 Initial version +# + +use 5.005; # require Perl 5.005 or higher +use strict; # require strict checking + +use Getopt::Long; + +my %opts = (); + +GetOptions(\%opts ) || exit 1; + +if (scalar(@ARGV) != 2) { + print STDERR "%ticonv_pdpcp-E: usage: ticonv_pdpcp \n"; + exit 1; +} + +my $cpu = $ARGV[0]; +my $fnam = $ARGV[1]; +open IFILE, $fnam or die "failed to open '$fnam'"; + +while () { + chomp; + s/--.*//; # drop all -- style comments + s/\s*$//; # drop traing blanks + next if m/^#/; + + # print "$_\n"; + + my $cmd = $_; + + $cmd =~ s/^rsp/rr6/; # rsp -> rr6 + $cmd =~ s/^rpc/rr7/; # rpc -> rr7 + $cmd =~ s/^wsp/wr6/; # wsp -> wr6 + $cmd =~ s/^wpc/wr7/; # wpc -> wr7 + + # C... comments -> write to rlc log -------------------------------- + if ($cmd =~ /^C(.*)/) { + my $msg = $1; + $msg =~ s/"/'/g; + $msg =~ s/\[/\{/g; + $msg =~ s/\]/\}/g; + print "rlc log \"C $msg\"\n"; + + # .tocmd,.tostp,.togo,.cerr,.merr -> ignore, like pi_rri ----------- + } elsif ($cmd =~ /^\.(tocmd|tostp|togo|[cm]err)\s+(\d*)/) { + print "# $cmd currently ignored\n"; + + # .mode mode -> accept only 'pdpcp', quit otherwise ---------------- + } elsif ($cmd =~ /^\.mode\s+(.*)/) { + if ($1 ne "pdpcp") { + print "# FAIL: $cmd not supported\n"; + exit 1; + } + + # .rlmon,.rbmon ---------------------------------------------------- + } elsif ($cmd =~ /^\.(r[lb]mon)\s+(\d)/) { + print "rlc oob -$1 $2\n"; + + # .scntl ----------------------------------------------------------- + } elsif ($cmd =~ /^\.scntl\s+(\d+)\s+(\d)/) { + print "rlc oob -sbcntl $1 $2\n"; + + # .anena (0|1) -> rlc exec -init ----------------------------------- + } elsif ($cmd =~ /^\.anena\s+(\d)/) { + my $dat = $1 ? '[regbld rlink::INIT anena]' : '0'; + print "rlc exec -init 0xff $dat\n"; + print "rlc exec -attn\n"; + + # .reset ----------------------------------------------------------- + } elsif ($cmd =~ /^\.reset/) { + print "rlc exec -init 0 1\n"; + + # (write) data type commands: wrx,wps,wal,wah,wm,wmi,stapc --- + # Note: 'stapc' must be decoeded before 'sta' !! + # Note: 'wibrb' must be handled separately + # Note: 'wmi' must be matched before 'wm' + } elsif ($cmd =~ /^(wr[0-7]|wps|wal|wah|wmi|wm|stapc)\s+([0-7]+)/) { + print "$cpu cp -$1 0$2\n"; + + # (write) data type commands: wibrb --- + } elsif ($cmd =~ /^(wibrb)\s+([0-7]+)/) { + my $base = oct($2); + my $be = $base & 0x3; + if ($be == 0) { + print "$cpu cp -wibrb 0$2\n"; + } else { + printf "$cpu cp -wibrbbe 0%6.6o %o\n", $base&0177700, $be; + } + + # (read) [d=data] type commands: rrx,rps,rm,rmi -------------------- + # Note: 'rmi' must be matched before 'rm' + } elsif ($cmd =~ /^(rr[0-7]|rps|rmi|rm)/) { + print "$cpu cp -$1 "; + add_edata($'); + print "\n"; + + # bwm n ------------------------------------------------------------ + } elsif ($cmd =~ /^bwm\s+(\d+)/) { + my $nw = $1; + print "$cpu cp -bwm {"; + for (my $i=0; $i<$nw;) { + my $dat = ; + $dat =~ s/--.*//; + $dat =~ s/\s*//g; + next if $dat =~ m/^#/; + print " 0$dat"; + $i++; + } + print "}\n"; + + # brm n ------------------------------------------------------------ + } elsif ($cmd =~ /^brm\s+(\d+)/) { + my $nw = $1; + print "$cpu cp -brm $1"; + my @data; + my @mask; + my $domask; + for (my $i=0; $i<$nw;) { + my $dat = ; + $dat =~ s/--.*//; + $dat =~ s/\s*//g; + next if $dat =~ m/^#/; + if ($dat =~ m/d=([0-7]+)/ ) { + push @data, "0$1"; + push @mask, "0"; + } elsif ($dat =~ m/d=-/) { + push @data, "0"; + push @mask, "0177777"; + $domask = 1; + } else { + exit 1; + } + $i++; + } + print " -edata {", join(" ",@data), "} "; + print " {", join(" ",@mask), "} " if $domask; + print "\n"; + + # wibr off data --------------------------------------------------- + } elsif ($cmd =~ /^(wibr)\s+([0-7]+)\s+([0-7]+)/) { + print "$cpu cp -$1 0$2 0$3"; + print "\n"; + + # ribr off [d=data] ------------------------------------------------ + } elsif ($cmd =~ /^(ribr)\s+([0-7]+)/) { + print "$cpu cp -$1 0$2"; + add_edata($'); + print "\n"; + + # simple action commands: sta,sto,cont,step,rst -------------------- + } elsif ($cmd =~ /^(sta|sto|cont|step|rst)/) { + my %cmdmap = (sta => 'start', + sto => 'stop', + cont => 'continue', + step => 'step', + rst => 'reset'); + printf "$cpu cp -%s", $cmdmap{$1}; + print "\n"; + + # wtgo -> wtcpu ---------------------------------------------------- + } elsif ($cmd =~ /^(wtgo)/) { + print "$cpu wtcpu 10."; + print "\n"; + + # wtlam apat ------------------------------------------------------- + # Note: apat currently ignored !! + } elsif ($cmd =~ /^(wtlam)/) { + print "$cpu wtcpu 10."; + print "\n"; + + # currently unimplemented commands ... ----------------------------- + } elsif ($cmd =~ /^(\.wait|\.sdef)/) { + print "## TODO... $cmd\n"; + + } else { + print "# FAIL: no match for '$cmd'\n"; + exit 1; + } + +} + +sub add_edata { + my ($crest) = @_; + $crest =~ s/\s+//; + if ($crest =~ m/d=([0-7]+)/) { + print " -edata 0$1"; + } +} diff --git a/tools/dox/.cvsignore b/tools/dox/.cvsignore new file mode 100644 index 00000000..01a80adc --- /dev/null +++ b/tools/dox/.cvsignore @@ -0,0 +1,2 @@ +default*.Doxyfile +*.dox_log diff --git a/tools/dox/make_doxy b/tools/dox/make_doxy new file mode 100755 index 00000000..c4e32d2f --- /dev/null +++ b/tools/dox/make_doxy @@ -0,0 +1,40 @@ +#!/bin/sh +# $Id: make_doxy 488 2013-02-16 18:49:47Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-02-05 482 1.0 Initial version +# +if [ -z "$RETROBASE" ] +then + echo "RETROBASE not defined" + exit 1 +fi +# +if [ -z "$RETRODOXY" ] +then + echo "RETRODOXY defaulted to /tmp" + export RETRODOXY=/tmp +fi +# +if [ ! -d "$RETRODOXY" ] +then + echo "$RETRODOXY doesn't exist" + exit 1 +fi +# +if [ ! -d "$RETRODOXY/w11" ] +then + mkdir $RETRODOXY/w11 +fi +# +doxygen w11_cpp.Doxyfile 2>&1 | tee w11_cpp.dox_log +doxygen w11_tcl.Doxyfile 2>&1 | tee w11_tcl.dox_log +doxygen w11_vhd_all.Doxyfile 2>&1 | tee w11_vhd_all.dox_log +# +# +echo "" +echo "to view use" +echo " firefox $RETRODOXY/w11/cpp/html/index.html &" +echo " firefox $RETRODOXY/w11/tcl/html/index.html &" +echo " firefox $RETRODOXY/w11/vhd/html/index.html &" diff --git a/tools/dox/w11_cpp.Doxyfile b/tools/dox/w11_cpp.Doxyfile new file mode 100644 index 00000000..d9079f7d --- /dev/null +++ b/tools/dox/w11_cpp.Doxyfile @@ -0,0 +1,303 @@ +# Doxyfile 1.8.3.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = w11 - cpp +PROJECT_NUMBER = 0.57 +PROJECT_BRIEF = "Backend server for Rlink and w11" +PROJECT_LOGO = +OUTPUT_DIRECTORY = $(RETRODOXY)/w11/cpp +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = $(RETROBASE)/tools/src +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = ipp=C++ +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = YES +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +SYMBOL_CACHE_SIZE = 0 +LOOKUP_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = $(RETROBASE)/tools/src \ + $(RETROBASE)/tools/dox/cpp_extra +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.cpp \ + *.hpp \ + *.ipp \ + *.dox +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = */.svn* \ + */librnew/* \ + */tests/* +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = YES +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://www.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/tools/dox/w11.Doxyfile b/tools/dox/w11_tcl.Doxyfile similarity index 89% rename from tools/dox/w11.Doxyfile rename to tools/dox/w11_tcl.Doxyfile index 9b16c806..c26ca48f 100644 --- a/tools/dox/w11.Doxyfile +++ b/tools/dox/w11_tcl.Doxyfile @@ -1,20 +1,14 @@ -# $Id: w11.Doxyfile 403 2011-08-06 17:36:22Z mueller $ -# Revision History: -# Date Rev Version Comment -# 2011-01-09 354 1.0 Initial version -#--------------------------------------------------------------------------- -# -# Doxyfile 1.7.3 +# Doxyfile 1.8.3.1 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = w11 -PROJECT_NUMBER = 0.53 +PROJECT_NAME = w11 - tcl +PROJECT_NUMBER = 0.57 PROJECT_BRIEF = "Backend server for Rlink and w11" PROJECT_LOGO = -OUTPUT_DIRECTORY = $(HOME)/tmp/w11 +OUTPUT_DIRECTORY = $(RETRODOXY)/w11/tcl CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES @@ -23,7 +17,7 @@ ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES -STRIP_FROM_PATH = $(RETROBASE)/tools/src +STRIP_FROM_PATH = $(RETROBASE)/tools/tcl STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO @@ -33,24 +27,31 @@ INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = +TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO -EXTENSION_MAPPING = ipp=C++ +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO TYPEDEF_HIDES_STRUCT = NO SYMBOL_CACHE_SIZE = 0 +LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = NO EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO @@ -78,11 +79,11 @@ GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -SHOW_DIRECTORIES = NO SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -96,13 +97,15 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = $(RETROBASE)/tools/src +INPUT = $(RETROBASE)/tools/tcl INPUT_ENCODING = UTF-8 -FILE_PATTERNS = *.cpp *.hpp *.ipp *.dox +FILE_PATTERNS = *.tcl \ + *.dox RECURSIVE = YES -EXCLUDE = +EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = */.svn* */tests/* +EXCLUDE_PATTERNS = */.svn* \ + */tests/* EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = @@ -112,6 +115,7 @@ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- @@ -138,12 +142,14 @@ HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES -HTML_ALIGN_MEMBERS = YES HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project @@ -167,17 +173,23 @@ QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = YES -USE_INLINE_TREES = YES +ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO -MATHJAX_RELPATH = http://www.mathjax.org/mathjax +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://www.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = SEARCHENGINE = YES SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -189,11 +201,13 @@ COMPACT_LATEX = NO PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = +LATEX_FOOTER = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -264,6 +278,7 @@ CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES @@ -271,7 +286,8 @@ CALL_GRAPH = NO CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = diff --git a/tools/dox/w11_vhd_all.Doxyfile b/tools/dox/w11_vhd_all.Doxyfile new file mode 100644 index 00000000..6307236e --- /dev/null +++ b/tools/dox/w11_vhd_all.Doxyfile @@ -0,0 +1,302 @@ +# Doxyfile 1.8.3.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = w11 - vhd +PROJECT_NUMBER = 0.57 +PROJECT_BRIEF = "Backend server for Rlink and w11" +PROJECT_LOGO = +OUTPUT_DIRECTORY = $(RETRODOXY)/w11/vhd +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = $(RETROBASE)/rtl +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = NO +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = YES +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = YES +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +SYMBOL_CACHE_SIZE = 0 +LOOKUP_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PACKAGE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = YES +SHOW_INCLUDE_FILES = YES +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = $(RETROBASE)/rtl +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.vhd \ + *.dox +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = */*_ssim.vhd \ + */*_fsim.vhd \ + */*_tsim.vhd \ + */.svn* \ + */tests/* +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = YES +HTML_DYNAMIC_SECTIONS = NO +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = http://www.mathjax.org/mathjax/latest +MATHJAX_EXTENSIONS = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +LATEX_BIB_STYLE = plain +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = NO +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/tools/make/dontincdep.mk b/tools/make/dontincdep.mk new file mode 100644 index 00000000..38ea0336 --- /dev/null +++ b/tools/make/dontincdep.mk @@ -0,0 +1,21 @@ +# $Id: dontincdep.mk 477 2013-01-27 14:07:10Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-01-27 477 1.0 Initial version +# +# DONTINCDEP controls whether dependency files are included. Set it if +# any of the 'clean' type targets is involved +# +ifneq ($(findstring clean, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifneq ($(findstring cleandep, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifneq ($(findstring distclean, $(MAKECMDGOALS)),) +DONTINCDEP = 1 +endif +ifdef DONTINCDEP +$(info DONTINCDEP set, *.dep files not included) +endif diff --git a/tools/make/generic_asm11.mk b/tools/make/generic_asm11.mk new file mode 100644 index 00000000..c7d58b05 --- /dev/null +++ b/tools/make/generic_asm11.mk @@ -0,0 +1,45 @@ +# $Id: generic_asm11.mk 503 2013-04-06 19:44:13Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-04-06 503 1.0.1 use --hostinc for mac2lda +# 2013-03-22 496 1.0 Initial version +#--- +# + +ASM11 = asm-11 +ASM11EXP = asm-11_expect + +MAC2LDA = mac2lda + +ifdef ASM11COMMAND +ASM11 = $(ASM11COMMAND) +endif +ifdef ASM11EXPCOMMAND +ASM11EXP = $(ASM11EXPCOMMAND) +endif + +# +# Compile rules +# +%.lda : %.mac + $(ASM11) --lda --lst $< +%.cof : %.mac + $(ASM11) --cof --lst $< +# +%.lst : %.mac + $(ASM11) --lst $< +# +%.lsterr : %.mac + $(ASM11) --olst=%.lsterr $< || true +# +%.lstrt %ldart : %.mac + $(MAC2LDA) --hostinc --suff=rt $* +# +# Expect rules +# +%.lstexp : %.lst + $(ASM11EXP) $< +# +%.lstexp : %.lsterr + $(ASM11EXP) $< diff --git a/tools/src/Makefile b/tools/src/Makefile index d6d3c9fd..f76d333f 100644 --- a/tools/src/Makefile +++ b/tools/src/Makefile @@ -1,10 +1,12 @@ -# $Id: Makefile 431 2011-11-21 17:56:37Z mueller $ +# $Id: Makefile 479 2013-02-01 18:09:49Z mueller $ # # Top level makefile, using the recipe found in # http://www.lackof.org/taggart/hacking/make-example/ # # Revision History: # Date Rev Version Comment +# 2013-02-01 479 1.2.2 correct so names for *w11* libs +# 2013-01-27 478 1.2.1 add librlw11(tpp) # 2011-03-20 372 1.1.1 renamed ..tcl -> ..tpp # 2011-03-14 370 1.1.0 rename librtoolstcl -> librtcltools # 2011-02-13 361 1.1 add realclean rule; add dirs and dependencies @@ -12,9 +14,11 @@ # DIRS = librtools DIRS += librlink +DIRS += librw11 DIRS += librtcltools DIRS += librutiltpp DIRS += librlinktpp +DIRS += librwxxtpp # BUILDDIRS = $(DIRS:%=build-%) CLEANDIRS = $(DIRS:%=clean-%) @@ -30,9 +34,11 @@ REALCDIRS = $(DIRS:%=distc-%) # all: $(BUILDDIRS) # +build-librw11 : build-librlink build-librlink : build-librtools build-librtcltools : build-librtools build-librutiltpp : build-librtcltools +build-librwxxtpp : build-librw11 build-librtcltools build-librlinktpp : build-librlink build-librtcltools # $(BUILDDIRS): diff --git a/tools/src/checkpath_cpp.mk b/tools/src/checkpath_cpp.mk new file mode 100644 index 00000000..17afa4f4 --- /dev/null +++ b/tools/src/checkpath_cpp.mk @@ -0,0 +1,34 @@ +# $Id: checkpath_cpp.mk 504 2013-04-13 15:37:24Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-03-01 493 1.0.1 fix logic +# 2013-02-01 479 1.0 Initial version +# +ifndef RETROBASE +$(error RETROBASE not defined) +endif +# +# check that BOOSTLIB/BOOSTINC are defined either both, or none +# +ifndef BOOSTINC +ifdef BOOSTLIB +$(error BOOSTLIB defined, but not BOOSTINC; either both, or none !!) +endif +endif +# +ifndef BOOSTLIB +ifdef BOOSTINC +$(error BOOSTINC defined, but not BOOSTLIB; either both, or none !!) +endif +endif +# +# now define, if needed +# +ifndef BOOSTINC +BOOSTINC = /usr/include +endif +# +ifndef BOOSTLIB +BOOSTLIB = /usr/lib +endif diff --git a/tools/src/librlink/Makefile b/tools/src/librlink/Makefile index 72a75287..a3a48d17 100644 --- a/tools/src/librlink/Makefile +++ b/tools/src/librlink/Makefile @@ -1,7 +1,8 @@ -# $Id: Makefile 465 2012-12-27 21:29:38Z mueller $ +# $Id: Makefile 492 2013-02-24 22:14:47Z mueller $ # # Revision History: # Date Rev Version Comment +# 2013-02-01 479 1.1.1 use checkpath_cpp.mk # 2011-07-31 401 1.1 rename realclean->distclean # 2011-07-01 386 1.0.1 add BOOSTINC # 2011-01-09 354 1.0 Initial version (adopted from CTB...) @@ -15,17 +16,23 @@ SOMINV = 0 # # Compile and Link search paths # +include ../checkpath_cpp.mk +# INCLFLAGS = -I${RETROBASE}/tools/src -I${BOOSTINC} -LDLIBS = -lboost_thread -lusb-1.0 -L${RETROBASE}/tools/lib -lrtools +LDLIBS = -lusb-1.0 +LDLIBS += -L${BOOSTLIB} -lboost_thread +LDLIBS += -L${RETROBASE}/tools/lib -lrtools # # Object files to be included # -OBJ_all = RlinkAddrMap.o \ - RlinkCommand.o RlinkCommandExpect.o RlinkCommandList.o \ - RlinkConnect.o \ - RlinkCrc8.o RlinkPacketBuf.o \ - RlinkPort.o RlinkPortFactory.o \ - RlinkPortFifo.o RlinkPortTerm.o RlinkPortCuff.o +OBJ_all = RlinkAddrMap.o +OBJ_all += RlinkCommand.o RlinkCommandExpect.o RlinkCommandList.o +OBJ_all += RlinkConnect.o RlinkContext.o RlinkChannel.o +OBJ_all += RlinkCrc8.o RlinkPacketBuf.o +OBJ_all += RlinkPort.o RlinkPortFactory.o +OBJ_all += RlinkPortFifo.o RlinkPortTerm.o RlinkPortCuff.o +OBJ_all += RtimerFd.o ReventFd.o ReventLoop.o +OBJ_all += RlinkServer.o RlinkServerEventLoop.o # DEP_all = $(OBJ_all:.o=.dep) # @@ -38,10 +45,13 @@ SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) include $(RETROBASE)/tools/make/generic_cpp.mk include $(RETROBASE)/tools/make/generic_dep.mk include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk # # The magic autodependcy include # +ifndef DONTINCDEP include $(DEP_all) +endif # # cleanup phonies: # diff --git a/tools/src/librlink/ReventFd.cpp b/tools/src/librlink/ReventFd.cpp new file mode 100644 index 00000000..2d827b0b --- /dev/null +++ b/tools/src/librlink/ReventFd.cpp @@ -0,0 +1,82 @@ +// $Id: ReventFd.cpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-14 475 1.0 Initial version +// 2013-01-11 473 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: ReventFd.cpp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation of class ReventFd. +*/ + +#include +#include +#include + +#include "ReventFd.hpp" + +#include "librtools/Rexception.hpp" + +using namespace std; + +/*! + \class Retro::ReventFd + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +ReventFd::ReventFd() +{ + fFd = eventfd(0,0); // ini value = 0; no flags + if (fFd < 0) + throw Rexception("ReventFd::ctor", "eventfd() failed: ", errno); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +ReventFd::~ReventFd() +{ + close(fFd); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int ReventFd::SignalFd(int fd) +{ + uint64_t one(1); + int irc = write(fd, &one, sizeof(one)); + return irc; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int ReventFd::WaitFd(int fd) +{ + uint64_t buf; + int irc = read(fd, &buf, sizeof(buf)); + return (irc <= 0) ? irc : (int)buf; +} + +} // end namespace Retro diff --git a/tools/src/librlink/ReventFd.hpp b/tools/src/librlink/ReventFd.hpp new file mode 100644 index 00000000..906393db --- /dev/null +++ b/tools/src/librlink/ReventFd.hpp @@ -0,0 +1,57 @@ +// $Id: ReventFd.hpp 486 2013-02-10 22:34:43Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-14 475 1.0 Initial version +// 2013-01-11 473 0.5 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: ReventFd.hpp 486 2013-02-10 22:34:43Z mueller $ + \brief Declaration of class \c ReventFd. +*/ + +#ifndef included_Retro_ReventFd +#define included_Retro_ReventFd 1 + +#include "boost/utility.hpp" + +namespace Retro { + + class ReventFd : private boost::noncopyable { + public: + ReventFd(); + virtual ~ReventFd(); + + int Fd() const; + int Signal(); + int Wait(); + + operator int() const; + + static int SignalFd(int fd); + static int WaitFd(int fd); + + protected: + + int fFd; +}; + +} // end namespace Retro + +#include "ReventFd.ipp" + +#endif diff --git a/tools/src/librlink/ReventFd.ipp b/tools/src/librlink/ReventFd.ipp new file mode 100644 index 00000000..ba6e009f --- /dev/null +++ b/tools/src/librlink/ReventFd.ipp @@ -0,0 +1,61 @@ +// $Id: ReventFd.ipp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-14 475 1.0 Initial version +// 2013-01-11 473 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: ReventFd.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class ReventFd. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline int ReventFd::Fd() const +{ + return fFd; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline int ReventFd::Signal() +{ + return SignalFd(fFd); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline int ReventFd::Wait() +{ + return WaitFd(fFd); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline ReventFd::operator int() const +{ + return fFd; +} + +} // end namespace Retro diff --git a/tools/src/librlink/ReventLoop.cpp b/tools/src/librlink/ReventLoop.cpp new file mode 100644 index 00000000..e94da0e0 --- /dev/null +++ b/tools/src/librlink/ReventLoop.cpp @@ -0,0 +1,280 @@ +// $Id: ReventLoop.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-05 495 1.1.2 add exception catcher to EventLoop +// 2013-03-01 493 1.1.1 DoCall(): remove handler on negative return +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: ReventLoop.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of class ReventLoop. +*/ + +#include +#include +#include + +#include "boost/bind.hpp" +#include "boost/thread/locks.hpp" + +#include "librtools/Rexception.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosFill.hpp" +#include "librtools/RlogMsg.hpp" + +#include "ReventLoop.hpp" + +using namespace std; + +/*! + \class Retro::ReventLoop + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +ReventLoop::ReventLoop() + : fLoopActive(false), + fUpdatePoll(false), + fPollDscMutex(), + fPollDsc(), + fPollFd(), + fPollHdl(), + fTraceLevel(0), + fspLog() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +ReventLoop::~ReventLoop() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +// by default handlers should start with: +// if (pfd.revents & (~pfd.events)) return -1; + +void ReventLoop::AddPollHandler(const pollhdl_t& pollhdl, + int fd, short events) +{ + boost::lock_guard lock(fPollDscMutex); + + for (size_t i=0; i= 1) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "eloop: add handler: " << fd << "," << RosPrintf(events,"x"); + } + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void ReventLoop::RemovePollHandler(int fd, short events, bool nothrow) +{ + boost::lock_guard lock(fPollDscMutex); + + for (size_t i=0; i= 1) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "eloop: remove handler: " << fd << "," << RosPrintf(events,"x"); + } + return; + } + } + if (!nothrow) throw Rexception("ReventLoop::RemovePollHandler()", + "Bad args: unknown handler"); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool ReventLoop::TestPollHandler(int fd, short events) +{ + boost::lock_guard lock(fPollDscMutex); + + for (size_t i=0; i lock(fPollDscMutex); + + for (size_t i=0; i0) DoCall(); + } + } catch (exception& e) { + if (fspLog) { + RlogMsg lmsg(*fspLog, 'F'); + lmsg << "eloop: crashed with exception: " << e.what(); + } + return; + } + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void ReventLoop::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "ReventLoop @ " << this << endl; + os << bl << " fLoopActive: " << fLoopActive << endl; + os << bl << " fUpdatePoll: " << fUpdatePoll << endl; + { + boost::lock_guard lock(((ReventLoop*)this)->fPollDscMutex); + os << bl << " fPollDsc.size " << fPollDsc.size() << endl; + os << bl << " fPollFd.size " << fPollFd.size() << endl; + os << bl << " fPollHdl.size " << fPollHdl.size() << endl; + for (size_t i=0; i lock(fPollDscMutex); + + fPollFd.resize(fPollDsc.size()); + fPollHdl.resize(fPollDsc.size()); + for (size_t i=0; i= 1) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "eloop: redo pollfd list, size=" << fPollFd.size() << endl; + } + } + + if (fPollFd.size() == 0) return 0; + + int irc = poll(fPollFd.data(), fPollFd.size(), timeout); + if (irc < 0 && errno == EINTR) return 0; + if (irc < 0) + throw Rexception("ReventLoop::EventLoop()", "poll() failed: ", errno); + + if (fspLog && fTraceLevel >= 2) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "eloop: poll(): "; + for (size_t i=0; i= 1) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "eloop: handler(" << fPollFd[i].fd + << "," << RosPrintf(fPollFd[i].events,"x") + << ") got " << RosPrintf(fPollFd[i].revents,"x") + << " and requested removal"; + } + RemovePollHandler(fPollFd[i].fd, fPollFd[i].events, true); + } + } + } + return; +} + +} // end namespace Retro diff --git a/tools/src/librlink/ReventLoop.hpp b/tools/src/librlink/ReventLoop.hpp new file mode 100644 index 00000000..bed26dcd --- /dev/null +++ b/tools/src/librlink/ReventLoop.hpp @@ -0,0 +1,95 @@ +// $Id: ReventLoop.hpp 494 2013-03-03 21:50:07Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: ReventLoop.hpp 494 2013-03-03 21:50:07Z mueller $ + \brief Declaration of class \c ReventLoop. +*/ + +#ifndef included_Retro_ReventLoop +#define included_Retro_ReventLoop 1 + +#include + +#include +#include + +#include "boost/utility.hpp" +#include "boost/function.hpp" +#include "boost/thread/mutex.hpp" +#include "boost/shared_ptr.hpp" + +#include "librtools/RlogFile.hpp" + +namespace Retro { + + class ReventLoop : private boost::noncopyable { + public: + typedef boost::function pollhdl_t; + + ReventLoop(); + virtual ~ReventLoop(); + + void AddPollHandler(const pollhdl_t& pollhdl, + int fd, short events=POLLIN); + bool TestPollHandler(int fd, short events=POLLIN); + void RemovePollHandler(int fd, short events, bool nothrow=false); + void RemovePollHandler(int fd); + + void SetLogFile(const boost::shared_ptr& splog); + void SetTraceLevel(size_t level); + size_t TraceLevel() const; + + void Stop(); + virtual void EventLoop(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + + int DoPoll(int timeout=-1); + void DoCall(void); + + protected: + + struct PollDsc { + pollhdl_t fHandler; + int fFd; + short fEvents; + PollDsc(pollhdl_t hdl,int fd,short evts) : + fHandler(hdl),fFd(fd),fEvents(evts) {} + }; + + bool fLoopActive; + bool fUpdatePoll; + boost::mutex fPollDscMutex; + std::vector fPollDsc; + std::vector fPollFd; + std::vector fPollHdl; + size_t fTraceLevel; //!< trace level + boost::shared_ptr fspLog; //!< log file ptr +}; + +} // end namespace Retro + +#include "ReventLoop.ipp" + +#endif diff --git a/tools/src/librlink/ReventLoop.ipp b/tools/src/librlink/ReventLoop.ipp new file mode 100644 index 00000000..7edb87e3 --- /dev/null +++ b/tools/src/librlink/ReventLoop.ipp @@ -0,0 +1,65 @@ +// $Id: ReventLoop.ipp 491 2013-02-23 12:41:18Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: ReventLoop.ipp 491 2013-02-23 12:41:18Z mueller $ + \brief Implemenation (inline) of class ReventLoop. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void ReventLoop::Stop() +{ + fLoopActive = false; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void ReventLoop::SetLogFile(const boost::shared_ptr& splog) +{ + fspLog = splog; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void ReventLoop::SetTraceLevel(size_t level) +{ + fTraceLevel = level; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t ReventLoop::TraceLevel() const +{ + return fTraceLevel; +} + +} // end namespace Retro + diff --git a/tools/src/librlink/RlinkAddrMap.cpp b/tools/src/librlink/RlinkAddrMap.cpp index 87daa7fb..80cf77ac 100644 --- a/tools/src/librlink/RlinkAddrMap.cpp +++ b/tools/src/librlink/RlinkAddrMap.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkAddrMap.cpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RlinkAddrMap.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.2 use Rexception // 2011-11-28 434 1.0.1 Print(): use proper cast for lp64 compatibility // 2011-03-06 367 1.0 Initial version // 2011-03-05 366 0.1 First draft @@ -20,26 +21,28 @@ /*! \file - \version $Id: RlinkAddrMap.cpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RlinkAddrMap.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of class RlinkAddrMap. */ -#include #include #include "RlinkAddrMap.hpp" #include "librtools/RosFill.hpp" #include "librtools/RosPrintf.hpp" +#include "librtools/Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkAddrMap - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -90,9 +93,11 @@ bool RlinkAddrMap::Erase(const std::string& name) fMaxLength = 0; // force recalculate if (fNameMap.erase(name) == 0) - throw logic_error("RlinkAddrMap::Erase: fNameMap erase failed"); + throw Rexception("RlinkAddrMap::Erase()", + "BugCheck: fNameMap erase failed"); if (fAddrMap.erase(it->second) == 0) - throw logic_error("RlinkAddrMap::Erase: fAddrMap erase failed"); + throw Rexception("RlinkAddrMap::Erase()", + "BugCheck: fAddrMap erase failed"); return true; } @@ -107,9 +112,11 @@ bool RlinkAddrMap::Erase(uint16_t addr) fMaxLength = 0; // force recalculate if (fAddrMap.erase(addr) == 0) - throw logic_error("RlinkAddrMap::Erase: fAddrMap erase failed"); + throw Rexception("RlinkAddrMap::Erase()", + "BugCheck: fAddrMap erase failed"); if (fNameMap.erase(it->second) == 0) - throw logic_error("RlinkAddrMap::Erase: fNameMap erase failed"); + throw Rexception("RlinkAddrMap::Erase()", + "BugCheck: fNameMap erase failed"); return true; } @@ -181,10 +188,4 @@ void RlinkAddrMap::Dump(std::ostream& os, int ind, const char* text) const return; } - -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkAddrMap_NoInline)) -#define inline -#include "RlinkAddrMap.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkAddrMap.hpp b/tools/src/librlink/RlinkAddrMap.hpp index dbede4e1..6c1bd286 100644 --- a/tools/src/librlink/RlinkAddrMap.hpp +++ b/tools/src/librlink/RlinkAddrMap.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkAddrMap.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkAddrMap.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: RlinkAddrMap.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkAddrMap.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class \c RlinkAddrMap. */ @@ -73,8 +73,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkAddrMap_NoInline)) #include "RlinkAddrMap.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkAddrMap.ipp b/tools/src/librlink/RlinkAddrMap.ipp index 8e028fc1..755db4dc 100644 --- a/tools/src/librlink/RlinkAddrMap.ipp +++ b/tools/src/librlink/RlinkAddrMap.ipp @@ -1,4 +1,4 @@ -// $Id: RlinkAddrMap.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkAddrMap.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,11 +18,11 @@ /*! \file - \version $Id: RlinkAddrMap.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkAddrMap.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of class RlinkAddrMap. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librlink/RlinkChannel.cpp b/tools/src/librlink/RlinkChannel.cpp new file mode 100644 index 00000000..403654f3 --- /dev/null +++ b/tools/src/librlink/RlinkChannel.cpp @@ -0,0 +1,85 @@ +// $Id: RlinkChannel.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkChannel.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of class RlinkChannel. + */ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosPrintBvi.hpp" +#include "librtools/Rexception.hpp" + +#include "RlinkChannel.hpp" + +using namespace std; + +/*! + \class Retro::RlinkChannel + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlinkChannel::RlinkChannel(const boost::shared_ptr& spconn) + : fContext(), + fspConn(spconn) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlinkChannel::~RlinkChannel() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkChannel::Exec(RlinkCommandList& clist, RerrMsg& emsg) +{ + if (!fspConn) + throw Rexception("RlinkChannel::Exec", "Bad state: fspConn == 0"); + + return fspConn->Exec(clist, emsg); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkChannel::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "RlinkChannel @ " << this << endl; + + fContext.Dump(os, ind+2, "fContext: "); + if (fspConn) { + fspConn->Dump(os, ind+2, "fspConn: "); + } else { + os << bl << " fspConn: " << fspConn.get() << endl; + } + + return; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkChannel.hpp b/tools/src/librlink/RlinkChannel.hpp new file mode 100644 index 00000000..34c1e7ad --- /dev/null +++ b/tools/src/librlink/RlinkChannel.hpp @@ -0,0 +1,58 @@ +// $Id: RlinkChannel.hpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RlinkChannel.hpp 492 2013-02-24 22:14:47Z mueller $ + \brief Declaration of class RlinkChannel. +*/ + +#ifndef included_Retro_RlinkChannel +#define included_Retro_RlinkChannel 1 + +#include "boost/shared_ptr.hpp" + +#include "RlinkContext.hpp" +#include "RlinkConnect.hpp" +#include "RlinkCommandList.hpp" + +namespace Retro { + + class RlinkChannel { + public: + explicit RlinkChannel(const boost::shared_ptr& spconn); + ~RlinkChannel(); + + RlinkConnect& Connect(); + RlinkContext& Context(); + + bool Exec(RlinkCommandList& clist, RerrMsg& emsg); + + void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + RlinkContext fContext; //!< stat check and errcnt context + boost::shared_ptr fspConn; //!< ptr to connect + }; + +} // end namespace Retro + +#include "RlinkChannel.ipp" + +#endif diff --git a/tools/src/librlink/RlinkChannel.ipp b/tools/src/librlink/RlinkChannel.ipp new file mode 100644 index 00000000..29021603 --- /dev/null +++ b/tools/src/librlink/RlinkChannel.ipp @@ -0,0 +1,44 @@ +// $Id: RlinkChannel.ipp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkChannel.ipp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation (inline) of class RlinkChannel. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& RlinkChannel::Connect() +{ + return *fspConn; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkContext& RlinkChannel::Context() +{ + return fContext; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkCommand.cpp b/tools/src/librlink/RlinkCommand.cpp index 1c7cb62f..228546f2 100644 --- a/tools/src/librlink/RlinkCommand.cpp +++ b/tools/src/librlink/RlinkCommand.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkCommand.cpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommand.cpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,20 +13,21 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.2 add RlinkContext to Print() args +// 2013-02-03 481 1.0.1 use Rexception // 2011-03-27 374 1.0 Initial version // 2011-01-15 355 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkCommand.cpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommand.cpp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation of class RlinkCommand. */ // debug #include -#include #include #include "RlinkCommand.hpp" @@ -34,15 +35,18 @@ #include "librtools/RosFill.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/RosPrintBvi.hpp" +#include "librtools/Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkCommand \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- // constants definitions @@ -69,6 +73,20 @@ const uint32_t RlinkCommand::kFlagChkStat; const uint32_t RlinkCommand::kFlagChkData; const uint32_t RlinkCommand::kFlagVol; +const uint8_t RlinkCommand::kStat_M_Stat; +const uint8_t RlinkCommand::kStat_V_Stat; +const uint8_t RlinkCommand::kStat_B_Stat; +const uint8_t RlinkCommand::kStat_M_Attn; +const uint8_t RlinkCommand::kStat_M_Cerr; +const uint8_t RlinkCommand::kStat_M_Derr; +const uint8_t RlinkCommand::kStat_M_RbNak; +const uint8_t RlinkCommand::kStat_M_RbErr; + +const uint16_t RlinkCommand::kRbaddr_IInt; +const uint16_t RlinkCommand::kIInt_M_AnEna; +const uint16_t RlinkCommand::kIInt_M_ItoEna; +const uint16_t RlinkCommand::kIInt_M_ItoVal; + //------------------------------------------+----------------------------------- //! Default constructor @@ -157,9 +175,9 @@ void RlinkCommand::CmdWblk(uint16_t addr, const uint16_t* pblock, size_t size) void RlinkCommand::SetCommand(uint8_t cmd, uint16_t addr, uint16_t data) { if (cmd > kCmdInit) - throw invalid_argument("RlinkCommand::SetCommand: invalid cmd"); + throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid cmd"); if (addr > 0xff) - throw invalid_argument("RlinkCommand::SetCommand: invalid addr"); + throw Rexception("RlinkCommand::SetCommand()", "Bad args: invalid addr"); fRequest = cmd; fAddress = addr; fData = data; @@ -179,7 +197,7 @@ void RlinkCommand::SetCommand(uint8_t cmd, uint16_t addr, uint16_t data) void RlinkCommand::SetAddress(uint16_t addr) { if (addr > 0xff) - throw invalid_argument("RlinkCommand::SetAddress: invalid addr"); + throw Rexception("RlinkCommand::SetAddress()", "Bad args: invalid addr"); fAddress = addr; return; } @@ -190,7 +208,8 @@ void RlinkCommand::SetAddress(uint16_t addr) void RlinkCommand::SetBlockWrite(const std::vector& block) { if (block.size() == 0 || block.size() > 256) - throw invalid_argument("RlinkCommand::SetBlockWrite: invalid block size"); + throw Rexception("RlinkCommand::SetBlockWrite()", + "Bad args: invalid block size"); fBlock = block; fpBlockExt = 0; fBlockExtSize = 0; @@ -203,7 +222,8 @@ void RlinkCommand::SetBlockWrite(const std::vector& block) void RlinkCommand::SetBlockRead(size_t size) { if (size == 0 || size > 256) - throw invalid_argument("RlinkCommand::SetBlockRead: invalid block size"); + throw Rexception("RlinkCommand::SetBlockRead()", + "Bad args: invalid block size"); fBlock.clear(); fBlock.resize(size); fpBlockExt = 0; @@ -217,9 +237,11 @@ void RlinkCommand::SetBlockRead(size_t size) void RlinkCommand::SetBlockExt(uint16_t* pblock, size_t size) { if (pblock == 0) - throw invalid_argument("RlinkCommand::SetBlockExt: pblock is null"); + throw Rexception("RlinkCommand::SetBlockExt()", + "Bad args: pblock is null"); if (size == 0 || size > 256) - throw invalid_argument("RlinkCommand::SetBlockExt: invalid block size"); + throw Rexception("RlinkCommand::SetBlockExt()", + "Bad args: invalid block size"); fpBlockExt = pblock; fBlockExtSize = size; return; @@ -238,8 +260,9 @@ void RlinkCommand::SetExpect(RlinkCommandExpect* pexp) //------------------------------------------+----------------------------------- //! FIXME_docs -void RlinkCommand::Print(std::ostream& os, const RlinkAddrMap* pamap, - size_t abase, size_t dbase, size_t sbase) const +void RlinkCommand::Print(std::ostream& os, const RlinkContext& cntx, + const RlinkAddrMap* pamap, size_t abase, + size_t dbase, size_t sbase) const { uint8_t ccode = Command(); @@ -306,20 +329,16 @@ void RlinkCommand::Print(std::ostream& os, const RlinkAddrMap* pamap, // status field os << " s=" << RosPrintBvi(fStatus, sbase); - if (fpExpect) { - if (TestFlagAny(kFlagChkStat)) { - os << "#"; - os << " S=" << RosPrintBvi(fpExpect->StatusValue(), sbase); - if (fpExpect->StatusMask() != 0x00) { - os << "," << RosPrintBvi(fpExpect->StatusMask(), sbase); - } - } else if (fpExpect->StatusIsChecked()) { - os << "!"; - } else { - os << " "; + uint8_t scval = fpExpect ? fpExpect->StatusValue() : cntx.StatusValue(); + uint8_t scmsk = fpExpect ? fpExpect->StatusMask() : cntx.StatusMask(); + if (TestFlagAny(kFlagChkStat)) { + os << "#"; + os << " S=" << RosPrintBvi(scval, sbase); + if (scmsk != 0x00) { + os << "," << RosPrintBvi(scmsk, sbase); } } else { - os << " "; + os << ( scmsk != 0xff ? "!" : " " ); } if (TestFlagAny(kFlagDone)) { @@ -489,9 +508,4 @@ RlinkCommand& RlinkCommand::operator=(const RlinkCommand& rhs) return *this; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkCommand_NoInline)) -#define inline -#include "RlinkCommand.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkCommand.hpp b/tools/src/librlink/RlinkCommand.hpp index 21a09205..ba75057c 100644 --- a/tools/src/librlink/RlinkCommand.hpp +++ b/tools/src/librlink/RlinkCommand.hpp @@ -1,6 +1,6 @@ -// $Id: RlinkCommand.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommand.hpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<() // 2011-03-27 374 1.0 Initial version // 2011-01-09 354 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RlinkCommand.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommand.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class RlinkCommand. */ @@ -32,13 +33,17 @@ #include #include -#include "RlinkCommandExpect.hpp" -#include "RlinkAddrMap.hpp" #include "librtools/Rtools.hpp" +#include "RlinkContext.hpp" +#include "RlinkAddrMap.hpp" +#include "RlinkCommandExpect.hpp" + +#include "librtools/Rbits.hpp" + namespace Retro { - class RlinkCommand { + class RlinkCommand : public Rbits { public: RlinkCommand(); RlinkCommand(const RlinkCommand& rhs); @@ -86,9 +91,9 @@ namespace Retro { size_t RcvSize() const; RlinkCommandExpect* Expect() const; - void Print(std::ostream& os, const RlinkAddrMap* pamap=0, - size_t abase=16, size_t dbase=16, - size_t sbase=16) const; + void Print(std::ostream& os, const RlinkContext& cntx, + const RlinkAddrMap* pamap=0, size_t abase=16, + size_t dbase=16, size_t sbase=16) const; void Dump(std::ostream& os, int ind=0, const char* text=0) const; static const char* CommandName(uint8_t cmd); @@ -96,7 +101,7 @@ namespace Retro { RlinkCommand& operator=(const RlinkCommand& rhs); - // some constants + // some constants (also defined in cpp) static const uint8_t kCmdRreg = 0; //!< command code read register static const uint8_t kCmdRblk = 1; //!< command code read block static const uint8_t kCmdWreg = 2; //!< command code write register @@ -122,7 +127,21 @@ namespace Retro { static const uint32_t kFlagChkStat= 1u<<12; //!< stat expect check failed static const uint32_t kFlagChkData= 1u<<13; //!< data expect check failed - static const uint32_t kFlagVol = 1<<16; //!< volatile + static const uint32_t kFlagVol = 1u<<16; //!< volatile + + static const uint8_t kStat_M_Stat = 0xe0; //!< stat: external stat bits + static const uint8_t kStat_V_Stat = 5; + static const uint8_t kStat_B_Stat = 0x07; + static const uint8_t kStat_M_Attn = kBBit04;//!< stat: attn flags set + static const uint8_t kStat_M_Cerr = kBBit03;//!< stat: attn flags set + static const uint8_t kStat_M_Derr = kBBit02;//!< stat: attn flags set + static const uint8_t kStat_M_RbNak = kBBit01;//!< stat: attn flags set + static const uint8_t kStat_M_RbErr = kBBit00;//!< stat: attn flags set + + static const uint16_t kRbaddr_IInt = 0xff; //!< iint: rbus address + static const uint16_t kIInt_M_AnEna = kWBit15;//!< iint: attn notify + static const uint16_t kIInt_M_ItoEna= kWBit14;//!< iint: attn/idle timeout + static const uint16_t kIInt_M_ItoVal= 0x00ff; //!< iint: attn/idle timeout protected: void SetCmdSimple(uint8_t cmd, uint16_t addr, uint16_t data); @@ -140,14 +159,9 @@ namespace Retro { size_t fRcvSize; //!< receive size for command RlinkCommandExpect* fpExpect; //!< pointer to expect container }; - - std::ostream& operator<<(std::ostream& os, const RlinkCommand& obj); - } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkCommand_NoInline)) #include "RlinkCommand.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkCommand.ipp b/tools/src/librlink/RlinkCommand.ipp index 5792a8dd..a2cd7c3a 100644 --- a/tools/src/librlink/RlinkCommand.ipp +++ b/tools/src/librlink/RlinkCommand.ipp @@ -1,6 +1,6 @@ -// $Id: RlinkCommand.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommand.ipp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,21 +13,22 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<() // 2011-03-27 374 1.0 Initial version // 2011-01-15 355 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkCommand.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommand.ipp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation (inline) of class RlinkCommand. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::CmdRreg(uint16_t addr) { @@ -36,7 +37,7 @@ inline void RlinkCommand::CmdRreg(uint16_t addr) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::CmdWreg(uint16_t addr, uint16_t data) { @@ -45,7 +46,7 @@ inline void RlinkCommand::CmdWreg(uint16_t addr, uint16_t data) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::CmdStat() { @@ -54,7 +55,7 @@ inline void RlinkCommand::CmdStat() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::CmdAttn() { @@ -63,7 +64,7 @@ inline void RlinkCommand::CmdAttn() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::CmdInit(uint16_t addr, uint16_t data) { @@ -72,7 +73,7 @@ inline void RlinkCommand::CmdInit(uint16_t addr, uint16_t data) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetSeqNumber(uint8_t snum) { @@ -81,7 +82,7 @@ inline void RlinkCommand::SetSeqNumber(uint8_t snum) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetData(uint16_t data) { @@ -90,7 +91,7 @@ inline void RlinkCommand::SetData(uint16_t data) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetStatRequest(uint8_t ccmd) { @@ -99,7 +100,7 @@ inline void RlinkCommand::SetStatRequest(uint8_t ccmd) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetStatus(uint8_t stat) { @@ -108,7 +109,7 @@ inline void RlinkCommand::SetStatus(uint8_t stat) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetFlagBit(uint32_t mask) { @@ -117,7 +118,7 @@ inline void RlinkCommand::SetFlagBit(uint32_t mask) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::ClearFlagBit(uint32_t mask) { @@ -126,7 +127,7 @@ inline void RlinkCommand::ClearFlagBit(uint32_t mask) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommand::SetRcvSize(size_t rsize) { @@ -135,7 +136,7 @@ inline void RlinkCommand::SetRcvSize(size_t rsize) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommand::Request() const { @@ -143,7 +144,7 @@ inline uint8_t RlinkCommand::Request() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommand::Command() const { @@ -151,7 +152,7 @@ inline uint8_t RlinkCommand::Command() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommand::SeqNumber() const { @@ -159,7 +160,7 @@ inline uint8_t RlinkCommand::SeqNumber() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint16_t RlinkCommand::Address() const { @@ -167,7 +168,7 @@ inline uint16_t RlinkCommand::Address() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint16_t RlinkCommand::Data() const { @@ -175,7 +176,7 @@ inline uint16_t RlinkCommand::Data() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline const std::vector& RlinkCommand::Block() const { @@ -183,7 +184,7 @@ inline const std::vector& RlinkCommand::Block() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommand::IsBlockExt() const { @@ -191,7 +192,7 @@ inline bool RlinkCommand::IsBlockExt() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint16_t* RlinkCommand::BlockPointer() { @@ -199,7 +200,7 @@ inline uint16_t* RlinkCommand::BlockPointer() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline const uint16_t* RlinkCommand::BlockPointer() const { @@ -207,7 +208,7 @@ inline const uint16_t* RlinkCommand::BlockPointer() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline size_t RlinkCommand::BlockSize() const { @@ -215,7 +216,7 @@ inline size_t RlinkCommand::BlockSize() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommand::StatRequest() const { @@ -223,7 +224,7 @@ inline uint8_t RlinkCommand::StatRequest() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommand::Status() const { @@ -231,7 +232,7 @@ inline uint8_t RlinkCommand::Status() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint32_t RlinkCommand::Flags() const { @@ -239,7 +240,7 @@ inline uint32_t RlinkCommand::Flags() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommand::TestFlagAny(uint32_t mask) const { @@ -247,7 +248,7 @@ inline bool RlinkCommand::TestFlagAny(uint32_t mask) const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommand::TestFlagAll(uint32_t mask) const { @@ -255,7 +256,7 @@ inline bool RlinkCommand::TestFlagAll(uint32_t mask) const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline size_t RlinkCommand::RcvSize() const { @@ -263,24 +264,12 @@ inline size_t RlinkCommand::RcvSize() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline RlinkCommandExpect* RlinkCommand::Expect() const { return fpExpect; } -//------------------------------------------+----------------------------------- -/*! - \relates RlinkCommand - \brief ostream insertion operator. -*/ - -inline std::ostream& operator<<(std::ostream& os, const RlinkCommand& obj) -{ - obj.Print(os); - return os; -} - } // end namespace Retro diff --git a/tools/src/librlink/RlinkCommandExpect.cpp b/tools/src/librlink/RlinkCommandExpect.cpp index d2f82b9a..cd887b24 100644 --- a/tools/src/librlink/RlinkCommandExpect.cpp +++ b/tools/src/librlink/RlinkCommandExpect.cpp @@ -1,4 +1,4 @@ -// $Id: RlinkCommandExpect.cpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,14 +20,13 @@ /*! \file - \version $Id: RlinkCommandExpect.cpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of class RlinkCommandExpect. */ // debug #include -#include #include #include "RlinkCommandExpect.hpp" @@ -37,13 +36,15 @@ #include "librtools/RosPrintBvi.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkCommandExpect \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -188,9 +189,4 @@ void RlinkCommandExpect::Dump(std::ostream& os, int ind, const char* text) const return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkCommandExpect_NoInline)) -#define inline -#include "RlinkCommandExpect.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkCommandExpect.hpp b/tools/src/librlink/RlinkCommandExpect.hpp index 0b387c33..03769c5d 100644 --- a/tools/src/librlink/RlinkCommandExpect.hpp +++ b/tools/src/librlink/RlinkCommandExpect.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkCommandExpect.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommandExpect.hpp 492 2013-02-24 22:14:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RlinkCommandExpect.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommandExpect.hpp 492 2013-02-24 22:14:47Z mueller $ \brief Declaration of class RlinkCommandExpect. */ @@ -44,7 +44,7 @@ namespace Retro { RlinkCommandExpect(uint8_t stat, uint8_t statmsk, const std::vector& block, const std::vector& blockmsk); - ~RlinkCommandExpect(); + ~RlinkCommandExpect(); void SetStatus(uint8_t stat, uint8_t statmsk=0); void SetData(uint16_t data, uint16_t datamsk=0); @@ -68,7 +68,6 @@ namespace Retro { bool DataIsChecked() const; bool BlockIsChecked(size_t ind) const; - void Dump(std::ostream& os, int ind=0, const char* text=0) const; protected: @@ -82,8 +81,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkCommandExpect_NoInline)) #include "RlinkCommandExpect.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkCommandExpect.ipp b/tools/src/librlink/RlinkCommandExpect.ipp index bc0d9934..d8fb1ed0 100644 --- a/tools/src/librlink/RlinkCommandExpect.ipp +++ b/tools/src/librlink/RlinkCommandExpect.ipp @@ -1,4 +1,4 @@ -// $Id: RlinkCommandExpect.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommandExpect.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,15 +19,15 @@ /*! \file - \version $Id: RlinkCommandExpect.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommandExpect.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of class RlinkCommandExpect. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommandExpect::SetStatus(uint8_t stat, uint8_t statmsk) { @@ -37,7 +37,7 @@ inline void RlinkCommandExpect::SetStatus(uint8_t stat, uint8_t statmsk) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommandExpect::SetData(uint16_t data, uint16_t datamsk) { @@ -47,7 +47,7 @@ inline void RlinkCommandExpect::SetData(uint16_t data, uint16_t datamsk) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommandExpect::SetBlock(const std::vector& block) { @@ -56,7 +56,7 @@ inline void RlinkCommandExpect::SetBlock(const std::vector& block) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline void RlinkCommandExpect::SetBlock( const std::vector& block, @@ -68,7 +68,7 @@ inline void RlinkCommandExpect::SetBlock( } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommandExpect::StatusValue() const { @@ -76,7 +76,7 @@ inline uint8_t RlinkCommandExpect::StatusValue() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint8_t RlinkCommandExpect::StatusMask() const { @@ -84,7 +84,7 @@ inline uint8_t RlinkCommandExpect::StatusMask() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint16_t RlinkCommandExpect::DataValue() const { @@ -92,7 +92,7 @@ inline uint16_t RlinkCommandExpect::DataValue() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline uint16_t RlinkCommandExpect::DataMask() const { @@ -100,7 +100,7 @@ inline uint16_t RlinkCommandExpect::DataMask() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline const std::vector& RlinkCommandExpect::BlockValue() const { @@ -108,7 +108,7 @@ inline const std::vector& RlinkCommandExpect::BlockValue() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline const std::vector& RlinkCommandExpect::BlockMask() const { @@ -116,7 +116,7 @@ inline const std::vector& RlinkCommandExpect::BlockMask() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommandExpect::StatusCheck(uint8_t val) const { @@ -124,7 +124,7 @@ inline bool RlinkCommandExpect::StatusCheck(uint8_t val) const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommandExpect::DataCheck(uint16_t val) const { @@ -132,7 +132,7 @@ inline bool RlinkCommandExpect::DataCheck(uint16_t val) const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommandExpect::StatusIsChecked() const { @@ -140,7 +140,7 @@ inline bool RlinkCommandExpect::StatusIsChecked() const } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline bool RlinkCommandExpect::DataIsChecked() const { diff --git a/tools/src/librlink/RlinkCommandList.cpp b/tools/src/librlink/RlinkCommandList.cpp index ca8c7cf9..52185378 100644 --- a/tools/src/librlink/RlinkCommandList.cpp +++ b/tools/src/librlink/RlinkCommandList.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkCommandList.cpp 380 2011-04-25 18:14:52Z mueller $ +// $Id: RlinkCommandList.cpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.3 add RlinkContext to Print() args +// 2013-02-03 481 1.0.2 use Rexception // 2011-04-25 380 1.0.1 use boost/foreach // 2011-03-05 366 1.0 Initial version // 2011-01-15 355 0.1 First draft @@ -20,29 +22,31 @@ /*! \file - \version $Id: RlinkCommandList.cpp 380 2011-04-25 18:14:52Z mueller $ + \version $Id: RlinkCommandList.cpp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation of class RlinkCommandList. */ #include -#include #include "boost/foreach.hpp" -#define foreach BOOST_FOREACH +#define foreach_ BOOST_FOREACH #include "RlinkCommandList.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/RosFill.hpp" +#include "librtools/Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkCommandList \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -66,7 +70,7 @@ RlinkCommandList::RlinkCommandList(const RlinkCommandList& rhs) RlinkCommandList::~RlinkCommandList() { - foreach (RlinkCommand* pcmd, fList) { delete pcmd; } + foreach_ (RlinkCommand* pcmd, fList) { delete pcmd; } } //------------------------------------------+----------------------------------- @@ -196,7 +200,8 @@ size_t RlinkCommandList::AddInit(uint16_t addr, uint16_t data) void RlinkCommandList::LastVolatile() { if (fList.size() == 0) - throw out_of_range("RlinkCommandList::LastExpect: list empty"); + throw Rexception("RlinkCommandList::LastVolatile()", + "Bad state: list empty"); fList[fList.size()-1]->SetFlagBit(RlinkCommand::kFlagVol); return; } @@ -207,7 +212,8 @@ void RlinkCommandList::LastVolatile() void RlinkCommandList::LastExpect(RlinkCommandExpect* exp) { if (fList.size() == 0) - throw out_of_range("RlinkCommandList::LastExpect: list empty"); + throw Rexception("RlinkCommandList::LastExpect()", + "Bad state: list empty"); fList[fList.size()-1]->SetExpect(exp); return; } @@ -225,11 +231,12 @@ void RlinkCommandList::Clear() //------------------------------------------+----------------------------------- //! FIXME_docs -void RlinkCommandList::Print(std::ostream& os, const RlinkAddrMap* pamap, - size_t abase, size_t dbase, size_t sbase) const +void RlinkCommandList::Print(std::ostream& os, const RlinkContext& cntx, + const RlinkAddrMap* pamap, size_t abase, + size_t dbase, size_t sbase) const { - foreach (RlinkCommand* pcmd, fList) { - pcmd->Print(os, pamap, abase, dbase, sbase); + foreach_ (RlinkCommand* pcmd, fList) { + pcmd->Print(os, cntx, pamap, abase, dbase, sbase); } return; } @@ -259,7 +266,7 @@ RlinkCommandList& { if (&rhs == this) return *this; - foreach (RlinkCommand* pcmd, fList) { delete pcmd; } + foreach_ (RlinkCommand* pcmd, fList) { delete pcmd; } fList.clear(); for (size_t i=0; i +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<() // 2011-03-05 366 1.0 Initial version // 2011-01-09 354 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RlinkCommandList.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommandList.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class RlinkCommandList. */ @@ -34,6 +35,7 @@ #include "RlinkCommandExpect.hpp" #include "RlinkCommand.hpp" +#include "RlinkContext.hpp" #include "RlinkAddrMap.hpp" namespace Retro { @@ -43,7 +45,7 @@ namespace Retro { RlinkCommandList(); RlinkCommandList(const RlinkCommandList&); - ~RlinkCommandList(); + ~RlinkCommandList(); size_t AddCommand(RlinkCommand* cmd); size_t AddCommand(const RlinkCommand& cmd); @@ -64,9 +66,9 @@ namespace Retro { void Clear(); size_t Size() const; - void Print(std::ostream& os, const RlinkAddrMap* pamap=0, - size_t abase=16, size_t dbase=16, - size_t sbase=16) const; + void Print(std::ostream& os, const RlinkContext& cntx, + const RlinkAddrMap* pamap=0, size_t abase=16, + size_t dbase=16, size_t sbase=16) const; void Dump(std::ostream& os, int ind=0, const char* text=0) const; RlinkCommandList& operator=(const RlinkCommandList& rhs); @@ -78,12 +80,8 @@ namespace Retro { std::vector fList; //!< vector of commands }; - std::ostream& operator<<(std::ostream& os, const RlinkCommandList& obj); - } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkCommandList_NoInline)) #include "RlinkCommandList.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkCommandList.ipp b/tools/src/librlink/RlinkCommandList.ipp index f6b07d6b..c96f54d0 100644 --- a/tools/src/librlink/RlinkCommandList.ipp +++ b/tools/src/librlink/RlinkCommandList.ipp @@ -1,6 +1,6 @@ -// $Id: RlinkCommandList.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkCommandList.ipp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,38 +13,27 @@ // // Revision History: // Date Rev Version Comment +// 2013-05-06 495 1.0.1 add RlinkContext to Print() args; drop oper<<() // 2011-03-05 366 1.0 Initial version // 2011-01-15 355 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkCommandList.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkCommandList.ipp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation (inline) of class RlinkCommandList. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs inline size_t RlinkCommandList::Size() const { return fList.size(); } -//------------------------------------------+----------------------------------- -/*! - \relates RlinkCommandList - \brief ostream insertion operator. -*/ - -inline std::ostream& operator<<(std::ostream& os, const RlinkCommandList& obj) -{ - obj.Print(os); - return os; -} - } // end namespace Retro diff --git a/tools/src/librlink/RlinkConnect.cpp b/tools/src/librlink/RlinkConnect.cpp index 99983858..a8ae2d05 100644 --- a/tools/src/librlink/RlinkConnect.cpp +++ b/tools/src/librlink/RlinkConnect.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkConnect.cpp 386 2011-07-01 17:31:03Z mueller $ +// $Id: RlinkConnect.cpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,12 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-01 493 1.3.1 add Server(Active..|SignalAttn)() methods +// 2013-02-23 492 1.3 use scoped_ptr for Port; Close allways allowed +// use RlinkContext, add Context(), Exec(..., cntx) +// 2013-02-22 491 1.2 use new RlogFile/RlogMsg interfaces +// 2013-02-03 481 1.1.2 use Rexception +// 2013-01-13 474 1.1.1 add PollAttn() method // 2011-04-25 380 1.1 use boost::(mutex&lock), implement Lockable IF // 2011-04-22 379 1.0.1 add Lock(), Unlock(), lock connect in Exec() // 2011-04-02 375 1.0 Initial version @@ -21,43 +27,49 @@ /*! \file - \version $Id: RlinkConnect.cpp 386 2011-07-01 17:31:03Z mueller $ + \version $Id: RlinkConnect.cpp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation of RlinkConnect. */ #include -#include #include "boost/thread/locks.hpp" -#include "RlinkConnect.hpp" #include "RlinkPortFactory.hpp" - #include "librtools/RosFill.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/RosPrintBvi.hpp" #include "librtools/Rtools.hpp" +#include "librtools/Rexception.hpp" +#include "librtools/RlogMsg.hpp" +#include "RlinkServer.hpp" + +#include "RlinkConnect.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkConnect \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor RlinkConnect::RlinkConnect() - : fpPort(0), + : fpPort(), + fpServ(0), fTxPkt(), fRxPkt(), + fContext(), fAddrMap(), fStats(), fLogOpts(), - fLogFile(&cout), - fMutexConn() + fspLog(new RlogFile(&cout, "")), + fConnectMutex() { for (size_t i=0; i<8; i++) fSeqNumber[i] = 0; @@ -94,7 +106,7 @@ RlinkConnect::RlinkConnect() RlinkConnect::~RlinkConnect() { - if (fpPort) Close(); + Close(); } //------------------------------------------+----------------------------------- @@ -102,12 +114,12 @@ RlinkConnect::~RlinkConnect() bool RlinkConnect::Open(const std::string& name, RerrMsg& emsg) { - if (fpPort) Close(); + Close(); - fpPort = RlinkPortFactory::Open(name, emsg); + fpPort.reset(RlinkPortFactory::Open(name, emsg)); if (!fpPort) return false; - fpPort->SetLogFile(&fLogFile); + fpPort->SetLogFile(fspLog); fpPort->SetTraceLevel(fLogOpts.tracelevel); return true; } @@ -117,16 +129,16 @@ bool RlinkConnect::Open(const std::string& name, RerrMsg& emsg) void RlinkConnect::Close() { - if (!fpPort) - throw logic_error("RlinkConnect::PortClose(): no port connected"); + if (!fpPort) return; - if (fpPort->UrlFindOpt("keep")) { + if (fpServ) fpServ->Stop(); // stop server in case still running + + if (fpPort->Url().FindOpt("keep")) { RerrMsg emsg; - fTxPkt.SndKeep(fpPort, emsg); + fTxPkt.SndKeep(fpPort.get(), emsg); } - delete fpPort; - fpPort = 0; + fpPort.reset(); return; } @@ -134,9 +146,42 @@ void RlinkConnect::Close() //------------------------------------------+----------------------------------- //! FIXME_docs +bool RlinkConnect::ServerActive() const +{ + return fpServ && fpServ->IsActive(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkConnect::ServerActiveInside() const +{ + return fpServ && fpServ->IsActiveInside(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkConnect::ServerActiveOutside() const +{ + return fpServ && fpServ->IsActiveOutside(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkConnect::ServerSignalAttn() +{ + if (fpServ) fpServ->SignalAttn(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + void RlinkConnect::lock() { - fMutexConn.lock(); + fConnectMutex.lock(); return; } @@ -145,7 +190,7 @@ void RlinkConnect::lock() bool RlinkConnect::try_lock() { - return fMutexConn.try_lock(); + return fConnectMutex.try_lock(); } //------------------------------------------+----------------------------------- @@ -153,19 +198,20 @@ bool RlinkConnect::try_lock() void RlinkConnect::unlock() { - fMutexConn.unlock(); + fConnectMutex.unlock(); return; } //------------------------------------------+----------------------------------- //! FIXME_docs -bool RlinkConnect::Exec(RlinkCommandList& clist, RerrMsg& emsg) +bool RlinkConnect::Exec(RlinkCommandList& clist, RlinkContext& cntx, + RerrMsg& emsg) { if (clist.Size() == 0) - throw invalid_argument("RlinkConnect::Exec(): clist empty"); + throw Rexception("RlinkConnect::Exec()", "Bad state: clist empty"); if (! IsOpen()) - throw logic_error("RlinkConnect::Exec(): port not open"); + throw Rexception("RlinkConnect::Exec()", "Bad state: port not open"); boost::lock_guard lock(*this); @@ -177,9 +223,16 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RerrMsg& emsg) for (size_t i=0; i RlinkCommand::kCmdInit) - throw invalid_argument("RlinkConnect::Exec(): invalid command code"); + throw Rexception("RlinkConnect::Exec()", + "BugCheck: invalid command code"); + // trap attn command when server running and outside server thread + if (cmd.Command() == RlinkCommand::kCmdAttn && ServerActiveOutside()) + throw Rexception("RlinkConnect::Exec()", + "attn command not allowed outside avtice server"); + cmd.ClearFlagBit(RlinkCommand::kFlagSend | RlinkCommand::kFlagDone | RlinkCommand::kFlagPktBeg | RlinkCommand::kFlagPktEnd | RlinkCommand::kFlagRecov | RlinkCommand::kFlagResend | @@ -196,7 +249,7 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RerrMsg& emsg) break; } } - bool rc = ExecPart(clist, ibeg, iend, emsg); + bool rc = ExecPart(clist, ibeg, iend, emsg, cntx); if (!rc) return rc; ibeg = iend+1; } @@ -207,36 +260,60 @@ bool RlinkConnect::Exec(RlinkCommandList& clist, RerrMsg& emsg) for (size_t i=0; iiend || iend>=clist.Size()) - throw invalid_argument("RlinkConnect::ExecPart(): ibeg or iend invalid"); + throw Rexception("RlinkConnect::ExecPart()", + "Bad args: ibeg or iend invalid"); if (!IsOpen()) - throw logic_error("RlinkConnect::ExecPart(): port not open"); + throw Rexception("RlinkConnect::ExecPart()","Bad state: port not open"); fStats.Inc(kStatNExecPart); @@ -305,7 +382,7 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, break; default: - throw logic_error("RlinkConnect::Exec(): invalid command"); + throw Rexception("RlinkConnect::Exec()", "BugCheck: invalid command"); } fTxPkt.PutCrc(); @@ -317,13 +394,23 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, clist[iend].SetFlagBit(RlinkCommand::kFlagPktEnd); // FIXME_code: handle send fail properly; - if (!fTxPkt.SndPacket(fpPort, emsg)) return false; + if (!fTxPkt.SndPacket(fpPort.get(), emsg)) return false; fStats.Inc(kStatNTxPktByt, double(fTxPkt.PktSize())); fStats.Inc(kStatNTxEsc , double(fTxPkt.Nesc())); fRxPkt.Init(); - // FIXME_code: handle timeout properly; parametrize timeout - if (!fRxPkt.RcvPacket(fpPort, nrcvtot, 1.0, emsg)) return false; + // FIXME_code: parametrize timeout + if (!fRxPkt.RcvPacket(fpPort.get(), nrcvtot, 5.0, emsg)) return false; + + // FIXME_code: handle timeout properly + if (fRxPkt.TestFlag(RlinkPacketBuf::kFlagTout)) { + emsg.Init("RlinkConnect::ExecPart", "timeout from RlinkPacketBuf"); + return false; + } + + // if attn seen, signal to server + if (fRxPkt.Nattn()) ServerSignalAttn(); + fStats.Inc(kStatNRxPktByt, double(fRxPkt.PktSize())); fStats.Inc(kStatNRxEsc , double(fRxPkt.Nesc())); fStats.Inc(kStatNRxAttn , double(fRxPkt.Nattn())); @@ -331,6 +418,7 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, fStats.Inc(kStatNRxDrop , double(fRxPkt.Ndrop())); size_t ncmd = 0; + const char* etxt = 0; for (size_t i=ibeg; i<=iend; i++) { RlinkCommand& cmd = clist[i]; @@ -340,11 +428,13 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, if (!fRxPkt.CheckSize(cmd.RcvSize())) { // not enough data for cmd cmd.SetFlagBit(RlinkCommand::kFlagErrMiss); + etxt = "FlagErrMiss: not enough data for cmd"; break; } if (fRxPkt.Get8WithCrc() != cmd.Request()) { // command mismatch cmd.SetFlagBit(RlinkCommand::kFlagErrCmd); + etxt = "FlagErrCmd: command mismatch"; break; } @@ -352,6 +442,7 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, if (ccode == RlinkCommand::kCmdRblk) { if (fRxPkt.Get8WithCrc() != (uint8_t)(ndata-1)) { // length mismatch cmd.SetFlagBit(RlinkCommand::kFlagErrCmd); + etxt = "FlagErrCmd: length mismatch"; break; } } @@ -381,12 +472,13 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, case RlinkCommand::kCmdInit: break; - } + } // switch(ccode) cmd.SetStatus(fRxPkt.Get8WithCrc()); if (!fRxPkt.CheckCrc()) { // crc mismatch cmd.SetFlagBit(RlinkCommand::kFlagErrCrc); //fStats.Inc(kStatNRxCcrc); + etxt = "FlagErrCrc: crc mismatch"; break; } @@ -402,7 +494,7 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, cmd.SetFlagBit(RlinkCommand::kFlagDone); ncmd += 1; - if (cmd.Expect()) { + if (cmd.Expect()) { // expect object attached ? RlinkCommandExpect& expect = *cmd.Expect(); if (expect.DataIsChecked() || expect.BlockValue().size()>0) fStats.Inc(kStatNExpData); @@ -425,12 +517,20 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, fStats.Inc(kStatNChkStat); cmd.SetFlagBit(RlinkCommand::kFlagChkStat); } + + } else { // no expect, use context + if (!cntx.StatusCheck(cmd.Status())) { + fStats.Inc(kStatNChkStat); + cmd.SetFlagBit(RlinkCommand::kFlagChkStat); + } } } // FIXME_code: add proper error handling... if (ncmd != iend-ibeg+1) { + if (etxt == 0) etxt = "not all commands processed"; + emsg.Init("RlinkConnect::ExecPart", etxt); return false; } @@ -442,7 +542,27 @@ bool RlinkConnect::ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, double RlinkConnect::WaitAttn(double timeout, RerrMsg& emsg) { - double rval = fRxPkt.WaitAttn(fpPort, timeout, emsg); + if (ServerActiveOutside()) + throw Rexception("RlinkConnect::WaitAttn()", + "not allowed outside avtice server"); + + double rval = fRxPkt.WaitAttn(fpPort.get(), timeout, emsg); + fStats.Inc(kStatNRxAttn , double(fRxPkt.Nattn())); + fStats.Inc(kStatNRxIdle , double(fRxPkt.Nidle())); + fStats.Inc(kStatNRxDrop , double(fRxPkt.Ndrop())); + return rval; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RlinkConnect::PollAttn(RerrMsg& emsg) +{ + if (ServerActiveOutside()) + throw Rexception("RlinkConnect::PollAttn()", + "not allowed outside avtice server"); + + int rval = fRxPkt.PollAttn(fpPort.get(), emsg); fStats.Inc(kStatNRxAttn , double(fRxPkt.Nattn())); fStats.Inc(kStatNRxIdle , double(fRxPkt.Nidle())); fStats.Inc(kStatNRxDrop , double(fRxPkt.Ndrop())); @@ -455,28 +575,7 @@ double RlinkConnect::WaitAttn(double timeout, RerrMsg& emsg) bool RlinkConnect::SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg) { fStats.Inc(kStatNSndOob); - return fTxPkt.SndOob(fpPort, addr, data, emsg); -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - -bool RlinkConnect::LogOpen(const std::string& name) -{ - if (!fLogFile.Open(name)) { - fLogFile.UseStream(&cout); - return false; - } - return true; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - -void RlinkConnect::LogUseStream(std::ostream* pstr) -{ - fLogFile.UseStream(pstr); - return; + return fTxPkt.SndOob(fpPort.get(), addr, data, emsg); } //------------------------------------------+----------------------------------- @@ -485,11 +584,14 @@ void RlinkConnect::LogUseStream(std::ostream* pstr) void RlinkConnect::SetLogOpts(const LogOpts& opts) { if (opts.baseaddr!=2 && opts.baseaddr!=8 && opts.baseaddr!=16) - throw invalid_argument("RlinkConnect::SetLogOpts(): baseaddr != 2,8,16"); + throw Rexception("RlinkConnect::SetLogOpts()", + "Bad args: baseaddr != 2,8,16"); if (opts.basedata!=2 && opts.basedata!=8 && opts.basedata!=16) - throw invalid_argument("RlinkConnect::SetLogOpts(): basedata != 2,8,16"); + throw Rexception("RlinkConnect::SetLogOpts()", + "Bad args: basedata != 2,8,16"); if (opts.basestat!=2 && opts.basestat!=8 && opts.basestat!=16) - throw invalid_argument("RlinkConnect::SetLogOpts(): basestat != 2,8,16"); + throw Rexception("RlinkConnect::SetLogOpts()", + "Bad args: basestat != 2,8,16"); fLogOpts = opts; if (fpPort) fpPort->SetTraceLevel(opts.tracelevel); @@ -499,6 +601,27 @@ void RlinkConnect::SetLogOpts(const LogOpts& opts) //------------------------------------------+----------------------------------- //! FIXME_docs +bool RlinkConnect::LogOpen(const std::string& name) +{ + if (!fspLog->Open(name)) { + fspLog->UseStream(&cout, ""); + return false; + } + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkConnect::LogUseStream(std::ostream* pstr, const std::string& name) +{ + fspLog->UseStream(pstr, name); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + void RlinkConnect::Print(std::ostream& os) const { os << "RlinkConnect::Print(std::ostream& os)" << endl; @@ -516,23 +639,27 @@ void RlinkConnect::Dump(std::ostream& os, int ind, const char* text) const if (fpPort) { fpPort->Dump(os, ind+2, "fpPort: "); } else { - os << bl << " fpPort: " << fpPort << endl; + os << bl << " fpPort: " << fpPort.get() << endl; } + os << bl << " fpServ: " << fpServ << endl; os << bl << " fSeqNumber: "; for (size_t i=0; i<8; i++) os << RosPrintBvi(fSeqNumber[i],16) << " "; os << endl; fTxPkt.Dump(os, ind+2, "fTxPkt: "); fRxPkt.Dump(os, ind+2, "fRxPkt: "); + fContext.Dump(os, ind+2, "fContext: "); fAddrMap.Dump(os, ind+2, "fAddrMap: "); fStats.Dump(os, ind+2, "fStats: "); + os << bl << " fLogOpts.baseaddr " << fLogOpts.baseaddr << endl; + os << bl << " .basedata " << fLogOpts.basedata << endl; + os << bl << " .basestat " << fLogOpts.basestat << endl; + os << bl << " .printlevel " << fLogOpts.printlevel << endl; + os << bl << " .dumplevel " << fLogOpts.dumplevel << endl; + os << bl << " .tracelevel " << fLogOpts.tracelevel << endl; + fspLog->Dump(os, ind+2, "fspLog: "); return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkConnect_NoInline)) -#define inline -#include "RlinkConnect.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkConnect.hpp b/tools/src/librlink/RlinkConnect.hpp index ee897f5a..bf941ef5 100644 --- a/tools/src/librlink/RlinkConnect.hpp +++ b/tools/src/librlink/RlinkConnect.hpp @@ -1,6 +1,6 @@ -// $Id: RlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RlinkConnect.hpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,13 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-05 495 1.3.2 add Exec() without emsg (will send emsg to LogFile) +// 2013-03-01 493 1.3.1 add Server(Active..|SignalAttn)() methods +// 2013-02-23 492 1.3 use scoped_ptr for Port; Close allways allowed +// use RlinkContext, add Context(), Exec(..., cntx) +// 2013-02-22 491 1.2 use new RlogFile/RlogMsg interfaces +// 2013-02-03 481 1.1.3 add SetServer(),Server() +// 2013-01-13 474 1.1.2 add PollAttn() method // 2011-11-28 434 1.1.1 struct LogOpts: use uint32_t for lp64 compatibility // 2011-04-24 380 1.1 use boost::noncopyable (instead of private dcl's); // use boost::(mutex&lock), implement Lockable IF @@ -21,10 +28,9 @@ // 2011-01-15 356 0.1 First draft // --------------------------------------------------------------------------- - /*! \file - \version $Id: RlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RlinkConnect.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class \c RlinkConnect. */ @@ -38,6 +44,8 @@ #include "boost/utility.hpp" #include "boost/thread/recursive_mutex.hpp" +#include "boost/shared_ptr.hpp" +#include "boost/scoped_ptr.hpp" #include "librtools/RerrMsg.hpp" #include "librtools/Rstats.hpp" @@ -47,9 +55,12 @@ #include "RlinkCommandList.hpp" #include "RlinkPacketBuf.hpp" #include "RlinkAddrMap.hpp" +#include "RlinkContext.hpp" namespace Retro { + class RlinkServer; // forw decl to avoid circular incl + class RlinkConnect : private boost::noncopyable { public: struct LogOpts { @@ -67,21 +78,35 @@ namespace Retro { }; RlinkConnect(); - ~RlinkConnect(); + ~RlinkConnect(); bool Open(const std::string& name, RerrMsg& emsg); void Close(); bool IsOpen() const; RlinkPort* Port() const; + RlinkContext& Context(); + + void SetServer(RlinkServer* pserv); + RlinkServer* Server() const; + bool ServerActive() const; + bool ServerActiveInside() const; + bool ServerActiveOutside() const; + void ServerSignalAttn(); + // provide boost Lockable interface void lock(); bool try_lock(); void unlock(); bool Exec(RlinkCommandList& clist, RerrMsg& emsg); + bool Exec(RlinkCommandList& clist, RlinkContext& cntx, + RerrMsg& emsg); + bool Exec(RlinkCommandList& clist); + bool Exec(RlinkCommandList& clist, RlinkContext& cntx); double WaitAttn(double timeout, RerrMsg& emsg); + int PollAttn(RerrMsg& emsg); bool SndOob(uint16_t addr, uint16_t data, RerrMsg& emsg); bool AddrMapInsert(const std::string& name, uint16_t addr); @@ -92,11 +117,14 @@ namespace Retro { const RlinkAddrMap& AddrMap() const; const Rstats& Stats() const; - bool LogOpen(const std::string& name); - void LogUseStream(std::ostream* pstr); void SetLogOpts(const LogOpts& opts); const LogOpts& GetLogOpts() const; + + bool LogOpen(const std::string& name); + void LogUseStream(std::ostream* pstr, + const std::string& name = ""); RlogFile& LogFile() const; + const boost::shared_ptr& LogFileSPtr() const; void Print(std::ostream& os) const; void Dump(std::ostream& os, int ind=0, const char* text=0) const; @@ -133,24 +161,24 @@ namespace Retro { protected: bool ExecPart(RlinkCommandList& clist, size_t ibeg, size_t iend, - RerrMsg& emsg); + RerrMsg& emsg, RlinkContext& cntx); protected: - RlinkPort* fpPort; //!< ptr to port + boost::scoped_ptr fpPort; //!< ptr to port + RlinkServer* fpServ; //!< ptr to server (optional) uint8_t fSeqNumber[8]; //!< command sequence number RlinkPacketBuf fTxPkt; //!< transmit packet buffer RlinkPacketBuf fRxPkt; //!< receive packet buffer + RlinkContext fContext; //!< default context RlinkAddrMap fAddrMap; //!< name<->address mapping Rstats fStats; //!< statistics LogOpts fLogOpts; //!< log options - RlogFile fLogFile; //!< connection log file - boost::recursive_mutex fMutexConn; //!< mutex to lock whole connect + boost::shared_ptr fspLog; //!< log file ptr + boost::recursive_mutex fConnectMutex; //!< mutex to lock whole connect }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkConnect_NoInline)) #include "RlinkConnect.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkConnect.ipp b/tools/src/librlink/RlinkConnect.ipp index 3a4a003e..5ee6eae0 100644 --- a/tools/src/librlink/RlinkConnect.ipp +++ b/tools/src/librlink/RlinkConnect.ipp @@ -1,6 +1,6 @@ -// $Id: RlinkConnect.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkConnect.ipp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,17 +13,22 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-05 495 1.2.1 add Exec() without emsg (will send emsg to LogFile) +// 2013-02-23 492 1.2 use scoped_ptr for Port; Close allways allowed +// use RlinkContext, add Context(), Exec(..., cntx) +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-02-03 481 1.0.1 add SetServer(),Server() // 2011-04-02 375 1.0 Initial version // 2011-01-15 356 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkConnect.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkConnect.ipp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation (inline) of RlinkConnect. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- @@ -39,7 +44,46 @@ inline bool RlinkConnect::IsOpen() const inline RlinkPort* RlinkConnect::Port() const { - return fpPort; + return fpPort.get(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkContext& RlinkConnect::Context() +{ + return fContext; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlinkConnect::SetServer(RlinkServer* pserv) +{ + fpServ = pserv; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer* RlinkConnect::Server() const +{ + return fpServ; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs +inline bool RlinkConnect::Exec(RlinkCommandList& clist, RerrMsg& emsg) +{ + return Exec(clist, fContext, emsg); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs +inline bool RlinkConnect::Exec(RlinkCommandList& clist) +{ + return Exec(clist, fContext); } //------------------------------------------+----------------------------------- @@ -103,7 +147,15 @@ inline const RlinkConnect::LogOpts& RlinkConnect::GetLogOpts() const inline RlogFile& RlinkConnect::LogFile() const { - return (RlogFile&)fLogFile; + return *fspLog; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const boost::shared_ptr& RlinkConnect::LogFileSPtr() const +{ + return fspLog; } diff --git a/tools/src/librlink/RlinkContext.cpp b/tools/src/librlink/RlinkContext.cpp new file mode 100644 index 00000000..63bbde62 --- /dev/null +++ b/tools/src/librlink/RlinkContext.cpp @@ -0,0 +1,70 @@ +// $Id: RlinkContext.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkContext.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of class RlinkContext. + */ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosPrintBvi.hpp" + +#include "RlinkContext.hpp" + +using namespace std; + +/*! + \class Retro::RlinkContext + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlinkContext::RlinkContext() + : fStatusVal(0), + fStatusMsk(0xff), + fErrCnt(0) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlinkContext::~RlinkContext() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkContext::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "RlinkContext @ " << this << endl; + + os << bl << " fStatusVal: " << RosPrintBvi(fStatusVal,0) << endl; + os << bl << " fStatusMsk: " << RosPrintBvi(fStatusMsk,0) << endl; + os << bl << " fErrCnt: " << RosPrintf((int)fErrCnt,"d") << endl; + return; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkContext.hpp b/tools/src/librlink/RlinkContext.hpp new file mode 100644 index 00000000..6734364b --- /dev/null +++ b/tools/src/librlink/RlinkContext.hpp @@ -0,0 +1,62 @@ +// $Id: RlinkContext.hpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RlinkContext.hpp 492 2013-02-24 22:14:47Z mueller $ + \brief Declaration of class RlinkContext. +*/ + +#ifndef included_Retro_RlinkContext +#define included_Retro_RlinkContext 1 + +#include + +namespace Retro { + + class RlinkContext { + public: + RlinkContext(); + ~RlinkContext(); + + void SetStatus(uint8_t stat, uint8_t statmsk=0); + + uint8_t StatusValue() const; + uint8_t StatusMask() const; + + bool StatusIsChecked() const; + bool StatusCheck(uint8_t val) const; + + void IncErrorCount(size_t inc = 1); + void ClearErrorCount(); + size_t ErrorCount() const; + + void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + uint8_t fStatusVal; //!< status value + uint8_t fStatusMsk; //!< status mask + size_t fErrCnt; //!< error count + }; + +} // end namespace Retro + +#include "RlinkContext.ipp" + +#endif diff --git a/tools/src/librlink/RlinkContext.ipp b/tools/src/librlink/RlinkContext.ipp new file mode 100644 index 00000000..43f28b00 --- /dev/null +++ b/tools/src/librlink/RlinkContext.ipp @@ -0,0 +1,96 @@ +// $Id: RlinkContext.ipp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkContext.ipp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation (inline) of class RlinkContext. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlinkContext::SetStatus(uint8_t stat, uint8_t statmsk) +{ + fStatusVal = stat; + fStatusMsk = statmsk; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint8_t RlinkContext::StatusValue() const +{ + return fStatusVal; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint8_t RlinkContext::StatusMask() const +{ + return fStatusMsk; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkContext::StatusIsChecked() const +{ + return fStatusMsk != 0xff; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkContext::StatusCheck(uint8_t val) const +{ + return (val|fStatusMsk) == (fStatusVal|fStatusMsk); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlinkContext::IncErrorCount(size_t inc) +{ + fErrCnt += inc; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlinkContext::ClearErrorCount() +{ + fErrCnt = 0; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t RlinkContext::ErrorCount() const +{ + return fErrCnt; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkCrc8.cpp b/tools/src/librlink/RlinkCrc8.cpp index 9f20b2ca..a82fa4e1 100644 --- a/tools/src/librlink/RlinkCrc8.cpp +++ b/tools/src/librlink/RlinkCrc8.cpp @@ -1,4 +1,4 @@ -// $Id: RlinkCrc8.cpp 410 2011-09-18 11:23:09Z mueller $ +// $Id: RlinkCrc8.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,20 +20,22 @@ /*! \file - \version $Id: RlinkCrc8.cpp 410 2011-09-18 11:23:09Z mueller $ + \version $Id: RlinkCrc8.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of class RlinkCrc8. */ #include "RlinkCrc8.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkCrc8 - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! FIXME_docs // from gen_crc8_tbl @@ -74,9 +76,4 @@ const uint8_t RlinkCrc8::fCrc8Table[256] = 6, 75, 156, 209, 127, 50, 229, 168 }; -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkCrc8_NoInline)) -#define inline -#include "RlinkCrc8.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkCrc8.hpp b/tools/src/librlink/RlinkCrc8.hpp index 880fd7f2..4f909fa4 100644 --- a/tools/src/librlink/RlinkCrc8.hpp +++ b/tools/src/librlink/RlinkCrc8.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkCrc8.hpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RlinkCrc8.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RlinkCrc8.hpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RlinkCrc8.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class \c RlinkCrc8. */ @@ -49,8 +49,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkCrc8_NoInline)) #include "RlinkCrc8.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkCrc8.ipp b/tools/src/librlink/RlinkCrc8.ipp index f463f9d9..bfca72f6 100644 --- a/tools/src/librlink/RlinkCrc8.ipp +++ b/tools/src/librlink/RlinkCrc8.ipp @@ -1,4 +1,4 @@ -// $Id: RlinkCrc8.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RlinkCrc8.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RlinkCrc8.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RlinkCrc8.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of class RlinkCrc8. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librlink/RlinkPacketBuf.cpp b/tools/src/librlink/RlinkPacketBuf.cpp index a4e2a4ac..854c13b3 100644 --- a/tools/src/librlink/RlinkPacketBuf.cpp +++ b/tools/src/librlink/RlinkPacketBuf.cpp @@ -1,4 +1,4 @@ -// $Id: RlinkPacketBuf.cpp 469 2013-01-05 12:29:44Z mueller $ +// $Id: RlinkPacketBuf.cpp 492 2013-02-24 22:14:47Z mueller $ // // Copyright 2011-2013 by Walter F.J. Mueller // @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.3 use Rexception +// 2013-01-13 474 1.0.2 add PollAttn() method // 2013-01-04 469 1.0.1 SndOob(): Add filler 0 to ensure escape state // 2011-04-02 375 1.0 Initial version // 2011-03-05 366 0.1 First draft @@ -20,7 +22,7 @@ /*! \file - \version $Id: RlinkPacketBuf.cpp 469 2013-01-05 12:29:44Z mueller $ + \version $Id: RlinkPacketBuf.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of class RlinkPacketBuf. */ @@ -29,22 +31,23 @@ // debug #include -#include - #include "RlinkPacketBuf.hpp" #include "librtools/RosFill.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/RosPrintBvi.hpp" +#include "librtools/Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkPacketBuf \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- // constants definitions @@ -150,7 +153,8 @@ bool RlinkPacketBuf::RcvPacket(RlinkPort* port, size_t nrcv, float timeout, while (!(eopseen|nakseen)) { // try till eop or nak received size_t nread = nrcv - fPktBuf.size(); // FIXME_code: if the 'enough data' handling below correct ? - if (nread < 0) return true; + if (nread < 0) return true; + if (!sopseen) nread += 1; if (!eopseen) nread += 1; @@ -202,8 +206,9 @@ bool RlinkPacketBuf::RcvPacket(RlinkPort* port, size_t nrcv, float timeout, fNdrop += 1; } } - } - } + } // for (int i=0; iIsOpen()) - throw logic_error("RlinkPacketBuf::SndRaw(): port not open"); + throw Rexception("RlinkPacketBuf::SndRaw()", "Bad state: port not open"); fRawBufSize = fRawBuf.size(); int irc = port->Write(fRawBuf.data(), fRawBuf.size(), emsg); @@ -352,7 +391,7 @@ int RlinkPacketBuf::RcvRaw(RlinkPort* port, size_t size, float timeout, RerrMsg& emsg) { if (port==0 || !port->IsOpen()) - throw logic_error("RlinkPacketBuf::RcvRaw(): port not open"); + throw Rexception("RlinkPacketBuf::RcvRaw()", "Bad state: port not open"); if (fRawBuf.size() < fRawBufSize+size) fRawBuf.resize(fRawBufSize+size); int irc = port->Read(fRawBuf.data()+fRawBufSize, size, timeout, emsg); @@ -367,9 +406,4 @@ int RlinkPacketBuf::RcvRaw(RlinkPort* port, size_t size, float timeout, return irc; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPacketBuf_NoInline)) -#define inline -#include "RlinkPacketBuf.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPacketBuf.hpp b/tools/src/librlink/RlinkPacketBuf.hpp index 4752b8c0..3222400d 100644 --- a/tools/src/librlink/RlinkPacketBuf.hpp +++ b/tools/src/librlink/RlinkPacketBuf.hpp @@ -1,6 +1,6 @@ -// $Id: RlinkPacketBuf.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkPacketBuf.hpp 486 2013-02-10 22:34:43Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-13 474 1.0.1 add PollAttn() method // 2011-04-02 375 1.0 Initial version // 2011-03-05 366 0.1 First draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RlinkPacketBuf.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkPacketBuf.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RlinkPacketBuf. */ @@ -52,6 +53,7 @@ namespace Retro { RerrMsg& emsg); double WaitAttn(RlinkPort* port, double timeout, RerrMsg& emsg); + int PollAttn(RlinkPort* port, RerrMsg& emsg); bool SndOob(RlinkPort* port, uint16_t addr, uint16_t data, RerrMsg& emsg); bool SndKeep(RlinkPort* port, RerrMsg& emsg); @@ -73,7 +75,7 @@ namespace Retro { void Dump(std::ostream& os, int ind=0, const char* text=0) const; - // flag bits + // flag bits (also defined in cpp) static const uint32_t kFlagSopSeen = 1<<0; //!< sop was seen static const uint32_t kFlagEopSeen = 1<<1; //!< eop was seen static const uint32_t kFlagNakSeen = 1<<2; //!< nak was seen @@ -82,7 +84,7 @@ namespace Retro { static const uint32_t kFlagDatDrop = 1<<17; //!< data before sop dropped static const uint32_t kFlagDatMiss = 1<<18; //!< eop before expected data - // some constants + // some constants (also defined in cpp) static const uint8_t kCPREF = 0x80; //!< VHDL def for comma prefix static const uint8_t kNCOMM = 0x04; //!< VHDL def for number of commas static const uint8_t kCommaIdle = kCPREF+0; //!< IDLE comma @@ -115,8 +117,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkPacketBuf_NoInline)) #include "RlinkPacketBuf.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkPacketBuf.ipp b/tools/src/librlink/RlinkPacketBuf.ipp index 4a49213c..30fa0b2b 100644 --- a/tools/src/librlink/RlinkPacketBuf.ipp +++ b/tools/src/librlink/RlinkPacketBuf.ipp @@ -1,4 +1,4 @@ -// $Id: RlinkPacketBuf.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RlinkPacketBuf.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of class RlinkPacketBuf. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librlink/RlinkPort.cpp b/tools/src/librlink/RlinkPort.cpp index 21382389..f12e2efe 100644 --- a/tools/src/librlink/RlinkPort.cpp +++ b/tools/src/librlink/RlinkPort.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkPort.cpp 466 2012-12-30 13:26:55Z mueller $ +// $Id: RlinkPort.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,11 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.2 use RparseUrl +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-02-10 485 1.0.5 add static const defs +// 2013-02-03 481 1.0.4 use Rexception +// 2013-01-27 477 1.0.3 add RawRead(),RawWrite() methods // 2012-12-28 466 1.0.2 allow Close() even when not open // 2012-12-26 465 1.0.1 add CloseFd() method // 2011-03-27 375 1.0 Initial version @@ -21,50 +26,60 @@ /*! \file - \version $Id: RlinkPort.cpp 466 2012-12-30 13:26:55Z mueller $ + \version $Id: RlinkPort.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RlinkPort. */ #include #include #include +#include -#include #include -#include "RlinkPort.hpp" - #include "librtools/RosFill.hpp" #include "librtools/RosPrintf.hpp" #include "librtools/RosPrintBvi.hpp" +#include "librtools/Rexception.hpp" +#include "librtools/RlogMsg.hpp" + +#include "RlinkPort.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkPort \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const int RlinkPort::kEof; +const int RlinkPort::kTout; +const int RlinkPort::kErr; + //------------------------------------------+----------------------------------- //! Default constructor RlinkPort::RlinkPort() : fIsOpen(false), fUrl(), - fScheme(), - fPath(), - fOptMap(), fFdRead(-1), fFdWrite(-1), - fpLogFile(0), + fspLog(), fTraceLevel(0), fStats() { - fStats.Define(kStatNPortWrite, "NPortWrite", "Port::Write() calls"); - fStats.Define(kStatNPortRead, "NPortRead", "Port::Read() calls"); - fStats.Define(kStatNPortTxByt, "NPortTxByt", "Port Tx raw bytes send"); - fStats.Define(kStatNPortRxByt, "NPortRxByt", "Port Rx raw bytes rcvd"); + fStats.Define(kStatNPortWrite, "NPortWrite", "Port::Write() calls"); + fStats.Define(kStatNPortRead, "NPortRead", "Port::Read() calls"); + fStats.Define(kStatNPortTxByt, "NPortTxByt", "Port Tx bytes send"); + fStats.Define(kStatNPortRxByt, "NPortRxByt", "Port Rx bytes rcvd"); + fStats.Define(kStatNPortRawWrite, "NPortRawWrite", "Port::RawWrite() calls"); + fStats.Define(kStatNPortRawRead, "NPortRawRead", "Port::RawRead() calls"); } //------------------------------------------+----------------------------------- @@ -87,10 +102,7 @@ void RlinkPort::Close() CloseFd(fFdRead); fIsOpen = false; - fUrl.clear(); - fScheme.clear(); - fPath.clear(); - fOptMap.clear(); + fUrl.Clear(); return; } @@ -101,11 +113,11 @@ void RlinkPort::Close() int RlinkPort::Read(uint8_t* buf, size_t size, double timeout, RerrMsg& emsg) { if (!IsOpen()) - throw logic_error("RlinkPort::Read(): port not open"); + throw Rexception("RlinkPort::Read()","Bad state: port not open"); if (buf == 0) - throw invalid_argument("RlinkPort::Read(): buf==NULL"); + throw Rexception("RlinkPort::Read()","Bad args: buf==NULL"); if (size == 0) - throw invalid_argument("RlinkPort::Read(): size==0"); + throw Rexception("RlinkPort::Read()","Bad args: size==0"); fStats.Inc(kStatNPortRead); @@ -117,22 +129,21 @@ int RlinkPort::Read(uint8_t* buf, size_t size, double timeout, RerrMsg& emsg) irc = read(fFdRead, (void*) buf, size); if (irc < 0 && errno != EINTR) { emsg.InitErrno("RlinkPort::Read()", "read() failed : ", errno); - if (fpLogFile && fTraceLevel>0) (*fpLogFile)('E') << emsg << endl; + if (fspLog && fTraceLevel>0) fspLog->Write(emsg.Message(), 'E'); return kErr; } } - if (fpLogFile && fTraceLevel>0) { - ostream& os = (*fpLogFile)(); - (*fpLogFile)('I') << "port read nchar=" << RosPrintf(irc,"d",4); + if (fspLog && fTraceLevel>0) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "port read nchar=" << RosPrintf(irc,"d",4); if (fTraceLevel>1) { size_t ncol = (80-5-6)/(2+1); for (int i=0; i0) { - ostream& os = (*fpLogFile)(); - (*fpLogFile)('I') << "port write nchar=" << RosPrintf(size,"d",4); + if (fspLog && fTraceLevel>0) { + RlogMsg lmsg(*fspLog, 'I'); + lmsg << "port write nchar=" << RosPrintf(size,"d",4); if (fTraceLevel>1) { size_t ncol = (80-5-6)/(2+1); for (size_t i=0; i0) (*fpLogFile)('E') << emsg << endl; + if (fspLog && fTraceLevel>0) fspLog->Write(emsg.Message(), 'E'); return kErr; } } @@ -193,9 +203,9 @@ int RlinkPort::Write(const uint8_t* buf, size_t size, RerrMsg& emsg) bool RlinkPort::PollRead(double timeout) { if (! IsOpen()) - throw logic_error("RlinkPort::PollRead(): port not open"); + throw Rexception("RlinkPort::PollRead()","Bad state: port not open"); if (timeout < 0.) - throw invalid_argument("RlinkPort::PollRead(): timeout < 0"); + throw Rexception("RlinkPort::PollRead()","Bad args: timeout < 0"); int ito = 1000.*timeout + 0.1; @@ -208,38 +218,57 @@ bool RlinkPort::PollRead(double timeout) while (irc < 0) { irc = poll(fds, 1, ito); if (irc < 0 && errno != EINTR) - throw logic_error("RlinkPort::PollRead(): poll failed: rc<0"); + throw Rexception("RlinkPort::PollRead()","poll() failed: rc<0: ", errno); } if (irc == 0) return false; if (fds[0].revents == POLLERR) - throw logic_error("RlinkPort::PollRead(): poll failed: POLLERR"); + throw Rexception("RlinkPort::PollRead()", "poll() failed: POLLERR"); return true; } //------------------------------------------+----------------------------------- //! FIXME_docs - -bool RlinkPort::UrlFindOpt(const std::string& name) const +int RlinkPort::RawRead(uint8_t* buf, size_t size, bool exactsize, + double timeout, double& tused, RerrMsg& emsg) { - omap_cit_t it = fOptMap.find(name); - if (it == fOptMap.end()) return false; - return true; -} + if (timeout <= 0.) + throw Rexception("RlinkPort::RawRead()", "Bad args: timeout <= 0."); + if (size <= 0) + throw Rexception("RlinkPort::RawRead()", "Bad args: size <= 0"); -//------------------------------------------+----------------------------------- -//! FIXME_docs + fStats.Inc(kStatNPortRawRead); + tused = 0.; -bool RlinkPort::UrlFindOpt(const std::string& name, std::string& value) const -{ - omap_cit_t it = fOptMap.find(name); - if (it == fOptMap.end()) return false; + struct timeval tval; + gettimeofday(&tval, 0); + double tbeg = double(tval.tv_sec) + 1.e-6*double(tval.tv_usec); + double trest = timeout; - value = it->second; + size_t ndone = 0; + while (trest>0. && ndonefirst).c_str(), "-s",8) - << " : " << it->second << endl; - } + fUrl.Dump(os, ind+2, "fUrl: "); os << bl << " fFdRead: " << fFdRead << endl; os << bl << " fFdWrite: " << fFdWrite << endl; + os << bl << " fspLog: " << fspLog.get() << endl; + os << bl << " fTraceLevel: " << fTraceLevel << endl; fStats.Dump(os, ind+2, "fStats: "); return; } @@ -268,99 +292,6 @@ void RlinkPort::Dump(std::ostream& os, int ind, const char* text) const //------------------------------------------+----------------------------------- //! FIXME_docs -bool RlinkPort::ParseUrl(const std::string& url, const std::string& optlist, - RerrMsg& emsg) -{ - fUrl.clear(); - fScheme.clear(); - fPath.clear(); - fOptMap.clear(); - - size_t pdel = url.find_first_of(':'); - if (pdel == string::npos) { - emsg.Init("RlinkPort::ParseUrl()", - string("no scheme specified in url \"") + url + string("\"")); - return false; - } - - fUrl = url; - fScheme = url.substr(0, pdel); - - size_t odel = url.find_first_of('?', pdel); - if (odel == string::npos) { // no options - if (url.length() > pdel+1) fPath = url.substr(pdel+1); - - } else { // options to process - fPath = url.substr(pdel+1,odel-(pdel+1)); - string key; - string val; - bool hasval = false; - - for (size_t i=odel+1; i= url.length()) { - emsg.Init("RlinkPort::ParseUrl()", - string("invalid trailing \\ in url \"") + url + - string("\"")); - return false; - } - i += 1; - switch (url[i]) { - case '\\' : c = '\\'; break; - case ';' : c = ';'; break; - default : emsg.Init("RlinkPort::ParseUrl()", - string("invalid \\ escape in url \"") + - url + string("\"")); - return false; - } - } - val.push_back(c); - } - } - } - if (key.length() || hasval) { - if (!AddOpt(key, val, hasval, optlist, emsg)) return false; - } - } - - return true; -} -// -//------------------------------------------+----------------------------------- -//! FIXME_docs - -bool RlinkPort::AddOpt(const std::string& key, const std::string& val, - bool hasval, const std::string& optlist, RerrMsg& emsg) -{ - string lkey = "|"; - lkey += key; - if (hasval) lkey += "="; - lkey += "|"; - if (optlist.find(lkey) == string::npos) { - emsg.Init("RlinkPort::AddOpt()", - string("invalid field name \"") + lkey + string("\"")); - } - - fOptMap.insert(omap_val_t(key, hasval ? val : "1")); - return true; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - void RlinkPort::CloseFd(int& fd) { if (fd >= 0) { @@ -370,9 +301,4 @@ void RlinkPort::CloseFd(int& fd) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline)) -#define inline -#include "RlinkPort.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPort.hpp b/tools/src/librlink/RlinkPort.hpp index c1091a3a..c208b0ed 100644 --- a/tools/src/librlink/RlinkPort.hpp +++ b/tools/src/librlink/RlinkPort.hpp @@ -1,6 +1,6 @@ -// $Id: RlinkPort.hpp 465 2012-12-27 21:29:38Z mueller $ +// $Id: RlinkPort.hpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,9 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.2 use RparseUrl +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-01-27 477 1.0.3 add RawRead(),RawWrite() methods // 2012-12-26 465 1.0.2 add CloseFd() method // 2011-04-24 380 1.0.1 use boost::noncopyable (instead of private dcl's) // 2011-03-27 375 1.0 Initial version @@ -22,7 +25,7 @@ /*! \file - \version $Id: RlinkPort.hpp 465 2012-12-27 21:29:38Z mueller $ + \version $Id: RlinkPort.hpp 492 2013-02-24 22:14:47Z mueller $ \brief Declaration of class RlinkPort. */ @@ -37,18 +40,14 @@ #include "librtools/RerrMsg.hpp" #include "librtools/RlogFile.hpp" #include "librtools/Rstats.hpp" +#include "librtools/RparseUrl.hpp" namespace Retro { class RlinkPort : private boost::noncopyable { public: - typedef std::map omap_t; - typedef omap_t::iterator omap_it_t; - typedef omap_t::const_iterator omap_cit_t; - typedef omap_t::value_type omap_val_t; - RlinkPort(); - virtual ~RlinkPort(); + virtual ~RlinkPort(); virtual bool Open(const std::string& url, RerrMsg& emsg) = 0; virtual void Close(); @@ -58,19 +57,18 @@ namespace Retro { virtual int Write(const uint8_t* buf, size_t size, RerrMsg& emsg); virtual bool PollRead(double timeout); + int RawRead(uint8_t* buf, size_t size, bool exactsize, + double timeout, double& tused, RerrMsg& emsg); + int RawWrite(const uint8_t* buf, size_t size, RerrMsg& emsg); + bool IsOpen() const; - const std::string& Url() const; - const std::string& UrlScheme() const; - const std::string& UrlPath() const; - const omap_t& UrlOpts() const; - bool UrlFindOpt(const std::string& name) const; - bool UrlFindOpt(const std::string& name, - std::string& value) const; + + const RparseUrl& Url() const; int FdRead() const; int FdWrite() const; - void SetLogFile(RlogFile* log); + void SetLogFile(const boost::shared_ptr& splog); void SetTraceLevel(size_t level); size_t TraceLevel() const; @@ -78,10 +76,10 @@ namespace Retro { virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; - // some constants - static const int kEof = 0; - static const int kTout = -1; - static const int kErr = -2; + // some constants (also defined in cpp) + static const int kEof = 0; // fspLog; //!< log file ptr size_t fTraceLevel; //!< trace level Rstats fStats; //!< statistics }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkPort_NoInline)) #include "RlinkPort.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkPort.ipp b/tools/src/librlink/RlinkPort.ipp index 0c5f207b..93e29613 100644 --- a/tools/src/librlink/RlinkPort.ipp +++ b/tools/src/librlink/RlinkPort.ipp @@ -1,6 +1,6 @@ -// $Id: RlinkPort.ipp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkPort.ipp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,17 +13,19 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.2 use RparseUrl +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces // 2011-03-27 375 1.0 Initial version // 2011-01-15 356 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkPort.ipp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkPort.ipp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation (inline) of RlinkPort. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- @@ -37,7 +39,7 @@ inline bool RlinkPort::IsOpen() const //------------------------------------------+----------------------------------- //! FIXME_docs -inline const std::string& RlinkPort::Url() const +inline const Retro::RparseUrl& RlinkPort::Url() const { return fUrl; } @@ -45,30 +47,6 @@ inline const std::string& RlinkPort::Url() const //------------------------------------------+----------------------------------- //! FIXME_docs -inline const std::string& RlinkPort::UrlScheme() const -{ - return fScheme; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - -inline const std::string& RlinkPort::UrlPath() const -{ - return fPath; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - -inline const RlinkPort::omap_t& RlinkPort::UrlOpts() const -{ - return fOptMap; -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - inline int RlinkPort::FdRead() const { return fFdRead; @@ -85,9 +63,9 @@ inline int RlinkPort::FdWrite() const //------------------------------------------+----------------------------------- //! FIXME_docs -inline void RlinkPort::SetLogFile(RlogFile* log) +inline void RlinkPort::SetLogFile(const boost::shared_ptr& splog) { - fpLogFile = log; + fspLog = splog; return; } diff --git a/tools/src/librlink/RlinkPortCuff.cpp b/tools/src/librlink/RlinkPortCuff.cpp index 1742c298..c9ab92de 100644 --- a/tools/src/librlink/RlinkPortCuff.cpp +++ b/tools/src/librlink/RlinkPortCuff.cpp @@ -1,4 +1,4 @@ -// $Id: RlinkPortCuff.cpp 467 2013-01-02 19:49:05Z mueller $ +// $Id: RlinkPortCuff.cpp 504 2013-04-13 15:37:24Z mueller $ // // Copyright 2012-2013 by Walter F.J. Mueller // @@ -13,13 +13,16 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.1 use RparseUrl +// 2013-02-10 485 1.0.3 add static const defs +// 2013-02-03 481 1.0.2 use Rexception // 2013-01-02 467 1.0.1 get cleanup code right; add USBErrorName() // 2012-12-26 465 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkPortCuff.cpp 467 2013-01-02 19:49:05Z mueller $ + \version $Id: RlinkPortCuff.cpp 504 2013-04-13 15:37:24Z mueller $ \brief Implemenation of RlinkPortCuff. */ @@ -28,19 +31,33 @@ #include #include #include +#include -#include +#include +#include #include "RlinkPortCuff.hpp" +#include "librtools/Rexception.hpp" + using namespace std; -using namespace Retro; /*! \class Retro::RlinkPortCuff - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const size_t RlinkPortCuff::kUSBBufferSize; +const int RlinkPortCuff::kUSBWriteEP; +const int RlinkPortCuff::kUSBReadEP; +const size_t RlinkPortCuff::kUSBReadQueue; + //------------------------------------------+----------------------------------- //! Default constructor @@ -69,7 +86,7 @@ RlinkPortCuff::~RlinkPortCuff() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg) { @@ -77,7 +94,7 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg) if (IsOpen()) Close(); - if (!ParseUrl(url, "|trace|", emsg)) return false; + if (!fUrl.Set(url, "|trace|", emsg)) return false; // initialize USB context irc = libusb_init(&fpUsbContext); @@ -104,14 +121,12 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg) fUsbDevCount = libusb_get_device_list(fpUsbContext, &fpUsbDevList); // determine USB path name - if (fPath.length() == 0) { - char* env_vid = getenv("RETRO_FX2_VID"); - char* env_pid = getenv("RETRO_FX2_PID"); - if (env_vid && strlen(env_vid) == 4 && - env_pid && strlen(env_pid) == 4) { - fPath = env_vid; - fPath += ":"; - fPath += env_pid; + if (fUrl.Path().length() == 0) { + char* env_vid = ::getenv("RETRO_FX2_VID"); + char* env_pid = ::getenv("RETRO_FX2_PID"); + if (env_vid && ::strlen(env_vid) == 4 && + env_pid && ::strlen(env_pid) == 4) { + fUrl.SetPath(string(env_vid) + string(":") + string(env_pid)); } else { emsg.Init("RlinkPortCuff::Open()", string("RETRO_FX2_VID/PID not or ill defined")); @@ -123,12 +138,12 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg) // connect to USB device libusb_device* mydev = 0; // path syntax: /bus/dev - if (fPath.length()==8 && fPath[0]=='/' && fPath[4]=='/') { - string busnam = fPath.substr(1,3); - string devnam = fPath.substr(5,3); + if (fUrl.Path().length()==8 && fUrl.Path()[0]=='/' && fUrl.Path()[4]=='/') { + string busnam = fUrl.Path().substr(1,3); + string devnam = fUrl.Path().substr(5,3); char* endptr; - uint8_t busnum = strtol(busnam.c_str(), &endptr, 10); - uint8_t devnum = strtol(devnam.c_str(), &endptr, 10); + uint8_t busnum = ::strtol(busnam.c_str(), &endptr, 10); + uint8_t devnum = ::strtol(devnam.c_str(), &endptr, 10); for (ssize_t idev=0; idevfd, (*p)->events); } - free(plist); + ::free(plist); libusb_set_pollfd_notifiers(fpUsbContext, ThunkPollfdAdd, ThunkPollfdRemove, this); @@ -220,7 +235,7 @@ bool RlinkPortCuff::Open(const std::string& url, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::Close() { @@ -235,7 +250,7 @@ void RlinkPortCuff::Close() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::Cleanup() { @@ -246,8 +261,8 @@ void RlinkPortCuff::Cleanup() // use timed join, throw in case driver doesn't stop if (fDriverThread.get_id() != boost::thread::id()) { if (!fDriverThread.timed_join(boost::posix_time::milliseconds(500))) { - throw runtime_error("RlinkPortCuff::Cleanup(): " - "driver thread failed to stop"); + throw Rexception("RlinkPortCuff::Cleanup()", + "driver thread failed to stop"); } } @@ -278,14 +293,14 @@ void RlinkPortCuff::Cleanup() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RlinkPortCuff::OpenPipe(int& fdread, int& fdwrite, RerrMsg& emsg) { int irc; int pipefd[2]; - irc = pipe(pipefd); + irc = ::pipe(pipefd); if (irc < 0) { emsg.InitErrno("RlinkPortCuff::OpenPipe()", string("pipe() failed: "), @@ -300,7 +315,7 @@ bool RlinkPortCuff::OpenPipe(int& fdread, int& fdwrite, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs // executed in separate boost thread !! void RlinkPortCuff::Driver() @@ -373,7 +388,7 @@ void RlinkPortCuff::Driver() DriverEventUSB(); } if (fWriteQueuePending.size() + fReadQueuePending.size()) - throw runtime_error("RlinkPortCuff::Driver(): cleanup timeout"); + throw Rexception("RlinkPortCuff::Driver()", "cleanup timeout"); fLoopState = kLoopStateStopped; if (TraceOn()) cout << "cleanup ended" << endl; @@ -390,7 +405,7 @@ void RlinkPortCuff::Driver() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::DriverEventWritePipe() { @@ -417,7 +432,7 @@ void RlinkPortCuff::DriverEventWritePipe() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::DriverEventUSB() { @@ -433,7 +448,7 @@ void RlinkPortCuff::DriverEventUSB() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs libusb_transfer* RlinkPortCuff::NewWriteTransfer() { @@ -461,48 +476,48 @@ libusb_transfer* RlinkPortCuff::NewWriteTransfer() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RlinkPortCuff::TraceOn() { - if (!UrlFindOpt("trace")) return false; + if (!fUrl.FindOpt("trace")) return false; struct timeval tv; struct timezone tz; struct tm tmval; - gettimeofday(&tv, &tz); - localtime_r(&tv.tv_sec, &tmval); + ::gettimeofday(&tv, &tz); + ::localtime_r(&tv.tv_sec, &tmval); char buf[20]; - snprintf(buf, 20, "%02d:%02d:%02d.%06d: ", - tmval.tm_hour, tmval.tm_min, tmval.tm_sec, (int) tv.tv_usec); + ::snprintf(buf, 20, "%02d:%02d:%02d.%06d: ", + tmval.tm_hour, tmval.tm_min, tmval.tm_sec, (int) tv.tv_usec); cout << buf; return true; } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::BadSysCall(const char* meth, const char* text, int rc) { - char buf[1024]; - snprintf(buf, 1024, "%s : %s failed with rc=%d errno=%d: %s", - meth, text, rc, errno, strerror(errno)); - throw runtime_error(buf); + stringstream ss; + ss << rc; + throw Rexception(meth, string(text)+string(" failed with rc=")+ss.str(), + errno); } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::BadUSBCall(const char* meth, const char* text, int rc) { - char buf[1024]; - snprintf(buf, 1024, "%s : %s failed with rc=%d: %s", - meth, text, rc, USBErrorName(rc)); - throw runtime_error(buf); + stringstream ss; + ss << rc; + throw Rexception(meth, string(text)+string(" failed with rc=")+ss.str()+ + string(" : ")+string(USBErrorName(rc))); } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::CheckUSBTransfer(const char* meth, libusb_transfer *t) { @@ -516,13 +531,13 @@ void RlinkPortCuff::CheckUSBTransfer(const char* meth, libusb_transfer *t) if (etext == 0) return; char buf[1024]; - snprintf(buf, 1024, "%s : transfer failure on ep=%d: %s", - meth, (int)(t->endpoint&(~0x80)), etext); - throw runtime_error(buf); + ::snprintf(buf, 1024, "%s : transfer failure on ep=%d: %s", + meth, (int)(t->endpoint&(~0x80)), etext); + throw Rexception(meth, buf); } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs const char* RlinkPortCuff::USBErrorName(int rc) { @@ -564,7 +579,7 @@ const char* RlinkPortCuff::USBErrorName(int rc) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::PollfdAdd(int fd, short events) { @@ -578,7 +593,7 @@ void RlinkPortCuff::PollfdAdd(int fd, short events) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::PollfdRemove(int fd) { @@ -594,7 +609,7 @@ void RlinkPortCuff::PollfdRemove(int fd) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::USBWriteDone(libusb_transfer* t) { @@ -603,8 +618,8 @@ void RlinkPortCuff::USBWriteDone(libusb_transfer* t) if (fWriteQueuePending.size() && t == fWriteQueuePending.front()) fWriteQueuePending.pop_front(); else - throw logic_error("RlinkPortCuff::USBWriteDone: " - "fWriteQueuePending disordered"); + throw Rexception("RlinkPortCuff::USBWriteDone()", + "BugCheck: fWriteQueuePending disordered"); if (fLoopState == kLoopStateRunning) { CheckUSBTransfer("RlinkPortCuff::USBWriteDone()", t); @@ -618,7 +633,7 @@ void RlinkPortCuff::USBWriteDone(libusb_transfer* t) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::USBReadDone(libusb_transfer* t) { @@ -627,8 +642,8 @@ void RlinkPortCuff::USBReadDone(libusb_transfer* t) if (fReadQueuePending.size() && t == fReadQueuePending.front()) fReadQueuePending.pop_front(); else - throw logic_error("RlinkPortCuff::USBReadDone: " - "fReadQueuePending disordered"); + throw Rexception("RlinkPortCuff::USBReadDone()", + "BugCheck: fReadQueuePending disordered"); if (fLoopState == kLoopStateRunning) { CheckUSBTransfer("RlinkPortCuff::USBReadDone()", t); @@ -654,7 +669,7 @@ void RlinkPortCuff::USBReadDone(libusb_transfer* t) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::ThunkPollfdAdd(int fd, short events, void* udata) { @@ -664,7 +679,7 @@ void RlinkPortCuff::ThunkPollfdAdd(int fd, short events, void* udata) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::ThunkPollfdRemove(int fd, void* udata) { @@ -674,7 +689,7 @@ void RlinkPortCuff::ThunkPollfdRemove(int fd, void* udata) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::ThunkUSBWriteDone(libusb_transfer* t) { @@ -684,7 +699,7 @@ void RlinkPortCuff::ThunkUSBWriteDone(libusb_transfer* t) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortCuff::ThunkUSBReadDone(libusb_transfer* t) { @@ -693,9 +708,4 @@ void RlinkPortCuff::ThunkUSBReadDone(libusb_transfer* t) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPortCuff_NoInline)) -#define inline -//#include "RlinkPortCuff.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPortCuff.hpp b/tools/src/librlink/RlinkPortCuff.hpp index 63eac68f..51c0a0ad 100644 --- a/tools/src/librlink/RlinkPortCuff.hpp +++ b/tools/src/librlink/RlinkPortCuff.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkPortCuff.hpp 467 2013-01-02 19:49:05Z mueller $ +// $Id: RlinkPortCuff.hpp 502 2013-04-02 19:29:30Z mueller $ // // Copyright 2012-2013 by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RlinkPortCuff.hpp 467 2013-01-02 19:49:05Z mueller $ + \version $Id: RlinkPortCuff.hpp 502 2013-04-02 19:29:30Z mueller $ \brief Declaration of class RlinkPortCuff. */ @@ -30,10 +30,12 @@ #include "RlinkPort.hpp" #include +#include #include -#include "boost/thread.hpp" -#include +#include + +#include "boost/thread/thread.hpp" namespace Retro { @@ -46,7 +48,7 @@ namespace Retro { virtual bool Open(const std::string& url, RerrMsg& emsg); virtual void Close(); - // some constants + // some constants (also defined in cpp) static const size_t kUSBBufferSize = 4096; //!< USB buffer size static const int kUSBWriteEP = 4 ; //!< USB write endpoint static const int kUSBReadEP = 6 ; //!< USB read endpoint @@ -109,8 +111,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkPortCuff_NoInline)) //#include "RlinkPortCuff.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkPortFactory.cpp b/tools/src/librlink/RlinkPortFactory.cpp index 351b873d..0a44af81 100644 --- a/tools/src/librlink/RlinkPortFactory.cpp +++ b/tools/src/librlink/RlinkPortFactory.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkPortFactory.cpp 465 2012-12-27 21:29:38Z mueller $ +// $Id: RlinkPortFactory.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011-2012 by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.2 use RparseUrl // 2012-12-26 465 1.1 add cuff: support // 2011-03-27 374 1.0 Initial version // 2011-01-15 356 0.1 First draft @@ -20,37 +21,41 @@ /*! \file - \version $Id: RlinkPortFactory.cpp 465 2012-12-27 21:29:38Z mueller $ + \version $Id: RlinkPortFactory.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RlinkPortFactory. */ -#include "RlinkPortFactory.hpp" +#include "librtools/RparseUrl.hpp" + #include "RlinkPortFifo.hpp" #include "RlinkPortTerm.hpp" #include "RlinkPortCuff.hpp" +#include "RlinkPortFactory.hpp" + using namespace std; -using namespace Retro; /*! \class Retro::RlinkPortFactory - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs RlinkPort* Retro::RlinkPortFactory::New(const std::string& url, RerrMsg& emsg) { - size_t dpos = url.find_first_of(':'); - if (dpos == string::npos) { + string scheme = RparseUrl::FindScheme(url); + + if (scheme.length() == 0) { emsg.Init("RlinkPortFactory::New()", - string("no scheme specified in url \"" + url + string("\""))); + string("no scheme specified in url '" + url + string("'"))); return 0; } - string scheme = url.substr(0,dpos); // get scheme without ':' delim - if (scheme == "fifo") { return new RlinkPortFifo(); } else if (scheme == "term") { @@ -64,7 +69,7 @@ RlinkPort* Retro::RlinkPortFactory::New(const std::string& url, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs RlinkPort* RlinkPortFactory::Open(const std::string& url, RerrMsg& emsg) { @@ -76,10 +81,4 @@ RlinkPort* RlinkPortFactory::Open(const std::string& url, RerrMsg& emsg) return 0; } - -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPortFactory_NoInline)) -#define inline -//#include "RlinkPortFactory.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPortFactory.hpp b/tools/src/librlink/RlinkPortFactory.hpp index 18e8feb1..a6bb8a78 100644 --- a/tools/src/librlink/RlinkPortFactory.hpp +++ b/tools/src/librlink/RlinkPortFactory.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkPortFactory.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkPortFactory.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RlinkPortFactory.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkPortFactory.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RlinkPortFactory. */ @@ -40,8 +40,6 @@ namespace Retro { } // end namespace Retro -//#if !(defined(Retro_NoInline) || defined(Retro_RlinkPortFactory_NoInline)) //#include "RlinkPortFactory.ipp" -//#endif #endif diff --git a/tools/src/librlink/RlinkPortFifo.cpp b/tools/src/librlink/RlinkPortFifo.cpp index a6a55026..7f26b448 100644 --- a/tools/src/librlink/RlinkPortFifo.cpp +++ b/tools/src/librlink/RlinkPortFifo.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkPortFifo.cpp 466 2012-12-30 13:26:55Z mueller $ +// $Id: RlinkPortFifo.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 y Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.1 use RparseUrl // 2011-03-27 374 1.0 Initial version // 2011-01-15 356 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RlinkPortFifo.cpp 466 2012-12-30 13:26:55Z mueller $ + \version $Id: RlinkPortFifo.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RlinkPortFifo. */ @@ -31,13 +32,15 @@ #include "RlinkPortFifo.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkPortFifo - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -55,21 +58,21 @@ RlinkPortFifo::~RlinkPortFifo() } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RlinkPortFifo::Open(const std::string& url, RerrMsg& emsg) { if (IsOpen()) Close(); - if (!ParseUrl(url, "|keep|", emsg)) return false; + if (!fUrl.Set(url, "|keep|", emsg)) return false; // Note: _rx fifo must be opened before the _tx fifo, otherwise the test // bench might close with EOF on read prematurely (is a race condition). - fFdWrite = OpenFifo(UrlPath() + "_rx", true, emsg); + fFdWrite = OpenFifo(fUrl.Path() + "_rx", true, emsg); if (fFdWrite < 0) return false; - fFdRead = OpenFifo(UrlPath() + "_tx", false, emsg); + fFdRead = OpenFifo(fUrl.Path() + "_tx", false, emsg); if (fFdRead < 0) { close(fFdWrite); fFdWrite = -1; @@ -82,7 +85,7 @@ bool RlinkPortFifo::Open(const std::string& url, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs int RlinkPortFifo::OpenFifo(const std::string& name, bool snd, RerrMsg& emsg) { @@ -94,7 +97,7 @@ int RlinkPortFifo::OpenFifo(const std::string& name, bool snd, RerrMsg& emsg) if (irc == 0) { if ((stat_fifo.st_mode & S_IFIFO) == 0) { emsg.Init("RlinkPortFifo::OpenFiFo()", - string("\"") + name + string("\" exists but is not a pipe")); + string("'") + name + string("' exists but is not a pipe")); return -1; } } else { @@ -102,7 +105,7 @@ int RlinkPortFifo::OpenFifo(const std::string& name, bool snd, RerrMsg& emsg) irc = mkfifo(name.c_str(), mode); if (irc != 0) { emsg.InitErrno("RlinkPortFifo::OpenFifo()", - string("mkfifo() for \"") + name + string("\" failed: "), + string("mkfifo() for '") + name + string("' failed: "), errno); return -1; } @@ -111,7 +114,7 @@ int RlinkPortFifo::OpenFifo(const std::string& name, bool snd, RerrMsg& emsg) irc = open(name.c_str(), snd ? O_WRONLY : O_RDONLY); if (irc < 0) { emsg.InitErrno("RlinkPortFifo::OpenFifo()", - string("open() for \"") + name + string("\" failed: "), + string("open() for '") + name + string("' failed: "), errno); return -1; } @@ -119,9 +122,4 @@ int RlinkPortFifo::OpenFifo(const std::string& name, bool snd, RerrMsg& emsg) return irc; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPortFifo_NoInline)) -#define inline -//#include "RlinkPortFifo.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPortFifo.hpp b/tools/src/librlink/RlinkPortFifo.hpp index 73bb64cd..95cf6b80 100644 --- a/tools/src/librlink/RlinkPortFifo.hpp +++ b/tools/src/librlink/RlinkPortFifo.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkPortFifo.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RlinkPortFifo.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RlinkPortFifo.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RlinkPortFifo.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RlinkPortFifo. */ @@ -46,8 +46,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkPortFifo_NoInline)) //#include "RlinkPortFifo.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkPortTerm.cpp b/tools/src/librlink/RlinkPortTerm.cpp index 4c6e012d..71a5ca66 100644 --- a/tools/src/librlink/RlinkPortTerm.cpp +++ b/tools/src/librlink/RlinkPortTerm.cpp @@ -1,6 +1,6 @@ -// $Id: RlinkPortTerm.cpp 466 2012-12-30 13:26:55Z mueller $ +// $Id: RlinkPortTerm.cpp 494 2013-03-03 21:50:07Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.1 use RparseUrl // 2011-12-18 440 1.0.4 add kStatNPort stats; Open(): autoadd /dev/tty, // BUGFIX: Open(): set VSTART, VSTOP // 2011-12-11 438 1.0.3 Read(),Write(): added for xon handling, tcdrain(); @@ -24,7 +25,7 @@ /*! \file - \version $Id: RlinkPortTerm.cpp 466 2012-12-30 13:26:55Z mueller $ + \version $Id: RlinkPortTerm.cpp 494 2013-03-03 21:50:07Z mueller $ \brief Implemenation of RlinkPortTerm. */ @@ -41,13 +42,15 @@ #include "librtools/RosPrintf.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlinkPortTerm - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- // constants definitions const uint8_t RlinkPortTerm::kc_xon; @@ -69,28 +72,26 @@ RlinkPortTerm::RlinkPortTerm() RlinkPortTerm::~RlinkPortTerm() { - if (IsOpen()) RlinkPortTerm::Close(); + RlinkPortTerm::Close(); } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) { - if (IsOpen()) Close(); + Close(); - if (!ParseUrl(url, "|baud=|break|cts|xon", emsg)) return false; + if (!fUrl.Set(url, "|baud=|break|cts|xon|", emsg)) return false; // if path doesn't start with a '/' prepend a '/dev/tty' - if (fPath.substr(0,1) != "/") { - string dev = fPath; - fPath = "/dev/tty"; - fPath += dev; + if (fUrl.Path().substr(0,1) != "/") { + fUrl.SetPath(string("/dev/tty" + fUrl.Path())); } speed_t speed = B115200; string baud; - if (UrlFindOpt("baud", baud)) { + if (fUrl.FindOpt("baud", baud)) { speed = B0; if (baud=="2400") speed = B2400; if (baud=="4800") speed = B4800; @@ -113,39 +114,40 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) if (baud=="4000000" || baud=="4000k" || baud=="4M") speed = B4000000; if (speed == B0) { emsg.Init("RlinkPortTerm::Open()", - string("invalid baud rate \"") + baud + string("\" specified")); + string("invalid baud rate '") + baud + string("' specified")); return false; } } int fd; - fd = open(fPath.c_str(), O_RDWR|O_NOCTTY); + fd = open(fUrl.Path().c_str(), O_RDWR|O_NOCTTY); if (fd < 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("open() for \"") + fPath + string("\" failed: "), + string("open() for '") + fUrl.Path() + string("' failed: "), errno); return false; } if (!isatty(fd)) { emsg.Init("RlinkPortTerm::Open()", - string("isatty() check for \"") + fPath + - string("\" failed: not a TTY")); + string("isatty() check for '") + fUrl.Path() + + string("' failed: not a TTY")); close(fd); return false; } if (tcgetattr(fd, &fTiosOld) != 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("tcgetattr() for \"") + fPath + string("\" failed: "), + string("tcgetattr() for '") + fUrl.Path() + + string("' failed: "), errno); close(fd); return false; } - bool use_cts = UrlFindOpt("cts"); - bool use_xon = UrlFindOpt("xon"); + bool use_cts = fUrl.FindOpt("cts"); + bool use_xon = fUrl.FindOpt("xon"); fUseXon = use_xon; fPendXesc = false; @@ -172,7 +174,7 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) if (cfsetspeed(&fTiosNew, speed) != 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("cfsetspeed() for \"") + baud + string("\" failed: "), + string("cfsetspeed() for '") + baud + string("' failed: "), errno); close(fd); return false; @@ -196,7 +198,8 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) if (tcsetattr(fd, TCSANOW, &fTiosNew) != 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("tcsetattr() for \"") + fPath + string("\" failed: "), + string("tcsetattr() for '") + fUrl.Path() + + string("' failed: "), errno); close(fd); return false; @@ -209,8 +212,8 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) struct termios tios; if (tcgetattr(fd, &tios) != 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("2nd tcgetattr() for \"") + fPath + - string("\" failed: "), + string("2nd tcgetattr() for '") + fUrl.Path() + + string("' failed: "), errno); close(fd); return false; @@ -239,11 +242,11 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) fFdRead = fd; fIsOpen = true; - if (UrlFindOpt("break")) { + if (fUrl.FindOpt("break")) { if (tcsendbreak(fd, 0) != 0) { emsg.InitErrno("RlinkPortTerm::Open()", - string("tcsendbreak() for \"") + fPath + - string("\" failed: "), errno); + string("tcsendbreak() for '") + fUrl.Path() + + string("' failed: "), errno); Close(); return false; } @@ -259,7 +262,7 @@ bool RlinkPortTerm::Open(const std::string& url, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortTerm::Close() { @@ -347,7 +350,7 @@ int RlinkPortTerm::Write(const uint8_t* buf, size_t size, RerrMsg& emsg) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortTerm::Dump(std::ostream& os, int ind, const char* text) const { @@ -355,13 +358,12 @@ void RlinkPortTerm::Dump(std::ostream& os, int ind, const char* text) const os << bl << (text?text:"--") << "RlinkPortTerm @ " << this << endl; DumpTios(os, ind, "fTiosOld", fTiosOld); DumpTios(os, ind, "fTiosNew", fTiosNew); - RlinkPort::Dump(os, ind+2, ""); + RlinkPort::Dump(os, ind, " ^"); return; -} - +} //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RlinkPortTerm::DumpTios(std::ostream& os, int ind, const std::string& name, const struct termios& tios) const @@ -449,9 +451,4 @@ void RlinkPortTerm::DumpTios(std::ostream& os, int ind, const std::string& name, return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlinkPortTerm_NoInline)) -#define inline -//#include "RlinkPortTerm.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlink/RlinkPortTerm.hpp b/tools/src/librlink/RlinkPortTerm.hpp index 10dfbd0f..d46c9eb4 100644 --- a/tools/src/librlink/RlinkPortTerm.hpp +++ b/tools/src/librlink/RlinkPortTerm.hpp @@ -1,4 +1,4 @@ -// $Id: RlinkPortTerm.hpp 440 2011-12-18 20:08:09Z mueller $ +// $Id: RlinkPortTerm.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -21,7 +21,7 @@ /*! \file - \version $Id: RlinkPortTerm.hpp 440 2011-12-18 20:08:09Z mueller $ + \version $Id: RlinkPortTerm.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RlinkPortTerm. */ @@ -49,7 +49,7 @@ namespace Retro { virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; - // some constants + // some constants (also defined in cpp) static const uint8_t kc_xon = 0x11; // XON char -> ^Q = hex 11 static const uint8_t kc_xoff = 0x13; // XOFF char -> ^S = hex 13 static const uint8_t kc_xesc = 0x1b; // XESC char -> ^[ = ESC = hex 1B @@ -76,8 +76,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlinkPortTerm_NoInline)) //#include "RlinkPortTerm.ipp" -#endif #endif diff --git a/tools/src/librlink/RlinkServer.cpp b/tools/src/librlink/RlinkServer.cpp new file mode 100644 index 00000000..1174fac7 --- /dev/null +++ b/tools/src/librlink/RlinkServer.cpp @@ -0,0 +1,453 @@ +// $Id: RlinkServer.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-12 474 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkServer.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of RlinkServer. +*/ + +#include "boost/thread/locks.hpp" +#include "boost/bind.hpp" + +#include "librtools/Rexception.hpp" +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosPrintBvi.hpp" +#include "librtools/Rexception.hpp" +#include "librtools/RlogMsg.hpp" + +#include "RlinkServer.hpp" + +using namespace std; + +/*! + \class Retro::RlinkServer + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlinkServer::RlinkServer() + : fspConn(), + fContext(), + fAttnDsc(), + fActnList(), + fWakeupEvent(), + fELoop(this), + fServerThread(), + fAttnSeen(false), + fAttnPatt(0), + fTraceLevel(0), + fStats() +{ + fContext.SetStatus(0, + ~(RlinkCommand::kStat_M_RbNak|RlinkCommand::kStat_M_RbErr)); + + fELoop.AddPollHandler(boost::bind(&RlinkServer::WakeupHandler, this, _1), + fWakeupEvent, POLLIN); + + // Statistic setup + fStats.Define(kStatNEloopWait,"NEloopWait","event loop turns (wait)"); + fStats.Define(kStatNEloopPoll,"NEloopPoll","event loop turns (poll)"); + fStats.Define(kStatNWakeupEvt,"NWakeupEvt","Wakeup events"); + fStats.Define(kStatNRlinkEvt, "NRlinkEvt", "Rlink data events"); + fStats.Define(kStatNAttnRead, "NAttnRead", "Attn read commands"); + fStats.Define(kStatNAttn00, "NAttn00", "Attn bit 0 set"); + fStats.Define(kStatNAttn01, "NAttn01", "Attn bit 1 set"); + fStats.Define(kStatNAttn02, "NAttn02", "Attn bit 2 set"); + fStats.Define(kStatNAttn03, "NAttn03", "Attn bit 3 set"); + fStats.Define(kStatNAttn04, "NAttn04", "Attn bit 4 set"); + fStats.Define(kStatNAttn05, "NAttn05", "Attn bit 5 set"); + fStats.Define(kStatNAttn06, "NAttn06", "Attn bit 6 set"); + fStats.Define(kStatNAttn07, "NAttn07", "Attn bit 7 set"); + fStats.Define(kStatNAttn08, "NAttn08", "Attn bit 8 set"); + fStats.Define(kStatNAttn09, "NAttn09", "Attn bit 9 set"); + fStats.Define(kStatNAttn10, "NAttn10", "Attn bit 10 set"); + fStats.Define(kStatNAttn11, "NAttn11", "Attn bit 11 set"); + fStats.Define(kStatNAttn12, "NAttn12", "Attn bit 12 set"); + fStats.Define(kStatNAttn13, "NAttn13", "Attn bit 13 set"); + fStats.Define(kStatNAttn14, "NAttn14", "Attn bit 14 set"); + fStats.Define(kStatNAttn15, "NAttn15", "Attn bit 15 set"); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlinkServer::~RlinkServer() +{ + Stop(); + if (fspConn) fspConn->SetServer(0); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::SetConnect(const boost::shared_ptr& spconn) +{ + if (!fspConn && !spconn) return; // allow 0 = 0 ... + if (fspConn) + throw Rexception("RlinkServer::SetConnect()", + "Bad state: fspConn already set"); + if (!spconn) + throw Rexception("RlinkServer::SetConnect()", "Bad args: spconn==0"); + + fspConn = spconn; + fELoop.SetLogFile(fspConn->LogFileSPtr()); + fspConn->SetServer(this); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::AddAttnHandler(const attnhdl_t& attnhdl, uint16_t mask, + void* cdata) +{ + if (mask == 0) + throw Rexception("RlinkServer::AddAttnHandler()", "Bad args: mask == 0"); + + boost::lock_guard lock(*fspConn); + + AttnId id(mask, cdata); + for (size_t i=0; i lock(*fspConn); + + AttnId id(mask, cdata); + for (size_t i=0; i lock(*fspConn); + fActnList.push_back(actnhdl); + if (IsActiveOutside()) Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::AddPollHandler(const pollhdl_t& pollhdl, + int fd, short events) +{ + boost::lock_guard lock(*fspConn); + fELoop.AddPollHandler(pollhdl, fd, events); + if (IsActiveOutside()) Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkServer::TestPollHandler(int fd, short events) +{ + boost::lock_guard lock(*fspConn); + return fELoop.TestPollHandler(fd, events); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::RemovePollHandler(int fd, short events, bool nothrow) +{ + boost::lock_guard lock(*fspConn); + fELoop.RemovePollHandler(fd, events,nothrow); + if (IsActiveOutside()) Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::RemovePollHandler(int fd) +{ + boost::lock_guard lock(*fspConn); + fELoop.RemovePollHandler(fd); + if (IsActiveOutside()) Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::Start() +{ + if (IsActive()) + throw Rexception("RlinkServer::Start()", + "Bad state: server thread already running"); + if (!fspConn->IsOpen()) + throw Rexception("RlinkServer::Start()", + "Bad state: RlinkConnect not open"); + + // enable attn comma send + RlinkCommandList clist; + clist.AddInit(RlinkCommand::kRbaddr_IInt, RlinkCommand::kIInt_M_AnEna); + Exec(clist); + + // setup poll handler for Rlink traffic + int rlinkfd = fspConn->Port()->FdRead(); + if (!fELoop.TestPollHandler(rlinkfd, POLLIN)) + fELoop.AddPollHandler(boost::bind(&RlinkServer::RlinkHandler, this, _1), + rlinkfd, POLLIN); + + // and start server thread + fServerThread = boost::thread(boost::bind(&RlinkServerEventLoop::EventLoop, + &fELoop)); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::Stop() +{ + fELoop.Stop(); + Wakeup(); + fServerThread.join(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::Wakeup() +{ + uint64_t one(1); + int irc = write(fWakeupEvent, &one, sizeof(one)); + if (irc < 0) + throw Rexception("RlinkServer::Wakeup()", + "write() to eventfd failed: ", errno); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::SignalAttn() +{ + boost::lock_guard lock(*fspConn); + fAttnSeen = true; + Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkServer::IsActive() const +{ + return fServerThread.get_id() != boost::thread::id(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkServer::IsActiveInside() const +{ + return IsActive() && boost::this_thread::get_id() == fServerThread.get_id(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RlinkServer::IsActiveOutside() const +{ + return IsActive() && boost::this_thread::get_id() != fServerThread.get_id(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::SetTraceLevel(size_t level) +{ + fTraceLevel = level; + fELoop.SetTraceLevel(level); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::Print(std::ostream& os) const +{ + os << "RlinkServer::Print(std::ostream& os)" << endl; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::Dump(std::ostream& os, int ind, const char* text) const +{ + // FIXME_code: is that thread safe ??? fActnList.size() ??? + RosFill bl(ind); + os << bl << (text?text:"--") << "RlinkServer @ " << this << endl; + os << bl << " fspConn: " << fspConn << endl; + + os << bl << " fAttnDsc: " << endl; + for (size_t i=0; i lock(*fspConn); + RlinkCommandList clist; + clist.AddAttn(); + fStats.Inc(kStatNAttnRead); + Exec(clist); + // FIXME_code: handle errors: bool ok = + uint16_t nattn = clist[0].Data(); + fAttnPatt |= nattn; + for (size_t i=0; i<16; i++) { + if (nattn & (uint16_t(1)< lock(*fspConn); + fAttnDsc[i].fHandler(args); + hdone |= hmatch; + } + } + fAttnPatt &= ~hdone; // clear handled bits + + if (fAttnPatt && fTraceLevel>0) { + RlogMsg lmsg(LogFile(), 'I'); + lmsg << "eloop: unhandled attn, mask=" + << RosPrintBvi(fAttnPatt,16) << endl; + } + + fAttnPatt = 0; + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServer::CallActnHandler() +{ + if (!ActnPending()) return; + + // call first action + boost::lock_guard lock(*fspConn); + + int irc = fActnList.front()(); + + // if irc>1 requeue to end, otherwise drop + if (irc > 1) { + fActnList.splice(fActnList.end(), fActnList, fActnList.begin()); + } else { + fActnList.pop_front(); + } + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RlinkServer::WakeupHandler(const pollfd& pfd) +{ + fStats.Inc(kStatNWakeupEvt); + + // bail-out and cancel handler if poll returns an error event + if (pfd.revents & (~pfd.events)) return -1; + + uint64_t buf; + int irc = read(fWakeupEvent, &buf, sizeof(buf)); + if (irc < 0) + throw Rexception("RlinkServer::WakeupHandler()", + "read() from eventfd failed: ", errno); + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RlinkServer::RlinkHandler(const pollfd& pfd) +{ + fStats.Inc(kStatNRlinkEvt); + + // bail-out and cancel handler if poll returns an error event + if (pfd.revents & (~pfd.events)) return -1; + + boost::lock_guard lock(*fspConn); + RerrMsg emsg; + int irc = fspConn->PollAttn(emsg); + if (irc > 0) { + fAttnSeen = true; + } + + return 0; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkServer.hpp b/tools/src/librlink/RlinkServer.hpp new file mode 100644 index 00000000..60e11a92 --- /dev/null +++ b/tools/src/librlink/RlinkServer.hpp @@ -0,0 +1,177 @@ +// $Id: RlinkServer.hpp 502 2013-04-02 19:29:30Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-12 474 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkServer.hpp 502 2013-04-02 19:29:30Z mueller $ + \brief Declaration of class \c RlinkServer. +*/ + +#ifndef included_Retro_RlinkServer +#define included_Retro_RlinkServer 1 + +#include + +#include +#include +#include + +#include "boost/utility.hpp" +#include "boost/thread/thread.hpp" +#include "boost/shared_ptr.hpp" + +#include "librtools/Rstats.hpp" + +#include "ReventFd.hpp" +#include "RlinkConnect.hpp" +#include "RlinkContext.hpp" +#include "RlinkServerEventLoop.hpp" + +namespace Retro { + + class RlinkServer : private boost::noncopyable { + public: + + struct AttnArgs { + uint16_t fAttnPatt; + uint16_t fAttnMask; + RlinkCommandList* fpClist; + size_t fOffset; + AttnArgs(); + AttnArgs(uint16_t apatt, uint16_t amask); + AttnArgs(uint16_t apatt, uint16_t amask, + RlinkCommandList* pclist, size_t off); + }; + + typedef ReventLoop::pollhdl_t pollhdl_t; + typedef boost::function attnhdl_t; + typedef boost::function actnhdl_t; + + explicit RlinkServer(); + virtual ~RlinkServer(); + + void SetConnect(const boost::shared_ptr& spconn); + const boost::shared_ptr& ConnectSPtr() const; + RlinkConnect& Connect() const; + RlogFile& LogFile() const; + RlinkContext& Context(); + + bool Exec(RlinkCommandList& clist, RerrMsg& emsg); + bool Exec(RlinkCommandList& clist); + + void AddAttnHandler(const attnhdl_t& attnhdl, uint16_t mask, + void* cdata = 0); + void RemoveAttnHandler(uint16_t mask, void* cdata = 0); + + void QueueAction(const actnhdl_t& actnhdl); + + + void AddPollHandler(const pollhdl_t& pollhdl, + int fd, short events=POLLIN); + bool TestPollHandler(int fd, short events=POLLIN); + void RemovePollHandler(int fd, short events, bool nothrow=false); + void RemovePollHandler(int fd); + + void Start(); + void Stop(); + void Wakeup(); + void SignalAttn(); + + bool IsActive() const; + bool IsActiveInside() const; + bool IsActiveOutside() const; + + void SetTraceLevel(size_t level); + size_t TraceLevel() const; + + const Rstats& Stats() const; + + void Print(std::ostream& os) const; + void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices + enum stats { + kStatNEloopWait = 0, + kStatNEloopPoll, + kStatNWakeupEvt, + kStatNRlinkEvt, + kStatNAttnRead, + kStatNAttn00, + kStatNAttn01, + kStatNAttn02, + kStatNAttn03, + kStatNAttn04, + kStatNAttn05, + kStatNAttn06, + kStatNAttn07, + kStatNAttn08, + kStatNAttn09, + kStatNAttn10, + kStatNAttn11, + kStatNAttn12, + kStatNAttn13, + kStatNAttn14, + kStatNAttn15, + kDimStat + }; + + friend class RlinkServerEventLoop; + + protected: + bool AttnPending() const; + bool ActnPending() const; + void CallAttnHandler(); + void CallActnHandler(); + int WakeupHandler(const pollfd& pfd); + int RlinkHandler(const pollfd& pfd); + + protected: + struct AttnId { + uint16_t fMask; + void* fCdata; + AttnId(); + AttnId(uint16_t mask, void* cdata); + bool operator==(const AttnId& rhs) const; + }; + + struct AttnDsc { + attnhdl_t fHandler; + AttnId fId; + AttnDsc(); + AttnDsc(attnhdl_t hdl, const AttnId& id); + }; + + boost::shared_ptr fspConn; + RlinkContext fContext; //!< default server context + std::vector fAttnDsc; + std::list fActnList; + ReventFd fWakeupEvent; + RlinkServerEventLoop fELoop; + boost::thread fServerThread; + bool fAttnSeen; + uint16_t fAttnPatt; + size_t fTraceLevel; //!< trace level + Rstats fStats; //!< statistics +}; + +} // end namespace Retro + +#include "RlinkServer.ipp" + +#endif diff --git a/tools/src/librlink/RlinkServer.ipp b/tools/src/librlink/RlinkServer.ipp new file mode 100644 index 00000000..7eed7767 --- /dev/null +++ b/tools/src/librlink/RlinkServer.ipp @@ -0,0 +1,205 @@ +// $Id: RlinkServer.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-12 474 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkServer.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of RlinkServer. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const boost::shared_ptr& RlinkServer::ConnectSPtr() const +{ + return fspConn; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& RlinkServer::Connect() const +{ + return *fspConn; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& RlinkServer::LogFile() const +{ + return fspConn->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkContext& RlinkServer::Context() +{ + return fContext; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkServer::Exec(RlinkCommandList& clist, RerrMsg& emsg) +{ + return Connect().Exec(clist, fContext, emsg); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkServer::Exec(RlinkCommandList& clist) +{ + return Connect().Exec(clist, fContext); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t RlinkServer::TraceLevel() const +{ + return fTraceLevel; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rstats& RlinkServer::Stats() const +{ + return fStats; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkServer::AttnPending() const +{ + return fAttnSeen || fAttnPatt; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkServer::ActnPending() const +{ + return !fActnList.empty(); +} + + +//==========================================+=================================== +// AttnArgs sub class + +/*! + \class Retro::RlinkServer::AttnArgs + \brief FIXME_docs +*/ + +//------------------------------------------+----------------------------------- +//! Default constructor + +inline RlinkServer::AttnArgs::AttnArgs() + : fAttnPatt(0), + fAttnMask(0), + fpClist(0), + fOffset(0) +{} + +//------------------------------------------+----------------------------------- +//! Constructor + +inline RlinkServer::AttnArgs::AttnArgs(uint16_t apatt, uint16_t amask) + : fAttnPatt(apatt), + fAttnMask(amask), + fpClist(0), + fOffset(0) +{} + +//------------------------------------------+----------------------------------- +//! Constructor + +inline RlinkServer::AttnArgs::AttnArgs(uint16_t apatt, uint16_t amask, + RlinkCommandList* pclist, size_t offset) + : fAttnPatt(apatt), + fAttnMask(amask), + fpClist(pclist), + fOffset(offset) +{} + +//==========================================+=================================== +// AttnId sub class + +/*! + \class Retro::RlinkServer::AttnId + \brief FIXME_docs +*/ + +//------------------------------------------+----------------------------------- +//! Default constructor + +inline RlinkServer::AttnId::AttnId() + : fMask(0), + fCdata(0) +{} + +//------------------------------------------+----------------------------------- +//! Constructor + +inline RlinkServer::AttnId::AttnId(uint16_t mask, void* cdata) + : fMask(mask), + fCdata(cdata) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool RlinkServer::AttnId::operator==(const AttnId& rhs) const +{ + return fMask==rhs.fMask && fCdata==rhs.fCdata; +} + +//==========================================+=================================== +// AttnDsc sub class + +/*! + \class Retro::RlinkServer::AttnDsc + \brief FIXME_docs +*/ + +//------------------------------------------+----------------------------------- +//! Default constructor + +inline RlinkServer::AttnDsc::AttnDsc() + : fHandler(), + fId() +{} + +//------------------------------------------+----------------------------------- +//! Constructor + +inline RlinkServer::AttnDsc::AttnDsc(attnhdl_t hdl, const AttnId& id) + : fHandler(hdl), + fId(id) +{} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkServerEventLoop.cpp b/tools/src/librlink/RlinkServerEventLoop.cpp new file mode 100644 index 00000000..82b2a759 --- /dev/null +++ b/tools/src/librlink/RlinkServerEventLoop.cpp @@ -0,0 +1,93 @@ +// $Id: RlinkServerEventLoop.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-05 495 1.1.1 add exception catcher to EventLoop +// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces +// 2013-01-12 474 1.0 Initial Version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlinkServerEventLoop.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of RlinkServerEventLoop. +*/ + +#include + +#include "RlinkServer.hpp" +#include "librtools/RlogMsg.hpp" + +#include "RlinkServerEventLoop.hpp" + +using namespace std; + +/*! + \class Retro::RlinkServerEventLoop + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlinkServerEventLoop::RlinkServerEventLoop(RlinkServer* pserv) + : fpServer(pserv) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlinkServerEventLoop::~RlinkServerEventLoop() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlinkServerEventLoop::EventLoop() +{ + fLoopActive = true; + fUpdatePoll = true; + + if (fspLog && fTraceLevel>0) fspLog->Write("eloop: starting", 'I'); + + try { + while (fLoopActive) { + int timeout = (fpServer->AttnPending() || + fpServer->ActnPending()) ? 0 : -1; + int irc = DoPoll(timeout); + fpServer->fStats.Inc(timeout<0 ? RlinkServer::kStatNEloopWait : + RlinkServer::kStatNEloopPoll); + if (fPollFd.size() == 0) break; + if (irc > 0) DoCall(); + + if (fpServer->AttnPending()) fpServer->CallAttnHandler(); + if (fpServer->ActnPending()) fpServer->CallActnHandler(); + } + } catch (exception& e) { + if (fspLog) { + RlogMsg lmsg(*fspLog, 'F'); + lmsg << "eloop: crashed with exception: " << e.what(); + } + return; + } + + if (fspLog && fTraceLevel>0) fspLog->Write("eloop: stopped", 'I'); + + return; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RlinkServerEventLoop.hpp b/tools/src/librlink/RlinkServerEventLoop.hpp new file mode 100644 index 00000000..aacf77f1 --- /dev/null +++ b/tools/src/librlink/RlinkServerEventLoop.hpp @@ -0,0 +1,52 @@ +// $Id: RlinkServerEventLoop.hpp 486 2013-02-10 22:34:43Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RlinkServerEventLoop.hpp 486 2013-02-10 22:34:43Z mueller $ + \brief Declaration of class \c RlinkServerEventLoop. +*/ + +#ifndef included_Retro_RlinkServerEventLoop +#define included_Retro_RlinkServerEventLoop 1 + +#include + +#include "ReventLoop.hpp" + +namespace Retro { + + class RlinkServer; // forward dcl + + class RlinkServerEventLoop : public ReventLoop { + public: + RlinkServerEventLoop(RlinkServer* pserv); + virtual ~RlinkServerEventLoop(); + + virtual void EventLoop(); + + protected: + RlinkServer* fpServer; +}; + +} // end namespace Retro + +//#include "RlinkServerEventLoop.ipp" + +#endif diff --git a/tools/src/librlink/RtimerFd.cpp b/tools/src/librlink/RtimerFd.cpp new file mode 100644 index 00000000..7e7364c5 --- /dev/null +++ b/tools/src/librlink/RtimerFd.cpp @@ -0,0 +1,80 @@ +// $Id: RtimerFd.cpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtimerFd.cpp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation of class RtimerFd. +*/ + +#include +#include +#include + +#include "RtimerFd.hpp" + +#include "librtools/Rexception.hpp" + +using namespace std; + +/*! + \class Retro::RtimerFd + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtimerFd::RtimerFd() +{ + fFd = timerfd_create(CLOCK_MONOTONIC,0); // use MONOTONIC; no flags + if (fFd < 0) + throw Rexception("RtimerFd::", "timerfd() failed: ", errno); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtimerFd::~RtimerFd() +{ + close(fFd); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtimerFd::SetRelTimer(boost::posix_time::time_duration interval, + boost::posix_time::time_duration initial) +{ + itimerspec its; + itimerspec old; + long sf = 1000000000/interval.ticks_per_second(); + its.it_interval.tv_sec = interval.total_seconds(); + its.it_interval.tv_nsec = interval.fractional_seconds() * sf; + its.it_value.tv_sec = initial.total_seconds(); + its.it_value.tv_nsec = initial.fractional_seconds() * sf; + int irc = timerfd_settime(fFd, 0, &its, &old); + if (irc < 0) + throw Rexception("RtimerFd::SetRelTimer()", "timerfd() failed: ", errno); + return; +} + +} // end namespace Retro diff --git a/tools/src/librlink/RtimerFd.hpp b/tools/src/librlink/RtimerFd.hpp new file mode 100644 index 00000000..508911fe --- /dev/null +++ b/tools/src/librlink/RtimerFd.hpp @@ -0,0 +1,54 @@ +// $Id: RtimerFd.hpp 486 2013-02-10 22:34:43Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtimerFd.hpp 486 2013-02-10 22:34:43Z mueller $ + \brief Declaration of class \c RtimerFd. +*/ + +#ifndef included_Retro_RtimerFd +#define included_Retro_RtimerFd 1 + +#include "boost/utility.hpp" +#include "boost/date_time/posix_time/posix_time_types.hpp" + +namespace Retro { + + class RtimerFd : private boost::noncopyable { + public: + RtimerFd(); + virtual ~RtimerFd(); + + int Fd() const; + void SetRelTimer(boost::posix_time::time_duration interval, + boost::posix_time::time_duration initial); + + operator int() const; + + protected: + + int fFd; +}; + +} // end namespace Retro + +#include "RtimerFd.ipp" + +#endif diff --git a/tools/src/librlink/RtimerFd.ipp b/tools/src/librlink/RtimerFd.ipp new file mode 100644 index 00000000..c15fd31a --- /dev/null +++ b/tools/src/librlink/RtimerFd.ipp @@ -0,0 +1,46 @@ +// $Id: RtimerFd.ipp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-11 473 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtimerFd.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class RtimerFd. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline int RtimerFd::Fd() const +{ + return fFd; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RtimerFd::operator int() const +{ + return fFd; +} + +} // end namespace Retro + + diff --git a/tools/src/librlinktpp/Makefile b/tools/src/librlinktpp/Makefile index cc7f7449..f2dec4b3 100644 --- a/tools/src/librlinktpp/Makefile +++ b/tools/src/librlinktpp/Makefile @@ -1,7 +1,9 @@ -# $Id: Makefile 464 2012-12-26 10:14:15Z mueller $ +# $Id: Makefile 479 2013-02-01 18:09:49Z mueller $ # # Revision History: # Date Rev Version Comment +# 2013-02-01 479 1.1.32 use checkpath_cpp.mk +# 2013-01-27 478 1.1.2 add RtclRlinkPort # 2012-12-24 464 1.1.1 add TCLINC # 2011-07-31 401 1.1 rename realclean->distclean # 2011-07-01 386 1.0.2 add BOOSTINC @@ -17,12 +19,15 @@ SOMINV = 0 # # Compile and Link search paths # +include ../checkpath_cpp.mk +# INCLFLAGS = -I${RETROBASE}/tools/src -I${TCLINC} -I${BOOSTINC} LDLIBS = -L${RETROBASE}/tools/lib -lrtools -lrtcltools -lrlink # # Object files to be included # -OBJ_all = Rlinktpp_Init.o RtclRlinkConnect.o +OBJ_all = Rlinktpp_Init.o RtclRlinkPort.o RtclRlinkConnect.o \ + RtclRlinkServer.o RtclAttnShuttle.o # DEP_all = $(OBJ_all:.o=.dep) # @@ -35,10 +40,13 @@ SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) include $(RETROBASE)/tools/make/generic_cpp.mk include $(RETROBASE)/tools/make/generic_dep.mk include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk # # The magic autodependcy include # +ifndef DONTINCDEP include $(DEP_all) +endif # # cleanup phonies: # diff --git a/tools/src/librlinktpp/Rlinktpp_Init.cpp b/tools/src/librlinktpp/Rlinktpp_Init.cpp index e7aa6333..805848c7 100644 --- a/tools/src/librlinktpp/Rlinktpp_Init.cpp +++ b/tools/src/librlinktpp/Rlinktpp_Init.cpp @@ -1,6 +1,6 @@ -// $Id: Rlinktpp_Init.cpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: Rlinktpp_Init.cpp 504 2013-04-13 15:37:24Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,14 +13,18 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-10 485 1.0.5 remove Tcl_InitStubs() +// 2013-01-27 478 1.0.4 add rlinkport +// 2013-01-12 474 1.0.3 add rlinkserver // 2011-03-20 372 1.0.2 renamed ..tcl -> ..tpp // 2011-03-19 371 1.0.1 moved Bvi into librtoolstcl +// 2011-03-14 370 1.0 Initial version // 2011-02-11 360 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: Rlinktpp_Init.cpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: Rlinktpp_Init.cpp 504 2013-04-13 15:37:24Z mueller $ \brief Implemenation of Rlinktpp_Init . */ @@ -29,7 +33,9 @@ #include #include "librtcltools/RtclClassOwned.hpp" +#include "RtclRlinkPort.hpp" #include "RtclRlinkConnect.hpp" +#include "RtclRlinkServer.hpp" using namespace std; using namespace Retro; @@ -39,23 +45,23 @@ extern "C" int Rlinktpp_Init(Tcl_Interp* interp) { int irc; - // use stubs - const char* vers = Tcl_InitStubs(interp, TCL_VERSION, 0); - if (vers == NULL) return TCL_ERROR; - // declare package name and version irc = Tcl_PkgProvide(interp, "rlinktpp", "1.0.0"); if (irc != TCL_OK) return irc; try { // register class commands + RtclClassOwned::CreateClass(interp, "rlinkport", + "RlinkPort"); RtclClassOwned::CreateClass(interp, "rlinkconnect", "RlinkConnect"); + RtclClassOwned::CreateClass(interp, "rlinkserver", + "RlinkServer"); return TCL_OK; } catch (exception& e) { - Tcl_AppendResult(interp, "-E: exception caught in Rlinktpp_Init: \"", - e.what(), "\"", NULL); + Tcl_AppendResult(interp, "-E: exception caught in Rlinktpp_Init: '", + e.what(), "'", NULL); } return TCL_ERROR; } diff --git a/tools/src/librlinktpp/RtclAttnShuttle.cpp b/tools/src/librlinktpp/RtclAttnShuttle.cpp new file mode 100644 index 00000000..0f64a479 --- /dev/null +++ b/tools/src/librlinktpp/RtclAttnShuttle.cpp @@ -0,0 +1,154 @@ +// $Id: RtclAttnShuttle.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// 2013-01-12 475 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclAttnShuttle.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of class RtclAttnShuttle. + */ + +#include "errno.h" + +#include "boost/bind.hpp" + +#include "librtools/Rexception.hpp" + +#include "RtclAttnShuttle.hpp" + +using namespace std; + +/*! + \class Retro::RtclAttnShuttle + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! constructor + +RtclAttnShuttle::RtclAttnShuttle(uint16_t mask, Tcl_Obj* pobj) + : fpServ(0), + fpInterp(0), + fFdPipeRead(0), + fFdPipeWrite(0), + fShuttleChn(0), + fMask(mask), + fpScript(pobj) +{ + int pipefd[2]; + int irc = pipe(pipefd); + if (irc < 0) + throw Rexception("RtclAttnShuttle::", "pipe() failed: ", errno); + fFdPipeRead = pipefd[0]; + fFdPipeWrite = pipefd[1]; +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclAttnShuttle::~RtclAttnShuttle() +{ + Remove(); + close(fFdPipeWrite); + close(fFdPipeRead); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclAttnShuttle::Add(RlinkServer* pserv, Tcl_Interp* interp) +{ + // connect to RlinkServer + pserv->AddAttnHandler(boost::bind(&RtclAttnShuttle::AttnHandler, this, _1), + fMask, (void*)this); + fpServ = pserv; + + // connect to Tcl + fShuttleChn = Tcl_MakeFileChannel((ClientData)fFdPipeRead, TCL_READABLE); + Tcl_CreateChannelHandler(fShuttleChn, TCL_READABLE, + (Tcl_FileProc*) ThunkTclChannelHandler, + (ClientData) this); + fpInterp = interp; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclAttnShuttle::Remove() +{ + // disconnect from RlinkServer + if (fpServ) { + fpServ->RemoveAttnHandler(fMask, (void*)this); + fpServ = 0; + } + // disconnect from Tcl + if (fpInterp) { + Tcl_DeleteChannelHandler(fShuttleChn, + (Tcl_FileProc*) ThunkTclChannelHandler, + (ClientData) this); + Tcl_Close(fpInterp, fShuttleChn); + fpInterp = 0; + } + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclAttnShuttle::AttnHandler(const RlinkServer::AttnArgs& args) +{ + uint16_t apat = args.fAttnPatt & args.fAttnMask; + int irc = write(fFdPipeWrite, (void*) &apat, sizeof(apat)); + if (irc < 0) + throw Rexception("RtclAttnShuttle::AttnHandler()", + "write() failed: ", errno); + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclAttnShuttle::TclChannelHandler(int mask) +{ + uint16_t apat; + Tcl_ReadRaw(fShuttleChn, (char*) &apat, sizeof(apat)); + // FIXME_code: handle return code + + Tcl_SetVar2Ex(fpInterp, "Rlink_attnbits", NULL, Tcl_NewIntObj((int)apat), 0); + // FIXME_code: handle return code + + Tcl_EvalObjEx(fpInterp, fpScript, TCL_EVAL_GLOBAL); + // FIXME_code: handle return code + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclAttnShuttle::ThunkTclChannelHandler(ClientData cdata, int mask) +{ + ((RtclAttnShuttle*) cdata)->TclChannelHandler(mask); + return; +} + +} // end namespace Retro diff --git a/tools/src/librlinktpp/RtclAttnShuttle.hpp b/tools/src/librlinktpp/RtclAttnShuttle.hpp new file mode 100644 index 00000000..5fbb6043 --- /dev/null +++ b/tools/src/librlinktpp/RtclAttnShuttle.hpp @@ -0,0 +1,68 @@ +// $Id: RtclAttnShuttle.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// 2013-01-14 475 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclAttnShuttle.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class RtclAttnShuttle. +*/ + +#ifndef included_Retro_RtclAttnShuttle +#define included_Retro_RtclAttnShuttle 1 + +#include "tcl.h" + +#include + +#include "librtcltools/RtclOPtr.hpp" +#include "librlink/RlinkServer.hpp" + +namespace Retro { + + class RtclAttnShuttle { + public: + RtclAttnShuttle(uint16_t mask, Tcl_Obj* pobj); + ~RtclAttnShuttle(); + + uint16_t Mask() const; + Tcl_Obj* Script() const; + + void Add(RlinkServer* pserv, Tcl_Interp* interp); + void Remove(); + + protected: + int AttnHandler(const RlinkServer::AttnArgs& args); + void TclChannelHandler(int mask); + static void ThunkTclChannelHandler(ClientData cdata, int mask); + + protected: + RlinkServer* fpServ; //!< RlinkServer used + Tcl_Interp* fpInterp; //!< Tcl interpreter used + int fFdPipeRead; //!< attn pipe read fd + int fFdPipeWrite; //!< attn pipe write fd + Tcl_Channel fShuttleChn; //!< Tcl channel + uint16_t fMask; //!< attn mask + RtclOPtr fpScript; //!< Tcl handler script (as Tcl_Obj) + }; + +} // end namespace Retro + +#include "RtclAttnShuttle.ipp" + +#endif diff --git a/tools/src/librlinktpp/RtclAttnShuttle.ipp b/tools/src/librlinktpp/RtclAttnShuttle.ipp new file mode 100644 index 00000000..4f6a27e2 --- /dev/null +++ b/tools/src/librlinktpp/RtclAttnShuttle.ipp @@ -0,0 +1,46 @@ +// $Id: RtclAttnShuttle.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// 2013-01-14 475 0.5 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclAttnShuttle.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of class RtclAttnShuttle. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint16_t RtclAttnShuttle::Mask() const +{ + return fMask; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Tcl_Obj* RtclAttnShuttle::Script() const +{ + return fpScript; +} + +} // end namespace Retro + diff --git a/tools/src/librlinktpp/RtclRlinkConnect.cpp b/tools/src/librlinktpp/RtclRlinkConnect.cpp index 15204d94..c1fb6d64 100644 --- a/tools/src/librlinktpp/RtclRlinkConnect.cpp +++ b/tools/src/librlinktpp/RtclRlinkConnect.cpp @@ -1,6 +1,6 @@ -// $Id: RtclRlinkConnect.cpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RtclRlinkConnect.cpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,11 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.1.6 use RlogFile.Name(); use Context().ErrorCount() +// 2013-02-22 491 1.1.5 use new RlogFile/RlogMsg interfaces +// 2013-02-02 480 1.1.4 allow empty exec commands +// 2013-01-27 478 1.1.3 use RtclRlinkPort::DoRawio on M_rawio +// 2013-01-06 473 1.1.2 add M_rawio: rawio -write|-read // 2011-11-28 434 1.1.1 ConfigBase(): use uint32_t for lp64 compatibility // 2011-04-23 380 1.1 use boost/bind instead of RmethDsc // 2011-04-17 376 1.0.1 M_wtlam: now correct log levels @@ -22,13 +27,12 @@ /*! \file - \version $Id: RtclRlinkConnect.cpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RtclRlinkConnect.cpp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation of class RtclRlinkConnect. */ #include -#include #include #include "boost/bind.hpp" @@ -38,25 +42,28 @@ #include "librtcltools/RtclNameSet.hpp" #include "librtcltools/RtclStats.hpp" #include "librtools/RosPrintf.hpp" +#include "librtools/RlogMsg.hpp" #include "librlink/RlinkCommandList.hpp" +#include "RtclRlinkPort.hpp" + #include "RtclRlinkConnect.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RtclRlinkConnect \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor RtclRlinkConnect::RtclRlinkConnect(Tcl_Interp* interp, const char* name) : RtclProxyOwned("RlinkConnect", interp, name, - new RlinkConnect()), - fErrCnt(0), - fLogFileName("-") + new RlinkConnect()) { AddMeth("open", boost::bind(&RtclRlinkConnect::M_open, this, _1)); AddMeth("close", boost::bind(&RtclRlinkConnect::M_close, this, _1)); @@ -65,6 +72,7 @@ RtclRlinkConnect::RtclRlinkConnect(Tcl_Interp* interp, const char* name) AddMeth("errcnt", boost::bind(&RtclRlinkConnect::M_errcnt, this, _1)); AddMeth("wtlam", boost::bind(&RtclRlinkConnect::M_wtlam, this, _1)); AddMeth("oob", boost::bind(&RtclRlinkConnect::M_oob, this, _1)); + AddMeth("rawio", boost::bind(&RtclRlinkConnect::M_rawio, this, _1)); AddMeth("stats", boost::bind(&RtclRlinkConnect::M_stats, this, _1)); AddMeth("log", boost::bind(&RtclRlinkConnect::M_log, this, _1)); AddMeth("print", boost::bind(&RtclRlinkConnect::M_print, this, _1)); @@ -95,12 +103,9 @@ int RtclRlinkConnect::M_open(RtclArgs& args) RerrMsg emsg; if (args.NOptMiss() == 0) { // open path - if (!Obj().Open(path, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().Open(path, emsg)) return args.Quit(emsg); } else { // open - string name = Obj().IsOpen() ? Obj().Port()->Url() : string(); + string name = Obj().IsOpen() ? Obj().Port()->Url().Url() : string(); args.SetResult(name); } return kOK; @@ -112,11 +117,7 @@ int RtclRlinkConnect::M_open(RtclArgs& args) int RtclRlinkConnect::M_close(RtclArgs& args) { if (!args.AllDone()) return kERR; - - if (!Obj().IsOpen()) { - args.AppendResult("-E: port not open", NULL); - return kERR; - } + if (!Obj().IsOpen()) return args.Quit("-E: port not open"); Obj().Close(); return kOK; } @@ -263,27 +264,20 @@ int RtclRlinkConnect::M_exec(RtclArgs& args) if (varprint == "-") nact += 1; if (vardump == "-") nact += 1; if (varlist == "-") nact += 1; - if (nact > 1) { - args.AppendResult("-E: more that one of -print,-dump,-list without ", - "target variable found", NULL); - return kERR; - } + if (nact > 1) + return args.Quit( + "-E: more that one of -print,-dump,-list without target variable found"); if (!args.AllDone()) return kERR; + if (clist.Size() == 0) return kOK; RerrMsg emsg; - if (!Obj().Exec(clist, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().Exec(clist, emsg)) return args.Quit(emsg); for (size_t icmd=0; icmd retstat; @@ -317,8 +311,8 @@ int RtclRlinkConnect::M_exec(RtclArgs& args) if (!varprint.empty()) { ostringstream sos; const RlinkConnect::LogOpts& logopts = Obj().GetLogOpts(); - clist.Print(sos, &Obj().AddrMap(), logopts.baseaddr, logopts.basedata, - logopts.basestat); + clist.Print(sos, Obj().Context(), &Obj().AddrMap(), logopts.baseaddr, + logopts.basedata, logopts.basestat); RtclOPtr pobj = Rtcl::NewLinesObj(sos); if (!Rtcl::SetVarOrResult(args.Interp(), varprint, pobj)) return kERR; } @@ -388,9 +382,8 @@ int RtclRlinkConnect::M_amap(RtclArgs& args) if(addrmap.Find(addr, tstname)) { args.SetResult(tstname); } else { - args.AppendResult("-E: address \"", args.PeekArgString(-1), - "\" not mapped", NULL); - return kERR; + return args.Quit(string("-E: address '") + args.PeekArgString(-1) + + "' not mapped"); } } else if (opt == "-testname") { // amap -testname name @@ -411,33 +404,23 @@ int RtclRlinkConnect::M_amap(RtclArgs& args) int tstint; if (!args.GetArg("name", name)) return kERR; // enforce that the name is not a valid representation of an int - if (Tcl_GetIntFromObj(NULL, args[args.NDone()-1], &tstint) == kOK) { - args.AppendResult("-E: name should not look like an int but \"", - name.c_str(), "\" does", NULL); - return kERR; - } + if (Tcl_GetIntFromObj(NULL, args[args.NDone()-1], &tstint) == kOK) + return args.Quit(string("-E: name should not look like an int but '")+ + name + "' does"); if (!args.GetArg("addr", addr, 0x00ff)) return kERR; if (!args.AllDone()) return kERR; - if (addrmap.Find(name, tstaddr)) { - args.AppendResult("-E: mapping already defined for \"", name.c_str(), - "\"", NULL); - return kERR; - } - if (addrmap.Find(addr, tstname)) { - args.AppendResult("-E: mapping already defined for address \"", - args.PeekArgString(-1), "\"", NULL); - return kERR; - } + if (addrmap.Find(name, tstaddr)) + return args.Quit(string("-E: mapping already defined for '")+name+"'"); + if (addrmap.Find(addr, tstname)) + return args.Quit(string("-E: mapping already defined for address '") + + args.PeekArgString(-1) + "'"); Obj().AddrMapInsert(name, addr); } else if (opt == "-erase") { // amap -erase name if (!args.GetArg("name", name)) return kERR; if (!args.AllDone()) return kERR; - if (!Obj().AddrMapErase(name)) { - args.AppendResult("-E: no mapping defined for \"", name.c_str(), - "\"", NULL); - return kERR; - } + if (!Obj().AddrMapErase(name)) + return args.Quit(string("-E: no mapping defined for '") + name + "'"); } else if (opt == "-clear") { // amap -clear if (!args.AllDone()) return kERR; @@ -458,9 +441,7 @@ int RtclRlinkConnect::M_amap(RtclArgs& args) if(addrmap.Find(name, tstaddr)) { args.SetResult(int(tstaddr)); } else { - args.AppendResult("-E: no mapping defined for \"", name.c_str(), - "\"", NULL); - return kERR; + return args.Quit(string("-E: no mapping defined for '") + name + "'"); } } else { // amap @@ -493,8 +474,8 @@ int RtclRlinkConnect::M_errcnt(RtclArgs& args) } if (!args.AllDone()) return kERR; - args.SetResult(int(fErrCnt)); - if (fclear) fErrCnt = 0; + args.SetResult(int(Obj().Context().ErrorCount())); + if (fclear) Obj().Context().ClearErrorCount(); return kOK; } @@ -512,22 +493,23 @@ int RtclRlinkConnect::M_wtlam(RtclArgs& args) double twait = Obj().WaitAttn(tout, emsg); if (twait == -2.) { - args.AppendResult(emsg.Message()); - return kERR; + return args.Quit(emsg); } else if (twait == -1.) { if (Obj().GetLogOpts().printlevel >= 1) { - Obj().LogFile()() << "-- wtlam to=" << RosPrintf(tout, "f", 0,3) - << " FAIL timeout" << endl; - fErrCnt += 1; + RlogMsg lmsg(Obj().LogFile()); + lmsg << "-- wtlam to=" << RosPrintf(tout, "f", 0,3) + << " FAIL timeout" << endl; + Obj().Context().IncErrorCount(); args.SetResult(tout); return kOK; } } if (Obj().GetLogOpts().printlevel >= 3) { - Obj().LogFile()() << "-- wtlam to=" << RosPrintf(tout, "f", 0,3) - << " T=" << RosPrintf(twait, "f", 0,3) - << " OK" << endl; + RlogMsg lmsg(Obj().LogFile()); + lmsg << "-- wtlam to=" << RosPrintf(tout, "f", 0,3) + << " T=" << RosPrintf(twait, "f", 0,3) + << " OK" << endl; } args.SetResult(twait); @@ -551,43 +533,29 @@ int RtclRlinkConnect::M_oob(RtclArgs& args) if (!args.GetArg("val", data, 1)) return kERR; if (!args.AllDone()) return kERR; addr = 15; // rlmon on bit 15 - if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) return args.Quit(emsg); } else if (opt == "-rbmon") { // oob -rbmon (0|1) if (!args.GetArg("val", data, 1)) return kERR; if (!args.AllDone()) return kERR; addr = 14; // rbmon on bit 14 - if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) return args.Quit(emsg); } else if (opt == "-sbcntl") { // oob -sbcntl bit (0|1) if (!args.GetArg("bit", addr, 15)) return kERR; if (!args.GetArg("val", data, 1)) return kERR; if (!args.AllDone()) return kERR; - if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().SndOob(0x00, (addr<<8)+data, emsg)) return args.Quit(emsg); } else if (opt == "-sbdata") { // oob -sbdata addr val if (!args.GetArg("bit", addr, 0x0ff)) return kERR; if (!args.GetArg("val", data)) return kERR; if (!args.AllDone()) return kERR; - if (!Obj().SndOob(addr, data, emsg)) { - args.AppendResult(emsg.Message()); - return kERR; - } + if (!Obj().SndOob(addr, data, emsg)) return args.Quit(emsg); } } else { - args.AppendResult("-E: missing option, one of " - "-rlmon,-rbmon,-sbcntl,-sbdata", - NULL); - return kERR; + return args.Quit( + "-E: missing option, one of -rlmon,-rbmon,-sbcntl,-sbdata"); } return kOK; @@ -596,13 +564,24 @@ int RtclRlinkConnect::M_oob(RtclArgs& args) //------------------------------------------+----------------------------------- //! FIXME_docs +int RtclRlinkConnect::M_rawio(RtclArgs& args) +{ + size_t errcnt = 0; + int rc = RtclRlinkPort::DoRawio(args, Obj().Port(), errcnt); + Obj().Context().IncErrorCount(errcnt); + return rc; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + int RtclRlinkConnect::M_stats(RtclArgs& args) { RtclStats::Context cntx; if (!RtclStats::GetArgs(args, cntx)) return kERR; - if (!RtclStats::Exec(args, cntx, Obj().Stats())) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Stats())) return kERR; if (Obj().Port()) { - if (!RtclStats::Exec(args, cntx, Obj().Port()->Stats())) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Port()->Stats())) return kERR; } return kOK; } @@ -618,7 +597,7 @@ int RtclRlinkConnect::M_log(RtclArgs& args) if (Obj().GetLogOpts().printlevel != 0 || Obj().GetLogOpts().dumplevel != 0 || Obj().GetLogOpts().tracelevel != 0) { - Obj().LogFile()() << "# " << msg << endl; + Obj().LogFile().Write(string("# ") + msg); } return kOK; } @@ -665,7 +644,7 @@ int RtclRlinkConnect::M_config(RtclArgs& args) sos << "-baseaddr " << RosPrintf(logopts.baseaddr, "d") << " -basedata " << RosPrintf(logopts.basedata, "d") << " -basestat " << RosPrintf(logopts.basestat, "d") - << " -logfile {" << fLogFileName << "}" + << " -logfile {" << Obj().LogFile().Name() << "}" << " -logprintlevel " << RosPrintf(logopts.printlevel, "d") << " -logdumplevel " << RosPrintf(logopts.dumplevel, "d") << " -logtracelevel " << RosPrintf(logopts.tracelevel, "d"); @@ -688,17 +667,16 @@ int RtclRlinkConnect::M_config(RtclArgs& args) if (args.NOptMiss() == 0) Obj().SetLogOpts(logopts); } else if (opt == "-logfile") { // -logfile ?name ------------------ - if (!args.Config("??name", fLogFileName)) return false; + string name; + if (!args.Config("??name", name)) return false; if (args.NOptMiss() == 0) { // new filename ? - if (fLogFileName == "-") { - Obj().LogUseStream(&cout); + if (name == "-" || name == "") { + Obj().LogUseStream(&cout, ""); } else { - if (!Obj().LogOpen(fLogFileName)) { - args.AppendResult("-E: open failed for \"", - fLogFileName.c_str(), "\", using stdout", NULL); - Obj().LogUseStream(&cout); - fLogFileName = "-"; - return kERR; + if (!Obj().LogOpen(name)) { + Obj().LogUseStream(&cout, ""); + return args.Quit(string("-E: open failed for '") + name + + "', using stdout"); } } } @@ -733,7 +711,7 @@ int RtclRlinkConnect::M_default(RtclArgs& args) sos << "print base: " << "addr " << RosPrintf(logopts.baseaddr, "d", 2) << " data " << RosPrintf(logopts.basedata, "d", 2) << " stat " << RosPrintf(logopts.basestat, "d", 2) << endl; - sos << "logfile: " << fLogFileName + sos << "logfile: " << Obj().LogFile().Name() << " printlevel " << logopts.printlevel << " dumplevel " << logopts.dumplevel; @@ -756,8 +734,8 @@ bool RtclRlinkConnect::GetAddr(RtclArgs& args, RlinkConnect& conn, if (tstint >= 0 && tstint <= 0x00ff) { addr = (uint16_t)tstint; } else { - args.AppendResult("-E: value \"", Tcl_GetString(pobj), - "\" for \"addr\" out of range 0...0x00ff", NULL); + args.AppendResult("-E: value '", Tcl_GetString(pobj), + "' for 'addr' out of range 0...0x00ff", NULL); return false; } // if a name is given @@ -767,8 +745,8 @@ bool RtclRlinkConnect::GetAddr(RtclArgs& args, RlinkConnect& conn, if (Obj().AddrMap().Find(name, tstaddr)) { addr = tstaddr; } else { - args.AppendResult("-E: no address mapping known for \"", - Tcl_GetString(pobj), "\"", NULL); + args.AppendResult("-E: no address mapping known for '", + Tcl_GetString(pobj), "'", NULL); return false; } } @@ -789,8 +767,8 @@ bool RtclRlinkConnect::GetVarName(RtclArgs& args, const char* argname, if (name.length()) { // if variable defined char c = name[0]; if (isdigit(c) || c=='+' || c=='-' ) { // check for mistaken number - args.AppendResult("-E: invalid variable name \"", name.c_str(), - "\": looks like a number", NULL); + args.AppendResult("-E: invalid variable name '", name.c_str(), + "': looks like a number", NULL); return false; } } @@ -807,8 +785,9 @@ bool RtclRlinkConnect::ConfigBase(RtclArgs& args, uint32_t& base) uint32_t tmp = base; if (!args.Config("??base", tmp, 16, 2)) return false; if (tmp != base && tmp != 2 && tmp !=8 && tmp != 16) { - args.AppendResult("-E: base must be 2, 8, or 16, found \"", - args.PeekArgString(-1), "\"", NULL); + args.AppendResult("-E: base must be 2, 8, or 16, found '", + args.PeekArgString(-1), "'", NULL); + return false; } base = tmp; return true; @@ -822,15 +801,11 @@ bool RtclRlinkConnect::ClistNonEmpty(RtclArgs& args, const RlinkCommandList& clist) { if (clist.Size() == 0) { - args.AppendResult("-E: -volatile not allowed on empty command list", NULL); + args.AppendResult("-E: -edata, -estat, or -volatile " + "not allowed on empty command list", NULL); return false; } return true; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclRlinkConnect_NoInline)) -#define inline -//#include "RtclRlinkConnect.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librlinktpp/RtclRlinkConnect.hpp b/tools/src/librlinktpp/RtclRlinkConnect.hpp index e1058475..1cb031f7 100644 --- a/tools/src/librlinktpp/RtclRlinkConnect.hpp +++ b/tools/src/librlinktpp/RtclRlinkConnect.hpp @@ -1,6 +1,6 @@ -// $Id: RtclRlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RtclRlinkConnect.hpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 1.0.3 use RlogFile.Name(); use Context().ErrorCount() +// 2013-01-06 473 1.0.2 add M_rawio // 2011-11-28 434 1.0.1 ConfigBase(): use uint32_t for lp64 compatibility // 2011-03-27 374 1.0 Initial version // 2011-02-11 360 0.1 First draft @@ -20,7 +22,7 @@ /*! \file - \version $Id: RtclRlinkConnect.hpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RtclRlinkConnect.hpp 492 2013-02-24 22:14:47Z mueller $ \brief Declaration of class RtclRlinkConnect. */ @@ -40,7 +42,7 @@ namespace Retro { class RtclRlinkConnect : public RtclProxyOwned { public: RtclRlinkConnect(Tcl_Interp* interp, const char* name); - ~RtclRlinkConnect(); + ~RtclRlinkConnect(); protected: int M_open(RtclArgs& args); @@ -50,6 +52,7 @@ namespace Retro { int M_errcnt(RtclArgs& args); int M_wtlam(RtclArgs& args); int M_oob(RtclArgs& args); + int M_rawio(RtclArgs& args); int M_stats(RtclArgs& args); int M_log(RtclArgs& args); int M_print(RtclArgs& args); @@ -66,14 +69,10 @@ namespace Retro { protected: RtclOPtr fCmdnameObj[8]; - size_t fErrCnt; - std::string fLogFileName; }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclRlinkConnect_NoInline)) //#include "RtclRlinkConnect.ipp" -#endif #endif diff --git a/tools/src/librlinktpp/RtclRlinkPort.cpp b/tools/src/librlinktpp/RtclRlinkPort.cpp new file mode 100644 index 00000000..dd78e853 --- /dev/null +++ b/tools/src/librlinktpp/RtclRlinkPort.cpp @@ -0,0 +1,330 @@ +// $Id: RtclRlinkPort.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0.2 use RlogFile.Name(); +// 2013-02-22 491 1.0.1 use new RlogFile/RlogMsg interfaces +// 2013-01-27 478 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRlinkPort.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of class RtclRlinkPort. + */ + +#include + +#include + +#include "boost/bind.hpp" + +#include "librtcltools/Rtcl.hpp" +#include "librtcltools/RtclOPtr.hpp" +#include "librtcltools/RtclNameSet.hpp" +#include "librtcltools/RtclStats.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RlogFile.hpp" +#include "librlink/RlinkPortFactory.hpp" + +#include "RtclRlinkPort.hpp" + +using namespace std; + +/*! + \class Retro::RtclRlinkPort + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RtclRlinkPort::RtclRlinkPort(Tcl_Interp* interp, const char* name) + : RtclProxyBase("RlinkPort"), + fpObj(0), + fspLog(new RlogFile(&cout, "")), + fTraceLevel(0), + fErrCnt(0) +{ + CreateObjectCmd(interp, name); + AddMeth("open", boost::bind(&RtclRlinkPort::M_open, this, _1)); + AddMeth("close", boost::bind(&RtclRlinkPort::M_close, this, _1)); + AddMeth("errcnt", boost::bind(&RtclRlinkPort::M_errcnt, this, _1)); + AddMeth("rawio", boost::bind(&RtclRlinkPort::M_rawio, this, _1)); + AddMeth("stats", boost::bind(&RtclRlinkPort::M_stats, this, _1)); + AddMeth("log", boost::bind(&RtclRlinkPort::M_log, this, _1)); + AddMeth("dump", boost::bind(&RtclRlinkPort::M_dump, this, _1)); + AddMeth("config", boost::bind(&RtclRlinkPort::M_config, this, _1)); + AddMeth("$default", boost::bind(&RtclRlinkPort::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRlinkPort::~RtclRlinkPort() +{ + delete fpObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_open(RtclArgs& args) +{ + string path; + + if (!args.GetArg("?path", path)) return kERR; + if (!args.AllDone()) return kERR; + + RerrMsg emsg; + if (args.NOptMiss() == 0) { // open path + delete fpObj; + fpObj = RlinkPortFactory::Open(path, emsg); + if (!fpObj) return args.Quit(emsg); + fpObj->SetLogFile(fspLog); + fpObj->SetTraceLevel(fTraceLevel); + } else { // open + string name = (fpObj && fpObj->IsOpen()) ? fpObj->Url().Url() : string(); + args.SetResult(name); + } + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_close(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + if (!TestOpen(args)) return kERR; + delete fpObj; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_errcnt(RtclArgs& args) +{ + static RtclNameSet optset("-clear"); + string opt; + bool fclear = false; + + while (args.NextOpt(opt, optset)) { + if (opt == "-clear") fclear = true; + } + if (!args.AllDone()) return kERR; + + args.SetResult(int(fErrCnt)); + if (fclear) fErrCnt = 0; + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_rawio(RtclArgs& args) +{ + return DoRawio(args, fpObj, fErrCnt); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + + if (!TestOpen(args)) return kERR; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, fpObj->Stats())) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_log(RtclArgs& args) +{ + string msg; + if (!args.GetArg("msg", msg)) return kERR; + if (!args.AllDone()) return kERR; + if (fTraceLevel != 0) fspLog->Write(string("# ") + msg); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + if (!TestOpen(args)) return kERR; + + ostringstream sos; + fpObj->Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_config(RtclArgs& args) +{ + static RtclNameSet optset("-logfile|-logtracelevel"); + + if (args.NDone() == (size_t)args.Objc()) { + ostringstream sos; + sos << " -logfile {" << fspLog->Name() << "}" + << " -logtracelevel " << RosPrintf(fTraceLevel, "d"); + args.AppendResult(sos); + return kOK; + } + + string opt; + while (args.NextOpt(opt, optset)) { + if (opt == "-logfile") { // -logfile ?name ------------------ + string name; + if (!args.Config("??name", name)) return false; + if (args.NOptMiss() == 0) { // new filename ? + if (name == "-" || name == "") { + fspLog->UseStream(&cout, ""); + } else { + if (!fspLog->Open(name)) { + fspLog->UseStream(&cout, ""); + return args.Quit(string("-E: open failed for '") + name + + "', using stdout"); + } + } + } + } else if (opt == "-logtracelevel") { // -logtracelevel ?loglevel -------- + if (!args.Config("??loglevel", fTraceLevel, 3)) return false; + if (fpObj) fpObj->SetTraceLevel(fTraceLevel); + } + } + + if (!args.AllDone()) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + + sos << "logfile: " << fspLog->Name() + << " tracelevel " << fTraceLevel; + + args.AppendResultLines(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RtclRlinkPort::TestOpen(RtclArgs& args) +{ + if (fpObj) return true; + args.AppendResult("-E: port not open", NULL); + return false; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkPort::DoRawio(RtclArgs& args, RlinkPort* pport, size_t& errcnt) +{ + static RtclNameSet optset("-rblk|-wblk|-edata|-timeout"); + + if (!pport || !pport->IsOpen()) args.Quit("-E: port not open"); + + string opt; + char mode = 0; + + int32_t rsize; + string rvname; + vector rdata; + vector wdata; + vector edata; + vector emask; + double timeout = 1.; + + while (args.NextOpt(opt, optset)) { + if (opt == "-rblk") { // -rblk size ?varData ------------ + if (mode) return args.Quit("-E: only one -rblk or -wblk allowed"); + mode = 'r'; + if (!args.GetArg("bsize", rsize, 1, 256)) return kERR; + if (!args.GetArg("??varData", rvname)) return kERR; + + } else if (opt == "-wblk") { // -wblk block -------------------- + if (mode) return args.Quit("-E: only one -rblk or -wblk allowed"); + mode = 'w'; + if (!args.GetArg("data", wdata, 1, 256)) return kERR; + + } else if (opt == "-edata") { // -edata data ?mask -------------- + if (mode != 'r') return args.Quit("-E: -edata only allowed after -rblk"); + if (!args.GetArg("data", edata, 0, rsize)) return kERR; + if (!args.GetArg("??mask", emask, 0, rsize)) return kERR; + + } else if (opt == "-timeout") { // -timeout tsec ------------------ + if (!args.GetArg("tsec", timeout, 0.)) return kERR; + } + } + + if (!args.AllDone()) return kERR; + + if (!mode) return args.Quit("-E: no -rblk or -wblk given"); + + if (mode == 'r') { // handle -rblk ------------------ + RerrMsg emsg; + double tused = 0.; + rdata.resize(rsize); + int irc = pport->RawRead(rdata.data(), rdata.size(), true, timeout, + tused, emsg); + if (irc == RlinkPort::kErr) return args.Quit("-E: timeout on -rblk"); + if (irc != (int)rdata.size()) return args.Quit(emsg); + if (rvname.length()) { + RtclOPtr pres = Rtcl::NewListIntObj(rdata); + if(!Rtcl::SetVar(args.Interp(), rvname, pres)) return kERR; + } + if (edata.size()) { + size_t nerr=0; + for (size_t i=0; i= edata.size()) break; + uint8_t eval = edata[i]; + uint8_t emsk = (i < emask.size()) ? emask[i] : 0x0000; + if ((rdata[i]|emsk) != (eval|emsk)) nerr += 1; + } + if (nerr) errcnt += 1; + } + args.SetResult(tused); + + } else { // handle -wblk ------------------ + RerrMsg emsg; + int irc = pport->RawWrite(wdata.data(), wdata.size(), emsg); + if (irc != (int)wdata.size()) return args.Quit(emsg); + } + + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librlinktpp/RtclRlinkPort.hpp b/tools/src/librlinktpp/RtclRlinkPort.hpp new file mode 100644 index 00000000..081870ac --- /dev/null +++ b/tools/src/librlinktpp/RtclRlinkPort.hpp @@ -0,0 +1,74 @@ +// $Id: RtclRlinkPort.hpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0.1 use RlogFile.Name(); +// 2013-01-27 478 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRlinkPort.hpp 492 2013-02-24 22:14:47Z mueller $ + \brief Declaration of class RtclRlinkPort. +*/ + +#ifndef included_Retro_RtclRlinkPort +#define included_Retro_RtclRlinkPort 1 + +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "librtcltools/RtclProxyBase.hpp" + +#include "librtools/RlogFile.hpp" +#include "librlink/RlinkPort.hpp" + +namespace Retro { + + class RtclRlinkPort : public RtclProxyBase { + public: + RtclRlinkPort(Tcl_Interp* interp, const char* name); + ~RtclRlinkPort(); + + friend class RtclRlinkConnect; + + protected: + int M_open(RtclArgs& args); + int M_close(RtclArgs& args); + int M_errcnt(RtclArgs& args); + int M_rawio(RtclArgs& args); + int M_stats(RtclArgs& args); + int M_log(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_config(RtclArgs& args); + int M_default(RtclArgs& args); + + bool TestOpen(RtclArgs& args); + + static int DoRawio(RtclArgs& args, RlinkPort* pport, size_t& errcnt); + + protected: + RlinkPort* fpObj; //!< ptr to managed object + boost::shared_ptr fspLog; //!< port log file + uint32_t fTraceLevel; //!< 0=off,1=buf,2=char + size_t fErrCnt; //!< error count + }; + +} // end namespace Retro + +//#include "RtclRlinkPort.ipp" + +#endif diff --git a/tools/src/librlinktpp/RtclRlinkServer.cpp b/tools/src/librlinktpp/RtclRlinkServer.cpp new file mode 100644 index 00000000..77d1806c --- /dev/null +++ b/tools/src/librlinktpp/RtclRlinkServer.cpp @@ -0,0 +1,276 @@ +// $Id: RtclRlinkServer.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-05 483 1.0.2 ClassCmdConfig: use RtclArgs +// 2013-02-05 482 1.0.1 add shared_ptr to RlinkConnect object +// 2013-01-12 474 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRlinkServer.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of class RtclRlinkServer. + */ + +#include + +#include +#include +#include +#include +#include + +#include "boost/bind.hpp" + +#include "librtools/RosPrintBvi.hpp" +#include "librtcltools/Rtcl.hpp" +#include "librtcltools/RtclOPtr.hpp" +#include "librtcltools/RtclStats.hpp" +#include "librtcltools/RtclContext.hpp" +#include "RtclRlinkConnect.hpp" + +#include "RtclRlinkServer.hpp" + +using namespace std; + +/*! + \class Retro::RtclRlinkServer + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RtclRlinkServer::RtclRlinkServer(Tcl_Interp* interp, const char* name) + : RtclProxyOwned("RlinkServer", interp, name, + new RlinkServer()), + fspConn() +{ + AddMeth("server", boost::bind(&RtclRlinkServer::M_server, this, _1)); + AddMeth("attn", boost::bind(&RtclRlinkServer::M_attn, this, _1)); + AddMeth("stats", boost::bind(&RtclRlinkServer::M_stats, this, _1)); + AddMeth("print", boost::bind(&RtclRlinkServer::M_print, this, _1)); + AddMeth("dump", boost::bind(&RtclRlinkServer::M_dump, this, _1)); + AddMeth("$default", boost::bind(&RtclRlinkServer::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRlinkServer::~RtclRlinkServer() +{ + for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) { + delete (*it); + } +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::ClassCmdConfig(RtclArgs& args) +{ + string parent; + if (!args.GetArg("parent", parent)) return kERR; + + // locate RlinkConnect proxy and object -> setup Server->Connect linkage + RtclProxyBase* pprox = RtclContext::Find(args.Interp()).FindProxy( + "RlinkConnect", parent); + if (pprox == 0) + return args.Quit(string("-E: object '") + parent + + "' not found or not type RlinkConnect"); + + // make RtclRlinkServer object be co-owner of RlinkConnect object + fspConn = dynamic_cast(pprox)->ObjSPtr(); + // set RlinkConnect in RlinkServer (make RlinkServer also co-owner) + Obj().SetConnect(fspConn); + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_server(RtclArgs& args) +{ + static RtclNameSet optset("-start|-stop|-test|-trace"); + string opt; + if (args.NextOpt(opt, optset)) { + if (opt == "-start") { // server -start + if (!args.AllDone()) return kERR; + Obj().Start(); + } else if (opt == "-stop") { // server -stop + if (!args.AllDone()) return kERR; + Obj().Stop(); + } else if (opt == "-test") { // server -test + if (!args.AllDone()) return kERR; + args.SetResult(Obj().IsActive()); + } else if (opt == "-trace") { // server -trace ... + int level; + if (!args.GetArg("?level", level)) return kERR; + if (args.NOptMiss()==0) { // server -trace level + Obj().SetTraceLevel((size_t)level); + } else { // server -trace + args.SetResult((int)Obj().TraceLevel()); + } + } + + } else { // server + if (!args.OptValid()) return kERR; + if (!args.AllDone()) return kERR; + args.SetResult(Obj().IsActive()); + } + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_attn(RtclArgs& args) +{ + static RtclNameSet optset("-add|-remove|-show|-test|-list"); + + Tcl_Interp* interp = args.Interp(); + + string opt; + + if (args.NextOpt(opt, optset)) { + if (opt == "-add") { // attn -add mask script + uint16_t mask=0; + Tcl_Obj* script=0; + if (!args.GetArg("mask", mask,0xff,1)) return kERR; + if (!args.GetArg("script", script)) return kERR; + if (!args.AllDone()) return kERR; + + unique_ptr p(new RtclAttnShuttle(mask, script)); + try { + p->Add(&Obj(), interp); + } catch (exception& e) { + return args.Quit(string("-E: handler rejected: ")+e.what()); + } + fAttnHdl.push_back(p.release()); + return kOK; + + } else if (opt == "-remove") { // attn -remove mask + uint16_t mask=0; + if (!args.GetArg("mask", mask)) return kERR; + if (!args.AllDone()) return kERR; + for (alist_it_t it = fAttnHdl.end(); it != fAttnHdl.begin(); ) { + it--; + if ((*it)->Mask() == mask) { + fAttnHdl.erase(it); + delete (*it); + return kOK; + } + } + return args.Quit(string("-E: no handler defined for '") + + args.PeekArgString(-1) + "'"); + + // common handling for -show, -test + } else if (opt == "-show" ||opt == "-test") {// attn -(show|test) mask + uint16_t mask=0; + if (!args.GetArg("mask", mask)) return kERR; + if (!args.AllDone()) return kERR; + int nhdl = 0; + for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) { + if ((*it)->Mask() & mask) { + nhdl += 1; + if (opt == "-show") { // attn -show mask + args.SetResult((*it)->Script()); + } else if (opt == "-test") { // attn -test mask + int rc = Tcl_EvalObjEx(interp, (*it)->Script(), TCL_EVAL_GLOBAL); + if (rc != kOK) return rc; + } + } + } + if (nhdl) return kOK; + return args.Quit(string("-E: no handler defined for '") + + args.PeekArgString(-1) + "'"); + + } else if (opt == "-list") { // attn -list + if (!args.AllDone()) return kERR; + vector vres; + for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) { + vres.push_back((*it)->Mask()); + } + args.SetResult(Rtcl::NewListIntObj(vres)); + } + + } else { // attn + if (!args.OptValid()) return kERR; + if (!args.AllDone()) return kERR; + uint16_t mask=0; + for (alist_it_t it = fAttnHdl.begin(); it != fAttnHdl.end(); it++) { + mask |= (*it)->Mask(); + } + args.SetResult(mask); + } + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Stats())) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_print(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Print(sos); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRlinkServer::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + sos << "no default output defined yet...\n"; + args.AppendResultLines(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librlinktpp/RtclRlinkServer.hpp b/tools/src/librlinktpp/RtclRlinkServer.hpp new file mode 100644 index 00000000..533cdb97 --- /dev/null +++ b/tools/src/librlinktpp/RtclRlinkServer.hpp @@ -0,0 +1,70 @@ +// $Id: RtclRlinkServer.hpp 486 2013-02-10 22:34:43Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-05 482 1.0.1 add shared_ptr to RlinkConnect object +// 2013-01-12 474 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRlinkServer.hpp 486 2013-02-10 22:34:43Z mueller $ + \brief Declaration of class RtclRlinkServer. +*/ + +#ifndef included_Retro_RtclRlinkServer +#define included_Retro_RtclRlinkServer 1 + +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "librtcltools/RtclOPtr.hpp" +#include "librtcltools/RtclProxyOwned.hpp" +#include "RtclAttnShuttle.hpp" +#include "librlink/RlinkServer.hpp" + +namespace Retro { + + class RlinkConnect; + + class RtclRlinkServer : public RtclProxyOwned { + public: + RtclRlinkServer(Tcl_Interp* interp, const char* name); + ~RtclRlinkServer(); + + virtual int ClassCmdConfig(RtclArgs& args); + + protected: + int M_server(RtclArgs& args); + int M_attn(RtclArgs& args); + int M_stats(RtclArgs& args); + int M_print(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_default(RtclArgs& args); + + protected: + typedef std::list alist_t; + typedef alist_t::iterator alist_it_t; + + boost::shared_ptr fspConn; + alist_t fAttnHdl; //distclean # 2011-07-01 386 1.0.1 add BOOSTINC @@ -16,13 +17,16 @@ SOMINV = 0 # # Compile and Link search paths # +include ../checkpath_cpp.mk +# INCLFLAGS = -I${RETROBASE}/tools/src -I${TCLINC} -I${BOOSTINC} LDLIBS = -L${RETROBASE}/tools/lib -lrtools # # Object files to be included # -OBJ_all = Rtcl.o RtclArgs.o RtclClassBase.o RtclContext.o \ - RtclNameSet.o RtclProxyBase.o RtclStats.o +OBJ_all = Rtcl.o RtclArgs.o RtclClassBase.o RtclContext.o +OBJ_all += RtclNameSet.o RtclCmdBase.o RtclProxyBase.o RtclStats.o +OBJ_all += RtclGetBase.o RtclGetList.o RtclSetBase.o RtclSetList.o # DEP_all = $(OBJ_all:.o=.dep) # @@ -35,10 +39,13 @@ SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) include $(RETROBASE)/tools/make/generic_cpp.mk include $(RETROBASE)/tools/make/generic_dep.mk include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk # # The magic autodependcy include # +ifndef DONTINCDEP include $(DEP_all) +endif # # cleanup phonies: # diff --git a/tools/src/librtcltools/Rtcl.cpp b/tools/src/librtcltools/Rtcl.cpp index f7ccbbed..927296f2 100644 --- a/tools/src/librtcltools/Rtcl.cpp +++ b/tools/src/librtcltools/Rtcl.cpp @@ -1,6 +1,6 @@ -// $Id: Rtcl.cpp 369 2011-03-13 22:39:26Z mueller $ +// $Id: Rtcl.cpp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-06 473 1.0.4 add NewListIntObj(const uint(8|16)_t, ...) // 2011-03-13 369 1.0.2 add NewListIntObj(vector) // 2011-03-05 366 1.0.1 add AppendResultNewLines() // 2011-02-26 364 1.0 Initial version @@ -21,20 +22,22 @@ /*! \file - \version $Id: Rtcl.cpp 369 2011-03-13 22:39:26Z mueller $ + \version $Id: Rtcl.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of Rtcl. */ #include "Rtcl.hpp" using namespace std; -using namespace Retro; /*! \class Retro::Rtcl \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! FIXME_docs @@ -49,15 +52,15 @@ Tcl_Obj* Rtcl::NewLinesObj(const std::string& str) //------------------------------------------+----------------------------------- //! FIXME_docs -Tcl_Obj* Rtcl::NewListIntObj(const std::vector& vec) +Tcl_Obj* Rtcl::NewListIntObj(const uint8_t* data, size_t size) { - if (vec.size() == 0) return Tcl_NewListObj(0, NULL); + if (size == 0) return Tcl_NewListObj(0, NULL); vector vobj; - vobj.reserve(vec.size()); + vobj.reserve(size); - for (size_t i=0; i& vec) //------------------------------------------+----------------------------------- //! FIXME_docs -Tcl_Obj* Rtcl::NewListIntObj(const std::vector& vec) +Tcl_Obj* Rtcl::NewListIntObj(const uint16_t* data, size_t size) { - if (vec.size() == 0) return Tcl_NewListObj(0, NULL); + if (size == 0) return Tcl_NewListObj(0, NULL); vector vobj; - vobj.reserve(vec.size()); + vobj.reserve(size); - for (size_t i=0; i& vec) //------------------------------------------+----------------------------------- //! FIXME_docs +Tcl_Obj* Rtcl::NewListIntObj(const std::vector& vec) +{ + return NewListIntObj(vec.data(), vec.size()); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Tcl_Obj* Rtcl::NewListIntObj(const std::vector& vec) +{ + return NewListIntObj(vec.data(), vec.size()); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + bool Rtcl::SetVar(Tcl_Interp* interp, const std::string& varname, Tcl_Obj* pobj) { Tcl_Obj* pret = 0; @@ -91,8 +110,8 @@ bool Rtcl::SetVar(Tcl_Interp* interp, const std::string& varname, Tcl_Obj* pobj) if (pos_pbeg == string::npos || pos_pbeg == 0 || pos_pend == string::npos || pos_pend != varname.length()-1 || pos_pend-pos_pbeg <= 1) { - Tcl_AppendResult(interp, "illformed array name \"", varname.c_str(), - "\"", NULL); + Tcl_AppendResult(interp, "illformed array name '", varname.c_str(), + "'", NULL); return false; } string arrname(varname.substr(0,pos_pbeg)); @@ -144,9 +163,4 @@ void Rtcl::SetResult(Tcl_Interp* interp, const std::string& str) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_Rtcl_NoInline)) -#define inline -#include "Rtcl.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/Rtcl.hpp b/tools/src/librtcltools/Rtcl.hpp index db260945..cd0e5622 100644 --- a/tools/src/librtcltools/Rtcl.hpp +++ b/tools/src/librtcltools/Rtcl.hpp @@ -1,6 +1,6 @@ -// $Id: Rtcl.hpp 369 2011-03-13 22:39:26Z mueller $ +// $Id: Rtcl.hpp 486 2013-02-10 22:34:43Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-06 473 1.0.4 add NewListIntObj(const uint(8|16)_t, ...) // 2011-03-13 369 1.0.3 add NewListIntObj(vector) // 2011-03-12 368 1.0.2 use namespace Rtcl // 2011-03-05 366 1.0.1 add AppendResultNewLines() @@ -22,7 +23,7 @@ /*! \file - \version $Id: Rtcl.hpp 369 2011-03-13 22:39:26Z mueller $ + \version $Id: Rtcl.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class Rtcl. */ @@ -42,6 +43,8 @@ namespace Retro { Tcl_Obj* NewLinesObj(const std::string& str); Tcl_Obj* NewLinesObj(std::ostringstream& sos); + Tcl_Obj* NewListIntObj(const uint8_t* data, size_t size); + Tcl_Obj* NewListIntObj(const uint16_t* data, size_t size); Tcl_Obj* NewListIntObj(const std::vector& vec); Tcl_Obj* NewListIntObj(const std::vector& vec); @@ -58,8 +61,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_Rtcl_NoInline)) #include "Rtcl.ipp" -#endif #endif diff --git a/tools/src/librtcltools/Rtcl.ipp b/tools/src/librtcltools/Rtcl.ipp index d0b3b165..230fe1e4 100644 --- a/tools/src/librtcltools/Rtcl.ipp +++ b/tools/src/librtcltools/Rtcl.ipp @@ -1,4 +1,4 @@ -// $Id: Rtcl.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: Rtcl.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: Rtcl.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: Rtcl.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of Rtcl. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtcltools/RtclArgs.cpp b/tools/src/librtcltools/RtclArgs.cpp index cf8bd9b3..c2e53571 100644 --- a/tools/src/librtcltools/RtclArgs.cpp +++ b/tools/src/librtcltools/RtclArgs.cpp @@ -1,6 +1,6 @@ -// $Id: RtclArgs.cpp 374 2011-03-27 17:02:47Z mueller $ +// $Id: RtclArgs.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-12 487 1.0.6 add CurrentArg() method +// 2013-02-03 481 1.0.5 use Rexception // 2011-03-26 373 1.0.4 add GetArg(float/double) // 2011-03-13 369 1.0.3 add GetArg(vector); NextOpt clear NOptMiss // 2011-03-06 367 1.0.2 add Config() methods; @@ -24,7 +26,7 @@ /*! \file - \version $Id: RtclArgs.cpp 374 2011-03-27 17:02:47Z mueller $ + \version $Id: RtclArgs.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RtclArgs. */ @@ -34,19 +36,21 @@ #include #include -#include - #include "RtclArgs.hpp" + #include "Rtcl.hpp" +#include "librtools/Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RtclArgs \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -76,7 +80,7 @@ RtclArgs::RtclArgs(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], fArgErr(false) { if (objc < 0) - throw invalid_argument("RtclArgs::ctor: objc must be >= 0"); + throw Rexception("RtclArgs::","Bad args: objc must be >= 0"); } //------------------------------------------+----------------------------------- @@ -104,7 +108,7 @@ RtclArgs::~RtclArgs() Tcl_Obj* RtclArgs::Objv(size_t ind) const { if (ind >= (size_t)fObjc) - throw out_of_range("RtclArgs::Objv: index out-of-range"); + throw Rexception("RtclArgs::Objv()","Bad args: index out-of-range"); return fObjv[ind]; } @@ -403,12 +407,24 @@ bool RtclArgs::NextOpt(std::string& val, RtclNameSet& optset) //------------------------------------------+----------------------------------- //! FIXME_docs +Tcl_Obj* RtclArgs::CurrentArg() const +{ + if (fNDone == 0) + throw Rexception("RtclArgs::CurrentArg()", + "Bad state: no argument processed yet"); + + return fObjv[fNDone-1]; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + bool RtclArgs::AllDone() { if (fArgErr || fOptErr) return false; if (fNDone < fObjc) { - AppendResult("-E: superfluous arguments, first one \"", - Tcl_GetString(fObjv[fNDone]), "\"", NULL); + AppendResult("-E: superfluous arguments, first one '", + Tcl_GetString(fObjv[fNDone]), "'", NULL); return false; } return true; @@ -466,7 +482,7 @@ bool RtclArgs::NextArg(const char* name, Tcl_Obj*& pobj) if (fNDone == fObjc) { if (!isopt) { - AppendResult("-E: required argument \"", name, "\" missing", NULL); + AppendResult("-E: required argument '", name, "' missing", NULL); fArgErr = true; return false; } @@ -520,7 +536,7 @@ bool RtclArgs::NextArgList(const char* name, int& objc, Tcl_Obj**& objv, void RtclArgs::ConfigNameCheck(const char* name) { if (name==0 || name[0]!='?' || name[1]!='?') - throw invalid_argument("RtclArgs::Config(): name must start with ??"); + throw Rexception("RtclArgs::Config()","Bad args: name must start with ??"); return; } @@ -531,17 +547,12 @@ bool RtclArgs::ConfigReadCheck() { if (fNConfigRead != 0) { SetResult(Tcl_NewObj()); - AppendResult("-E: only one config read allowed per command, \"", - PeekArgString(-1), "\" is second", NULL); + AppendResult("-E: only one config read allowed per command, '", + PeekArgString(-1), "' is second", NULL); return false; } fNConfigRead += 1; return true; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclArgs_NoInline)) -#define inline -#include "RtclArgs.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclArgs.hpp b/tools/src/librtcltools/RtclArgs.hpp index bbfdba50..cb100195 100644 --- a/tools/src/librtcltools/RtclArgs.hpp +++ b/tools/src/librtcltools/RtclArgs.hpp @@ -1,6 +1,6 @@ -// $Id: RtclArgs.hpp 373 2011-03-26 08:54:27Z mueller $ +// $Id: RtclArgs.hpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,10 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-05 495 1.0.8 add SetResult(bool) +// 2013-03-02 494 1.0.7 add Quit() method +// 2013-02-12 487 1.0.6 add CurrentArg() method +// 2013-02-01 479 1.0.5 add Objv() method // 2011-03-26 373 1.0.4 add GetArg(flt/dbl), SetResult(str,sos,int,dbl) // 2011-03-13 369 1.0.3 add GetArg(vector) // 2011-03-06 367 1.0.2 add min to GetArg(unsigned); add Config() methods; @@ -25,7 +29,7 @@ /*! \file - \version $Id: RtclArgs.hpp 373 2011-03-26 08:54:27Z mueller $ + \version $Id: RtclArgs.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class RtclArgs. */ @@ -64,6 +68,7 @@ namespace Retro { Tcl_Interp* Interp() const; int Objc() const; + Tcl_Obj* const * Objv() const; Tcl_Obj* Objv(size_t ind) const; bool GetArg(const char* name, Tcl_Obj*& pval); @@ -102,6 +107,8 @@ namespace Retro { bool NextOpt(std::string& val, RtclNameSet& optset); bool OptValid() const; + Tcl_Obj* CurrentArg() const; + bool AllDone(); size_t NDone() const; size_t NOptMiss() const; @@ -110,6 +117,7 @@ namespace Retro { void SetResult(const std::string& str); void SetResult(std::ostringstream& sos); + void SetResult(bool val); void SetResult(int val); void SetResult(double val); void SetResult(Tcl_Obj* pobj); @@ -120,6 +128,8 @@ namespace Retro { void AppendResultLines(const std::string& str); void AppendResultLines(std::ostringstream& sos); + int Quit(const std::string& str); + Tcl_Obj* operator[](size_t ind) const; protected: @@ -144,8 +154,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclArgs_NoInline)) #include "RtclArgs.ipp" -#endif #endif diff --git a/tools/src/librtcltools/RtclArgs.ipp b/tools/src/librtcltools/RtclArgs.ipp index d76cd714..ab89f544 100644 --- a/tools/src/librtcltools/RtclArgs.ipp +++ b/tools/src/librtcltools/RtclArgs.ipp @@ -1,6 +1,6 @@ -// $Id: RtclArgs.ipp 373 2011-03-26 08:54:27Z mueller $ +// $Id: RtclArgs.ipp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,9 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-05 495 1.0.8 add SetResult(bool) +// 2013-03-02 494 1.0.7 add Quit() method +// 2013-02-01 479 1.0.5 add Objv() method // 2011-03-26 373 1.0.2 add SetResult(string) // 2011-03-05 366 1.0.1 add NDone(), NOptMiss(), SetResult(); // 2011-02-26 364 1.0 Initial version @@ -21,13 +24,13 @@ /*! \file - \version $Id: RtclArgs.ipp 373 2011-03-26 08:54:27Z mueller $ + \version $Id: RtclArgs.ipp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation (inline) of RtclArgs. */ #include "Rtcl.hpp" -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- @@ -49,6 +52,14 @@ inline int RtclArgs::Objc() const //------------------------------------------+----------------------------------- //! FIXME_docs +inline Tcl_Obj* const * RtclArgs::Objv() const +{ + return fObjv; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + inline bool RtclArgs::OptValid() const { return !fOptErr; @@ -91,6 +102,15 @@ inline void RtclArgs::SetResult(std::ostringstream& sos) //------------------------------------------+----------------------------------- //! FIXME_docs +inline void RtclArgs::SetResult(bool val) +{ + Tcl_SetObjResult(fpInterp, Tcl_NewBooleanObj(val)); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + inline void RtclArgs::SetResult(int val) { Tcl_SetObjResult(fpInterp, Tcl_NewIntObj(val)); @@ -145,6 +165,15 @@ inline void RtclArgs::AppendResultLines(std::ostringstream& sos) //------------------------------------------+----------------------------------- //! FIXME_docs +inline int RtclArgs::Quit(const std::string& str) +{ + Tcl_AppendResult(fpInterp, str.c_str(), NULL); + return TCL_ERROR; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + inline Tcl_Obj* RtclArgs::operator[](size_t ind) const { return fObjv[ind]; diff --git a/tools/src/librtcltools/RtclClassBase.cpp b/tools/src/librtcltools/RtclClassBase.cpp index c3b461d7..733b04bc 100644 --- a/tools/src/librtcltools/RtclClassBase.cpp +++ b/tools/src/librtcltools/RtclClassBase.cpp @@ -1,6 +1,6 @@ -// $Id: RtclClassBase.cpp 374 2011-03-27 17:02:47Z mueller $ +// $Id: RtclClassBase.cpp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-10 485 1.0.3 add static const defs +// 2013-01-13 474 1.0.2 TclClassCmd(): check for existing Rtclproxy names // 2011-03-05 366 1.0.1 use AppendResultNewLines() in exception catcher // 2011-02-20 363 1.0 Initial version // 2011-02-11 360 0.1 First draft @@ -20,7 +22,7 @@ /*! \file - \version $Id: RtclClassBase.cpp 374 2011-03-27 17:02:47Z mueller $ + \version $Id: RtclClassBase.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RtclClassBase. */ @@ -34,13 +36,21 @@ #include "Rtcl.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RtclClassBase \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const int RtclClassBase::kOK; +const int RtclClassBase::kERR; + //------------------------------------------+----------------------------------- //! Default constructor @@ -74,25 +84,38 @@ void RtclClassBase::CreateClassCmd(Tcl_Interp* interp, const char* name) //------------------------------------------+----------------------------------- //! FIXME_docs -inline int RtclClassBase::TclClassCmd(Tcl_Interp* interp, int objc, +int RtclClassBase::TclClassCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + // no args -> lists existing proxies if (objc == 1) { return ClassCmdList(interp); } + // 2nd arg -delete -> delete proxy const char* name = Tcl_GetString(objv[1]); if (objc == 3 && strcmp(Tcl_GetString(objv[2]), "-delete")==0) { return ClassCmdDelete(interp, name); } - + + // check if proxy of given name already existing + RtclProxyBase* pprox = RtclContext::Find(interp).FindProxy("",name); + if (pprox) { + Tcl_AppendResult(interp, "-E: command name '", name, + "' exists already as RtclProxy of type '", + pprox->Type().c_str(), "'", NULL); + return kERR; + + } + + // finally create new proxy return ClassCmdCreate(interp, objc, objv); } //------------------------------------------+----------------------------------- //! FIXME_docs -inline int RtclClassBase::ClassCmdList(Tcl_Interp* interp) +int RtclClassBase::ClassCmdList(Tcl_Interp* interp) { std::vector list; RtclContext::Find(interp).ListProxy(list, Type()); @@ -112,30 +135,30 @@ inline int RtclClassBase::ClassCmdList(Tcl_Interp* interp) //------------------------------------------+----------------------------------- //! FIXME_docs -inline int RtclClassBase::ClassCmdDelete(Tcl_Interp* interp, const char* name) +int RtclClassBase::ClassCmdDelete(Tcl_Interp* interp, const char* name) { Tcl_CmdInfo cinfo; if (Tcl_GetCommandInfo(interp, name, &cinfo) == 0) { - Tcl_AppendResult(interp, "-E: unknown command name \"", name, "\"", NULL); + Tcl_AppendResult(interp, "-E: unknown command name '", name, "'", NULL); return kERR; } RtclContext& cntx = RtclContext::Find(interp); if (!cntx.CheckProxy((RtclProxyBase*) cinfo.objClientData)) { - Tcl_AppendResult(interp, "-E: command \"", name, "\" is not a RtclProxy", + Tcl_AppendResult(interp, "-E: command '", name, "' is not a RtclProxy", NULL); return kERR; } if (!cntx.CheckProxy((RtclProxyBase*) cinfo.objClientData, Type())) { - Tcl_AppendResult(interp, "-E: command \"", name, - "\" is not a RtclProxy of type \"", - Type().c_str(), "\"", NULL); + Tcl_AppendResult(interp, "-E: command '", name, + "' is not a RtclProxy of type '", + Type().c_str(), "'", NULL); return kERR; } int irc = Tcl_DeleteCommand(interp, name); - if (irc != kOK) Tcl_AppendResult(interp, "-E: failed to delete \"", name, - "\"", NULL); + if (irc != kOK) Tcl_AppendResult(interp, "-E: failed to delete '", name, + "'", NULL); return irc; } @@ -155,8 +178,8 @@ int RtclClassBase::ThunkTclClassCmd(ClientData cdata, Tcl_Interp* interp, return ((RtclClassBase*) cdata)->TclClassCmd(interp, objc, objv); } catch (exception& e) { Rtcl::AppendResultNewLines(interp); - Tcl_AppendResult(interp, "-E: exception caught in ThunkTclClassCmd: \"", - e.what(), "\"", NULL); + Tcl_AppendResult(interp, "-E: exception caught in ThunkTclClassCmd: '", + e.what(), "'", NULL); } return kERR; } @@ -180,9 +203,4 @@ void RtclClassBase::ThunkTclExitProc(ClientData cdata) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclClassBase_NoInline)) -#define inline -#include "RtclClassBase.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclClassBase.hpp b/tools/src/librtcltools/RtclClassBase.hpp index 05a19448..24663846 100644 --- a/tools/src/librtcltools/RtclClassBase.hpp +++ b/tools/src/librtcltools/RtclClassBase.hpp @@ -1,6 +1,6 @@ -// $Id: RtclClassBase.hpp 380 2011-04-25 18:14:52Z mueller $ +// $Id: RtclClassBase.hpp 486 2013-02-10 22:34:43Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -20,7 +20,7 @@ /*! \file - \version $Id: RtclClassBase.hpp 380 2011-04-25 18:14:52Z mueller $ + \version $Id: RtclClassBase.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RtclClassBase. */ @@ -35,8 +35,6 @@ namespace Retro { class RtclClassBase : private boost::noncopyable { public: - static const int kOK = TCL_OK; - static const int kERR = TCL_ERROR; explicit RtclClassBase(const std::string& type = std::string()); virtual ~RtclClassBase(); @@ -44,6 +42,10 @@ namespace Retro { const std::string& Type() const; Tcl_Command Token() const; + // some constants (also defined in cpp) + static const int kOK = TCL_OK; // // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RtclClassBase.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclClassBase.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RtclClassBase. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtcltools/RtclClassOwned.hpp b/tools/src/librtcltools/RtclClassOwned.hpp index 5c07bf89..b924cf0b 100644 --- a/tools/src/librtcltools/RtclClassOwned.hpp +++ b/tools/src/librtcltools/RtclClassOwned.hpp @@ -1,4 +1,4 @@ -// $Id: RtclClassOwned.hpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclClassOwned.hpp 482 2013-02-05 15:53:09Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: RtclClassOwned.hpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclClassOwned.hpp 482 2013-02-05 15:53:09Z mueller $ \brief Declaration of class RtclClassOwned. */ @@ -39,7 +39,7 @@ namespace Retro { public: explicit RtclClassOwned(const std::string& type = std::string()); - ~RtclClassOwned(); + ~RtclClassOwned(); int ClassCmdCreate(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); diff --git a/tools/src/librtcltools/RtclClassOwned.ipp b/tools/src/librtcltools/RtclClassOwned.ipp index c99fceca..06e5bc37 100644 --- a/tools/src/librtcltools/RtclClassOwned.ipp +++ b/tools/src/librtcltools/RtclClassOwned.ipp @@ -1,6 +1,6 @@ -// $Id: RtclClassOwned.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclClassOwned.ipp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,33 +13,36 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-13 474 1.0.1 ClassCmdCreate(): fix configuration failed logic // 2011-02-20 363 1.0 Initial version // 2011-02-11 360 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclClassOwned.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclClassOwned.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of class RtclClassOwned. */ #include +#include #include "RtclProxyBase.hpp" +#include "RtclArgs.hpp" /*! \class Retro::RtclClassOwned \brief FIXME_docs */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- //! Default constructor template -RtclClassOwned::RtclClassOwned(const std::string& type) +inline RtclClassOwned::RtclClassOwned(const std::string& type) : RtclClassBase(type) {} @@ -47,7 +50,7 @@ RtclClassOwned::RtclClassOwned(const std::string& type) //! Destructor template -RtclClassOwned::~RtclClassOwned() +inline RtclClassOwned::~RtclClassOwned() {} //------------------------------------------+----------------------------------- @@ -57,9 +60,16 @@ template inline int RtclClassOwned::ClassCmdCreate(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - TP* pobj = new TP(interp, Tcl_GetString(objv[1])); - if (pobj->ClassCmdConfig(interp, objc, objv) != kOK) { - delete pobj; + RtclArgs args(interp, objc, objv, 1); + std::string name; + if (!args.GetArg("name", name)) return kERR; + + // create new proxy object + TP* pobj = new TP(interp, name.c_str()); + // execute configure, delete command in case configure failed + // Note: deleting the command will implicitely delete the object.. + if (pobj->ClassCmdConfig(args) != kOK) { + ClassCmdDelete(interp, name.c_str()); return kERR; } return kOK; diff --git a/tools/src/librtcltools/RtclCmdBase.cpp b/tools/src/librtcltools/RtclCmdBase.cpp new file mode 100644 index 00000000..f627dceb --- /dev/null +++ b/tools/src/librtcltools/RtclCmdBase.cpp @@ -0,0 +1,140 @@ +// $Id: RtclCmdBase.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2011-2013 by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-10 485 1.0.2 add static const defs +// 2013-02-05 483 1.0.1 remove 'unknown specified, full match only' logic +// 2013-02-02 480 1.0 Initial version (refactored out from ProxyBase) +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclCmdBase.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of RtclCmdBase. +*/ + +#include "RtclCmdBase.hpp" + +#include "librtools/Rexception.hpp" +#include "Rtcl.hpp" + +using namespace std; + +/*! + \class Retro::RtclCmdBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +typedef std::pair mmap_ins_t; + +//------------------------------------------+----------------------------------- +// constants definitions + +const int RtclCmdBase::kOK; +const int RtclCmdBase::kERR; + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclCmdBase::RtclCmdBase() + : fMapMeth() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclCmdBase::~RtclCmdBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclCmdBase::DispatchCmd(RtclArgs& args) +{ + mmap_cit_t it_match; + + Tcl_Interp* interp = args.Interp(); + + // no method name given + if (args.Objc() <= 1) { // no args + it_match = fMapMeth.find("$default"); // default method registered ? + if (it_match != fMapMeth.end()) { + return (it_match->second)(args); + } + Tcl_WrongNumArgs(interp, 1, args.Objv(), "option ?args?"); // or fail + return kERR; + } + + // here if at least method name given + string name(Tcl_GetString(args[1])); + + it_match = fMapMeth.lower_bound(name); + + // no leading substring match + if (it_match==fMapMeth.end() || + name!=it_match->first.substr(0,name.length())) { + + mmap_cit_t it_un = fMapMeth.find("$unknown"); // unknown method registered ? + if (it_un!=fMapMeth.end()) { + return (it_un->second)(args); + } + + Tcl_AppendResult(interp, "-E: bad option '", name.c_str(), + "': must be ", NULL); + const char* delim = ""; + for (mmap_cit_t it1=fMapMeth.begin(); it1!=fMapMeth.end(); it1++) { + if (it1->first.c_str()[0] != '$') { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + } + return kERR; + } + + // check for ambiguous substring match + if (name != it_match->first) { + mmap_cit_t it1 = it_match; + it1++; + if (it1!=fMapMeth.end() && name==it1->first.substr(0,name.length())) { + Tcl_AppendResult(interp, "-E: ambiguous option '", + name.c_str(), "': must be ", NULL); + const char* delim = ""; + for (it1=it_match; it1!=fMapMeth.end() && + name==it1->first.substr(0,name.length()); it1++) { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + return kERR; + } + } + + return (it_match->second)(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclCmdBase::AddMeth(const std::string& name, const methfo_t& methfo) +{ + mmap_ins_t ret = fMapMeth.insert(mmap_val_t(name, methfo)); + if (ret.second == false) // or use !(ret.second) + throw Rexception("RtclCmdBase::AddMeth:", "Bad args: " + + string("duplicate name: ") + name); + return; +} + +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclCmdBase.hpp b/tools/src/librtcltools/RtclCmdBase.hpp new file mode 100644 index 00000000..fecd89ef --- /dev/null +++ b/tools/src/librtcltools/RtclCmdBase.hpp @@ -0,0 +1,69 @@ +// $Id: RtclCmdBase.hpp 486 2013-02-10 22:34:43Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-02 480 1.0 Initial version (refactored out from ProxyBase) +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclCmdBase.hpp 486 2013-02-10 22:34:43Z mueller $ + \brief Declaration of class RtclCmdBase. +*/ + +#ifndef included_Retro_RtclCmdBase +#define included_Retro_RtclCmdBase 1 + +#include "tcl.h" + +#include +#include + +#include "boost/utility.hpp" +#include "boost/function.hpp" + +#include "RtclArgs.hpp" + +namespace Retro { + + class RtclCmdBase : private boost::noncopyable { + public: + typedef boost::function methfo_t; + + typedef std::map mmap_t; + typedef mmap_t::iterator mmap_it_t; + typedef mmap_t::const_iterator mmap_cit_t; + typedef mmap_t::value_type mmap_val_t; + + RtclCmdBase(); + virtual ~RtclCmdBase(); + + int DispatchCmd(RtclArgs& args); + + // some constants (also defined in cpp) + static const int kOK = TCL_OK; // +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.3 use Rexception +// 2013-01-12 474 1.0.2 add FindProxy() method // 2011-03-12 368 1.0.1 drop fExitSeen, get exit handling right // 2011-02-18 362 1.0 Initial version // 2011-02-13 361 0.1 First draft @@ -20,25 +22,28 @@ /*! \file - \version $Id: RtclContext.cpp 368 2011-03-12 09:58:53Z mueller $ + \version $Id: RtclContext.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RtclContext. */ -#include #include #include "RtclContext.hpp" +#include "librtools/Rexception.hpp" + using namespace std; -using namespace Retro; /*! \class Retro::RtclContext \brief FIXME_docs */ -typedef std::pair cset_ins_t; -typedef std::pair pset_ins_t; +// all method definitions in namespace Retro +namespace Retro { + +typedef std::pair cset_ins_t; +typedef std::pair pset_ins_t; RtclContext::xmap_t RtclContext::fMapContext; @@ -64,7 +69,8 @@ void RtclContext::RegisterClass(RtclClassBase* pobj) { cset_ins_t ret = fSetClass.insert(pobj); if (ret.second == false) // or use !(ret.second) - throw logic_error("RtclContext::RegisterClass: duplicate pointer"); + throw Rexception("RtclContext::RegisterClass()", + "Bad args: duplicate pointer"); return; } @@ -84,7 +90,8 @@ void RtclContext::RegisterProxy(RtclProxyBase* pobj) { pset_ins_t ret = fSetProxy.insert(pobj); if (ret.second == false) // or use !(ret.second) - throw logic_error("RtclContext::RegisterProxy: duplicate pointer"); + throw Rexception("RtclContext::RegisterProxy()", + "Bad args: duplicate pointer"); return; } @@ -119,7 +126,6 @@ bool RtclContext::CheckProxy(RtclProxyBase* pobj, const string& type) //------------------------------------------+----------------------------------- //! FIXME_docs - void RtclContext::ListProxy(std::vector& list, const std::string& type) { @@ -135,6 +141,21 @@ void RtclContext::ListProxy(std::vector& list, //------------------------------------------+----------------------------------- //! FIXME_docs +RtclProxyBase* RtclContext::FindProxy(const std::string& type, + const std::string& name) +{ + for (pset_it_t it = fSetProxy.begin(); it != fSetProxy.end(); it++) { + if (type.length() == 0 || (*it)->Type()==type) { + const char* cmdname = Tcl_GetCommandName(fInterp, (*it)->Token()); + if (name == cmdname) return *it; + } + } + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + RtclContext& RtclContext::Find(Tcl_Interp* interp) { RtclContext* pcntx = 0; @@ -169,9 +190,4 @@ void RtclContext::ThunkTclExitProc(ClientData cdata) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclContext_NoInline)) -#define inline -#include "RtclContext.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclContext.hpp b/tools/src/librtcltools/RtclContext.hpp index 3d98bf2a..45b758ec 100644 --- a/tools/src/librtcltools/RtclContext.hpp +++ b/tools/src/librtcltools/RtclContext.hpp @@ -1,6 +1,6 @@ -// $Id: RtclContext.hpp 380 2011-04-25 18:14:52Z mueller $ +// $Id: RtclContext.hpp 490 2013-02-22 18:43:26Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-12 474 1.0.3 add FindProxy() method // 2011-04-24 380 1.0.2 use boost::noncopyable (instead of private dcl's) // 2011-03-12 368 1.0.1 drop fExitSeen, get exit handling right // 2011-02-18 362 1.0 Initial version @@ -21,7 +22,7 @@ /*! \file - \version $Id: RtclContext.hpp 380 2011-04-25 18:14:52Z mueller $ + \version $Id: RtclContext.hpp 490 2013-02-22 18:43:26Z mueller $ \brief Declaration of class RtclContext. */ @@ -52,7 +53,7 @@ namespace Retro { typedef xmap_t::value_type xmap_val_t; explicit RtclContext(Tcl_Interp* interp); - virtual ~RtclContext(); + virtual ~RtclContext(); void RegisterClass(RtclClassBase* pobj); void UnRegisterClass(RtclClassBase* pobj); @@ -64,6 +65,8 @@ namespace Retro { void ListProxy(std::vector& list, const std::string& type); + RtclProxyBase* FindProxy(const std::string& type, + const std::string& name); static RtclContext& Find(Tcl_Interp* interp); @@ -80,8 +83,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclContext_NoInline)) -#include "RtclContext.ipp" -#endif +//#include "RtclContext.ipp" #endif diff --git a/tools/src/librtcltools/RtclGet.hpp b/tools/src/librtcltools/RtclGet.hpp new file mode 100644 index 00000000..7b327881 --- /dev/null +++ b/tools/src/librtcltools/RtclGet.hpp @@ -0,0 +1,56 @@ +// $Id: RtclGet.hpp 487 2013-02-12 19:14:38Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGet.hpp 487 2013-02-12 19:14:38Z mueller $ + \brief Declaration of class \c RtclGet. +*/ + +#ifndef included_Retro_RtclGet +#define included_Retro_RtclGet 1 + +#include "tcl.h" + +#include +#include + +#include "boost/function.hpp" + +#include "RtclGetBase.hpp" + +namespace Retro { + + template + class RtclGet : public RtclGetBase { + public: + explicit RtclGet(const boost::function& get); + ~RtclGet(); + + virtual Tcl_Obj* operator()() const; + + protected: + boost::function fGet; + }; + + +} // end namespace Retro + +#include "RtclGet.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclGet.ipp b/tools/src/librtcltools/RtclGet.ipp new file mode 100644 index 00000000..09a6776c --- /dev/null +++ b/tools/src/librtcltools/RtclGet.ipp @@ -0,0 +1,189 @@ +// $Id: RtclGet.ipp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGet.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class RtclGet. +*/ + +/*! + \class Retro::RtclGet + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclGet::RtclGet(const boost::function& get) + : fGet(get) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclGet::~RtclGet() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + bool val = fGet(); + return Tcl_NewBooleanObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + char val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + signed char val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + unsigned char val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + short val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + unsigned short val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + int val = fGet(); + return Tcl_NewIntObj(val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + unsigned int val = fGet(); + return Tcl_NewIntObj((int)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + long val = fGet(); + return Tcl_NewLongObj(val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + unsigned long val = fGet(); + return Tcl_NewLongObj((long)val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + float val = fGet(); + return Tcl_NewDoubleObj(val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + double val = fGet(); + return Tcl_NewDoubleObj(val); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + std::string val = fGet(); + return Tcl_NewStringObj((char*) val.data(), val.length()); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline Tcl_Obj* RtclGet::operator()() const +{ + std::string val = fGet(); + return Tcl_NewStringObj((char*) val.data(), val.length()); +} + +} // end namespace Retro + diff --git a/tools/src/librtcltools/RtclGetBase.cpp b/tools/src/librtcltools/RtclGetBase.cpp new file mode 100644 index 00000000..8660b24f --- /dev/null +++ b/tools/src/librtcltools/RtclGetBase.cpp @@ -0,0 +1,49 @@ +// $Id: RtclGetBase.cpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGetBase.cpp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation of class RtclGetBase. +*/ + +#include "RtclGetBase.hpp" + +using namespace std; + +/*! + \class Retro::RtclGetBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclGetBase::RtclGetBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclGetBase::~RtclGetBase() +{} + +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclGetBase.hpp b/tools/src/librtcltools/RtclGetBase.hpp new file mode 100644 index 00000000..ef2b26bd --- /dev/null +++ b/tools/src/librtcltools/RtclGetBase.hpp @@ -0,0 +1,50 @@ +// $Id: RtclGetBase.hpp 487 2013-02-12 19:14:38Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGetBase.hpp 487 2013-02-12 19:14:38Z mueller $ + \brief Declaration of class \c RtclGetBase. +*/ + +#ifndef included_Retro_RtclGetBase +#define included_Retro_RtclGetBase 1 + +#include "tcl.h" + +#include +#include + +#include "boost/function.hpp" + +namespace Retro { + + class RtclGetBase { + public: + RtclGetBase(); + virtual ~RtclGetBase(); + + virtual Tcl_Obj* operator()() const = 0; + }; + + +} // end namespace Retro + +//#include "RtclGetBase.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclGetList.cpp b/tools/src/librtcltools/RtclGetList.cpp new file mode 100644 index 00000000..4728c962 --- /dev/null +++ b/tools/src/librtcltools/RtclGetList.cpp @@ -0,0 +1,117 @@ +// $Id: RtclGetList.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGetList.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of class RtclGetList. +*/ + +#include + +#include "librtools/Rexception.hpp" + +#include "RtclGet.hpp" +#include "RtclGetList.hpp" + +using namespace std; + +/*! + \class Retro::RtclGetList + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclGetList::RtclGetList() + : fMap() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclGetList::~RtclGetList() +{ + for (map_cit_t it=fMap.begin(); it != fMap.end(); it++) { + delete (it->second); + } +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclGetList::Add(const std::string& name, RtclGetBase* pget) +{ + typedef std::pair map_ins_t; + map_ins_t ret = fMap.insert(map_val_t(name, pget)); + if (ret.second == false) + throw Rexception("RtclGetList::Add:", "Bad args: " + + string("duplicate name: ") + name); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclGetList::M_get(RtclArgs& args) +{ + string pname; + if (!args.GetArg("pname", pname)) return TCL_ERROR; + + Tcl_Interp* interp = args.Interp(); + map_cit_t it = fMap.lower_bound(pname); + + // complain if not found + if (it == fMap.end() || pname != it->first.substr(0,pname.length())) { + Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(), + "': must be ", NULL); + const char* delim = ""; + for (map_cit_t it1=fMap.begin(); it1!=fMap.end(); it1++) { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + return TCL_ERROR; + } + + // check for ambiguous substring match + map_cit_t it1 = it; + it1++; + if (it1!=fMap.end() && pname==it1->first.substr(0,pname.length())) { + Tcl_AppendResult(interp, "-E: ambiguous property name '", pname.c_str(), + "': must be ", NULL); + const char* delim = ""; + for (it1=it; it1!=fMap.end() && + pname==it1->first.substr(0,pname.length()); it1++) { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + + return TCL_ERROR; + } + + if (!args.AllDone()) return TCL_ERROR; + + args.SetResult((it->second)->operator()()); + return TCL_OK; +} + +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclGetList.hpp b/tools/src/librtcltools/RtclGetList.hpp new file mode 100644 index 00000000..9962334a --- /dev/null +++ b/tools/src/librtcltools/RtclGetList.hpp @@ -0,0 +1,71 @@ +// $Id: RtclGetList.hpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclGetList.hpp 488 2013-02-16 18:49:47Z mueller $ + \brief Declaration of class \c RtclGetList. +*/ + +#ifndef included_Retro_RtclGetList +#define included_Retro_RtclGetList 1 + +#include "tcl.h" + +#include +#include +#include + +#include "boost/utility.hpp" +#include "boost/function.hpp" + +#include "RtclGet.hpp" +#include "librtcltools/RtclArgs.hpp" + +namespace Retro { + + class RtclGetList : private boost::noncopyable { + public: + RtclGetList(); + virtual ~RtclGetList(); + + void Add(const std::string& name, RtclGetBase* pget); + + template + void Add(const std::string& name, + const boost::function& get); + + int M_get(RtclArgs& args); + + protected: + + + protected: + typedef std::map map_t; + typedef map_t::iterator map_it_t; + typedef map_t::const_iterator map_cit_t; + typedef map_t::value_type map_val_t; + + map_t fMap; + }; + +} // end namespace Retro + +#include "RtclGetList.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclContext.ipp b/tools/src/librtcltools/RtclGetList.ipp similarity index 60% rename from tools/src/librtcltools/RtclContext.ipp rename to tools/src/librtcltools/RtclGetList.ipp index 49bc988e..1fc8362c 100644 --- a/tools/src/librtcltools/RtclContext.ipp +++ b/tools/src/librtcltools/RtclGetList.ipp @@ -1,6 +1,6 @@ -// $Id: RtclContext.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclGetList.ipp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2013- by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,24 +13,27 @@ // // Revision History: // Date Rev Version Comment -// 2011-02-18 362 1.0 Initial version -// 2011-02-18 362 0.1 First draft +// 2013-02-12 487 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclContext.ipp 365 2011-02-28 07:28:26Z mueller $ - \brief Implemenation (inline) of RtclContext. + \version $Id: RtclGetList.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class RtclGetList. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- //! FIXME_docs -//inline RtclContext::pset_cit_t RtclContext::Begin() const -//{} - +template +inline void RtclGetList::Add(const std::string& name, + const boost::function& get) +{ + Add(name, new RtclGet(get)); + return; +} } // end namespace Retro diff --git a/tools/src/librtcltools/RtclNameSet.cpp b/tools/src/librtcltools/RtclNameSet.cpp index 1c2247d2..968ace6f 100644 --- a/tools/src/librtcltools/RtclNameSet.cpp +++ b/tools/src/librtcltools/RtclNameSet.cpp @@ -1,6 +1,6 @@ -// $Id: RtclNameSet.cpp 374 2011-03-27 17:02:47Z mueller $ +// $Id: RtclNameSet.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,31 +13,34 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.1 use Rexception // 2011-02-20 363 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclNameSet.cpp 374 2011-03-27 17:02:47Z mueller $ + \version $Id: RtclNameSet.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RtclNameSet. */ // debug #include -#include - #include "RtclNameSet.hpp" +#include "librtools/Rexception.hpp" + using namespace std; -using namespace Retro; /*! \class Retro::RtclNameSet \brief FIXME_docs */ -typedef std::pair nset_ins_t; +// all method definitions in namespace Retro +namespace Retro { + +typedef std::pair nset_ins_t; //------------------------------------------+----------------------------------- //! Default constructor @@ -59,8 +62,9 @@ RtclNameSet::RtclNameSet(const std::string& nset) string name(nset, ibeg, iend-ibeg); nset_ins_t ret = fSet.insert(name); if (ret.second == false) // or use !(ret.second) - throw logic_error(string("RtclNameSet:: duplicate name '") + - name + string("' in set '") + nset + string("'")); + throw Rexception("RtclNameSet::", "Bad args: " + + string("duplicate name '") + name + + string("' in set '") + nset + string("'")); } if (iend == string::npos) break; ibeg = iend+1; @@ -84,8 +88,8 @@ bool RtclNameSet:: Check(Tcl_Interp* interp, std::string& rval, // no leading substring match if (it==fSet.end() || tval!=it->substr(0,tval.length())) { - Tcl_AppendResult(interp, "-E: bad option \"", tval.c_str(), - "\": must be ", NULL); + Tcl_AppendResult(interp, "-E: bad option '", tval.c_str(), + "': must be ", NULL); const char* delim = ""; for (nset_cit_t it1=fSet.begin(); it1!=fSet.end(); it1++) { Tcl_AppendResult(interp, delim, it1->c_str(), NULL); @@ -99,8 +103,8 @@ bool RtclNameSet:: Check(Tcl_Interp* interp, std::string& rval, nset_cit_t it1 = it; it1++; if (it1!=fSet.end() && tval==it1->substr(0,tval.length())) { - Tcl_AppendResult(interp, "-E: ambiguous option \"", tval.c_str(), - "\": must be ", NULL); + Tcl_AppendResult(interp, "-E: ambiguous option '", tval.c_str(), + "': must be ", NULL); const char* delim = ""; for (it1=it; it1!=fSet.end() && tval==it1->substr(0,tval.length()); it1++) { @@ -115,9 +119,4 @@ bool RtclNameSet:: Check(Tcl_Interp* interp, std::string& rval, return true; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclNameSet_NoInline)) -#define inline -#include "RtclNameSet.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclNameSet.hpp b/tools/src/librtcltools/RtclNameSet.hpp index 0766c11e..1bb18d1b 100644 --- a/tools/src/librtcltools/RtclNameSet.hpp +++ b/tools/src/librtcltools/RtclNameSet.hpp @@ -1,4 +1,4 @@ -// $Id: RtclNameSet.hpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclNameSet.hpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: RtclNameSet.hpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclNameSet.hpp 488 2013-02-16 18:49:47Z mueller $ \brief Declaration of class RtclNameSet. */ @@ -54,8 +54,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclNameSet_NoInline)) -#include "RtclNameSet.ipp" -#endif +//#include "RtclNameSet.ipp" #endif diff --git a/tools/src/librtcltools/RtclOPtr.ipp b/tools/src/librtcltools/RtclOPtr.ipp index 48f4f7c1..22952d05 100644 --- a/tools/src/librtcltools/RtclOPtr.ipp +++ b/tools/src/librtcltools/RtclOPtr.ipp @@ -1,4 +1,4 @@ -// $Id: RtclOPtr.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclOPtr.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,7 +18,7 @@ /*! \file - \version $Id: RtclOPtr.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclOPtr.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RtclOPtr. */ @@ -27,7 +27,7 @@ \brief FIXME_docs */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtcltools/RtclProxyBase.cpp b/tools/src/librtcltools/RtclProxyBase.cpp index 9af3b8c4..5413b344 100644 --- a/tools/src/librtcltools/RtclProxyBase.cpp +++ b/tools/src/librtcltools/RtclProxyBase.cpp @@ -1,6 +1,6 @@ -// $Id: RtclProxyBase.cpp 401 2011-07-31 21:02:33Z mueller $ +// $Id: RtclProxyBase.cpp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,10 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-09 485 1.4.2 add CommandName() +// 2013-02-05 483 1.4.1 ClassCmdConfig: use RtclArgs +// 2013-02-02 480 1.4 factor out RtclCmdBase base class +// 2013-02-01 479 1.3 add DispatchCmd(), support $unknown method // 2011-07-31 401 1.2 add ctor(type,interp,name) for direct usage // 2011-04-23 380 1.1 use boost/function instead of RmethDsc // 2011-03-05 366 1.0.1 use AppendResultNewLines() in exception catcher @@ -22,32 +26,33 @@ /*! \file - \version $Id: RtclProxyBase.cpp 401 2011-07-31 21:02:33Z mueller $ + \version $Id: RtclProxyBase.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RtclProxyBase. */ -#include - #include "RtclProxyBase.hpp" + #include "RtclContext.hpp" #include "Rtcl.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RtclProxyBase \brief FIXME_docs */ -typedef std::pair mmap_ins_t; +// all method definitions in namespace Retro +namespace Retro { + +typedef std::pair mmap_ins_t; //------------------------------------------+----------------------------------- //! FIXME_docs RtclProxyBase::RtclProxyBase(const std::string& type) - : fType(type), - fMapMeth(), + : RtclCmdBase(), + fType(type), fInterp(0) {} @@ -56,8 +61,8 @@ RtclProxyBase::RtclProxyBase(const std::string& type) RtclProxyBase::RtclProxyBase(const std::string& type, Tcl_Interp* interp, const char* name) - : fType(type), - fMapMeth(), + : RtclCmdBase(), + fType(type), fInterp(0) { CreateObjectCmd(interp, name); @@ -74,26 +79,18 @@ RtclProxyBase::~RtclProxyBase() //------------------------------------------+----------------------------------- //! FIXME_docs -int RtclProxyBase::ClassCmdConfig(Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]) +int RtclProxyBase::ClassCmdConfig(RtclArgs& args) { - if (objc > 2) { - Tcl_AppendResult(interp, "-E: no configuration args supported", NULL); - return TCL_ERROR; - } - return TCL_OK; + if (!args.AllDone()) return kERR; + return kOK; } //------------------------------------------+----------------------------------- //! FIXME_docs -void RtclProxyBase::AddMeth(const std::string& name, const methfo_t& methfo) +std::string RtclProxyBase::CommandName() const { - mmap_ins_t ret = fMapMeth.insert(mmap_val_t(name, methfo)); - if (ret.second == false) // or use !(ret.second) - throw logic_error(string("RtclProxyBase::AddMeth: duplicate name: ") + - name); - return; + return string(Tcl_GetCommandName(fInterp, fCmdToken)); } //------------------------------------------+----------------------------------- @@ -116,56 +113,8 @@ void RtclProxyBase::CreateObjectCmd(Tcl_Interp* interp, const char* name) int RtclProxyBase::TclObjectCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - mmap_cit_t it_match; - - if (objc == 1) { // no args - mmap_cit_t it = fMapMeth.find("$default"); // default method registered ? - if (it == fMapMeth.end()) { // if not, complain - Tcl_WrongNumArgs(interp, 1, objv, "option ?args?"); - return TCL_ERROR; - } - it_match = it; - - } else { // at least method name given - string name(Tcl_GetString(objv[1])); - mmap_cit_t it = fMapMeth.lower_bound(name); - - // no leading substring match - if (it==fMapMeth.end() || name!=it->first.substr(0,name.length())) { - Tcl_AppendResult(interp, "-E: bad option \"", Tcl_GetString(objv[1]), - "\": must be ", NULL); - const char* delim = ""; - for (mmap_cit_t it1=fMapMeth.begin(); it1!=fMapMeth.end(); it1++) { - if (it1->first.c_str()[0] != '$') { - Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); - delim = ","; - } - } - return TCL_ERROR; - } - - it_match = it; - - // check for ambiguous substring match - if (name != it->first) { - mmap_cit_t it1 = it; - it1++; - if (it1!=fMapMeth.end() && name==it1->first.substr(0,name.length())) { - Tcl_AppendResult(interp, "-E: ambiguous option \"", - Tcl_GetString(objv[1]), "\": must be ", NULL); - const char* delim = ""; - for (it1=it; it1!=fMapMeth.end() && - name==it1->first.substr(0,name.length()); it1++) { - Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); - delim = ","; - } - return TCL_ERROR; - } - } - } - RtclArgs args(interp, objc, objv, 2); - return (it_match->second)(args); + return DispatchCmd(args); } //------------------------------------------+----------------------------------- @@ -184,7 +133,7 @@ int RtclProxyBase::ThunkTclObjectCmd(ClientData cdata, Tcl_Interp* interp, return ((RtclProxyBase*) cdata)->TclObjectCmd(interp, objc, objv); } catch (exception& e) { Rtcl::AppendResultNewLines(interp); - Tcl_AppendResult(interp, "-E: exception caught \"", e.what(), "\"", NULL); + Tcl_AppendResult(interp, "-E: exception caught '", e.what(), "'", NULL); } return TCL_ERROR; } @@ -208,9 +157,4 @@ void RtclProxyBase::ThunkTclExitProc(ClientData cdata) return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclProxyBase_NoInline)) -#define inline -#include "RtclProxyBase.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclProxyBase.hpp b/tools/src/librtcltools/RtclProxyBase.hpp index 3bd085e4..68a5f2e7 100644 --- a/tools/src/librtcltools/RtclProxyBase.hpp +++ b/tools/src/librtcltools/RtclProxyBase.hpp @@ -1,6 +1,6 @@ -// $Id: RtclProxyBase.hpp 401 2011-07-31 21:02:33Z mueller $ +// $Id: RtclProxyBase.hpp 486 2013-02-10 22:34:43Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,10 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-09 485 1.4.2 add CommandName() +// 2013-02-05 483 1.4.1 ClassCmdConfig: use RtclArgs +// 2013-02-02 480 1.4 factor out RtclCmdBase base class +// 2013-02-01 479 1.3 add DispatchCmd(), support $unknown method // 2011-07-31 401 1.2 add ctor(type,interp,name) for direct usage // 2011-04-23 380 1.1 use boost/function instead of RmethDsc // use boost::noncopyable (instead of private dcl's) @@ -22,7 +26,7 @@ /*! \file - \version $Id: RtclProxyBase.hpp 401 2011-07-31 21:02:33Z mueller $ + \version $Id: RtclProxyBase.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RtclProxyBase. */ @@ -34,41 +38,29 @@ #include #include -#include "boost/utility.hpp" -#include "boost/function.hpp" +#include "RtclCmdBase.hpp" #include "RtclArgs.hpp" namespace Retro { - class RtclProxyBase : private boost::noncopyable { + class RtclProxyBase : public RtclCmdBase { public: - static const int kOK = TCL_OK; - static const int kERR = TCL_ERROR; - - typedef boost::function methfo_t; - - typedef std::map mmap_t; - typedef mmap_t::iterator mmap_it_t; - typedef mmap_t::const_iterator mmap_cit_t; - typedef mmap_t::value_type mmap_val_t; explicit RtclProxyBase(const std::string& type = std::string()); RtclProxyBase(const std::string& type, Tcl_Interp* interp, const char* name); - virtual ~RtclProxyBase(); + virtual ~RtclProxyBase(); - virtual int ClassCmdConfig(Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]); + virtual int ClassCmdConfig(RtclArgs& args); const std::string& Type() const; Tcl_Command Token() const; + std::string CommandName() const; protected: void SetType(const std::string& type); - void AddMeth(const std::string& name, const methfo_t& methfo); - void CreateObjectCmd(Tcl_Interp* interp, const char* name); int TclObjectCmd(Tcl_Interp* interp, int objc, @@ -81,15 +73,12 @@ namespace Retro { protected: std::string fType; //!< proxied type name - mmap_t fMapMeth; //!< map for named methods Tcl_Interp* fInterp; //!< tcl interpreter Tcl_Command fCmdToken; //!< cmd token for object command }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclProxyBase_NoInline)) #include "RtclProxyBase.ipp" -#endif #endif diff --git a/tools/src/librtcltools/RtclProxyBase.ipp b/tools/src/librtcltools/RtclProxyBase.ipp index 14af0bca..d43ffd34 100644 --- a/tools/src/librtcltools/RtclProxyBase.ipp +++ b/tools/src/librtcltools/RtclProxyBase.ipp @@ -1,4 +1,4 @@ -// $Id: RtclProxyBase.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclProxyBase.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -13,17 +13,18 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-08 484 1.0.1 add CommandName() // 2011-02-20 363 1.0 Initial version // 2011-02-13 361 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclProxyBase.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclProxyBase.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RtclProxyBase. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtcltools/RtclProxyOwned.hpp b/tools/src/librtcltools/RtclProxyOwned.hpp index 8c840cdc..c704e813 100644 --- a/tools/src/librtcltools/RtclProxyOwned.hpp +++ b/tools/src/librtcltools/RtclProxyOwned.hpp @@ -1,6 +1,6 @@ -// $Id: RtclProxyOwned.hpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclProxyOwned.hpp 490 2013-02-22 18:43:26Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,19 +13,22 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-05 482 1.1 use shared_ptr to TO*; add ObjPtr(); // 2011-02-13 361 1.0 Initial version // 2011-02-11 360 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclProxyOwned.hpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclProxyOwned.hpp 490 2013-02-22 18:43:26Z mueller $ \brief Declaration of class RtclProxyOwned. */ -#ifndef included_Retro_RtclProxyOwned +#ifndef included_Retro_RtclProxyOwned #define included_Retro_RtclProxyOwned 1 +#include "boost/shared_ptr.hpp" + #include "RtclProxyBase.hpp" namespace Retro { @@ -37,16 +40,13 @@ namespace Retro { RtclProxyOwned(const std::string& type); RtclProxyOwned(const std::string& type, Tcl_Interp* interp, const char* name, TO* pobj=0); - ~RtclProxyOwned(); + ~RtclProxyOwned(); TO& Obj(); + const boost::shared_ptr& ObjSPtr(); protected: - void SetObj(TO* pobj); - - protected: - TO* fpObj; //!< ptr to managed object - + boost::shared_ptr fspObj; //!< sptr to managed object }; diff --git a/tools/src/librtcltools/RtclProxyOwned.ipp b/tools/src/librtcltools/RtclProxyOwned.ipp index f364d83d..48b5171c 100644 --- a/tools/src/librtcltools/RtclProxyOwned.ipp +++ b/tools/src/librtcltools/RtclProxyOwned.ipp @@ -1,6 +1,6 @@ -// $Id: RtclProxyOwned.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclProxyOwned.ipp 491 2013-02-23 12:41:18Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-05 482 1.1 use shared_ptr to TO*; add ObjPtr(); // 2011-02-13 361 1.0 Initial version // 2011-02-11 360 0.1 First draft // --------------------------------------------------------------------------- @@ -20,10 +21,15 @@ /*! \file \version $Id: - \brief Implemenation (inline) of class RtclProxyOwned. + \brief Implemenation (all inline) of class RtclProxyOwned. */ -// all method definitions in namespace Retro (avoid using in includes...) +/*! + \class Retro::RtclProxyOwned + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- @@ -32,7 +38,7 @@ namespace Retro { template inline RtclProxyOwned::RtclProxyOwned() : RtclProxyBase(), - fpObj(0) + fspObj() {} //------------------------------------------+----------------------------------- @@ -41,7 +47,7 @@ inline RtclProxyOwned::RtclProxyOwned() template inline RtclProxyOwned::RtclProxyOwned(const std::string& type) : RtclProxyBase(type), - fpObj(0) + fspObj() {} //------------------------------------------+----------------------------------- @@ -52,7 +58,7 @@ inline RtclProxyOwned::RtclProxyOwned(const std::string& type, Tcl_Interp* interp, const char* name, TO* pobj) : RtclProxyBase(type), - fpObj(pobj) + fspObj(pobj) { CreateObjectCmd(interp, name); } @@ -62,9 +68,7 @@ inline RtclProxyOwned::RtclProxyOwned(const std::string& type, template inline RtclProxyOwned::~RtclProxyOwned() -{ - delete fpObj; -} +{} //------------------------------------------+----------------------------------- //! FIXME_docs @@ -72,7 +76,16 @@ inline RtclProxyOwned::~RtclProxyOwned() template inline TO& RtclProxyOwned::Obj() { - return *fpObj; + return *fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline const boost::shared_ptr& RtclProxyOwned::ObjSPtr() +{ + return fspObj; } } // end namespace Retro diff --git a/tools/src/librtcltools/RtclSet.hpp b/tools/src/librtcltools/RtclSet.hpp new file mode 100644 index 00000000..e9e11db1 --- /dev/null +++ b/tools/src/librtcltools/RtclSet.hpp @@ -0,0 +1,57 @@ +// $Id: RtclSet.hpp 487 2013-02-12 19:14:38Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSet.hpp 487 2013-02-12 19:14:38Z mueller $ + \brief Declaration of class \c RtclSet. +*/ + +#ifndef included_Retro_RtclSet +#define included_Retro_RtclSet 1 + +#include "tcl.h" + +#include +#include + +#include "boost/function.hpp" + +#include "librtools/Rexception.hpp" +#include "RtclSetBase.hpp" + +namespace Retro { + + template + class RtclSet : public RtclSetBase { + public: + explicit RtclSet(const boost::function& set); + ~RtclSet(); + + virtual void operator()(RtclArgs& args) const; + + protected: + boost::function fSet; + }; + + +} // end namespace Retro + +#include "RtclSet.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclSet.ipp b/tools/src/librtcltools/RtclSet.ipp new file mode 100644 index 00000000..74f46d48 --- /dev/null +++ b/tools/src/librtcltools/RtclSet.ipp @@ -0,0 +1,250 @@ +// $Id: RtclSet.ipp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSet.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class RtclSet. +*/ + +/*! + \class Retro::RtclSet + \brief FIXME_docs +*/ + +#include +#include + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclSet::RtclSet(const boost::function& set) + : fSet(set) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclSet::~RtclSet() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetBooleanFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet((bool)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if (val < CHAR_MIN || val > CHAR_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'char'"); + + fSet((char)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if (val < SCHAR_MIN || val > SCHAR_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'signed char'"); + + fSet((signed char)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if ((unsigned int)val > UCHAR_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'unsigned char'"); + + fSet((unsigned char)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if (val < SHRT_MIN || val > SHRT_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'short'"); + + fSet((short)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if ((unsigned int)val > USHRT_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'unsigned short'"); + + fSet((unsigned short)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet(val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + int val; + if(Tcl_GetIntFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet((unsigned int) val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + long val; + if(Tcl_GetLongFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet(val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + long val; + if(Tcl_GetLongFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet((unsigned long) val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + double val; + if(Tcl_GetDoubleFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + if (val < -FLT_MAX || val > FLT_MAX) + throw Rexception("RtclSet<>::oper()", + "out of range for type 'float'"); + + fSet((float)val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + double val; + if(Tcl_GetDoubleFromObj(args.Interp(), args.CurrentArg(), &val) != TCL_OK) + throw Rexception("RtclSet<>::oper()", "conversion error"); + + fSet(val); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template <> +inline void RtclSet::operator()(RtclArgs& args) const +{ + char* val = Tcl_GetString(args.CurrentArg()); + fSet(std::string(val)); + return; +} + + +} // end namespace Retro + diff --git a/tools/src/librtcltools/RtclSetBase.cpp b/tools/src/librtcltools/RtclSetBase.cpp new file mode 100644 index 00000000..b89fdec5 --- /dev/null +++ b/tools/src/librtcltools/RtclSetBase.cpp @@ -0,0 +1,49 @@ +// $Id: RtclSetBase.cpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSetBase.cpp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation of class RtclSetBase. +*/ + +#include "RtclSetBase.hpp" + +using namespace std; + +/*! + \class Retro::RtclSetBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclSetBase::RtclSetBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclSetBase::~RtclSetBase() +{} + +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclSetBase.hpp b/tools/src/librtcltools/RtclSetBase.hpp new file mode 100644 index 00000000..1f2b1591 --- /dev/null +++ b/tools/src/librtcltools/RtclSetBase.hpp @@ -0,0 +1,52 @@ +// $Id: RtclSetBase.hpp 487 2013-02-12 19:14:38Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSetBase.hpp 487 2013-02-12 19:14:38Z mueller $ + \brief Declaration of class \c RtclSetBase. +*/ + +#ifndef included_Retro_RtclSetBase +#define included_Retro_RtclSetBase 1 + +#include "tcl.h" + +#include +#include + +#include "boost/function.hpp" + +#include "RtclArgs.hpp" + +namespace Retro { + + class RtclSetBase { + public: + RtclSetBase(); + virtual ~RtclSetBase(); + + virtual void operator()(RtclArgs& args) const = 0; + }; + + +} // end namespace Retro + +//#include "RtclSetBase.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclSetList.cpp b/tools/src/librtcltools/RtclSetList.cpp new file mode 100644 index 00000000..10ea7362 --- /dev/null +++ b/tools/src/librtcltools/RtclSetList.cpp @@ -0,0 +1,126 @@ +// $Id: RtclSetList.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSetList.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of class RtclSetList. +*/ + +#include + +#include "librtools/Rexception.hpp" + +#include "RtclSet.hpp" +#include "RtclSetList.hpp" + +using namespace std; + +/*! + \class Retro::RtclSetList + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclSetList::RtclSetList() + : fMap() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclSetList::~RtclSetList() +{ + for (map_cit_t it=fMap.begin(); it != fMap.end(); it++) { + delete (it->second); + } +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclSetList::Add(const std::string& name, RtclSetBase* pset) +{ + typedef std::pair map_ins_t; + map_ins_t ret = fMap.insert(map_val_t(name, pset)); + if (ret.second == false) + throw Rexception("RtclSetList::Add:", "Bad args: " + + string("duplicate name: ") + name); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclSetList::M_set(RtclArgs& args) +{ + string pname; + if (!args.GetArg("pname", pname)) return TCL_ERROR; + + Tcl_Interp* interp = args.Interp(); + map_cit_t it = fMap.lower_bound(pname); + + // complain if not found + if (it == fMap.end() || pname != it->first.substr(0,pname.length())) { + Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(), + "': must be ", NULL); + const char* delim = ""; + for (map_cit_t it1=fMap.begin(); it1!=fMap.end(); it1++) { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + return TCL_ERROR; + } + + // check for ambiguous substring match + map_cit_t it1 = it; + it1++; + if (it1!=fMap.end() && pname==it1->first.substr(0,pname.length())) { + Tcl_AppendResult(interp, "-E: ambiguous property name '", pname.c_str(), + "': must be ", NULL); + const char* delim = ""; + for (it1=it; it1!=fMap.end() && + pname==it1->first.substr(0,pname.length()); it1++) { + Tcl_AppendResult(interp, delim, it1->first.c_str(), NULL); + delim = ","; + } + + return TCL_ERROR; + } + + Tcl_Obj* pobj; + if (!args.GetArg("val", pobj)) return TCL_ERROR; + if (!args.AllDone()) return TCL_ERROR; + + try { + (it->second)->operator()(args); + } catch (Rexception& e) { + Tcl_AppendResult(args.Interp(), ", ", e.ErrMsg().Text().c_str(), NULL); + } catch (exception& e) { + Tcl_AppendResult(args.Interp(), " -E: ", e.what(), NULL); + } + + return TCL_OK; +} + +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclSetList.hpp b/tools/src/librtcltools/RtclSetList.hpp new file mode 100644 index 00000000..676f5c86 --- /dev/null +++ b/tools/src/librtcltools/RtclSetList.hpp @@ -0,0 +1,71 @@ +// $Id: RtclSetList.hpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclSetList.hpp 488 2013-02-16 18:49:47Z mueller $ + \brief Declaration of class \c RtclSetList. +*/ + +#ifndef included_Retro_RtclSetList +#define included_Retro_RtclSetList 1 + +#include "tcl.h" + +#include +#include +#include + +#include "boost/utility.hpp" +#include "boost/function.hpp" + +#include "RtclSet.hpp" +#include "librtcltools/RtclArgs.hpp" + +namespace Retro { + + class RtclSetList : private boost::noncopyable { + public: + RtclSetList(); + virtual ~RtclSetList(); + + void Add(const std::string& name, RtclSetBase* pset); + + template + void Add(const std::string& name, + const boost::function& set); + + int M_set(RtclArgs& args); + + protected: + + + protected: + typedef std::map map_t; + typedef map_t::iterator map_it_t; + typedef map_t::const_iterator map_cit_t; + typedef map_t::value_type map_val_t; + + map_t fMap; + }; + +} // end namespace Retro + +#include "RtclSetList.ipp" + +#endif diff --git a/tools/src/librtools/RlogStd.cpp b/tools/src/librtcltools/RtclSetList.ipp similarity index 55% rename from tools/src/librtools/RlogStd.cpp rename to tools/src/librtcltools/RtclSetList.ipp index acef6c89..f7861d26 100644 --- a/tools/src/librtools/RlogStd.cpp +++ b/tools/src/librtcltools/RtclSetList.ipp @@ -1,6 +1,6 @@ -// $Id: RlogStd.cpp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RtclSetList.ipp 488 2013-02-16 18:49:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2013- by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,22 +13,27 @@ // // Revision History: // Date Rev Version Comment -// 2011-02-04 358 1.0 Initial version +// 2013-02-12 487 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RlogStd.cpp 359 2011-02-06 22:37:43Z mueller $ - \brief Implemenation of RlogStd. + \version $Id: RtclSetList.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of class RtclSetList. */ -#include - -#include "RlogStd.hpp" +// all method definitions in namespace Retro +namespace Retro { //------------------------------------------+----------------------------------- -// define global RlogFile objects +//! FIXME_docs -Retro::RlogFile Retro::gRcout(&std::cout); //!< foo -Retro::RlogFile Retro::gRcerr(&std::cerr); //!< bar +template +inline void RtclSetList::Add(const std::string& name, + const boost::function& set) +{ + Add(name, new RtclSet(set)); + return; +} +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclStats.cpp b/tools/src/librtcltools/RtclStats.cpp index bcc7f91f..3587d3cc 100644 --- a/tools/src/librtcltools/RtclStats.cpp +++ b/tools/src/librtcltools/RtclStats.cpp @@ -1,6 +1,6 @@ -// $Id: RtclStats.cpp 374 2011-03-27 17:02:47Z mueller $ +// $Id: RtclStats.cpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-06 495 1.0.1 Rename Exec->Collect // 2011-02-26 364 1.0 Initial version // 2011-02-20 363 0.1 First draft // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclStats.cpp 374 2011-03-27 17:02:47Z mueller $ + \version $Id: RtclStats.cpp 495 2013-03-06 17:13:48Z mueller $ \brief Implemenation of RtclStats. */ @@ -30,7 +31,14 @@ #include "RtclOPtr.hpp" using namespace std; -using namespace Retro; + +/*! + \class Retro::RtclStats + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { //------------------------------------------+----------------------------------- //! FIXME_docs @@ -73,7 +81,8 @@ bool RtclStats::GetArgs(RtclArgs& args, Context& cntx) //------------------------------------------+----------------------------------- //! FIXME_docs -bool RtclStats::Exec(RtclArgs& args, Context& cntx, const Rstats& stats) +bool RtclStats::Collect(RtclArgs& args, const Context& cntx, + const Rstats& stats) { Tcl_Interp* interp = args.Interp(); Tcl_Obj* plist = Tcl_GetObjResult(interp); @@ -135,17 +144,12 @@ bool RtclStats::Exec(RtclArgs& args, Context& cntx, const Rstats& stats) args.AppendResultLines(sos); } else { - args.AppendResult("-E: BUG! RtclStats::Exec: bad option \"", - cntx.opt.c_str(), "\"", NULL); + args.AppendResult("-E: BUG! RtclStats::Collect: bad option '", + cntx.opt.c_str(), "'", NULL); return false; } return true; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclStats_NoInline)) -#define inline -//#include "RtclStats.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtcltools/RtclStats.hpp b/tools/src/librtcltools/RtclStats.hpp index 7e637bee..5f43fedd 100644 --- a/tools/src/librtcltools/RtclStats.hpp +++ b/tools/src/librtcltools/RtclStats.hpp @@ -1,6 +1,6 @@ -// $Id: RtclStats.hpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RtclStats.hpp 495 2013-03-06 17:13:48Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-03-06 495 1.0.1 Rename Exec->Collect // 2011-02-26 364 1.0 Initial version // 2011-02-20 363 0.1 fFirst draft // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RtclStats.hpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RtclStats.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class RtclStats. */ @@ -49,13 +50,12 @@ namespace Retro { }; static bool GetArgs(RtclArgs& args, Context& cntx); - static bool Exec(RtclArgs& args, Context& cntx, const Rstats& stats); + static bool Collect(RtclArgs& args, const Context& cntx, + const Rstats& stats); }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclStats_NoInline)) //#include "RtclStats.ipp" -#endif #endif diff --git a/tools/src/librtools/Makefile b/tools/src/librtools/Makefile index 76387fb2..a92f8529 100644 --- a/tools/src/librtools/Makefile +++ b/tools/src/librtools/Makefile @@ -1,7 +1,8 @@ -# $Id: Makefile 401 2011-07-31 21:02:33Z mueller $ +# $Id: Makefile 493 2013-03-01 21:02:33Z mueller $ # # Revision History: # Date Rev Version Comment +# 2013-02-01 479 1.1.1 use checkpath_cpp.mk # 2011-07-31 401 1.1 rename realclean->distclean # 2011-03-27 374 1.0.1 removed Rnamed (obsolete now) # 2011-01-15 357 1.0 Initial version (adopted from CTB...) @@ -15,15 +16,18 @@ SOMINV = 0 # # Compile and Link search paths # -INCLFLAGS = -LDLIBS = +include ../checkpath_cpp.mk +# +INCLFLAGS = -I${BOOSTINC} +LDLIBS = -L${BOOSTLIB} -lboost_thread # # Object files to be included # OBJ_all = RerrMsg.o RosFill.o RosPrintBvi.o RosPrintfBase.o RosPrintfS.o \ - RiosState.o \ - RlogFile.o RlogStd.o \ - Rstats.o Rtools.o + RiosState.o Rbits.o \ + RlogFile.o RlogFileCatalog.o RlogMsg.o \ + Rstats.o Rtools.o \ + Rexception.o RparseUrl.o # DEP_all = $(OBJ_all:.o=.dep) # @@ -36,10 +40,13 @@ SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) include $(RETROBASE)/tools/make/generic_cpp.mk include $(RETROBASE)/tools/make/generic_dep.mk include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk # # The magic autodependcy include # +ifndef DONTINCDEP include $(DEP_all) +endif # # cleanup phonies: # diff --git a/tools/src/librtools/Rbits.cpp b/tools/src/librtools/Rbits.cpp new file mode 100644 index 00000000..7aee1f79 --- /dev/null +++ b/tools/src/librtools/Rbits.cpp @@ -0,0 +1,92 @@ +// $Id: Rbits.cpp 493 2013-03-01 21:02:33Z mueller $ +// +// Copyright 2011-2013 by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rbits.cpp 493 2013-03-01 21:02:33Z mueller $ + \brief Implemenation of Rbits . +*/ + +#include "Rbits.hpp" + +// all definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const uint8_t Rbits::kBBit00; +const uint8_t Rbits::kBBit01; +const uint8_t Rbits::kBBit02; +const uint8_t Rbits::kBBit03; +const uint8_t Rbits::kBBit04; +const uint8_t Rbits::kBBit05; +const uint8_t Rbits::kBBit06; +const uint8_t Rbits::kBBit07; + +const uint16_t Rbits::kWBit00; +const uint16_t Rbits::kWBit01; +const uint16_t Rbits::kWBit02; +const uint16_t Rbits::kWBit03; +const uint16_t Rbits::kWBit04; +const uint16_t Rbits::kWBit05; +const uint16_t Rbits::kWBit06; +const uint16_t Rbits::kWBit07; +const uint16_t Rbits::kWBit08; +const uint16_t Rbits::kWBit09; +const uint16_t Rbits::kWBit10; +const uint16_t Rbits::kWBit11; +const uint16_t Rbits::kWBit12; +const uint16_t Rbits::kWBit13; +const uint16_t Rbits::kWBit14; +const uint16_t Rbits::kWBit15; + +const uint32_t Rbits::kLBit00; +const uint32_t Rbits::kLBit01; +const uint32_t Rbits::kLBit02; +const uint32_t Rbits::kLBit03; +const uint32_t Rbits::kLBit04; +const uint32_t Rbits::kLBit05; +const uint32_t Rbits::kLBit06; +const uint32_t Rbits::kLBit07; +const uint32_t Rbits::kLBit08; +const uint32_t Rbits::kLBit09; +const uint32_t Rbits::kLBit10; +const uint32_t Rbits::kLBit11; +const uint32_t Rbits::kLBit12; +const uint32_t Rbits::kLBit13; +const uint32_t Rbits::kLBit14; +const uint32_t Rbits::kLBit15; +const uint32_t Rbits::kLBit16; +const uint32_t Rbits::kLBit17; +const uint32_t Rbits::kLBit18; +const uint32_t Rbits::kLBit19; +const uint32_t Rbits::kLBit20; +const uint32_t Rbits::kLBit21; +const uint32_t Rbits::kLBit22; +const uint32_t Rbits::kLBit23; +const uint32_t Rbits::kLBit24; +const uint32_t Rbits::kLBit25; +const uint32_t Rbits::kLBit26; +const uint32_t Rbits::kLBit27; +const uint32_t Rbits::kLBit28; +const uint32_t Rbits::kLBit29; +const uint32_t Rbits::kLBit30; +const uint32_t Rbits::kLBit31; + +} // end namespace Retro diff --git a/tools/src/librtools/Rbits.hpp b/tools/src/librtools/Rbits.hpp new file mode 100644 index 00000000..da8a1a02 --- /dev/null +++ b/tools/src/librtools/Rbits.hpp @@ -0,0 +1,99 @@ +// $Id: Rbits.hpp 493 2013-03-01 21:02:33Z mueller $ +// +// Copyright 2011-2013 by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rbits.hpp 493 2013-03-01 21:02:33Z mueller $ + \brief Declaration of class Rbits . +*/ + +#ifndef included_Retro_Rbits +#define included_Retro_Rbits 1 + +#include + +namespace Retro { + class Rbits { + public: + + static const uint8_t kBBit00 = 1u<< 0; + static const uint8_t kBBit01 = 1u<< 1; + static const uint8_t kBBit02 = 1u<< 2; + static const uint8_t kBBit03 = 1u<< 3; + static const uint8_t kBBit04 = 1u<< 4; + static const uint8_t kBBit05 = 1u<< 5; + static const uint8_t kBBit06 = 1u<< 6; + static const uint8_t kBBit07 = 1u<< 7; + + static const uint16_t kWBit00 = 1u<< 0; + static const uint16_t kWBit01 = 1u<< 1; + static const uint16_t kWBit02 = 1u<< 2; + static const uint16_t kWBit03 = 1u<< 3; + static const uint16_t kWBit04 = 1u<< 4; + static const uint16_t kWBit05 = 1u<< 5; + static const uint16_t kWBit06 = 1u<< 6; + static const uint16_t kWBit07 = 1u<< 7; + static const uint16_t kWBit08 = 1u<< 8; + static const uint16_t kWBit09 = 1u<< 9; + static const uint16_t kWBit10 = 1u<<10; + static const uint16_t kWBit11 = 1u<<11; + static const uint16_t kWBit12 = 1u<<12; + static const uint16_t kWBit13 = 1u<<13; + static const uint16_t kWBit14 = 1u<<14; + static const uint16_t kWBit15 = 1u<<15; + + static const uint32_t kLBit00 = 1u<< 0; + static const uint32_t kLBit01 = 1u<< 1; + static const uint32_t kLBit02 = 1u<< 2; + static const uint32_t kLBit03 = 1u<< 3; + static const uint32_t kLBit04 = 1u<< 4; + static const uint32_t kLBit05 = 1u<< 5; + static const uint32_t kLBit06 = 1u<< 6; + static const uint32_t kLBit07 = 1u<< 7; + static const uint32_t kLBit08 = 1u<< 8; + static const uint32_t kLBit09 = 1u<< 9; + static const uint32_t kLBit10 = 1u<<10; + static const uint32_t kLBit11 = 1u<<11; + static const uint32_t kLBit12 = 1u<<12; + static const uint32_t kLBit13 = 1u<<13; + static const uint32_t kLBit14 = 1u<<14; + static const uint32_t kLBit15 = 1u<<15; + static const uint32_t kLBit16 = 1u<<16; + static const uint32_t kLBit17 = 1u<<17; + static const uint32_t kLBit18 = 1u<<18; + static const uint32_t kLBit19 = 1u<<19; + static const uint32_t kLBit20 = 1u<<20; + static const uint32_t kLBit21 = 1u<<21; + static const uint32_t kLBit22 = 1u<<22; + static const uint32_t kLBit23 = 1u<<23; + static const uint32_t kLBit24 = 1u<<24; + static const uint32_t kLBit25 = 1u<<25; + static const uint32_t kLBit26 = 1u<<26; + static const uint32_t kLBit27 = 1u<<27; + static const uint32_t kLBit28 = 1u<<28; + static const uint32_t kLBit29 = 1u<<29; + static const uint32_t kLBit30 = 1u<<30; + static const uint32_t kLBit31 = 1u<<31; + + }; + +} // end namespace Retro + +//#include "Rbits.ipp" + +#endif diff --git a/tools/src/librtools/RerrMsg.cpp b/tools/src/librtools/RerrMsg.cpp index 221d0ab7..f2d15fed 100644 --- a/tools/src/librtools/RerrMsg.cpp +++ b/tools/src/librtools/RerrMsg.cpp @@ -1,6 +1,6 @@ -// $Id: RerrMsg.cpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RerrMsg.cpp 493 2013-03-01 21:02:33Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-12 474 1.2 add meth+text and meth+text+errnum ctors // 2011-02-06 359 1.1 use references in interface, fix printf usage // 2011-01-15 356 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RerrMsg.cpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RerrMsg.cpp 493 2013-03-01 21:02:33Z mueller $ \brief Implemenation of RerrMsg. */ @@ -30,13 +31,15 @@ #include "RerrMsg.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RerrMsg \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -46,13 +49,31 @@ RerrMsg::RerrMsg() {} //------------------------------------------+----------------------------------- -//! FIXME_docs +//! Copy constructor RerrMsg::RerrMsg(const RerrMsg& rhs) : fMeth(rhs.fMeth), fText(rhs.fText) {} +//------------------------------------------+----------------------------------- +//! Construct from method and message text + +RerrMsg::RerrMsg(const std::string& meth, const std::string& text) + : fMeth(meth), + fText(text) +{} + +//------------------------------------------+----------------------------------- +//! Construct from method and message text and errno + +RerrMsg::RerrMsg(const std::string& meth, const std::string& text, int errnum) + : fMeth(meth), + fText(text) +{ + AppendErrno(errnum); +} + //------------------------------------------+----------------------------------- //! Destructor @@ -157,7 +178,7 @@ std::string RerrMsg::Message() const //------------------------------------------+----------------------------------- //! FIXME_docs -void RerrMsg::Grab(RerrMsg& rhs) +void RerrMsg::Swap(RerrMsg& rhs) { fMeth.swap(rhs.fMeth); fText.swap(rhs.fText); @@ -175,9 +196,4 @@ RerrMsg& RerrMsg::operator=(const RerrMsg& rhs) return *this; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RerrMsg_NoInline)) -#define inline -#include "RerrMsg.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtools/RerrMsg.hpp b/tools/src/librtools/RerrMsg.hpp index ab103cbd..9dbbb5ad 100644 --- a/tools/src/librtools/RerrMsg.hpp +++ b/tools/src/librtools/RerrMsg.hpp @@ -1,6 +1,6 @@ -// $Id: RerrMsg.hpp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RerrMsg.hpp 493 2013-03-01 21:02:33Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2013-01-12 474 1.2 add meth+text and meth+text+errnum ctors // 2011-02-06 359 1.1 use references in interface // 2011-01-15 356 1.0 Initial version // --------------------------------------------------------------------------- @@ -20,7 +21,7 @@ /*! \file - \version $Id: RerrMsg.hpp 359 2011-02-06 22:37:43Z mueller $ + \version $Id: RerrMsg.hpp 493 2013-03-01 21:02:33Z mueller $ \brief Declaration of class RerrMsg. */ @@ -36,6 +37,9 @@ namespace Retro { public: RerrMsg(); RerrMsg(const RerrMsg& rhs); + RerrMsg(const std::string& meth, const std::string& text); + RerrMsg(const std::string& meth, const std::string& text, + int errnum); ~RerrMsg(); void Init(const std::string& meth, const std::string& text); @@ -56,7 +60,7 @@ namespace Retro { const std::string& Text() const; std::string Message() const; - void Grab(RerrMsg& rhs); + void Swap(RerrMsg& rhs); RerrMsg& operator=(const RerrMsg& rhs); operator std::string() const; @@ -70,8 +74,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RerrMsg_NoInline)) #include "RerrMsg.ipp" -#endif #endif diff --git a/tools/src/librtools/RerrMsg.ipp b/tools/src/librtools/RerrMsg.ipp index 62d55023..60111230 100644 --- a/tools/src/librtools/RerrMsg.ipp +++ b/tools/src/librtools/RerrMsg.ipp @@ -1,4 +1,4 @@ -// $Id: RerrMsg.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RerrMsg.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RerrMsg.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RerrMsg.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RerrMsg. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtools/Rexception.cpp b/tools/src/librtools/Rexception.cpp new file mode 100644 index 00000000..1c584698 --- /dev/null +++ b/tools/src/librtools/Rexception.cpp @@ -0,0 +1,80 @@ +// $Id: Rexception.cpp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-01-12 474 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rexception.cpp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation of Rexception. +*/ + +#include "Rexception.hpp" + +using namespace std; + +/*! + \class Retro::Rexception + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rexception::Rexception() + : fErrmsg() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rexception::Rexception(const RerrMsg& errmsg) + : fErrmsg(errmsg) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rexception::Rexception(const std::string& meth, const std::string& text) + : fErrmsg(meth,text) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rexception::Rexception(const std::string& meth, const std::string& text, + int errnum) + : fErrmsg(meth,text,errnum) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rexception::~Rexception() throw() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +const char* Rexception::what() const throw() +{ + return fErrmsg.Message().c_str(); +} + +} // end namespace Retro diff --git a/tools/src/librtools/Rexception.hpp b/tools/src/librtools/Rexception.hpp new file mode 100644 index 00000000..80159bc1 --- /dev/null +++ b/tools/src/librtools/Rexception.hpp @@ -0,0 +1,58 @@ +// $Id: Rexception.hpp 487 2013-02-12 19:14:38Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-12 487 1.0,1 add ErrMsg() getter +// 2013-01-12 474 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rexception.hpp 487 2013-02-12 19:14:38Z mueller $ + \brief Declaration of class Rexception. +*/ + +#ifndef included_Retro_Rexception +#define included_Retro_Rexception 1 + +#include +#include + +#include "RerrMsg.hpp" + +namespace Retro { + + class Rexception : public std::exception { + public: + Rexception(); + Rexception(const RerrMsg& errmsg); + Rexception(const std::string& meth, + const std::string& text); + Rexception(const std::string& meth, + const std::string& text, int errnum); + ~Rexception() throw(); + + const char* what() const throw(); + const RerrMsg& ErrMsg() const; + + protected: + RerrMsg fErrmsg; //!< message object + }; + +} // end namespace Retro + +#include "Rexception.ipp" + +#endif diff --git a/tools/src/librtcltools/RtclNameSet.ipp b/tools/src/librtools/Rexception.ipp similarity index 64% rename from tools/src/librtcltools/RtclNameSet.ipp rename to tools/src/librtools/Rexception.ipp index e688b698..7bc73fb2 100644 --- a/tools/src/librtcltools/RtclNameSet.ipp +++ b/tools/src/librtools/Rexception.ipp @@ -1,6 +1,6 @@ -// $Id: RtclNameSet.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: Rexception.ipp 487 2013-02-12 19:14:38Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2013- by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,24 +13,25 @@ // // Revision History: // Date Rev Version Comment -// 2011-02-20 363 1.0 Initial version +// 2013-02-12 487 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RtclNameSet.ipp 365 2011-02-28 07:28:26Z mueller $ - \brief Implemenation (inline) of RtclNameSet. + \version $Id: Rexception.ipp 487 2013-02-12 19:14:38Z mueller $ + \brief Implemenation (inline) of Rexception. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- //! FIXME_docs -//inline Tcl_Interp* RtclNameSet::Interp() const -//{ -// return fpInterp; -//} +inline const RerrMsg& Rexception::ErrMsg() const +{ + return fErrmsg; +} + } // end namespace Retro diff --git a/tools/src/librtools/RiosState.cpp b/tools/src/librtools/RiosState.cpp index deac6f45..ef332e79 100644 --- a/tools/src/librtools/RiosState.cpp +++ b/tools/src/librtools/RiosState.cpp @@ -1,4 +1,4 @@ -// $Id: RiosState.cpp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RiosState.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2006-2011 by Walter F.J. Mueller // @@ -19,14 +19,13 @@ /*! \file - \version $Id: RiosState.cpp 359 2011-02-06 22:37:43Z mueller $ + \version $Id: RiosState.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RiosState. */ #include "RiosState.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RiosState @@ -34,6 +33,9 @@ using namespace Retro; */ //------------------------------------------+----------------------------------- +// all method definitions in namespace Retro +namespace Retro { + //! Construct with stream. RiosState::RiosState(ios& stream) @@ -153,9 +155,4 @@ void RiosState::SetFormat(const char* form, int prec) } } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RiosState_NoInline)) -#define inline -#include "RiosState.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtools/RiosState.hpp b/tools/src/librtools/RiosState.hpp index 1a64779e..d83c7f84 100644 --- a/tools/src/librtools/RiosState.hpp +++ b/tools/src/librtools/RiosState.hpp @@ -1,4 +1,4 @@ -// $Id: RiosState.hpp 357 2011-01-31 08:00:13Z mueller $ +// $Id: RiosState.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2006-2011 by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RiosState.hpp 357 2011-01-31 08:00:13Z mueller $ + \version $Id: RiosState.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RiosState. */ @@ -57,8 +57,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RiosState_NoInline)) #include "RiosState.ipp" -#endif #endif diff --git a/tools/src/librtools/RiosState.ipp b/tools/src/librtools/RiosState.ipp index c518471d..3fd1d9ec 100644 --- a/tools/src/librtools/RiosState.ipp +++ b/tools/src/librtools/RiosState.ipp @@ -1,4 +1,4 @@ -// $Id: RiosState.ipp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RiosState.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2006-2011 by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RiosState.ipp 359 2011-02-06 22:37:43Z mueller $ + \version $Id: RiosState.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RiosState. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtools/RlogFile.cpp b/tools/src/librtools/RlogFile.cpp index c541733d..5ac952c6 100644 --- a/tools/src/librtools/RlogFile.cpp +++ b/tools/src/librtools/RlogFile.cpp @@ -1,6 +1,6 @@ -// $Id: RlogFile.cpp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RlogFile.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,34 +13,46 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 2.1 add Name(), keep log file name; add Dump() +// 2013-02-22 491 2.0 add Write(),IsNew(), RlogMsg iface; use lockable // 2011-01-30 357 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RlogFile.cpp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RlogFile.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RlogFile. */ #include -#include "RlogFile.hpp" +#include "boost/thread/locks.hpp" + +#include "RosFill.hpp" #include "RosPrintf.hpp" +#include "RlogMsg.hpp" + +#include "RlogFile.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RlogFile \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor RlogFile::RlogFile() : fpExtStream(0), - fIntStream() + fIntStream(), + fNew(true), + fName(), + fMutex() { ClearTime(); } @@ -48,10 +60,15 @@ RlogFile::RlogFile() //------------------------------------------+----------------------------------- //! FIXME_docs -RlogFile::RlogFile(std::ostream* os) +RlogFile::RlogFile(std::ostream* os, const std::string& name) : fpExtStream(os), - fIntStream() -{} + fIntStream(), + fNew(false), + fName(name), + fMutex() +{ + ClearTime(); +} //------------------------------------------+----------------------------------- //! Destructor @@ -64,7 +81,9 @@ RlogFile::~RlogFile() bool RlogFile::Open(std::string name) { + fNew = false; fpExtStream = 0; + fName = name; fIntStream.open(name.c_str()); return fIntStream.is_open(); } @@ -81,49 +100,102 @@ void RlogFile::Close() //------------------------------------------+----------------------------------- //! FIXME_docs -void RlogFile::UseStream(std::ostream* os) +void RlogFile::UseStream(std::ostream* os, const std::string& name) { + fNew = false; if (fIntStream.is_open()) Close(); fpExtStream = os; + fName = name; return; } //------------------------------------------+----------------------------------- //! FIXME_docs -std::ostream& RlogFile::operator()(char c) +void RlogFile::Write(const std::string& str, char tag) { - struct timeval tval; - gettimeofday(&tval, 0); + ostream& os = fpExtStream ? *fpExtStream : fIntStream; - struct tm tymd; - localtime_r(&tval.tv_sec, &tymd); + boost::lock_guard lock(*this); - ostream& os = operator()(); - - if (tymd.tm_year != fTagYear || - tymd.tm_mon != fTagMonth || - tymd.tm_mday != fTagDay) { + if (tag) { + struct timeval tval; + gettimeofday(&tval, 0); - os << "-+- " - << RosPrintf(tymd.tm_year+1900,"d",4) << "-" - << RosPrintf(tymd.tm_mon,"d0",2) << "-" - << RosPrintf(tymd.tm_mday,"d0",2) << " -+- \n"; + struct tm tymd; + localtime_r(&tval.tv_sec, &tymd); - fTagYear = tymd.tm_year; - fTagMonth = tymd.tm_mon; - fTagDay = tymd.tm_mday; + if (tymd.tm_year != fTagYear || + tymd.tm_mon != fTagMonth || + tymd.tm_mday != fTagDay) { + + os << "-+- " + << RosPrintf(tymd.tm_year+1900,"d",4) << "-" + << RosPrintf(tymd.tm_mon,"d0",2) << "-" + << RosPrintf(tymd.tm_mday,"d0",2) << " -+- \n"; + + fTagYear = tymd.tm_year; + fTagMonth = tymd.tm_mon; + fTagDay = tymd.tm_mday; + } + + int usec = (int)(tval.tv_usec/1000); + + os << "-" << tag << "- " + << RosPrintf(tymd.tm_hour,"d0",2) << ":" + << RosPrintf(tymd.tm_min,"d0",2) << ":" + << RosPrintf(tymd.tm_sec,"d0",2) << "." + << RosPrintf(usec,"d0",3) << " : "; } - int usec = (int)(tval.tv_usec/1000); + os << str; + if (str[str.length()-1] != '\n') os << endl; - os << "-" << c << "- " - << RosPrintf(tymd.tm_hour,"d0",2) << ":" - << RosPrintf(tymd.tm_min,"d0",2) << ":" - << RosPrintf(tymd.tm_sec,"d0",2) << "." - << RosPrintf(usec,"d0",3) << " : "; + return; +} - return os; +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlogFile::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "RlogFile @ " << this << endl; + os << bl << " fpExtStream: " << fpExtStream << endl; + os << bl << " fIntStream.isopen " << fIntStream.is_open() << endl; + os << bl << " fNew " << fNew << endl; + os << bl << " fName " << fName << endl; + os << bl << " fTagYr,Mo,Dy " << fTagYear << ", " << fTagMonth + << ", " << fTagDay << endl; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlogFile::lock() +{ + fMutex.lock(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlogFile::unlock() +{ + fMutex.unlock(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RlogFile& RlogFile::operator<<(const RlogMsg& lmsg) +{ + string str = lmsg.String(); + if (str.length() > 0) Write(str, lmsg.Tag()); + return *this; } //------------------------------------------+----------------------------------- @@ -137,9 +209,4 @@ void RlogFile::ClearTime() return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RlogFile_NoInline)) -#define inline -#include "RlogFile.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtools/RlogFile.hpp b/tools/src/librtools/RlogFile.hpp index 02a88b2d..24d7b664 100644 --- a/tools/src/librtools/RlogFile.hpp +++ b/tools/src/librtools/RlogFile.hpp @@ -1,6 +1,6 @@ -// $Id: RlogFile.hpp 380 2011-04-25 18:14:52Z mueller $ +// $Id: RlogFile.hpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,13 +13,15 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 2.1 add Name(), keep log file name; add Dump() +// 2013-02-22 491 2.0 add Write(),IsNew(), RlogMsg iface; use lockable // 2011-04-24 380 1.0.1 use boost::noncopyable (instead of private dcl's) // 2011-01-30 357 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RlogFile.hpp 380 2011-04-25 18:14:52Z mueller $ + \version $Id: RlogFile.hpp 492 2013-02-24 22:14:47Z mueller $ \brief Declaration of class RlogFile. */ @@ -31,37 +33,51 @@ #include #include "boost/utility.hpp" +#include "boost/thread/mutex.hpp" namespace Retro { + class RlogMsg; // forw decl to avoid circular incl + class RlogFile : private boost::noncopyable { public: RlogFile(); - explicit RlogFile(std::ostream* os); - ~RlogFile(); + explicit RlogFile(std::ostream* os, const std::string& name = ""); + ~RlogFile(); + bool IsNew() const; bool Open(std::string name); void Close(); - void UseStream(std::ostream* os); + void UseStream(std::ostream* os, const std::string& name = ""); + const std::string& Name() const; - std::ostream& operator()(); - std::ostream& operator()(char c); + void Write(const std::string& str, char tag = 0); + + void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // provide boost Lockable interface + void lock(); + void unlock(); + + RlogFile& operator<<(const RlogMsg& lmsg); protected: + std::ostream& Stream(); void ClearTime(); protected: std::ostream* fpExtStream; //!< pointer to external stream std::ofstream fIntStream; //!< internal stream + bool fNew; //!< true if never opened or used + std::string fName; //!< log file name int fTagYear; //!< year of last time tag int fTagMonth; //!< month of last time tag int fTagDay; //!< day of last time tag + boost::mutex fMutex; //!< mutex to lock file }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RlogFile_NoInline)) #include "RlogFile.ipp" -#endif #endif diff --git a/tools/src/librtools/RlogFile.ipp b/tools/src/librtools/RlogFile.ipp index 4a5342ae..f2c21ec0 100644 --- a/tools/src/librtools/RlogFile.ipp +++ b/tools/src/librtools/RlogFile.ipp @@ -1,6 +1,6 @@ -// $Id: RlogFile.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: RlogFile.ipp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,22 +13,40 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-23 492 2.1 add Name(), keep log file name +// 2013-02-22 491 2.0 add Write(),IsNew(), RlogMsg iface; use lockable // 2011-01-30 357 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RlogFile.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: RlogFile.ipp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation (inline) of RlogFile. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- //! FIXME_docs -inline std::ostream& RlogFile::operator()() +inline bool RlogFile::IsNew() const +{ + return fNew; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& RlogFile::Name() const +{ + return fName; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline std::ostream& RlogFile::Stream() { return fpExtStream ? *fpExtStream : fIntStream; } diff --git a/tools/src/librtools/RlogFileCatalog.cpp b/tools/src/librtools/RlogFileCatalog.cpp new file mode 100644 index 00000000..42b6a925 --- /dev/null +++ b/tools/src/librtools/RlogFileCatalog.cpp @@ -0,0 +1,87 @@ +// $Id: RlogFileCatalog.cpp 493 2013-03-01 21:02:33Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 491 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlogFileCatalog.cpp 493 2013-03-01 21:02:33Z mueller $ + \brief Implemenation of RlogFileCatalog. +*/ + +#include + +#include "RlogFileCatalog.hpp" + +using namespace std; + +/*! + \class Retro::RlogFileCatalog + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RlogFileCatalog& RlogFileCatalog::Obj() +{ + static RlogFileCatalog obj; + return obj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +const boost::shared_ptr& + RlogFileCatalog::FindOrCreate(const std::string& name) +{ + map_cit_t it = fMap.find(name); + if (it != fMap.end()) return it->second; + + boost::shared_ptr sptr(new RlogFile()); + it = fMap.insert(fMap.begin(), map_val_t(name, sptr)); + + return it->second; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RlogFileCatalog::Delete(const std::string& name) +{ + fMap.erase(name); + return; +} + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlogFileCatalog::RlogFileCatalog() +{ + FindOrCreate("cout")->UseStream(&cout, ""); + FindOrCreate("cerr")->UseStream(&cerr, ""); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlogFileCatalog::~RlogFileCatalog() +{} + +} // end namespace Retro diff --git a/tools/src/librtools/RlogFileCatalog.hpp b/tools/src/librtools/RlogFileCatalog.hpp new file mode 100644 index 00000000..b6328697 --- /dev/null +++ b/tools/src/librtools/RlogFileCatalog.hpp @@ -0,0 +1,62 @@ +// $Id: RlogFileCatalog.hpp 491 2013-02-23 12:41:18Z mueller $ +// +// Copyright 2011-2013 by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 491 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlogFileCatalog.hpp 491 2013-02-23 12:41:18Z mueller $ + \brief Declaration of class RlogFileCatalog. +*/ + +#ifndef included_Retro_RlogFileCatalog +#define included_Retro_RlogFileCatalog 1 + +#include + +#include "boost/utility.hpp" +#include "boost/shared_ptr.hpp" + +#include "RlogFile.hpp" + +namespace Retro { + + class RlogFileCatalog : private boost::noncopyable { + public: + + static RlogFileCatalog& Obj(); + + const boost::shared_ptr& FindOrCreate(const std::string& name); + void Delete(const std::string& name); + + private: + RlogFileCatalog(); + ~RlogFileCatalog(); + + protected: + typedef std::map> map_t; + typedef map_t::iterator map_it_t; + typedef map_t::const_iterator map_cit_t; + typedef map_t::value_type map_val_t; + + map_t fMap; //!< name->rlogfile map + }; + +} // end namespace Retro + +//#include "RlogFileCatalog.ipp" + +#endif diff --git a/tools/src/librtools/RlogMsg.cpp b/tools/src/librtools/RlogMsg.cpp new file mode 100644 index 00000000..9d4e15f4 --- /dev/null +++ b/tools/src/librtools/RlogMsg.cpp @@ -0,0 +1,67 @@ +// $Id: RlogMsg.cpp 490 2013-02-22 18:43:26Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 490 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlogMsg.cpp 490 2013-02-22 18:43:26Z mueller $ + \brief Implemenation of RlogMsg. +*/ + +#include "boost/thread/locks.hpp" + +#include "RlogFile.hpp" + +#include "RlogMsg.hpp" + +using namespace std; + +/*! + \class Retro::RlogMsg + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RlogMsg::RlogMsg(char tag) + : fStream(), + fLfile(0), + fTag(tag) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RlogMsg::RlogMsg(RlogFile& lfile, char tag) + : fStream(), + fLfile(&lfile), + fTag(tag) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RlogMsg::~RlogMsg() +{ + if (fLfile) *fLfile << *this; +} + +} // end namespace Retro diff --git a/tools/src/librtools/RlogMsg.hpp b/tools/src/librtools/RlogMsg.hpp new file mode 100644 index 00000000..93666476 --- /dev/null +++ b/tools/src/librtools/RlogMsg.hpp @@ -0,0 +1,63 @@ +// $Id: RlogMsg.hpp 490 2013-02-22 18:43:26Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 490 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlogMsg.hpp 490 2013-02-22 18:43:26Z mueller $ + \brief Declaration of class RlogMsg. +*/ + +#ifndef included_Retro_RlogMsg +#define included_Retro_RlogMsg 1 + +#include + +#include "boost/utility.hpp" + +namespace Retro { + + class RlogFile; // forw decl to avoid circular incl + + class RlogMsg : private boost::noncopyable { + public: + explicit RlogMsg(char tag = 0); + RlogMsg(RlogFile& lfile, char tag = 0); + ~RlogMsg(); + + void SetTag(char tag); + void SetString(const std::string& str); + + char Tag() const; + std::string String() const; + + std::ostream& operator()(); + + protected: + std::stringstream fStream; //!< string stream + RlogFile* fLfile; + char fTag; + }; + + template + std::ostream& operator<<(RlogMsg& lmsg, const T& val); + +} // end namespace Retro + +#include "RlogMsg.ipp" + +#endif diff --git a/tools/src/librtools/RlogMsg.ipp b/tools/src/librtools/RlogMsg.ipp new file mode 100644 index 00000000..f29870d9 --- /dev/null +++ b/tools/src/librtools/RlogMsg.ipp @@ -0,0 +1,83 @@ +// $Id: RlogMsg.ipp 490 2013-02-22 18:43:26Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-22 490 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RlogMsg.ipp 490 2013-02-22 18:43:26Z mueller $ + \brief Implemenation (inline) of RlogMsg. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlogMsg::SetTag(char tag) +{ + fTag = tag; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RlogMsg::SetString(const std::string& str) +{ + fStream.str(str); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline char RlogMsg::Tag() const +{ + return fTag; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline std::string RlogMsg::String() const +{ + return fStream.str(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline std::ostream& RlogMsg::operator()() +{ + return fStream; +} + +//------------------------------------------+----------------------------------- +/*! + \relates RlogMsg + \brief FIXME_docs +*/ + +template +inline std::ostream& operator<<(RlogMsg& lmsg, const T& val) +{ + lmsg() << val; + return lmsg(); +} + +} // end namespace Retro diff --git a/tools/src/librtools/RosFill.cpp b/tools/src/librtools/RosFill.cpp index 387a15ee..69c61103 100644 --- a/tools/src/librtools/RosFill.cpp +++ b/tools/src/librtools/RosFill.cpp @@ -1,4 +1,4 @@ -// $Id: RosFill.cpp 364 2011-02-26 08:33:01Z mueller $ +// $Id: RosFill.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2000-2011 by Walter F.J. Mueller // @@ -20,14 +20,13 @@ /*! \file - \version $Id: RosFill.cpp 364 2011-02-26 08:33:01Z mueller $ + \version $Id: RosFill.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RosFill . */ #include "RosFill.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RosFill @@ -60,13 +59,16 @@ void xyz::Dump(ostream& os, int indent) const This finally produces a nicely structured output. */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- /*! \relates RosFill \brief ostream insertion operator. */ -std::ostream& Retro::operator<<(std::ostream& os, const RosFill& obj) +std::ostream& operator<<(std::ostream& os, const RosFill& obj) { for (int i=0; i // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RosFill.hpp 364 2011-02-26 08:33:01Z mueller $ + \version $Id: RosFill.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RosFill . */ @@ -50,8 +50,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RosFill_NoInline)) #include "RosFill.ipp" -#endif #endif diff --git a/tools/src/librtools/RosFill.ipp b/tools/src/librtools/RosFill.ipp index 9cb98b82..b5ce027a 100644 --- a/tools/src/librtools/RosFill.ipp +++ b/tools/src/librtools/RosFill.ipp @@ -1,4 +1,4 @@ -// $Id: RosFill.ipp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RosFill.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2000-2011 by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RosFill.ipp 359 2011-02-06 22:37:43Z mueller $ + \version $Id: RosFill.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RosFill. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtools/RosPrintBvi.cpp b/tools/src/librtools/RosPrintBvi.cpp index 10f54706..98830c21 100644 --- a/tools/src/librtools/RosPrintBvi.cpp +++ b/tools/src/librtools/RosPrintBvi.cpp @@ -1,6 +1,6 @@ -// $Id: RosPrintBvi.cpp 368 2011-03-12 09:58:53Z mueller $ +// $Id: RosPrintBvi.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,28 +13,31 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.2 use Rexception // 2011-03-12 368 1.0.1 allow base=0, will print in hex,oct and bin // 2011-03-05 366 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: RosPrintBvi.cpp 368 2011-03-12 09:58:53Z mueller $ + \version $Id: RosPrintBvi.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of RosPrintBvi . */ -#include - #include "RosPrintBvi.hpp" +#include "Rexception.hpp" + using namespace std; -using namespace Retro; /*! \class Retro::RosPrintBvi \brief FIXME_docs. */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Constructor. FIXME_docs @@ -44,9 +47,11 @@ RosPrintBvi::RosPrintBvi(uint8_t val, size_t base, size_t nbit) fNbit(nbit) { if (base!=0 && base!=2 && base!=8 && base!=16) - throw invalid_argument("RosPrintBvi::ctor: base must be 0,2,8, or 16"); + throw Rexception("RosPrintBvi::", + "Bad args: base must be 0,2,8, or 16"); if (nbit<1 || nbit>8) - throw invalid_argument("RosPrintBvi::ctor: nbit must be in 1,..,8"); + throw Rexception("RosPrintBvi::", + "Bad args: nbit must be in 1,..,8"); } //------------------------------------------+----------------------------------- @@ -58,9 +63,11 @@ RosPrintBvi::RosPrintBvi(uint16_t val, size_t base, size_t nbit) fNbit(nbit) { if (base!=0 && base!=2 && base!=8 && base!=16) - throw invalid_argument("RosPrintBvi::ctor: base must be 0,2,8, or 16"); + throw Rexception("RosPrintBvi::", + "Bad args: base must be 0,2,8, or 16"); if (nbit<1 || nbit>16) - throw invalid_argument("RosPrintBvi::ctor: nbit must be in 1,..,16"); + throw Rexception("RosPrintBvi::", + "Bad args: nbit must be in 1,..,16"); } //------------------------------------------+----------------------------------- @@ -72,9 +79,11 @@ RosPrintBvi::RosPrintBvi(uint32_t val, size_t base, size_t nbit) fNbit(nbit) { if (base!=0 && base!=2 && base!=8 && base!=16) - throw invalid_argument("RosPrintBvi::ctor: base must be 0,2,8, or 16"); + throw Rexception("RosPrintBvi::", + "Bad args: base must be 0,2,8, or 16"); if (nbit<1 || nbit>32) - throw invalid_argument("RosPrintBvi::ctor: nbit must be in 1,..,32"); + throw Rexception("RosPrintBvi::", + "Bad args: nbit must be in 1,..,32"); } //------------------------------------------+----------------------------------- @@ -139,9 +148,5 @@ void RosPrintBvi::Convert(char* pbuf) const return; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RosPrintBvi_NoInline)) -#define inline -#include "RosPrintBvi.ipp" -#undef inline -#endif +} // end namespace Retro + diff --git a/tools/src/librtools/RosPrintBvi.hpp b/tools/src/librtools/RosPrintBvi.hpp index ae84330b..4d05907a 100644 --- a/tools/src/librtools/RosPrintBvi.hpp +++ b/tools/src/librtools/RosPrintBvi.hpp @@ -1,4 +1,4 @@ -// $Id: RosPrintBvi.hpp 366 2011-03-05 14:55:15Z mueller $ +// $Id: RosPrintBvi.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,7 +18,7 @@ /*! \file - \version $Id: RosPrintBvi.hpp 366 2011-03-05 14:55:15Z mueller $ + \version $Id: RosPrintBvi.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RosPrintBvi . */ @@ -55,8 +55,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RosPrintBvi_NoInline)) #include "RosPrintBvi.ipp" -#endif #endif diff --git a/tools/src/librtools/RosPrintBvi.ipp b/tools/src/librtools/RosPrintBvi.ipp index b44f6c19..cb1c0cc3 100644 --- a/tools/src/librtools/RosPrintBvi.ipp +++ b/tools/src/librtools/RosPrintBvi.ipp @@ -1,4 +1,4 @@ -// $Id: RosPrintBvi.ipp 367 2011-03-06 20:07:18Z mueller $ +// $Id: RosPrintBvi.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,11 +18,11 @@ /*! \file - \version $Id: RosPrintBvi.ipp 367 2011-03-06 20:07:18Z mueller $ + \version $Id: RosPrintBvi.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RosPrintBvi. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtools/RosPrintf.ipp b/tools/src/librtools/RosPrintf.ipp index 68636b9f..92e92f6f 100644 --- a/tools/src/librtools/RosPrintf.ipp +++ b/tools/src/librtools/RosPrintf.ipp @@ -1,4 +1,4 @@ -// $Id: RosPrintf.ipp 358 2011-02-05 09:45:14Z mueller $ +// $Id: RosPrintf.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2000-2011 by Walter F.J. Mueller // @@ -19,10 +19,13 @@ /*! \file - \version $Id: RosPrintf.ipp 358 2011-02-05 09:45:14Z mueller $ + \version $Id: RosPrintf.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RosPrintf. */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- /*! \defgroup RosPrintf RosPrintf -- print format object creators @@ -41,10 +44,10 @@ \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(char value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(char value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -61,10 +64,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(signed char value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(signed char value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -81,10 +84,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(unsigned char value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(unsigned char value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -101,10 +104,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(short value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(short value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -121,10 +124,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(unsigned short value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(unsigned short value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -141,10 +144,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(int value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(int value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -161,10 +164,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(unsigned int value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(unsigned int value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -181,10 +184,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(long value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(long value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -201,10 +204,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(unsigned long value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(unsigned long value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -221,10 +224,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(double value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(double value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -241,10 +244,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(const char* value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(const char* value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } //------------------------------------------+----------------------------------- @@ -261,9 +264,10 @@ inline Retro::RosPrintfS \param prec precision */ -inline Retro::RosPrintfS - Retro::RosPrintf(const void* value, const char* form, int width, int prec) +inline RosPrintfS + RosPrintf(const void* value, const char* form, int width, int prec) { - return Retro::RosPrintfS(value, form, width, prec); + return RosPrintfS(value, form, width, prec); } +} // end namespace Retro diff --git a/tools/src/librtools/RosPrintfBase.cpp b/tools/src/librtools/RosPrintfBase.cpp index 8b343190..a36ed3fd 100644 --- a/tools/src/librtools/RosPrintfBase.cpp +++ b/tools/src/librtools/RosPrintfBase.cpp @@ -1,4 +1,4 @@ -// $Id: RosPrintfBase.cpp 403 2011-08-06 17:36:22Z mueller $ +// $Id: RosPrintfBase.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,7 +18,7 @@ /*! \file - \version $Id: RosPrintfBase.cpp 403 2011-08-06 17:36:22Z mueller $ + \version $Id: RosPrintfBase.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RosPrintfBase . */ @@ -27,7 +27,9 @@ #include "RosPrintfBase.hpp" using namespace std; -using namespace Retro; + +// all method definitions in namespace Retro +namespace Retro { //------------------------------------------+----------------------------------- /*! @@ -35,7 +37,7 @@ using namespace Retro; \brief string insertion */ -std::string& Retro::operator<<(std::string& os, const RosPrintfBase& obj) +std::string& operator<<(std::string& os, const RosPrintfBase& obj) { std::ostringstream sos; obj.ToStream(sos); @@ -43,9 +45,4 @@ std::string& Retro::operator<<(std::string& os, const RosPrintfBase& obj) return os; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RosPrintfBase_NoInline)) -#define inline -#include "RosPrintfBase.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtools/RosPrintfBase.hpp b/tools/src/librtools/RosPrintfBase.hpp index 02ee03ca..64d48310 100644 --- a/tools/src/librtools/RosPrintfBase.hpp +++ b/tools/src/librtools/RosPrintfBase.hpp @@ -1,4 +1,4 @@ -// $Id: RosPrintfBase.hpp 364 2011-02-26 08:33:01Z mueller $ +// $Id: RosPrintfBase.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2006-2011 by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RosPrintfBase.hpp 364 2011-02-26 08:33:01Z mueller $ + \version $Id: RosPrintfBase.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of RosPrintfBase class . */ @@ -50,8 +50,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RosPrintfBase_NoInline)) #include "RosPrintfBase.ipp" -#endif #endif diff --git a/tools/src/librtools/RosPrintfBase.ipp b/tools/src/librtools/RosPrintfBase.ipp index f25212b9..ac626410 100644 --- a/tools/src/librtools/RosPrintfBase.ipp +++ b/tools/src/librtools/RosPrintfBase.ipp @@ -1,4 +1,4 @@ -// $Id: RosPrintfBase.ipp 359 2011-02-06 22:37:43Z mueller $ +// $Id: RosPrintfBase.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2006-2011 by Walter F.J. Mueller // @@ -19,11 +19,11 @@ /*! \file - \version $Id: RosPrintfBase.ipp 359 2011-02-06 22:37:43Z mueller $ + \version $Id: RosPrintfBase.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of RosPrintfBase */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { /*! diff --git a/tools/src/librtools/RosPrintfS.cpp b/tools/src/librtools/RosPrintfS.cpp index 24137bff..f184382b 100644 --- a/tools/src/librtools/RosPrintfS.cpp +++ b/tools/src/librtools/RosPrintfS.cpp @@ -1,4 +1,4 @@ -// $Id: RosPrintfS.cpp 364 2011-02-26 08:33:01Z mueller $ +// $Id: RosPrintfS.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2000-2011 by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RosPrintfS.cpp 364 2011-02-26 08:33:01Z mueller $ + \version $Id: RosPrintfS.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RosPrintfS . */ @@ -30,13 +30,15 @@ #include "RosPrintfS.hpp" using namespace std; -using namespace Retro; /*! \class RosPrintfS \brief Print object for scalar values . ** */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- /*! \brief Constructor. @@ -136,3 +138,5 @@ template class RosPrintfS; template class RosPrintfS; template class RosPrintfS; + +} // end namespace Retro diff --git a/tools/src/librtools/RparseUrl.cpp b/tools/src/librtools/RparseUrl.cpp new file mode 100644 index 00000000..d29c8265 --- /dev/null +++ b/tools/src/librtools/RparseUrl.cpp @@ -0,0 +1,219 @@ +// $Id: RparseUrl.cpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0.1 add static FindScheme(); allow no or empty scheme +// 2013-02-03 481 1.0 Initial version, extracted from RlinkPort +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RparseUrl.cpp 492 2013-02-24 22:14:47Z mueller $ + \brief Implemenation of RparseUrl. +*/ + +#include + +#include "RparseUrl.hpp" + +#include "RosFill.hpp" +#include "RosPrintf.hpp" + +using namespace std; + +/*! + \class Retro::RparseUrl + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RparseUrl::RparseUrl() + : fUrl(), + fScheme(), + fPath(), + fOptMap() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +RparseUrl::~RparseUrl() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RparseUrl::Set(const std::string& url, const std::string& optlist, + RerrMsg& emsg) +{ + fUrl = url; + fScheme = FindScheme(url); + fPath.clear(); + fOptMap.clear(); + + size_t pdel = fScheme.length(); + if (pdel == 0 && url.length()>0 && url[0] != ':') pdel = -1; + size_t odel = url.find_first_of('?', fScheme.length()); + + if (odel == string::npos) { // no options + if (url.length() > pdel+1) fPath = url.substr(pdel+1); + + } else { // options to process + fPath = url.substr(pdel+1,odel-(pdel+1)); + string key; + string val; + bool hasval = false; + + for (size_t i=odel+1; i= url.length()) { + emsg.Init("RparseUrl::ParseUrl()", + string("invalid trailing \\ in url '") + url + + string("'")); + return false; + } + i += 1; + switch (url[i]) { + case '\\' : c = '\\'; break; + case ';' : c = ';'; break; + default : emsg.Init("RparseUrl::ParseUrl()", + string("invalid \\ escape in url '") + + url + string("'")); + return false; + } + } + val.push_back(c); + } + } + } + if (key.length() || hasval) { + if (!AddOpt(key, val, hasval, optlist, emsg)) return false; + } + } + + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RparseUrl::Clear() +{ + fUrl.clear(); + fScheme.clear(); + fPath.clear(); + fOptMap.clear(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RparseUrl::FindOpt(const std::string& name) const +{ + omap_cit_t it = fOptMap.find(name); + if (it == fOptMap.end()) return false; + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RparseUrl::FindOpt(const std::string& name, std::string& value) const +{ + omap_cit_t it = fOptMap.find(name); + if (it == fOptMap.end()) return false; + + value = it->second; + + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RparseUrl::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "RparseUrl @ " << this << endl; + + os << bl << " fUrl: " << fUrl << endl; + os << bl << " fScheme: " << fScheme << endl; + os << bl << " fPath: " << fPath << endl; + os << bl << " fOptMap: " << endl; + for (omap_cit_t it=fOptMap.begin(); it!=fOptMap.end(); it++) { + os << bl << " " << RosPrintf((it->first).c_str(), "-s",8) + << " : " << it->second << endl; + } + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +std::string RparseUrl::FindScheme(const std::string& url, + const std::string& def) +{ + size_t pdel = url.find_first_of(':'); + if (pdel == string::npos) { // no : found + return def; + } + + size_t odel = url.find_first_of('?'); + if (odel != string::npos && odel < pdel) { // : after ? + return def; + } + + return url.substr(0, pdel); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RparseUrl::AddOpt(const std::string& key, const std::string& val, + bool hasval, const std::string& optlist, RerrMsg& emsg) +{ + string lkey = "|"; + lkey += key; + if (hasval) lkey += "="; + lkey += "|"; + if (optlist.find(lkey) == string::npos) { + emsg.Init("RparseUrl::AddOpt()", + string("invalid field name '") + lkey + string("'")); + return false; + } + + fOptMap.insert(omap_val_t(key, hasval ? val : "1")); + return true; +} + +} // end namespace Retro diff --git a/tools/src/librtools/RparseUrl.hpp b/tools/src/librtools/RparseUrl.hpp new file mode 100644 index 00000000..080f3587 --- /dev/null +++ b/tools/src/librtools/RparseUrl.hpp @@ -0,0 +1,81 @@ +// $Id: RparseUrl.hpp 492 2013-02-24 22:14:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 492 1.0.1 add static FindScheme(); allow no or empty scheme +// 2013-02-03 481 1.0 Initial version, extracted from RlinkPort +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RparseUrl.hpp 492 2013-02-24 22:14:47Z mueller $ + \brief Declaration of class RparseUrl. +*/ + +#ifndef included_Retro_RparseUrl +#define included_Retro_RparseUrl 1 + +#include +#include + +#include "RerrMsg.hpp" + +namespace Retro { + + class RparseUrl { + public: + typedef std::map omap_t; + typedef omap_t::iterator omap_it_t; + typedef omap_t::const_iterator omap_cit_t; + typedef omap_t::value_type omap_val_t; + + RparseUrl(); + virtual ~RparseUrl(); + + bool Set(const std::string& url, const std::string& optlist, + RerrMsg& emsg); + void SetPath(const std::string& path); + + void Clear(); + + const std::string& Url() const; + const std::string& Scheme() const; + const std::string& Path() const; + const omap_t& Opts() const; + bool FindOpt(const std::string& name) const; + bool FindOpt(const std::string& name, + std::string& value) const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + static std::string FindScheme(const std::string& url, + const std::string& def = ""); + + protected: + bool AddOpt(const std::string& key, const std::string& val, + bool hasval, const std::string& optlist, + RerrMsg& emsg); + + protected: + std::string fUrl; //!< full url given with open + std::string fScheme; //!< url scheme part + std::string fPath; //!< url path part + omap_t fOptMap; //!< option map + }; + +} // end namespace Retro + +#include "RparseUrl.ipp" + +#endif diff --git a/tools/src/librtools/RparseUrl.ipp b/tools/src/librtools/RparseUrl.ipp new file mode 100644 index 00000000..f4fa5067 --- /dev/null +++ b/tools/src/librtools/RparseUrl.ipp @@ -0,0 +1,70 @@ +// $Id: RparseUrl.ipp 488 2013-02-16 18:49:47Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-03 481 1.0 Initial version, extracted from RlinkPort +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RparseUrl.ipp 488 2013-02-16 18:49:47Z mueller $ + \brief Implemenation (inline) of RparseUrl. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void RparseUrl::SetPath(const std::string& path) +{ + fPath = path; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& RparseUrl::Url() const +{ + return fUrl; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& RparseUrl::Scheme() const +{ + return fScheme; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& RparseUrl::Path() const +{ + return fPath; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const RparseUrl::omap_t& RparseUrl::Opts() const +{ + return fOptMap; +} + + +} // end namespace Retro diff --git a/tools/src/librtools/Rstats.cpp b/tools/src/librtools/Rstats.cpp index 206816a9..b92be266 100644 --- a/tools/src/librtools/Rstats.cpp +++ b/tools/src/librtools/Rstats.cpp @@ -1,6 +1,6 @@ -// $Id: Rstats.cpp 368 2011-03-12 09:58:53Z mueller $ +// $Id: Rstats.cpp 492 2013-02-24 22:14:47Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,30 +13,35 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-03 481 1.0.2 use Rexception // 2011-03-06 367 1.0.1 use max from algorithm // 2011-02-06 359 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: Rstats.cpp 368 2011-03-12 09:58:53Z mueller $ + \version $Id: Rstats.cpp 492 2013-02-24 22:14:47Z mueller $ \brief Implemenation of Rstats . */ -#include #include #include "Rstats.hpp" + #include "RosFill.hpp" #include "RosPrintf.hpp" +#include "Rexception.hpp" using namespace std; -using namespace Retro; /*! \class Retro::Rstats \brief FIXME_docs */ + +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! Default constructor @@ -145,7 +150,7 @@ void Rstats::Dump(std::ostream& os, int ind, const char* text) const for (size_t i=0; i // @@ -18,7 +18,7 @@ /*! \file - \version $Id: Rstats.hpp 364 2011-02-26 08:33:01Z mueller $ + \version $Id: Rstats.hpp 495 2013-03-06 17:13:48Z mueller $ \brief Declaration of class Rstats . */ @@ -67,17 +67,15 @@ namespace Retro { std::vector fName; //!< counter name std::vector fText; //!< counter text std::uint32_t fHash; //!< hash value for name+text - std::string fFormat; //!< default format for Print - int fWidth; //!< default width for Print - int fPrec; //!< default precision for Print + std::string fFormat; //!< default format for Print + int fWidth; //!< default width for Print + int fPrec; //!< default precision for Print }; std::ostream& operator<<(std::ostream& os, const Rstats& obj); } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_Rstats_NoInline)) #include "Rstats.ipp" -#endif #endif diff --git a/tools/src/librtools/Rstats.ipp b/tools/src/librtools/Rstats.ipp index 0c10c4cd..951122eb 100644 --- a/tools/src/librtools/Rstats.ipp +++ b/tools/src/librtools/Rstats.ipp @@ -1,4 +1,4 @@ -// $Id: Rstats.ipp 365 2011-02-28 07:28:26Z mueller $ +// $Id: Rstats.ipp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -18,11 +18,11 @@ /*! \file - \version $Id: Rstats.ipp 365 2011-02-28 07:28:26Z mueller $ + \version $Id: Rstats.ipp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation (inline) of Rstats. */ -// all method definitions in namespace Retro (avoid using in includes...) +// all method definitions in namespace Retro namespace Retro { //------------------------------------------+----------------------------------- diff --git a/tools/src/librtools/Rtools.cpp b/tools/src/librtools/Rtools.cpp index fc8fb4e2..44b2d780 100644 --- a/tools/src/librtools/Rtools.cpp +++ b/tools/src/librtools/Rtools.cpp @@ -1,6 +1,6 @@ -// $Id: Rtools.cpp 403 2011-08-06 17:36:22Z mueller $ +// $Id: Rtools.cpp 493 2013-03-01 21:02:33Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,29 +13,34 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-13 481 1.0.2 remove Throw(Logic|Runtime)(); use Rexception // 2011-04-10 376 1.0.1 add ThrowLogic(), ThrowRuntime() // 2011-03-12 368 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: Rtools.cpp 403 2011-08-06 17:36:22Z mueller $ + \version $Id: Rtools.cpp 493 2013-03-01 21:02:33Z mueller $ \brief Implemenation of Rtools . */ -#include +#include + +#include "RerrMsg.hpp" +#include "Rexception.hpp" #include "Rtools.hpp" -#include "RerrMsg.hpp" using namespace std; -using namespace Retro; /*! - \class Retro::Rtools + \namespace Retro::Rtools \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + //------------------------------------------+----------------------------------- //! FIXME_docs @@ -43,7 +48,7 @@ std::string Rtools::Flags2String(uint32_t flags, const RflagName* fnam, char delim) { if (fnam == 0) - throw invalid_argument("Rtools::Flags2String: fnam==NULL"); + throw Rexception("Rtools::Flags2String()","Bad args: fnam==NULL"); string rval; while (fnam->mask) { @@ -56,33 +61,4 @@ std::string Rtools::Flags2String(uint32_t flags, const RflagName* fnam, return rval; } -//------------------------------------------+----------------------------------- -//! FIXME_docs - -void Rtools::ThrowLogic(const std::string& meth, - const std::string& text, int errnum) -{ - RerrMsg emsg; - emsg.Init(meth, text); - if (errnum != 0) emsg.AppendErrno(errnum); - throw logic_error(emsg.Message()); -} - -//------------------------------------------+----------------------------------- -//! FIXME_docs - -void Rtools::ThrowRuntime(const std::string& meth, - const std::string& text, int errnum) -{ - RerrMsg emsg; - emsg.Init(meth, text); - if (errnum != 0) emsg.AppendErrno(errnum); - throw runtime_error(emsg.Message()); -} - -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_Rtools_NoInline)) -#define inline -//#include "Rtools.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librtools/Rtools.hpp b/tools/src/librtools/Rtools.hpp index 924b9044..734c05a0 100644 --- a/tools/src/librtools/Rtools.hpp +++ b/tools/src/librtools/Rtools.hpp @@ -1,6 +1,6 @@ -// $Id: Rtools.hpp 403 2011-08-06 17:36:22Z mueller $ +// $Id: Rtools.hpp 486 2013-02-10 22:34:43Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2011-2013 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment +// 2013-02-13 481 1.0.2 remove ThrowLogic(), ThrowRuntime() // 2011-04-10 376 1.0.1 add ThrowLogic(), ThrowRuntime() // 2011-03-12 368 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: Rtools.hpp 403 2011-08-06 17:36:22Z mueller $ + \version $Id: Rtools.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class Rtools . */ @@ -34,22 +35,15 @@ namespace Retro { struct RflagName { uint32_t mask; const char* name; - }; - + }; namespace Rtools { std::string Flags2String(uint32_t flags, const RflagName* fnam, char delim='|'); - void ThrowLogic(const std::string& meth, - const std::string& text, int errnum=0); - void ThrowRuntime(const std::string& meth, - const std::string& text, int errnum=0); }; } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_Rtools_NoInline)) //#include "Rtools.ipp" -#endif #endif diff --git a/tools/src/librutiltpp/Makefile b/tools/src/librutiltpp/Makefile index 660cc5c9..e8e69ad7 100644 --- a/tools/src/librutiltpp/Makefile +++ b/tools/src/librutiltpp/Makefile @@ -1,7 +1,8 @@ -# $Id: Makefile 464 2012-12-26 10:14:15Z mueller $ +# $Id: Makefile 479 2013-02-01 18:09:49Z mueller $ # # Revision History: # Date Rev Version Comment +# 2013-02-01 479 1.1.2 use checkpath_cpp.mk # 2012-12-24 464 1.1.1 add TCLINC # 2011-07-31 401 1.1 rename realclean->distclean # 2011-07-01 386 1.0.2 add BOOSTINC @@ -17,6 +18,8 @@ SOMINV = 0 # # Compile and Link search paths # +include ../checkpath_cpp.mk +# INCLFLAGS = -I${RETROBASE}/tools/src -I${TCLINC} -I${BOOSTINC} LDLIBS = -L${RETROBASE}/tools/lib -lrtcltools # @@ -35,10 +38,13 @@ SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) include $(RETROBASE)/tools/make/generic_cpp.mk include $(RETROBASE)/tools/make/generic_dep.mk include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk # # The magic autodependcy include # +ifndef DONTINCDEP include $(DEP_all) +endif # # cleanup phonies: # diff --git a/tools/src/librutiltpp/RtclBvi.cpp b/tools/src/librutiltpp/RtclBvi.cpp index 2f525c12..f524330e 100644 --- a/tools/src/librutiltpp/RtclBvi.cpp +++ b/tools/src/librutiltpp/RtclBvi.cpp @@ -1,4 +1,4 @@ -// $Id: RtclBvi.cpp 434 2011-12-02 19:17:38Z mueller $ +// $Id: RtclBvi.cpp 488 2013-02-16 18:49:47Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -20,7 +20,7 @@ /*! \file - \version $Id: RtclBvi.cpp 434 2011-12-02 19:17:38Z mueller $ + \version $Id: RtclBvi.cpp 488 2013-02-16 18:49:47Z mueller $ \brief Implemenation of RtclBvi. */ @@ -34,18 +34,20 @@ #include "librtcltools/RtclOPtr.hpp" using namespace std; -using namespace Retro; /*! \class Retro::RtclBvi - \brief FIXME_text + \brief FIXME_docs */ +// all method definitions in namespace Retro +namespace Retro { + static const int kOK = TCL_OK; static const int kERR = TCL_ERROR; //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs void RtclBvi::CreateCmds(Tcl_Interp* interp) { @@ -55,7 +57,7 @@ void RtclBvi::CreateCmds(Tcl_Interp* interp) } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs int RtclBvi::DoCmd(ClientData cdata, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) @@ -95,7 +97,7 @@ int RtclBvi::DoCmd(ClientData cdata, Tcl_Interp* interp, int objc, } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs Tcl_Obj* RtclBvi::DoConv(Tcl_Interp* interp, ConvMode mode, Tcl_Obj* val, char form, int nbit) @@ -117,7 +119,7 @@ Tcl_Obj* RtclBvi::DoConv(Tcl_Interp* interp, ConvMode mode, Tcl_Obj* val, // check for c"ddd" format if (lval>3 && pval[1]=='"' && pval[lval-1]=='"') { if (strchr("bBoOdDxX", pval[0]) == 0) { - Tcl_AppendResult(interp, "-E: bad prefix in c\"dddd\" format string", + Tcl_AppendResult(interp, "-E: bad prefix in c'dddd' format string", NULL); return 0; } @@ -201,7 +203,7 @@ Tcl_Obj* RtclBvi::DoConv(Tcl_Interp* interp, ConvMode mode, Tcl_Obj* val, } //------------------------------------------+----------------------------------- -//! FIXME_text +//! FIXME_docs bool RtclBvi::CheckFormat(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], bool& list, char& form, int& nbit) @@ -236,12 +238,12 @@ bool RtclBvi::CheckFormat(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], if (*opt>='0' && *opt<='9') { nbit = 10*nbit + ((*opt) - '0'); if (nbit > 32) { - Tcl_AppendResult(interp, "-E: invalid bvi format \"", opt, "\"", + Tcl_AppendResult(interp, "-E: invalid bvi format '", opt, "'", " bit count > 32", NULL); return false; } } else { - Tcl_AppendResult(interp, "-E: invalid bvi format \"", opt, "\"", + Tcl_AppendResult(interp, "-E: invalid bvi format '", opt, "'", " allowed: [bBoOxXl][0-9]*", NULL); return false; } @@ -255,9 +257,4 @@ bool RtclBvi::CheckFormat(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], return true; } -//------------------------------------------+----------------------------------- -#if (defined(Retro_NoInline) || defined(Retro_RtclBvi_NoInline)) -#define inline -//#include "RtclBvi.ipp" -#undef inline -#endif +} // end namespace Retro diff --git a/tools/src/librutiltpp/RtclBvi.hpp b/tools/src/librutiltpp/RtclBvi.hpp index 0a42166e..1be560e2 100644 --- a/tools/src/librutiltpp/RtclBvi.hpp +++ b/tools/src/librutiltpp/RtclBvi.hpp @@ -1,4 +1,4 @@ -// $Id: RtclBvi.hpp 375 2011-04-02 07:56:47Z mueller $ +// $Id: RtclBvi.hpp 486 2013-02-10 22:34:43Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -19,7 +19,7 @@ /*! \file - \version $Id: RtclBvi.hpp 375 2011-04-02 07:56:47Z mueller $ + \version $Id: RtclBvi.hpp 486 2013-02-10 22:34:43Z mueller $ \brief Declaration of class RtclBvi. */ @@ -49,8 +49,6 @@ namespace Retro { } // end namespace Retro -#if !(defined(Retro_NoInline) || defined(Retro_RtclBvi_NoInline)) //#include "RtclBvi.ipp" -#endif #endif diff --git a/tools/src/librutiltpp/Rutiltpp_Init.cpp b/tools/src/librutiltpp/Rutiltpp_Init.cpp index af0db9ed..4ee54712 100644 --- a/tools/src/librutiltpp/Rutiltpp_Init.cpp +++ b/tools/src/librutiltpp/Rutiltpp_Init.cpp @@ -1,4 +1,4 @@ -// $Id: Rutiltpp_Init.cpp 374 2011-03-27 17:02:47Z mueller $ +// $Id: Rutiltpp_Init.cpp 485 2013-02-10 18:57:55Z mueller $ // // Copyright 2011- by Walter F.J. Mueller // @@ -13,13 +13,14 @@ // // Revision History: // Date Rev Version Comment -// 2011-03-20 372 1.0.2 renamed ..tcl -> ..tpp +// 2013-02-10 485 1.0.2 remove Tcl_InitStubs() +// 2011-03-20 372 1.0.1 renamed ..tcl -> ..tpp // 2011-03-19 371 1.0 Initial version // --------------------------------------------------------------------------- /*! \file - \version $Id: Rutiltpp_Init.cpp 374 2011-03-27 17:02:47Z mueller $ + \version $Id: Rutiltpp_Init.cpp 485 2013-02-10 18:57:55Z mueller $ \brief Implemenation of Rutiltpp_Init . */ @@ -37,10 +38,6 @@ extern "C" int Rutiltpp_Init(Tcl_Interp* interp) { int irc; - // use stubs - const char* vers = Tcl_InitStubs(interp, TCL_VERSION, 0); - if (vers == NULL) return TCL_ERROR; - // declare package name and version irc = Tcl_PkgProvide(interp, "rutiltpp", "1.0.0"); if (irc != TCL_OK) return irc; @@ -51,8 +48,8 @@ extern "C" int Rutiltpp_Init(Tcl_Interp* interp) return TCL_OK; } catch (exception& e) { - Tcl_AppendResult(interp, "-E: exception caught in Rutiltpp_Init: \"", - e.what(), "\"", NULL); + Tcl_AppendResult(interp, "-E: exception caught in Rutiltpp_Init: '", + e.what(), "'", NULL); } return TCL_ERROR; } diff --git a/tools/src/librw11/.cvsignore b/tools/src/librw11/.cvsignore new file mode 100644 index 00000000..49858186 --- /dev/null +++ b/tools/src/librw11/.cvsignore @@ -0,0 +1 @@ +*.dep diff --git a/tools/src/librw11/Makefile b/tools/src/librw11/Makefile new file mode 100644 index 00000000..f8dc3136 --- /dev/null +++ b/tools/src/librw11/Makefile @@ -0,0 +1,65 @@ +# $Id: Makefile 504 2013-04-13 15:37:24Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-02-01 479 1.0.1 correct so name; use checkpath_cpp.mk +# 2013-01-27 478 1.0 Initial version +#--- +# +# Name of the sharable library +# +SONAME = rw11 +SOMAJV = 1 +SOMINV = 0 +# +# Compile and Link search paths +# +include ../checkpath_cpp.mk +# +INCLFLAGS = -I${RETROBASE}/tools/src -I${BOOSTINC} +LDLIBS = -L${RETROBASE}/tools/lib -lrtools -lrlink +# +# Object files to be included +# +OBJ_all = Rw11.o Rw11Cpu.o Rw11CpuW11a.o +OBJ_all += Rw11Probe.o +OBJ_all += Rw11Cntl.o Rw11Unit.o +OBJ_all += Rw11UnitTerm.o +OBJ_all += Rw11CntlDL11.o Rw11UnitDL11.o +OBJ_all += Rw11Virt.o +OBJ_all += Rw11VirtTerm.o Rw11VirtTermPty.o Rw11VirtTermTcp.o +# +DEP_all = $(OBJ_all:.o=.dep) +# +#- generic part ---------------------------------------------------------------- +# +SOFILE = lib$(SONAME).so +SOFILEV = lib$(SONAME).so.$(SOMAJV) +SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) +# +include $(RETROBASE)/tools/make/generic_cpp.mk +include $(RETROBASE)/tools/make/generic_dep.mk +include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk +# +# The magic autodependcy include +# +ifndef DONTINCDEP +include $(DEP_all) +endif +# +# cleanup phonies: +# +.PHONY : clean cleandep distclean +clean : + @ rm -f $(OBJ_all) + @ echo "Object files removed" +# +cleandep : + @ rm -f $(DEP_all) + @ echo "Dependency files removed" +# +distclean : clean cleandep + @ rm -f $(SOPATH)/lib$(SONAME).a $(SOPATH)/lib$(SONAME).so* + @ echo "Libraries removed" +# diff --git a/tools/src/librw11/Rw11.cpp b/tools/src/librw11/Rw11.cpp new file mode 100644 index 00000000..495e6032 --- /dev/null +++ b/tools/src/librw11/Rw11.cpp @@ -0,0 +1,142 @@ +// $Id: Rw11.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11. +*/ + +#include "librtools/Rexception.hpp" + +#include "librtools/RosFill.hpp" +#include "Rw11Cpu.hpp" + +#include "Rw11.hpp" + +using namespace std; + +/*! + \class Retro::Rw11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const int Rw11::kLam; + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11::Rw11() + : fspServ(), + fNCpu(0), + fStarted(false) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11::~Rw11() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11::SetServer(const boost::shared_ptr& spserv) +{ + fspServ = spserv; + fspServ->AddAttnHandler(boost::bind(&Rw11::AttnHandler, this, _1), + uint16_t(1)<& spcpu) +{ + if (fNCpu >= 4) + throw Rexception("Rw11::AddCpu", "Bad state: already 4 cpus registered"); + if (fNCpu > 0 && fspCpu[0]->Type() != spcpu->Type()) + throw Rexception("Rw11::AddCpu", "Bad state: type mismatch, new is " + + spcpu->Type() + " first was " + fspCpu[0]->Type()); + + fspCpu[fNCpu] = spcpu; + fNCpu += 1; + spcpu->Setup(this); + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rw11Cpu& Rw11::Cpu(size_t ind) const +{ + return *fspCpu[ind]; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11::Start() +{ + if (fStarted) + throw Rexception("Rw11::Start()","alread started"); + + for (size_t i=0; iStart(); + + if (!Server().IsActive()) Server().Start(); + + fStarted = true; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11 @ " << this << endl; + + os << bl << " fspServ: " << fspServ.get() << endl; + os << bl << " fNCpu: " << fNCpu << endl; + os << bl << " fspCpu[4]: "; + for (size_t i=0; i<4; i++) os << fspCpu[i].get() << " "; + os << endl; + os << bl << " fStarted: " << fStarted << endl; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11::AttnHandler(const RlinkServer::AttnArgs& args) +{ + for (size_t i=0; iW11AttnHandler(); + return 0; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11.hpp b/tools/src/librw11/Rw11.hpp new file mode 100644 index 00000000..69a8c9f6 --- /dev/null +++ b/tools/src/librw11/Rw11.hpp @@ -0,0 +1,77 @@ +// $Id: Rw11.hpp 502 2013-04-02 19:29:30Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11.hpp 502 2013-04-02 19:29:30Z mueller $ + \brief Declaration of class Rw11. +*/ + +#ifndef included_Retro_Rw11 +#define included_Retro_Rw11 1 + +#include "boost/utility.hpp" +#include "boost/shared_ptr.hpp" + +#include "librlink/RlinkServer.hpp" + +namespace Retro { + + class Rw11Cpu; // forw decl to avoid circular incl + + class Rw11 : private boost::noncopyable { + public: + + Rw11(); + virtual ~Rw11(); + + void SetServer(const boost::shared_ptr& spserv); + const boost::shared_ptr& ServerSPtr() const; + RlinkServer& Server() const; + RlinkConnect& Connect() const; + RlogFile& LogFile() const; + + void AddCpu(const boost::shared_ptr& spcpu); + size_t NCpu() const; + Rw11Cpu& Cpu(size_t ind) const; + + void Start(); + bool IsStarted() const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // some constants (also defined in cpp) + static const int kLam = 0; //!< W11 CPU cluster lam + + protected: + int AttnHandler(const RlinkServer::AttnArgs& args); + + protected: + boost::shared_ptr fspServ; + size_t fNCpu; + boost::shared_ptr fspCpu[4]; + bool fStarted; //!< true if Start() called + }; + +} // end namespace Retro + +#include "Rw11.ipp" + +#endif diff --git a/tools/src/librw11/Rw11.ipp b/tools/src/librw11/Rw11.ipp new file mode 100644 index 00000000..c842837e --- /dev/null +++ b/tools/src/librw11/Rw11.ipp @@ -0,0 +1,78 @@ +// $Id: Rw11.ipp 502 2013-04-02 19:29:30Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11.ipp 502 2013-04-02 19:29:30Z mueller $ + \brief Implemenation (inline) of Rw11. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const boost::shared_ptr& Rw11::ServerSPtr() const +{ + return fspServ; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& Rw11::Server() const +{ + return *fspServ; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& Rw11::Connect() const +{ + return fspServ->Connect(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& Rw11::LogFile() const +{ + return fspServ->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t Rw11::NCpu() const +{ + return fNCpu; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool Rw11::IsStarted() const +{ + return fStarted; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Cntl.cpp b/tools/src/librw11/Rw11Cntl.cpp new file mode 100644 index 00000000..4bd6e230 --- /dev/null +++ b/tools/src/librw11/Rw11Cntl.cpp @@ -0,0 +1,181 @@ +// $Id: Rw11Cntl.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Cntl.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of Rw11Cntl. +*/ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/Rexception.hpp" + +#include "Rw11Cntl.hpp" + +using namespace std; + +/*! + \class Retro::Rw11Cntl + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +Rw11Cntl::Rw11Cntl(const std::string& type) + : fpCpu(0), + fType(type), + fName(), + fBase(0), + fLam(-1), + fEnable(true), + fStarted(false), + fProbe(), + fTraceLevel(0), + fPrimClist(), + fStats() +{ + fStats.Define(kStatNAttnHdl, "NAttnHdl", "AttnHandler() calls"); + fStats.Define(kStatNPrimFused,"NPrimFused","PrimInfo fused with attn cmd"); + fStats.Define(kStatNAttnNoAct,"NAttnNoAct","AttnHandler() no action return"); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11Cntl::~Rw11Cntl() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cntl::SetEnable(bool ena) +{ + if (fStarted) + throw Rexception("Rw11Cntl::SetEnable", "only allowed before Start()"); + fEnable = ena; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cntl::Probe() +{ + return Cpu().ProbeCntl(fProbe); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cntl::Start() +{ + fStarted = true; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cntl::BootCode(size_t unit, std::vector& code, + uint16_t& aload, uint16_t& astart) +{ + code.clear(); + aload = 0; + astart = 0; + return false; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +std::string Rw11Cntl::UnitName(size_t index) const +{ + string name = fName; + if (index > 9) name += char('0' + index/10); + name += char('0' + index%10); + return name; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cntl::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11Cntl @ " << this << endl; + + os << bl << " fpCpu: " << fpCpu << endl; + os << bl << " fType: " << fType << endl; + os << bl << " fName: " << fName << endl; + os << bl << " fBase: " << RosPrintf(fBase,"o0",6) << endl; + os << bl << " fLam: " << fLam << endl; + os << bl << " fEnable: " << fEnable << endl; + os << bl << " fStarted: " << fStarted << endl; + fProbe.Dump(os, ind+2, "fProbe: "); + os << bl << " fTraceLevel: " << fTraceLevel << endl; + fPrimClist.Dump(os, ind+2, "fPrimClist: "); + fStats.Dump(os, ind+2, "fStats: "); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cntl::ConfigCntl(const std::string& name, uint16_t base, int lam, + uint16_t probeoff, bool probeint, bool proberem) +{ + fName = name; + fBase = base; + fLam = lam; + fProbe.fAddr = base + probeoff; + fProbe.fProbeInt = probeint; + fProbe.fProbeRem = proberem; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cntl::GetPrimInfo(const RlinkServer::AttnArgs& args, + RlinkCommandList*& pclist, size_t& offset) +{ + fStats.Inc(kStatNAttnHdl); + + if (args.fpClist) { + fStats.Inc(kStatNPrimFused); + pclist = args.fpClist; + offset = args.fOffset; + + } else { + Server().Exec(fPrimClist); + // FIXME_code: handle errors + pclist = &fPrimClist; + offset = 0; + } + + return; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Cntl.hpp b/tools/src/librw11/Rw11Cntl.hpp new file mode 100644 index 00000000..c4077b04 --- /dev/null +++ b/tools/src/librw11/Rw11Cntl.hpp @@ -0,0 +1,117 @@ +// $Id: Rw11Cntl.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11Cntl.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11Cntl. +*/ + +#ifndef included_Retro_Rw11Cntl +#define included_Retro_Rw11Cntl 1 + +#include + +#include "boost/utility.hpp" + +#include "librtools/Rstats.hpp" +#include "librlink/RlinkConnect.hpp" +#include "librlink/RlinkServer.hpp" +#include "Rw11Probe.hpp" + +#include "librtools/Rbits.hpp" +#include "Rw11Cpu.hpp" + +namespace Retro { + + class Rw11Cntl : public Rbits, private boost::noncopyable { + public: + + explicit Rw11Cntl(const std::string& type); + virtual ~Rw11Cntl(); + + void SetCpu(Rw11Cpu* pcpu); + Rw11Cpu& Cpu() const; + Rw11& W11() const; + RlinkServer& Server() const; + RlinkConnect& Connect() const; + RlogFile& LogFile() const; + + const std::string& Type() const; + const std::string& Name() const; + uint16_t Base() const; + int Lam() const; + + void SetEnable(bool ena); + bool Enable() const; + + virtual bool Probe(); + const Rw11Probe& ProbeStatus() const; + + virtual void Start(); + bool IsStarted() const; + + virtual bool BootCode(size_t unit, std::vector& code, + uint16_t& aload, uint16_t& astart); + + void SetTraceLevel(uint32_t level); + uint32_t TraceLevel() const; + + std::string UnitName(size_t index) const; + + const Rstats& Stats() const; + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices + enum stats { + kStatNAttnHdl = 0, + kStatNPrimFused, + kStatNAttnNoAct, + kDimStat + }; + + protected: + void ConfigCntl(const std::string& name, uint16_t base, int lam, + uint16_t probeoff, bool probeint, bool proberem); + void GetPrimInfo(const RlinkServer::AttnArgs& args, + RlinkCommandList*& pclist, size_t& offset); + + private: + Rw11Cntl() {} //!< default ctor blocker + + protected: + Rw11Cpu* fpCpu; //!< cpu back pointer + std::string fType; //!< controller type + std::string fName; //!< controller name + uint16_t fBase; //!< controller base address + int fLam; //!< attn bit number (-1 of none) + bool fEnable; //!< enable flag + bool fStarted; //!< true if Start() called + Rw11Probe fProbe; //!< controller probe context + uint32_t fTraceLevel; //!< trace level; 0=off;1=attn + RlinkCommandList fPrimClist; //!< clist for attn primary info + Rstats fStats; //!< statistics + }; + +} // end namespace Retro + +#include "Rw11Cntl.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Cntl.ipp b/tools/src/librw11/Rw11Cntl.ipp new file mode 100644 index 00000000..e203dc34 --- /dev/null +++ b/tools/src/librw11/Rw11Cntl.ipp @@ -0,0 +1,159 @@ +// $Id: Rw11Cntl.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Cntl.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of Rw11Cntl. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void Rw11Cntl::SetCpu(Rw11Cpu* pcpu) +{ + fpCpu = pcpu; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Cpu& Rw11Cntl::Cpu() const +{ + return *fpCpu; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11& Rw11Cntl::W11() const +{ + return fpCpu->W11(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& Rw11Cntl::Server() const +{ + return fpCpu->Server(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& Rw11Cntl::Connect() const +{ + return fpCpu->Connect(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& Rw11Cntl::LogFile() const +{ + return fpCpu->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& Rw11Cntl::Type() const +{ + return fType; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& Rw11Cntl::Name() const +{ + return fName; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint16_t Rw11Cntl::Base() const +{ + return fBase; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline int Rw11Cntl::Lam() const +{ + return fLam; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool Rw11Cntl::Enable() const +{ + return fEnable; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rw11Probe& Rw11Cntl::ProbeStatus() const +{ + return fProbe; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool Rw11Cntl::IsStarted() const +{ + return fStarted; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void Rw11Cntl::SetTraceLevel(uint32_t level) +{ + fTraceLevel = level; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint32_t Rw11Cntl::TraceLevel() const +{ + return fTraceLevel; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rstats& Rw11Cntl::Stats() const +{ + return fStats; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11CntlBase.hpp b/tools/src/librw11/Rw11CntlBase.hpp new file mode 100644 index 00000000..03d5f83c --- /dev/null +++ b/tools/src/librw11/Rw11CntlBase.hpp @@ -0,0 +1,57 @@ +// $Id: Rw11CntlBase.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-14 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11CntlBase.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11CntlBase. +*/ + +#ifndef included_Retro_Rw11CntlBase +#define included_Retro_Rw11CntlBase 1 + +#include "boost/shared_ptr.hpp" + +#include "Rw11Cntl.hpp" + +namespace Retro { + + template + class Rw11CntlBase : public Rw11Cntl { + public: + + explicit Rw11CntlBase(const std::string& type); + ~Rw11CntlBase(); + + size_t NUnit() const; + TU& Unit(size_t index) const; + const boost::shared_ptr& UnitSPtr(size_t index) const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + boost::shared_ptr fspUnit[NU]; + }; + +} // end namespace Retro + +#include "Rw11CntlBase.ipp" + +#endif diff --git a/tools/src/librw11/Rw11CntlBase.ipp b/tools/src/librw11/Rw11CntlBase.ipp new file mode 100644 index 00000000..5424c816 --- /dev/null +++ b/tools/src/librw11/Rw11CntlBase.ipp @@ -0,0 +1,100 @@ +// $Id: Rw11CntlBase.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-14 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11CntlBase.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of Rw11CntlBase. +*/ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" + +#include "Rw11CntlBase.hpp" + +/*! + \class Retro::Rw11CntlBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +inline Rw11CntlBase::Rw11CntlBase(const std::string& type) + : Rw11Cntl(type) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +template +inline Rw11CntlBase::~Rw11CntlBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline size_t Rw11CntlBase::NUnit() const +{ + return NU; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TU& Rw11CntlBase::Unit(size_t index) const +{ + return *fspUnit[index]; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline const boost::shared_ptr& + Rw11CntlBase::UnitSPtr(size_t index) const +{ + return fspUnit[index]; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +void Rw11CntlBase::Dump(std::ostream& os, int ind, + const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11CntlBase @ " << this << std::endl; + os << bl << " fspUnit: " << std::endl; + for (size_t i=0; i +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11CntlDL11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11CntlDL11. +*/ + +#include "boost/bind.hpp" + +#include "librtools/RosFill.hpp" +#include "librtools/Rexception.hpp" + +#include "Rw11CntlDL11.hpp" + +using namespace std; + +/*! + \class Retro::Rw11CntlDL11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const uint16_t Rw11CntlDL11::kIbaddr; +const int Rw11CntlDL11::kLam; + +const uint16_t Rw11CntlDL11::kRCSR; +const uint16_t Rw11CntlDL11::kRBUF; +const uint16_t Rw11CntlDL11::kXCSR; +const uint16_t Rw11CntlDL11::kXBUF; + +const uint16_t Rw11CntlDL11::kProbeOff; +const bool Rw11CntlDL11::kProbeInt; +const bool Rw11CntlDL11::kProbeRem; + +const uint16_t Rw11CntlDL11::kRCSR_M_RDONE; +const uint16_t Rw11CntlDL11::kXCSR_M_XRDY; +const uint16_t Rw11CntlDL11::kXBUF_M_RRDY; +const uint16_t Rw11CntlDL11::kXBUF_M_XVAL; +const uint16_t Rw11CntlDL11::kXBUF_M_XBUF; + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11CntlDL11::Rw11CntlDL11() + : Rw11CntlBase("dl11"), + fPC_xbuf(0) +{ + // must here because Unit have a back-pointer (not available at Rw11CntlBase) + for (size_t i=0; iRcvQueueEmpty()) { + RlinkCommandList clist; + Cpu().AddIbrb(clist, fBase); + size_t ircsr = Cpu().AddRibr(clist, fBase+kRCSR); + Server().Exec(clist); + // FIXME_code: handle errors + uint16_t rcsr = clist[ircsr].Data(); + if ((rcsr & kRCSR_M_RDONE) == 0) { // RBUF not full + uint8_t ichr = fspUnit[0]->RcvNext(); + clist.Clear(); + Cpu().AddWibr(clist, fBase+kRBUF, ichr); + Server().Exec(clist); + // FIXME_code: handle errors + } + } + + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11CntlDL11::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11CntlDL11 @ " << this << endl; + Rw11CntlBase::Dump(os, ind, " ^"); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11CntlDL11::AttnHandler(const RlinkServer::AttnArgs& args) +{ + RlinkCommandList* pclist; + size_t off; + + GetPrimInfo(args, pclist, off); + + uint16_t xbuf = (*pclist)[off+fPC_xbuf].Data(); + + uint8_t ochr = xbuf & kXBUF_M_XBUF; + bool xval = xbuf & kXBUF_M_XVAL; + bool rrdy = xbuf & kXBUF_M_RRDY; + + if (xval) { + fspUnit[0]->Snd(&ochr, 1); + } + + if (rrdy && !fspUnit[0]->RcvQueueEmpty()) { + uint8_t ichr = fspUnit[0]->RcvNext(); + RlinkCommandList clist; + Cpu().AddWibr(clist, fBase+kRBUF, ichr); + Server().Exec(clist); + // FIXME_code: handle errors + } + + return 0; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11CntlDL11.hpp b/tools/src/librw11/Rw11CntlDL11.hpp new file mode 100644 index 00000000..a6a6772b --- /dev/null +++ b/tools/src/librw11/Rw11CntlDL11.hpp @@ -0,0 +1,79 @@ +// $Id: Rw11CntlDL11.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11CntlDL11.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11CntlDL11. +*/ + +#ifndef included_Retro_Rw11CntlDL11 +#define included_Retro_Rw11CntlDL11 1 + +#include "Rw11CntlBase.hpp" +#include "Rw11UnitDL11.hpp" + +namespace Retro { + + class Rw11CntlDL11 : public Rw11CntlBase { + public: + + Rw11CntlDL11(); + ~Rw11CntlDL11(); + + void Config(const std::string& name, uint16_t base, int lam); + + virtual void Start(); + + void Wakeup(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // some constants (also defined in cpp) + static const uint16_t kIbaddr = 0177560; //!< RK11 default address + static const int kLam = 1; //!< RK11 default lam + + static const uint16_t kRCSR = 000; //!< RCSR register address offset + static const uint16_t kRBUF = 002; //!< RBUF register address offset + static const uint16_t kXCSR = 004; //!< XCSR register address offset + static const uint16_t kXBUF = 006; //!< XBUF register address offset + + static const uint16_t kProbeOff = kRCSR; //!< probe address offset (rcsr) + static const bool kProbeInt = true; //!< probe int active + static const bool kProbeRem = true; //!< probr rem active + + static const uint16_t kRCSR_M_RDONE = kWBit07; + static const uint16_t kXCSR_M_XRDY = kWBit07; + static const uint16_t kXBUF_M_RRDY = kWBit09; + static const uint16_t kXBUF_M_XVAL = kWBit08; + static const uint16_t kXBUF_M_XBUF = 0xff; + + protected: + int AttnHandler(const RlinkServer::AttnArgs& args); + + protected: + size_t fPC_xbuf; //!< PrimClist: xbuf index + }; + +} // end namespace Retro + +//#include "Rw11CntlDL11.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Cpu.cpp b/tools/src/librw11/Rw11Cpu.cpp new file mode 100644 index 00000000..4be05dcd --- /dev/null +++ b/tools/src/librw11/Rw11Cpu.cpp @@ -0,0 +1,651 @@ +// $Id: Rw11Cpu.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-12 504 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Cpu.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11Cpu. +*/ +#include +#include +#include + +#include +#include +#include + +#include "boost/date_time/posix_time/posix_time_types.hpp" + +#include "librtools/Rexception.hpp" +#include "librtools/RlogMsg.hpp" +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosPrintBvi.hpp" +#include "Rw11Cntl.hpp" + +#include "Rw11Cpu.hpp" + +using namespace std; + +/*! + \class Retro::Rw11Cpu + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const uint16_t Rw11Cpu::kCp_addr_conf; +const uint16_t Rw11Cpu::kCp_addr_cntl; +const uint16_t Rw11Cpu::kCp_addr_stat; +const uint16_t Rw11Cpu::kCp_addr_psw; +const uint16_t Rw11Cpu::kCp_addr_al; +const uint16_t Rw11Cpu::kCp_addr_ah; +const uint16_t Rw11Cpu::kCp_addr_mem; +const uint16_t Rw11Cpu::kCp_addr_memi; +const uint16_t Rw11Cpu::kCp_addr_r0; +const uint16_t Rw11Cpu::kCp_addr_pc; +const uint16_t Rw11Cpu::kCp_addr_ibrb; +const uint16_t Rw11Cpu::kCp_addr_ibr; + +const uint16_t Rw11Cpu::kCp_func_noop; +const uint16_t Rw11Cpu::kCp_func_start; +const uint16_t Rw11Cpu::kCp_func_stop; +const uint16_t Rw11Cpu::kCp_func_cont; +const uint16_t Rw11Cpu::kCp_func_step; +const uint16_t Rw11Cpu::kCp_func_reset; + +const uint16_t Rw11Cpu::kCp_stat_m_cpurust; +const uint16_t Rw11Cpu::kCp_stat_v_cpurust; +const uint16_t Rw11Cpu::kCp_stat_b_cpurust; +const uint16_t Rw11Cpu::kCp_stat_m_cpuhalt; +const uint16_t Rw11Cpu::kCp_stat_m_cpugo; +const uint16_t Rw11Cpu::kCp_stat_m_cmdmerr; +const uint16_t Rw11Cpu::kCp_stat_m_cmderr; + +const uint16_t Rw11Cpu::kCp_cpurust_init; +const uint16_t Rw11Cpu::kCp_cpurust_halt; +const uint16_t Rw11Cpu::kCp_cpurust_reset; +const uint16_t Rw11Cpu::kCp_cpurust_stop; +const uint16_t Rw11Cpu::kCp_cpurust_step; +const uint16_t Rw11Cpu::kCp_cpurust_susp; +const uint16_t Rw11Cpu::kCp_cpurust_runs; +const uint16_t Rw11Cpu::kCp_cpurust_vecfet; +const uint16_t Rw11Cpu::kCp_cpurust_recrsv; +const uint16_t Rw11Cpu::kCp_cpurust_sfail; +const uint16_t Rw11Cpu::kCp_cpurust_vfail; + +//------------------------------------------+----------------------------------- +//! Constructor + +Rw11Cpu::Rw11Cpu(const std::string& type) + : fpW11(0), + fType(type), + fIndex(0), + fBase(0), + fCpuGo(0), + fCpuStat(0), + fCpuGoMutex(), + fCpuGoCond(), + fCntlMap(), + fStats() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11Cpu::~Rw11Cpu() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::Setup(Rw11* pw11) +{ + fpW11 = pw11; + // command base: 'cn.', where n is cpu index + string cbase = "c"; + cbase += '0'+Index(); + cbase += '.'; + Connect().AddrMapInsert(cbase+"conf", Base()+kCp_addr_conf); + Connect().AddrMapInsert(cbase+"cntl", Base()+kCp_addr_cntl); + Connect().AddrMapInsert(cbase+"stat", Base()+kCp_addr_stat); + Connect().AddrMapInsert(cbase+"psw" , Base()+kCp_addr_psw); + Connect().AddrMapInsert(cbase+"al" , Base()+kCp_addr_al); + Connect().AddrMapInsert(cbase+"ah" , Base()+kCp_addr_ah); + Connect().AddrMapInsert(cbase+"mem" , Base()+kCp_addr_mem); + Connect().AddrMapInsert(cbase+"memi", Base()+kCp_addr_memi); + Connect().AddrMapInsert(cbase+"r0" , Base()+kCp_addr_r0); + Connect().AddrMapInsert(cbase+"r1" , Base()+kCp_addr_r0+1); + Connect().AddrMapInsert(cbase+"r2" , Base()+kCp_addr_r0+2); + Connect().AddrMapInsert(cbase+"r3" , Base()+kCp_addr_r0+3); + Connect().AddrMapInsert(cbase+"r4" , Base()+kCp_addr_r0+4); + Connect().AddrMapInsert(cbase+"r5" , Base()+kCp_addr_r0+5); + Connect().AddrMapInsert(cbase+"sp" , Base()+kCp_addr_r0+6); + Connect().AddrMapInsert(cbase+"pc" , Base()+kCp_addr_r0+7); + Connect().AddrMapInsert(cbase+"ibrb", Base()+kCp_addr_ibrb); + // create names for ib window, line c0.ib00, c0.ib02,.., c0.ib76 + for (int i=0; i<32; i++) { + string rname = cbase + "ib"; + rname += '0' + ((i>>2)&07); + rname += '0' + ((i<<1)&07); + Connect().AddrMapInsert(rname , Base()+kCp_addr_ibr+i); + } + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::AddCntl(const boost::shared_ptr& spcntl) +{ + if (!spcntl) + throw Rexception("Rw11Cpu::AddCntl","Bad args: spcntl == 0"); + + string name(spcntl->Name()); + if (fCntlMap.find(name) != fCntlMap.end()) + throw Rexception("Rw11Cpu::AddCntl", + "Bad state: duplicate controller name");; + + fCntlMap.insert(cmap_val_t(name, spcntl)); + spcntl->SetCpu(this); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cpu::TestCntl(const std::string& name) const +{ + return fCntlMap.find(name) != fCntlMap.end(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::ListCntl(std::vector& list) const +{ + list.clear(); + for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) { + list.push_back((it->second)->Name()); + } + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rw11Cntl& Rw11Cpu::Cntl(const std::string& name) const +{ + cmap_cit_t it=fCntlMap.find(name); + if (it == fCntlMap.end()) + throw Rexception("Rw11Cpu::Cntl()", + "Bad args: controller name '" + name + "' unknown"); + return *(it->second); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::Start() +{ + for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) { + Rw11Cntl& cntl(*(it->second)); + cntl.Probe(); + if (cntl.ProbeStatus().Found() && cntl.Enable()) { + cntl.Start(); + } + } + return; +} + + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +std::string Rw11Cpu::NextCntlName(const std::string& base) const +{ + for (char let='a'; let<='z'; let++) { + string name = base + let; + if (fCntlMap.find(name) == fCntlMap.end()) return name; + } + throw Rexception("Rw11Cpu::NextCntlName", + "Bad args: all controller letters used for '" + base + "'"); + return ""; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11Cpu::AddIbrb(RlinkCommandList& clist, uint16_t ibaddr) +{ + return clist.AddWreg(fBase+kCp_addr_ibrb, ibaddr & ~(077)); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11Cpu::AddRibr(RlinkCommandList& clist, uint16_t ibaddr) +{ + uint16_t ibroff = (ibaddr & 077)/2; + return clist.AddRreg(fBase+kCp_addr_ibr + ibroff); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11Cpu::AddWibr(RlinkCommandList& clist, uint16_t ibaddr, uint16_t data) +{ + uint16_t ibroff = (ibaddr & 077)/2; + return clist.AddWreg(fBase+kCp_addr_ibr + ibroff, data); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cpu::MemRead(uint16_t addr, std::vector& data, + size_t nword, RerrMsg& emsg) +{ + data.resize(nword); + size_t ndone = 0; + while (nword>ndone) { + size_t nblk = min(size_t(256), nword-ndone); + RlinkCommandList clist; + clist.AddWreg(fBase+kCp_addr_al, addr+2*ndone); + clist.AddRblk(fBase+kCp_addr_memi, data.data()+ndone, nblk); + if (!Server().Exec(clist, emsg)) return false; + ndone += nblk; + } + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cpu::MemWrite(uint16_t addr, const std::vector& data, + RerrMsg& emsg) +{ + size_t nword = data.size(); + size_t ndone = 0; + while (nword>ndone) { + size_t nblk = min(size_t(256), nword-ndone); + RlinkCommandList clist; + clist.AddWreg(fBase+kCp_addr_al, addr+2*ndone); + clist.AddWblk(fBase+kCp_addr_memi, data.data()+ndone, nblk); + if (!Server().Exec(clist, emsg)) return false; + ndone += nblk; + } + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cpu::ProbeCntl(Rw11Probe& dsc) +{ + if (!(dsc.fProbeInt | dsc.fProbeRem) || dsc.fAddr == 0) + throw Rexception("Rw11Cpu::Probe", + "Bad args: fAddr == 0 or fProbeInt|fProbeRem == false"); + + if (!dsc.fProbeDone) { + RlinkCommandList clist; + int iib = -1; + int irb = -1; + if (dsc.fProbeInt) { + clist.AddWreg(fBase+kCp_addr_al, dsc.fAddr); + iib = clist.AddRreg(fBase+kCp_addr_mem); + clist.LastExpect(new RlinkCommandExpect(0,0xff)); // disable stat checking + } + if (dsc.fProbeRem) { + AddIbrb(clist, dsc.fAddr); + irb = AddRibr(clist, dsc.fAddr); + clist.LastExpect(new RlinkCommandExpect(0,0xff)); // disable stat checking + } + + Server().Exec(clist); + // FIXME_code: handle errors + + if (dsc.fProbeInt) { + dsc.fFoundInt = (clist[iib].Status() & (RlinkCommand::kStat_M_RbNak | + RlinkCommand::kStat_M_RbErr)) ==0; + } + if (dsc.fProbeRem) { + dsc.fFoundRem = (clist[irb].Status() & (RlinkCommand::kStat_M_RbNak | + RlinkCommand::kStat_M_RbErr)) ==0; + } + dsc.fProbeDone = true; + } + + return dsc.Found(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +// absolute binary format described in notes_ptape.txt + +bool Rw11Cpu::LoadAbs(const std::string& fname, RerrMsg& emsg, bool trace) +{ + int fd = open(fname.c_str(), O_RDONLY); + + if (fd < 0) { + emsg.InitErrno("Rw11Cpu::LoadAbs()", string("open() for '") + fname + + string("' failed: "), errno); + return false; + } + + enum states { + s_chr0, + s_chr1, + s_cntlow, + s_cnthgh, + s_adrlow, + s_adrhgh, + s_data, + s_chksum + }; + + typedef std::map obmap_t; + typedef obmap_t::iterator obmap_it_t; + typedef obmap_t::const_iterator obmap_cit_t; + typedef obmap_t::value_type obmap_val_t; + + obmap_t oddbyte; // odd byte cache + + vector data; + data.reserve(256); + + int chrnum = -1; // char number in block + int blknum = 0; // block number + int bytcnt = 0; // byte count + uint16_t ldaddr = 0; // load address + uint8_t chksum = 0; // check sum + uint16_t addr = 0; // current address + uint16_t word = 0; // current word + + bool ok = false; + bool go = true; + enum states state = s_chr0; + + while (go) { + uint8_t byte; + int irc = read(fd, &byte, 1); + if (irc == 0) { + if (state == s_chr0) { + ok = true; + } else { + emsg.Init("Rw11Cpu::LoadAbs()", "unexpected EOF"); + } + break; + } else if (irc < 0) { + emsg.InitErrno("Rw11Cpu::LoadAbs()", "read() failed: ", errno); + break; + } + + chrnum += 1; + chksum += byte; + + //cout << "+++1 " << blknum << "," << chrnum << " s=" << state << " : " + // << RosPrintBvi(byte,8) << endl; + + switch (state) { + case s_chr0: + if (byte == 0) { + chrnum = -1; + state = s_chr0; + } else if (byte == 1) { + state = s_chr1; + } else { + emsg.InitPrintf("Rw11Cpu::LoadAbs()", + "unexpected start-of-block %3.3o", byte); + go = false; + } + break; + + case s_chr1: + if (byte == 0) { + state = s_cntlow; + } else { + emsg.InitPrintf("Rw11Cpu::LoadAbs()", + "unexpected 2nd char %3.3o", byte); + go = false; + } + break; + + case s_cntlow: + bytcnt = byte; + state = s_cnthgh; + break; + + case s_cnthgh: + bytcnt |= uint16_t(byte) << 8; + state = s_adrlow; + break; + + case s_adrlow: + ldaddr = byte; + state = s_adrhgh; + break; + + case s_adrhgh: + ldaddr |= uint16_t(byte) << 8; + addr = ldaddr; + word = 0; + if ((addr & 0x01) == 1 && bytcnt > 6) { + obmap_cit_t it = oddbyte.find(addr); + if (it != oddbyte.end()) { + word = it->second; + } else { + if (trace) { + RlogMsg lmsg(LogFile()); + lmsg << "LoadAbs-W: no low byte data for " << RosPrintBvi(addr,8); + } + } + } + + if (trace) { + RlogMsg lmsg(Connect().LogFile()); + lmsg << "LoadAbs-I: block " << RosPrintf(blknum,"d",3) + << ", length " << RosPrintf(bytcnt-6,"d",5) + << " byte, address " << RosPrintBvi(ldaddr,8) + << ":" << RosPrintBvi(uint16_t(ldaddr+(bytcnt-6)-1),8); + } + state = (bytcnt == 6) ? s_chksum : s_data; + break; + + case s_data: + if ((addr & 0x01) == 0) { // even (low) byte + word = byte; + } else { // odd (high) byte + word |= uint16_t(byte) << 8; + data.push_back(word); + } + addr += 1; + if (chrnum == bytcnt-1) state = s_chksum; + break; + + case s_chksum: + if (chksum != 0) { + emsg.InitPrintf("Rw11Cpu::LoadAbs()", "check sum error %3.3o", chksum); + go = false; + } else if (bytcnt == 6) { + if (trace) { + RlogMsg lmsg(Connect().LogFile()); + lmsg << "LoadAbs-I: start address " << RosPrintBvi(ldaddr,8); + } + go = false; + ok = true; + } else { + if ((addr & 0x01) == 1) { // high byte not yet seen + data.push_back(word); // zero fill high byte + oddbyte.insert(obmap_val_t(addr,word)); // store even byte for later + } + + //cout << "+++2 " << RosPrintBvi(ldaddr,8) + // << " " << data.size() << endl; + + if (!MemWrite(ldaddr, data, emsg)) { + go = false; + } + data.clear(); + } + chrnum = -1; + blknum += 1; + state = s_chr0; + break; + + } // switch(state) + } // while(go) + + close(fd); + + return ok; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Cpu::Boot(const std::string& uname, RerrMsg& emsg) +{ + string cname; + size_t uind=0; + for (size_t i=0; i= '0' && c <= '9') { + string unum = cname.substr(i); + uind = atoi(unum.c_str()); + break; + } else { + cname.push_back(c); + } + } + + if (!TestCntl(cname)) { + emsg.Init("Rw11Cpu::Boot", string("controller '") + cname + + string("' not known")); + return false; + } + + // FIXME_code: unit number not checked. Cntl doesn't even know about ... + + Rw11Cntl& cntl = Cntl(cname); + + vector code; + uint16_t aload = 0; + uint16_t astart = 0; + + if (!cntl.BootCode(uind, code, aload, astart) || code.size()==0) { + emsg.Init("Rw11Cpu::Boot", string("boot not supported for controller '") + + cname + string("'")); + return false; + } + + if (!MemWrite(aload, code, emsg)) return false; + + RlinkCommandList clist; + clist.AddWreg(fBase+kCp_addr_pc, astart); + clist.AddWreg(fBase+kCp_addr_cntl, kCp_func_start); + SetCpuGoUp(); + if (!Server().Exec(clist, emsg)) return false; + + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::SetCpuGoUp() +{ + boost::lock_guard lock(fCpuGoMutex); + fCpuGo = true; + fCpuStat = 0; + fCpuGoCond.notify_all(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::SetCpuGoDown(uint16_t stat) +{ + if ((stat & kCp_stat_m_cpugo) == 0) { + boost::lock_guard lock(fCpuGoMutex); + fCpuGo = false; + fCpuStat = stat; + fCpuGoCond.notify_all(); + } + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +double Rw11Cpu::WaitCpuGoDown(double tout) +{ + boost::system_time t0(boost::get_system_time()); + boost::system_time timeout(boost::posix_time::max_date_time); + if (tout > 0.) + timeout = t0 + boost::posix_time::microseconds((long)1E6 * tout); + boost::unique_lock lock(fCpuGoMutex); + while (fCpuGo) { + if (!fCpuGoCond.timed_wait(lock, timeout)) return -1.; + } + boost::posix_time::time_duration dt = boost::get_system_time() - t0; + return double(dt.ticks()) / dt.ticks_per_second(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::W11AttnHandler() +{ + RlinkCommandList clist; + clist.AddRreg(fBase+kCp_addr_stat); + if (Server().Exec(clist)) + SetCpuGoDown(clist[0].Data()); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Cpu::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11Cpu @ " << this << endl; + + os << bl << " fpW11: " << fpW11 << endl; + os << bl << " fType: " << fType << endl; + os << bl << " fIndex: " << fIndex << endl; + os << bl << " fBase: " << RosPrintf(fBase,"$x0",4) << endl; + os << bl << " fCpuGo: " << fCpuGo << endl; + os << bl << " fCpuStat: " << RosPrintf(fCpuStat,"$x0",4) << endl; + os << bl << " fCntlMap: " << endl; + for (cmap_cit_t it=fCntlMap.begin(); it!=fCntlMap.end(); it++) { + os << bl << " " << RosPrintf((it->first).c_str(), "-s",8) + << " : " << it->second << endl; + } + fStats.Dump(os, ind+2, "fStats: "); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Cpu.hpp b/tools/src/librw11/Rw11Cpu.hpp new file mode 100644 index 00000000..612add75 --- /dev/null +++ b/tools/src/librw11/Rw11Cpu.hpp @@ -0,0 +1,168 @@ +// $Id: Rw11Cpu.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-12 504 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11Cpu.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11Cpu. +*/ + +#ifndef included_Retro_Rw11Cpu +#define included_Retro_Rw11Cpu 1 + +#include +#include + +#include "boost/utility.hpp" +#include "boost/shared_ptr.hpp" +#include "boost/thread/locks.hpp" +#include "boost/thread/condition_variable.hpp" + +#include "librtools/Rstats.hpp" +#include "librtools/RerrMsg.hpp" +#include "librlink/RlinkConnect.hpp" + +#include "Rw11Probe.hpp" + +#include "librtools/Rbits.hpp" +#include "Rw11.hpp" + +namespace Retro { + + class Rw11Cntl; // forw decl to avoid circular incl + + class Rw11Cpu : public Rbits, private boost::noncopyable { + public: + typedef std::map> cmap_t; + typedef cmap_t::iterator cmap_it_t; + typedef cmap_t::const_iterator cmap_cit_t; + typedef cmap_t::value_type cmap_val_t; + + explicit Rw11Cpu(const std::string& type); + virtual ~Rw11Cpu(); + + void Setup(Rw11* pw11); + Rw11& W11() const; + RlinkServer& Server() const; + RlinkConnect& Connect() const; + RlogFile& LogFile() const; + + const std::string& Type() const; + size_t Index() const; + uint16_t Base() const; + + void AddCntl(const boost::shared_ptr& spcntl); + bool TestCntl(const std::string& name) const; + void ListCntl(std::vector& list) const; + Rw11Cntl& Cntl(const std::string& name) const; + + void Start(); + + std::string NextCntlName(const std::string& base) const; + + int AddIbrb(RlinkCommandList& clist, uint16_t ibaddr); + int AddRibr(RlinkCommandList& clist, uint16_t ibaddr); + int AddWibr(RlinkCommandList& clist, uint16_t ibaddr, + uint16_t data); + + bool MemRead(uint16_t addr, std::vector& data, + size_t nword, RerrMsg& emsg); + bool MemWrite(uint16_t addr, const std::vector& data, + RerrMsg& emsg); + + bool ProbeCntl(Rw11Probe& dsc); + + bool LoadAbs(const std::string& fname, RerrMsg& emsg, + bool trace=false); + bool Boot(const std::string& uname, RerrMsg& emsg); + + void SetCpuGoUp(); + void SetCpuGoDown(uint16_t stat); + double WaitCpuGoDown(double tout); + bool CpuGo() const; + uint16_t CpuStat() const; + + void W11AttnHandler(); + + const Rstats& Stats() const; + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // some constants (also defined in cpp) + static const uint16_t kCp_addr_conf = 0x0000; //!< + static const uint16_t kCp_addr_cntl = 0x0001; //!< + static const uint16_t kCp_addr_stat = 0x0002; //!< + static const uint16_t kCp_addr_psw = 0x0003; //!< + static const uint16_t kCp_addr_al = 0x0004; //!< + static const uint16_t kCp_addr_ah = 0x0005; //!< + static const uint16_t kCp_addr_mem = 0x0006; //!< + static const uint16_t kCp_addr_memi = 0x0007; //!< + static const uint16_t kCp_addr_r0 = 0x0008; //!< + static const uint16_t kCp_addr_pc = 0x000f; //!< + static const uint16_t kCp_addr_ibrb = 0x0010; //!< + static const uint16_t kCp_addr_ibr = 0x0080; //!< + + static const uint16_t kCp_func_noop = 0x0000; //!< + static const uint16_t kCp_func_start = 0x0001; //!< + static const uint16_t kCp_func_stop = 0x0002; //!< + static const uint16_t kCp_func_cont = 0x0003; //!< + static const uint16_t kCp_func_step = 0x0004; //!< + static const uint16_t kCp_func_reset = 0x000f; //!< + + static const uint16_t kCp_stat_m_cpurust = 0x00f0; //!< + static const uint16_t kCp_stat_v_cpurust = 4; //!< + static const uint16_t kCp_stat_b_cpurust = 0x000f; //!< + static const uint16_t kCp_stat_m_cpuhalt = kWBit03; //!< + static const uint16_t kCp_stat_m_cpugo = kWBit02; //!< + static const uint16_t kCp_stat_m_cmdmerr = kWBit01; //!< + static const uint16_t kCp_stat_m_cmderr = kWBit00; //!< + + static const uint16_t kCp_cpurust_init = 0x0; //!< cpu in init state + static const uint16_t kCp_cpurust_halt = 0x1; //!< cpu executed HALT + static const uint16_t kCp_cpurust_reset = 0x2; //!< cpu was reset + static const uint16_t kCp_cpurust_stop = 0x3; //!< cpu was stopped + static const uint16_t kCp_cpurust_step = 0x4; //!< cpu was stepped + static const uint16_t kCp_cpurust_susp = 0x5; //!< cpu was suspended + static const uint16_t kCp_cpurust_runs = 0x7; //!< cpu running + static const uint16_t kCp_cpurust_vecfet = 0x8; //!< vector fetch halt + static const uint16_t kCp_cpurust_recrsv = 0x9; //!< rec red-stack halt + static const uint16_t kCp_cpurust_sfail = 0xa; //!< sequencer failure + static const uint16_t kCp_cpurust_vfail = 0xb; //!< vmbox failure + + private: + Rw11Cpu() {} //!< default ctor blocker + + protected: + Rw11* fpW11; + std::string fType; + size_t fIndex; + uint16_t fBase; + bool fCpuGo; + uint16_t fCpuStat; + boost::mutex fCpuGoMutex; + boost::condition_variable fCpuGoCond; + cmap_t fCntlMap; //!< name->cntl map + Rstats fStats; //!< statistics + }; + +} // end namespace Retro + +#include "Rw11Cpu.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Cpu.ipp b/tools/src/librw11/Rw11Cpu.ipp new file mode 100644 index 00000000..6728e90a --- /dev/null +++ b/tools/src/librw11/Rw11Cpu.ipp @@ -0,0 +1,110 @@ +// $Id: Rw11Cpu.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-12 504 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Cpu.ipp 502 2013-04-02 19:29:30Z mu./librwxxtpp/Rwxxtpp_Init.cpp +eller $ + \brief Implemenation (inline) of Rw11Cpu. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11& Rw11Cpu::W11() const +{ + return *fpW11; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& Rw11Cpu::Server() const +{ + return fpW11->Server(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& Rw11Cpu::Connect() const +{ + return fpW11->Connect(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& Rw11Cpu::LogFile() const +{ + return fpW11->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& Rw11Cpu::Type() const +{ + return fType; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t Rw11Cpu::Index() const +{ + return fIndex; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint16_t Rw11Cpu::Base() const +{ + return fBase; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline uint16_t Rw11Cpu::CpuStat() const +{ + return fCpuStat; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool Rw11Cpu::CpuGo() const +{ + return fCpuGo; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rstats& Rw11Cpu::Stats() const +{ + return fStats; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11CpuW11a.cpp b/tools/src/librw11/Rw11CpuW11a.cpp new file mode 100644 index 00000000..0dce12e6 --- /dev/null +++ b/tools/src/librw11/Rw11CpuW11a.cpp @@ -0,0 +1,74 @@ +// $Id: Rw11CpuW11a.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11CpuW11a.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11CpuW11a. +*/ + +#include "librtools/RosFill.hpp" + +#include "Rw11CpuW11a.hpp" + +using namespace std; + +/*! + \class Retro::Rw11CpuW11a + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11CpuW11a::Rw11CpuW11a() + : Rw11Cpu("w11a") +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11CpuW11a::~Rw11CpuW11a() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11CpuW11a::Setup(size_t ind, uint16_t base) +{ + fIndex = ind; + fBase = base; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11CpuW11a::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11CpuW11a @ " << this << endl; + Rw11Cpu::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11CpuW11a.hpp b/tools/src/librw11/Rw11CpuW11a.hpp new file mode 100644 index 00000000..aa863363 --- /dev/null +++ b/tools/src/librw11/Rw11CpuW11a.hpp @@ -0,0 +1,51 @@ +// $Id: Rw11CpuW11a.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11CpuW11a.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11CpuW11a. +*/ + +#ifndef included_Retro_Rw11CpuW11a +#define included_Retro_Rw11CpuW11a 1 + +#include "Rw11Cpu.hpp" + +namespace Retro { + + class Rw11CpuW11a : public Rw11Cpu { + public: + + Rw11CpuW11a(); + ~Rw11CpuW11a(); + + void Setup(size_t ind, uint16_t base); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + }; + +} // end namespace Retro + +//#include "Rw11CpuW11a.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Probe.cpp b/tools/src/librw11/Rw11Probe.cpp new file mode 100644 index 00000000..17e51181 --- /dev/null +++ b/tools/src/librw11/Rw11Probe.cpp @@ -0,0 +1,100 @@ +// $Id: Rw11Probe.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-05 495 1.0 Initial version +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Probe.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of Rw11Probe. +*/ + +#include "librtools/RosFill.hpp" +#include "librtools/RosPrintf.hpp" + +#include "librlink/RlinkServer.hpp" + +#include "Rw11Probe.hpp" + +using namespace std; + +/*! + \class Retro::Rw11Probe + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11Probe::Rw11Probe(uint16_t addr, bool probeint, bool proberem) + : fAddr(addr), + fProbeInt(probeint), + fProbeRem(proberem), + fProbeDone(false), + fFoundInt(false), + fFoundRem(false) +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Probe::Found() const +{ + if (!fProbeDone) return false; + if (fProbeInt && ! fFoundInt) return false; + if (fProbeRem && ! fFoundRem) return false; + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +char Rw11Probe::IndicatorInt() const +{ + if (!fProbeDone) return '?'; + if (!fProbeInt) return '-'; + return fFoundInt ? 'y' : 'n'; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +char Rw11Probe::IndicatorRem() const +{ + if (!fProbeDone) return '?'; + if (!fProbeRem) return '-'; + return fFoundRem ? 'y' : 'n'; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Probe::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11Probe @ " << this << endl; + + os << bl << " fAddr: " << RosPrintf(fAddr,"o0",6) << endl; + os << bl << " fProbeInt,Rem: " << fProbeInt << ", " << fProbeInt<< endl; + os << bl << " fProbeDone: " << fProbeDone << endl; + os << bl << " fFoundInt,Rem " << fFoundInt << ", " << fFoundInt<< endl; + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Probe.hpp b/tools/src/librw11/Rw11Probe.hpp new file mode 100644 index 00000000..c7beb958 --- /dev/null +++ b/tools/src/librw11/Rw11Probe.hpp @@ -0,0 +1,54 @@ +// $Id: Rw11Probe.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-05 495 1.0 Initial version +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11Probe.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11Probe. +*/ + +#ifndef included_Retro_Rw11Probe +#define included_Retro_Rw11Probe 1 + +namespace Retro { + + struct Rw11Probe { + uint16_t fAddr; + bool fProbeInt; + bool fProbeRem; + bool fProbeDone; + bool fFoundInt; + bool fFoundRem; + + explicit Rw11Probe(uint16_t addr = 0, bool probeint = false, + bool proberem = false); + + bool Found() const; + + char IndicatorInt() const; + char IndicatorRem() const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + }; + +} // end namespace Retro + +//#include "Rw11Probe.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Unit.cpp b/tools/src/librw11/Rw11Unit.cpp new file mode 100644 index 00000000..f924b0c9 --- /dev/null +++ b/tools/src/librw11/Rw11Unit.cpp @@ -0,0 +1,97 @@ +// $Id: Rw11Unit.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Unit.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of Rw11Unit. +*/ + +#include "librtools/RosFill.hpp" + +#include "Rw11Unit.hpp" + +using namespace std; + +/*! + \class Retro::Rw11Unit + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +Rw11Unit::Rw11Unit(Rw11Cntl* pcntl, size_t index) + : fpCntlBase(pcntl), + fIndex(index), + fStats() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11Unit::~Rw11Unit() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11Unit::Attach(const std::string& url, RerrMsg& emsg) +{ + emsg.Init("Rw11Unit::Attach","attach not available for this device type"); + return false; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Unit::Detach() +{ + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Unit::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11Unit @ " << this << endl; + + os << bl << " fIndex: " << fIndex << endl; + fStats.Dump(os, ind+2, "fStats: "); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Unit::AttachSetup() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Unit::DetachCleanup() +{} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Unit.hpp b/tools/src/librw11/Rw11Unit.hpp new file mode 100644 index 00000000..06c14f71 --- /dev/null +++ b/tools/src/librw11/Rw11Unit.hpp @@ -0,0 +1,85 @@ +// $Id: Rw11Unit.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11Unit.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11Unit. +*/ + +#ifndef included_Retro_Rw11Unit +#define included_Retro_Rw11Unit 1 + +#include "boost/utility.hpp" + +#include "librtools/Rstats.hpp" +#include "librtools/RerrMsg.hpp" +#include "librlink/RlinkServer.hpp" + +#include "librtools/Rbits.hpp" +#include "Rw11Cntl.hpp" + +namespace Retro { + + class Rw11Unit : public Rbits, private boost::noncopyable { + public: + + Rw11Unit(Rw11Cntl* pcntl, size_t index); + virtual ~Rw11Unit(); + + size_t Index() const; + std::string Name() const; + + Rw11Cntl& CntlBase() const; + Rw11Cpu& Cpu() const; + Rw11& W11() const; + RlinkServer& Server() const; + RlinkConnect& Connect() const; + RlogFile& LogFile() const; + + virtual bool Attach(const std::string& url, RerrMsg& emsg); + virtual void Detach(); + + const Rstats& Stats() const; + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices + enum stats { + kDimStat = 0 + }; + + protected: + virtual void AttachSetup(); + virtual void DetachCleanup(); + + private: + Rw11Unit() {} //!< default ctor blocker + + protected: + Rw11Cntl* fpCntlBase; //!< plain Rw11Cntl ptr + size_t fIndex; //!< unit number + Rstats fStats; //!< statistics + }; + +} // end namespace Retro + +#include "Rw11Unit.ipp" + +#endif diff --git a/tools/src/librw11/Rw11Unit.ipp b/tools/src/librw11/Rw11Unit.ipp new file mode 100644 index 00000000..dcc7d3d5 --- /dev/null +++ b/tools/src/librw11/Rw11Unit.ipp @@ -0,0 +1,101 @@ +// $Id: Rw11Unit.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Unit.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of Rw11Unit. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline size_t Rw11Unit::Index() const +{ + return fIndex; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline std::string Rw11Unit::Name() const +{ + return fpCntlBase->UnitName(fIndex); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Cntl& Rw11Unit::CntlBase() const +{ + return *fpCntlBase; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Cpu& Rw11Unit::Cpu() const +{ + return fpCntlBase->Cpu(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11& Rw11Unit::W11() const +{ + return fpCntlBase->W11(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& Rw11Unit::Server() const +{ + return fpCntlBase->Server(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& Rw11Unit::Connect() const +{ + return fpCntlBase->Connect(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& Rw11Unit::LogFile() const +{ + return fpCntlBase->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rstats& Rw11Unit::Stats() const +{ + return fStats; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitBase.hpp b/tools/src/librw11/Rw11UnitBase.hpp new file mode 100644 index 00000000..ade2f057 --- /dev/null +++ b/tools/src/librw11/Rw11UnitBase.hpp @@ -0,0 +1,61 @@ +// $Id: Rw11UnitBase.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-14 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11UnitBase.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11UnitBase. +*/ + +#ifndef included_Retro_Rw11UnitBase +#define included_Retro_Rw11UnitBase 1 + +#include "boost/scoped_ptr.hpp" + +#include "Rw11Unit.hpp" + +namespace Retro { + + template + class Rw11UnitBase : public Rw11Unit { + public: + + Rw11UnitBase(TC* pcntl, size_t index); + ~Rw11UnitBase(); + + TC& Cntl() const; + TV* Virt() const; + + virtual bool Attach(const std::string& url, RerrMsg& emsg); + virtual void Detach(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + TC* fpCntl; + boost::scoped_ptr fpVirt; + + }; + +} // end namespace Retro + +#include "Rw11UnitBase.ipp" + +#endif diff --git a/tools/src/librw11/Rw11UnitBase.ipp b/tools/src/librw11/Rw11UnitBase.ipp new file mode 100644 index 00000000..2a0340a5 --- /dev/null +++ b/tools/src/librw11/Rw11UnitBase.ipp @@ -0,0 +1,123 @@ +// $Id: Rw11UnitBase.ipp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitBase.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of Rw11UnitBase. +*/ + +#include "boost/thread/locks.hpp" + +#include "librtools/RosFill.hpp" + +#include "Rw11CntlBase.hpp" +#include "Rw11UnitBase.hpp" + +/*! + \class Retro::Rw11UnitBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +Rw11UnitBase::Rw11UnitBase(TC* pcntl, size_t index) + : Rw11Unit(index), + fpCntl(pcntl), + fpVirt() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +template +Rw11UnitBase::~Rw11UnitBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TC& Rw11UnitBase::Cntl() const +{ + return *fpCntl; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TV* Rw11UnitBase::Virt() const +{ + return fpVirt.get(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline bool Rw11UnitBase::Attach(const std::string& url, RerrMsg& emsg) +{ + // synchronize with server thread + boost::lock_guard lock(Cntl().Connect()); + if (fpVirt) DetachCleanup(); + fpVirt.reset(TV::New(url, emsg)); + if (fpVirt) AttachSetup(); + return fpVirt; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline void Rw11UnitBase::Detach() +{ + // synchronize with server thread + boost::lock_guard lock(Cntl().Connect()); + if (fpVirt) DetachCleanup(); + fpVirt.reset(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +void Rw11UnitBase::Dump(std::ostream& os, int ind, + const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11UnitBase @ " << this << std::endl; + os << bl << " fpCntl: " << fpCntl << std::endl; + if (fpVirt) { + fpVirt->Dump(os, ind+2, "*fpVirt: "); + } else { + os << bl << " fpVirt: " << fpVirt.get() << std::endl; + } + + Rw11Unit::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitDL11.cpp b/tools/src/librw11/Rw11UnitDL11.cpp new file mode 100644 index 00000000..469c2a8d --- /dev/null +++ b/tools/src/librw11/Rw11UnitDL11.cpp @@ -0,0 +1,67 @@ +// $Id: Rw11UnitDL11.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitDL11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11UnitDL11. +*/ + +#include "boost/bind.hpp" + +#include "librtools/RosFill.hpp" +#include "Rw11CntlDL11.hpp" + +#include "Rw11UnitDL11.hpp" + +using namespace std; + +/*! + \class Retro::Rw11UnitDL11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +Rw11UnitDL11::Rw11UnitDL11(Rw11CntlDL11* pcntl, size_t index) + : Rw11UnitTermBase(pcntl, index) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11UnitDL11::~Rw11UnitDL11() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11UnitDL11::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11UnitDL11 @ " << this << endl; + Rw11UnitTermBase::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitDL11.hpp b/tools/src/librw11/Rw11UnitDL11.hpp new file mode 100644 index 00000000..5285e86e --- /dev/null +++ b/tools/src/librw11/Rw11UnitDL11.hpp @@ -0,0 +1,54 @@ +// $Id: Rw11UnitDL11.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11UnitDL11.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11UnitDL11. +*/ + +#ifndef included_Retro_Rw11UnitDL11 +#define included_Retro_Rw11UnitDL11 1 + +#include "Rw11VirtTerm.hpp" + +#include "Rw11UnitTermBase.hpp" + +namespace Retro { + + class Rw11CntlDL11; // forw decl to avoid circular incl + + class Rw11UnitDL11 : public Rw11UnitTermBase { + public: + + Rw11UnitDL11(Rw11CntlDL11* pcntl, size_t index); + ~Rw11UnitDL11(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + + }; + +} // end namespace Retro + +//#include "Rw11UnitDL11.ipp" + +#endif diff --git a/tools/src/librw11/Rw11UnitTerm.cpp b/tools/src/librw11/Rw11UnitTerm.cpp new file mode 100644 index 00000000..33cc8f9e --- /dev/null +++ b/tools/src/librw11/Rw11UnitTerm.cpp @@ -0,0 +1,197 @@ +// $Id: Rw11UnitTerm.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-13 504 1.0 Initial version +// 2013-02-19 490 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitTerm.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11UnitTerm. +*/ + +#include "boost/thread/locks.hpp" +#include "boost/bind.hpp" + +#include "librtools/RosPrintf.hpp" + +#include "Rw11UnitTerm.hpp" + +using namespace std; + +/*! + \class Retro::Rw11UnitTerm + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +Rw11UnitTerm::Rw11UnitTerm(Rw11Cntl* pcntl, size_t index) + : Rw11UnitVirt(pcntl, index), + fRcv7bit(false), + fRcvQueue() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11UnitTerm::~Rw11UnitTerm() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +const std::string& Rw11UnitTerm::ChannelId() const +{ + if (fpVirt) return fpVirt->ChannelId(); + static string nil; + return nil; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11UnitTerm::RcvQueueEmpty() +{ + return fRcvQueue.empty(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +size_t Rw11UnitTerm::RcvQueueSize() +{ + return fRcvQueue.size(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +uint8_t Rw11UnitTerm::RcvNext() +{ + if (RcvQueueEmpty()) return 0; + uint8_t ochr = fRcvQueue.front(); + fRcvQueue.pop_front(); + return ochr; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +size_t Rw11UnitTerm::Rcv(uint8_t* buf, size_t count) +{ + uint8_t* p = buf; + for (size_t i=0; iSnd(buf, count, emsg); + // FIXME_code: handler errors + } else { + for (size_t i=0; i lock(Connect()); + + bool que_empty_old = fRcvQueue.empty(); + for (size_t i=0; i lock(Connect()); + size_t size = fRcvQueue.size(); + os << bl << " fRcvQueue.size: " << fRcvQueue.size() << endl; + if (size > 0) { + os << bl << " fRcvQueue: \""; + size_t ocount = 0; + for (size_t i=0; i= 50) { + os << "..."; + break; + } + uint8_t byt = fRcvQueue[i]; + if (byt >= 040 && byt <= 0176) { + os << char(byt); + ocount += 1; + } else { + os << "<" << RosPrintf(byt,"o0",3) << ">"; + ocount += 5; + } + } + os << "\"" << endl; + } + } + + Rw11UnitVirt::Dump(os, ind, " ^"); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11UnitTerm::AttachSetup() +{ + fpVirt->SetupRcvCallback(boost::bind(&Rw11UnitTerm::RcvCallback, + this, _1, _2)); + return; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitTerm.hpp b/tools/src/librw11/Rw11UnitTerm.hpp new file mode 100644 index 00000000..edbc0d5f --- /dev/null +++ b/tools/src/librw11/Rw11UnitTerm.hpp @@ -0,0 +1,72 @@ +// $Id: Rw11UnitTerm.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-13 504 1.0 Initial version +// 2013-02-19 490 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11UnitTerm.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11UnitTerm. +*/ + +#ifndef included_Retro_Rw11UnitTerm +#define included_Retro_Rw11UnitTerm 1 + +#include + +#include "Rw11VirtTerm.hpp" + +#include "Rw11UnitVirt.hpp" + +namespace Retro { + + class Rw11UnitTerm : public Rw11UnitVirt { + public: + Rw11UnitTerm(Rw11Cntl* pcntl, size_t index); + ~Rw11UnitTerm(); + + const std::string& ChannelId() const; + + void SetRcv7bit(bool rcv7bit); + bool Rcv7bit() const; + + virtual bool RcvQueueEmpty(); + virtual size_t RcvQueueSize(); + virtual uint8_t RcvNext(); + virtual size_t Rcv(uint8_t* buf, size_t count); + + virtual bool Snd(const uint8_t* buf, size_t count); + + virtual bool RcvCallback(const uint8_t* buf, size_t count); + virtual void WakeupCntl(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + virtual void AttachSetup(); + + protected: + bool fRcv7bit; // fRcvQueue; // +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-13 504 1.0 Initial version +// 2013-03-02 493 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitTerm.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of Rw11UnitTerm. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void Rw11UnitTerm::SetRcv7bit(bool rcv7bit) +{ + fRcv7bit = rcv7bit; + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline bool Rw11UnitTerm::Rcv7bit() const +{ + return fRcv7bit; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitTermBase.hpp b/tools/src/librw11/Rw11UnitTermBase.hpp new file mode 100644 index 00000000..201a923a --- /dev/null +++ b/tools/src/librw11/Rw11UnitTermBase.hpp @@ -0,0 +1,55 @@ +// $Id: Rw11UnitTermBase.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-22 490 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11UnitTermBase.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11UnitTermBase. +*/ + +#ifndef included_Retro_Rw11UnitTermBase +#define included_Retro_Rw11UnitTermBase 1 + +#include "Rw11UnitTerm.hpp" + +namespace Retro { + + template + class Rw11UnitTermBase : public Rw11UnitTerm { + public: + + Rw11UnitTermBase(TC* pcntl, size_t index); + ~Rw11UnitTermBase(); + + TC& Cntl() const; + + virtual void WakeupCntl(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + TC* fpCntl; + }; + +} // end namespace Retro + +#include "Rw11UnitTermBase.ipp" + +#endif diff --git a/tools/src/librw11/Rw11UnitTermBase.ipp b/tools/src/librw11/Rw11UnitTermBase.ipp new file mode 100644 index 00000000..0d569497 --- /dev/null +++ b/tools/src/librw11/Rw11UnitTermBase.ipp @@ -0,0 +1,85 @@ +// $Id: Rw11UnitTermBase.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-22 490 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitTermBase.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of Rw11UnitTermBase. +*/ + +#include "Rw11UnitTermBase.hpp" + +/*! + \class Retro::Rw11UnitTermBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +template +Rw11UnitTermBase::Rw11UnitTermBase(TC* pcntl, size_t index) + : Rw11UnitTerm(pcntl, index), + fpCntl(pcntl) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +template +Rw11UnitTermBase::~Rw11UnitTermBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TC& Rw11UnitTermBase::Cntl() const +{ + return *fpCntl; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline void Rw11UnitTermBase::WakeupCntl() +{ + fpCntl->Wakeup(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +void Rw11UnitTermBase::Dump(std::ostream& os, int ind, + const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11UnitTermBase @ " << this << std::endl; + os << bl << " fpCntl: " << fpCntl << std::endl; + Rw11UnitTerm::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11UnitVirt.hpp b/tools/src/librw11/Rw11UnitVirt.hpp new file mode 100644 index 00000000..b948d85e --- /dev/null +++ b/tools/src/librw11/Rw11UnitVirt.hpp @@ -0,0 +1,59 @@ +// $Id: Rw11UnitVirt.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-22 490 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11UnitVirt.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11UnitVirt. +*/ + +#ifndef included_Retro_Rw11UnitVirt +#define included_Retro_Rw11UnitVirt 1 + +#include "boost/scoped_ptr.hpp" + +#include "Rw11Unit.hpp" + +namespace Retro { + + template + class Rw11UnitVirt : public Rw11Unit { + public: + + Rw11UnitVirt(Rw11Cntl* pcntl, size_t index); + ~Rw11UnitVirt(); + + TV* Virt() const; + + virtual bool Attach(const std::string& url, RerrMsg& emsg); + virtual void Detach(); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + boost::scoped_ptr fpVirt; + + }; + +} // end namespace Retro + +#include "Rw11UnitVirt.ipp" + +#endif diff --git a/tools/src/librw11/Rw11UnitVirt.ipp b/tools/src/librw11/Rw11UnitVirt.ipp new file mode 100644 index 00000000..f192ded4 --- /dev/null +++ b/tools/src/librw11/Rw11UnitVirt.ipp @@ -0,0 +1,111 @@ +// $Id: Rw11UnitVirt.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-05 483 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11UnitVirt.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of Rw11UnitVirt. +*/ + +#include "boost/thread/locks.hpp" + +#include "librtools/RosFill.hpp" + +#include "Rw11UnitVirt.hpp" + +/*! + \class Retro::Rw11UnitVirt + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +template +Rw11UnitVirt::Rw11UnitVirt(Rw11Cntl* pcntl, size_t index) + : Rw11Unit(pcntl, index), + fpVirt() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +template +Rw11UnitVirt::~Rw11UnitVirt() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TV* Rw11UnitVirt::Virt() const +{ + return fpVirt.get(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline bool Rw11UnitVirt::Attach(const std::string& url, RerrMsg& emsg) +{ + // synchronize with server thread + boost::lock_guard lock(Connect()); + if (fpVirt) DetachCleanup(); + fpVirt.reset(TV::New(url, this, emsg)); + if (fpVirt) AttachSetup(); + return fpVirt; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline void Rw11UnitVirt::Detach() +{ + // synchronize with server thread + boost::lock_guard lock(Connect()); + if (fpVirt) DetachCleanup(); + fpVirt.reset(); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +void Rw11UnitVirt::Dump(std::ostream& os, int ind, + const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11UnitVirt @ " << this << std::endl; + if (fpVirt) { + fpVirt->Dump(os, ind+2, "*fpVirt: "); + } else { + os << bl << " fpVirt: " << fpVirt.get() << std::endl; + } + + Rw11Unit::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Virt.cpp b/tools/src/librw11/Rw11Virt.cpp new file mode 100644 index 00000000..0347aac5 --- /dev/null +++ b/tools/src/librw11/Rw11Virt.cpp @@ -0,0 +1,70 @@ +// $Id: Rw11Virt.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Virt.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of Rw11Virt. +*/ + +#include "librtools/RosFill.hpp" + +#include "Rw11Virt.hpp" + +using namespace std; + +/*! + \class Retro::Rw11Virt + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11Virt::Rw11Virt(Rw11Unit* punit) + : fpUnit(punit), + fUrl(), + fStats() +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11Virt::~Rw11Virt() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11Virt::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11Virt @ " << this << endl; + + os << bl << " fpUnit: " << fpUnit << endl; + fUrl.Dump(os, ind+2, "fUrl: "); + fStats.Dump(os, ind+2, "fStats: "); + return; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11Virt.hpp b/tools/src/librw11/Rw11Virt.hpp new file mode 100644 index 00000000..7dd188d4 --- /dev/null +++ b/tools/src/librw11/Rw11Virt.hpp @@ -0,0 +1,75 @@ +// $Id: Rw11Virt.hpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11Virt.hpp 495 2013-03-06 17:13:48Z mueller $ + \brief Declaration of class Rw11Virt. +*/ + +#ifndef included_Retro_Rw11Virt +#define included_Retro_Rw11Virt 1 + +#include +#include + +#include "boost/utility.hpp" + +#include "librtools/RparseUrl.hpp" +#include "librtools/RerrMsg.hpp" +#include "librtools/Rstats.hpp" +#include "Rw11Unit.hpp" + +namespace Retro { + + class Rw11Virt : private boost::noncopyable { + public: + explicit Rw11Virt(Rw11Unit* punit); + virtual ~Rw11Virt(); + + Rw11Unit& Unit() const; + Rw11Cntl& Cntl() const; + Rw11Cpu& Cpu() const; + Rw11& W11() const; + RlinkServer& Server() const; + RlogFile& LogFile() const; + + virtual bool Open(const std::string& url, RerrMsg& emsg) = 0; + + const Rstats& Stats() const; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices + enum stats { + kDimStat = 0 + }; + + protected: + Rw11Unit* fpUnit; // +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-16 489 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11Virt.ipp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation (inline) of Rw11Virt. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Unit& Rw11Virt::Unit() const +{ + return *fpUnit; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Cntl& Rw11Virt::Cntl() const +{ + return fpUnit->CntlBase(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11Cpu& Rw11Virt::Cpu() const +{ + return fpUnit->Cpu(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline Rw11& Rw11Virt::W11() const +{ + return fpUnit->W11(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& Rw11Virt::Server() const +{ + return fpUnit->Server(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlogFile& Rw11Virt::LogFile() const +{ + return fpUnit->LogFile(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const Rstats& Rw11Virt::Stats() const +{ + return fStats; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtTerm.cpp b/tools/src/librw11/Rw11VirtTerm.cpp new file mode 100644 index 00000000..8d8d7a13 --- /dev/null +++ b/tools/src/librw11/Rw11VirtTerm.cpp @@ -0,0 +1,102 @@ +// $Id: Rw11VirtTerm.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtTerm.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11VirtTerm. +*/ +#include + +#include "librtools/RparseUrl.hpp" +#include "librtools/RosFill.hpp" +#include "Rw11VirtTermPty.hpp" +#include "Rw11VirtTermTcp.hpp" + +#include "Rw11VirtTerm.hpp" + +using namespace std; + +/*! + \class Retro::Rw11VirtTerm + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11VirtTerm::Rw11VirtTerm(Rw11Unit* punit) + : Rw11Virt(punit), + fChannelId(), + fRcvCb() +{ + fStats.Define(kStatNVTRcvPoll, "NVTRcvPoll", "RcvPollHandler() calls"); + fStats.Define(kStatNVTSnd, "NVTSnd", "Snd() calls"); + fStats.Define(kStatNVTRcvByt, "NVTRcvByt", "bytes received"); + fStats.Define(kStatNVTSndByt, "NVTSndByt", "bytes send"); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11VirtTerm::~Rw11VirtTerm() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Rw11VirtTerm* Rw11VirtTerm::New(const std::string& url, Rw11Unit* punit, + RerrMsg& emsg) +{ + string scheme = RparseUrl::FindScheme(url, "tcp"); + unique_ptr p; + + if (scheme == "pty") { // scheme -> pty: + p.reset(new Rw11VirtTermPty(punit)); + if (p->Open(url, emsg)) return p.release(); + + } else if (scheme == "tcp") { // scheme -> tcp: + p.reset(new Rw11VirtTermTcp(punit)); + if (p->Open(url, emsg)) return p.release(); + + } else { // scheme -> no match + emsg.Init("Rw11VirtTerm::New", string("Scheme '") + scheme + + "' is not supported"); + + } + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtTerm::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11VirtTerm @ " << this << endl; + + os << bl << " fChannelId: " << fChannelId << endl; + Rw11Virt::Dump(os, ind, " ^"); + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtTerm.hpp b/tools/src/librw11/Rw11VirtTerm.hpp new file mode 100644 index 00000000..abcf9633 --- /dev/null +++ b/tools/src/librw11/Rw11VirtTerm.hpp @@ -0,0 +1,70 @@ +// $Id: Rw11VirtTerm.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtTerm.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11VirtTerm. +*/ + +#ifndef included_Retro_Rw11VirtTerm +#define included_Retro_Rw11VirtTerm 1 + +#include "boost/function.hpp" + +#include "Rw11Virt.hpp" + +namespace Retro { + + class Rw11VirtTerm : public Rw11Virt { + public: + typedef boost::function rcvcbfo_t; + + explicit Rw11VirtTerm(Rw11Unit* punit); + ~Rw11VirtTerm(); + + virtual const std::string& ChannelId() const; + + void SetupRcvCallback(const rcvcbfo_t& rcvcbfo); + virtual bool Snd(const uint8_t* data, size_t count, RerrMsg& emsg) = 0; + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + static Rw11VirtTerm* New(const std::string& url, Rw11Unit* punit, + RerrMsg& emsg); + + // statistics counter indices + enum stats { + kStatNVTRcvPoll = Rw11Virt::kDimStat, + kStatNVTSnd, + kStatNVTRcvByt, + kStatNVTSndByt, + kDimStat + }; + + protected: + std::string fChannelId; //!< channel id + rcvcbfo_t fRcvCb; //!< receive callback fobj + }; + +} // end namespace Retro + +#include "Rw11VirtTerm.ipp" + +#endif diff --git a/tools/src/librw11/Rw11VirtTerm.ipp b/tools/src/librw11/Rw11VirtTerm.ipp new file mode 100644 index 00000000..894f821c --- /dev/null +++ b/tools/src/librw11/Rw11VirtTerm.ipp @@ -0,0 +1,47 @@ +// $Id: Rw11VirtTerm.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-19 490 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtTerm.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of Rw11VirtTerm. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline const std::string& Rw11VirtTerm::ChannelId() const +{ + return fChannelId; +} + + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline void Rw11VirtTerm::SetupRcvCallback(const rcvcbfo_t& rcvcbfo) +{ + fRcvCb = rcvcbfo; + return; +} + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtTermPty.cpp b/tools/src/librw11/Rw11VirtTermPty.cpp new file mode 100644 index 00000000..d9f84462 --- /dev/null +++ b/tools/src/librw11/Rw11VirtTermPty.cpp @@ -0,0 +1,157 @@ +// $Id: Rw11VirtTermPty.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-24 492 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtTermPty.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11VirtTermPty. +*/ +#define _XOPEN_SOURCE 600 + +#include +#include +#include +#include + +#include "boost/bind.hpp" + +#include "librtools/RosFill.hpp" +#include "Rw11VirtTermPty.hpp" + +using namespace std; + +/*! + \class Retro::Rw11VirtTermPty + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11VirtTermPty::Rw11VirtTermPty(Rw11Unit* punit) + : Rw11VirtTerm(punit), + fFd(-1) +{} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11VirtTermPty::~Rw11VirtTermPty() +{ + if (fFd>=2) { + Server().RemovePollHandler(fFd); + close(fFd); + } +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtTermPty::Open(const std::string& url, RerrMsg& emsg) +{ + int fd = posix_openpt(O_RDWR); + if (fd < 0) { + emsg.InitErrno("Rw11VirtTermPty::Open", "posix_openpt() failed: ", errno); + return false; + } + + int irc = grantpt(fd); + if (irc < 0) { + emsg.InitErrno("Rw11VirtTermPty::Open", "grantpt() failed: ", errno); + close(fd); + return false; + } + + irc = unlockpt(fd); + if (irc < 0) { + emsg.InitErrno("Rw11VirtTermPty::Open", "unlockpt() failed: ", errno); + close(fd); + return false; + } + + char* pname = ptsname(fd); + if (pname == 0) { + emsg.InitErrno("Rw11VirtTermPty::Open", "ptsname() failed: ", errno); + close(fd); + return false; + } + + fFd = fd; + fChannelId = pname; + + Server().AddPollHandler(boost::bind(&Rw11VirtTermPty::RcvPollHandler, + this, _1), + fFd, POLLIN); + + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtTermPty::Snd(const uint8_t* data, size_t count, RerrMsg& emsg) +{ + fStats.Inc(kStatNVTSnd); + ssize_t irc = write(fFd, data, count); + if (irc != ssize_t(count)) { + emsg.InitErrno("Rw11VirtTermPty::Snd", "write() failed: ", errno); + return false; + } + fStats.Inc(kStatNVTSndByt, double(count)); + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11VirtTermPty::RcvPollHandler(const pollfd& pfd) +{ + fStats.Inc(kStatNVTRcvPoll); + // bail-out and cancel handler if poll returns an error event + if (pfd.revents & (~pfd.events)) return -1; + + uint8_t buf[1024]; + ssize_t irc = read(fFd, buf, 1024); + + if (irc > 0) { + fRcvCb(buf, size_t(irc)); + fStats.Inc(kStatNVTRcvByt, double(irc)); + } + + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtTermPty::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11VirtTermPty @ " << this << endl; + + os << bl << " fFd: " << fFd << endl; + Rw11VirtTerm::Dump(os, ind+2, ""); + return; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtTermPty.hpp b/tools/src/librw11/Rw11VirtTermPty.hpp new file mode 100644 index 00000000..a5e7d6bc --- /dev/null +++ b/tools/src/librw11/Rw11VirtTermPty.hpp @@ -0,0 +1,59 @@ +// $Id: Rw11VirtTermPty.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-24 492 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11VirtTermPty.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11VirtTermPty. +*/ + +#ifndef included_Retro_Rw11VirtTermPty +#define included_Retro_Rw11VirtTermPty 1 + +#include + +#include "Rw11VirtTerm.hpp" + +namespace Retro { + + class Rw11VirtTermPty : public Rw11VirtTerm { + public: + + explicit Rw11VirtTermPty(Rw11Unit* punit); + ~Rw11VirtTermPty(); + + bool Open(const std::string& url, RerrMsg& emsg); + + virtual bool Snd(const uint8_t* data, size_t count, RerrMsg& emsg); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + protected: + int RcvPollHandler(const pollfd& pfd); + + protected: + int fFd; // +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rw11VirtTermTcp.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rw11VirtTermTcp. +*/ + +#include +#include +#include +#include +#include + +#include + +#include "librtools/RosFill.hpp" +#include "librtools/RlogMsg.hpp" + +#include "Rw11VirtTermTcp.hpp" + +using namespace std; + +/*! + \class Retro::Rw11VirtTermTcp + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +// constants definitions + +const uint8_t Rw11VirtTermTcp::kCode_NULL; +const uint8_t Rw11VirtTermTcp::kCode_LF; +const uint8_t Rw11VirtTermTcp::kCode_CR; +const uint8_t Rw11VirtTermTcp::kCode_ESC; +const uint8_t Rw11VirtTermTcp::kCode_SE; +const uint8_t Rw11VirtTermTcp::kCode_NOP; +const uint8_t Rw11VirtTermTcp::kCode_IP; +const uint8_t Rw11VirtTermTcp::kCode_GA; +const uint8_t Rw11VirtTermTcp::kCode_SB; +const uint8_t Rw11VirtTermTcp::kCode_WILL; +const uint8_t Rw11VirtTermTcp::kCode_WONT; +const uint8_t Rw11VirtTermTcp::kCode_DO; +const uint8_t Rw11VirtTermTcp::kCode_DONT; +const uint8_t Rw11VirtTermTcp::kCode_IAC; + +const uint8_t Rw11VirtTermTcp::kOpt_BIN; +const uint8_t Rw11VirtTermTcp::kOpt_ECHO; +const uint8_t Rw11VirtTermTcp::kOpt_SGA; +const uint8_t Rw11VirtTermTcp::kOpt_TTYP; +const uint8_t Rw11VirtTermTcp::kOpt_LINE; + +//------------------------------------------+----------------------------------- +//! Default constructor + +Rw11VirtTermTcp::Rw11VirtTermTcp(Rw11Unit* punit) + : Rw11VirtTerm(punit), + fFdListen(-1), + fFd(-1), + fState(ts_Closed), + fTcpTrace(false) +{ + fStats.Define(kStatNVTListenPoll , "NVTListenPoll" , + "ListenPollHandler() calls"); + fStats.Define(kStatNVTAccept, "NVTAccept", "socket accepts"); + fStats.Define(kStatNVTRcvRaw, "NVTRcvRaw", "raw bytes received"); + fStats.Define(kStatNVTSndRaw, "NVTSndRaw", "raw bytes send"); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +Rw11VirtTermTcp::~Rw11VirtTermTcp() +{ + if (fFdListen > 2) { + Server().RemovePollHandler(fFdListen); + close(fFdListen); + } + if (fFd > 2) { + Server().RemovePollHandler(fFd); + close(fFd); + } +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtTermTcp::Open(const std::string& url, RerrMsg& emsg) +{ + if (!fUrl.Set(url, "|port=|trace|", emsg)) return false; + if (!(fUrl.FindOpt("port"))) { + emsg.Init("Rw11VirtTermTcp::Open", "port= option not specified"); + return false; + } + + fTcpTrace = fUrl.FindOpt("trace"); + + string port; + fUrl.FindOpt("port",port); + int portno = atoi(port.c_str()); + // FIXME_code: error handling ... + + protoent* pe = getprotobyname("tcp"); + if (pe == 0) { + emsg.Init("Rw11VirtTermTcp::Open","getprotobyname(\"tcp\") failed"); + return false; + } + + int fd = socket(AF_INET, SOCK_STREAM|SOCK_NONBLOCK, pe->p_proto); + if (fd < 0) { + emsg.InitErrno("Rw11VirtTermTcp::Open","socket() failed: ", errno); + return false; + } + + int on = 1; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { + emsg.InitErrno("Rw11VirtTermTcp::Open","setsockop() failed: ", errno); + close(fd); + return false; + } + + sockaddr_in sa; + memset(&sa, 0, sizeof(sa)); + sa.sin_family = AF_INET; + sa.sin_port = htons((unsigned short) portno); + sa.sin_addr.s_addr = htonl(INADDR_ANY); + + // Note: ::bind needed below to avoid collision with std::bind... + if (::bind(fd, (sockaddr*) &sa, sizeof(sa)) < 0) { + emsg.InitErrno("Rw11VirtTermTcp::Open","bind() failed: ", errno); + close(fd); + return false; + } + + if (listen(fd, 1) <0) { + emsg.InitErrno("Rw11VirtTermTcp::Open","listen() failed: ", errno); + close(fd); + return false; + } + + fFdListen = fd; + fChannelId = port; + fState = ts_Listen; + + if (fTcpTrace) { + RlogMsg lmsg(LogFile(),'I'); + lmsg << "TermTcp: listen on " << fChannelId << " for " << Unit().Name(); + } + + Server().AddPollHandler(boost::bind(&Rw11VirtTermTcp::ListenPollHandler, + this, _1), + fFdListen, POLLIN); + + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool Rw11VirtTermTcp::Snd(const uint8_t* data, size_t count, RerrMsg& emsg) +{ + fStats.Inc(kStatNVTSnd); + const uint8_t* pdata = data; + const uint8_t* pdataend = data+count; + + uint8_t obuf[1024]; + while (pdata < pdataend) { + uint8_t* pobuf = obuf; + uint8_t* pobufend = obuf+1024; + while (pdata < pdataend && pobuf < pobufend-1) { + if (*pdata == kCode_IAC) *pobuf++ = kCode_IAC; + *pobuf++ = *pdata++; + } + + int irc = write(fFd, obuf, pobuf-obuf); + if (irc < 0) { + RlogMsg lmsg(LogFile(),'E'); + RerrMsg emsg("Rw11VirtTermTcp::Snd", + string("write() for port ") + fChannelId + + string(" failed: ", errno)); + lmsg << emsg; + } else { + fStats.Inc(kStatNVTSndRaw, double(irc)); + } + } + + fStats.Inc(kStatNVTSndByt, double(count)); + return true; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void Rw11VirtTermTcp::Dump(std::ostream& os, int ind, const char* text) const +{ + RosFill bl(ind); + os << bl << (text?text:"--") << "Rw11VirtTermTcp @ " << this << endl; + + os << bl << " fFdListen: " << fFdListen << endl; + os << bl << " fFd: " << fFd << endl; + const char* t_state = ""; + switch (fState) { + case ts_Closed: t_state = "ts_Closed"; break; + case ts_Listen: t_state = "ts_Listen"; break; + case ts_Stream: t_state = "ts_Stream"; break; + case ts_Iac: t_state = "ts_Iac"; break; + case ts_Cmd: t_state = "ts_Cmd"; break; + case ts_Subneg: t_state = "ts_Subneg"; break; + case ts_Subiac: t_state = "ts_Subiac"; break; + default: t_state = "???"; + } + os << bl << " fState: " << t_state << endl; + os << bl << " fTcpTrace: " << fTcpTrace << endl; + Rw11VirtTerm::Dump(os, ind, " ^"); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11VirtTermTcp::ListenPollHandler(const pollfd& pfd) +{ + // bail-out and cancel handler if poll returns an error event + if (pfd.revents & (~pfd.events)) return -1; + + fFd = accept(fFdListen, NULL, 0); + + if (fFd < 0) { + RlogMsg lmsg(LogFile(),'E'); + RerrMsg emsg("Rw11VirtTermTcp::ListenPollHandler", + string("accept() for port ") + fChannelId + + string(" failed: ", errno)); + lmsg << emsg; + // FIXME_code: proper error handling + return 0; + } + + fStats.Inc(kStatNVTAccept); + + uint8_t buf_1[3] = {kCode_IAC, kCode_WILL, kOpt_LINE}; + uint8_t buf_2[3] = {kCode_IAC, kCode_WILL, kOpt_SGA}; + uint8_t buf_3[3] = {kCode_IAC, kCode_WILL, kOpt_ECHO}; + uint8_t buf_4[3] = {kCode_IAC, kCode_WILL, kOpt_BIN}; + uint8_t buf_5[3] = {kCode_IAC, kCode_DO , kOpt_BIN}; + + int nerr = 0; + + if (write(fFd, buf_1, sizeof(buf_1)) < 0) nerr += 1; + if (write(fFd, buf_2, sizeof(buf_2)) < 0) nerr += 1; + if (write(fFd, buf_3, sizeof(buf_3)) < 0) nerr += 1; + if (write(fFd, buf_4, sizeof(buf_4)) < 0) nerr += 1; + if (write(fFd, buf_5, sizeof(buf_5)) < 0) nerr += 1; + if (nerr==0) { + stringstream msg; + msg << "\r\nconnect on port " << fChannelId + << " for " << Unit().Name() << "\r\n\r\n"; + string str = msg.str(); + if (write(fFd, str.c_str(), str.length()) < 0) nerr += 1; + } + + if (nerr) { + close(fFd); + fFd = -1; + RlogMsg lmsg(LogFile(),'E'); + RerrMsg emsg("Rw11VirtTermTcp::ListenPollHandler", + string("initial write()s for port ") + fChannelId + + string(" failed: ", errno)); + lmsg << emsg; + return 0; + } + + if (fTcpTrace) { + RlogMsg lmsg(LogFile(),'I'); + lmsg << "TermTcp: accept on " << fChannelId << " for " << Unit().Name(); + } + + fState = ts_Stream; + + Server().RemovePollHandler(fFdListen); + Server().AddPollHandler(boost::bind(&Rw11VirtTermTcp::RcvPollHandler, + this, _1), + fFd, POLLIN); + return 0; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int Rw11VirtTermTcp::RcvPollHandler(const pollfd& pfd) +{ + fStats.Inc(kStatNVTRcvPoll); + + int irc = -1; + + if (pfd.revents & POLLIN) { + uint8_t ibuf[1024]; + uint8_t obuf[1024]; + uint8_t* pobuf = obuf; + + irc = read(fFd, ibuf, 1024); + + if (irc < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) return 0; + + if (irc > 0) { + fStats.Inc(kStatNVTRcvRaw, double(irc)); + for (int i=0; i obuf) fRcvCb(obuf, pobuf - obuf); + } + + + if (irc <= 0) { + if (irc < 0) { + RlogMsg lmsg(LogFile(),'E'); + RerrMsg emsg("Rw11VirtTermTcp::ListenPollHandler", + string("read() for port ") + fChannelId + + string(" failed: ", errno)); + lmsg << emsg; + } + if (fTcpTrace) { + RlogMsg lmsg(LogFile(),'I'); + lmsg << "TermTcp: close on " << fChannelId << " for " << Unit().Name(); + } + close(fFd); + fFd = -1; + Server().AddPollHandler(boost::bind(&Rw11VirtTermTcp::ListenPollHandler, + this, _1), + fFdListen, POLLIN); + fState = ts_Listen; + return -1; + } + + return 0; +} + + +} // end namespace Retro diff --git a/tools/src/librw11/Rw11VirtTermTcp.hpp b/tools/src/librw11/Rw11VirtTermTcp.hpp new file mode 100644 index 00000000..3def1269 --- /dev/null +++ b/tools/src/librw11/Rw11VirtTermTcp.hpp @@ -0,0 +1,103 @@ +// $Id: Rw11VirtTermTcp.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-13 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: Rw11VirtTermTcp.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class Rw11VirtTermTcp. +*/ + +#ifndef included_Retro_Rw11VirtTermTcp +#define included_Retro_Rw11VirtTermTcp 1 + +#include "Rw11VirtTerm.hpp" + +namespace Retro { + + class Rw11VirtTermTcp : public Rw11VirtTerm { + public: + + explicit Rw11VirtTermTcp(Rw11Unit* punit); + ~Rw11VirtTermTcp(); + + bool Open(const std::string& url, RerrMsg& emsg); + + virtual bool Snd(const uint8_t* data, size_t count, RerrMsg& emsg); + + virtual void Dump(std::ostream& os, int ind=0, const char* text=0) const; + + // statistics counter indices + enum stats { + kStatNVTListenPoll = Rw11VirtTerm::kDimStat, + kStatNVTAccept, + kStatNVTRcvRaw, + kStatNVTSndRaw, + kDimStat + }; + + protected: + + int ListenPollHandler(const pollfd& pfd); + int RcvPollHandler(const pollfd& pfd); + + // some constants (also defined in cpp) + static const uint8_t kCode_NULL = 0; + static const uint8_t kCode_LF = 10; + static const uint8_t kCode_CR = 13; + static const uint8_t kCode_ESC = 27; + static const uint8_t kCode_SE = 240; + static const uint8_t kCode_NOP = 241; + static const uint8_t kCode_IP = 244; + static const uint8_t kCode_GA = 249; + static const uint8_t kCode_SB = 250; + static const uint8_t kCode_WILL = 251; + static const uint8_t kCode_WONT = 252; + static const uint8_t kCode_DO = 253; + static const uint8_t kCode_DONT = 254; + static const uint8_t kCode_IAC = 255; + + static const uint8_t kOpt_BIN = 0; + static const uint8_t kOpt_ECHO = 1; + static const uint8_t kOpt_SGA = 3; + static const uint8_t kOpt_TTYP = 24; + static const uint8_t kOpt_LINE = 34; + + enum telnet_state { + ts_Closed = 0, + ts_Listen, + ts_Stream, + ts_Iac, + ts_Cmd, + ts_Subneg, + ts_Subiac + }; + + protected: + int fFdListen; + int fFd; + telnet_state fState; + bool fTcpTrace; + }; + +} // end namespace Retro + +//#include "Rw11VirtTermTcp.ipp" + +#endif diff --git a/tools/src/librwxxtpp/.cvsignore b/tools/src/librwxxtpp/.cvsignore new file mode 100644 index 00000000..49858186 --- /dev/null +++ b/tools/src/librwxxtpp/.cvsignore @@ -0,0 +1 @@ +*.dep diff --git a/tools/src/librwxxtpp/Makefile b/tools/src/librwxxtpp/Makefile new file mode 100644 index 00000000..9451e8db --- /dev/null +++ b/tools/src/librwxxtpp/Makefile @@ -0,0 +1,66 @@ +# $Id: Makefile 504 2013-04-13 15:37:24Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-02-01 479 1.0.1 correct so name (no digits allowed in tcl load...) +# 2013-01-27 478 1.0 Initial version +#--- +# +# Name of the sharable library +# +SONAME = rwxxtpp +SOMAJV = 1 +SOMINV = 0 +# +# Compile and Link search paths +# +include ../checkpath_cpp.mk +# +INCLFLAGS = -I${RETROBASE}/tools/src -I${TCLINC} -I${BOOSTINC} +LDLIBS = -L${RETROBASE}/tools/lib -lrtools -lrtcltools +LDLIBS += -lrlink -lrw11 +LDLIBS += -lrlinktpp +# +# Object files to be included +# +OBJ_all = Rwxxtpp_Init.o RtclRw11.o +OBJ_all += RtclRw11Cpu.o RtclRw11CpuW11a.o +OBJ_all += RtclRw11Cntl.o RtclRw11CntlFactory.o +OBJ_all += RtclRw11Unit.o +OBJ_all += RtclRw11UnitTerm.o +OBJ_all += RtclRw11CntlDL11.o RtclRw11UnitDL11.o +# +DEP_all = $(OBJ_all:.o=.dep) +# +#- generic part ---------------------------------------------------------------- +# +SOFILE = lib$(SONAME).so +SOFILEV = lib$(SONAME).so.$(SOMAJV) +SOFILEVV = lib$(SONAME).so.$(SOMAJV).$(SOMINV) +# +include $(RETROBASE)/tools/make/generic_cpp.mk +include $(RETROBASE)/tools/make/generic_dep.mk +include $(RETROBASE)/tools/make/generic_so.mk +include $(RETROBASE)/tools/make/dontincdep.mk +# +# The magic autodependcy include +# +ifndef DONTINCDEP +include $(DEP_all) +endif +# +# cleanup phonies: +# +.PHONY : clean cleandep distclean +clean : + @ rm -f $(OBJ_all) + @ echo "Object files removed" +# +cleandep : + @ rm -f $(DEP_all) + @ echo "Dependency files removed" +# +distclean : clean cleandep + @ rm -f $(SOPATH)/lib$(SONAME).a $(SOPATH)/lib$(SONAME).so* + @ echo "Libraries removed" +# diff --git a/tools/src/librwxxtpp/RtclRw11.cpp b/tools/src/librwxxtpp/RtclRw11.cpp new file mode 100644 index 00000000..d7a027ea --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11.cpp @@ -0,0 +1,178 @@ +// $Id: RtclRw11.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-27 478 0.1 First Draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of class RtclRw11. + */ + +#include + +#include +#include + +#include "boost/bind.hpp" + +#include "librtools/RosPrintf.hpp" +#include "librtcltools/RtclContext.hpp" +#include "librlinktpp/RtclRlinkServer.hpp" +#include "RtclRw11CpuW11a.hpp" +#include "librw11/Rw11Cpu.hpp" +#include "librw11/Rw11Cntl.hpp" + +#include "RtclRw11.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11::RtclRw11(Tcl_Interp* interp, const char* name) + : RtclProxyOwned("Rw11", interp, name, new Rw11()), + fspServ() +{ + AddMeth("start", boost::bind(&RtclRw11::M_start, this, _1)); + AddMeth("dump", boost::bind(&RtclRw11::M_dump, this, _1)); + AddMeth("$default", boost::bind(&RtclRw11::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11::~RtclRw11() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11::ClassCmdConfig(RtclArgs& args) +{ + string parent; + if (!args.GetArg("parent", parent)) return kERR; + + // locate RlinkServer proxy and object -> setup W11->Server linkage + RtclProxyBase* pprox = RtclContext::Find(args.Interp()).FindProxy( + "RlinkServer", parent); + + if (pprox == 0) + return args.Quit(string("-E: object '") + parent + + "' not found or not type RlinkServer"); + + // make RtclRlinkRw11 object be co-owner of RlinkServer object + fspServ = dynamic_cast(pprox)->ObjSPtr(); + + // set RlinkServer in Rw11 (make Rw11 also co-owner) + Obj().SetServer(fspServ); + + // now configure cpu's + string type; + int count = 1; + if (!args.GetArg("type", type)) return kERR; + if (!args.GetArg("?count", count, 1, 1)) return kERR; + if (!args.AllDone()) return kERR; + + // 'factory section', create concrete w11Cpu objects + if (type == "w11a") { // w11a -------------------------- + RtclRw11CpuW11a* pobj = new RtclRw11CpuW11a(args.Interp(), "cpu0"); + // configure cpu + pobj->Obj().Setup(0,0); // ind=0,base=0 + // install in w11 + Obj().AddCpu(dynamic_pointer_cast(pobj->ObjSPtr())); + + } else { // unknown cpu type -------------- + return args.Quit(string("-E: unknown cpu type '") + type + "'"); + } + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11::M_start(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + if (Obj().IsStarted()) return args.Quit("already started"); + Obj().Start(); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + + sos << "cpu type base : cntl type ibbase probe lam boot" << endl; + + for (size_t i=0; i list; + cpu.ListCntl(list); + for (size_t j=0; j 0) sos << " " << RosPrintf(cntl.Lam(),"d",3); + else sos << " -"; + uint16_t aload; + uint16_t astart; + vector code; + bool bootok = cntl.BootCode(0, code, aload, astart); + sos << " " << (bootok ? "y" : "n"); + sos << endl; + } + } + + args.AppendResultLines(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11.hpp b/tools/src/librwxxtpp/RtclRw11.hpp new file mode 100644 index 00000000..9032fa1c --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11.hpp @@ -0,0 +1,61 @@ +// $Id: RtclRw11.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11. +*/ + +#ifndef included_Retro_RtclRw11 +#define included_Retro_RtclRw11 1 + +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "librtcltools/RtclProxyOwned.hpp" + +#include "librlink/RlinkServer.hpp" +#include "librw11/Rw11.hpp" + +namespace Retro { + + class RtclRw11 : public RtclProxyOwned { + public: + RtclRw11(Tcl_Interp* interp, const char* name); + ~RtclRw11(); + + virtual int ClassCmdConfig(RtclArgs& args); + + protected: + int M_start(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_default(RtclArgs& args); + + protected: + boost::shared_ptr fspServ; + }; + +} // end namespace Retro + +//#include "RtclRw11.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11Cntl.cpp b/tools/src/librwxxtpp/RtclRw11Cntl.cpp new file mode 100644 index 00000000..9a420dcb --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Cntl.cpp @@ -0,0 +1,131 @@ +// $Id: RtclRw11Cntl.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Cntl.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11Cntl. +*/ + +#include "boost/thread/locks.hpp" +#include "boost/bind.hpp" + +#include "librtcltools/RtclStats.hpp" + +#include "RtclRw11Cntl.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11Cntl + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11Cntl::RtclRw11Cntl(const std::string& type) + : RtclProxyBase(type), + fGets(), + fSets() +{ + AddMeth("get", boost::bind(&RtclRw11Cntl::M_get, this, _1)); + AddMeth("set", boost::bind(&RtclRw11Cntl::M_set, this, _1)); + AddMeth("probe", boost::bind(&RtclRw11Cntl::M_probe, this, _1)); + AddMeth("stats", boost::bind(&RtclRw11Cntl::M_stats, this, _1)); + AddMeth("dump", boost::bind(&RtclRw11Cntl::M_dump, this, _1)); + AddMeth("$default", boost::bind(&RtclRw11Cntl::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11Cntl::~RtclRw11Cntl() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_get(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Obj().Connect()); + return fGets.M_get(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_set(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Obj().Connect()); + return fSets.M_set(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_probe(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + args.SetResult(Obj().Probe()); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Stats())) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cntl::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + sos << "no default output defined yet...\n"; + args.AppendResultLines(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Cntl.hpp b/tools/src/librwxxtpp/RtclRw11Cntl.hpp new file mode 100644 index 00000000..9b04706b --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Cntl.hpp @@ -0,0 +1,68 @@ +// $Id: RtclRw11Cntl.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11Cntl.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11Cntl. +*/ + +#ifndef included_Retro_RtclRw11Cntl +#define included_Retro_RtclRw11Cntl 1 + +#include +#include + +#include "librtcltools/RtclProxyBase.hpp" +#include "librtcltools/RtclGetList.hpp" +#include "librtcltools/RtclSetList.hpp" + +#include "librw11/Rw11Cntl.hpp" +#include "RtclRw11Cpu.hpp" + +namespace Retro { + + class RtclRw11Cntl : public RtclProxyBase { + public: + + explicit RtclRw11Cntl(const std::string& type); + virtual ~RtclRw11Cntl(); + + virtual Rw11Cntl& Obj() = 0; + virtual int FactoryCmdConfig(RtclArgs& args, RtclRw11Cpu& cpu) = 0; + + protected: + int M_get(RtclArgs& args); + int M_set(RtclArgs& args); + int M_probe(RtclArgs& args); + int M_stats(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_default(RtclArgs& args); + + protected: + RtclGetList fGets; + RtclSetList fSets; + }; + +} // end namespace Retro + +//#include "RtclRw11Cntl.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11CntlBase.hpp b/tools/src/librwxxtpp/RtclRw11CntlBase.hpp new file mode 100644 index 00000000..74b2b726 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CntlBase.hpp @@ -0,0 +1,57 @@ +// $Id: RtclRw11CntlBase.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11CntlBase.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11CntlBase. +*/ + +#ifndef included_Retro_RtclRw11CntlBase +#define included_Retro_RtclRw11CntlBase 1 + +#include "boost/shared_ptr.hpp" + +#include "RtclRw11Cntl.hpp" + +namespace Retro { + + template + class RtclRw11CntlBase : public RtclRw11Cntl { + public: + explicit RtclRw11CntlBase(const std::string& type); + ~RtclRw11CntlBase(); + + TO& Obj(); + const boost::shared_ptr& ObjSPtr(); + + protected: + int M_bootcode(RtclArgs& args); + + protected: + boost::shared_ptr fspObj; //!< sptr to managed object + }; + +} // end namespace Retro + +// implementation is all inline +#include "RtclRw11CntlBase.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11CntlBase.ipp b/tools/src/librwxxtpp/RtclRw11CntlBase.ipp new file mode 100644 index 00000000..e6bdf689 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CntlBase.ipp @@ -0,0 +1,109 @@ +// $Id: RtclRw11CntlBase.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11CntlBase.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (all inline) of RtclRw11CntlBase. +*/ + +/*! + \class Retro::RtclRw11CntlBase + \brief FIXME_docs +*/ + +#include "librtcltools/Rtcl.hpp" +#include "librtcltools/RtclOPtr.hpp" + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +inline RtclRw11CntlBase::RtclRw11CntlBase(const std::string& type) + : RtclRw11Cntl(type), + fspObj(new TO()) +{ + AddMeth("bootcode", boost::bind(&RtclRw11CntlBase::M_bootcode,this, _1)); + + TO* pobj = fspObj.get(); + fGets.Add("type", boost::bind(&TO::Type, pobj)); + fGets.Add("name", boost::bind(&TO::Name, pobj)); + fGets.Add ("base", boost::bind(&TO::Base, pobj)); + fGets.Add ("lam", boost::bind(&TO::Lam, pobj)); + fGets.Add ("enable",boost::bind(&TO::Enable, pobj)); + fGets.Add ("started",boost::bind(&TO::IsStarted, pobj)); + fGets.Add ("trace", boost::bind(&TO::TraceLevel,pobj)); + + fSets.Add ("enable", boost::bind(&TO::SetEnable,pobj,_1)); + fSets.Add ("trace", boost::bind(&TO::SetTraceLevel,pobj,_1)); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclRw11CntlBase::~RtclRw11CntlBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TO& RtclRw11CntlBase::Obj() +{ + return *fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline const boost::shared_ptr& RtclRw11CntlBase::ObjSPtr() +{ + return fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +int RtclRw11CntlBase::M_bootcode(RtclArgs& args) +{ + int unit = 0; + if (!args.GetArg("?unit", unit, 0, Obj().NUnit()-1)) return kERR; + if (!args.AllDone()) return kERR; + + std::vector code; + uint16_t aload; + uint16_t astart; + if (Obj().BootCode(unit, code, aload, astart)) { + RtclOPtr pres = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(NULL, pres, Tcl_NewIntObj((int)aload)); + Tcl_ListObjAppendElement(NULL, pres, Tcl_NewIntObj((int)astart)); + Tcl_ListObjAppendElement(NULL, pres, Rtcl::NewListIntObj(code)); + args.SetResult(pres); + } + + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11CntlDL11.cpp b/tools/src/librwxxtpp/RtclRw11CntlDL11.cpp new file mode 100644 index 00000000..b8673637 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CntlDL11.cpp @@ -0,0 +1,97 @@ +// $Id: RtclRw11CntlDL11.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11CntlDL11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11CntlDL11. +*/ + +#include "librtcltools/RtclNameSet.hpp" + +#include "RtclRw11CntlDL11.hpp" +#include "RtclRw11UnitDL11.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11CntlDL11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11CntlDL11::RtclRw11CntlDL11() + : RtclRw11CntlBase("Rw11CntlDL11") +{ + //Rw11CntlDL11* pobj = &Obj(); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11CntlDL11::~RtclRw11CntlDL11() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11CntlDL11::FactoryCmdConfig(RtclArgs& args, RtclRw11Cpu& cpu) +{ + static RtclNameSet optset("-base|-lam"); + + string cntlname(cpu.Obj().NextCntlName("tt")); + string cntlcmd = cpu.CommandName() + cntlname; + + uint16_t base = Rw11CntlDL11::kIbaddr; + int lam = Rw11CntlDL11::kLam; + + string opt; + while (args.NextOpt(opt, optset)) { + if (opt == "-base") { + if (!args.GetArg("base", base, 0177776, 0160000)) return kERR; + } else if (opt == "-lam") { + if (!args.GetArg("lam", lam, 0, 15)) return kERR; + } + } + if (!args.AllDone()) return kERR; + + // configure controller + Obj().Config(cntlname, base, lam); + + // install in CPU + cpu.Obj().AddCntl(dynamic_pointer_cast(ObjSPtr())); + + // finally create tcl command + CreateObjectCmd(args.Interp(), cntlcmd.c_str()); + + // and create unit commands + for (size_t i=0; i +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11CntlDL11.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11CntlDL11. +*/ + +#ifndef included_Retro_RtclRw11CntlDL11 +#define included_Retro_RtclRw11CntlDL11 1 + +#include "RtclRw11CntlBase.hpp" +#include "librw11/Rw11CntlDL11.hpp" + +namespace Retro { + + class RtclRw11CntlDL11 : public RtclRw11CntlBase { + public: + RtclRw11CntlDL11(); + ~RtclRw11CntlDL11(); + + virtual int FactoryCmdConfig(RtclArgs& args, RtclRw11Cpu& cpu); + }; + +} // end namespace Retro + +//#include "RtclRw11CntlDL11.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11CntlFactory.cpp b/tools/src/librwxxtpp/RtclRw11CntlFactory.cpp new file mode 100644 index 00000000..977a80d3 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CntlFactory.cpp @@ -0,0 +1,64 @@ +// $Id: RtclRw11CntlFactory.cpp 495 2013-03-06 17:13:48Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-09 489 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11CntlFactory.cpp 495 2013-03-06 17:13:48Z mueller $ + \brief Implemenation of global function RtclRw11CntlFactory. +*/ + +#include "tcl.h" + +#include "RtclRw11CntlFactory.hpp" + +#include "RtclRw11CntlDL11.hpp" +//#include "RtclRw11CntlRK11.hpp" + +using namespace std; + +// all method definitions in namespace Retro (avoid using in includes...) +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11CntlFactory(RtclArgs& args, RtclRw11Cpu& cpu) +{ + string type; + if (!args.GetArg("type", type)) return TCL_ERROR; + + // 'factory section', create concrete Rw11Cntl objects + if (type == "dl11") { // dl11 -------------------------- + unique_ptr pobj(new RtclRw11CntlDL11()); + if(pobj->FactoryCmdConfig(args, cpu) != TCL_OK) return TCL_ERROR; + pobj.release(); + +// } else if (type == "rk11") { // rk11 -------------------------- +// unique_ptr pobj(new RtclRw11CntlRK11()); +// if(pobj->FactoryCmdConfig(args, cpu) != TCL_OK) return TCL_ERROR; +// pobj.release(); + + } else { // unknown cntl type ------------- + return args.Quit(string("-E: unknown controller type '") + type + "'"); + } + + return TCL_OK; +} + +} // end namespace Retro diff --git a/tools/src/librtools/RlogStd.hpp b/tools/src/librwxxtpp/RtclRw11CntlFactory.hpp similarity index 55% rename from tools/src/librtools/RlogStd.hpp rename to tools/src/librwxxtpp/RtclRw11CntlFactory.hpp index 00bd4c3e..c060c677 100644 --- a/tools/src/librtools/RlogStd.hpp +++ b/tools/src/librwxxtpp/RtclRw11CntlFactory.hpp @@ -1,6 +1,6 @@ -// $Id: RlogStd.hpp 358 2011-02-05 09:45:14Z mueller $ +// $Id: RtclRw11CntlFactory.hpp 504 2013-04-13 15:37:24Z mueller $ // -// Copyright 2011- by Walter F.J. Mueller +// Copyright 2013- by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,24 +13,26 @@ // // Revision History: // Date Rev Version Comment -// 2011-02-04 358 1.0 Initial version +// 2013-03-06 495 1.0 Initial version +// 2013-02-09 485 0.1 First draft // --------------------------------------------------------------------------- + /*! \file - \version $Id: RlogStd.hpp 358 2011-02-05 09:45:14Z mueller $ - \brief Declaration of class RlogStd. + \version $Id: RtclRw11CntlFactory.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of global function RtclRw11CntlFactory. */ -#ifndef included_Retro_RlogStd -#define included_Retro_RlogStd 1 +#ifndef included_Retro_RtclRw11CntlFactory +#define included_Retro_RtclRw11CntlFactory 1 -#include "RlogFile.hpp" +#include "librtcltools/RtclArgs.hpp" +#include "RtclRw11Cpu.hpp" namespace Retro { - extern RlogFile gRcout; - extern RlogFile gRcerr; + int RtclRw11CntlFactory(RtclArgs& args, RtclRw11Cpu& cpu); } // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.cpp b/tools/src/librwxxtpp/RtclRw11Cpu.cpp new file mode 100644 index 00000000..170f7263 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Cpu.cpp @@ -0,0 +1,903 @@ +// $Id: RtclRw11Cpu.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-02 502 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Cpu.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11Cpu. +*/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "boost/bind.hpp" + +#include "librtools/RerrMsg.hpp" +#include "librtools/RlogMsg.hpp" +#include "librtools/RosPrintf.hpp" +#include "librtools/RosPrintBvi.hpp" +#include "librtcltools/Rtcl.hpp" +#include "librtcltools/RtclStats.hpp" +#include "librtcltools/RtclOPtr.hpp" +#include "librtcltools/RtclNameSet.hpp" +#include "librlink/RlinkCommandList.hpp" + +#include "RtclRw11.hpp" + +#include "RtclRw11CntlFactory.hpp" +#include "librw11/Rw11Cntl.hpp" + +#include "RtclRw11Cpu.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11Cpu + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RtclRw11Cpu::RtclRw11Cpu(const std::string& type) + : RtclProxyBase(type), + fGets() +{ + AddMeth("add", boost::bind(&RtclRw11Cpu::M_add, this, _1)); + AddMeth("cp", boost::bind(&RtclRw11Cpu::M_cp, this, _1)); + AddMeth("wtcpu", boost::bind(&RtclRw11Cpu::M_wtcpu, this, _1)); + AddMeth("deposit", boost::bind(&RtclRw11Cpu::M_deposit, this, _1)); + AddMeth("examine", boost::bind(&RtclRw11Cpu::M_examine, this, _1)); + AddMeth("lsmem", boost::bind(&RtclRw11Cpu::M_lsmem, this, _1)); + AddMeth("ldabs", boost::bind(&RtclRw11Cpu::M_ldabs, this, _1)); + AddMeth("ldasm", boost::bind(&RtclRw11Cpu::M_ldasm, this, _1)); + AddMeth("boot", boost::bind(&RtclRw11Cpu::M_boot, this, _1)); + AddMeth("get", boost::bind(&RtclRw11Cpu::M_get, this, _1)); + AddMeth("set", boost::bind(&RtclRw11Cpu::M_set, this, _1)); + AddMeth("stats", boost::bind(&RtclRw11Cpu::M_stats, this, _1)); + AddMeth("dump", boost::bind(&RtclRw11Cpu::M_dump, this, _1)); + AddMeth("$default", boost::bind(&RtclRw11Cpu::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11Cpu::~RtclRw11Cpu() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_add(RtclArgs& args) +{ + return RtclRw11CntlFactory(args, *this); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_cp(RtclArgs& args) +{ + static RtclNameSet optset("-rr|-rr0|-rr1|-rr2|-rr3|-rr4|-rr5|-rr6|-rr7|" + "-wr|-wr0|-wr1|-wr2|-wr3|-wr4|-wr5|-wr6|-wr7|" + "-rsp|-rpc|-wsp|-wpc|" + "-rps|-wps|" + "-wal|-wah|-rm|-rmi|-wm|-wmi|-brm|-bwm|" + "-stapc|-start|-stop|-continue|-step|-reset|" + "-ribrb|-wibrb|-wibrbbe|-ribr|-wibr|" + "-rconf|-rstat|" + "-edata|-estat|-estatdef" + ); + + Tcl_Interp* interp = args.Interp(); + + RlinkCommandList clist; + string opt; + uint16_t base = Obj().Base(); + + vector vardata; + vector varstat; + + uint8_t estatdef_val = 0x00; + uint8_t estatdef_msk = 0xff; + + bool setcpugo = false; + + while (args.NextOpt(opt, optset)) { + size_t lsize = clist.Size(); + + // map register read/write + if (opt == "-rsp") opt = "-rr6"; + if (opt == "-rpc") opt = "-rr7"; + if (opt == "-wsp") opt = "-wr6"; + if (opt == "-wpc") opt = "-wr7"; + + int regnum = 0; + if (opt.substr(0,3) == "-rr" || opt.substr(0,3) == "-wr" ) { + if (opt.length() == 3) { + if (!args.GetArg("regnum", regnum, 0, 7)) return kERR; + } else { + regnum = opt[3] - '0'; + regnum &= 0x7; // to be sure... + } + opt = opt.substr(0,3); + } + + if (opt == "-rr") { // -rr* ?varData ?varStat -------- + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_r0 + regnum); + + } else if (opt == "-wr") { // -wr* data ?varStat ------------ + uint16_t data; + if (!args.GetArg("data", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_r0 + regnum, data); + + } else if (opt == "-rps") { // -rps ?varData ?varStat -------- + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_psw); + + } else if (opt == "-wps") { // -wps data ?varStat ------------ + uint16_t data; + if (!args.GetArg("data", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_psw, data); + + } else if (opt == "-wal") { // -wal data ?varStat ------------ + uint16_t data; + if (!args.GetArg("al", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_al, data); + + } else if (opt == "-wah") { // -wah data ?varStat ------------ + uint16_t data; + if (!args.GetArg("ah", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_ah, data); + + } else if (opt == "-rm" || // -rm(i) ?varData ?varStat ------ + opt == "-rmi") { + uint16_t addr = opt=="-rm" ? Rw11Cpu::kCp_addr_mem : Rw11Cpu::kCp_addr_memi; + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + addr); + + } else if (opt == "-wm" || // -wm(i) data ?varStat - + opt == "-wmi") { + uint16_t addr = opt=="-wm" ? Rw11Cpu::kCp_addr_mem : + Rw11Cpu::kCp_addr_memi; + uint16_t data; + if (!args.GetArg("data", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + addr, data); + + } else if (opt == "-brm") { // -brm size ?varData ?varStat --- + int32_t bsize; + if (!args.GetArg("bsize", bsize, 1, 256)) return kERR; + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRblk(base + Rw11Cpu::kCp_addr_memi, (size_t) bsize); + + } else if (opt == "-bwm") { // -bwm block ?varStat ----------- + vector block; + if (!args.GetArg("data", block, 1, 256)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWblk(base + Rw11Cpu::kCp_addr_memi, block); + + } else if (opt == "-stapc") { // -stapc addr ?varStat ---------- + uint16_t data; + if (!args.GetArg("data", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize+1, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_pc, data); + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_start); + setcpugo = true; + + } else if (opt == "-start") { // -start ?varStat --------------- + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_start); + setcpugo = true; + + } else if (opt == "-stop") { // -stop ?varStat ---------------- + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_stop); + + } else if (opt == "-continue") { // -continue ?varStat ------------ + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_cont); + setcpugo = true; + + } else if (opt == "-step") { // -step ?varStat ---------------- + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_step); + + } else if (opt == "-reset") { // -reset ?varStat --------------- + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_reset); + + } else if (opt == "-ribrb") { // -ribrb ?varData ?varStat ------ + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_ibrb); + + } else if (opt == "-wibrb") { // -wibrb base ?varStat ---------- + uint16_t data; + if (!args.GetArg("base", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + data &= 0177700; // clear byte enables + clist.AddWreg(base + Rw11Cpu::kCp_addr_ibrb, data); + + } else if (opt == "-wibrbbe") { // -wibrbbe base be ?varStat ----- + uint16_t data; + uint16_t be; + if (!args.GetArg("base", data)) return kERR; + if (!args.GetArg("be", be, 0x3)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + data &= 0177700; // clear byte enables from base + if (be == 0) be = 0x3; // map be 0 -> be 3 + data |= be; // set byte enables + clist.AddWreg(base + Rw11Cpu::kCp_addr_ibrb, data); + + } else if (opt == "-ribr") { // -ribr off ?varData ?varStat ---- + uint16_t off; + if (!args.GetArg("off", off, 63)) return kERR; + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_ibr + off/2); + + } else if (opt == "-wibr") { // -wibrb off data ?varStat -------- + uint16_t off; + uint16_t data; + if (!args.GetArg("off", off, 63)) return kERR; + if (!args.GetArg("data", data)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddWreg(base + Rw11Cpu::kCp_addr_ibr + off/2, data); + + } else if (opt == "-rconf") { // -rconf ?varData ?varStat ------ + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_conf); + + } else if (opt == "-rstat") { // -rstat ?varData ?varStat ------ + if (!GetVarName(args, "??varData", lsize, vardata)) return kERR; + if (!GetVarName(args, "??varStat", lsize, varstat)) return kERR; + clist.AddRreg(base + Rw11Cpu::kCp_addr_stat); + + } else if (opt == "-edata") { // -edata data ?mask -------------- + if (lsize == 0) + return args.Quit("-E: -edata not allowed on empty command list"); + if (clist[lsize-1].Expect()==0) { + clist.LastExpect(new RlinkCommandExpect()); + } + if (clist[lsize-1].Command() == RlinkCommand::kCmdRblk) { + vector data; + vector mask; + size_t bsize = clist[lsize-1].BlockSize(); + if (!args.GetArg("data", data, 0, bsize)) return kERR; + if (!args.GetArg("??mask", mask, 0, bsize)) return kERR; + clist[lsize-1].Expect()->SetBlock(data, mask); + } else { + uint16_t data=0; + uint16_t mask=0; + if (!args.GetArg("data", data)) return kERR; + if (!args.GetArg("??mask", mask)) return kERR; + clist[lsize-1].Expect()->SetData(data, mask); + } + + } else if (opt == "-estat") { // -estat ?stat ?mask ------------- + if (lsize == 0) + return args.Quit("-E: -estat not allowed on empty command list"); + uint8_t stat=0; + uint8_t mask=0; + if (!args.GetArg("??stat", stat)) return kERR; + if (!args.GetArg("??mask", mask)) return kERR; + if (args.NOptMiss() == 2) mask = 0xff; + if (clist[lsize-1].Expect()==0) { + clist.LastExpect(new RlinkCommandExpect()); + } + clist[lsize-1].Expect()->SetStatus(stat, mask); + + } else if (opt == "-estatdef") { // -estatdef ?stat ?mask ----------- + uint8_t stat=0; + uint8_t mask=0; + if (!args.GetArg("??stat", stat)) return kERR; + if (!args.GetArg("??mask", mask)) return kERR; + if (args.NOptMiss() == 2) mask = 0xff; + estatdef_val = stat; + estatdef_msk = mask; + + } + + if (lsize != clist.Size()) { // cmd added to clist (ind=lsize!) + if (estatdef_msk != 0xff) { // estatdef defined + if (clist[lsize].Expect()==0) { + clist.LastExpect(new RlinkCommandExpect()); + } + clist[lsize].Expect()->SetStatus(estatdef_val, estatdef_msk); + } + } + + } + + if (!args.AllDone()) return kERR; + if (clist.Size() == 0) return kOK; + + // signal cpugo up before clist executed to prevent races + if (setcpugo) Obj().SetCpuGoUp(); + + RerrMsg emsg; + // this one intentionally on Connect() to allow mixing of rlc + w11 commands + // FIXME_code: is this a good idea ?? + if (!Connect().Exec(clist, emsg)) return args.Quit(emsg); + + for (size_t icmd=0; icmd retstat; + RtclOPtr pele; + switch (cmd.Command()) { + case RlinkCommand::kCmdRreg: + pres = Tcl_NewIntObj((int)cmd.Data()); + break; + + case RlinkCommand::kCmdRblk: + pres = Rtcl::NewListIntObj(cmd.Block()); + break; + } + if(!Rtcl::SetVar(interp, vardata[icmd], pres)) return kERR; + } + + if (icmd= 0.) { // wait succeeded + RlinkCommandList clist; // get and discard attn pattern + clist.AddAttn(); + if (!Connect().Exec(clist, emsg)) return args.Quit(emsg); + } + + } else { // server is active + twait = Obj().WaitCpuGoDown(tout); + } + + if (twait < 0.) { // timeout + if (Connect().GetLogOpts().printlevel >= 1) { + RlogMsg lmsg(Connect().LogFile()); + lmsg << "-- wtcpu to=" << RosPrintf(tout, "f", 0,3) << " FAIL timeout"; + } + Connect().Context().IncErrorCount(); + if (reset) { // reset requested + uint16_t base = Obj().Base(); + RlinkCommandList clist; + clist.AddWreg(base + Rw11Cpu::kCp_addr_cntl, Rw11Cpu::kCp_func_stop); + RerrMsg emsg; + if (!Connect().Exec(clist, emsg)) return args.Quit(emsg); + } + } else { // no timeout + if (Connect().GetLogOpts().printlevel >= 3) { + RlogMsg lmsg(Connect().LogFile()); + lmsg << "-- wtcpu to=" << RosPrintf(tout, "f", 0,3) + << " T=" << RosPrintf(twait, "f", 0,3) + << " OK"; + } + } + + args.SetResult(twait); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_deposit(RtclArgs& args) +{ + uint16_t addr; + vector data; + if (!args.GetArg("addr", addr)) return kERR; + if (!args.GetArg("data", data, 1)) return kERR; + if (!args.AllDone()) return kERR; + + RerrMsg emsg; + // FIXME_code: handle memory read/write error + if (!Obj().MemWrite(addr, data, emsg)) return args.Quit(emsg); + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_examine(RtclArgs& args) +{ + uint16_t addr; + if (!args.GetArg("addr", addr)) return kERR; + if (!args.AllDone()) return kERR; + + RerrMsg emsg; + vector data; + // FIXME_code: handle memory read/write error + if (!Obj().MemRead(addr, data, 1, emsg)) return args.Quit(emsg); + + args.SetResult(Rtcl::NewListIntObj(data)); + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_lsmem(RtclArgs& args) +{ + uint16_t abeg; + if (!args.GetArg("abeg", abeg)) return kERR; + uint16_t aend = abeg; + if (!args.GetArg("?aend", aend, 0xffff, abeg)) return kERR; + if (!args.AllDone()) return kERR; + + RerrMsg emsg; + vector data; + size_t nword = 1+(aend-abeg)/2; + // FIXME_code: handle memory read/write error + if (!Obj().MemRead(abeg, data, nword, emsg)) return args.Quit(emsg); + + ostringstream sos; + for (size_t i=0; i argv; + vector opts; + + argv.push_back("asm-11"); + if (varlst.length()>0) argv.push_back("--olst=-"); + argv.push_back("--ocof=-"); + if (asmopt.length()) { + istringstream optstream(asmopt); + string tok; + while (optstream >> tok) { + opts.push_back(tok); + argv.push_back(opts[opts.size()-1].c_str()); + } + } + if (file.length()) { + argv.push_back(file.c_str()); + } else { + argv.push_back("-"); + } + argv.push_back(NULL); + + ::dup2(pipe_tcl2asm[0], STDIN_FILENO); + ::dup2(pipe_asm2tcl[1], STDOUT_FILENO); + ::dup2(STDOUT_FILENO, STDERR_FILENO); + ::close(pipe_tcl2asm[1]); + ::close(pipe_asm2tcl[0]); + ::execvp("asm-11", (char* const*) argv.data()); + ::perror("execvp() for asm-11 failed"); + ::exit(EXIT_FAILURE); + + } else { // in parent here + ::close(pipe_tcl2asm[0]); + ::close(pipe_asm2tcl[1]); + if (pid < (pid_t) 0) + return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" , + "fork() failed: ", errno)); + } + + // if first line empty, drop it (created often by using {) + if (code.length() && code[0] == '\n') code = code.substr(1); + + istringstream ostream(code); + string oline; + while (std::getline(ostream, oline)) { + oline += '\n'; + //cout << "+++1:" << oline; + if (::write(pipe_tcl2asm[1], oline.data(), oline.length()) < 0) break; + } + ::close(pipe_tcl2asm[1]); + + FILE* fp = ::fdopen(pipe_asm2tcl[0], "r"); + if (fp == NULL) { + ::close(pipe_asm2tcl[0]); + return args.Quit(RerrMsg("RtclRw11Cpu::M_ldasm" , + "fdopen() failed: ", errno)); + } + + vector ilines; + while(true) { + char* pline = NULL; + size_t nchar; + if (::getline(&pline, &nchar, fp) < 0) break; + //cout << "+++2:" << pline; + string line(pline); + if (line.length() && line[line.length()-1] =='\n') + line.resize(line.length()-1); + ilines.push_back(line); + ::free(pline); + } + ::fclose(fp); + ::close(pipe_asm2tcl[0]); + + int wstat; + int wexit = -1; + waitpid(pid, &wstat, 0); + if (WIFEXITED(wstat)) wexit = WEXITSTATUS(wstat); + + bool insym = false; + bool indat = false; + char dtyp = ' '; + + ostringstream los; // list stream + ostringstream eos; // error stream + bool lstbodyseen = false; + + typedef map cmap_t; + typedef cmap_t::iterator cmap_it_t; + typedef cmap_t::value_type cmap_val_t; + + cmap_t cmap; + uint16_t dot = 0; + + for (size_t i=0; i "); + if (dpos != std::string::npos) { + string key = line.substr(0,dpos); + string val= line.substr(dpos+4); + if (!Tcl_SetVar2Ex(interp, varsym.c_str(), key.c_str(), + Tcl_NewIntObj((int)strtol(val.c_str(),NULL,8)), + TCL_LEAVE_ERR_MSG)) return kERR; + } else { + return args.Quit(string("bad sym spec: ") + line); + } + + // handle data part + } else if (indat) { + if (dtyp == ' ') { + if (line.length() != 10) + return args.Quit(string("bad dat spec: ") + line); + dtyp = line[0]; + dot = (uint16_t)strtol(line.c_str()+2,NULL,8); + } else if (line[0] == '}') { + dtyp = ' '; + } else { + istringstream datstream(line); + string dat; + while (datstream >> dat) { + //cout << "+++1 " << dtyp << ":" << dat << endl; + uint16_t val = (uint16_t)strtol(dat.c_str(),NULL,8); + if (dtyp == 'w') { + cmap[dot] = val; + dot += 2; + } else { + uint16_t tmp = cmap[dot&0xfffe]; + if (dot & 01) { + tmp = (val&0xff)<<8 | (tmp&0xff); // odd (high) byte + } else { + tmp = (tmp&0xff00) | (val&0xff); // even (low) byte + } + cmap[dot&0xfffe] = tmp; + dot += 1; + } + } + } + + // handle listing part (everything not sym{} or dat{} + } else { + los << line << endl; + // put lines into error stream if + // 1. before 'Input file list:' and not starting with '--' + // 2. after 'Input file list:' and starting with uppercase letter + if (line == "; Input file list:") lstbodyseen = true; + bool etake = false; + if (lstbodyseen) { + if (line.length() && (line[0]>'A' && line[0]<'Z')) etake = true; + } else { + if (line.substr(0,2) != "--") etake = true; + } + if (line.substr(0,6) == "asm-11") etake = true; + if (etake) eos << line << endl; + } + } + + if (varlst.length()) { + if (!Rtcl::SetVar(interp, varlst, Rtcl::NewLinesObj(los))) return kERR; + } + + // now, finally, iterate of cmap and write code to memory + + vector block; + uint16_t base = 0; + dot = 0; + RerrMsg emsg; + + for (cmap_it_t it=cmap.begin(); it!=cmap.end(); it++) { + //cout << "+++2 mem[" << RosPrintf(it->first, "o0", 6) + // << "]=" << RosPrintf(it->second, "o0", 6) << endl; + if (dot != it->first || block.size() == 256) { + if (block.size()) { + if (!Obj().MemWrite(base, block, emsg)) return args.Quit(emsg); + block.clear(); + } + base = dot = it->first; + } + block.push_back(it->second); + dot += 2; + } + + if (block.size()) { + if (!Obj().MemWrite(base, block, emsg)) return args.Quit(emsg); + block.clear(); + } + + if (wexit != 0) { + args.AppendResultLines("asm-11 compilation failed with:"); + args.AppendResultLines(eos); + return kERR; + } + + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_boot(RtclArgs& args) +{ + string uname; + if (!args.GetArg("uname", uname)) return kERR; + if (!args.AllDone()) return kERR; + RerrMsg emsg; + if (!Obj().Boot(uname, emsg)) return args.Quit(emsg); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_get(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Obj().Connect()); + return fGets.M_get(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_set(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(Obj().Connect()); + return fSets.M_set(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Stats())) return kERR; + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Cpu::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + + vector cntlnames; + Obj().ListCntl(cntlnames); + + sos << "name type ibbase lam" << endl; + + for (size_t i=0; i("type", boost::bind(&Rw11Cpu::Type, pobj)); + fGets.Add ("index", boost::bind(&Rw11Cpu::Index, pobj)); + fGets.Add ("base", boost::bind(&Rw11Cpu::Base, pobj)); + return; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +bool RtclRw11Cpu::GetVarName(RtclArgs& args, const char* argname, + size_t nind, + std::vector& varname) +{ + while (varname.size() < nind+1) varname.push_back(string()); + string name; + if (!args.GetArg(argname, name)) return false; + if (name.length()) { // if variable defined + char c = name[0]; + if (isdigit(c) || c=='+' || c=='-' ) { // check for mistaken number + args.AppendResult("-E: invalid variable name '", name.c_str(), + "': looks like a number", NULL); + return false; + } + } + + varname[nind] = name; + return true; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.hpp b/tools/src/librwxxtpp/RtclRw11Cpu.hpp new file mode 100644 index 00000000..9eeca43d --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Cpu.hpp @@ -0,0 +1,84 @@ +// $Id: RtclRw11Cpu.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-02 502 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11Cpu.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11Cpu. +*/ + +#ifndef included_Retro_RtclRw11Cpu +#define included_Retro_RtclRw11Cpu 1 + +#include +#include + +#include "librlink/RlinkConnect.hpp" + +#include "librtcltools/RtclProxyBase.hpp" +#include "librtcltools/RtclGetList.hpp" +#include "librtcltools/RtclSetList.hpp" + +#include "librw11/Rw11Cpu.hpp" + +namespace Retro { + + class RtclRw11Cpu : public RtclProxyBase { + public: + + explicit RtclRw11Cpu(const std::string& type); + virtual ~RtclRw11Cpu(); + + virtual Rw11Cpu& Obj() = 0; + + protected: + int M_add(RtclArgs& args); + int M_cp(RtclArgs& args); + int M_wtcpu(RtclArgs& args); + int M_deposit(RtclArgs& args); + int M_examine(RtclArgs& args); + int M_lsmem(RtclArgs& args); + int M_ldabs(RtclArgs& args); + int M_ldasm(RtclArgs& args); + int M_boot(RtclArgs& args); + int M_get(RtclArgs& args); + int M_set(RtclArgs& args); + int M_stats(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_default(RtclArgs& args); + + void SetupGetSet(); + + RlinkServer& Server(); + RlinkConnect& Connect(); + + bool GetVarName(RtclArgs& args, const char* argname, + size_t nind, std::vector& varname); + + protected: + RtclGetList fGets; + RtclSetList fSets; + }; + +} // end namespace Retro + +#include "RtclRw11Cpu.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.ipp b/tools/src/librwxxtpp/RtclRw11Cpu.ipp new file mode 100644 index 00000000..3f2973d7 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Cpu.ipp @@ -0,0 +1,45 @@ +// $Id: RtclRw11Cpu.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-04-02 502 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Cpu.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of RtclRw11Cpu. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkServer& RtclRw11Cpu::Server() +{ + return Obj().Server(); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RlinkConnect& RtclRw11Cpu::Connect() +{ + return Obj().Connect(); +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11CpuBase.hpp b/tools/src/librwxxtpp/RtclRw11CpuBase.hpp new file mode 100644 index 00000000..eba8c8d5 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CpuBase.hpp @@ -0,0 +1,55 @@ +// $Id: RtclRw11CpuBase.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 491 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11CpuBase.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11CpuBase. +*/ + +#ifndef included_Retro_RtclRw11CpuBase +#define included_Retro_RtclRw11CpuBase 1 + +#include "boost/shared_ptr.hpp" + +#include "RtclRw11Cpu.hpp" + +namespace Retro { + + template + class RtclRw11CpuBase : public RtclRw11Cpu { + public: + RtclRw11CpuBase(Tcl_Interp* interp, const char* name, + const std::string& type); + ~RtclRw11CpuBase(); + + TO& Obj(); + const boost::shared_ptr& ObjSPtr(); + + protected: + boost::shared_ptr fspObj; //!< sptr to managed object + }; + +} // end namespace Retro + +// implementation is all inline +#include "RtclRw11CpuBase.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11CpuBase.ipp b/tools/src/librwxxtpp/RtclRw11CpuBase.ipp new file mode 100644 index 00000000..a9419e7c --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CpuBase.ipp @@ -0,0 +1,73 @@ +// $Id: RtclRw11CpuBase.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-23 491 1.0 Initial version +// 2013-02-08 484 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11CpuBase.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (all inline) of RtclRw11CpuBase. +*/ + +/*! + \class Retro::RtclRw11CpuBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +inline RtclRw11CpuBase::RtclRw11CpuBase(Tcl_Interp* interp, + const char* name, + const std::string& type) + : RtclRw11Cpu(type), + fspObj(new TO()) +{ + CreateObjectCmd(interp, name); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclRw11CpuBase::~RtclRw11CpuBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TO& RtclRw11CpuBase::Obj() +{ + return *fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline const boost::shared_ptr& RtclRw11CpuBase::ObjSPtr() +{ + return fspObj; +} + + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11CpuW11a.cpp b/tools/src/librwxxtpp/RtclRw11CpuW11a.cpp new file mode 100644 index 00000000..5689b353 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CpuW11a.cpp @@ -0,0 +1,64 @@ +// $Id: RtclRw11CpuW11a.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-16 488 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11CpuW11a.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11CpuW11a. +*/ + +#include + +#include "RtclRw11CpuW11a.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11CpuW11a + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11CpuW11a::RtclRw11CpuW11a(Tcl_Interp* interp, const char* name) + : RtclRw11CpuBase(interp, name, "Rw11CpuW11a") +{ + SetupGetSet(); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11CpuW11a::~RtclRw11CpuW11a() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +void RtclRw11CpuW11a::SetupGetSet() +{ + RtclRw11Cpu::SetupGetSet(); + return; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11CpuW11a.hpp b/tools/src/librwxxtpp/RtclRw11CpuW11a.hpp new file mode 100644 index 00000000..fab823a4 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11CpuW11a.hpp @@ -0,0 +1,49 @@ +// $Id: RtclRw11CpuW11a.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-16 488 1.0 Initial version +// 2013-02-02 480 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11CpuW11a.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11CpuW11a. +*/ + +#ifndef included_Retro_RtclRw11CpuW11a +#define included_Retro_RtclRw11CpuW11a 1 + +#include "RtclRw11CpuBase.hpp" +#include "librw11/Rw11CpuW11a.hpp" + +namespace Retro { + + class RtclRw11CpuW11a : public RtclRw11CpuBase { + public: + RtclRw11CpuW11a(Tcl_Interp* interp, const char* name); + ~RtclRw11CpuW11a(); + + protected: + void SetupGetSet(); + + }; + +} // end namespace Retro + +//#include "RtclRw11CpuW11a.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11Unit.cpp b/tools/src/librwxxtpp/RtclRw11Unit.cpp new file mode 100644 index 00000000..665c53ac --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Unit.cpp @@ -0,0 +1,141 @@ +// $Id: RtclRw11Unit.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Unit.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11Unit. +*/ + +#include "boost/thread/locks.hpp" +#include "boost/bind.hpp" + +#include "librtcltools/RtclStats.hpp" + +#include "RtclRw11Unit.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11Unit + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Default constructor + +RtclRw11Unit::RtclRw11Unit(const std::string& type, Rw11Cpu* pcpu) + : RtclProxyBase(type), + fpCpu(pcpu), + fGets(), + fSets() +{ + AddMeth("get", boost::bind(&RtclRw11Unit::M_get, this, _1)); + AddMeth("set", boost::bind(&RtclRw11Unit::M_set, this, _1)); + AddMeth("attach", boost::bind(&RtclRw11Unit::M_attach, this, _1)); + AddMeth("detach", boost::bind(&RtclRw11Unit::M_detach, this, _1)); + AddMeth("dump", boost::bind(&RtclRw11Unit::M_dump, this, _1)); + AddMeth("$default", boost::bind(&RtclRw11Unit::M_default, this, _1)); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11Unit::~RtclRw11Unit() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_get(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(fpCpu->Connect()); + return fGets.M_get(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_set(RtclArgs& args) +{ + // synchronize with server thread + boost::lock_guard lock(fpCpu->Connect()); + return fSets.M_set(args); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_attach(RtclArgs& args) +{ + string url; + if (!args.GetArg("url", url)) return kERR; + + if (!args.AllDone()) return kERR; + + RerrMsg emsg; + // synchronize with server thread + boost::lock_guard lock(fpCpu->Connect()); + if (!Obj().Attach(url, emsg)) return args.Quit(emsg); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_detach(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + // synchronize with server thread + boost::lock_guard lock(fpCpu->Connect()); + Obj().Detach(); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_dump(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + + ostringstream sos; + Obj().Dump(sos, 0); + args.SetResult(sos); + return kOK; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +int RtclRw11Unit::M_default(RtclArgs& args) +{ + if (!args.AllDone()) return kERR; + ostringstream sos; + sos << "no default output defined yet...\n"; + args.AppendResultLines(sos); + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Unit.hpp b/tools/src/librwxxtpp/RtclRw11Unit.hpp new file mode 100644 index 00000000..842cc64a --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Unit.hpp @@ -0,0 +1,70 @@ +// $Id: RtclRw11Unit.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11Unit.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11Unit. +*/ + +#ifndef included_Retro_RtclRw11Unit +#define included_Retro_RtclRw11Unit 1 + +#include +#include + +#include "librtcltools/RtclProxyBase.hpp" +#include "librtcltools/RtclGetList.hpp" +#include "librtcltools/RtclSetList.hpp" + +#include "librw11/Rw11Cpu.hpp" +#include "librw11/Rw11Unit.hpp" + +namespace Retro { + + class RtclRw11Unit : public RtclProxyBase { + public: + + RtclRw11Unit(const std::string& type, Rw11Cpu* pcpu); + virtual ~RtclRw11Unit(); + + virtual Rw11Unit& Obj() = 0; + RtclGetList& GetList(); + RtclSetList& SetList(); + + protected: + int M_get(RtclArgs& args); + int M_set(RtclArgs& args); + int M_attach(RtclArgs& args); + int M_detach(RtclArgs& args); + int M_dump(RtclArgs& args); + int M_default(RtclArgs& args); + + protected: + Rw11Cpu* fpCpu; + RtclGetList fGets; + RtclSetList fSets; + }; + +} // end namespace Retro + +#include "RtclRw11Unit.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11Unit.ipp b/tools/src/librwxxtpp/RtclRw11Unit.ipp new file mode 100644 index 00000000..b0ee64cc --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11Unit.ipp @@ -0,0 +1,45 @@ +// $Id: RtclRw11Unit.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-02-22 490 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11Unit.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (inline) of RtclRw11Unit. +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RtclGetList& RtclRw11Unit::GetList() +{ + return fGets; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +inline RtclSetList& RtclRw11Unit::SetList() +{ + return fSets; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11UnitBase.hpp b/tools/src/librwxxtpp/RtclRw11UnitBase.hpp new file mode 100644 index 00000000..c13e6861 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitBase.hpp @@ -0,0 +1,58 @@ +// $Id: RtclRw11UnitBase.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11UnitBase.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11UnitBase. +*/ + +#ifndef included_Retro_RtclRw11UnitBase +#define included_Retro_RtclRw11UnitBase 1 + +#include "boost/shared_ptr.hpp" + +#include "RtclRw11Unit.hpp" + +namespace Retro { + + template + class RtclRw11UnitBase : public RtclRw11Unit { + public: + RtclRw11UnitBase(const std::string& type, + const boost::shared_ptr& spunit); + ~RtclRw11UnitBase(); + + TO& Obj(); + const boost::shared_ptr& ObjSPtr(); + + protected: + int M_stats(RtclArgs& args); + + protected: + boost::shared_ptr fspObj; //!< sptr to managed object + }; + +} // end namespace Retro + +// implementation is all inline +#include "RtclRw11UnitBase.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11UnitBase.ipp b/tools/src/librwxxtpp/RtclRw11UnitBase.ipp new file mode 100644 index 00000000..6ac293ea --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitBase.ipp @@ -0,0 +1,91 @@ +// $Id: RtclRw11UnitBase.ipp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-06 495 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11UnitBase.ipp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation (all inline) of RtclRw11UnitBase. +*/ + +#include "librtcltools/RtclStats.hpp" + +/*! + \class Retro::RtclRw11UnitBase + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +template +inline RtclRw11UnitBase::RtclRw11UnitBase(const std::string& type, + const boost::shared_ptr& spunit) + : RtclRw11Unit(type, &(spunit->Cntl().Cpu())), + fspObj(spunit) +{ + AddMeth("stats", boost::bind(&RtclRw11UnitBase::M_stats, this, _1)); + TO* pobj = fspObj.get(); + fGets.Add ("index", boost::bind(&TO::Index, pobj)); + fGets.Add ("name", boost::bind(&TO::Name, pobj)); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline RtclRw11UnitBase::~RtclRw11UnitBase() +{} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline TO& RtclRw11UnitBase::Obj() +{ + return *fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +inline const boost::shared_ptr& RtclRw11UnitBase::ObjSPtr() +{ + return fspObj; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +template +int RtclRw11UnitBase::M_stats(RtclArgs& args) +{ + RtclStats::Context cntx; + if (!RtclStats::GetArgs(args, cntx)) return kERR; + if (!RtclStats::Collect(args, cntx, Obj().Stats())) return kERR; + if (Obj().Virt()) { + if (!RtclStats::Collect(args, cntx, Obj().Virt()->Stats())) return kERR; + } + return kOK; +} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11UnitDL11.cpp b/tools/src/librwxxtpp/RtclRw11UnitDL11.cpp new file mode 100644 index 00000000..f1e4d5c2 --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitDL11.cpp @@ -0,0 +1,56 @@ +// $Id: RtclRw11UnitDL11.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11UnitDL11.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11UnitDL11. +*/ + +#include "RtclRw11UnitDL11.hpp" + +using namespace std; + +/*! + \class Retro::RtclRw11UnitDL11 + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11UnitDL11::RtclRw11UnitDL11(Tcl_Interp* interp, + const std::string& unitcmd, + const boost::shared_ptr& spunit) + : RtclRw11UnitBase("Rw11UnitDL11", spunit), + RtclRw11UnitTerm(this, spunit.get()) +{ + CreateObjectCmd(interp, unitcmd.c_str()); +} + +//------------------------------------------+----------------------------------- +//! Destructor + +RtclRw11UnitDL11::~RtclRw11UnitDL11() +{} + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11UnitDL11.hpp b/tools/src/librwxxtpp/RtclRw11UnitDL11.hpp new file mode 100644 index 00000000..549f4cdf --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitDL11.hpp @@ -0,0 +1,53 @@ +// $Id: RtclRw11UnitDL11.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-01 493 1.0 Initial version +// 2013-02-16 488 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11UnitDL11.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11UnitDL11. +*/ + +#ifndef included_Retro_RtclRw11UnitDL11 +#define included_Retro_RtclRw11UnitDL11 1 + +#include "librw11/Rw11UnitDL11.hpp" +#include "librw11/Rw11CntlDL11.hpp" + +#include "RtclRw11UnitTerm.hpp" +#include "RtclRw11UnitBase.hpp" + +namespace Retro { + +class RtclRw11UnitDL11 : public RtclRw11UnitBase, + public RtclRw11UnitTerm { + public: + RtclRw11UnitDL11(Tcl_Interp* interp, + const std::string& unitcmd, + const boost::shared_ptr& spunit); + ~RtclRw11UnitDL11(); + + protected: + }; + +} // end namespace Retro + +//#include "RtclRw11UnitDL11.ipp" + +#endif diff --git a/tools/src/librwxxtpp/RtclRw11UnitTerm.cpp b/tools/src/librwxxtpp/RtclRw11UnitTerm.cpp new file mode 100644 index 00000000..02066afb --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitTerm.cpp @@ -0,0 +1,64 @@ +// $Id: RtclRw11UnitTerm.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-03-01 493 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: RtclRw11UnitTerm.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of RtclRw11UnitTerm. +*/ + +using namespace std; + +#include "RtclRw11UnitTerm.hpp" + +/*! + \class Retro::RtclRw11UnitTerm + \brief FIXME_docs +*/ + +// all method definitions in namespace Retro +namespace Retro { + +//------------------------------------------+----------------------------------- +//! Constructor + +RtclRw11UnitTerm::RtclRw11UnitTerm(RtclRw11Unit* ptcl, Rw11UnitTerm* pobj) + : fpTcl(ptcl), + fpObj(pobj) +{ + RtclGetList& gets = ptcl->GetList(); + RtclSetList& sets = ptcl->SetList(); + + gets.Add ("channelid", + boost::bind(&Rw11UnitTerm::ChannelId, pobj)); + gets.Add ("rcv7bit", + boost::bind(&Rw11UnitTerm::Rcv7bit, pobj)); + + sets.Add ("rcv7bit", + boost::bind(&Rw11UnitTerm::SetRcv7bit,pobj, _1)); +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +RtclRw11UnitTerm::~RtclRw11UnitTerm() +{} + + +} // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11UnitTerm.hpp b/tools/src/librwxxtpp/RtclRw11UnitTerm.hpp new file mode 100644 index 00000000..75bb9b7d --- /dev/null +++ b/tools/src/librwxxtpp/RtclRw11UnitTerm.hpp @@ -0,0 +1,52 @@ +// $Id: RtclRw11UnitTerm.hpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-03-03 494 1.0 Initial version +// 2013-03-01 493 0.1 First draft +// --------------------------------------------------------------------------- + + +/*! + \file + \version $Id: RtclRw11UnitTerm.hpp 504 2013-04-13 15:37:24Z mueller $ + \brief Declaration of class RtclRw11UnitTerm. +*/ + +#ifndef included_Retro_RtclRw11UnitTerm +#define included_Retro_RtclRw11UnitTerm 1 + +#include "librw11/Rw11UnitTerm.hpp" + +#include "RtclRw11Unit.hpp" + +namespace Retro { + + class RtclRw11UnitTerm { + public: + RtclRw11UnitTerm(RtclRw11Unit* ptcl, Rw11UnitTerm* pobj); + ~RtclRw11UnitTerm(); + + protected: + + protected: + RtclRw11Unit* fpTcl; + Rw11UnitTerm* fpObj; + }; + +} // end namespace Retro + +//#include "RtclRw11UnitTerm.ipp" + +#endif diff --git a/tools/src/librwxxtpp/Rwxxtpp_Init.cpp b/tools/src/librwxxtpp/Rwxxtpp_Init.cpp new file mode 100644 index 00000000..d9e4b28c --- /dev/null +++ b/tools/src/librwxxtpp/Rwxxtpp_Init.cpp @@ -0,0 +1,56 @@ +// $Id: Rwxxtpp_Init.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-10 485 1.0 Initial version +// 2013-01-27 478 0.1 First draft +// --------------------------------------------------------------------------- + +/*! + \file + \version $Id: Rwxxtpp_Init.cpp 504 2013-04-13 15:37:24Z mueller $ + \brief Implemenation of Rwxxtpp_Init . +*/ + +#include "tcl.h" + +#include + +#include "librtcltools/RtclClassOwned.hpp" +#include "RtclRw11.hpp" + +using namespace std; +using namespace Retro; + +//------------------------------------------+----------------------------------- +extern "C" int Rwxxtpp_Init(Tcl_Interp* interp) +{ + int irc; + + // declare package name and version + irc = Tcl_PkgProvide(interp, "rwxxtpp", "1.0.0"); + if (irc != TCL_OK) return irc; + + try { + // register class commands + RtclClassOwned::CreateClass(interp, "rw11", "Rw11"); + return TCL_OK; + + } catch (exception& e) { + Tcl_AppendResult(interp, "-E: exception caught in Rwxxtpp_Init: '", + e.what(), "'", NULL); + } + return TCL_ERROR; +} + diff --git a/tools/src/testtclsh/.cvsignore b/tools/src/testtclsh/.cvsignore new file mode 100644 index 00000000..661be0f4 --- /dev/null +++ b/tools/src/testtclsh/.cvsignore @@ -0,0 +1,2 @@ +*.dep +testtclsh diff --git a/tools/src/testtclsh/Makefile b/tools/src/testtclsh/Makefile new file mode 100644 index 00000000..0c1f02f9 --- /dev/null +++ b/tools/src/testtclsh/Makefile @@ -0,0 +1,47 @@ +# $Id: Makefile 504 2013-04-13 15:37:24Z mueller $ +# +# Revision History: +# Date Rev Version Comment +# 2013-02-10 485 1.0 Initial version +# +# Compile and Link search paths +# +include ../checkpath_cpp.mk +# +INCLFLAGS = -I${TCLINC} -I${RETROBASE}/tools/src +LDLIBS = -ltcl -lreadline +LDLIBS += -L${RETROBASE}/tools/lib -lrtcltools +LDLIBS += -lrutiltpp -lrlinktpp -lrwxxtpp +#LDLIBS += -lrusbtpp +# +# Object files to be included +# +OBJ_all = testtclsh.o +# +DEP_all = $(OBJ_all:.o=.dep) +# +testtclsh : $(OBJ_all) + +#- generic part ---------------------------------------------------------------- +# +include $(RETROBASE)/tools/make/generic_cpp.mk +include $(RETROBASE)/tools/make/generic_dep.mk +include $(RETROBASE)/tools/make/dontincdep.mk +# +# The magic autodependcy include +# +ifndef DONTINCDEP +include $(DEP_all) +endif +# +# cleanup phonies: +# +.PHONY : clean cleandep distclean +clean : + @ rm -f $(OBJ_all) + @ echo "Object files removed" +# +cleandep : + @ rm -f $(DEP_all) + @ echo "Dependency files removed" +# diff --git a/tools/src/testtclsh/testtclsh.cpp b/tools/src/testtclsh/testtclsh.cpp new file mode 100644 index 00000000..09c74570 --- /dev/null +++ b/tools/src/testtclsh/testtclsh.cpp @@ -0,0 +1,68 @@ +// $Id: testtclsh.cpp 504 2013-04-13 15:37:24Z mueller $ +// +// Copyright 2013- by Walter F.J. Mueller +// +// This program is free software; you may redistribute 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 complete details. +// +// Revision History: +// Date Rev Version Comment +// 2013-02-10 485 1.0 Initial version +// --------------------------------------------------------------------------- + +#include +#include +#include +#include + +#include "tcl.h" + +#include + +using namespace std; + +extern "C" int Rutiltpp_Init(Tcl_Interp* interp); +extern "C" int Rlinktpp_Init(Tcl_Interp* interp); +//extern "C" int Rusbtpp_Init(Tcl_Interp* interp); +extern "C" int Rwxxtpp_Init(Tcl_Interp* interp); + +int main(int argc, const char* argv[]) +{ + cout << "testtclsh starting..." << endl; + + Tcl_Interp* interp = Tcl_CreateInterp(); + if (!interp) { + cout << "Tcl_CreateInterp() failed" << endl; + return 1; + } + + Rutiltpp_Init(interp); + Rlinktpp_Init(interp); + // Rusbtpp_Init(interp); + Rwxxtpp_Init(interp); + + char* line; + while ((line = readline("testtclsh> "))) { + if (line[0]!=0) add_history(line); + int rc = Tcl_Eval(interp, line); + if (rc != TCL_OK) { + cout << "command '" << line << "' failed" << endl; + } + const char* res = Tcl_GetStringResult(interp); + if (res && res[0]) + cout << Tcl_GetStringResult(interp) << endl; + free(line); + } + + Tcl_DeleteInterp(interp); + Tcl_Finalize(); + + cout << "testtclsh exit..." << endl; + return 0; +} diff --git a/tools/tbench/test_cp_cpubasics.tcl b/tools/tbench/test_cp_cpubasics.tcl new file mode 100644 index 00000000..8ecadf5e --- /dev/null +++ b/tools/tbench/test_cp_cpubasics.tcl @@ -0,0 +1,64 @@ +# $Id: test_cp_cpubasics.tcl 504 2013-04-13 15:37:24Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test very basic cpu interface gymnastics +# 1. load code via ldasm +# 2. execute code via -start, -stapc, -continue +# 3. single step code via -step +# + +rlc log "test_cp_cpubasics: Test very basic cpu interface gymnastics" +rlc log " load code via lsasm" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: inc r2 + inc r2 + inc r2 + halt +stop: +} + +rlc log " read back and check" +$cpu cp -wal $sym(start) \ + -brm 4 -edata {0005202 0005202 0005202 0000000} + +rlc log " execute via -start" +$cpu cp -wr2 00000 \ + -wpc $sym(start) \ + -start +$cpu wtcpu -reset 1.0 +$cpu cp -rr2 -edata 00003 \ + -rpc -edata $sym(stop) + +rlc log " execute via -stapc" +$cpu cp -wr2 00100 \ + -stapc $sym(start) +$cpu wtcpu -reset 1.0 +$cpu cp -rr2 -edata 00103 \ + -rpc -edata $sym(stop) + +rlc log " execute via -continue" +$cpu cp -wr2 00200 \ + -wpc $sym(start) \ + -continue +$cpu wtcpu -reset 1.0 +$cpu cp -rr2 -edata 00203 \ + -rpc -edata $sym(stop) + +rlc log " execute via -step" +$cpu cp -wr2 00300 \ + -wpc $sym(start) +$cpu cp -step -rpc -edata [expr {$sym(start)+002}] \ + -rr2 -edata 00301 -rstat -edata 000100 +$cpu cp -step -rpc -edata [expr {$sym(start)+004}] \ + -rr2 -edata 00302 -rstat -edata 000100 +$cpu cp -step -rpc -edata [expr {$sym(start)+006}] \ + -rr2 -edata 00303 -rstat -edata 000100 +$cpu cp -step -rpc -edata [expr {$sym(start)+010}] \ + -rr2 -edata 00303 -rstat -edata 000030 diff --git a/tools/tbench/test_cp_gpr.tcl b/tools/tbench/test_cp_gpr.tcl new file mode 100644 index 00000000..a584ee03 --- /dev/null +++ b/tools/tbench/test_cp_gpr.tcl @@ -0,0 +1,63 @@ +# $Id: test_cp_gpr.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test that general purpose registers are writable and readable via cp +# check all 16 registers, especially that +# set 0 and 1 are distinct +# k,s,u mode sp are distinct +# + +rlc log "test_cp_gpr: test cp access to general purpose registers" +rlc log " write set 0" +$cpu cp -wps 0000000 +$cpu cp -wr0 0000001 \ + -wr1 0000101 +$cpu cp -wr2 0000201 \ + -wr3 0000301 +$cpu cp -wr4 0000401 \ + -wr5 0000501 + +rlc log " write set 1" +$cpu cp -wps 0004000 +$cpu cp -wr0 0010001 \ + -wr1 0010101 +$cpu cp -wr2 0010201 \ + -wr3 0010301 +$cpu cp -wr4 0010401 \ + -wr5 0010501 + +rlc log " write all sp and pc" +$cpu cp -wps 0000000 -wsp 0000601; # ksp +$cpu cp -wps 0040000 -wsp 0010601; # ssp +$cpu cp -wps 0140000 -wsp 0020601; # usp +$cpu cp -wps 0000000 -wpc 0000701; # pc + +rlc log " read set 0" +$cpu cp -wps 0000000; # set 0 +$cpu cp -rr0 -edata 0000001 \ + -rr1 -edata 0000101 +$cpu cp -rr2 -edata 0000201 \ + -rr3 -edata 0000301 +$cpu cp -rr4 -edata 0000401 \ + -rr5 -edata 0000501 + +rlc log " read set 1" +$cpu cp -wps 0004000; # set 1 +$cpu cp -rr0 -edata 0010001 \ + -rr1 -edata 0010101 +$cpu cp -rr2 -edata 0010201 \ + -rr3 -edata 0010301 +$cpu cp -rr4 -edata 0010401 \ + -rr5 -edata 0010501 + +rlc log " read all sp and pc" +$cpu cp -wps 0000000 -rsp -edata 0000601; # ksp +$cpu cp -wps 0040000 -rsp -edata 0010601; # ssp +$cpu cp -wps 0140000 -rsp -edata 0020601; # usp +$cpu cp -wps 0000000 -rpc -edata 0000701; # pc diff --git a/tools/tbench/test_cp_psw.tcl b/tools/tbench/test_cp_psw.tcl new file mode 100644 index 00000000..e2ea962b --- /dev/null +++ b/tools/tbench/test_cp_psw.tcl @@ -0,0 +1,49 @@ +# $Id: test_cp_psw.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test that psw is writable and readable via various ways +# 1. direct cp access +# 2. via 16bit memory addressing +# 3. via 22bit memory addressing +# 4. via ibr mapping +# +# This test not only verifies psw, but also all basic access methods +# + +rlc log "test_cp_psw: test psw access via all methods" +rlc log " write/read via cp" +foreach w { 000000 000017 } { + $cpu cp -wps $w \ + -rps -edata $w +} + +rlc log " write/read via 16bit cp addressing" +$cpu cp -wal 0177776 +foreach w { 000000 000017 } { + $cpu cp -wm $w \ + -rm -edata $w \ + -rps -edata $w +} + +rlc log " write/read via 22bit cp addressing" +$cpu cp -wal 0177776 -wah 000177 +foreach w { 000000 000017 } { + $cpu cp -wm $w \ + -rm -edata $w \ + -rps -edata $w +} + +rlc log " write/read via ibr window" +$cpu cp -wibrb 0177700 \ + -ribrb -edata 0017700 +foreach w { 000000 000017 } { + $cpu cp -wibr 076 $w \ + -ribr 076 -edata $w \ + -rps -edata $w +} diff --git a/tools/tbench/test_w11a_dsta_flow.tcl b/tools/tbench/test_w11a_dsta_flow.tcl new file mode 100644 index 00000000..81fa87d8 --- /dev/null +++ b/tools/tbench/test_w11a_dsta_flow.tcl @@ -0,0 +1,124 @@ +# $Id: test_w11a_dsta_flow.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test dsta flow with jsr pc,... instructions +# + +rlc log "test_w11a_dsta_flow: test dsta flow with jsr pc,..." +rlc log " (r0),(r0)+,@(r0)+,-(r0),@-(r0) (mode=1,2,3,4,5)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: jsr pc,(r0) +100$: jsr pc,(r1)+ +110$: jsr pc,@(r2)+ +120$: jsr pc,@(r2)+ +121$: jsr pc,-(r3) +130$: jsr pc,@-(r4) +140$: jsr pc,@-(r4) +141$: halt +stop: +psub2: .word sub20, sub21 +psub4: .word sub41, sub40 +psub4e: +sub00: mov #100,(r5)+ + mov (sp),(r5)+ + rts pc +sub10: mov #110,(r5)+ + mov (sp),(r5)+ + rts pc +sub20: mov #120,(r5)+ + mov (sp),(r5)+ + rts pc +sub21: mov #121,(r5)+ + mov (sp),(r5)+ + rts pc +sub30: mov #130,(r5)+ + mov (sp),(r5)+ + rts pc +sub40: mov #140,(r5)+ + mov (sp),(r5)+ + rts pc +sub41: mov #141,(r5)+ + mov (sp),(r5)+ + rts pc +data: .blkw 2*7. + .word 177777 +} + +rw11a::asmrun $cpu sym [list r0 $sym(sub00) \ + r1 $sym(sub10) \ + r2 $sym(psub2) \ + r3 [expr {$sym(sub30)+2}] \ + r4 $sym(psub4e) \ + r5 $sym(data) ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 $sym(sub00) \ + r1 [expr {$sym(sub10)+2}] \ + r2 [expr {$sym(psub2)+4}] \ + r3 $sym(sub30) \ + r4 $sym(psub4) \ + r5 [expr {$sym(data) + 7*2*2}] ] +rw11a::asmtmem $cpu $sym(data) [list \ + 0100 $sym(start:100$) \ + 0110 $sym(start:110$) \ + 0120 $sym(start:120$) \ + 0121 $sym(start:121$) \ + 0130 $sym(start:130$) \ + 0140 $sym(start:140$) \ + 0141 $sym(start:141$) \ + 0177777 ] + +rlc log " nn(r0),@nn(r0),var,@var,@#var (mode=6,7,67,77,37)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: jsr pc,20(r0) +1100$: jsr pc,@40(r1) +1110$: jsr pc,sub20 +1120$: jsr pc,@psub30 +1130$: jsr pc,@#sub40 +1140$: halt +stop: +psub10: .word sub10 +psub30: .word sub30 +sub00: mov #1100,(r5)+ + mov (sp),(r5)+ + rts pc +sub10: mov #1110,(r5)+ + mov (sp),(r5)+ + rts pc +sub20: mov #1120,(r5)+ + mov (sp),(r5)+ + rts pc +sub30: mov #1130,(r5)+ + mov (sp),(r5)+ + rts pc +sub40: mov #1140,(r5)+ + mov (sp),(r5)+ + rts pc +data: .blkw 2*5. + .word 177777 +} + +rw11a::asmrun $cpu sym [list r0 [expr {$sym(sub00)-020}] \ + r1 [expr {$sym(psub10)-040}] \ + r5 $sym(data) ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 [expr {$sym(sub00)-020}] \ + r1 [expr {$sym(psub10)-040}] \ + r2 0 \ + r3 0 \ + r4 0 \ + r5 [expr {$sym(data) + 5*2*2}] ] +rw11a::asmtmem $cpu $sym(data) [list \ + 01100 $sym(start:1100$) \ + 01110 $sym(start:1110$) \ + 01120 $sym(start:1120$) \ + 01130 $sym(start:1130$) \ + 01140 $sym(start:1140$) \ + 0177777 ] diff --git a/tools/tbench/test_w11a_dstm_word_flow.tcl b/tools/tbench/test_w11a_dstm_word_flow.tcl new file mode 100644 index 00000000..e62d3278 --- /dev/null +++ b/tools/tbench/test_w11a_dstm_word_flow.tcl @@ -0,0 +1,80 @@ +# $Id: test_w11a_dstm_word_flow.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test dstm flow with inc ... instructions for word access +# + +rlc log "test_w11a_dstm_word_flow: test dstm flow for word with inc ..." +rlc log " r0,(r0),(r0)+,@(r0)+,-(r0),@-(r0) (mode=0,1,2,3,4,5)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: inc r0 + inc (r1) + inc (r2)+ + inc (r2)+ + inc @(r3)+ + inc @(r3)+ + inc -(r4) + inc -(r4) + inc @-(r5) + inc @-(r5) + halt +stop: +data1: .word 20 +data2: .word 30,31 +data3: .word 40,41 +data4: .word 50,51 +data4e: +data5: .word 60,61 +data5e: +pdata3: .word data3,data3+2 +pdata5: .word data5,data5+2 +pdat5e: +} + +rw11a::asmrun $cpu sym [list r0 010 \ + r1 $sym(data1) \ + r2 $sym(data2) \ + r3 $sym(pdata3) \ + r4 $sym(data4e) \ + r5 $sym(pdat5e) ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 011 \ + r1 $sym(data1) \ + r2 [expr {$sym(data2) + 4}] \ + r3 [expr {$sym(pdata3) + 4}] \ + r4 [expr {$sym(data4e) - 4}] \ + r5 [expr {$sym(pdat5e) - 4}] ] +rw11a::asmtmem $cpu $sym(data1) {021 031 032 041 042 051 052 061 062} + + +rlc log " nn(r0),@nn(r0),var,@var,@#var (mode=6,7,67,77,37)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: inc 20(r0) + inc @40(r1) + inc data2 + inc @pdata3 + inc @#data4 + halt +stop: +data0: .word 200 +data1: .word 210 +data2: .word 220 +data3: .word 230 +data4: .word 240 +data4e: +pdata1: .word data1 +pdata3: .word data3 +} + +rw11a::asmrun $cpu sym [list r0 [expr {$sym(data0)-020}] \ + r1 [expr {$sym(pdata1)-040}] ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtmem $cpu $sym(data0) {0201 0211 0221 0231 0241} diff --git a/tools/tbench/test_w11a_dstw_word_flow.tcl b/tools/tbench/test_w11a_dstw_word_flow.tcl new file mode 100644 index 00000000..a87c2afe --- /dev/null +++ b/tools/tbench/test_w11a_dstw_word_flow.tcl @@ -0,0 +1,80 @@ +# $Id: test_w11a_dstw_word_flow.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test dstw flow with mov #nnn,... instructions for word access +# + +rlc log "test_w11a_dstw_word_flow: test dstw flow for word with mov #nnn,..." +rlc log " r0,(r0),(r0)+,@(r0)+,-(r0),@-(r0) (mode=0,1,2,3,4,5)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov #100,r0 + mov #110,(r1) + mov #120,(r2)+ + mov #121,(r2)+ + mov #130,@(r3)+ + mov #131,@(r3)+ + mov #141,-(r4) + mov #140,-(r4) + mov #151,@-(r5) + mov #150,@-(r5) + halt +stop: +data1: .word 0 +data2: .word 0,0 +data3: .word 0,0 +data4: .word 0,0 +data4e: +data5: .word 0,0 +data5e: +pdata3: .word data3,data3+2 +pdata5: .word data5,data5+2 +pdat5e: +} + +rw11a::asmrun $cpu sym [list r1 $sym(data1) \ + r2 $sym(data2) \ + r3 $sym(pdata3) \ + r4 $sym(data4e) \ + r5 $sym(pdat5e) ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 0100 \ + r1 $sym(data1) \ + r2 [expr {$sym(data2) + 4}] \ + r3 [expr {$sym(pdata3) + 4}] \ + r4 [expr {$sym(data4e) - 4}] \ + r5 [expr {$sym(pdat5e) - 4}] ] +rw11a::asmtmem $cpu $sym(data1) {0110 0120 0121 0130 0131 0140 0141 0150 0151} + + + +rlc log " nn(r0),@nn(r0),var,@var,@#var (mode=6,7,67,77,37)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov #200,20(r0) + mov #210,@40(r1) + mov #220,data2 + mov #230,@pdata3 + mov #240,@#data4 + halt +stop: +data0: .word 0 +data1: .word 0 +data2: .word 0 +data3: .word 0 +data4: .word 0 +data4e: +pdata1: .word data1 +pdata3: .word data3 +} + +rw11a::asmrun $cpu sym [list r0 [expr {$sym(data0)-020}] \ + r1 [expr {$sym(pdata1)-040}] ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtmem $cpu $sym(data0) {0200 0210 0220 0230 0240} diff --git a/tools/tbench/test_w11a_inst_traps.tcl b/tools/tbench/test_w11a_inst_traps.tcl new file mode 100644 index 00000000..e607a17a --- /dev/null +++ b/tools/tbench/test_w11a_inst_traps.tcl @@ -0,0 +1,78 @@ +# $Id: test_w11a_inst_traps.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-04-01 502 1.0 Initial version +# +# Test trap type instructions: bpt,iot, emt nn, trap nn +# + +rlc log "test_w11a_inst_traps: test trap type instructions" +$cpu ldasm -lst lst -sym sym { + . = 14 + .word h.bpt ; vec 14: bpt + .word 340 + .word h.iot ; vec 20: iot + .word 341 + . = 30 + .word h.emt ; vec 30: emt + .word 342 + .word h.trp ; vec 34: trap + .word 343 +; + psw = 177776 +; + . = 1000 +start: mov #350,@#psw + bpt +350$: mov #351,@#psw + iot +351$: mov #352,@#psw + emt 100 +352$: mov #353,@#psw + emt 200 +353$: mov #354,@#psw + trap 10 +354$: mov #355,@#psw + trap 20 +355$: halt +stop: +; +h.bpt: mov @#psw,(r5)+ + mov #1014,(r5)+ + br iexit +h.iot: mov @#psw,(r5)+ + mov #1020,(r5)+ + br iexit +h.emt: mov @#psw,(r5)+ + mov #1030,(r5)+ + br iexit +h.trp: mov @#psw,(r5)+ + mov #1034,(r5)+ +; +iexit: mov (sp),r4 + mov r4,(r5)+ + mov 2(sp),(r5)+ + mov -2(r4),(r5)+ + rti +data: .blkw 6.*5. + .word 177777 +} + +rw11a::asmrun $cpu sym [list r5 $sym(data) ] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 0 r1 0 r2 0 r3 0 \ + r5 [expr {$sym(data) + 6*5*2}] \ + sp $sym(start) ] +# data: trap ps; trap id; stack-pc; stack-ps opcode +rw11a::asmtmem $cpu $sym(data) \ + [list 000340 001014 $sym(start:350$) 000350 0000003 \ + 000341 001020 $sym(start:351$) 000351 0000004 \ + 000342 001030 $sym(start:352$) 000352 0104100 \ + 000342 001030 $sym(start:353$) 000353 0104200 \ + 000343 001034 $sym(start:354$) 000354 0104410 \ + 000343 001034 $sym(start:355$) 000355 0104420 \ + 0177777 ] diff --git a/tools/tbench/test_w11a_srcr_word_flow.tcl b/tools/tbench/test_w11a_srcr_word_flow.tcl new file mode 100644 index 00000000..1dbd3200 --- /dev/null +++ b/tools/tbench/test_w11a_srcr_word_flow.tcl @@ -0,0 +1,134 @@ +# $Id: test_w11a_srcr_word_flow.tcl 502 2013-04-02 19:29:30Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory +# +# Revision History: +# Date Rev Version Comment +# 2013-03-31 502 1.0 Initial version +# +# Test srcr flow with mov ...,rx instructions for word access +# + +rlc log "test_w11a_srcr_word_flow: test srcr flow for word with mov ...,rx" +rlc log " r0 (mode=0)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +stack: +start: mov r0,r1 + mov sp,r2 + mov pc,r3 +lpc: halt +stop: +} + +rw11a::asmrun $cpu sym [list r0 01234] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 01234 \ + r1 01234 \ + r2 $sym(stack) \ + r3 $sym(lpc) \ + r4 0 \ + r5 0] + +rlc log " (r0),(r0)+,-(r0) (mode=1,2,4)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov (r0),r1 + mov (r0)+,r2 + mov (r0)+,r3 + mov -(r0),r4 + mov -(r0),r5 + halt +stop: +data: .word 1001 + .word 1002 +} + +rw11a::asmrun $cpu sym [list r0 $sym(data)] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 $sym(data) \ + r1 001001 \ + r2 001001 \ + r3 001002 \ + r4 001002 \ + r5 001001] + +rlc log " @(r0)+,@-(r0) (mode=3,5)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov @(r0)+,r1 + mov @(r0)+,r2 + mov r0,r3 + mov @-(r0),r4 + mov @-(r0),r5 + halt +stop: +pdata: .word data0 + .word data1 +data0: .word 2001 + .word 0 +data1: .word 2002 +} + +rw11a::asmrun $cpu sym [list r0 $sym(pdata)] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 $sym(pdata) \ + r1 002001 \ + r2 002002 \ + r3 [expr {$sym(pdata)+4}] \ + r4 002002 \ + r5 002001] + +rlc log " nn(r0),@nn(r0) (mode=6,7)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov 2(r0),r1 + mov @4(r0),r2 + mov 6(r0),r3 + mov @10(r0),r4 + halt +stop: +data: .word 177777 + .word 003001 + .word data0 + .word 003003 + .word data1 + +data0: .word 003002 +data1: .word 003004 +} + +rw11a::asmrun $cpu sym [list r0 $sym(data)] +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 $sym(data) \ + r1 003001 \ + r2 003002 \ + r3 003003 \ + r4 003004 \ + r5 0] + +rlc log " #nn,@#nn,var,@var (mode=27,37,67,77)" +$cpu ldasm -lst lst -sym sym { + . = 1000 +start: mov #004001,r1 + mov @#data2,r2 + mov data3,r3 + mov @pdata4,r4 + halt +stop: +pdata4: .word data4 + +data2: .word 004002 +data3: .word 004003 +data4: .word 004004 +} + +rw11a::asmrun $cpu sym {} +rw11a::asmwait $cpu sym 1.0 +rw11a::asmtreg $cpu [list r0 0 \ + r1 004001 \ + r2 004002 \ + r3 004003 \ + r4 004004 \ + r5 0] diff --git a/tools/tbench/w11a_all.dat b/tools/tbench/w11a_all.dat new file mode 100644 index 00000000..ce65d4b8 --- /dev/null +++ b/tools/tbench/w11a_all.dat @@ -0,0 +1,12 @@ +# $Id: w11a_all.dat 504 2013-04-13 15:37:24Z mueller $ +# +## steering file for all w11a tests +# +test_cp_gpr.tcl +test_cp_psw.tcl +test_cp_cpubasics.tcl +test_w11a_srcr_word_flow.tcl +test_w11a_dstw_word_flow.tcl +test_w11a_dstm_word_flow.tcl +test_w11a_dsta_flow.tcl +test_w11a_inst_traps.tcl diff --git a/tools/tcl/rutil/util.tcl b/tools/tcl/rutil/util.tcl index 01f3f6dc..2b9825cf 100644 --- a/tools/tcl/rutil/util.tcl +++ b/tools/tcl/rutil/util.tcl @@ -1,4 +1,4 @@ -# $Id: util.tcl 375 2011-04-02 07:56:47Z mueller $ +# $Id: util.tcl 502 2013-04-02 19:29:30Z mueller $ # # Copyright 2011- by Walter F.J. Mueller # @@ -64,7 +64,7 @@ namespace eval rutil { } # - # regdsc_print: print regsiter descriptor + # regdsc_print: print register descriptor # proc regdsc_print {name} { upvar $name rdsc diff --git a/tools/tcl/rw11a/.cvsignore b/tools/tcl/rw11a/.cvsignore new file mode 100644 index 00000000..fc959ab2 --- /dev/null +++ b/tools/tcl/rw11a/.cvsignore @@ -0,0 +1 @@ +pkgIndex.tcl diff --git a/tools/tcl/rw11a/util.tcl b/tools/tcl/rw11a/util.tcl new file mode 100644 index 00000000..e29d0fcf --- /dev/null +++ b/tools/tcl/rw11a/util.tcl @@ -0,0 +1,201 @@ +# $Id: util.tcl 504 2013-04-13 15:37:24Z mueller $ +# +# Copyright 2013- by Walter F.J. Mueller +# +# This program is free software; you may redistribute 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 complete details. +# +# Revision History: +# Date Rev Version Comment +# 2013-04-13 504 1.1.1 add tbench* procs +# 2013-04-01 501 1.1 add regdsc's and asm* procs +# 2013-02-02 380 1.0 Initial version +# + +package provide rw11a 1.0 + +package require rlink +package require rwxxtpp + +namespace eval rw11a { + # + # setup cp interface register descriptions for w11a + # + regdsc CP_CNTL {func 3 0} + regdsc CP_STAT {rust 7 4} {halt 3} {go 2} {merr 1} {err 0} + regdsc CP_IBRB {base 12 7} {bw 1 2} + # + # setup w11a register descriptions + # + regdsc PSW {cmode 15 2} {pmode 13 2} {rset 11} {pri 7 3} {tflag 3} {cc 3 4} + + # + # setup_cpu: create w11 cpu system + # + proc setup_cpu {} { + rlc config -basestat 2 -baseaddr 8 -basedata 8 + rw11 rlw rls w11a 1 + return "" + } + + # + # setup_sys: create full system + # + proc setup_sys {} { + if {[info commands rlw] eq ""} { + setup_cpu + } + cpu0 add dl11 + rlw start + return "" + } + + # + # init: reset w11a + # + proc init {} { + # rlc exec -wreg br.cntl 0x0000 + } + + # + # asmrun: run a program loaded with ldasm + # + proc asmrun {cpu symName opts} { + upvar 1 $symName sym + array set defs {r0 0 r1 0 r2 0 r3 0 r4 0 r5 0} + array set defs $opts + + if {![info exists defs(pc)]} { + if {[info exists sym(start)]} { + set defs(pc) $sym(start) + } else { + error "neither opts(pc) nor sym(start) given" + } + } + + if {![info exists defs(sp)]} { + if {[info exists sym(stack)]} { + set defs(sp) $sym(stack) + } elseif {[info exists sym(start)]} { + set defs(sp) $sym(start) + } else { + error "neither opts(sp) nor sym(stack) or sym(start) given" + } + } + + $cpu cp -wr0 $defs(r0) \ + -wr1 $defs(r1) \ + -wr2 $defs(r2) \ + -wr3 $defs(r3) \ + -wr4 $defs(r4) \ + -wr5 $defs(r5) + + $cpu cp -wsp $defs(sp) \ + -stapc $defs(pc) + + return "" + } + + # + # asmwait: wait for completion of a program loaded with ldasm + # + proc asmwait {cpu symName {tout 10.}} { + upvar 1 $symName sym + set dt [$cpu wtcpu -reset $tout] + if {$dt >= 0 && [info exists $sym(stop)]} { + $cpu cp -rpc -edata $sym(stop) + } + return $dt + } + + # + # asmtreg: test registers after running a program loaded with ldasm + # + proc asmtreg {cpu opts} { + array set defs $opts + set cpcmd "" + foreach key [lsort [array names defs]] { + append cpcmd " -r$key -edata $defs($key)" + } + eval $cpu cp $cpcmd + return "" + } + + # + # asmtmem: test memory after running a program loaded with ldasm + # + proc asmtmem {cpu base list} { + set nw [llength $list] + if {$nw == 0} { + error "asmtreg called with empty list" + } + $cpu cp -wal $base -brm $nw -edata $list + return "" + } + + # + # tbench: driver for tbench scripts + # + proc tbench {fname} { + rlc exec -init 0xff [regbld rlink::INIT anena] + set errcnt [tbench_list $fname] + return $errcnt + } + + # + # tbench_file: execute list of tbench steps + # + proc tbench_list {lname} { + set errcnt 0 + if {[string match "@*" $lname]} { + set fname [string range $lname 1 end] + set fh [open "$::env(RETROBASE)/tools/tbench/$fname"] + while {[gets $fh line] >= 0} { + if {[string match "#*" $line]} { + if {[string match "##*" $line]} { puts $line } + } elseif {[string match "@*" $line]} { + incr errcnt [tbench_list $line] + } else { + incr errcnt [tbench_step $line] + } + } + close $fh + } else { + incr errcnt [tbench_step $lname] + } + puts [format "%s: %s" $lname [rutil::errcnt2txt $errcnt]] + return $errcnt + } + + # + # tbench_step: execute single tbench step + # + proc tbench_step {fname} { + rlc errcnt -clear + set cpu cpu0 + source "$::env(RETROBASE)/tools/tbench/$fname" + set errcnt [rlc errcnt] + puts [format "%s: %s" $fname [rutil::errcnt2txt $errcnt]] + return $errcnt + } + + # + # run_pdpcp: execute pdpcp type command file + # + proc run_pdpcp {fname {cpu "cpu0"}} { + rlc errcnt -clear + set code [exec ticonv_pdpcp $cpu $fname] + eval $code + set errcnt [rlc errcnt] + if { $errcnt } { + puts [format "run_pdpcp: FAIL after %d errors" $errcnt] + } + return $errcnt + } +} diff --git a/tools/tcl/setup_packages b/tools/tcl/setup_packages index 2b3c13b8..a352c982 100755 --- a/tools/tcl/setup_packages +++ b/tools/tcl/setup_packages @@ -1,5 +1,5 @@ #! /usr/bin/env tclsh -# $Id: setup_packages 445 2011-12-26 21:19:26Z mueller $ +# $Id: setup_packages 480 2013-02-03 10:11:02Z mueller $ # pkg_mkIndex -verbose ../lib libr*tpp.so # @@ -11,4 +11,6 @@ pkg_mkIndex -verbose rbbram *.tcl pkg_mkIndex -verbose rbs3hio *.tcl pkg_mkIndex -verbose rbemon *.tcl # +pkg_mkIndex -verbose rw11a *.tcl +# pkg_mkIndex -verbose tst_rlink *.tcl