--- /dev/null
+<?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>
--- /dev/null
+<?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>
#-------------------------------------------------------------------------------
+define SOURCEFILE_TEMPLATE
+$(BIN_DIR)$(1): $(2)/$(3).c
+ $(CC) $(CFLAGS) -c -o $@ $<
+endef
+#-------------------------------------------------------------------------------
$(BIN_DIR)%.o: %.c
@echo "[gcc]: $@"
@$(CC) $(CFLAGS) -c -o $@ $<
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
#include <avr/pgmspace.h>
#include "camellia.h"
#if 0
- #include "uart.h"
+ #include "cli.h"
#include "debug.h"
#include <util/delay.h>
#endif
/*****************************************************************************/
/*
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;
}
*/
#include <avr/pgmspace.h>
#include "camellia.h"
#if 0
- #include "uart.h"
+ #include "cli.h"
#include "debug.h"
#include <util/delay.h>
#endif
/*****************************************************************************/
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]);
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;
}
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];
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
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
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
/*****************************************************************************/
#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
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--------------------");
}
/*****************************************************************************/
#undef DEBUG
#ifdef DEBUG
- #include "uart.h"
+ #include "cli.h"
#endif
#include "cast5-sbox.h"
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);
}
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);
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
#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]] )
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;
/*
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;-----"));
}
}
*/
// #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
*/
#include "config.h"
#include "debug.h"
-#include "uart.h"
+#include "cli.h"
#include <stdint.h>
#include <string.h>
#include <util/delay.h>
#include "md5.h"
#include "md5_sbox.h"
- #include "uart.h"
+ #include "cli.h"
#include <stdint.h>
#include <string.h>
/* 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) ;
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];
-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
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"
$(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
$(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
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
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"
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"
$(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
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"
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"
$(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
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"
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"
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"
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"
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"
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"
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"
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"
$(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
$(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
$(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
$(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
$(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"
$(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
$(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
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"
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"
$(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"
$(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"
$(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"
$(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"
$(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"
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"
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"
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"
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"
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"
$(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"
$(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"
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"
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"
$(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
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"
$(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
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"
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"
#include <avr/pgmspace.h>
#endif
#include "noekeon.h"
-// #include "uart.h"
+// #include "cli.h"
#define ROUND_NR 16
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__
#include <avr/pgmspace.h>
#include <string.h>
#include "seed_sbox.h"
-#include "uart.h"
+#include "cli.h"
#include "debug.h"
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);
}
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);
}
DEBUG_B(dbgi);
DEBUG_C(':');
#ifdef DEBUG
- uart_hexdump(&(w[dbgi]) ,4);
+ cli_hexdump(&(w[dbgi]) ,4);
#endif
}
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
}
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
}
--- /dev/null
+/* 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
--- /dev/null
+/* 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_ */
--- /dev/null
+/* 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
--- /dev/null
+/* 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
+
+
+
+
--- /dev/null
+/* 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
+
+
--- /dev/null
+/* 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;
+ }
+ }
+}
+++ /dev/null
-/* 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;
- }
- }
-}
#include "config.h"
#if DEBUG == uart
- #include "uart.h"
+ #include "uart_i.h"
#else
#error "Your DEBUG methode is not suported!"
#endif
#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){
--- /dev/null
+/* 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
--- /dev/null
+/* 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);
+++ /dev/null
-/* 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"));
- }
-}
-
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include <A5_1.h>
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "aes.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include <arcfour.h>
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "noekeon.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "blake_small.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "bmw_small.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "camellia.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include <cast5.h>
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cast6.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "des.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "entropium.h"
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);
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 ("));
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "groestl_small.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "md5.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha1.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha256.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "md5.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "mugi.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include <noekeon.h>
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "noekeon.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include <present.h>
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "rc5.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "rc6.h"
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);
*/
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "seed.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "serpent.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha1.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "sha256.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shabal.h"
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(;;){
*/
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shabea.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shacal1_enc.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "shacal2_enc.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "skein.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "skipjack.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "des.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "threefish.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "cli.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "twister-small.h"
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(;;){
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "ubi.h"
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);
#include "config.h"
#include "serial-tools.h"
-#include "uart.h"
+#include "uart_i.h"
#include "debug.h"
#include "xtea.h"
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);
#include <string.h>
#include "nessie_bc_test.h"
#include "nessie_common.h"
-#include "uart.h"
nessie_bc_ctx_t nessie_bc_ctx;
#include "nessie_mac_test.h"
#include "nessie_common.h"
#include "dbz_strings.h"
-#include "uart.h"
nessie_mac_ctx_t nessie_mac_ctx;
#include <string.h>
#include "nessie_stream_test.h"
#include "nessie_common.h"
-#include "uart.h"
nessie_stream_ctx_t nessie_stream_ctx;
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
-#include "uart.h"
+#include "cli.h"
#include "performance_test.h"
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);
}
*/
#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;
// 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 {
((uint8_t*)buffer)[i] <<= 4;
- c = uart_getc();
+ c = uart0_getc();
if ('0'<= c && '9'>=c){
((uint8_t*)buffer)[i] |= c - '0';
} else {
} /* for i=0 .. n */
}
-void uart_putptr(void* p){
- uart_hexdump((void*) &p,2);
+void uart0_putptr(void* p){
+ uart0_hexdump((void*) &p,2);
}
--- /dev/null
+/* 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
--- /dev/null
+/* 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);
+++ /dev/null
-/* 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
--- /dev/null
+/* 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_ */
--- /dev/null
+/* 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
+
--- /dev/null
+/* 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_ */