]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
backporting uart_i and cli
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 29 Jul 2009 09:49:57 +0000 (09:49 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 29 Jul 2009 09:49:57 +0000 (09:49 +0000)
126 files changed:
AVR-Crypto-Lib-logo+text.svg [new file with mode: 0644]
AVR-Crypto-Lib-logo.svg [new file with mode: 0644]
Makefile
avr-makefile.inc
camellia128-stub.c
camellia_C.c
cast5.c
cast6.c
config.h
des.c
md5.c
mkfiles/001_cli_std.mk
mkfiles/a5_1.mk
mkfiles/aes.mk
mkfiles/aes_asm_faster.mk
mkfiles/aes_c.mk
mkfiles/arcfour.mk
mkfiles/arcfour_c.mk
mkfiles/base64.mk
mkfiles/camellia.mk
mkfiles/cast5.mk
mkfiles/cast6.mk
mkfiles/des.mk
mkfiles/entropium.mk
mkfiles/grain.mk
mkfiles/hmac-md5.mk
mkfiles/hmac-sha1.mk
mkfiles/hmac-sha256.mk
mkfiles/mickey128.mk
mkfiles/mugi.mk
mkfiles/noekeon.mk
mkfiles/noekeon_c.mk
mkfiles/omac_noekeon.mk
mkfiles/omac_noekeon_c.mk
mkfiles/present.mk
mkfiles/rc5.mk
mkfiles/rc6.mk
mkfiles/seed.mk
mkfiles/seed_C.mk
mkfiles/serpent-bitslice.mk
mkfiles/serpent_asm_bitslice.mk
mkfiles/serpent_asm_fast.mk
mkfiles/serpent_asm_small.mk
mkfiles/serpent_c.mk
mkfiles/sha1.mk
mkfiles/sha1_c.mk
mkfiles/sha256.mk
mkfiles/sha256_c.mk
mkfiles/shabea.mk
mkfiles/shacal1enc.mk
mkfiles/shacal2enc.mk
mkfiles/skipjack.mk
mkfiles/tdes.mk
mkfiles/threefish.mk
mkfiles/trivium.mk
mkfiles/ubi.mk
mkfiles/xtea.mk
mkfiles/xtea_c.mk
noekeon.c
seed_C.c
sha1.c
test_src/circularbytebuffer-asm.S [new file with mode: 0644]
test_src/circularbytebuffer.h [new file with mode: 0644]
test_src/cli-basics.S [new file with mode: 0644]
test_src/cli-core.S [new file with mode: 0644]
test_src/cli-hexdump.S [new file with mode: 0644]
test_src/cli-stub.c [new file with mode: 0644]
test_src/cli.c [deleted file]
test_src/debug.c
test_src/dump-asm.S [new file with mode: 0644]
test_src/dump-decl.c [new file with mode: 0644]
test_src/dump.c [deleted file]
test_src/main-a5_1-test.c
test_src/main-aes-test.c
test_src/main-aes128-test.c
test_src/main-aes192-test.c
test_src/main-aes256-test.c
test_src/main-arcfour-test.c
test_src/main-base64-test.c
test_src/main-blake-test.c
test_src/main-bmw-test.c
test_src/main-camellia-test.c
test_src/main-cast5-test.c
test_src/main-cast6-test.c
test_src/main-des-test.c
test_src/main-entropium-test.c
test_src/main-grain-test.c
test_src/main-groestl-test.c
test_src/main-hmac-md5-test.c
test_src/main-hmac-sha1-test.c
test_src/main-hmac-sha256-test.c
test_src/main-md5-test.c
test_src/main-mickey128-test.c
test_src/main-mugi-test.c
test_src/main-noekeon-test.c
test_src/main-omac-noekeon-test.c
test_src/main-present-test.c
test_src/main-rc5-test.c
test_src/main-rc6-test.c
test_src/main-seed-test.c
test_src/main-serpent-test.c
test_src/main-sha1-test.c
test_src/main-sha256-test.c
test_src/main-shabal-test.c
test_src/main-shabea-test.c
test_src/main-shacal1_enc-test.c
test_src/main-shacal2_enc-test.c
test_src/main-skein-test.c
test_src/main-skipjack-test.c
test_src/main-tdes-test.c
test_src/main-threefish-test.c
test_src/main-trivium-test.c
test_src/main-twister-test.c
test_src/main-ubi-test.c
test_src/main-xtea-test.c
test_src/nessie_bc_test.c
test_src/nessie_mac_test.c
test_src/nessie_stream_test.c
test_src/performance_test.c
test_src/serial-tools.c
test_src/string-extras-asm.S [new file with mode: 0644]
test_src/string-extras.h [new file with mode: 0644]
test_src/uart.c [deleted file]
test_src/uart_defs.h [new file with mode: 0644]
test_src/uart_i-asm.S [new file with mode: 0644]
test_src/uart_i.h [new file with mode: 0644]

diff --git a/AVR-Crypto-Lib-logo+text.svg b/AVR-Crypto-Lib-logo+text.svg
new file mode 100644 (file)
index 0000000..e140390
--- /dev/null
@@ -0,0 +1,453 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   sodipodi:docname="uC-Crypto-logo+text.svg"
+   height="60.0000000"
+   sodipodi:version="0.32"
+   width="60.0000000"
+   _SVGFile__filename="scalable/apps/kgpg.svg"
+   version="1.0"
+   y="0"
+   x="0"
+   inkscape:version="0.46"
+   id="svg1"
+   sodipodi:docbase="/home/bg/workspace/micro-crypt"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/home/bg/workspace/micro-crypt/uC-Crypto-logo.png"
+   inkscape:export-xdpi="299.73813"
+   inkscape:export-ydpi="299.73813">
+  <sodipodi:namedview
+     bordercolor="#666666"
+     inkscape:pageshadow="2"
+     inkscape:window-y="-1"
+     pagecolor="#ffffff"
+     inkscape:window-height="580"
+     inkscape:zoom="1.7366334"
+     inkscape:window-x="1"
+     borderopacity="1.0"
+     inkscape:cx="179.69675"
+     inkscape:cy="27.879071"
+     inkscape:window-width="1022"
+     inkscape:pageopacity="0.0"
+     id="base"
+     inkscape:current-layer="svg1"
+     showgrid="false" />
+  <defs
+     id="defs3">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 30 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="60 : 30 : 1"
+       inkscape:persp3d-origin="30 : 20 : 1"
+       id="perspective37" />
+  </defs>
+  <g
+     id="g1554"
+     transform="translate(0.230915,-0.235226)"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160">
+    <path
+       sodipodi:nodetypes="ccc"
+       style="font-size:12.000000;fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#333333;stroke-width:5.0000000;stroke-miterlimit:4.0000000;"
+       d="M 12.986483,29.403286 C 15.818301,17.671464 20.875121,5.3328238 31.191034,5.5350970 C 41.304673,5.5350974 45.147854,18.885102 47.372855,29.605558"
+       sodipodi:stroke-cmyk="(0 0 0 0.8)"
+       id="path612" />
+    <path
+       style="font-size:12.000000;fill:#cccccc;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#333333;stroke-width:3.1250000;stroke-linejoin:round;"
+       d="M 9.8122082,28.265654 C 8.7042082,28.265654 7.8122082,29.157654 7.8122082,30.265654 L 7.8122082,53.817583 C 7.8122082,54.925583 8.7042082,55.817583 9.8122082,55.817583 L 50.547129,55.817583 C 51.655129,55.817583 52.547129,54.925583 52.547129,53.817583 L 52.547129,30.265654 C 52.547129,29.157654 51.655129,28.265654 50.547129,28.265654 L 9.8122082,28.265654 z "
+       id="rect611" />
+  </g>
+  <metadata
+     id="metadata6">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:title>Part of the Flat Icon Collection (Thu Aug 26 14:31:40 2004)</dc:title>
+        <dc:description />
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li />
+          </rdf:Bag>
+        </dc:subject>
+        <dc:publisher>
+          <cc:Agent
+             rdf:about="">
+            <dc:title />
+          </cc:Agent>
+        </dc:publisher>
+        <dc:creator>
+          <cc:Agent
+             rdf:about="">
+            <dc:title>Danny Allen</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:rights>
+          <cc:Agent
+             rdf:about="">
+            <dc:title>Danny Allen</dc:title>
+          </cc:Agent>
+        </dc:rights>
+        <dc:date />
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/LGPL/2.1/">
+          <dc:date />
+        </cc:license>
+        <dc:language>en</dc:language>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4208"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="22.392134"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4210"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958696"
+     x="25.205595"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4212"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="28.039183"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4214"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="30.862715"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4216"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="30.059542"
+     x="33.676201"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <a
+     id="a2680"
+     transform="matrix(1.0764385,0,0,1.0764386,-3.9678317,-2.8218674)"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160">
+    <rect
+       x="22.957844"
+       y="-49.865311"
+       ry="0.50752664"
+       style="fill:#c0c0c0;fill-opacity:0;stroke:#000000;stroke-width:0.26633105;stroke-opacity:1"
+       rx="0.60646188"
+       id="rect4218"
+       width="16.989586"
+       transform="scale(1,-1)"
+       height="16.91943" />
+  </a>
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4220"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958696"
+     x="36.489658"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4222"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136734"
+     x="-46.626415"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4224"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-35.312218"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4226"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-38.135746"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4228"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-40.959274"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4230"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-43.782803"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4232"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-49.429836"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4234"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="22.412243"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4236"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="25.225708"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4238"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="28.059299"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4240"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="30.88283"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4242"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="33.686245"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4244"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="36.509773"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4246"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313171"
+     x="-46.626415"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4248"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-35.312218"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4250"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-38.135746"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4252"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-40.959274"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4254"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-43.782803"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4256"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-49.429836"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160" />
+  <text
+     xml:space="preserve"
+     style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans Mono"
+     x="22.675781"
+     y="45.092186"
+     id="text2683"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160"><tspan
+       sodipodi:role="line"
+       id="tspan2685"
+       x="22.675781"
+       y="45.092186">µC</tspan></text>
+  <text
+     xml:space="preserve"
+     style="font-size:40px;font-style:normal;font-weight:bold;text-align:start;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans"
+     x="65.350945"
+     y="47.988457"
+     id="text2410"
+     inkscape:export-filename="/home/bg/workspace/micro-crypt/logo+text.png"
+     inkscape:export-xdpi="160"
+     inkscape:export-ydpi="160"><tspan
+       sodipodi:role="line"
+       id="tspan2412"
+       x="65.350945"
+       y="47.988457">AVR-Crypto-Lib</tspan></text>
+</svg>
diff --git a/AVR-Crypto-Lib-logo.svg b/AVR-Crypto-Lib-logo.svg
new file mode 100644 (file)
index 0000000..bb90e43
--- /dev/null
@@ -0,0 +1,350 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   sodipodi:docname="uC-Crypto-logo.svg"
+   height="60.0000000"
+   sodipodi:version="0.32"
+   width="60.0000000"
+   _SVGFile__filename="scalable/apps/kgpg.svg"
+   version="1.0"
+   y="0"
+   x="0"
+   inkscape:version="0.45.1"
+   id="svg1"
+   sodipodi:docbase="/home/bg/workspace/micro-crypt"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/home/bg/workspace/micro-crypt/uC-Crypto-logo.png"
+   inkscape:export-xdpi="299.73813"
+   inkscape:export-ydpi="299.73813">
+  <sodipodi:namedview
+     bordercolor="#666666"
+     inkscape:pageshadow="2"
+     inkscape:window-y="0"
+     pagecolor="#ffffff"
+     inkscape:window-height="580"
+     inkscape:zoom="4.9119411"
+     inkscape:window-x="0"
+     borderopacity="1.0"
+     inkscape:cx="33.667126"
+     inkscape:cy="27.879071"
+     inkscape:window-width="1022"
+     inkscape:pageopacity="0.0"
+     id="base"
+     inkscape:current-layer="svg1" />
+  <defs
+     id="defs3" />
+  <g
+     id="g1554"
+     transform="translate(0.230915,-0.235226)">
+    <path
+       sodipodi:nodetypes="ccc"
+       style="font-size:12.000000;fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#333333;stroke-width:5.0000000;stroke-miterlimit:4.0000000;"
+       d="M 12.986483,29.403286 C 15.818301,17.671464 20.875121,5.3328238 31.191034,5.5350970 C 41.304673,5.5350974 45.147854,18.885102 47.372855,29.605558"
+       sodipodi:stroke-cmyk="(0 0 0 0.8)"
+       id="path612" />
+    <path
+       style="font-size:12.000000;fill:#cccccc;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#333333;stroke-width:3.1250000;stroke-linejoin:round;"
+       d="M 9.8122082,28.265654 C 8.7042082,28.265654 7.8122082,29.157654 7.8122082,30.265654 L 7.8122082,53.817583 C 7.8122082,54.925583 8.7042082,55.817583 9.8122082,55.817583 L 50.547129,55.817583 C 51.655129,55.817583 52.547129,54.925583 52.547129,53.817583 L 52.547129,30.265654 C 52.547129,29.157654 51.655129,28.265654 50.547129,28.265654 L 9.8122082,28.265654 z "
+       id="rect611" />
+  </g>
+  <metadata
+     id="metadata6">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:title>Part of the Flat Icon Collection (Thu Aug 26 14:31:40 2004)</dc:title>
+        <dc:description />
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li />
+          </rdf:Bag>
+        </dc:subject>
+        <dc:publisher>
+          <cc:Agent
+             rdf:about="">
+            <dc:title />
+          </cc:Agent>
+        </dc:publisher>
+        <dc:creator>
+          <cc:Agent
+             rdf:about="">
+            <dc:title>Danny Allen</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:rights>
+          <cc:Agent
+             rdf:about="">
+            <dc:title>Danny Allen</dc:title>
+          </cc:Agent>
+        </dc:rights>
+        <dc:date />
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/LGPL/2.1/">
+          <dc:date />
+        </cc:license>
+        <dc:language>en</dc:language>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4208"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="22.392134" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4210"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958696"
+     x="25.205595" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4212"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="28.039183" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4214"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958729"
+     x="30.862715" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4216"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="30.059542"
+     x="33.676201" />
+  <a
+     id="a2680"
+     transform="matrix(1.0764385,0,0,1.0764386,-3.9678317,-2.8218674)">
+    <rect
+       x="22.957844"
+       y="-49.865311"
+       ry="0.50752664"
+       style="fill:#c0c0c0;fill-opacity:0;stroke:#000000;stroke-width:0.26633105;stroke-opacity:1"
+       rx="0.60646188"
+       id="rect4218"
+       width="16.989586"
+       transform="scale(1,-1)"
+       height="16.91943" />
+  </a>
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4220"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="29.958696"
+     x="36.489658" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4222"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136734"
+     x="-46.626415" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4224"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-35.312218" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4226"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-38.135746" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4228"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-40.959274" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4230"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-43.782803" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4232"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="18.136717"
+     x="-49.429836" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4234"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="22.412243" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4236"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="25.225708" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4238"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="28.059299" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4240"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.13517"
+     x="30.88283" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4242"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="33.686245" />
+  <rect
+     height="2.550113"
+     width="1.1182215"
+     id="rect4244"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="51.135139"
+     x="36.509773" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4246"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313171"
+     x="-46.626415" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4248"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-35.312218" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4250"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-38.135746" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4252"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-40.959274" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4254"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-43.782803" />
+  <rect
+     height="2.5501127"
+     transform="matrix(0,-1,1,0,0,0)"
+     width="1.1182216"
+     id="rect4256"
+     rx="0"
+     style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.27343532;stroke-opacity:1"
+     ry="0"
+     y="39.313141"
+     x="-49.429836" />
+  <text
+     xml:space="preserve"
+     style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans Mono"
+     x="22.675781"
+     y="45.092186"
+     id="text2683"><tspan
+       sodipodi:role="line"
+       id="tspan2685"
+       x="22.675781"
+       y="45.092186">µC</tspan></text>
+</svg>
index f51b1a776583040b6499aa5b7c00fd48c6b15289..7afbe74b8c47f36e106884ae7a15f761797877cb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,12 @@ info:
 
 #-------------------------------------------------------------------------------
        
+define SOURCEFILE_TEMPLATE
+$(BIN_DIR)$(1): $(2)/$(3).c
+       $(CC) $(CFLAGS) -c -o $@ $<
+endef
 
+#-------------------------------------------------------------------------------
 $(BIN_DIR)%.o: %.c
        @echo "[gcc]:  $@"
        @$(CC) $(CFLAGS)  -c -o $@ $<
index d44ca11ee4cf29adf67c5adf95a4e26422710c6c..323786abf3024a9fa7ceb4ff3fd68a8fd218ca35 100644 (file)
@@ -1,7 +1,7 @@
 
 MCU_TARGET     = atmega644
 OPTIMIZE       = -Os
-PROGRAMMER     = stk500v2 # avr911
+PROGRAMMER     = avr911
 DEFS           = -D$(call uc, $(MCU_TARGET))
 FLASHCMD       = avrdude -p $(MCU_TARGET) -P /dev/ttyUSB0 -c $(PROGRAMMER) -U flash:w:# no space at the end
 #FLASHCMD       = avrdude -p $(MCU_TARGET) -c usbasp -U flash:w:# no space at the end
index 95fb5df2833ee0822dbff60e7482f98c01efffc5..a09223af3ff1e0bc29c4ca4371638a67a6d4a351 100644 (file)
@@ -28,7 +28,7 @@
 #include <avr/pgmspace.h>
 #include "camellia.h"
 #if 0
- #include "uart.h"
+ #include "cli.h"
  #include "debug.h"
  #include <util/delay.h>
 #endif
@@ -72,11 +72,11 @@ uint32_t PROGMEM camellia_sigma[12]={ /* 48 byte table */
 /*****************************************************************************/
 /*
 void camellia128_ctx_dump(camellia128_ctx_t *s){
-       uart_putstr_P(PSTR("\r\n==State Dump=="));
-       uart_putstr_P(PSTR("\n\rKAl: ")); uart_hexdump(&(s->kal), 8);
-       uart_putstr_P(PSTR("\n\rKAr: ")); uart_hexdump(&(s->kar), 8);
-       uart_putstr_P(PSTR("\n\rKLl: ")); uart_hexdump(&(s->kll), 8);
-       uart_putstr_P(PSTR("\n\rKLr: ")); uart_hexdump(&(s->klr), 8);   
+       cli_putstr_P(PSTR("\r\n==State Dump=="));
+       cli_putstr_P(PSTR("\n\rKAl: ")); cli_hexdump(&(s->kal), 8);
+       cli_putstr_P(PSTR("\n\rKAr: ")); cli_hexdump(&(s->kar), 8);
+       cli_putstr_P(PSTR("\n\rKLl: ")); cli_hexdump(&(s->kll), 8);
+       cli_putstr_P(PSTR("\n\rKLr: ")); cli_hexdump(&(s->klr), 8);     
        return;
 }
 */
index e6ea17fe59ac33b24b1934710074c91b759aa437..c8cf45050f57e7e08fb8395954d0ffd9da9684ab 100644 (file)
@@ -28,7 +28,7 @@
 #include <avr/pgmspace.h>
 #include "camellia.h"
 #if 0
- #include "uart.h"
+ #include "cli.h"
  #include "debug.h"
  #include <util/delay.h>
 #endif 
@@ -100,7 +100,7 @@ uint8_t camellia_s4(uint8_t b){
 /*****************************************************************************/
 
 uint64_t camellia_s(uint64_t d){
-//     uart_putstr("\n\r S von "); uart_hexdump(&(d), 8);
+//     cli_putstr("\n\r S von "); cli_hexdump(&(d), 8);
        #define D ((uint8_t*)(&d))
        D[7] = camellia_s1(D[7]);
        D[6] = camellia_s2(D[6]);
@@ -112,7 +112,7 @@ uint64_t camellia_s(uint64_t d){
        D[1] = camellia_s4(D[1]);
        D[0] = camellia_s1(D[0]);
        #undef D
-//     uart_putstr(" ist "); uart_hexdump(&(d), 8);
+//     cli_putstr(" ist "); cli_hexdump(&(d), 8);
        return d;
 }
 
@@ -133,7 +133,7 @@ uint64_t camellia_p(uint64_t d){
        Z[7] = D[3] ^ D[5] ^ D[4];
 */
 //     Z[7] = z1 z3 z4 z6 z7 z8
-//     uart_putstr("\n\r P von "); uart_hexdump(&(d), 8);
+//     cli_putstr("\n\r P von "); cli_hexdump(&(d), 8);
        
        Z[7] = D[7] ^        D[5] ^ D[4] ^        D[2] ^ D[1] ^ D[0];
        Z[6] = D[7] ^ D[6]        ^ D[4] ^ D[3] ^        D[1] ^ D[0];
@@ -144,7 +144,7 @@ uint64_t camellia_p(uint64_t d){
        Z[1] =               D[5] ^ D[4] ^ D[3] ^ D[2] ^        D[0];
        Z[0] = D[7] ^               D[4] ^ D[3] ^ D[2] ^ D[1]       ;
        
-//     uart_putstr(" ist "); uart_hexdump(&(z), 8);
+//     cli_putstr(" ist "); cli_hexdump(&(z), 8);
                        
        #undef Z
        #undef D
@@ -176,12 +176,12 @@ uint64_t camellia_fl(uint64_t x, uint64_t k){
        yl = (yr | K[0]) ^ (X[1]);           /* Yl */
        
 /*     
-       uart_putstr("\r\nFL(");
-       uart_hexdump(&(x), 8);
-       uart_putstr(", ");
-       uart_hexdump(&(k), 8);
-       uart_putstr(") = ");
-       uart_hexdump(y, 8);
+       cli_putstr("\r\nFL(");
+       cli_hexdump(&(x), 8);
+       cli_putstr(", ");
+       cli_hexdump(&(k), 8);
+       cli_putstr(") = ");
+       cli_hexdump(y, 8);
 */
        #undef K
        #undef X
@@ -206,11 +206,11 @@ uint64_t camellia_fl_inv(uint64_t y, uint64_t k){
        X[0]=rol32((X[1] & K[1]),1) ^ Y[0];
        
 /*     
-       uart_putstr("\r\nFL_inv(");
-       uart_hexdump(&(y), 8);
-       uart_putstr(", ");
-       uart_hexdump(&(k), 8);
-       uart_putstr(") = ");
+       cli_putstr("\r\nFL_inv(");
+       cli_hexdump(&(y), 8);
+       cli_putstr(", ");
+       cli_hexdump(&(k), 8);
+       cli_putstr(") = ");
 */     
        #undef K
        #undef X
@@ -232,11 +232,11 @@ uint64_t camellia_sigma[6]={
 /*****************************************************************************/
 #if 0
 void camellia128_ctx_dump(camellia128_ctx_t *s){
-       uart_putstr("\r\n==State Dump==");
-       uart_putstr("\n\rKAl: "); uart_hexdump(&(s->kal), 8);
-       uart_putstr("\n\rKAr: "); uart_hexdump(&(s->kar), 8);
-       uart_putstr("\n\rKLl: "); uart_hexdump(&(s->kll), 8);
-       uart_putstr("\n\rKLr: "); uart_hexdump(&(s->klr), 8);   
+       cli_putstr("\r\n==State Dump==");
+       cli_putstr("\n\rKAl: "); cli_hexdump(&(s->kal), 8);
+       cli_putstr("\n\rKAr: "); cli_hexdump(&(s->kar), 8);
+       cli_putstr("\n\rKLl: "); cli_hexdump(&(s->kll), 8);
+       cli_putstr("\n\rKLr: "); cli_hexdump(&(s->klr), 8);     
        return;
 }
 #endif
@@ -270,7 +270,7 @@ void camellia128_init(const void* key, camellia128_ctx_t* s){
        s->kar ^= camellia_f(s->kal, camellia_sigma[2]);
        s->kal ^= camellia_f(s->kar, camellia_sigma[3]);
        /**/
-//     uart_putstr("\n\r----------------init finished--------------------");
+//     cli_putstr("\n\r----------------init finished--------------------");
 }
 
 /*****************************************************************************/
diff --git a/cast5.c b/cast5.c
index 57d6f4335edc14a3af773b25172e1bfa738867bb..6d7f42fff5b3d323cb7950e2ca1af65154baf077 100644 (file)
--- a/cast5.c
+++ b/cast5.c
@@ -36,7 +36,7 @@
  #undef DEBUG
  
  #ifdef DEBUG
-  #include "uart.h"
+  #include "cli.h"
  #endif
  
 #include "cast5-sbox.h"
@@ -112,7 +112,7 @@ void cast5_init_rM(uint8_t *klo, uint8_t *khi, uint8_t offset, uint8_t *src, boo
                klo[offset*2+1] |= t<<4;
                h |= t&0x10; h >>=1;
        #ifdef DEBUG
-               uart_putstr("\r\n\t h="); uart_hexdump(&h,1);
+               cli_putstr("\r\n\t h="); cli_hexdump(&h,1);
        #endif
        khi[offset>>1] |= h<<((offset&0x1)?4:0);
 }
@@ -204,17 +204,17 @@ uint32_t cast5_f1(uint32_t d, uint32_t m, uint8_t r){
        t = ROTL32((d + m),r);
 #ifdef DEBUG
        uint32_t ia,ib,ic,id;
-       uart_putstr("\r\n f1("); uart_hexdump(&d, 4); uart_putc(',');
-               uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
-               uart_hexdump(&t, 4);
+       cli_putstr("\r\n f1("); cli_hexdump(&d, 4); cli_putc(',');
+               cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+               cli_hexdump(&t, 4);
        ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
        ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
        ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
        id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
-       uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
-       uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
-       uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
-       uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+       cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+       cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+       cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+       cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
 
        return (((ia ^ ib) - ic) + id);
 
@@ -234,19 +234,19 @@ uint32_t cast5_f2(uint32_t d, uint32_t m, uint8_t r){
        t = ROTL32((d ^ m),r);
 #ifdef DEBUG
        uint32_t ia,ib,ic,id;
-       uart_putstr("\r\n f2("); uart_hexdump(&d, 4); uart_putc(',');
-               uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
-               uart_hexdump(&t, 4);
+       cli_putstr("\r\n f2("); cli_hexdump(&d, 4); cli_putc(',');
+               cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+               cli_hexdump(&t, 4);
 
        ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
        ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
        ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
        id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
        
-       uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
-       uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
-       uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
-       uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+       cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+       cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+       cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+       cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
 
        return (((ia - ib) + ic) ^ id);
 #else
@@ -267,19 +267,19 @@ uint32_t cast5_f3(uint32_t d, uint32_t m, uint8_t r){
 #ifdef DEBUG
        uint32_t ia,ib,ic,id;
 
-       uart_putstr("\r\n f3("); uart_hexdump(&d, 4); uart_putc(',');
-               uart_hexdump(&m , 4); uart_putc(','); uart_hexdump(&r, 1);uart_putstr("): I=");
-               uart_hexdump(&t, 4);
+       cli_putstr("\r\n f3("); cli_hexdump(&d, 4); cli_putc(',');
+               cli_hexdump(&m , 4); cli_putc(','); cli_hexdump(&r, 1);cli_putstr("): I=");
+               cli_hexdump(&t, 4);
 
        ia = pgm_read_dword(&s1[((uint8_t*)&t)[IA]] );
        ib = pgm_read_dword(&s2[((uint8_t*)&t)[IB]] );
        ic = pgm_read_dword(&s3[((uint8_t*)&t)[IC]] );
        id = pgm_read_dword(&s4[((uint8_t*)&t)[ID]] );
        
-       uart_putstr("\r\n\tIA="); uart_hexdump(&ia, 4);
-       uart_putstr("\r\n\tIB="); uart_hexdump(&ib, 4);
-       uart_putstr("\r\n\tIC="); uart_hexdump(&ic, 4);
-       uart_putstr("\r\n\tID="); uart_hexdump(&id, 4);
+       cli_putstr("\r\n\tIA="); cli_hexdump(&ia, 4);
+       cli_putstr("\r\n\tIB="); cli_hexdump(&ib, 4);
+       cli_putstr("\r\n\tIC="); cli_hexdump(&ic, 4);
+       cli_putstr("\r\n\tID="); cli_hexdump(&id, 4);
        return (((ia + ib) ^ ic) - id);
 #else
        return ((  pgm_read_dword(&s1[((uint8_t*)&t)[IA]] )
@@ -298,16 +298,16 @@ void cast5_enc(void* block, const cast5_ctx_t *s){
        cast5_f_t* f[]={cast5_f1,cast5_f2,cast5_f3};
        l=((uint32_t*)block)[0];
        r=((uint32_t*)block)[1];
-//     uart_putstr("\r\n round[-1] = ");
-//     uart_hexdump(&r, 4);
+//     cli_putstr("\r\n round[-1] = ");
+//     cli_hexdump(&r, 4);
        for (i=0;i<(s->shortkey?12:16);++i){
                x = r;
                y = (f[i%3])(CHANGE_ENDIAN32(r), CHANGE_ENDIAN32(s->mask[i]), 
                        (((s->roth[i>>3]) & (1<<(i&0x7)))?0x10:0x00) 
                         + ( ((s->rotl[i>>1])>>((i&1)?4:0)) & 0x0f) );
                r = l ^ CHANGE_ENDIAN32(y);
-//             uart_putstr("\r\n round["); DEBUG_B(i); uart_putstr("] = ");
-//             uart_hexdump(&r, 4);
+//             cli_putstr("\r\n round["); DEBUG_B(i); cli_putstr("] = ");
+//             cli_hexdump(&r, 4);
                l = x;
        }
        ((uint32_t*)block)[0]=r;
diff --git a/cast6.c b/cast6.c
index cb0754b3d4bc1dc28a49b1b3685dbe05a6baad92..c4922fc9465b2fc1f9c890ee8d03ddc31f0cf8a9 100644 (file)
--- a/cast6.c
+++ b/cast6.c
@@ -194,31 +194,31 @@ void w(void* buffer, uint8_t* tr, uint32_t* tm){
 /*
 void dump_ctx(const cast6_ctx_t* ctx){
        uint8_t i,t;
-       uart_putstr_P(PSTR("\r\n DBG:"));
+       cli_putstr_P(PSTR("\r\n DBG:"));
        for(i=0; i<12; ++i){
-               uart_putstr_P(PSTR("\r\n DBG:"));
-               uart_putstr_P(PSTR(" rotk1="));
+               cli_putstr_P(PSTR("\r\n DBG:"));
+               cli_putstr_P(PSTR(" rotk1="));
                t=kr(i*4+0, ctx);
-               uart_hexdump(&t,1);
-               uart_putstr_P(PSTR("          rotk2="));
+               cli_hexdump(&t,1);
+               cli_putstr_P(PSTR("          rotk2="));
                t=kr(i*4+1, ctx);
-               uart_hexdump(&t,1);
-               uart_putstr_P(PSTR("          rotk3="));
+               cli_hexdump(&t,1);
+               cli_putstr_P(PSTR("          rotk3="));
                t=kr(i*4+2, ctx);
-               uart_hexdump(&t,1);
-               uart_putstr_P(PSTR("          rotk4="));
+               cli_hexdump(&t,1);
+               cli_putstr_P(PSTR("          rotk4="));
                t=kr(i*4+3, ctx);
-               uart_hexdump(&t,1);
-               uart_putstr_P(PSTR("\r\n     "));
-               uart_putstr_P(PSTR(" mask1="));
-               uart_hexdump(&(ctx->km[i][0]),4);
-               uart_putstr_P(PSTR(" mask2="));
-               uart_hexdump(&(ctx->km[i][1]),4);
-               uart_putstr_P(PSTR(" mask3="));
-               uart_hexdump(&(ctx->km[i][2]),4);
-               uart_putstr_P(PSTR(" mask4="));
-               uart_hexdump(&(ctx->km[i][3]),4);
-               uart_putstr_P(PSTR("\r\n;-----"));
+               cli_hexdump(&t,1);
+               cli_putstr_P(PSTR("\r\n     "));
+               cli_putstr_P(PSTR(" mask1="));
+               cli_hexdump(&(ctx->km[i][0]),4);
+               cli_putstr_P(PSTR(" mask2="));
+               cli_hexdump(&(ctx->km[i][1]),4);
+               cli_putstr_P(PSTR(" mask3="));
+               cli_hexdump(&(ctx->km[i][2]),4);
+               cli_putstr_P(PSTR(" mask4="));
+               cli_hexdump(&(ctx->km[i][3]),4);
+               cli_putstr_P(PSTR("\r\n;-----"));
        }
 }
 */
index 20af8455e3b783400513d67074d945d2d8c61f09..252a924119267045c244bbd5f29bd060de78627b 100644 (file)
--- a/config.h
+++ b/config.h
@@ -24,6 +24,7 @@
 // #define F_CPU 14745600
 
 
+#include "uart_defs.h"
 
 #define DEBUG uart
 
 #define UART_XON_XOFF_THRESHOLD_2 (UART_RXBUFSIZE - 60)
 
 #undef UART_LEDS
+
+#define UART0_I 1
+#define UART0_BAUD_RATE  38400
+#define UART0_PARATY     UART_PARATY_NONE
+#define UART0_STOPBITS   UART_STOPBITS_1
+#define UART0_DATABITS   UART_DATABITS_8
+#define UART0_RXBUFFER_SIZE 64
+#define UART0_TXBUFFER_SIZE 64
+#define UART0_SWFLOWCTRL     1
+#define UART0_THRESH_LOW    10
+#define UART0_THRESH_HIGH   48
 /*
 #define UART_HWFLOWCONTROL
 #define UART_RTS_PORT PORTA
diff --git a/des.c b/des.c
index 57bc7e30b9c41d86ca530871d9719d41baf043f9..2600a223d3a171eea31b54a80c8d86692fdccdd3 100644 (file)
--- a/des.c
+++ b/des.c
@@ -27,7 +27,7 @@
  */
 #include "config.h"
 #include "debug.h"
-#include "uart.h"
+#include "cli.h"
 #include <stdint.h>
 #include <string.h>
 #include <util/delay.h>
diff --git a/md5.c b/md5.c
index 20ec519c961a9152c235d8653351da9d0bbbee20..003699e5ef4ae65486bece16d9cdfbe21a4cca2b 100644 (file)
--- a/md5.c
+++ b/md5.c
@@ -27,7 +27,7 @@
 
  #include "md5.h"
  #include "md5_sbox.h"
- #include "uart.h" 
+ #include "cli.h" 
  #include <stdint.h>
  #include <string.h>
  
@@ -73,12 +73,12 @@ void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_
        /* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
 #ifdef DEBUG
        char funcc[]={'*', '-', '+', '~'};
-       uart_putstr("\r\n DBG: md5_core [");
-       uart_putc(funcc[fi]);
-       uart_hexdump(&as, 1); uart_putc(' ');
-       uart_hexdump(&k, 1); uart_putc(' ');
-       uart_hexdump(&s, 1); uart_putc(' ');
-       uart_hexdump(&i, 1); uart_putc(']');
+       cli_putstr("\r\n DBG: md5_core [");
+       cli_putc(funcc[fi]);
+       cli_hexdump(&as, 1); cli_putc(' ');
+       cli_hexdump(&k, 1); cli_putc(' ');
+       cli_hexdump(&s, 1); cli_putc(' ');
+       cli_hexdump(&i, 1); cli_putc(']');
 #endif 
        t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3]) 
            + *((uint32_t*)block) + pgm_read_dword(md5_T+i) ;
@@ -90,11 +90,11 @@ void md5_nextBlock(md5_ctx_t *state, const void* block){
        uint8_t         m,n,i=0;
        /* this requires other mixed sboxes */
 #ifdef DEBUG
-       uart_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
-       uart_hexdump(block, 16);        uart_putstr("\r\n");
-       uart_hexdump(block+16, 16);     uart_putstr("\r\n");
-       uart_hexdump(block+32, 16);     uart_putstr("\r\n");
-       uart_hexdump(block+48, 16);     uart_putstr("\r\n");
+       cli_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
+       cli_hexdump(block, 16); cli_putstr("\r\n");
+       cli_hexdump(block+16, 16);      cli_putstr("\r\n");
+       cli_hexdump(block+32, 16);      cli_putstr("\r\n");
+       cli_hexdump(block+48, 16);      cli_putstr("\r\n");
 #endif 
        
        a[0]=state->a[0];
index a13bf7268becdeb0fcb42afed3c6174e3befb100..22608a35aa20342c29bb5ec018a2e6cebe018da3 100644 (file)
@@ -1 +1,2 @@
-CLI_STD =  debug.o uart.o hexdigit_tab.o dbz_strings.o cli.o string-extras.o
+CLI_STD =  cli-stub.o cli-basics.o cli-core.o cli-hexdump.o debug.o hexdigit_tab.o \
+           dbz_strings.o string-extras-asm.o uart_i-asm.o circularbytebuffer-asm.o
index 63f59ec6f90994076bff03c9a224d9f0bc46183f..5dfcaddaf34abfa021dff3b3ed0d4b96a53e9cf3 100644 (file)
@@ -5,8 +5,7 @@ ALGO_NAME := A51
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := A5_1.o
-$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-a5_1-test.o nessie_stream_test.o nessie_common.o $(CLI_STD)
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 871434b18ee8fd19b5e03f0da9d02b0042d00964..f19a1c6e8186c02eb94790afeb04231ec9b56ce7 100644 (file)
@@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o  \
                          aes_keyschedule-asm.o  
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index ad5acb5b8048bfe366897cebc1b361f4073676ee..18ba9d82dd8ca13273f7e463ef63b73d482d7713 100644 (file)
@@ -7,8 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := aes_enc-asm.o aes_dec-asm_faster.o aes_sbox-asm.o aes_invsbox-asm.o  \
                          aes_keyschedule-asm.o  
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index dcc6c6204226c3eb45bcda89bb5f58650c01102f..8f0a4e138d759bfe326c6b2ddd8b8f1f04f1ad60 100644 (file)
@@ -9,8 +9,8 @@ $(ALGO_NAME)_OBJ      := aes_enc.o aes_dec.o aes_sbox.o aes_invsbox.o \
                          aes_keyschedule.o gf256mul.o \
                          aes128_enc.o aes128_dec.o aes192_enc.o aes192_dec.o \
                          aes256_enc.o aes256_dec.o
-$(ALGO_NAME)_TEST_BIN := main-aes-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 7cc4c8eaa6eb51a4d05674a047beb94a9d560fba..d62c1446cbf0c2876dd813e4a7f4fef2f19b3c33 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := ARCFOUR
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := arcfour-asm.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
-                         performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o $(CLI_STD)  \
+                         nessie_stream_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 23a413572f23f7b60cbd9aabaf09fba581311ed9..40a3a846f0e0bfa3749d1c3892ccfa967637d32e 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := ARCFOUR_C
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := arcfour.o
-$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o $(CLI_STD)  \
+                         nessie_stream_test.o nessie_common.o \
                          performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 35695c40595752d45835fedc117cdf10da60033a..58883c3d4cff1849fb82a10a2db40d9d4e7dba0b 100644 (file)
@@ -6,9 +6,8 @@ ENCODINGS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := base64_enc.o base64_dec.o
-$(ALGO_NAME)_TEST_BIN := main-base64-test.o debug.o uart.o hexdigit_tab.o  \
-                         cli.o string-extras.o performance_test.o noekeon_asm.o noekeon_prng.o \
-                        memxor.o
+$(ALGO_NAME)_TEST_BIN := main-base64-test.o $(CLI_STD)  \
+                         performance_test.o noekeon_asm.o noekeon_prng.o memxor.o
                         
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 2cd0581ca6f76483b6fbc0d0f51416a4bdd28420..0a7fbc5b0ad6b36ce24208b8d9a7bfa1c96f63b4 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := CAMELLIA
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := camellia128-stub.o camellia-asm.o
-$(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o \
-                        dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-camellia-test.o $(CLI_STD) nessie_bc_test.o \
+                        nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index df2fd137bcb4093c165543a2df5b49e2b29d8dd0..08ead6e980e55bb3fa6dee28f33ce7ce5c2da281 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := CAST5
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := cast5.o
-$(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o hexdigit_tab.o  cli.o string-extras.o\
-                         nessie_bc_test.o dbz_strings.o nessie_common.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-cast5-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index eb3baad70ef892b42f1c0b12a9fc23788d66d793..3f8539f66b748f613b4dfd896d93128894fb7d09 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := cast6.o
-$(ALGO_NAME)_TEST_BIN := main-cast6-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
-                         nessie_bc_test.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-cast6-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 17c5709369d3fbd8d03e726726d3d50ec956f0ba..5d9540dd027c054a565160f405bec3c46f630d9c 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := DES
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := des.o
-$(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-des-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index f6c16f6d706705f2e11fa8101a552d9b66cb5287..02ad75b7503610af00a4d73c1077c0970135e452 100644 (file)
@@ -5,8 +5,7 @@ ALGO_NAME := ENTROPIUM
 PRNGS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := entropium.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o hexdigit_tab.o  \
-                         cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-entropium-test.o $(CLI_STD) performance_test.o
                          
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index a79076d0b476da033fdb92a3634de6bea272e0d7..1b0da652aedf8a1290b61b5162455e123778b3f8 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := GRAIN
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := grain.o
-$(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
-                                    performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-grain-test.o $(CLI_STD) \
+                         nessie_stream_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index a816ed3c35b50487b4e77be9ce210ffb4b520b95..7d3f64495c597a9d05aea6ba70c5dda4e075842f 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-MD5
 MACS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := hmac-md5.o md5-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o debug.o uart.o hexdigit_tab.o  cli.o string-extras.o \
-                         nessie_mac_test.o dbz_strings.o nessie_common.o base64_enc.o base64_dec.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-md5-test.o $(CLI_STD) \
+                         nessie_mac_test.o nessie_common.o base64_enc.o base64_dec.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 3c75921b469dadbaa82c5ea5e786a7505e3de244..90874002cca2886048a79be2c04605a599141329 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-SHA1
 MACS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := hmac-sha1.o sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o hexdigit_tab.o  cli.o string-extras.o \
-                         nessie_mac_test.o dbz_strings.o nessie_common.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o $(CLI_STD) \
+                         nessie_mac_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 2dd2973254598f5c7230202e945010714d7b4694..ba221ab87d5b16d4b4005b077108479342872ffb 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := HMAC-SHA256
 MACS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := hmac-sha256.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o $(CLI_STD) \
+                         nessie_mac_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 382fcb9f5a0c25c42a6b848d51bf65170460c8ec..6c95c968d66f2d4e298893fc1bbf11af8e5531f8 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := MICKEY128
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := mickey128.o
-$(ALGO_NAME)_TEST_BIN := main-mickey128-test.o debug.o uart.o hexdigit_tab.o serial-tools.o \
-                         nessie_stream_test.o nessie_common.o cli.o string-extras.o
+$(ALGO_NAME)_TEST_BIN := main-mickey128-test.o $(CLI_STD) \
+                         nessie_stream_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 0e1e61fb2829763556f8ff8bc95f780b8a2e291e..7bcb92f40a69ee306ce40864697569f13049f5b1 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := MUGI_C
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := mugi.o gf256mul.o aes_sbox.o
-$(ALGO_NAME)_TEST_BIN := main-mugi-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
+$(ALGO_NAME)_TEST_BIN := main-mugi-test.o $(CLI_STD)  \
+                         nessie_stream_test.o nessie_common.o  \
                          performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 9c70942a635b7d1d09f60b92c559d0bae81f2578..086316270b2ec769e17eb67ba3ef6ed72abd6bcb 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := noekeon_asm.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 700e8c247932327975339a6686b0a6bd782afd7c..0f7f0879336927cc13bce93ae65db383c9bb3a28 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := noekeon.o
-$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-noekeon-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 3429a4afb49ed8822dc1b0d8beedb831c743d30d..5c8ba7c47f653aa1438c90a8efb3811693ca7a96 100644 (file)
@@ -6,8 +6,8 @@ MACS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := noekeon_asm.o omac_noekeon.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o $(CLI_STD)  \
+                         nessie_mac_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index e704b1e79c47fc519f72378bc1efa215fb1d9084..4346d3316791e0215372f5fff821bd33b238b743 100644 (file)
@@ -6,8 +6,8 @@ MACS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := noekeon_asm.o omac_noekeon_C.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_mac_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-omac-noekeon-test.o $(CLI_STD)  \
+                         nessie_mac_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 2c8e9d1e3543b8115ccaaedd17ba672b4e1342ed..3a4012c76fc500dce0cf570c8f3d5b0b1f658365 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := present.o
-$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-present-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index f948b622e4612fcdfac34b85570d8afa9e8f2419..3a5f1286698c1b25c2226431b6033156508b91eb 100644 (file)
@@ -6,9 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := rc5.o
-$(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o \
-                         dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-rc5-test.o $(CLI_STD) nessie_bc_test.o \
+                         nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index f6729e36b245a4d0b7e8825fc82f2dffeb8e9317..e0bc603e60640d431dac4ff597ffacadc6b25031 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := rc6.o
-$(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-rc6-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 28b437a66e4ecc5f5549e509a52669293b1d6c91..1c2b605802909d53c0b5334635ef3d2afca0adb9 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := SEED
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := seed-asm.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o \
-                         cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 7ec687fd2936559d5d228df424c2bdbbcfd4f21a..14aa8ac75bb14d2d0d3b8b61ca09a29b64633086 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := SEED_C
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := seed_C.o
-$(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o \
-                         cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-seed-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index d1e5a9a8d57c23a7a7fa47c847e43430ffb15f66..6a9b76a28a5b5712a51a04f9aea9a468fef7a1ed 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-bitslice-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index f8cb7b7affeb79df7e8951b409326693dc84be2f..afd0868e7622d45da856ec8c070864e86aa037a4 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := serpent-sboxes-bitslice-asm.o serpent-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index d9c3760d121b9b4db4f2e2fa4a318474d8341656..3e3a4fb78297a1dbb9e23fb035b9166f1f33dc98 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-fast.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 52cfda2612caa5727c4d6220722abc82f01eb6a8..6dde94bd93c22fcc9af219c21b99c13516cfcb85 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-small.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index e8c7be4c26b4d305ae3e80e9bd0324b07d9ff71a..dd3a69ba3309cf2037d2633c70d5deb9f41fb0a1 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes_c.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-serpent-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 434697ee1f6f9104e77b1359930813a7f37a3159..45df051cacb76c2f3a2ac01f7bc59689762657bd 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := SHA1
 HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o $(CLI_STD) $(HFAL_STD) dump.o 
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o $(CLI_STD) $(HFAL_STD) dump-decl.o dump-asm.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 4ce9f0ad2e82ecb3c53af86062cae6e8afea852c..4b0b7ae43bd18cf731f14f309330a3184743fa14 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := SHA1_C
 HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha1.o
-$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o dump.o $(CLI_STD) $(HFAL_STD)
+$(ALGO_NAME)_TEST_BIN := main-sha1-test.o hfal_sha1.o dump-asm.o dump-decl.o $(CLI_STD) $(HFAL_STD)
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 92dc0bcfdc7b85273d5e2cdd8a77f14f193ef1d2..93ebdc7b64df8899c01fe44000ebbc7b93eb802c 100644 (file)
@@ -5,8 +5,7 @@ ALGO_NAME := SHA256
 HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o dump.o hfal_sha256.o $(CLI_STD) $(HFAL_STD)
-                       
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o dump-asm.o dump-decl.o hfal_sha256.o $(CLI_STD) $(HFAL_STD)
                        
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 0e172dbcec374d7fedba6608ddb066511a1a2e09..d52fe8812b421f79661cea91cb20efef4ef5740d 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := SHA256_C
 HASHES += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := sha256.o
-$(ALGO_NAME)_TEST_BIN := main-sha256-test.o $(CLI_STD) $(HFAL_STD) hfal_sha256.o dump.o
+$(ALGO_NAME)_TEST_BIN := main-sha256-test.o $(CLI_STD) $(HFAL_STD) hfal_sha256.o dump-asm.o dump-decl.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index fb65dd4828f18097111dd79c4ea7cb1a5a72be34..e5f4a68dbc8cb3db399ac4f3116b429795fb448d 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := SHABEA
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-shabea-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 728116eafff06b74fdaba0898a696dd33dd2cf41..63be6c8514365170e49453e9b3485fa96b54ae44 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := shacal1_enc.o sha1-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o 
+$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o $(CLI_STD)  \
+                         nessie_bc_test.o nessie_common.o performance_test.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index fe24abaae06b27f7570c402ca54944bf72315784..e8a91a21dac33b1bc625716253a2ee38ef385427 100644 (file)
@@ -6,8 +6,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 
 
 $(ALGO_NAME)_OBJ      := shacal2_enc.o sha256-asm.o
-$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o 
+$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index a325577988600165b84b7b79f559ebbec6f0d652..56579b24c62e4d548b15c0c7d5d62428eb229682 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := SKIPJACK
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := skipjack.o
-$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
-                        performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-skipjack-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 34740e9a60000e43931a4ec750c8ed8490c72d4e..7bdc41ec42a337f042923d9348d41706bebd9033 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := TDES
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := des.o
-$(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-tdes-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index ef68ed43f5d9b05679b8650d9fc161d7036f6a0c..7781f3787e68be57495f3be5752bdf38c256b7af 100644 (file)
@@ -8,8 +8,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
 $(ALGO_NAME)_OBJ      := threefish256_enc_asm.o threefish512_enc_asm.o threefish1024_enc_asm.o\
                          threefish_mix.o threefish_invmix.o \
                         threefish256_dec_asm.o threefish512_dec_asm.o threefish1024_dec_asm.o
-$(ALGO_NAME)_TEST_BIN := main-threefish-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-threefish-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 1478cb66fce3d5863f6d1b701540391beb25da54..bbfba3b70163974d99a97cc50c7089384f768b15 100644 (file)
@@ -5,9 +5,8 @@ ALGO_NAME := TRIVIUM
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := trivium.o
-$(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_stream_test.o dbz_strings.o nessie_common.o cli.o string-extras.o \
-                         performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-trivium-test.o $(CLI_STD) \
+                         nessie_stream_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 9f0984df5f6cd97628149a43eb05f0cb79de9d76..4c1965e191136f25a475bc1305511669c39f3b13 100644 (file)
@@ -8,8 +8,8 @@ AUX += $(ALGO_NAME)
 $(ALGO_NAME)_OBJ      := threefish_mix.o threefish256_enc_asm.o ubi256_asm.o \
                          threefish512_enc_asm.o ubi512_asm.o threefish1024_enc_asm.o \
                          ubi1024_asm.o memxor.o
-$(ALGO_NAME)_TEST_BIN := main-ubi-test.o debug.o uart.o hexdigit_tab.o  \
-                         dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-ubi-test.o $(CLI_STD) \
+                         nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index a26ec2201e04a1729e0810bd368d4b386a8a7f8b..68adcfb64cf2eff73a3f9793c95794a3e4822a69 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := XTEA
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := xtea-asm.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 9779affaf10c4fe689d3cffa66dc6e78db1e112c..dec8f8ce30105750b3f1322808143b8417cd25b4 100644 (file)
@@ -5,8 +5,8 @@ ALGO_NAME := XTEA_C
 BLOCK_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_OBJ      := xtea.o
-$(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o hexdigit_tab.o  \
-                         nessie_bc_test.o dbz_strings.o nessie_common.o cli.o string-extras.o performance_test.o
+$(ALGO_NAME)_TEST_BIN := main-xtea-test.o $(CLI_STD) \
+                         nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 4b8075510065089374b8a0ce975197ba4db375d2..f48d1e6a9b282b4da6a038a356495087d57ff6da 100644 (file)
--- a/noekeon.c
+++ b/noekeon.c
@@ -32,7 +32,7 @@
        #include <avr/pgmspace.h>
 #endif
 #include "noekeon.h"
-// #include "uart.h"
+// #include "cli.h"
 
 #define ROUND_NR 16
 
@@ -172,8 +172,8 @@ void noekeon_dec(void* buffer, const void* key){
        changendian(dkey);
        
        theta((uint32_t*)nullv, (uint32_t*)dkey);
-//     uart_putstr_P(PSTR("\r\nTheta: "));
-//     uart_hexdump(dkey, 16);
+//     cli_putstr_P(PSTR("\r\nTheta: "));
+//     cli_hexdump(dkey, 16);
        
        for(i=ROUND_NR-1; i>=0; --i){
 #ifdef __AVR__
index 4460fa5e780626e90eb898c5656c9c8b44d958fa..7a9afc03bc18860c093543c485fa6db79c1180f3 100644 (file)
--- a/seed_C.c
+++ b/seed_C.c
@@ -29,7 +29,7 @@
 #include <avr/pgmspace.h>
 #include <string.h>
 #include "seed_sbox.h"
-#include "uart.h"
+#include "cli.h"
 #include "debug.h"
 
 
@@ -221,19 +221,19 @@ void seed_enc(void * buffer, const seed_ctx_t * ctx){
        for(r=0; r<8; ++r){
                        k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r);
 /*
-       DEBUG_S("\r\n\tDBG ka,0: "); uart_hexdump(&k.k0, 4);
-       DEBUG_S("\r\n\tDBG ka,1: "); uart_hexdump(&k.k1, 4);
-       DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+0, 8);
-       DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+8, 8);
+       DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
+       DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
+       DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
+       DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
 */
                        L ^= f_function(&R,k.k0,k.k1);
                        
                        k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
 /*
-       DEBUG_S("\r\n\tDBG kb,0: "); uart_hexdump(&k.k0, 4);
-       DEBUG_S("\r\n\tDBG kb,1: "); uart_hexdump(&k.k1, 4);
-       DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+8, 8);
-       DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+0, 8);
+       DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
+       DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
+       DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
+       DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
 */
                        R ^= f_function(&L,k.k0,k.k1);
        }
@@ -254,19 +254,19 @@ void seed_dec(void * buffer, seed_ctx_t * ctx){
        for(r=7; r>=0; --r){
                        k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
 /*
-       DEBUG_S("\r\n\tDBG ka,0: "); uart_hexdump(&k.k0, 4);
-       DEBUG_S("\r\n\tDBG ka,1: "); uart_hexdump(&k.k1, 4);
-       DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+0, 8);
-       DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+8, 8);
+       DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
+       DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
+       DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
+       DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
 */
                        L ^= f_function(&R,k.k0,k.k1);
                        
                        k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+0);
 /*
-       DEBUG_S("\r\n\tDBG kb,0: "); uart_hexdump(&k.k0, 4);
-       DEBUG_S("\r\n\tDBG kb,1: "); uart_hexdump(&k.k1, 4);
-       DEBUG_S("\r\n\t DBG L: "); uart_hexdump((uint8_t*)buffer+8, 8);
-       DEBUG_S("\r\n\t DBG R: "); uart_hexdump((uint8_t*)buffer+0, 8);
+       DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
+       DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
+       DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
+       DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
 */
                        R ^= f_function(&L,k.k0,k.k1);
        }
diff --git a/sha1.c b/sha1.c
index 2f38e60eaa4b7bb44239c69f2e3d60850524d9bb..97cde32814fbfd5264167e35060915e6ed9df641 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -110,7 +110,7 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
                DEBUG_B(dbgi);
                DEBUG_C(':');
                #ifdef DEBUG
-                       uart_hexdump(&(w[dbgi]) ,4);
+                       cli_hexdump(&(w[dbgi]) ,4);
                #endif
        }
        
@@ -124,12 +124,12 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
                s = t & MASK;
                if(t>=16){
                        #ifdef DEBUG
-                        DEBUG_S("\r\n ws = "); uart_hexdump(&ws, 4);
+                        DEBUG_S("\r\n ws = "); cli_hexdump(&ws, 4);
                        #endif
                        w[s] = rotl32( w[(s+13)&MASK] ^ w[(s+8)&MASK] ^ 
                                 w[(s+ 2)&MASK] ^ w[s] ,1);                     
                        #ifdef DEBUG
-                        DEBUG_S(" --> ws = "); uart_hexdump(&(w[s]), 4);
+                        DEBUG_S(" --> ws = "); cli_hexdump(&(w[s]), 4);
                        #endif
                }
                
@@ -143,15 +143,15 @@ void sha1_nextBlock (sha1_ctx_t *state, const void* block){
                DEBUG_S("\r\nt = "); DEBUG_B(t);
                DEBUG_S("; a[]: ");
                #ifdef DEBUG
-                uart_hexdump(a, 5*4);
+                cli_hexdump(a, 5*4);
                #endif
                DEBUG_S("; k = ");
                #ifdef DEBUG
-                uart_hexdump(&(k[t/20]), 4);
+                cli_hexdump(&(k[t/20]), 4);
                #endif
                DEBUG_S("; f(b,c,d) = ");
                #ifdef DEBUG
-                uart_hexdump(&dtemp, 4);
+                cli_hexdump(&dtemp, 4);
                #endif
        }
        
diff --git a/test_src/circularbytebuffer-asm.S b/test_src/circularbytebuffer-asm.S
new file mode 100644 (file)
index 0000000..bd0d310
--- /dev/null
@@ -0,0 +1,372 @@
+/* circularbytebuffer-asm.S */
+/*
+    This file is part of the AVR-circularbytebuffer.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file     circularbytebuffer-asm.S
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte 
+ * \date     2009-07-25
+ * \license  GPLv3 or later
+ * \ingroup  circularbytebuffer
+ * \brief    declaration for circular byte buffer
+ */
+/* 
+ typedef struct {
+        uint8_t buffer_size;
+        uint8_t fillcount;
+        uint8_t* buffer;
+        uint8_t* head;
+        uint8_t* tail;
+        uint8_t* top;
+} circularbytebuffer_t;
+*/
+
+#include "config.h"
+
+#define BUFFER_SIZE_OFFSET 0
+#define FILLCOUNT_OFFSET   1
+#define BUFFER_OFFSET      2
+#define HEAD_OFFSET        4
+#define TAIL_OFFSET        6
+#define TOP_OFFSET         8
+
+#ifndef CIRCULARBYTEBUFFER_NO_MALLOC
+#  define CIRCULARBYTEBUFFER_NO_MALLOC 0
+#endif
+
+#ifndef CIRCULARBYTEBUFFER_NO_INIT2
+#  define CIRCULARBYTEBUFFER_NO_INIT2 0
+#endif
+
+#if CIRCULARBYTEBUFFER_NO_MALLOC==0
+
+/******************************************************************************/
+/*
+ *     uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb){
+ *             cb->buffer_size = buffersize;
+ *             cb->buffer = malloc(buffersize);
+ *             cb->head = cb->tail = cb->buffer;
+ *             cb->top = cb->buffer + cb->buffer_size;
+ *             cb->fillcount = 0;
+ *             if(cb->buffer)
+ *                     return 1; / * success * /
+ *             return 0; / * malloc failed * / 
+ *     }
+ * 
+ * param buffersize:  r24
+ * param cb:          r22:r23
+ */
+.global circularbytebuffer_init
+circularbytebuffer_init:
+       push r28
+       push r29
+       movw r28, r22
+       std Y+0, r24 /* set buffer_size */
+       std Y+1, r1  /* set fillcount to 0 */
+       clr r25
+       call malloc
+       adiw r24, 0
+       brne 10f
+       clr r24
+       rjmp 99f
+10:
+       std Y+2, r24
+       std Y+3, r25
+       std Y+4, r24
+       std Y+5, r25
+       std Y+6, r24
+       std Y+7, r25
+       ld r22, Y
+       add r24, r22
+       adc r25, r1
+       std Y+8, r24
+       std Y+9, r25
+       ldi r24, 1      
+99:
+       clr r25
+       pop r29
+       pop r28
+       ret
+
+/******************************************************************************/
+/*
+ *     void circularbytebuffer_free(circularbytebuffer_t* cb){
+ *             free(cb->buffer);
+ *     }
+ *
+ * param cb:  r24:r25
+ */
+.global circularbytebuffer_free 
+circularbytebuffer_free:
+       movw r30, r24
+       ldd r24, Z+BUFFER_OFFSET
+       ldd r25, Z+BUFFER_OFFSET+1
+       jmp free
+
+#endif /* CIRCULARBYTEBUFFER_NO_MALLOC==0 */
+
+#if CIRCULARBYTEBUFFER_NO_INIT2==0
+
+/******************************************************************************/
+/*
+ *     void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer){
+ *             cb->buffer_size = buffersize;
+ *             cb->buffer = buffer
+ *             cb->head = cb->tail = cb->buffer;
+ *             cb->top = cb->buffer + cb->buffer_size;
+ *             cb->fillcount = 0;
+ *     }
+ * 
+ * param buffersize:  r24
+ * param cb:          r22:r23
+ * param buffer:      r20:r21
+ */
+.global circularbytebuffer_init2
+circularbytebuffer_init2:
+       movw r30, r22
+       std Z+0, r24 /* set buffer_size */
+       std Z+1, r1  /* set fillcount to 0 */
+       std Z+2, r20
+       std Z+3, r21
+       std Z+4, r20
+       std Z+5, r21
+       std Z+6, r20
+       std Z+7, r21
+       add r20, r24
+       adc r21, r1
+       std Z+8, r20
+       std Z+9, r21
+       ret
+
+#endif /* CIRCULARBYTEBUFFER_NO_INIT2==0 */
+
+/******************************************************************************/
+/*
+ *     uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb){
+ *             return (cb->fillcount);
+ *     }
+ *
+ * param cb:  r24:r25
+ */
+.global circularbytebuffer_cnt
+circularbytebuffer_cnt:
+       movw r30, r24
+       ldd r24, Z+FILLCOUNT_OFFSET
+       clr r25
+       ret
+       
+/******************************************************************************/
+/*
+ *     uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb){
+ *             uint8_t ret;
+ *             if(cb->fillcount==0)
+ *                     return 0xffff;
+ *             --cb->fillcount;
+ *             ret=*(cb->tail);
+ *             cb->tail = (uint8_t*)(cb->tail) + 1;
+ *             if(cb->tail>=cb->top)   
+ *                     cb->tail = (uint8_t*)(cb->tail) - cb->buffer_size;
+ *             return ret;     
+ *     }
+ * param cb:  r24:r25
+ */
+.global circularbytebuffer_get_lifo
+circularbytebuffer_get_lifo:
+       movw r30, r24
+       ldd r23, Z+FILLCOUNT_OFFSET
+       tst r23
+       brne 10f
+       ser r24
+       ser r25
+       ret
+10: 
+       dec r23
+       std Z+FILLCOUNT_OFFSET, r23
+       ldd r26, Z+TAIL_OFFSET
+       ldd r27, Z+TAIL_OFFSET+1
+       ld r24, X+
+       clr r25
+       ldd r22, Z+TOP_OFFSET
+       ldd r23, Z+TOP_OFFSET+1
+       cp  r26, r22
+       cpc r27, r23
+       brlo 20f
+       ldd r22, Z+BUFFER_SIZE_OFFSET
+       sub r26, r22
+       sbc r27, r1
+20:    
+       std Z+TAIL_OFFSET, r26
+       std Z+TAIL_OFFSET+1, r27
+       ret     
+
+/******************************************************************************/
+/*
+ *     uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb){
+ *             uint8_t ret;
+ *             if(cb->fillcount==0)
+ *                     return 0xffff;
+ *             --cb->fillcount;
+ *             ret=*(cb->head);
+ *             cb->head = (uint8_t*)(cb->head) - 1;
+ *             if(cb->head<cb->buffer) 
+ *                     cb->head = (uint8_t*)(cb->head) + cb->buffer_size;
+ *             return ret;
+ *     }
+ *
+ * param cb:  r24:r25
+ */
+.global circularbytebuffer_get_fifo
+circularbytebuffer_get_fifo:
+       movw r30, r24
+       ldd r23, Z+FILLCOUNT_OFFSET
+       tst r23
+       brne 10f
+       ser r24
+       ser r25
+       ret
+10: 
+       dec r23
+       std Z+FILLCOUNT_OFFSET, r23
+       ldd r26, Z+HEAD_OFFSET
+       ldd r27, Z+HEAD_OFFSET+1
+       ld r24, X
+       clr 25
+       sbiw r26, 1
+       ldd r22, Z+BUFFER_OFFSET
+       ldd r23, Z+BUFFER_OFFSET+1
+       cp  r26, r22
+       cpc r27, r23
+       brge 20f
+       ldd r22, Z+BUFFER_SIZE_OFFSET
+       add r26, r22
+       adc r27, r1
+20:    
+       std Z+HEAD_OFFSET, r26
+       std Z+HEAD_OFFSET+1, r27
+       ret     
+
+/******************************************************************************/
+/*
+ *     uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_t* cb){
+ *             if(cb->fillcount==cb->buffer_size)
+ *                     return 1;
+ *             cb->fillcount++;        
+ *             cb->tail = cb->tail - 1;
+ *             if(cb->tail<cb->buffer) 
+ *                     cb->tail = (uint8_t*)(cb->tail) + cb->buffer_size;
+ *             if(cb->fillcount==1)
+ *                     cb->head = cb->tail;
+ *             *(cb->tail) = elem;
+ *             return 0;
+ *     }
+ *
+ * param elem:  r24
+ * param cb:    r22:r23
+ */    
+.global circularbytebuffer_append
+circularbytebuffer_append:
+       movw r30, r22
+       ldd r22, Z+FILLCOUNT_OFFSET
+       ldd r23, Z+BUFFER_SIZE_OFFSET
+       cp r22, r23
+       brne 10f
+       ldi r24, 1
+       ret
+10:
+       clt
+       tst r22
+       brne 11f
+       set
+11:    
+       inc r22
+       std Z+FILLCOUNT_OFFSET, r22
+       ldd r26, Z+TAIL_OFFSET
+       ldd r27, Z+TAIL_OFFSET+1
+       sbiw r26, 1
+       ldd r22, Z+BUFFER_OFFSET
+       ldd r23, Z+BUFFER_OFFSET+1
+       cp  r26, r22
+       cpc r27, r23
+       brge 20f
+       ldd r22, Z+BUFFER_SIZE_OFFSET
+       add r26, r22
+       adc r27, r1     
+20:
+       std Z+TAIL_OFFSET, r26
+       std Z+TAIL_OFFSET+1, r27
+       brtc 30f
+       std Z+HEAD_OFFSET, r26
+       std Z+HEAD_OFFSET+1, r27
+30:
+       st X, r24
+       clr r24
+       ret     
+
+/******************************************************************************/
+/*
+ *     uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_t* cb){
+ *             if(cb->fillcount==cb->buffer_size)
+ *                     return 1;
+ *             cb->fillcount++;        
+ *             cb->head = cb->head + 1;
+ *             if(cb->head>=cb->top)   
+ *                     cb->head = (uint8_t*)(cb->head) - cb->buffer_size;
+ *             if(cb->fillcount==1)
+ *                     cb->tail = cb->head;
+ *             *(cb->head) = elem;
+ *             return 0;
+ *     }
+ * 
+ * param elem:  r24
+ * param cb:    r22:r23
+ */
+.global circularbytebuffer_push
+circularbytebuffer_push:
+       movw r30, r22
+       ldd r22, Z+FILLCOUNT_OFFSET
+       ldd r23, Z+BUFFER_SIZE_OFFSET
+       cp r22, r23
+       brne 10f
+       ldi r24, 1
+       ret
+10:
+       clt
+       tst r22
+       brne 11f
+       set
+11:    
+       inc r22
+       std Z+FILLCOUNT_OFFSET, r22
+       ldd r26, Z+HEAD_OFFSET
+       ldd r27, Z+HEAD_OFFSET+1
+       adiw r26, 1
+       ldd r22, Z+TOP_OFFSET
+       ldd r23, Z+TOP_OFFSET+1
+       cp  r26, r22
+       cpc r27, r23
+       brlo 20f
+       ldd r22, Z+BUFFER_SIZE_OFFSET
+       sub r26, r22
+       sbc r27, r1     
+20:
+       std Z+HEAD_OFFSET, r26
+       std Z+HEAD_OFFSET+1, r27
+       brtc 30b
+       std Z+TAIL_OFFSET, r26
+       std Z+TAIL_OFFSET+1, r27
+       rjmp 30b
diff --git a/test_src/circularbytebuffer.h b/test_src/circularbytebuffer.h
new file mode 100644 (file)
index 0000000..d1e40e4
--- /dev/null
@@ -0,0 +1,59 @@
+/* circularbytebuffer.h */
+/*
+    This file is part of the AVR-circularbytebuffer.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file     circularbytebuffer.h
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte 
+ * \date     2009-07-24
+ * \license  GPLv3 or later
+ * \ingroup  circularbytebuffer
+ * \brief    declaration for circular byte buffer
+ */
+#ifndef CIRCULARBYTEBUFFER_H_
+#define CIRCULARBYTEBUFFER_H_
+
+#include <stdint.h>
+#include <stdlib.h>
+#include "config.h"
+ typedef struct {
+        uint8_t buffer_size;
+        uint8_t fillcount;
+        uint8_t* buffer;
+        uint8_t* head;
+        uint8_t* tail;
+        uint8_t* top;
+} circularbytebuffer_t;
+
+
+#if CIRCULARBYTEBUFFER_NO_MALLOC==0
+uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb);
+#endif
+#if CIRCULARBYTEBUFFER_NO_INIT2==0
+void    circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer);
+#endif
+uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb);
+uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb);
+void circularbytebuffer_free(circularbytebuffer_t* cb);
+
+#endif /* CIRCULARBYTEBUFFER_H_ */
diff --git a/test_src/cli-basics.S b/test_src/cli-basics.S
new file mode 100644 (file)
index 0000000..e3cefc7
--- /dev/null
@@ -0,0 +1,150 @@
+/* cli-basics.S */
+/*
+    This file is part of the AVR-Huffman.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "avr-asm-macros.S"
+
+.extern cli_tx
+.extern cli_rx
+.extern cli_echo
+
+/******************************************************************************/
+.global cli_putc
+cli_putc:
+       lds r30, cli_tx
+       lds r31, cli_tx+1
+       adiw r30, 0
+       breq 2f
+       ijmp
+
+/******************************************************************************/
+.global cli_getc
+cli_getc:
+       lds r30, cli_rx
+       lds r31, cli_rx+1
+       adiw r30, 0
+       breq 1f
+       ijmp
+1:
+       ser r24
+       ser r25
+2:
+       ret
+
+/******************************************************************************/
+.global cli_getc_cecho
+cli_getc_cecho:
+       lds r30, cli_rx
+       lds r31, cli_rx+1
+       adiw r30, 0
+       brne 1f
+       ser r25
+       ser r24
+       ret
+1:     
+       icall
+       lds r20, cli_echo
+       tst r20
+       brne 2f
+       ret
+2:     
+       push r2
+       mov r2, r24
+       rcall cli_putc
+       mov r24, r2
+       clr r25
+       pop r2
+       ret
+       
+/******************************************************************************/
+.global cli_putstr
+cli_putstr:
+       push r28
+       push r29
+       movw r28, r24
+1:
+       ld r24, Y+
+       clr r25
+       tst r24
+       breq 2f
+       rcall cli_putc
+       rjmp 1b
+2:     
+       pop r29
+       pop r28
+       ret
+
+/******************************************************************************/
+.global cli_putstr_P
+cli_putstr_P:
+       push r28
+       push r29
+       movw r28, r24
+1:
+       movw r30, r28
+       lpm r24, Z
+       clr r25
+       tst r24
+       breq 2f
+       rcall cli_putc
+       adiw r28, 1
+       rjmp 1b
+2:     
+       pop r29
+       pop r28
+       ret
+
+/******************************************************************************/
+/*
+ * param s: r24:r25
+ * param n: r22:r23
+ */    
+.global cli_getsn
+cli_getsn:
+       push r28
+       push r29
+       push r16
+       push r17
+       movw r28, r24
+       ldi r20, 2
+       movw r24, r22
+       adiw r24, 0
+       breq 9f
+1:
+       movw r16, r22
+2:     clr r20
+       rcall cli_getc
+       cpi r24, '\r'
+       breq 9f
+       ldi r20, 1
+       tst r24
+       breq 9f
+       st Y+, r24
+       movw r26, r16
+       sbiw r26, 1
+       movw r16, r24
+       brne 2b
+9:     
+       clr r25
+       mov r24, r20
+       st Y, r1
+       pop r17
+       pop r16
+       pop r28
+       pop r29
+       ret
diff --git a/test_src/cli-core.S b/test_src/cli-core.S
new file mode 100644 (file)
index 0000000..f074b04
--- /dev/null
@@ -0,0 +1,406 @@
+/* cli-core.S */
+/*
+    This file is part of the AVR-Huffman.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "avr-asm-macros.S"
+
+#define CMDLIST_ENTRY_SIZE 8
+
+/******************************************************************************/
+/* uint16_t max_cmd_length(PGM_VOID_P cmdlist){
+       uint16_t t,ret=0;
+       char* str;
+       for(;;){
+               str = (char*)pgm_read_word(cmdlist);
+               cmdlist = (uint8_t*)cmdlist + CMDLIST_ENTRY_SIZE;
+               if(str==NULL)
+                       return ret;
+               t = strlen_P(str);
+               if(t>ret)
+                       ret=t;
+       }
+}
+ *    param cmdlist:  r24:r25
+ */
+TMP_CNT_0 = 26
+TMP_CNT_1 = 27 
+.global max_cmd_length
+max_cmd_length:
+       movw r30, r24
+       clr r24
+       clr r25
+1:
+       lpm r26, Z+
+       lpm r27, Z+
+       movw r20, r30
+       adiw r26, 0
+       brne 3f
+       ret
+3:
+       movw r30, r26
+       clr TMP_CNT_0
+       clr TMP_CNT_1
+4:
+       lpm r1, Z+
+       adiw TMP_CNT_0, 1
+       tst r1
+       brne 4b
+       sbiw TMP_CNT_0, 1
+       movw r30, r20
+       adiw r30, CMDLIST_ENTRY_SIZE-2
+       cp  r24, TMP_CNT_0
+       cpc r25, TMP_CNT_1
+       brge 1b
+       movw r24, TMP_CNT_0
+       rjmp 1b
+                
+/******************************************************************************/
+.global echo_ctrl
+echo_ctrl: 
+       call strstrip
+       tst r24
+       brne 3f
+       tst r25
+       breq print_echo_status
+3:
+       call strlwr
+       movw r26, r24
+       ld r20, X+
+       tst r20
+       breq print_echo_status
+       cpi r20, '1'
+       breq exit_1
+       cpi r20, '0'
+       breq exit_0
+       cpi r20, 't'
+       breq exit_1
+       cpi r20, 'f'
+       breq exit_0
+       ld r20, X+
+       cpi r20, 'n'
+       breq exit_1
+       cpi r20, 'f'
+       breq exit_0     
+       ret
+exit_1:        
+       ldi r20, 1
+       rjmp exit
+exit_0:
+       ldi r20, 0
+exit:  
+       sts cli_echo, r20
+       ret
+print_echo_status:
+       ldi r24, lo8(pecho)
+       ldi r25, hi8(pecho)
+       rcall cli_putstr_P
+       lds r20, cli_echo
+       tst r20
+       breq 3f
+       clr r25
+       ldi r24, 'n'
+       rcall cli_putc
+       rjmp 4f
+3:     clr r25
+       ldi r24, 'f'
+       rcall cli_putc
+       clr r25
+       ldi r24, 'f'
+       rcall cli_putc
+4:     clr r25
+       ldi r24, '\r'
+       rcall cli_putc
+       clr r25
+       ldi r24, '\n'
+       rcall cli_putc
+       ret             
+pecho:
+.asciz "\r\necho is o"
+
+/******************************************************************************/
+/* int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist)        
+ *    param cmd:          r24:r25
+ *    param maxcmdlength: r22:r23
+ *    param cmdlist:      r20:r21
+ */
+LEN_0 = 14
+LEN_1 = 15
+CMD_0 = 16
+CMD_1 = 17
+
+snc_auto_help:
+       movw r24, r22
+       movw r22, r20
+       rcall cli_auto_help     
+snc_return_1:
+       ldi r24, 1
+       rjmp snc_return
+snc_return_2:
+       ldi r24, 2
+snc_return:
+       clr r25
+       ret      
+
+.global search_and_call
+search_and_call:
+       adiw r24, 0
+       breq snc_return_1
+1:     movw r26, r24
+       ld r18, X+
+       cpi r18, 0
+       breq snc_return_1
+       cpi r18, '#'
+       breq snc_return_1
+       cpi r18, '?'
+       breq 2f
+       cpi r18, 'h'
+       brne 1f
+       ld r18, X+
+       cpi r18, 'e'
+       brne 1f
+       ld r18, X+
+       cpi r18, 'l'
+       brne 1f
+       ld r18, X+
+       cpi r18, 'p'
+       brne 1f
+       ld r18, X+
+       tst r18
+       brne 1f
+2:     rjmp snc_auto_help
+1:     
+       push r28
+       push r29
+       push CMD_0
+       push CMD_1
+       push LEN_0
+       push LEN_1
+       movw CMD_0, r24
+       movw r28, r20
+       rcall firstword_length
+       movw LEN_0, r24
+       movw r26, CMD_0
+       add r26, LEN_0
+       adc r27, LEN_1
+       st X, r1
+       movw r24, CMD_0
+       ldi r22, lo8(exit_str)
+       ldi r23, hi8(exit_str)
+       call strcmp_P
+       adiw r24, 0
+       breq snc_return_0
+1:
+       movw r30, r28
+       lpm r24, Z+
+       lpm r25, Z+
+       adiw r24, 0
+       brne 3f
+       ldi r24, lo8(nocommand_str)
+       ldi r25, hi8(nocommand_str)
+       rcall cli_putstr_P
+       ldi r24, 1
+       rjmp 5f
+3:     movw r22, r24
+       movw r24, CMD_0
+       call strcmp_P
+       adiw r24, 0
+       breq snc_found
+       adiw r28, CMDLIST_ENTRY_SIZE
+       rjmp 1b
+snc_found:
+       movw r24, CMD_0
+       add r24, LEN_0
+       adc r25, LEN_1
+       adiw r24, 1
+       movw r30, r28
+       adiw r30, 4
+       lpm r22, Z+
+       lpm r23, Z+
+       movw r30, r22
+       adiw r30, 0
+       breq 4f ;snc_return_2
+       icall
+       ldi r24, 1
+       rjmp 5f
+4:     ldi r24, 2      
+snc_return_0:
+       clr r24
+5:     pop LEN_1
+       pop LEN_0
+       pop CMD_1
+       pop CMD_0
+       pop r29
+       pop r28
+       rjmp snc_return
+
+exit_str:
+.asciz "exit"
+help_str:
+.asciz "help"
+nocommand_str:
+.asciz "\r\ncommand not found, try 'help'"
+
+/******************************************************************************/
+/* void cli_option_listing(char* buffer, PGM_VOID_P cmdlist)
+ *   param buffer:    r24:r25
+ *   param cmdlist:   r22:r23
+ */
+ITM_0 = 12
+ITM_1 = 13 
+CMD_0 = 14
+CMD_1 = 15
+LEN_0 = 16
+LEN_1 = 17
+LST_0 = 28
+LST_1 = 29
+.global cli_option_listing
+cli_option_listing:
+       push_range 12, 17
+       push_range 28, 29
+       movw CMD_0, r24
+       movw LST_0, r22
+       call strlen
+       sbiw r24, 1
+       movw LEN_0, r24
+1:
+       movw r30, LST_0
+       lpm r24, Z+
+       lpm r25, Z+
+       movw ITM_0, r24
+       adiw r24, 0
+       breq 99f
+       movw r22, r24
+       movw r24, CMD_0
+       movw r20, LEN_0
+       adiw r28, CMDLIST_ENTRY_SIZE
+       call strncmp_P
+       adiw r24, 0
+       brne 1b
+       ldi r24, lo8(itemprefix_str)
+       ldi r25, hi8(itemprefix_str)
+       rcall cli_putstr_P
+       movw r24, ITM_0
+       rcall cli_putstr_P
+       rjmp 1b
+99:    
+       ldi r24, lo8(prompt_str)
+       ldi r25, hi8(prompt_str)
+       rcall cli_putstr_P
+       movw r24, CMD_0
+       rcall cli_putstr
+       pop_range 28, 29
+       pop_range 12, 17
+       ret
+
+prompt_str:    
+.asciz "\r\n>"
+itemprefix_str:        
+.asciz "\r\n   "
+
+/******************************************************************************/
+/* void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist)
+ *   param maxcmdlength:  r24:r25
+ *   param cmdlist:       r22:r23
+ */
+
+TMP_0 = 14
+TMP_1 = 15 
+LEN_0 = 16
+LEN_1 = 17
+LST_0 = 28
+LST_1 = 29
+cli_auto_help:
+       push_range 16, 17
+       push_range 28, 29
+       movw LEN_0, r24
+       movw r28, r22
+       ldi r24, lo8(ahelphead_str)
+       ldi r25, hi8(ahelphead_str)
+       rcall cli_putstr_P
+1:
+       movw r30, r28
+       lpm r24, Z+
+       lpm r25, Z+
+       movw r28, r30
+       adiw r24, 0
+       breq 99f        
+       movw TMP_0, r24
+       rcall cli_putstr_P
+       movw r24, TMP_0
+       call strlen_P
+       movw TMP_0, LEN_0
+       sub TMP_0, r24
+       sbc TMP_1, r25
+       breq 4f
+2:     ldi r24, ' '
+       clr r25
+       rcall cli_putc
+       dec TMP_0
+       brne 2b
+4:     ldi r24, lo8(sep_str)
+       ldi r25, hi8(sep_str)
+       ldi r22, lo8(none_str)
+       ldi r23, hi8(none_str)
+       rcall cli_putstr_P
+       movw r30, r28
+       lpm r24, Z+
+       lpm r25, Z+
+       movw r28, r30
+       adiw r24, 0
+       breq 5f
+       ldi r22, lo8(yes_str)
+       ldi r23, hi8(yes_str)
+5:     movw r24, r22
+       rcall cli_putstr_P      
+       ldi r24, lo8(sep2_str)
+       ldi r25, hi8(sep2_str)
+       rcall cli_putstr_P
+       movw r30, r28
+       adiw r30, 1
+       lpm r24, Z
+       rcall cli_hexdump_byte
+       movw r30, r28
+       lpm r24, Z
+       rcall cli_hexdump_byte
+       ldi r24, '\r'
+       clr r25
+       rcall cli_putc
+       ldi r24, '\n'
+       clr r25
+       rcall cli_putc
+       adiw r28, CMDLIST_ENTRY_SIZE-4
+       rjmp 1b
+99:    
+       pop_range 28, 29
+       pop_range 14, 17
+       ret
+ahelphead_str:
+.asciz "\r\n[auto help] available commands:\r\n <command> - <params> - <address>\r\n"
+sep_str:
+.asciz " - "
+none_str:
+.asciz "none"
+yes_str:
+.asciz "yes "
+sep2_str:
+.asciz" \t - 0x"
+.byte 0
+
+
+
+
diff --git a/test_src/cli-hexdump.S b/test_src/cli-hexdump.S
new file mode 100644 (file)
index 0000000..0a34984
--- /dev/null
@@ -0,0 +1,205 @@
+/* cli-hexdump.S */
+/*
+    This file is part of the AVR-Huffman.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "avr-asm-macros.S"
+/******************************************************************************/
+/* cli_hexdump_byte 
+ *   param data:   r24
+ */
+.global cli_hexdump_byte
+cli_hexdump_byte:
+       push r24
+       swap r24
+       andi r24, 0x0f
+       ldi r30, lo8(hexdigit_tab_P)
+       ldi r31, hi8(hexdigit_tab_P)
+       add r30, r24
+       adc r31, r1
+       clr r25
+       lpm r24, Z
+       rcall cli_putc
+       pop r24
+       andi r24, 0x0f
+       ldi r30, lo8(hexdigit_tab_P)
+       ldi r31, hi8(hexdigit_tab_P)
+       add r30, r24
+       adc r31, r1
+       clr r25
+       lpm r24, Z
+       rcall cli_putc
+       ret     
+
+/******************************************************************************/
+/* cli_hexdump 
+ *   param data:   r24:r25
+ *   param length: r22:r23
+ */
+.global cli_hexdump
+cli_hexdump:
+       push r28
+       push r29
+       push r16
+       push r17
+       movw r28, r24
+       movw r16, r22
+       movw r26, r22
+       adiw r26, 0
+       breq hexdump_exit
+2:
+       ld r24, Y+
+       rcall cli_hexdump_byte  
+       subi r16, 1
+       sbc  r17, r1
+       brne 2b
+hexdump_exit:  
+       pop r17
+       pop r16
+       pop r29
+       pop r28
+       ret
+       
+/******************************************************************************/
+/* cli_hexdump_rev 
+ *   param data:   r24:r25
+ *   param length: r22:r23
+ */
+.global cli_hexdump_rev
+cli_hexdump_rev:
+       push r28
+       push r29
+       push r16
+       push r17
+       movw r28, r24
+       movw r16, r22
+       add r28, r22
+       adc r29, r23
+       movw r26, r22
+       adiw r26, 0
+1:
+       breq hexdump_exit
+       ld r24, -Y
+       rcall cli_hexdump_byte  
+       subi r16, 1
+       sbci r17, 0
+       rjmp 1b
+       
+/******************************************************************************/
+/* cli_hexdump2
+ *   param data:   r24:r25
+ *   param length: r22:r23
+ */
+.global cli_hexdump2
+cli_hexdump2:
+       push r28
+       push r29
+       push r16
+       push r17
+       movw r28, r24
+       movw r16, r22
+       movw r26, r16
+       adiw r26, 0
+1:     
+       breq hexdump_exit
+       ld r24, Y+
+       rcall cli_hexdump_byte
+       clr r25
+       ldi r24,' '
+       rcall cli_putc
+       
+       subi r16, 1
+       sbci r17, 0
+       rjmp 1b
+
+/******************************************************************************/
+/* void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width)
+ *   param data:     r24:r25
+ *   param length:   r22:r23
+ *   param indent:   r20
+ *   param width:    r18
+ */
+WIDTH  =  2
+INDENT =  3
+DATA_0 = 28
+DATA_1 = 29
+LENG_0 = 16
+LENG_1 = 17
+
+.global cli_hexdump_block
+cli_hexdump_block:
+       tst r22
+       brne 1f
+       tst r23
+       brne 1f
+       ret
+1:
+       push WIDTH
+       push INDENT
+       push DATA_0
+       push DATA_1
+       push LENG_0
+       push LENG_1
+       push r4
+       mov WIDTH, r18
+       mov INDENT, r20
+       movw DATA_0, r24
+       movw LENG_0, r22 
+2:
+       clr r25
+       ldi r24, '\r'
+       rcall cli_putc
+       clr r25
+       ldi r24, '\n'
+       rcall cli_putc
+       mov r4, INDENT
+       tst r4
+       breq 4f
+3:     clr r25
+       ldi r24, ' '
+       rcall cli_putc
+       dec r4
+       brne 3b
+4:
+       movw r24, DATA_0
+       clr r23
+       mov r22, WIDTH
+       tst LENG_1
+       brne 7f
+       cp WIDTH, LENG_0
+       breq 6f
+       brmi 7f
+       mov r22, LENG_0
+6:     inc r4  
+7:     
+       rcall cli_hexdump2
+       add DATA_0, WIDTH
+       adc DATA_1, r1
+       sub LENG_0, WIDTH
+       sbc LENG_0, r1
+       tst r4
+       breq 2b 
+       pop r4
+       pop LENG_1
+       pop LENG_0
+       pop DATA_1
+       pop DATA_0
+       pop INDENT
+       pop WIDTH
+       ret
+       
+       
diff --git a/test_src/cli-stub.c b/test_src/cli-stub.c
new file mode 100644 (file)
index 0000000..ec6ac1d
--- /dev/null
@@ -0,0 +1,189 @@
+/* cli.c */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * 
+ * author: Daniel Otte
+ * email:  daniel.otte@rub.de
+ * license: GPLv3 or later
+ * 
+ * components to help implementing simple command based interaction
+ * 
+ **/
+#include <stdlib.h> 
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <avr/pgmspace.h>
+#include "string-extras.h"
+#include "cli.h"
+#include "config.h"
+#include "hexdigit_tab.h"
+
+cli_rx_fpt cli_rx = NULL;
+cli_tx_fpt cli_tx = NULL;
+uint8_t cli_echo=1;
+
+void echo_ctrl(char* s);
+uint16_t max_cmd_length(PGM_VOID_P cmdlist);
+int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist);
+void cli_option_listing(char* buffer, PGM_VOID_P cmdlist);
+       
+
+void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist);/*
+{
+       cmdlist_entry_t item;
+       uint16_t i;
+       if(!cli_tx)
+               return;
+       
+       cli_putstr_P(PSTR("\r\n[auto help] available commands:\r\n"
+                         " <command> - <params> - <address>\r\n"));
+       for(;;){
+               item.cmd_name      = (void*)pgm_read_word(cmdlist+0);
+               item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
+               item.cmd_function  = (void_fpt)pgm_read_word(cmdlist+4);
+               cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
+               if(item.cmd_name==NULL){
+                       return;
+               }
+               cli_tx(' ');
+               cli_putstr_P(item.cmd_name);
+               i=maxcmdlength-strlen_P(item.cmd_name);
+               while(i--)
+                       cli_tx(' ');
+               cli_putstr_P(PSTR(" - "));
+               if(item.cmd_param_str==NULL){
+                       cli_putstr_P(PSTR("none \t- 0x"));
+               } else {
+                       if(item.cmd_param_str==(void*)1){
+                               cli_putstr_P(PSTR("yes  \t- 0x"));
+                       } else {
+                               cli_putstr_P(item.cmd_param_str);
+                               cli_putstr_P(PSTR(" \t- 0x"));
+                       }
+               }
+               cli_hexdump_rev(&item.cmd_function, 2); 
+               cli_putstr_P(PSTR("\r\n"));
+       }
+}
+*/
+typedef void(*str_fpt)(char*);
+#define CLI_ENTER     13
+#define CLI_BACKSPACE  8
+#define CLI_TABULATOR  9
+
+uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
+       uint8_t i=0;
+       char ref[maxcmdlength+1];
+       char* itemstr;
+       ref[0]='\0';
+       /* check if we are behind the first word */
+       while(buffer[i]){
+               if(!isgraph(buffer[i++]))
+                       return 0;
+       }
+       for(;;){
+               itemstr = (char*)pgm_read_word(cmdlist);
+               if(itemstr==NULL)
+                       break;
+               cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
+               if(!strncmp_P(buffer, itemstr, i)){
+                       if(!ref[0]){
+                               strcpy_P(ref, itemstr);
+                       }else{
+                               ref[stridentcnt_P(ref, itemstr)]='\0';
+                       }
+               }
+       }
+       i = strcmp(buffer, ref);
+       if(i)
+               strcpy(buffer, ref);
+       return ~i;
+}
+
+int8_t cmd_interface(PGM_VOID_P cmd_desc){
+       uint16_t cli_buffer_size;
+       uint16_t cli_buffer_index;
+       int8_t exit_code;
+       uint8_t completion_failed=0;
+       char* cli_buffer;
+       char c;
+       uint16_t maxcmdlength = max_cmd_length(cmd_desc);
+       cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2);
+       cli_buffer_index=0;
+       if(!cli_rx)
+               return -1;
+       if(cli_tx)
+               cli_tx('>');
+       for(;;){
+               c = cli_rx();
+               switch (c){
+               case CLI_ENTER:
+                       if((exit_code=search_and_call(cli_buffer, maxcmdlength, cmd_desc))<=0){
+                               free(cli_buffer);
+                               return exit_code;
+                       }
+                       memset(cli_buffer, 0, cli_buffer_size);
+                       cli_buffer_index=0;
+                       cli_putstr_P(PSTR("\r\n>"));
+                       completion_failed=0;
+                       break;
+               case CLI_BACKSPACE:
+                       completion_failed=0;
+                       if(cli_buffer_index==0)
+                               break;
+                       cli_buffer_index--;
+                       cli_buffer[cli_buffer_index] = '\0';
+                       if(cli_echo && cli_tx){
+                               cli_tx(c);
+                       }
+                       break;
+               case CLI_TABULATOR:
+                       if(completion_failed || cli_buffer_index==0){
+                               if(cli_tx)
+                                       cli_option_listing(cli_buffer, cmd_desc);
+                       } else {
+                               uint16_t old_idx = cli_buffer_index;
+                               completion_failed = 
+                                       ~cli_completion(cli_buffer, maxcmdlength, cmd_desc);
+                               cli_buffer_index = strlen(cli_buffer);
+                               if(cli_echo && cli_tx){
+                                       while(old_idx<cli_buffer_index){
+                                               cli_tx(cli_buffer[old_idx++]);
+                                       }
+                               }
+                       }
+                       break;
+               default:
+                       completion_failed=0;
+                       if(cli_echo && cli_tx){
+                               cli_tx(c);
+                       }
+                       if(cli_buffer_index+1==cli_buffer_size){
+                               cli_buffer = realloc(cli_buffer, cli_buffer_size+=CLI_BUFFER_BS);
+                               if(!cli_buffer){
+                                       return -2;
+                               }
+                               memset(cli_buffer+cli_buffer_index+1, 0, CLI_BUFFER_BS);
+                       }
+                       cli_buffer[cli_buffer_index++] = c;
+               }
+       }
+}
diff --git a/test_src/cli.c b/test_src/cli.c
deleted file mode 100644 (file)
index 95b0272..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-/* cli.c */
-/*
-    This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * 
- * author: Daniel Otte
- * email:  daniel.otte@rub.de
- * license: GPLv3 or later
- * 
- * components to help implementing simple command based interaction
- * 
- **/
-#include <stdlib.h> 
-#include <stdint.h>
-#include <ctype.h>
-#include <string.h>
-#include <avr/pgmspace.h>
-#include "string-extras.h"
-#include "cli.h"
-#include "config.h"
-#include "hexdigit_tab.h"
-
-cli_rx_fpt cli_rx = NULL;
-cli_tx_fpt cli_tx = NULL;
-uint8_t cli_echo=1;
-
-/**
- * \brief output a character to the console
- * 
- */
-
-void cli_putc(char c){
-       if(cli_tx)
-               cli_tx(c);
-}
-
-/**
- * \brief get a character from the console
- * Gets a character from the console input and blocks
- * until a character is recieved
- */
-uint16_t cli_getc(void){
-       if(cli_rx)
-               return cli_rx();
-       return ((uint16_t)-1);
-}
-
-/**
- * \brief get a character from the console
- * Gets a char from the console input (like cli_getc())
- * and echos it back to the console if echo is enabled.
- */
-uint16_t cli_getc_cecho(void){
-       char c;
-       if(cli_rx){
-               c = cli_rx();
-               if(cli_tx && cli_echo)
-                       cli_tx(c);
-               return c;
-       }
-       return ((uint16_t)-1);
-}
-
-/**
- * \brief ouputs a zero-terminated string from ram to the console 
- */
-void cli_putstr(const char* s){
-       if(!cli_tx)
-               return;
-       while(*s)
-               cli_tx(*s++);
-}
-
-
-/**
- * \brief ouputs a zero-terminated string from flash to the console 
- */
-void cli_putstr_P(PGM_P s){
-       char c;
-       if(!cli_tx)
-               return;
-       for(;;){
-               c = pgm_read_byte(s++);
-               if(!c)
-                       return;
-               cli_tx(c);
-       }
-}
-
-/**
- * \brief reads a line or max n characters from the console
- * Writes characters from the console into the supplyed buffer until a '\r'
- * character is recieved or until n character a read (whatever happens first).
- * The string will always be terminated by a '\0' character, so the buffer
- * should have at least a size of n+1. 
- */
-uint8_t cli_getsn(char* s, uint16_t n){
-       char c;
-       if(n==0)
-               return 2;
-       while((c=cli_getc_cecho())!='\0' && c!='\r' && n--){
-               *s++=c;
-       }
-       *s='\0';
-       return (c=='\r')?0:1;
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Dumps length bytes from data to the console ouput. The dump
- * will have 2*n continous hexadecimal characters.
- */
-void cli_hexdump(const void* data, uint16_t length){
-       if(!cli_tx)
-               return;
-       while(length--){
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
-               data = (uint8_t*)data +1;
-       }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * This function behaves like cli_hexdump except that the
- * bytes are dumped in reverse order. This is usefull to dump
- * integers which ar e in little endian order.
- */
-void cli_hexdump_rev(const void* data, uint16_t length){
-       if(!cli_tx)
-               return;
-       data = (uint8_t*)data + length -1;
-       while(length--){
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
-               data = (uint8_t*)data -1;
-       }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Like cli_hexdump but bytes are seperated with a single space
- * on the console output.
- */
-void cli_hexdump2(const void* data, uint16_t length){
-       if(!cli_tx)
-               return;
-       while(length--){
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
-               cli_tx(' ');
-               data = (uint8_t*)data +1;
-       }
-}
-
-/**
- * \brief dumps the contents of a buffer to the console
- * Like cli_hexdump but bytes are seperated with a single space
- * on the console output.
- */
-void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width){
-       uint16_t i;
-       uint8_t  j;
-       if(!cli_tx)
-               return;
-       for(i=0; i<length; ++i){
-               if(i%width==0){
-                       cli_putstr_P(PSTR("\r\n"));
-                       for(j=0; j<indent; ++j){
-                               cli_tx(' ');
-                       }
-               }
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))>>4)));
-               cli_tx(pgm_read_byte(hexdigit_tab_P +((*((uint8_t*)data))&0xf)));
-               cli_tx(' ');
-               data = (uint8_t*)data +1;
-       }
-}
-
-static
-void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist){
-       cmdlist_entry_t item;
-       uint16_t i;
-       if(!cli_tx)
-               return;
-       
-       cli_putstr_P(PSTR("\r\n[auto help] available commands:\r\n"
-                         " <command> - <params> - <address>\r\n"));
-       for(;;){
-               item.cmd_name      = (void*)pgm_read_word(cmdlist+0);
-               item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
-               item.cmd_function  = (void_fpt)pgm_read_word(cmdlist+4);
-               cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
-               if(item.cmd_name==NULL){
-                       return;
-               }
-               cli_tx(' ');
-               cli_putstr_P(item.cmd_name);
-               i=maxcmdlength-strlen_P(item.cmd_name);
-               while(i--)
-                       cli_tx(' ');
-               cli_putstr_P(PSTR(" - "));
-               if(item.cmd_param_str==NULL){
-                       cli_putstr_P(PSTR("none \t- 0x"));
-               } else {
-                       if(item.cmd_param_str==(void*)1){
-                               cli_putstr_P(PSTR("yes  \t- 0x"));
-                       } else {
-                               cli_putstr_P(item.cmd_param_str);
-                               cli_putstr_P(PSTR(" \t- 0x"));
-                       }
-               }
-               cli_hexdump_rev(&item.cmd_function, 2); 
-               cli_putstr_P(PSTR("\r\n"));
-       }
-}
-
-void echo_ctrl(char* s){
-       s = strstrip(s);
-       if(s==NULL || *s=='\0'){
-               cli_putstr_P(PSTR("\r\necho is "));
-               cli_putstr_P(cli_echo?PSTR("on"):PSTR("off"));
-               cli_putstr_P(PSTR("\r\n"));             
-       }
-       strlwr(s);
-       if(!strcmp_P(s, PSTR("true")) || !strcmp_P(s, PSTR("on")) || *s=='1'){
-               cli_echo=1;
-       }
-       if(!strcmp_P(s, PSTR("false")) || !strcmp_P(s, PSTR("off")) || *s=='0'){
-               cli_echo=0;
-       }
-}
-
-typedef void(*str_fpt)(char*);
-#define CLI_ENTER     13
-#define CLI_BACKSPACE  8
-#define CLI_TABULATOR  9
-
-int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
-       PGM_VOID_P cmdlist_orig = cmdlist;
-       if(*cmd=='\0' || *cmd=='#')
-               return 1;
-       if(!strcmp_P(cmd, PSTR("exit")))
-               return 0;
-       if((!strcmp_P(cmd, PSTR("help"))) || (!strcmp_P(cmd, PSTR("?")))){
-               cli_auto_help(maxcmdlength, cmdlist);
-               return 1;
-       }
-       uint16_t fwlength=firstword_length(cmd);
-       char fw[fwlength+1];
-       memcpy(fw, cmd, fwlength);
-       fw[fwlength] = '\0';
-       cmdlist_entry_t item;
-       do{
-               item.cmd_name =      (void*)pgm_read_word(cmdlist+0);
-               item.cmd_param_str = (void*)pgm_read_word(cmdlist+2);
-               item.cmd_function =  (void_fpt)pgm_read_word(cmdlist+4);
-               cmdlist = (uint8_t*)cmdlist+CMDLIST_ENTRY_SIZE;
-       }while(item.cmd_name!=NULL && strcmp_P(fw, item.cmd_name));
-       if(item.cmd_name==NULL){
-               cli_auto_help(maxcmdlength, cmdlist_orig);
-       } else {
-               if(item.cmd_function==NULL)
-                       return 2;
-               switch((uint16_t)item.cmd_param_str){
-                       case 0:
-                               item.cmd_function();
-                               break;
-                       case 1:
-                               if(cmd[fwlength]=='\0'){
-                                       ((str_fpt)item.cmd_function)(cmd+fwlength);
-                               } else {
-                                       ((str_fpt)item.cmd_function)(cmd+fwlength+1);
-                               }
-                               break;
-                       default:
-                               cli_putstr_P(PSTR("\r\nparam parsing currently not implemented!\r\n"));
-                               break;
-               }       
-               
-       }       
-       return 1;        
-}
-
-uint16_t max_cmd_length(PGM_VOID_P cmdlist){
-       uint16_t t,ret=0;
-       char* str;
-       for(;;){
-               str = (char*)pgm_read_word(cmdlist);
-               cmdlist = (uint8_t*)cmdlist + CMDLIST_ENTRY_SIZE;
-               if(str==NULL)
-                       return ret;
-               t = strlen_P(str);
-               if(t>ret)
-                       ret=t;
-       }
-}
-
-uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
-       uint8_t i=0;
-       char ref[maxcmdlength+1];
-       char* itemstr;
-       ref[0]='\0';
-       /* check if we are behind the first word */
-       while(buffer[i]){
-               if(!isgraph(buffer[i++]))
-                       return 0;
-       }
-       for(;;){
-               itemstr = (char*)pgm_read_word(cmdlist);
-               if(itemstr==NULL)
-                       break;
-               cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
-               if(!strncmp_P(buffer, itemstr, i)){
-                       if(!ref[0]){
-                               strcpy_P(ref, itemstr);
-                       }else{
-                               ref[stridentcnt_P(ref, itemstr)]='\0';
-                       }
-               }
-       }
-       i = strcmp(buffer, ref);
-       if(i)
-               strcpy(buffer, ref);
-       return ~i;
-}
-
-void cli_option_listing(char* buffer, PGM_VOID_P cmdlist){
-       char* itemstr;
-       uint16_t len=strlen(buffer);
-       for(;;){
-               itemstr = (char*)pgm_read_word(cmdlist);
-               if(itemstr==NULL){
-                       cli_putstr_P(PSTR("\r\n>"));
-                       cli_putstr(buffer);
-                       return;
-               }
-               cmdlist = (uint8_t*)cmdlist +CMDLIST_ENTRY_SIZE;
-               if(!strncmp_P(buffer, itemstr, len)){
-                       cli_putstr_P(PSTR("\r\n    "));
-                       cli_putstr_P(itemstr);
-               }
-       }
-}
-
-int8_t cmd_interface(PGM_VOID_P cmd_desc){
-       uint16_t cli_buffer_size;
-       uint16_t cli_buffer_index;
-       int8_t exit_code;
-       uint8_t completion_failed=0;
-       char* cli_buffer;
-       char c;
-       uint16_t maxcmdlength = max_cmd_length(cmd_desc);
-       cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2);
-       cli_buffer_index=0;
-       if(!cli_rx)
-               return -1;
-       if(cli_tx)
-               cli_tx('>');
-       for(;;){
-               c = cli_rx();
-               switch (c){
-               case CLI_ENTER:
-                       if((exit_code=search_and_call(cli_buffer, maxcmdlength, cmd_desc))<=0){
-                               free(cli_buffer);
-                               return exit_code;
-                       }
-                       memset(cli_buffer, 0, cli_buffer_size);
-                       cli_buffer_index=0;
-                       cli_putstr_P(PSTR("\r\n>"));
-                       completion_failed=0;
-                       break;
-               case CLI_BACKSPACE:
-                       completion_failed=0;
-                       if(cli_buffer_index==0)
-                               break;
-                       cli_buffer_index--;
-                       cli_buffer[cli_buffer_index] = '\0';
-                       if(cli_echo && cli_tx){
-                               cli_tx(c);
-                       }
-                       break;
-               case CLI_TABULATOR:
-                       if(completion_failed || cli_buffer_index==0){
-                               if(cli_tx)
-                                       cli_option_listing(cli_buffer, cmd_desc);
-                       } else {
-                               uint16_t old_idx = cli_buffer_index;
-                               completion_failed = 
-                                       ~cli_completion(cli_buffer, maxcmdlength, cmd_desc);
-                               cli_buffer_index = strlen(cli_buffer);
-                               if(cli_echo && cli_tx){
-                                       while(old_idx<cli_buffer_index){
-                                               cli_tx(cli_buffer[old_idx++]);
-                                       }
-                               }
-                       }
-                       break;
-               default:
-                       completion_failed=0;
-                       if(cli_echo && cli_tx){
-                               cli_tx(c);
-                       }
-                       if(cli_buffer_index+1==cli_buffer_size){
-                               cli_buffer = realloc(cli_buffer, cli_buffer_size+=CLI_BUFFER_BS);
-                               if(!cli_buffer){
-                                       return -2;
-                               }
-                               memset(cli_buffer+cli_buffer_index+1, 0, CLI_BUFFER_BS);
-                       }
-                       cli_buffer[cli_buffer_index++] = c;
-               }
-       }
-}
index 1e07451b8e3bb14b65d41f5f0eb6f3bf76142b43..128b4bcb2278aa9cc921562ca53fe7ed681d0ac6 100644 (file)
@@ -24,7 +24,7 @@
 #include "config.h"
 
 #if DEBUG == uart
- #include "uart.h"
+ #include "uart_i.h"
 #else
   #error "Your DEBUG methode is not suported!"
 #endif
@@ -32,7 +32,7 @@
 #ifdef DEBUG
  void debug_init(void){
  #if DBUG==uart
-  uart_init();
+  uart0_init();
  #else
   #error "Your DEBUG methode is not suported!"
  #endif
  void debug_char(char c){
        static char initialised = 0;
        if (!initialised){
-               uart_init();
+               uart0_init();
                initialised=1;
        }       
-       uart_putc(c);
+       uart0_putc(c);
  }
  
  void debug_str(char* s){
diff --git a/test_src/dump-asm.S b/test_src/dump-asm.S
new file mode 100644 (file)
index 0000000..f38b48a
--- /dev/null
@@ -0,0 +1,436 @@
+/* dump-asm.S */
+/*
+    This file is part of the AVR-Huffman.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "avr-asm-macros.S"
+#include <avr/io.h>
+#include <avr/sfr_defs.h>
+#define DUMP_WIDTH 16
+
+#define ADDR_BASE 16
+/******************************************************************************/
+/* uint8_t charisinstr_P(char c, PGM_P str)
+ *   param c:    r24
+ *   param str:  r22:r23
+ */
+charisinstr_P:
+       movw r30, r22
+1:
+       lpm r22, Z+
+       tst r22
+       brne 2f
+       clr r24
+       ret
+2:
+       cp r22, r24
+       brne 1b
+       ldi r24, 1
+       ret
+       
+/******************************************************************************/
+/* void dump_chars(uint8_t* buffer, uint8_t len)
+ *   param buffer:  r24:r25
+ *   param len:     r22
+ */
+dump_chars:
+       push r16
+       push r17
+       push r28
+       push r29
+       movw r28, r24
+       mov r16, r22
+       ldi r24, '|'
+       clr r25
+       call cli_putc
+       mov r17, r16
+1:
+       ld r24, Y
+       clr     r25
+       call isprint
+       tst r24
+       brne 2f
+       ldi r24, '.'
+       adiw r28, 1
+       rjmp 3f
+2:     ld r24, Y+      
+3:     
+       clr r25
+       call cli_putc
+       dec r17
+       brne 1b
+       subi r16, DUMP_WIDTH
+       tst r16
+       breq 5f
+       neg r16
+4:     
+       ldi r24, ' '
+       clr r25
+       call cli_putc
+       dec r16
+       brne 4b
+5:
+       ldi r24, '|'
+       clr r25
+       call cli_putc   
+       pop r29
+       pop r28
+       pop r17
+       pop r16
+       ret
+ /*****************************************************************************/
+ /* void print_aligned(unsigned long value, uint8_t align)
+  *    param value: r22:r25
+  *    param align: r20
+  */
+print_aligned:
+       push r16
+       push r28
+       push r29
+       stack_alloc 12, r28, r29
+       adiw r28, 1
+       mov r16, r20
+       movw r20, r28
+       ldi  r18, ADDR_BASE
+       clr  r19
+       call ultoa
+       movw r24, r28
+       call strlen
+       sub r16, r24
+       brmi 3f
+       breq 3f
+1:
+       ldi r24, ' '
+       clr r25
+       call cli_putc
+       dec r16
+       brne 1b
+3:     
+       movw r24, r28
+       call cli_putstr
+       stack_free 12
+       pop r29
+       pop r28
+       pop r16
+       ret 
+
+ /*****************************************************************************/
+ /* void dump(char* s)
+  *    param s: r24:r25
+  */
+
+STR_0    =  4
+STR_1    =  5
+ADDR_0   =  6
+ADDR_1   =  7
+ADDR_2   =  8
+ADDR_3   =  9
+SIZE_0   = 10
+SIZE_1   = 11
+SIZE_2   = 12
+SIZE_3   = 13
+MEM_0    = 14
+MEM_1    = 15
+xREADLEN = 16
+TMP      = 17
+
+.global dump
+dump:
+       call strstrip
+       push_range 4, 17
+       push_range 28, 29
+       movw r26, r24
+       ld TMP, X
+       movw STR_0, r26
+       ldi r30, lo8(memtype_desc)
+       ldi r31, hi8(memtype_desc)
+1:
+       lpm r22, Z+
+       lpm r23, Z+
+       tst r22
+       brne 2f
+       tst r23
+       breq 5f
+2:
+       movw r28, r30
+       mov r24, TMP
+       clr r25
+       rcall charisinstr_P
+       movw r30, r28
+       tst r24
+       brne 6f
+       adiw r30, 4
+       rjmp 1b
+5:
+       ldi r30, lo8(memtype_desc+2)
+       ldi r31, hi8(memtype_desc+2)
+6:     
+       movw MEM_0, r30
+       movw r26, STR_0
+61:
+       ld r20, X+
+       ori r20, 'A'^'a'
+       cpi r20, 'a'
+       brmi 7f
+       cpi r20, 'z'+1
+       brge 7f
+       rjmp 61b
+7:
+       sbiw r26, 1
+       stack_alloc 2+DUMP_WIDTH, r28, r29
+       adiw r28, 1
+       movw r24, r26
+       movw r22, r28
+       clr r20
+       clr r21
+       call strtoul
+       movw ADDR_0, r22
+       movw ADDR_2, r24
+       ld r24, Y+
+       ld r25, Y+
+       clr r23
+       clr r22
+       clr r21
+       clr r20
+       call strtoul
+       movw SIZE_0, r22
+       movw SIZE_2, r24
+       tst SIZE_0
+       brne 72f
+       tst SIZE_1
+       brne 72f
+       tst SIZE_2
+       brne 72f
+       tst SIZE_3
+       brne 72f
+       ldi TMP, 128
+       mov SIZE_0, TMP
+72:    
+       ldi r24, lo8(dumping)
+       ldi r25, hi8(dumping)
+       call cli_putstr_P
+       movw r24, SIZE_2
+       movw r22, SIZE_0
+       movw r20, r28
+       clr r19
+       ldi r18, 10
+       call ultoa
+       movw r24, r28
+       call cli_putstr
+       ldi r24, lo8(bytesof)
+       ldi r25, hi8(bytesof)
+       call cli_putstr_P
+       movw r30, MEM_0
+       lpm r24, Z+
+       lpm r25, Z+
+       call cli_putstr_P       
+       ldi r24, lo8(beginning)
+       ldi r25, hi8(beginning)
+       call cli_putstr_P
+       movw r24, ADDR_2
+       movw r22, ADDR_0
+       movw r20, r28
+       clr r19
+       ldi r18, 16
+       call ultoa
+       movw r24, r28
+       call cli_putstr
+       ldi r24, lo8(suffix)
+       ldi r25, hi8(suffix)
+       call cli_putstr_P
+       
+       movw r30, MEM_0
+       adiw r30, 2
+       lpm MEM_0, Z+
+       lpm MEM_1, Z
+       
+1:     
+       ldi xREADLEN, DUMP_WIDTH
+       tst SIZE_3
+       brne 3f
+       tst SIZE_2
+       brne 3f
+       tst SIZE_1
+       brne 3f
+       tst SIZE_0
+       brne 2f
+       rjmp 90f
+2:     
+       cp DUMP_WIDTH, SIZE_0
+       brmi 3f
+       mov xREADLEN, SIZE_0
+3:     
+       movw r24, r28
+       movw r22, ADDR_2
+       movw r20, ADDR_0
+       clr r19
+       mov r18, xREADLEN
+       movw r30, MEM_0
+       icall
+       movw r24, ADDR_2
+       movw r22, ADDR_0
+       clr r21
+       ldi r20, 6
+       rcall print_aligned     
+       clr r25
+       ldi r24, ':'
+       call cli_putc
+       clr r25
+       ldi r24, ' '
+       call cli_putc
+       movw r24, r28
+       clr r23
+       mov r22, xREADLEN
+       call cli_hexdump2
+       ldi TMP, DUMP_WIDTH
+       sub TMP, xREADLEN
+       tst TMP
+       breq 5f
+4:
+       clr r25
+       ldi r24, ' '
+       call cli_putc
+       clr r25
+       ldi r24, ' '
+       call cli_putc
+       clr r25
+       ldi r24, ' '
+       call cli_putc
+       dec TMP
+       brne 4b
+5:
+       clr r25
+       ldi r24, '\t'
+       call cli_putc
+       movw r24, r28
+       clr r23
+       mov r22, xREADLEN
+       rcall dump_chars
+       add ADDR_0, xREADLEN
+       adc ADDR_1, r1
+       adc ADDR_2, r1
+       adc ADDR_3, r1
+       sub SIZE_0, xREADLEN
+       sbc SIZE_1, r1
+       sbc SIZE_2, r1
+       sbc SIZE_3, r1
+       clr r25
+       ldi r24, '\r'
+       call cli_putc
+       clr r25
+       ldi r24, '\n'
+       call cli_putc
+       rjmp 1b
+90:    
+       stack_free 2+DUMP_WIDTH
+       
+       pop_range 28,29
+       pop_range 4, 17
+       ret
+        
+dumping:        
+.asciz "\r\ndumping "
+bytesof:
+.asciz " bytes of "
+beginning:
+.asciz ", beginnig at 0x"
+suffix:
+.asciz ":\r\n"
+.byte 0
+
+/******************************************************************************/
+/* void pgm_read_block(void* buffer, uint32_t addr, uint8_t length)
+ *   param buffer:  r24:r25
+ *   param addr:    r20:r23
+ *   param length:  r18
+ */
+.global pgm_read_block
+pgm_read_block:
+#if RAMEND<0x10000
+       movw r26, r24
+       movw r30, r20
+       tst r18
+       breq 3f
+1:
+       lpm r20, Z+
+       st X+, r20
+       dec r18
+       brne 1b
+3:     
+       ret
+#else
+       movw r26, r24
+       movw r30, r20
+       out RAMPZ, r22
+       tst r18
+       breq 3f
+1:
+       elpm r20, Z+
+       st X+, r20
+       dec r18
+       brne 1b
+3:     
+       ret
+
+#endif 
+       
+/******************************************************************************/
+/* void ram_read_block(void* buffer, uint32_t addr, uint8_t length)
+ *   param buffer:  r24:r25
+ *   param addr:    r20:r23
+ *   param length:  r18
+ */
+.global ram_read_block
+ram_read_block:
+       movw r26, r24
+       movw r30, r20
+       tst r18
+       breq 3f
+1:
+       ld r20, Z+
+       st X+, r20
+       dec r18
+       brne 1b
+3:     
+       ret
+
+/******************************************************************************/
+/* void ee_read_block(void* buffer, uint32_t addr, uint8_t length)
+ *   param buffer:  r24:r25
+ *   param addr:    r20:r23
+ *   param length:  r18
+ */
+.global ee_read_block
+ee_read_block:
+       movw r26, r24
+       movw r30, r20
+       tst r18
+       breq 3f
+1:
+       sbic _SFR_IO_ADDR(EECR), EEPE
+       rjmp 1b
+       out _SFR_IO_ADDR(EEARH), r31
+       out _SFR_IO_ADDR(EEARL), r30
+       sbi _SFR_IO_ADDR(EECR), EERE
+       adiw r30, 1
+       in r20, _SFR_IO_ADDR(EEDR)
+       st X+, r20
+       dec r18
+       brne 1b
+3:     
+       ret
diff --git a/test_src/dump-decl.c b/test_src/dump-decl.c
new file mode 100644 (file)
index 0000000..0053df8
--- /dev/null
@@ -0,0 +1,64 @@
+/* dump.c */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file     dump.c
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte 
+ * \date     2009-02-04
+ * \license  GPLv3 or later
+ * 
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>                                    
+#include <ctype.h>
+#include <avr/pgmspace.h>
+#include <avr/eeprom.h>
+#include "cli.h" 
+#include "string-extras.h" 
+#define DUMP_WIDTH 16
+
+void pgm_read_block(void* buffer, uint32_t addr, uint8_t length);
+void ee_read_block(void* buffer, uint32_t addr, uint8_t length);
+void ram_read_block(void* buffer, uint32_t addr, uint8_t length);
+
+const char flash_trigger[]  PROGMEM = "fF";
+const char ram_trigger[]    PROGMEM = "sSrRmM";
+const char eeprom_trigger[] PROGMEM = "eE";
+
+const char flash_desc[]  PROGMEM = "flash";
+const char ram_desc[]    PROGMEM = "ram";
+const char eeprom_desc[] PROGMEM = "eeprom";
+
+typedef struct {
+       PGM_P trigger;
+       PGM_P desc;
+       void (*fpt)(void*, uint32_t, uint8_t);
+} memtype_desc_t;
+
+memtype_desc_t memtype_desc[] PROGMEM = {
+       { flash_trigger,   flash_desc,      pgm_read_block },
+       { eeprom_trigger,  eeprom_desc,     ee_read_block  },
+       { ram_trigger,     ram_desc   ,     ram_read_block },
+       { NULL,            NULL,            NULL        }
+};
+
+void dump(char* s);
diff --git a/test_src/dump.c b/test_src/dump.c
deleted file mode 100644 (file)
index 04b35cb..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* dump.c */
-/*
-    This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * \file     dump.c
- * \email    daniel.otte@rub.de
- * \author   Daniel Otte 
- * \date     2009-02-04
- * \license  GPLv3 or later
- * 
- */
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <avr/pgmspace.h>
-#include "cli.h" 
-#include "string-extras.h" 
-#define DUMP_WIDTH 16
-
-static
-void dump_chars(uint8_t* buffer){
-       uint8_t i;
-       cli_putc('|');
-       for(i=0; i<DUMP_WIDTH; ++i){
-               if(isprint(buffer[i])){
-                       cli_putc(buffer[i]);
-               }else{
-                       cli_putc('.');
-               }
-       }
-       cli_putc('|');
-}
-
-
-void dump(char* s){
-       uint8_t flash=1;
-       uint32_t addr=0;
-       uint32_t size=128;
-       uint8_t i,buffer[DUMP_WIDTH];
-       char tstr[9];
-       s=strstrip(s);
-       if(*s=='r' || *s=='R' || *s=='m' || *s=='M')
-               flash=0;
-       if(isalpha(*s)){
-               while(isalpha(*s))
-                       ++s;
-       }
-       char* eptr;
-       if(*s)
-               addr = strtoul(s, &eptr, 0);
-       if(eptr)
-               size = strtoul(eptr, NULL, 0);
-       if(!size)
-               size = 32;      
-       
-       cli_putstr_P(PSTR("\r\ndumping "));     
-       ultoa(size, tstr, 10);
-       cli_putstr(tstr);
-       cli_putstr_P(PSTR(" bytes of "));
-       cli_putstr_P(flash?PSTR("flash"):PSTR("ram"));
-       cli_putstr_P(PSTR(", beginning at 0x"));        
-       ultoa(addr, tstr, 16);
-       cli_putstr(tstr);
-       cli_putstr_P(PSTR(":\r\n"));    
-       while(size>=DUMP_WIDTH){
-               if(flash){
-                       for(i=0; i<DUMP_WIDTH; ++i){
-#ifdef pgm_read_byte_far                               
-                               buffer[i]=pgm_read_byte_far(addr+i);
-#else
-                               buffer[i]=pgm_read_byte(addr+i);
-#endif
-                       }
-               }else{
-                       memcpy(buffer, (void*)((uint16_t)addr), DUMP_WIDTH);
-               }
-               ultoa(addr, tstr, 16);
-               sprintf(tstr,"%6lX", addr);
-               cli_putstr(tstr);
-               cli_putstr_P(PSTR(": "));       
-               cli_hexdump2(buffer, DUMP_WIDTH);
-               cli_putc('\t');
-               dump_chars(buffer);
-               addr+=DUMP_WIDTH;
-               size-=DUMP_WIDTH;
-               cli_putstr_P(PSTR("\r\n"));
-       }
-       if(size){
-               if(flash){
-                       for(i=0; i<size; ++i){
-#ifdef pgm_read_byte_far                               
-                               buffer[i]=pgm_read_byte_far(addr+i);
-#else
-                               buffer[i]=pgm_read_byte(addr+i);
-#endif
-                       }
-               }else{
-                       memcpy(buffer, (void*)((uint16_t)addr), size);
-               }
-               ultoa(addr, tstr, 16);
-               sprintf(tstr,"%6lX", addr);
-               cli_putstr(tstr);
-               cli_putstr_P(PSTR(": "));       
-               cli_hexdump2(buffer, size);
-               cli_putstr_P(PSTR("\r\n"));
-       }
-}
-
index 79e19caca4eed3a79980f433be43c22824fcd658..c0803755cd3d55c77d5fe5ca85a4f39fbfc4de5d 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include <A5_1.h>
@@ -79,8 +79,8 @@ int main (void){
        DEBUG_INIT();
        
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index c505753ab4276f15a6cf93e8ccb583ef14bc76ba..8d2aba62c84baabe37e6853495dcb0759bc26e1c 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "aes.h"
@@ -319,8 +319,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index aa231635a92291f46e32df17a20a9260441821d1..e9b3ce495221b560aa1730848137fbf51273c616 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "aes.h"
@@ -170,8 +170,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 2dc0f0e10905ea4a76d108b85f3ca8057ef94aaa..577d05759baa6a6b9403fad9862770366cb2e223 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "aes.h"
@@ -149,8 +149,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index d800b7f5a4ec45dcb72649d12e05f78be519d78a..6b9f0b545a6316df31b13558362cadc521f8c25c 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "aes.h"
@@ -151,8 +151,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index f80fd96a49888b1075e9f9902c4c10e301860063..7e5489220743ca22447c97027dfb7979fb51b396 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include <arcfour.h>
@@ -107,8 +107,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index ece676cfe58af46becc6eb53000b9421e254bc68..a4ce3f38b8146d066007d8dd575fda27c4a44d3e 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "noekeon.h"
@@ -154,8 +154,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 316d1a074ca6fc2f9ec50de894b7bcc8f0d954e3..379ba2bea2a2cc142327ee638e38b6720287d771 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "blake_small.h"
@@ -132,8 +132,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&blake32_desc;
        for(;;){
index 22a370d0fd032febe6e82397e4e418eeedbcc62b..c76dc06d3a85a1ee514189d56b8e35fe52cea9b5 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "bmw_small.h"
@@ -134,8 +134,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&bmw256_desc;
        for(;;){
index c54765ac1c9e676d27079ba85df2e957d27440b2..2401557d59fe0000cb610d2886e65abf1536f3a5 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "camellia.h"
@@ -158,8 +158,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 4d2530c03abfc15a9360fb9339a8b2ab07038b6b..fe5915cf660b48346198d874b20af15186fe4bf4 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include <cast5.h>
@@ -209,8 +209,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index a2599741e045e2178029b6b2bda274e9e81a5257..d13a100cdf0c9238f271dc5d4e16e4810ce184f8 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "cast6.h"
@@ -156,8 +156,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 26a641516365c63071a0bae6e7d10ef6d31aeb86..5ccf7b66204a28bc30a524f065bd8f8c0df33f29 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "des.h"
@@ -113,8 +113,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 95f3fc1136fb6ef8d6fdbc1111548f092f6ab598..50ad2b191703659fb8b0325eec9544b62dadce18 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "entropium.h"
@@ -45,7 +45,7 @@ void testrun_entropium(void){
        char c, str[16];
        uint8_t data[32];
        uint32_t i=0;
-       while(!uart_getc_nb(&c)){
+       while('q'!=cli_getc()){
                entropium_getRandomBlock(data);
                cli_putstr_P(PSTR("\r\n "));
                ultoa(i, str, 10);
@@ -106,8 +106,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
 
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
index 04f0333f1b6e75e4430aeee5fa66a209b4e47c11..d1de7eafed7a8d5246dada45d571e437b7ead813 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 #include "cli.h"
 
@@ -169,8 +169,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 30d4bbe20103bedf811aa047a91c7dc6fb714af1..545f4eb2eca48848ecd584117a2687a8a49cded9 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "groestl_small.h"
@@ -134,8 +134,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&groestl256_desc;
        for(;;){
index a2b2a2257c3f40876a036c722e35f358ea13fadc..dfbcead79a50e047614332c00c7c560ad35f11e1 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "md5.h"
@@ -181,8 +181,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 
 int main (void){
        DEBUG_INIT();
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 865300f9836344c8ef3f5c4321c613127a9db181..33c06006bae780e4aee2abc6e69b621ca612e899 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "sha1.h"
@@ -76,8 +76,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 553cc5084beb6087a041a13577edbfcda752505e..0cc773af58f97b41fb0f98eb37f609d037f06132 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "sha256.h"
@@ -94,8 +94,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 7cd6049d1830b8f173d3e62f823366c8bd05b108..7f76748aba990ed2557f7ae7ac3108faeff43d6e 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "md5.h"
@@ -142,8 +142,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 5547ccf672749a0457db599ae8796a5df7f0e81a..cd83212a859431e67df676cf2a7c10c35b49873a 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 #include "cli.h"
 
@@ -137,8 +137,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index f49340152b7f1ab77907f93562caa7c5dc28c686..d8f38985419b67821a9fc6da5542df66c73bad8a 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "mugi.h"
@@ -129,8 +129,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index acd501d79d70cb320d7738043d3da02d94177d51..a08f38ff3271d8c1089e541902ce665c9ee624dc 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include <noekeon.h>
@@ -231,8 +231,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 50a40c076a7058da084c8c2be4e25cf5e935b62b..3df0d2e754cfc5aa26740d6e627a24b0ab9a4977 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "noekeon.h"
@@ -168,8 +168,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index b2371b80b620080ffe66b6f3da416ba22de809d7..1ae9ad60924f90c313b6c5ca47417529bb72e744 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include <present.h>
@@ -143,8 +143,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index fa656b849142f73a2430c0cafde99157370bb052..e154020e948117cdf42b26b94c19fbc91897bae6 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "rc5.h"
@@ -121,8 +121,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index aa1d897a50dc75a214a8bdf6a69abd7ce7cf35d6..57f249ada23912ed1cb0bf5d2a02575902c93957 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "rc6.h"
@@ -128,8 +128,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 768e8d9523c5ec89c31105668492888add4ab774..cd2a5e859acb72a5c9b3da261d04a498cfbcf8d0 100644 (file)
@@ -28,7 +28,7 @@
  */
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "seed.h"
@@ -179,8 +179,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index b7fc4e52b772eb0c498a36d564291cdcaaee1509..142e993fa0c6ee4d8c133f259c57ab78139e1113 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "serpent.h"
@@ -133,8 +133,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 77104b945acb07a5a989418f74e048d0567ba429..311bb055b39f5c9a8f55d4c275ddd5c2fd19f23f 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "sha1.h"
@@ -159,8 +159,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;      
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;         
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&sha1_desc;       
        for(;;){
index 80c864e1d7266199a2362cb9fe5e943a735fa47c..61ee2313e6666d048c0c4564fbca0e3eb56340c2 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "sha256.h"
@@ -87,8 +87,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&sha256_desc;
        for(;;){
index 93a1900917c6bc61809f1bcca1929393d28d128d..b08d800e6c2f74dc4606bfc39023affea60d4266 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "shabal.h"
@@ -218,8 +218,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&shabal256_desc;
        for(;;){
index c577b6b95d13f903014b95ea96d7147726a06848..5a6c5fa273c1aa7d524f955b897e4b50722c6927 100644 (file)
@@ -27,7 +27,7 @@
  */
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "shabea.h"
@@ -182,8 +182,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index a4ff3c62d684287e0747ddcc4b5d78668d9488b4..96aad56a267f2876e35d821434e8e5ec9ffc798a 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "shacal1_enc.h"
@@ -99,8 +99,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 4e880638a6a9f7017dd9d5682507fe716e132849..6a8a4eadd29011e35bd6a0a43966f9b60353b8fa 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "shacal2_enc.h"
@@ -99,8 +99,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 0a44e34e7ff4f9c8efc6f92a40bde6e04f72f225..b1e846406021ca2161dd9e1293533cb576e24787 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "skein.h"
@@ -243,8 +243,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&skein256_256_desc;
        for(;;){
index fd686b6c74ff59bb15d610ba479697e1fa97e5e8..2e311792554dc5a8f68bf05555c9068036350775 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "skipjack.h"
@@ -153,8 +153,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index a0107d5d3fa22beb6ad560cb33a1398104306bb4..dd025d03ec0c0c8fba174389fcc38aae36f16579 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "des.h"
@@ -113,8 +113,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 7d05eb8decb211640a9edb14af0de7c33f5fe43c..f0af2b526d1239d1da4f348df749ed78543fe984 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "threefish.h"
@@ -433,8 +433,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 6924c4ff2fd05b3ba11f01e992847ef0fd2a5e57..cbc3c7cd96ebcf68770e790be59c12e6810fca41 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 #include "cli.h"
 
@@ -115,8 +115,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 505bbaf6569c0d93c21877d8bca156fed105ef45..0f6fc492772b8b7f840413ba0c4674d2f33a7092 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "twister-small.h"
@@ -141,8 +141,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&twister256_desc;
        for(;;){
index 140362d5e584a042f3b313e5179c7df9c96dc897..b9ae8103364fc0445a8793e1b787296a2595123b 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "ubi.h"
@@ -196,8 +196,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index f450a9f1dc57ad0ed5dfe55e738fe41686f42df7..bc13d95dcf1cf15942760dd3d905a90941145b3f 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
 #include "debug.h"
 
 #include "xtea.h"
@@ -103,8 +103,8 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
 int main (void){
        DEBUG_INIT();
        
-       cli_rx = uart_getc;
-       cli_tx = uart_putc;             
+       cli_rx = (cli_rx_fpt)uart0_getc;
+       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
                cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
                cli_putstr(algo_name);
index 3f05a552a1f078cdbdd9cb49af1a3ce31af1421b..6d55c57f539866533bf4139fa474cc7d7ea054fe 100644 (file)
@@ -29,7 +29,6 @@
 #include <string.h>
 #include "nessie_bc_test.h"
 #include "nessie_common.h"
-#include "uart.h"
 
 nessie_bc_ctx_t nessie_bc_ctx;
 
index d95c911a20739e4ab34f1428c7eeb0e7b77b76a5..80093a038d2629ec78940b1de28cc7ebb1fb98ee 100644 (file)
@@ -32,7 +32,6 @@
 #include "nessie_mac_test.h"
 #include "nessie_common.h"
 #include "dbz_strings.h"
-#include "uart.h"
 
 nessie_mac_ctx_t nessie_mac_ctx;
 
index cc4ac1ff5b8ee320929c2d289e947deeb0018439..751669b6a4ac5451865b495e969c03f94171de4a 100644 (file)
@@ -29,7 +29,6 @@
 #include <string.h>
 #include "nessie_stream_test.h"
 #include "nessie_common.h"
-#include "uart.h"
 
 nessie_stream_ctx_t nessie_stream_ctx;
 
index e371a5fc1c7951c0988a1bb5b211e5b48ae983d5..ad745fc4c96a0b6480bb25fb563500f911040689 100644 (file)
@@ -31,7 +31,7 @@
 #include <avr/io.h>
 #include <avr/interrupt.h>
 #include <avr/pgmspace.h>
-#include "uart.h"
+#include "cli.h"
 #include "performance_test.h"
 
 
@@ -89,24 +89,24 @@ void getOverhead(uint16_t* constoh, uint16_t* intoh){
 void print_time_P(PGM_P s, uint64_t t){
        char sv[16];
        uint8_t c;
-       uart_putstr_P(PSTR("\r\n"));
-       uart_putstr_P(s);
+       cli_putstr_P(PSTR("\r\n"));
+       cli_putstr_P(s);
        ultoa((unsigned long)t, sv, 10);
        for(c=strlen(sv); c<11; ++c){
-               uart_putc(' ');
+               cli_putc(' ');
        }
-       uart_putstr(sv);
+       cli_putstr(sv);
 }
 
 void print_overhead(void){
        char str[16];
-       uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
+       cli_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
        utoa(const_overhead, str, 10);
-       uart_putstr_P(PSTR("\r\n\tconst overhead:     "));
-       uart_putstr(str);
+       cli_putstr_P(PSTR("\r\n\tconst overhead:     "));
+       cli_putstr(str);
        utoa(int_overhead, str, 10);
-       uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
-       uart_putstr(str);
+       cli_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
+       cli_putstr(str);
 }
 
 
index 7bfd25d747e4cea3c121368a7e9ece1db9bb0bdd..6fb36bce8c43adb7dfff030e582f20ddeec3c0d2 100644 (file)
  */
 
 #include "config.h"
-#include "uart.h"
+#include "uart_i.h"
 #include <string.h>
 #include <stdint.h>
 
 int getnextwordn(char *s, int n){ /* words are seperated by spaces, lf or cr */
        char c = ' ';
        do{
-               c=uart_getc(); 
+               c=uart0_getc(); 
        }while(c==' ' || c=='\r' || c=='\n');
        *s++ = c;
        do{ 
-         *s++ = c = uart_getc();
+         *s++ = c = uart0_getc();
        }while(c!=' ' && c!='\r' && c!='\n' && --n);
        *(s-1) = '\0';
        return n;
@@ -50,7 +50,7 @@ void readhex2buffer(void* buffer, int n){
        
 //     DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
        for(i=0; i<n; ++i){
-               c = uart_getc();
+               c = uart0_getc();
                if ('0'<= c && '9'>=c){
                        ((uint8_t*)buffer)[i] = c - '0';
                } else {
@@ -64,7 +64,7 @@ void readhex2buffer(void* buffer, int n){
                
                ((uint8_t*)buffer)[i] <<= 4;
                
-               c = uart_getc();
+               c = uart0_getc();
                if ('0'<= c && '9'>=c){
                        ((uint8_t*)buffer)[i] |= c - '0';
                } else {
@@ -78,7 +78,7 @@ void readhex2buffer(void* buffer, int n){
        } /* for i=0 .. n */
 }
 
-void uart_putptr(void* p){
-       uart_hexdump((void*) &p,2);
+void uart0_putptr(void* p){
+       uart0_hexdump((void*) &p,2);
 }
 
diff --git a/test_src/string-extras-asm.S b/test_src/string-extras-asm.S
new file mode 100644 (file)
index 0000000..c40e442
--- /dev/null
@@ -0,0 +1,138 @@
+/* string-extras-asm.S */
+/*
+    This file is part of the AVR-Huffman.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "avr-asm-macros.S"
+
+/******************************************************************************/
+/*
+       uint16_t stridentcnt_P(char* a, PGM_P b){
+               uint16_t i=0;
+               char c;
+               for(;;){
+                       c = pgm_read_byte(b++);
+                       if(*a != c || c=='\0')
+                               return i;
+                       i++;
+                       a++;
+               }
+       }
+       
+       param a: r24:r25
+       param b: r22:r23
+*/     
+.global stridentcnt_P
+stridentcnt_P:
+       movw r30, r22
+       movw r26, r24
+       clr r24
+       clr r25
+1:
+       ld r22, X+
+       lpm r23, Z+
+       cpse r22, r23
+       ret
+       cpse r22, r1
+       ret
+       adiw r24, 1
+       rjmp 1b
+               
+
+/******************************************************************************/
+/*
+       uint16_t firstword_length(char* s){
+               uint16_t ret=0;
+               while(isgraph(*s++))
+                       ret++;
+               return ret; 
+       }
+       
+       param s: r24:r25
+*/
+.global firstword_length
+firstword_length:
+       push r28
+       push r29
+       push r2
+       push r3
+       movw r2, r24
+       movw r28, r24
+1:
+       clr r25
+       ld r24, Y+
+       call isgraph
+       adiw r24, 0
+       brne 1b
+       movw r24, r28
+       sbiw r24, 1
+       sub r24, r2
+       sbc r25, r3     
+       pop r3
+       pop r2
+       pop r29
+       pop r28
+       ret
+
+
+/******************************************************************************/
+/*
+       char* strstrip(char* str){
+               if(!str)
+                       return str;
+               char* endptr;
+               while(*str && (*str==' ' || *str=='\t'))
+                       ++str;
+               endptr=str;
+               while(*endptr)
+                       ++endptr;
+               do{
+                       --endptr;
+               }while(*endptr==' ' || *endptr=='\t');
+               endptr[1]='\0';
+               return str;
+       }
+  
+  param str: r24:r25
+*/
+.global strstrip
+strstrip:
+       movw r26, r24
+       adiw r26, 0
+       breq 9f
+1:
+       ld r22, X+
+       cpi r22, ' '
+       breq 1b
+       cpi r22, '\t'
+       breq 1b
+       sbiw r26, 1
+       movw r30, r26
+2:
+       ld r22, Z+
+       tst r22
+       brne 2b
+3:     
+       ld r22, -Z
+       cpi r22, ' '
+       breq 3b
+       cpi r22, '\t'
+       breq 3b
+       st Z, r1
+       movw r24, r26
+9:
+       ret
diff --git a/test_src/string-extras.h b/test_src/string-extras.h
new file mode 100644 (file)
index 0000000..bf2cbf7
--- /dev/null
@@ -0,0 +1,55 @@
+/* string-extras.h */
+/*
+    This file is part of the AVR-Crypto-Lib.
+    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file       string-extras.h
+ * \author  Daniel Otte 
+ * \date    2006-05-16
+ * \license    GPLv3 or later
+ * 
+ */
+
+/** \fn stridentcnt_P(char* a, PGM_P b)
+ * \brief counts the number of identic chars
+ * 
+ * This function compares the supplyed strings and returns the index of the 
+ * first char where the strings differ.
+ * \param a pointer to string in RAM
+ * \param b pointer to string in Flash
+ * \return index of the first char where \c a and \c b differ
+ */
+uint16_t stridentcnt_P(char* a, PGM_P b);
+
+/** \fn firstword_length(char* s)
+ * \brief compute the length of the first word in supllyed string
+ * 
+ * This function searches for the first whitespace in the string and returns the
+ * number of chars before the first whitespace.
+ * \param s string
+ * \return number of chars in first word
+ */
+uint16_t firstword_length(char* s);
+
+/** \fn strstrip(char* str)
+ * \brief removes whitespace at the beginning and the end of a string
+ * 
+ * This function removes whitespaces at the end of a string.
+ * \param str sting
+ * \return pointer to the first non-whitespace char in string
+ */
+char* strstrip(char* str);
diff --git a/test_src/uart.c b/test_src/uart.c
deleted file mode 100644 (file)
index 56b22dd..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/* uart.c */
-/*
-    This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-/* USART-Init beim ATmegaXX */
-
-#include "config.h"
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <stdlib.h>
-#include "hexdigit_tab.h"
-#include "uart.h"
-
-#ifdef ATMEGA128
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL
-#define USART_UDRE_vect USART0_UDRE_vect
-#define USART_RXC_vect USART0_RX_vect
-#define UCSRA UCSR0A
-#endif
-
-#ifdef ATMEGA644
-#define UCSRB UCSR0B
-#define UCSRC UCSR0C
-#define UDR UDR0
-#define UBRRH UBRR0H
-#define UBRRL UBRR0L
-#define URSEL UMSEL00
-#define USART_UDRE_vect USART0_UDRE_vect
-#define USART_RXC_vect USART0_RX_vect
-#define UDRIE UDRIE0
-#define TXEN TXEN0
-#define UMSEL UMSEL0
-#define RXEN RXEN0
-#define RXCIE RXCIE0
-#define UCSZ0 UCSZ00
-#define UCSRA UCSR0A
-#define UDRE UDRE0
-#define RXC RXC0
-#endif
-
-#ifdef AT90USB162
-#define UCSRB UCSR1B
-#define UCSRC UCSR1C
-#define UDR UDR1
-#define UBRRH UBRR1H
-#define UBRRL UBRR1L
-#define URSEL UMSEL10
-#define USART_UDRE_vect USART1_UDRE_vect
-#define USART_RXC_vect USART1_RX_vect
-#define UDRIE UDRIE1
-#define TXEN TXEN1
-#define UMSEL UMSEL1
-#define RXEN RXEN1
-#define RXCIE RXCIE1
-#define UCSZ0 UCSZ10
-#define UCSRA UCSR1A
-#define UDRE UDRE1
-#define RXC RXC1
-#endif
-
-
-
-#ifdef UART_XON_XOFF
-#define XON  0x11
-#define XOFF 0x13
-
- #ifdef UART_INTERRUPT
-  void uart_insertc(char c);
- #else
-  #define uart_insertc uart_putc
- #endif /* UART_INTERRUPT */
-#endif
-
-#define UART_BAUD_CALC(UART_BAUD_RATE,F_OSC) ((F_OSC)/((UART_BAUD_RATE)*16L)-1)
-
-#ifdef UART_XON_XOFF
-       typedef enum{go=1,nogo=0} gonogo;
-       static gonogo txon=go;
-       static gonogo rxon=go;
-#endif
-
-#ifdef UART_INTERRUPT
-volatile static char rxbuf[UART_RXBUFSIZE];
-volatile static char txbuf[UART_TXBUFSIZE];
-volatile static char *volatile rxhead, *volatile rxtail;
-volatile static char *volatile txhead, *volatile txtail;
-
-#ifdef UART_HOOK       
-        void (*uart_hook) (uint8_t) = (void*)0;        /* this is a pointer to a function ;-) */
-#endif
-
-ISR(USART_UDRE_vect) {
-#ifdef UART_LEDS       
-       PORTC ^= 0x01;
-#endif
-       
-       if ( txhead == txtail ) {
-               UCSRB &= ~(1 << UDRIE);         /* disable data register empty IRQ */
-       } else {
-               #ifdef UART_XON_XOFF
-                       while(txon==nogo)
-                               ;
-               #endif
-               UDR = *txtail;                  /* schreibt das Zeichen x auf die Schnittstelle */
-               if (++txtail == (txbuf + UART_TXBUFSIZE)) txtail = txbuf;
-       }
-}
-
-ISR(USART_RXC_vect) {
-       int diff; 
-       char c;
-#ifdef UART_HOOK       
-       static volatile uint8_t hook_running=0;
-#endif
-#ifdef UART_LEDS
-       PORTC ^= 0x02;
-#endif
-       c=UDR;
-       #ifdef UART_XON_XOFF
-        if (c==XON){
-                 txon=go;
-                 return;
-        }
-        if (c==XOFF){
-                txon=nogo;
-                return;
-        }
-       #endif
-       /* buffer full? */
-       diff = rxhead - rxtail;
-       if (diff < 0) diff += UART_RXBUFSIZE; /* diff is the amount of bytes in buffer */
-       if (diff < UART_RXBUFSIZE -1) {
-               // buffer NOT full
-#ifdef UART_HOOK
-               if(!hook_running && uart_hook){
-                       uint8_t t=c;    
-                       hook_running = 1;
-                       sei(); /* reenable interrupts, avoid recursion!!! */
-                       do {
-                               uart_hook(t);
-                       } while(uart_getc_nb((char*)&t));
-                       hook_running = 0;
-               } else {
-                       *rxhead = c;
-                       ++rxhead;
-                       if (rxhead == (rxbuf + UART_RXBUFSIZE)) rxhead = rxbuf;
-               }
-#else  
-               *rxhead = c;
-               ++rxhead;
-               if (rxhead == (rxbuf + UART_RXBUFSIZE))
-                       rxhead = rxbuf;
-#endif
-       } else {
-                                               //reads the buffer to clear the interrupt condition
-       }
-#ifdef UART_XON_XOFF   
-       if((diff > UART_XON_XOFF_THRESHOLD_1) && (rxon==go)){
-               rxon=nogo;
-               uart_insertc(XOFF);
-       }
-       if((diff < UART_XON_XOFF_THRESHOLD_2) && (rxon==nogo)){
-               rxon=go;
-               uart_insertc(XON);
-       }
-#endif
-}
-
-#endif // UART_INTERRUPT
-
-
-void uart_init() {
-       PORTD |= 0x01;                          //Pullup an RXD an
-       
-       UCSRB |= (1<<TXEN);                     //UART TX einschalten
-#ifdef ATMEGA644
-       UCSRA = 0;
-       UCSRC = (3<<UCSZ0);                 //Asynchron 8N1
-#else  
-    UCSRA = 0;
-       UCSRC |= (1<<URSEL)|(3<<UCSZ0);         //Asynchron 8N1
-#endif
-       UCSRB |= ( 1 << RXEN );                 //Uart RX einschalten
-
-       UBRRH=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU)>>8);
-       UBRRL=(uint8_t)(UART_BAUD_CALC(UART_BAUD_RATE,F_CPU));
-
-#ifdef UART_INTERRUPT
-       // init buffers
-       rxhead = rxtail = rxbuf;
-       txhead = txtail = txbuf;
-
-       // activate rx IRQ
-       UCSRB |= _BV(RXCIE) | _BV(UDRIE);
-       sei();
-//     #ifdef ATMEGA644
-//     UCSRB |= _BV(UDRIE);
-//     #endif
-#endif // UART_INTERRUPT
-}
-
-#ifdef UART_INTERRUPT
-#ifdef UART_XON_XOFF
-
-void uart_insertc(char c){
-       volatile int diff;
-       do {
-               diff = txhead - txtail;
-               if ( diff < 0 ) diff += UART_TXBUFSIZE;
-       } while ( diff >= UART_TXBUFSIZE -1 );
-
-       cli();
-       if (--txtail == (txbuf-1)) txtail += UART_TXBUFSIZE;
-       *txtail = c;
-       
-       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
-       sei();
-}
-#endif /* UART_XON_XOFF */
-void uart_putc(char c) {
-       volatile int diff;
-
-       /* buffer full? */
-       do {
-               diff = txhead - txtail;
-               if ( diff < 0 ) diff += UART_TXBUFSIZE;
-       } while ( diff >= UART_TXBUFSIZE -1 );
-
-       cli();
-       *txhead = c;
-       if (++txhead == (txbuf + UART_TXBUFSIZE)) txhead = txbuf;
-
-       UCSRB |= (1 << UDRIE);          /* enable data register empty IRQ */
-       sei();
-}
-#else  // WITHOUT INTERRUPT
-void uart_putc(char c) {
-       while (!(UCSRA & (1<<UDRE))) /* warten bis Senden moeglich */
-               ; 
-       #ifdef UART_XON_XOFF
-       while (txon==nogo)                       /* warte bis XON empfangen */
-               ;
-       #endif
-       UDR = c;                  /* schreibt das Zeichen x auf die Schnittstelle */
-}
-#endif // UART_INTERRUPT
-
-
-void uart_putstr(char *str) {
-       while(*str) {
-               uart_putc(*str++);
-       }
-}
-
-void uart_putstr_P(PGM_P str) {
-       char tmp;
-       while((tmp = pgm_read_byte(str))) {
-               uart_putc(tmp);
-               str++;
-       }
-}
-
-void uart_hexdump(const void* buf, int len)
-{
-       while(len--){
-               uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))>>4)));
-               uart_putc(pgm_read_byte(hexdigit_tab_P + ((*((uint8_t*)buf))&0xf)));
-               uart_putc(' ');
-               buf=(uint8_t*)buf+1;
-       }
-}
-
-
-#ifdef UART_INTERRUPT
-char uart_getc(void)
-{
-       char val;
-
-       while(rxhead==rxtail)
-               ;
-
-       val = *rxtail;
-       ++rxtail;
-       if (rxtail == (rxbuf + UART_RXBUFSIZE))
-               rxtail = rxbuf;
-
-       return val;
-}
-#else  // WITHOUT INTERRUPT
-char uart_getc(void)
-{
-       char t;
-       while (!(UCSRA & (1<<RXC)))
-               ;       // warten bis Zeichen verfuegbar
-       t=UDR;
-       #ifdef UART_XON_XOFF
-       if (t==XON)  txon=go;
-       if (t==XOFF) txon=nogo;
-       #endif
-       return t;                       // Zeichen aus UDR zurueckgeben
-}
-#endif // UART_INTERRUPT
-
-// returns 1 on success
-#ifdef UART_INTERRUPT
-char uart_getc_nb(char *c)
-{
-       if (rxhead==rxtail) return 0;
-
-       *c = *rxtail;
-       if (++rxtail == (rxbuf + UART_RXBUFSIZE)) rxtail = rxbuf;
-
-       return 1;
-}
-#else  // WITHOUT INTERRUPT
-char uart_getc_nb(char *c)
-{
-       if (UCSRA & (1<<RXC)) {         // Zeichen verfuegbar
-               *c = UDR;
-               #ifdef UART_XON_XOFF
-                       if (*c==XON)  txon=go;
-                       if (*c==XOFF) txon=nogo;
-               #endif
-               return 1;
-       }
-
-       return 0;
-}
-#endif // UART_INTERRUPT
diff --git a/test_src/uart_defs.h b/test_src/uart_defs.h
new file mode 100644 (file)
index 0000000..dac0a48
--- /dev/null
@@ -0,0 +1,34 @@
+/* uart_defs.h */
+/*
+    This file is part of the AVR-uart_ni.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef UART_DEFS_H_
+#define UART_DEFS_H_
+
+#define UART_PARATY_NONE 0 /** \def UART_PARATY_NONE define no paraty */
+#define UART_PARATY_EVEN 2 /** \def UART_PARATY_EVEN define even paraty */
+#define UART_PARATY_ODD  3 /** \def UART_PARATY_ODD define odd paraty */
+#define UART_STOPBITS_1 0  /** \def UART_STOPBITS_1 define 1 stop bit */
+#define UART_STOPBITS_2 1  /** \def UART_STOPBITS_2 define 2 stop bits */
+#define UART_DATABITS_5 0  /** \def UART_DATABITS_5 define 5 data bits */
+#define UART_DATABITS_6 1  /** \def UART_DATABITS_6 define 6 data bits */
+#define UART_DATABITS_7 2  /** \def UART_DATABITS_7 define 7 data bits */
+#define UART_DATABITS_8 3  /** \def UART_DATABITS_8 define 8 data bits */
+#define UART_DATABITS_9 7  /** \def UART_DATABITS_9 define 9 data bits */
+
+#endif /* UART_DEFS_H_ */
diff --git a/test_src/uart_i-asm.S b/test_src/uart_i-asm.S
new file mode 100644 (file)
index 0000000..8ce866b
--- /dev/null
@@ -0,0 +1,447 @@
+/* uart_i-asm.S */
+/*
+    This file is part of the AVR-uart_i.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file     uart_i-asm.S
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte 
+ * \date     2009-07-24
+ * \license  GPLv3 or later
+ * \ingroup  uart_i
+ * \brief    implementation of interrupt based uart
+ */
+
+#include <avr/io.h>
+#include "config.h"
+#include "avr-asm-macros.S"
+
+#define XON_VALUE  0x11
+#define XOFF_VALUE 0x13
+
+#ifdef UDR
+# define OLD_UART
+# ifdef UDR0
+#  error "can not decide which registernames to use, UDR and UDR0 are defined"
+# endif
+#endif
+
+#ifdef OLD_UART
+# define UCSR0A UCSRA
+# define UCSR0B UCSRB
+# define UCSR0C UCSRC
+# define UBRR0H UBRRH
+# define UBRR0L UBRRL
+# define UDR0   UDR
+# define TXEN0  TXEN
+# define RXEN0  RXEN
+# define UDRE0  UDRE
+# define RXC0   RXC
+# define TXB80  TXB8
+# define RXB80  RXB8
+#endif
+
+#define CBB_SIZE 10
+
+#define UART0_CBB_RX_OFFSET  0
+#define UART0_CBB_TX_OFFSET 10
+
+#define CTX_BASE_SIZE (2*(CBB_SIZE))
+
+#if UART0_HOOK
+#  if UART0_SWFLOWCTRL
+#    define UART0_CTX_SIZE (3+2+CTX_BASE_SIZE)
+#    define UART0_HOOK_OFFSET  20
+#    define UART0_HOOKR_OFFSET 22
+#    define UART0_TXON_OFFSET  23
+#    define UART0_RXON_OFFSET  24
+#  else
+#    define UART0_CTX_SIZE (3+0+CTX_BASE_SIZE)
+#    define UART0_HOOK_OFFSET  20
+#    define UART0_HOOKR_OFFSET 22
+#  endif
+#else
+#  if UART0_SWFLOWCTRL
+#    define UART0_CTX_SIZE (0+2+CTX_BASE_SIZE)
+#    define UART0_TXON_OFFSET  20
+#    define UART0_RXON_OFFSET  21
+#  else
+#    define UART0_CTX_SIZE (0+0+CTX_BASE_SIZE)
+#  endif
+#endif
+
+       .section .bss
+.global uart0_rxbuffer
+uart0_rxbuffer:
+       .fill UART0_RXBUFFER_SIZE, 1, 0
+.global uart0_txbuffer
+uart0_txbuffer:
+       .fill UART0_TXBUFFER_SIZE, 1, 0
+.global uart0_ctx
+uart0_ctx:
+       .fill UART0_CTX_SIZE, 1, 0      
+/******************************************************************************/       
+/* Baudrate calculation */
+#ifdef BAUD
+#undef BAUD
+#endif
+
+#define BAUD UART0_BAUD_RATE
+#include "setbaud_asm.inc"
+
+       .section .text
+/******************************************************************************/       
+/*
+ *     void uart0_init(void){
+ *             circularbytebuffer_init2(UART0_RXBUFFER_SIZE, &(uart0_ctx.rxb), uart0_rxbuffer);
+ *             circularbytebuffer_init2(UART0_TXBUFFER_SIZE, &(uart0_ctx.txb), uart0_txbuffer);
+ *     #if UART0_HOOK
+ *             uart0_ctx.hook = NULL;
+ *             uart0_ctx.hook_running = 0;
+ *     #endif
+ *     #if UART0_SWFLOWCTRL
+ *             uart0_ctx.txon = 1;
+ *             uart0_ctx.rxon = 1;
+ *     #endif
+ *             #define BAUD UART0_BAUD_RATE
+ *             #include <util/setbaud.h>       
+ *             UBRR0H = UBRRH_VALUE;
+ *             UBRR0L = UBRRL_VALUE;
+ *             #if USE_2X
+ *             UCSR0A |= _BV(U2X0);
+ *             #else
+ *             UCSR0A &= ~_BV(U2X0);
+ *             #endif
+ *             UCSR0C = (UART0_PARATY<<4)|(UART0_STOPBITS<<3)|((UART0_DATABITS&3)<<1);
+ *             UCSR0B = _BV(RXCIE0) | _BV(UDRIE0) | _BV(RXEN0) | _BV(TXEN0) ; / * enable TX and RX and interrupts * /
+ *             sei();
+ *     }
+ *
+ */
+.global uart0_init
+uart0_init:
+       ldi r24, UART0_RXBUFFER_SIZE
+       clr r25
+       ldi r22, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r23, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r24, UART0_RXBUFFER_SIZE
+       ldi r20, lo8(uart0_rxbuffer)
+       ldi r21, hi8(uart0_rxbuffer)
+       rcall circularbytebuffer_init2
+       ldi r24, UART0_TXBUFFER_SIZE
+       clr r25
+       ldi r22, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r23, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r24, UART0_TXBUFFER_SIZE
+       ldi r20, lo8(uart0_txbuffer)
+       ldi r21, hi8(uart0_txbuffer)
+       rcall circularbytebuffer_init2
+#if UART0_SWFLOWCTRL
+       ldi r30, lo8(uart0_ctx)
+       ldi r31, hi8(uart0_ctx)
+       ldi r24, 1
+       std Z+UART0_TXON_OFFSET, r24
+       std Z+UART0_RXON_OFFSET, r24
+#endif 
+       ldi r24, UBRRH_VALUE
+       STORE_IO UBRR0H, r24
+       ldi r24, UBRRL_VALUE
+       STORE_IO UBRR0L, r24
+#if USE_2X
+       SET_BIT_IO UCSR0A, U2X0, r24
+#else
+       CLEAR_BIT_IO UCSR0A, U2X0, r24
+/*                  UCSR0A */
+#endif
+       ldi r24, (UART0_PARATY<<4)|(UART0_STOPBITS<<3)|((UART0_DATABITS&3)<<1)
+       STORE_IO UCSR0C, r24
+       ldi r24, _BV(RXCIE0) | _BV(UDRIE0) | _BV(RXEN0) | _BV(TXEN0)  
+       STORE_IO UCSR0B, r24
+       sei
+       ret
+       
+/******************************************************************************/       
+/*
+ *     ISR(USART0_UDRE_vect){
+ *             uint16_t x;
+ *             x = circularbytebuffer_get_fifo(&(uart0_ctx.txb));
+ *             if(x==0xffff){
+ *                     / * the transmit buffer is empty, disable interrupt * /
+ *                     UCSR0B &= (uint8_t)~_BV(UDRIE0);
+ *                     return;
+ *             }
+ *     #if UART0_SWFLOWCTRL
+ *             while(!uart0_ctx.txon)
+ *                     ;
+ *     #endif          
+ *             UDR0 = x;
+ *     }
+ */ 
+.global USART0_UDRE_vect
+USART0_UDRE_vect:
+       push_range 21, 26
+       push_range 30, 31
+       in r21, _SFR_IO_ADDR(SREG)
+       ldi r24, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r25, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       rcall circularbytebuffer_get_fifo
+       cpi r25, 0xff
+       brne 20f
+       CLEAR_BIT_IO UCSR0B, UDRIE0, r24
+       rjmp 99f
+20:
+#if UART0_SWFLOWCTRL
+       ldi r30, lo8(uart0_ctx+UART0_TXON_OFFSET)
+       ldi r31, hi8(uart0_ctx+UART0_TXON_OFFSET)
+30:
+       ld r22, Z
+       tst r22
+       breq 30b
+#endif
+       STORE_IO UDR0, r24
+99:
+       out _SFR_IO_ADDR(SREG), r21
+       pop_range 30, 31
+       pop_range 21, 26
+       reti
+       
+/******************************************************************************/
+/*
+ *     void uart0_putc (uint16_t c){
+ *     #if UART0_SWFLOWCTRL
+ *             while(!uart0_ctx.txon)
+ *                     ;
+ *     #endif  
+ *             while(circularbytebuffer_cnt(&(uart0_ctx.txb))==UART0_TXBUFFER_SIZE)
+ *                     ;
+ *             cli();          
+ *             circularbytebuffer_append((uint8_t)c, &(uart0_ctx.txb));
+ *             sei();
+ *             UCSR0B |= (uint8_t)_BV(UDRIE0);
+ *     }
+ *
+ * param c:  r24:r25
+ */
+.global uart0_putc
+uart0_putc:
+       mov r18, r24
+#if UART0_SWFLOWCTRL
+       ldi r30, lo8(uart0_ctx+UART0_TXON_OFFSET)
+       ldi r31, hi8(uart0_ctx+UART0_TXON_OFFSET)
+10:
+       ld r22, Z
+       tst r22
+       breq 10b
+#endif
+       ldi r26, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r27, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+20:
+       movw r24, r26
+       rcall circularbytebuffer_cnt
+       cpi r24, UART0_TXBUFFER_SIZE
+       breq 20b
+       movw r22, r26
+       mov r24, r18
+       clr r25
+       cli
+       rcall circularbytebuffer_append
+       sei
+       SET_BIT_IO UCSR0B, UDRIE0, r24
+       ret
+
+/******************************************************************************/
+/*
+ *     ISR(USART0_RX_vect){
+ *             uint16_t c;
+ *             c = UDR0;
+ *     #if UART0_SWFLOWCTRL
+ *             if(c==XON_VALUE){
+ *                     uart0_ctx.txon = 1;
+ *                     return;
+ *             }
+ *             if(c==XOFF_VALUE){
+ *                     uart0_ctx.txon = 0;
+ *                     return;
+ *             }
+ *     #endif          
+ *     #if     UART0_HOOK
+ *             if((!uart0_ctx.hook_running) && uart0_ctx.hook){
+ *                     uart0_ctx.hook_running=1;
+ *                     sei();
+ *                     do{
+ *                             uart0_ctx.hook(c);
+ *                     }while((c=circularbytebuffer_get_fifo(&(uart0_ctx.rxb)))!=0xffff);
+ *                     uart0_ctx.hook_running=0;
+ *                     return;
+ *             }
+ *     #endif
+ *             if(circularbytebuffer_cnt(&(uart0_ctx.rxb))==UART0_RXBUFFER_SIZE)
+ *                     return;
+ *             circularbytebuffer_append(c, &(uart0_ctx.rxb));
+ *     #if UART0_SWFLOWCTRL
+ *             if(circularbytebuffer_cnt(&(uart0_ctx.rxb))>UART0_THRESH_HIGH && uart0_ctx.rxon){
+ *                     uart0_ctx.rxon = 0;
+ *                     circularbytebuffer_push(XOFF_VALUE, &(uart0_ctx.txb));
+ *                     UCSR0B |= (uint8_t)_BV(UDRIE0);
+ *             }
+ *             if(circularbytebuffer_cnt(&(uart0_ctx.rxb))<UART0_THRESH_LOW && !uart0_ctx.rxon){
+ *                     uart0_ctx.rxon = 1;
+ *                     circularbytebuffer_push(XON_VALUE, &(uart0_ctx.txb));
+ *                     UCSR0B |= (uint8_t)_BV(UDRIE0);
+ *             }
+ *     #endif          
+ *     }
+ *
+ */
+ .global USART0_RX_vect
+ USART0_RX_vect:
+       push_range 16, 31
+       in r21, _SFR_IO_ADDR(SREG)
+       LOAD_IO r24, UDR0
+#if UART0_SWFLOWCTRL
+       ldi r26, lo8(uart0_ctx+UART0_TXON_OFFSET)
+       ldi r27, hi8(uart0_ctx+UART0_TXON_OFFSET)
+       cpi r24, XON_VALUE
+       brne 10f
+       ldi r24, 1
+       st X, r24
+       rjmp 99f
+10:    
+       cpi r24, XOFF_VALUE
+       brne 20f
+       clr r24
+       st X, r24
+       rjmp 99f
+#endif /* UART0_SWFLOWCTRL */  
+20:    
+#if UART0_HOOK
+       ldi r30, lo8(uart0_ctx)
+       ldi r31, hi8(uart0_ctx)
+       ldd r22, Z+UART0_HOOKR_OFFSET
+       tst r22
+       brne 50f
+       ldd r26, Z+UART0_HOOK_OFFSET
+       ldd r27, Z+UART0_HOOK_OFFSET+1
+       adiw r26, 0
+       breq 50f
+       movw r28, r26
+       movw r16, r30
+       sei
+30:
+       /* now we can run the hook */
+       movw r30, r28
+       clr r25
+       icall
+       movw r24, r16
+       rcall circularbytebuffer_get_fifo 
+       cpi r25, 0xff
+       brne 30b
+       clr r24
+       st -Y, r24 /* write 0 to uart0_hook_running */
+       rjmp 99f
+#endif /* UART0_HOOK */
+50:
+       ldi r22, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r23, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       clr r25
+       rcall circularbytebuffer_append
+#if UART0_SWFLOWCTRL
+       ldi r24, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r25, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       rcall circularbytebuffer_cnt
+       ldi r22, lo8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r23, hi8(uart0_ctx+UART0_CBB_TX_OFFSET)
+       ldi r30, lo8(uart0_ctx+UART0_RXON_OFFSET)
+       ldi r31, hi8(uart0_ctx+UART0_RXON_OFFSET)
+       ld r21, Z
+       tst r21
+       breq 60f
+       cpi r24, UART0_THRESH_HIGH+1
+       brlo 99f
+       clr r25
+       ldi r24, XOFF_VALUE
+       rcall circularbytebuffer_push
+       SET_BIT_IO UCSR0B, UDRIE0, r24
+       rjmp 99f
+60:
+       cpi r24, UART0_THRESH_LOW
+       brge 99f
+       clr r25
+       ldi r24, XON_VALUE
+       rcall circularbytebuffer_push
+       SET_BIT_IO UCSR0B, UDRIE0, r24
+#endif /* UART0_SWFLOWCTRL */
+99:    
+       out _SFR_IO_ADDR(SREG), r21
+       pop_range 16, 31
+       reti
+
+/******************************************************************************/
+/*
+ *     uint16_t uart0_getc(void){
+ *             uint8_t ret;
+ *             while(circularbytebuffer_cnt(&(uart0_ctx.rxb))==0)
+ *                     ;
+ *             cli();  
+ *             ret = circularbytebuffer_get_fifo(&(uart0_ctx.rxb));
+ *             sei();
+ *             return  ret;
+ *     }
+ */
+ .global uart0_getc
+ uart0_getc:
+       ldi r22, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r23, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+ 10:
+       movw r24, r22
+       rcall circularbytebuffer_cnt
+       tst r24
+       breq 10b
+       movw r24, r22
+       cli
+       rcall circularbytebuffer_get_fifo
+       reti
+       
+/******************************************************************************/
+/*
+ *     uint8_t uart0_dataavail(void){
+ *             return circularbytebuffer_cnt(&(uart0_ctx.rxb));
+ *     }
+ */
+.global uart0_dataavail
+uart0_dataavail:
+       ldi r24, lo8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       ldi r25, hi8(uart0_ctx+UART0_CBB_RX_OFFSET)
+       rjmp circularbytebuffer_cnt
+       
+/******************************************************************************/
+#if    UART0_HOOK
+/*
+ *     void uart0_sethook(void(*fpt)(uint8_t)){
+ *             uart0_ctx.hook = fpt;
+ *     }
+ */
+.global uart0_sethook
+uart0_sethook:
+       ldi r26, lo8(uart0_ctx+UART0_HOOK_OFFSET)
+       ldi r27, hi8(uart0_ctx+UART0_HOOK_OFFSET)
+       st X+, r24
+       st X+, r25
+       ret
+#endif
+       
diff --git a/test_src/uart_i.h b/test_src/uart_i.h
new file mode 100644 (file)
index 0000000..aff5f85
--- /dev/null
@@ -0,0 +1,139 @@
+/* uart_i.h */
+/*
+    This file is part of the AVR-uart_ni.
+    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * \file     uart_i.h
+ * \email    daniel.otte@rub.de
+ * \author   Daniel Otte 
+ * \date     2009-07-24
+ * \license  GPLv3 or later
+ * \ingroup  uart_i
+ * \brief    declaration for non-interrupt uart
+ */
+
+#ifndef UART_I_H_
+#define UART_I_H_
+
+#include "config.h"
+#include "circularbytebuffer.h"
+#include <stdint.h>
+
+typedef struct{
+       circularbytebuffer_t rxb;
+       circularbytebuffer_t txb;       
+#if UART0_HOOK
+       void(*hook)(uint8_t);
+       volatile uint8_t hook_running;
+#endif
+#if UART0_SWFLOWCTRL
+       volatile uint8_t txon;
+       volatile uint8_t rxon;
+#endif
+} uart0_ctx_t;
+
+
+typedef struct{
+       circularbytebuffer_t rxb;
+       circularbytebuffer_t txb;       
+#if UART1_HOOK
+       void(*hook)(uint8_t);
+       volatile uint8_t hook_running;
+#endif
+#if UART1_SWFLOWCTRL
+       volatile uint8_t txon;
+       volatile uint8_t rxon;
+#endif
+} uart1_ctx_t;
+
+#if UART0_I
+
+/** \fn uart0_init(void)
+ * \brief initialize uart0.
+ * This function initializes the first uart according to the parameter specifyed
+ * in config.h .
+ */
+void uart0_init(void);
+
+/** \fn uart0_putc(uint16_t)
+ * \brief send data through uart0.
+ * This function sends data through the first uart 
+ * (the data size is debfined in config.h).
+ * \param c data to send
+ */
+void uart0_putc(uint16_t c);
+
+/** \fn uart0_getc(void)
+ * \brief read data from uart0.
+ * This function reads data from the first uart 
+ * (the data size is debfined in config.h).
+ * \return data recived by uart0
+ */
+uint16_t uart0_getc(void);
+
+/** \fn uart0_dataavail(void)
+ * \brief checks if data is available.
+ * 
+ * This function checks the state of the input buffer of uart0 and
+ * returns if data is available or not.
+ * \return zero if no data is available else a value different from zero is returned
+ */
+uint8_t uart0_dataavail(void);
+
+#if    UART0_HOOK
+void uart0_sethook(void(*fpt)(uint8_t));
+#endif
+
+
+#endif /* UART0_I */
+
+#if UART1_I
+/** \fn uart1_init(void)
+ * \brief initialize uart1.
+ * This function initializes the second uart according to the parameter specifyed
+ * in config.h .
+ */
+void uart1_init(void);
+
+/** \fn uart1_putc(uint16_t)
+ * \brief send data through uart1.
+ * This function sends data through the second uart 
+ * (the data size is debfined in config.h).
+ * \param c data to send
+ */
+void uart1_putc(uint16_t c);
+
+/** \fn uart1_getc(void)
+ * \brief read data from uart1.
+ * This function reads data from the second uart 
+ * (the data size is debfined in config.h).
+ * \return data recived by uart1
+ */
+uint16_t uart1_getc(void);
+
+/** \fn uart1_dataavail(void)
+ * \brief checks if data is available.
+ * This function checks the state of the input buffer of uart1 and
+ * returns if data is available or not.
+ * \return zero if no data is available else a value different from zero is returned
+ */
+uint8_t uart1_dataavail(void);
+
+void uart0_sethook(void(*fpt)(uint8_t));
+#endif
+
+#endif /* UART_I_H_ */