summaryrefslogtreecommitdiff
path: root/common/ipmbox
diff options
context:
space:
mode:
authorIPMbox Team2012-02-03 14:32:28 +0100
committerNicolas Schodet2012-02-20 10:08:46 +0100
commit3ed571f9d933e5c5dadef650c07e20e8aad06213 (patch)
tree761bfe80d4660605e00f52afb8532d9a2ef847b6 /common/ipmbox
parent89328e8cc096f8c9f340a3eb8910d06748a3e572 (diff)
cesar, cleopatre, common: new ipmbox design, closes #848
Diffstat (limited to 'common/ipmbox')
-rw-r--r--common/ipmbox/Module1
-rw-r--r--common/ipmbox/doc/Makefile23
-rw-r--r--common/ipmbox/doc/flow.svg776
-rw-r--r--common/ipmbox/doc/ipmbox.txt231
-rw-r--r--common/ipmbox/doc/rpc.msc10
-rw-r--r--common/ipmbox/msg.h205
-rw-r--r--common/ipmbox/protocol.h55
-rw-r--r--common/ipmbox/queue.h182
-rw-r--r--common/ipmbox/registers.h43
-rw-r--r--common/ipmbox/src/queue.c75
10 files changed, 1601 insertions, 0 deletions
diff --git a/common/ipmbox/Module b/common/ipmbox/Module
new file mode 100644
index 0000000000..4d1af1d099
--- /dev/null
+++ b/common/ipmbox/Module
@@ -0,0 +1 @@
+SOURCES = queue.c
diff --git a/common/ipmbox/doc/Makefile b/common/ipmbox/doc/Makefile
new file mode 100644
index 0000000000..0027813ce0
--- /dev/null
+++ b/common/ipmbox/doc/Makefile
@@ -0,0 +1,23 @@
+DOCUMENTS = ipmbox
+GEN_IMAGES = flow_tx.png flow_rx.png rpc.png
+
+all: html
+
+html: $(DOCUMENTS:%=%.html)
+%.html: %.txt images
+ rst2html $< $@
+
+pdf: $(DOCUMENTS:%=%.pdf)
+%.pdf: %.txt images
+ rst2pdf $< -o $@
+
+images: $(GEN_IMAGES)
+
+flow_%.png: flow.svg
+ inkscape $< --export-png=$@ -i g$*
+
+%.png: %.msc
+ mscgen -T png -i $< -o $@
+
+clean:
+ rm $(GEN_IMAGES) $(DOCUMENTS:%=%.html) $(DOCUMENTS:%=%.pdf)
diff --git a/common/ipmbox/doc/flow.svg b/common/ipmbox/doc/flow.svg
new file mode 100644
index 0000000000..bb6de5c672
--- /dev/null
+++ b/common/ipmbox/doc/flow.svg
@@ -0,0 +1,776 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<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:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="744.09448819"
+ height="1052.3622047"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="flow.svg">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="DotM"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="DotM"
+ style="overflow:visible">
+ <path
+ id="path3915"
+ d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;marker-end:none"
+ transform="scale(0.4) translate(7.4, 1)" />
+ </marker>
+ <marker
+ inkscape:stockid="CurveIn"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="CurveIn"
+ style="overflow:visible">
+ <path
+ id="path4035"
+ d="M 4.6254930,-5.0456926 C 1.8654930,-5.0456926 -0.37450702,-2.8056926 -0.37450702,-0.045692580 C -0.37450702,2.7143074 1.8654930,4.9543074 4.6254930,4.9543074"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;marker-end:none;fill:none"
+ transform="scale(0.6)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Lend"
+ style="overflow:visible;">
+ <path
+ id="path3853"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
+ transform="scale(0.8) rotate(180) translate(12.5,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Mend"
+ style="overflow:visible;">
+ <path
+ id="path3859"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
+ transform="scale(0.4) rotate(180) translate(10,0)" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.70710678"
+ inkscape:cx="380.80888"
+ inkscape:cy="532.38107"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:snap-global="true"
+ inkscape:snap-grids="true"
+ inkscape:window-width="1280"
+ inkscape:window-height="1012"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2816"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="false"
+ spacingx="20px"
+ spacingy="20px" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="135.36044"
+ y="144.23505"
+ id="text3735"><tspan
+ sodipodi:role="line"
+ id="tspan3737"
+ x="135.36044"
+ y="144.23505" /></text>
+ <g
+ id="gtx"
+ inkscape:label="#gtx">
+ <rect
+ y="72.362183"
+ x="80"
+ height="40"
+ width="160"
+ id="rect3805"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <text
+ id="text3715"
+ y="88.172729"
+ x="94.972656"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="88.172729"
+ x="94.972656"
+ id="tspan3717"
+ sodipodi:role="line">Free Buffer</tspan><tspan
+ id="tspan3803"
+ y="103.17273"
+ x="94.972656"
+ sodipodi:role="line">May restart TX queue</tspan></text>
+ <rect
+ transform="matrix(0,-1,1,0,0,0)"
+ y="120.00001"
+ x="-312.36218"
+ height="440"
+ width="160"
+ id="rect3713"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <g
+ transform="translate(180,20.000003)"
+ id="g3671">
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+ d="m 140,152.36218 0,80 -20,0 40,40 40,-40 -20,0 0,-80 -40,0 z"
+ id="path2833" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="159.95898"
+ y="209.23621"
+ id="text2826"><tspan
+ sodipodi:role="line"
+ id="tspan2828"
+ x="159.95898"
+ y="209.23621">Data</tspan><tspan
+ sodipodi:role="line"
+ x="159.95898"
+ y="224.23621"
+ id="tspan2830">A2L</tspan></text>
+ </g>
+ <g
+ transform="translate(240,20.000003)"
+ id="g3677">
+ <path
+ id="path3623"
+ d="m 240,152.36218 0,80 -20,0 40,40 40,-40 -20,0 0,-80 -40,0 z"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
+ <text
+ id="text3625"
+ y="209.23621"
+ x="259.95898"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="209.23621"
+ x="259.95898"
+ id="tspan3627"
+ sodipodi:role="line">MBX</tspan><tspan
+ id="tspan3629"
+ y="224.23621"
+ x="259.95898"
+ sodipodi:role="line">A2L</tspan></text>
+ </g>
+ <g
+ transform="translate(-180,-120)"
+ id="g3690">
+ <path
+ id="path3657"
+ d="m 380,412.36218 0,-80 20,0 -40,-40 -40,40 20,0 0,80 40,0 z"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
+ <text
+ id="text3659"
+ y="341.73621"
+ x="359.58984"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="341.73621"
+ x="359.58984"
+ id="tspan3661"
+ sodipodi:role="line">Empty</tspan><tspan
+ id="tspan3663"
+ y="356.73621"
+ x="359.58984"
+ sodipodi:role="line">Buf</tspan><tspan
+ id="tspan3665"
+ y="371.73621"
+ x="359.58984"
+ sodipodi:role="line">L2A</tspan></text>
+ </g>
+ <text
+ transform="matrix(0,-1,1,0,0,0)"
+ id="text3739"
+ y="114.28906"
+ x="-268.4071"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="114.28906"
+ x="-268.4071"
+ id="tspan3741"
+ sodipodi:role="line">IPMBox TX part</tspan></text>
+ <path
+ sodipodi:nodetypes="cc"
+ id="path3845"
+ d="m 180,172.36218 c 0,-20 -20,-60 -20,-60"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <text
+ id="text4486"
+ y="52.362183"
+ x="319.46094"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="52.362183"
+ x="319.46094"
+ id="tspan4488"
+ sodipodi:role="line">From Linux</tspan><tspan
+ id="tspan4490"
+ y="67.362183"
+ x="319.46094"
+ sodipodi:role="line">network layer</tspan></text>
+ <path
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 450,72.362183 30,0 0,39.999997 -40,0 0,-29.999997 10,-10 z"
+ id="path4492"
+ sodipodi:nodetypes="cccccc" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="460.00293"
+ y="52.362183"
+ id="text4494"><tspan
+ sodipodi:role="line"
+ x="460.00293"
+ y="52.362183"
+ id="tspan4498">From netlink</tspan><tspan
+ id="tspan4502"
+ sodipodi:role="line"
+ x="460.00293"
+ y="67.362183">(managerd/plcd)</tspan></text>
+ <g
+ transform="translate(0,40)"
+ id="g5324">
+ <rect
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect4504"
+ width="40"
+ height="40"
+ x="540"
+ y="32.362183"
+ rx="10"
+ ry="10" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="560.1582"
+ y="48.518433"
+ id="text4506"><tspan
+ sodipodi:role="line"
+ x="560.1582"
+ y="48.518433"
+ id="tspan4514">trace</tspan><tspan
+ sodipodi:role="line"
+ x="560.1582"
+ y="63.518433"
+ id="tspan4518">/RPC</tspan></text>
+ </g>
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4520"
+ d="m 320,112.36218 c 0,20 20,60 20,60"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4708"
+ d="m 460,112.36218 c 0,20 40,60 40,60"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path4896"
+ d="m 560,112.36218 c 0,20 -60,60 -60,60"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path5088"
+ d="m 500,292.36218 c 0,20 -80,120 -80,120"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path5290"
+ d="m 500,292.36218 c 0,20 40,60 40,60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <text
+ id="text5292"
+ y="403.97949"
+ x="560.31348"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="403.97949"
+ x="560.31348"
+ id="tspan5294"
+ sodipodi:role="line">To hle/tools</tspan></text>
+ <g
+ id="g5313">
+ <rect
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect5304"
+ width="80"
+ height="20"
+ x="380"
+ y="412.36218" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="419.73047"
+ y="426.83582"
+ id="text5296"><tspan
+ sodipodi:role="line"
+ id="tspan5298"
+ x="419.73047"
+ y="426.83582">CP/Interface</tspan></text>
+ </g>
+ <g
+ id="g5308">
+ <rect
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect5306"
+ width="80"
+ height="20"
+ x="220"
+ y="412.36218" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="259.69238"
+ y="426.73035"
+ id="text5300"><tspan
+ sodipodi:role="line"
+ id="tspan5302"
+ x="259.69238"
+ y="426.73035">CL</tspan></text>
+ </g>
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(0,280)"
+ id="use5330"
+ xlink:href="#g5324"
+ y="0"
+ x="0" />
+ <path
+ id="path5354"
+ d="m 260,412.36218 c 0,-20 -80,-120 -80,-120"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path5352"
+ d="m 420,412.36218 c 0,-20 -240,-120 -240,-120"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path5094"
+ d="m 340,292.36218 c 0,20 -80,120 -80,120"
+ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(-140,-6.1718754e-7)"
+ id="use5730"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(-180,280)"
+ id="use5734"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(-20,280)"
+ id="use5736"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path5776"
+ d="m 226.27417,100.59543 c 0,0 73.72583,31.76675 93.72583,31.76675"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:4,8;stroke-dashoffset:0;marker-end:url(#DotM)" />
+ </g>
+ <g
+ id="grx"
+ transform="translate(-20,0)">
+ <rect
+ y="572.36218"
+ x="100"
+ height="40"
+ width="160"
+ id="rect6581"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <text
+ id="text6381"
+ y="588.17273"
+ x="179.66895"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="588.17273"
+ x="179.66895"
+ id="tspan6383"
+ sodipodi:role="line">Complete empty buffer</tspan><tspan
+ id="tspan6585"
+ y="603.17273"
+ x="179.66895"
+ sodipodi:role="line">pool on each reception</tspan></text>
+ <rect
+ transform="matrix(0,-1,1,0,0,0)"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect3745"
+ width="160"
+ height="440"
+ x="-812.36218"
+ y="140" />
+ <text
+ transform="matrix(0,-1,1,0,0,0)"
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="-767.9032"
+ y="134.28906"
+ id="text3747"><tspan
+ sodipodi:role="line"
+ id="tspan3749"
+ x="-767.9032"
+ y="134.28906">IPMBox RX part</tspan></text>
+ <g
+ transform="translate(-160,520.00001)"
+ id="g3683">
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+ d="m 340,152.36218 0,80 -20,0 40,40 40,-40 -20,0 0,-80 -40,0 z"
+ id="path3631" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="359.58984"
+ y="201.73621"
+ id="text3633"><tspan
+ sodipodi:role="line"
+ id="tspan3635"
+ x="359.58984"
+ y="201.73621">Empty</tspan><tspan
+ sodipodi:role="line"
+ x="359.58984"
+ y="216.73621"
+ id="tspan3639">Buf</tspan><tspan
+ sodipodi:role="line"
+ x="359.58984"
+ y="231.73621"
+ id="tspan3637">A2L</tspan></text>
+ </g>
+ <g
+ transform="translate(200,380)"
+ id="g3703">
+ <path
+ id="path3641"
+ d="m 180,412.36218 0,-80 20,0 -40,-40 -40,40 20,0 0,80 40,0 z"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
+ <text
+ id="text3643"
+ y="349.23621"
+ x="159.95898"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="349.23621"
+ x="159.95898"
+ id="tspan3645"
+ sodipodi:role="line">Data</tspan><tspan
+ y="364.23621"
+ x="159.95898"
+ sodipodi:role="line"
+ id="tspan3667">L2A</tspan></text>
+ </g>
+ <g
+ transform="translate(260,380)"
+ id="g3697">
+ <path
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+ d="m 280,412.36218 0,-80 20,0 -40,-40 -40,40 20,0 0,80 40,0 z"
+ id="path3649" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="259.95898"
+ y="349.23621"
+ id="text3651"><tspan
+ sodipodi:role="line"
+ id="tspan3653"
+ x="259.95898"
+ y="349.23621">MBX</tspan><tspan
+ sodipodi:role="line"
+ x="259.95898"
+ y="364.23621"
+ id="tspan3655">L2A</tspan></text>
+ </g>
+ <text
+ id="text3719"
+ y="538.27625"
+ x="319.49902"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="538.27625"
+ x="319.49902"
+ id="tspan3721"
+ sodipodi:role="line">Send to Linux</tspan><tspan
+ id="tspan3723"
+ y="553.27625"
+ x="319.49902"
+ sodipodi:role="line">network layer</tspan><tspan
+ id="tspan3725"
+ y="568.27625"
+ x="319.49902"
+ sodipodi:role="line">(NAPI)</tspan></text>
+ <text
+ id="text3727"
+ y="552.36218"
+ x="460.00293"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="552.36218"
+ x="460.00293"
+ id="tspan3729"
+ sodipodi:role="line">Send to netlink</tspan><tspan
+ id="tspan5728"
+ y="567.36218"
+ x="460.00293"
+ sodipodi:role="line">(managerd/plcd)</tspan><tspan
+ id="tspan3731"
+ y="582.36218"
+ x="460.00293"
+ sodipodi:role="line" /></text>
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(-140,500)"
+ id="use5738"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(0,500)"
+ id="use5740"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(20,780)"
+ id="use5746"
+ xlink:href="#g5324"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(20,500)"
+ id="use5748"
+ xlink:href="#g5324"
+ y="0"
+ x="0" />
+ <g
+ transform="translate(40,-20.012817)"
+ id="g5769">
+ <path
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="m 100,872.375 0,40 c 0,2.76142 8.95431,5 20,5 11.04569,0 20,-2.23858 20,-5 l 0,-40 -40,0 z"
+ id="rect5750" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;stroke:#000000;stroke-width:1.41421354;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+ id="path5752"
+ sodipodi:cx="120"
+ sodipodi:cy="862.36218"
+ sodipodi:rx="20"
+ sodipodi:ry="10"
+ d="m 140,862.36218 c 0,5.52285 -8.95431,10 -20,10 -11.04569,0 -20,-4.47715 -20,-10 0,-5.52284 8.95431,-10 20,-10 11.04569,0 20,4.47716 20,10 z"
+ transform="matrix(1,0,0,0.5,0,441.18109)" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="119.41699"
+ y="893.1731"
+ id="text5763"><tspan
+ sodipodi:role="line"
+ id="tspan5765"
+ x="119.41699"
+ y="893.1731">Buf</tspan><tspan
+ sodipodi:role="line"
+ x="119.41699"
+ y="908.1731"
+ id="tspan5767">Mgr</tspan></text>
+ </g>
+ <path
+ sodipodi:nodetypes="cc"
+ id="path6181"
+ d="m 580,852.36218 c 0.17244,-18.97965 -60,-60 -60,-60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path6183"
+ d="m 520,672.36218 c 0,-20 40,-60 40,-60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path6185"
+ d="m 520,672.36218 c 0,-20 -40,-60 -40,-60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path6187"
+ d="m 360,672.36218 c 0,-20 -20,-60 -20,-60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ id="path6189"
+ d="m 200,792.36218 c 0,20 -40,60 -40,60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path6385"
+ d="m 480,612.36218 c -20,20 -200,40 -240,0"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:4, 8;stroke-dashoffset:0;marker-end:url(#DotM)" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:4, 8;stroke-dashoffset:0;marker-end:url(#DotM)"
+ d="m 340,612.36218 c -20,20 -60,20 -100,0"
+ id="path6389"
+ sodipodi:nodetypes="cc" />
+ <path
+ id="path6583"
+ d="m 180,612.36218 c 0,20 20,60 20,60"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <g
+ transform="translate(40,500)"
+ id="g6587">
+ <rect
+ y="412.36218"
+ x="220"
+ height="20"
+ width="80"
+ id="rect6589"
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <text
+ id="text6591"
+ y="426.73035"
+ x="259.69238"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="426.73035"
+ x="259.69238"
+ id="tspan6593"
+ sodipodi:role="line">SAR</tspan></text>
+ </g>
+ <g
+ transform="translate(20,0)"
+ id="g6996">
+ <rect
+ style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="rect6597"
+ width="80"
+ height="20"
+ x="400"
+ y="912.36218" />
+ <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="439.69238"
+ y="926.73035"
+ id="text6599"><tspan
+ sodipodi:role="line"
+ id="tspan6601"
+ x="439.69238"
+ y="926.73035">CP/Interface</tspan></text>
+ </g>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)"
+ d="m 180,872.36218 c 20,0 120,40 120,40"
+ id="path6603" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)"
+ d="m 180,872.36218 c 100,0 280,40 280,40"
+ id="path6605"
+ sodipodi:nodetypes="cc" />
+ <path
+ id="path6987"
+ d="M 299.00515,912.96113 C 300,892.36218 360,792.36218 360,792.36218"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <path
+ sodipodi:nodetypes="cc"
+ id="path6989"
+ d="m 460,912.36218 c 0,-20 60,-120 60,-120"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(20,760)"
+ id="use5742"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <use
+ height="1052.3622"
+ width="744.09448"
+ transform="translate(-140,760)"
+ id="use5744"
+ xlink:href="#path4492"
+ y="0"
+ x="0" />
+ <text
+ id="text7381"
+ y="903.97943"
+ x="579.70703"
+ style="font-size:12px;font-style:normal;font-weight:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ xml:space="preserve"><tspan
+ y="903.97943"
+ x="579.70703"
+ id="tspan7383"
+ sodipodi:role="line">From hle/tools</tspan></text>
+ </g>
+ </g>
+</svg>
diff --git a/common/ipmbox/doc/ipmbox.txt b/common/ipmbox/doc/ipmbox.txt
new file mode 100644
index 0000000000..916e417d91
--- /dev/null
+++ b/common/ipmbox/doc/ipmbox.txt
@@ -0,0 +1,231 @@
+=====================
+IPMBox specifications
+=====================
+
+Introduction
+************
+
+Forewords
+=========
+
+This document contains Inter Processor MailBox (IPMBox) specifications. Its
+goals are :
+
+- to describe how works the IPMBox, the queues and the messages it uses
+- to provide description of interfaces used to communicate with other parts.
+
+Acronyms
+========
+
+====== ==========================
+Term Definition
+====== ==========================
+IPMBox Inter Processor MailBox
+HAL Hardware Abstraction Layer
+MME Management Message Entity
+RPC Remote Procedure Call
+====== ==========================
+
+IPMBox (Inter Processor MailBox)
+********************************
+
+Presentation
+============
+
+Communication between Cesar and Cleopatre is done through an Hardware
+Abstraction Layer (HAL) interface named IPMBox.
+
+This interface provides all functions to send/receive an Ethernet packet,
+Message Management Entity (MME) or other messages to/from Cleopatre without
+knowing how the hardware part is implemented : this allows to use the same
+Higher Layer Entity (HLE) for both real (LEON) and simulated (Maximus)
+environment.
+
+Hardware implementation relies on interrupt based mechanism. For example, on
+the reception layer part, when a data packet is received, an interrupt is
+triggered, which leads to the execution of the interrupt handler:
+
+- acknowledge the interrupt
+- get a copy of pending message descriptors into a dedicated descriptor buffer
+- update the queue head pointer
+- process copy of message descriptor one after one (several messages may have
+ been received).
+
+IPMBox hardware implementation
+==============================
+
+The hardware is responsible to provide mechanisms to:
+
+- trigger interrupt
+- acknowledge interrupt
+- mask interrupt.
+
+Those mechanisms should be provided for both directions, independently.
+
+The current hardware implementation also provides registers to store head and
+tail queue's pointers for two queues. As we need more of them, some pointers
+are stored on shared memory (accessible by both processors). Thus, those
+registers are not a mandatory part of the implementation.
+
+Queues
+------
+
+Each queue is implemented as a circular buffer, with an head and tail pointer.
+
+The writer can only update tail, the reader can only update head. When head
+and tail pointers are equal, the buffer is empty. Only the writer can write to
+the buffer. Current implementation takes measures not to be affected by
+processor cache. The complete message, including its parameters are written in
+the buffer.
+
+Queues are provided by pair, one for each direction:
+
+- data: to transmit messages with an attached payload,
+- empty buffer: to transmit messages to be filled or cleared,
+- mailbox: to transmit messages for management (MME, debug dump, RPC).
+
+It also contains base and end pointers to improve management of the rollover.
+
+Interrupt handshake
+-------------------
+
+To trigger an interrupt, the writer writes a one in the interrupt trigger bit,
+this will set the interrupt flag bit to one. The interrupt is asserted on the
+reader as long as it is one. To acknowledge the interrupt, the reader must
+write a one to the interrupt flag bit. Writing a zero does not affect the
+flag.
+
+The interrupt can be masked by clearing the interrupt enable bit.
+
+Initialisation protocol
+-----------------------
+
+Both CPUs need to know and share some queues informations like queue's sizes
+and start of shared memory zone.
+
+A protocol is defined to:
+
+- exchange those information,
+- prevent incompatible changes between both Cleopatre and Cesar IPMBox's
+ implementation
+- know when Cesar is ready and IPMBox has been setup on both sides.
+
+Information flow
+****************
+
+TX flows
+========
+
+.. figure:: flow_tx.png
+
+Data frames are sent on the data queue, private MMEs are sent on the mailbox
+queue. Once the buffer has been used by the corresponding Cesar entity, it is
+sent back to Cleopatre.
+
+The number of buffers sent to Cesar is limited so that the empty buffer queue
+can never overflow.
+
+All other messages (RPC and debug dump) are sent on the mailbox queue.
+
+RX flows
+========
+
+Cleoaptre is responsible to feed the bufmgr with a pool of empty buffer. When
+a Cesar entity needs a buffer, it requests it to the bufmgr, fills it and
+sends it to Cleopatre using the data queue, or the mailbox queue for private
+MMEs.
+
+The number of empty buffers provided by Cleopatre is limited so that the RX
+queues can never overflow.
+
+All other messages (RPC and debug dump) are sent on the mailbox queue.
+
+.. figure:: flow_rx.png
+
+Messages nomenclature
+*********************
+
+Empty buf
+=========
+
+This message only contains the address of the empty buffer. It is only sent on
+the empty buf queues.
+
+Buffers coming from Cleopatre are supposed to contain enough room to put any
+Ethernet frame.
+
+Size of buffers coming from Cesar is unspecified. Cleopatre is supposed to
+known this information as it previously sent the buffer to Cesar.
+
+Data
+====
+
+This message is only sent on the data queues. It contains:
+
+- data buffer address,
+- data length,
+- VLAN prio (see IEEE P802.1p), used by Cesar to classify the data frame.
+
+MME priv
+========
+
+This message contains a private MME and is only sent on the mailbox queues. It
+contains:
+
+- the message type (IPMBOX_MSG_MBX_TYPE_MME_PRIV),
+- MME buffer address,
+- MME length.
+
+Debug dump
+==========
+
+This message is used to retrieve debug information dump from Cesar. It is only
+sent on mailbox queues.
+
+When sent to Cesar, the message contains:
+
+- the message type (IPMBOX_MSG_MBX_TYPE_DEBUG_DUMP),
+- an empty buffer address,
+- the number of bytes available in the provided buffer.
+
+Cesar is expected to reply with the same message which contains:
+
+- the message type (IPMBOX_MSG_MBX_TYPE_DEBUG_DUMP),
+- the same buffer address,
+- the number of bytes written in the buffer.
+
+RPC
+===
+
+This message is used to implement a remote procedure call to Cesar. It is only
+sent on mailbox queues.
+
+When sent to Cesar, the message contains:
+
+- the message type (IPMBOX_MSG_MBX_TYPE_RPC),
+- an exchange buffer address,
+- a forward length, which is the length of readable data in the exchange
+ buffer,
+- a reverse length in kilobyte, which is the available length in the exchange
+ buffer for writing,
+- a cookie to identify the request.
+
+If reverse length is 0, Cesar can not reply, it should wait the next message
+which will contain more information.
+
+If forward length is 0, Cesar is supposed to continue a previous exchange by
+sending more information.
+
+When sent from Cesar, the message contains:
+
+- the message type (IPMBOX_MSG_MBX_TYPE_RPC),
+- the same exchange buffer address,
+- a forward length, which is the length of readable data in the exchange
+ buffer, this can be zero,
+- a more_data flag to request more buffer to continue the exchange,
+- the same cookie as the request message.
+
+.. figure:: rpc.png
+
+ Example: Cleopatre send a RPC message of 1166 bytes, Cesar reply with 1184
+ bytes, with a buffer of 1024 bytes.
diff --git a/common/ipmbox/doc/rpc.msc b/common/ipmbox/doc/rpc.msc
new file mode 100644
index 0000000000..e662080e6e
--- /dev/null
+++ b/common/ipmbox/doc/rpc.msc
@@ -0,0 +1,10 @@
+# MSC for RPC exchanges.
+msc {
+ a [ label = "Cleopatre" ], b [ label = "Cesar" ];
+
+ a->b [ label = "forward length = 1024, revese length = 0" ];
+ a->b [ label = "forward length = 142, revese length = 1k" ];
+ a<-b [ label = "forward length = 1024, more data" ];
+ a->b [ label = "forward length = 0, revese length = 1k" ];
+ a<-b [ label = "forward length = 160" ];
+}
diff --git a/common/ipmbox/msg.h b/common/ipmbox/msg.h
new file mode 100644
index 0000000000..caa0674393
--- /dev/null
+++ b/common/ipmbox/msg.h
@@ -0,0 +1,205 @@
+#ifndef common_ipmbox_msg_h
+#define common_ipmbox_msg_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/ipmbox/msg.h
+ * \brief IPMBox message format.
+ */
+#include "common/universe.h"
+
+/**
+ * MBX message types.
+ */
+enum ipmbox_msg_mbx_type_t
+{
+ IPMBOX_MSG_MBX_TYPE_MME_PRIV = 0,
+ IPMBOX_MSG_MBX_TYPE_DEBUG_DUMP = 1,
+ IPMBOX_MSG_MBX_TYPE_RPC = 2,
+};
+
+/**
+ * Number of words for one message on each queue.
+ */
+#define IPMBOX_MSG_MBX_WORDS \
+ (sizeof (ipmbox_msg_mbx_t) / sizeof (u32))
+#define IPMBOX_MSG_EMPTY_BUF_WORDS \
+ (sizeof (ipmbox_msg_empty_buf_t) / sizeof (u32))
+#define IPMBOX_MSG_DATA_WORDS \
+ (sizeof (ipmbox_msg_data_t) / sizeof (u32))
+
+/**
+ * Structure of an empty buffer message.
+ */
+typedef struct ipmbox_msg_empty_buf_t
+{
+ /** Buffer address (physical). */
+ u32 buffer_addr;
+} ipmbox_msg_empty_buf_t;
+
+/**
+ * Structure of a data message.
+ */
+typedef struct ipmbox_msg_data_t
+{
+ /** Message header. */
+ u32 header;
+ /** Buffer address (physical). */
+ u32 buffer_addr;
+} ipmbox_msg_data_t;
+
+/**
+ * Structure of a mailbox message.
+ */
+typedef struct ipmbox_msg_mbx_t
+{
+ /** Message header. */
+ u32 header;
+ /** Buffer address (physical). */
+ u32 buffer_addr;
+} ipmbox_msg_mbx_t;
+
+/**
+ * Build an header for data type.
+ * \param length length of data frame
+ * \param prio_tag VLAN priority tag
+ * \return the built header
+ */
+extern inline u32
+ipmbox_msg_create_header_data (unsigned int length, unsigned int prio_tag)
+{
+ dbg_claim (length && length < (1 << 11));
+ dbg_claim (prio_tag < (1 << 3));
+ return length | (prio_tag << 11);
+}
+
+/** Get length from data header. */
+extern inline unsigned int
+ipmbox_msg_get_data_length (u32 header)
+{
+ return header & ((1 << 11) - 1);
+}
+
+/** Get prio_tag from data header. */
+extern inline unsigned int
+ipmbox_msg_get_data_prio_tag (u32 header)
+{
+ return (header >> 11) & ((1 << 3) - 1);
+}
+
+/** Get message type from mbx header. */
+extern inline unsigned int
+ipmbox_msg_get_mbx_type (u32 header)
+{
+ return header & ((1 << 8) - 1);
+}
+
+/**
+ * Build an header for private MME type.
+ * \param length length of data frame
+ * \return the built header
+ */
+extern inline u32
+ipmbox_msg_create_header_mme_priv (unsigned int length)
+{
+ dbg_assert (length && length < (1 << 11));
+ return IPMBOX_MSG_MBX_TYPE_MME_PRIV | (length << 8);
+}
+
+/** Get length from mme_priv header. */
+extern inline unsigned int
+ipmbox_msg_get_mme_priv_length (u32 header)
+{
+ return (header >> 8) & ((1 << 11) - 1);
+}
+
+/**
+ * Build an header for debug dump type.
+ * \param length length of data frame
+ * \return the built header
+ */
+extern inline u32
+ipmbox_msg_create_header_debug_dump (unsigned int length)
+{
+ dbg_assert (length < (1 << 16));
+ return IPMBOX_MSG_MBX_TYPE_DEBUG_DUMP | (length << 8);
+}
+
+/** Get length from debug dump header. */
+extern inline unsigned int
+ipmbox_msg_get_debug_dump_length (u32 header)
+{
+ return (header >> 8) & ((1 << 16) - 1);
+}
+
+/**
+ * Build an header for RPC request type (A2L).
+ * \param forward_length length of readable data in buffer
+ * \param reverse_length_kb length of writable space in buffer in kilobyte
+ * \param cookie cookie to identify request
+ */
+extern inline u32
+ipmbox_msg_create_header_rpc_a2l (unsigned int forward_length,
+ unsigned int reverse_length_kb,
+ unsigned int cookie)
+{
+ dbg_assert (forward_length < (1 << 13));
+ dbg_assert (reverse_length_kb < (1 << 3));
+ dbg_assert (cookie < (1 << 4));
+ return IPMBOX_MSG_MBX_TYPE_RPC | (forward_length << 8)
+ | (reverse_length_kb << (8 + 13)) | (cookie << (8 + 13 + 3));
+}
+
+/**
+ * Build an header for RPC response type (L2A).
+ * \param forward_length length of readable data in buffer
+ * \param more_data 1 if more data is to be read
+ * \param cookie cookie to identify response
+ */
+extern inline u32
+ipmbox_msg_create_header_rpc_l2a (unsigned int forward_length,
+ bool more_data,
+ unsigned int cookie)
+{
+ dbg_assert (forward_length < (1 << 13));
+ dbg_assert (cookie < (1 << 4));
+ return IPMBOX_MSG_MBX_TYPE_RPC | (forward_length << 8)
+ | (more_data ? (1 << (8 + 13)) : 0)
+ | 0 /* 2 padding bits */
+ | (cookie << (8 + 13 + 1 + 2));
+}
+
+/** Get length from RPC header. */
+extern inline unsigned int
+ipmbox_msg_get_rpc_forward_length (u32 header)
+{
+ return (header >> 8) & ((1 << 13) - 1);
+}
+
+/** Get reverse length from RPC request header. */
+extern inline unsigned int
+ipmbox_msg_get_rpc_a2l_reverse_length_kb (u32 header)
+{
+ return (header >> (8 + 13)) & ((1 << 3) - 1);
+}
+
+/** Get more_data from RPC response header. */
+extern inline bool
+ipmbox_msg_get_rpc_l2a_more_data (u32 header)
+{
+ return ((header >> (8 + 13)) & 1) ? true : false;
+}
+
+/** Get cookie from RPC header. */
+extern inline unsigned int
+ipmbox_msg_get_rpc_cookie (u32 header)
+{
+ return (header >> (8 + 13 + 3)) & ((1 << 4) - 1);
+}
+
+#endif /* common_ipmbox_msg_h */
diff --git a/common/ipmbox/protocol.h b/common/ipmbox/protocol.h
new file mode 100644
index 0000000000..af310d36cc
--- /dev/null
+++ b/common/ipmbox/protocol.h
@@ -0,0 +1,55 @@
+#ifndef common_ipmbox_protocol_h
+#define common_ipmbox_protocol_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/ipmbox/protocol.h
+ * \brief IPMbox protocol defines
+ */
+
+#include "queue.h"
+#include "msg.h"
+
+/**
+ * Protocol version.
+ * It must be changed when protocol is modified and is not compatible with
+ * previous version. It is stored on a 32 bits.
+ */
+#define IPMBOX_PROTOCOL_VERSION 42
+
+/**
+ * Queues sizes in words.
+ * On the TX side (A2L MBX & DATA, L2A EMPTY BUF):
+ * - L2A_EMPTY_BUF >= A2L_MBX / MSG_MBX_WORDS + A2L_DATA / MSG_DATA_WORDS
+ * On the RX side (L2A MBX & DATA, A2L EMPTY BUF):
+ * - L2A_DATA / MSG_DATA_WORDS = A2L_EMPTY_BUF
+ * - L2A_MBX / MSG_MBX_WORDS = A2L_EMPTY_BUF (but this is a worst case, in
+ * real life things are not that bad, we take the risk)
+ */
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_MBX (32 * IPMBOX_MSG_MBX_WORDS)
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_DATA (256 * IPMBOX_MSG_DATA_WORDS)
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_L2A_EMPTY_BUF (256 + 32)
+
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_L2A_MBX (32 * IPMBOX_MSG_MBX_WORDS)
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_L2A_DATA (256 * IPMBOX_MSG_DATA_WORDS)
+#define IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_EMPTY_BUF (256)
+
+/**
+ * Initialisation of IPMbox structure.
+ */
+typedef struct ipmbox_protocol_init_t
+{
+ /** Version. */
+ u32 version;
+ /** Pointer to shared memory. */
+ volatile ipmbox_queue_ptr_t *shared_mem;
+ /** Table of queues size. */
+ u32 queue_size[IPMBOX_QUEUE_TYPE_NB][IPMBOX_QUEUE_DIRECTION_NB];
+} ipmbox_protocol_init_t;
+
+#endif /* common_ipmbox_protocol_h */
diff --git a/common/ipmbox/queue.h b/common/ipmbox/queue.h
new file mode 100644
index 0000000000..3c5a4e6482
--- /dev/null
+++ b/common/ipmbox/queue.h
@@ -0,0 +1,182 @@
+#ifndef common_ipmbox_queue_h
+#define common_ipmbox_queue_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/ipmbox/queue.h
+ * \brief IPMbox queue management
+ *
+ * This file contains interfaces used to access the different queues for
+ * IPMbox.
+ */
+#include "common/universe.h"
+
+/**
+ * Shared queue management pointers.
+ * They must follow each others in memory. A structure is used to prevent too
+ * much indirections when accessing those pointers.
+ * Order of pointers is important and must not be changed (otherwise
+ * everything will fail).
+ * Only contains physical address.
+ */
+typedef struct ipmbox_queue_ptr_t
+{
+ unsigned long tail;
+ unsigned long head;
+} ipmbox_queue_ptr_t;
+
+/**
+ * A queue (implemented as a circular ring).
+ */
+typedef struct ipmbox_queue_t
+{
+ /** Base address of start of the queue. */
+ u32 *base_ptr;
+ /** End of the queue (past the queue). */
+ u32 *end_ptr;
+#if !CESAR
+ /** Virtual to physical address offset. */
+ u32 virt_to_phys_offset;
+#endif
+ /** Pointers of queue. */
+ volatile ipmbox_queue_ptr_t *ptr;
+ /** Queue size in words. */
+ unsigned int size;
+} ipmbox_queue_t;
+
+/**
+ * List of queues in the IPMBox.
+ */
+typedef enum ipmbox_queue_type_t
+{
+ /** All other types of messages (MME, RPC, debug types). */
+ IPMBOX_QUEUE_MBX = 0,
+ /** Empty buffer to free or for storing message (empty buf only). */
+ IPMBOX_QUEUE_EMPTY_BUF,
+ /** Data (PLC frame) queue (type data only). */
+ IPMBOX_QUEUE_DATA,
+ IPMBOX_QUEUE_TYPE_NB
+} ipmbox_queue_type_t;
+
+/**
+ * IPMbox direction.
+ */
+typedef enum ipmbox_queue_direction_t
+{
+ /** ARM to Leon. */
+ IPMBOX_A2L = 0,
+ /** Leon to ARM. */
+ IPMBOX_L2A,
+ IPMBOX_QUEUE_DIRECTION_NB
+} ipmbox_queue_direction_t;
+
+/**
+ * Convert virtual address to physical address for a pointer into a queue.
+ * \param queue queue context
+ * \param virt virtual address
+ * \return physical address
+ */
+extern inline u32
+ipmbox_queue_virt_to_phys (ipmbox_queue_t *queue, void *virt)
+{
+#if CESAR
+ return (u32) virt;
+#else
+ return (u32) virt + queue->virt_to_phys_offset;
+#endif
+}
+
+/**
+ * Convert physical address to virtual address for a pointer into a queue.
+ * \param queue queue context
+ * \param phys physical address
+ * \return virtual address
+ */
+extern inline void *
+ipmbox_queue_phys_to_virt (ipmbox_queue_t *queue, u32 phys)
+{
+#if CESAR
+ return (void *) phys;
+#else
+ return (void *) (phys - queue->virt_to_phys_offset);
+#endif
+}
+
+/**
+ * Get free space in a queue.
+ * \param queue queue to check
+ * \return free size in words
+ */
+extern inline unsigned int
+ipmbox_queue_get_free_space (ipmbox_queue_t *queue)
+{
+ u32 *tail, *head;
+
+ /* Check parameter. */
+ dbg_claim (queue);
+
+ tail = (u32 *) queue->ptr->tail;
+ head = (u32 *) queue->ptr->head;
+
+ if (tail >= head)
+ return queue->size - (tail - head) - 1;
+ else
+ return head - tail - 1;
+}
+
+/**
+ * Get used space in a queue.
+ * \param queue queue to check
+ * \return used size in words
+ */
+extern inline unsigned int
+ipmbox_queue_get_used_space (ipmbox_queue_t *queue)
+{
+ u32 *tail, *head;
+
+ /* Check parameter. */
+ dbg_claim (queue);
+
+ tail = (u32 *) queue->ptr->tail;
+ head = (u32 *) queue->ptr->head;
+
+ if (tail >= head)
+ return tail - head;
+ else
+ return queue->size + tail - head;
+}
+
+/**
+ * Copy data to a queue.
+ * \param queue queue in which to add data
+ * \param data pointer to the data
+ * \param size data size in words
+ *
+ * \warning callee is responsible to check there is enough space in queue
+ * to copy data.
+ */
+void
+ipmbox_queue_copy_to (ipmbox_queue_t *queue, u32 *data,
+ unsigned int size);
+
+/**
+ * Copy data from a queue.
+ * \param queue queue in which to get data from
+ * \param data pointer to the data where to store them
+ * \param size data size in words (space available in data buffer)
+ *
+ * \warning Callee is responsible to check that size is in sync with current
+ * queue size: size must be inferior or equal to used space in queue (never
+ * over queue size - 1).
+ */
+void
+ipmbox_queue_copy_from (ipmbox_queue_t *queue, u32 *data,
+ unsigned int size);
+
+
+#endif /* common_ipmbox_queue_h */
diff --git a/common/ipmbox/registers.h b/common/ipmbox/registers.h
new file mode 100644
index 0000000000..1a6a83df7d
--- /dev/null
+++ b/common/ipmbox/registers.h
@@ -0,0 +1,43 @@
+#ifndef common_ipmbox_registers_h
+#define common_ipmbox_registers_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/ipmbox/registers.h
+ * \brief IPMbox registers
+ */
+#include "common/universe.h"
+
+/** Bit fields for A2L_IT register. */
+#define IPMBOX_A2L_IT (1 << 0)
+#define IPMBOX_A2L_IT_ACK (1 << 1)
+
+/** Bit fields for L2A_IT register. */
+#define IPMBOX_L2A_IT (1 << 0)
+#define IPMBOX_L2A_IT_ACK (1 << 1)
+#define IPMBOX_L2A_IT_WKP (1 << 2)
+#define IPMBOX_L2A_IT_WD (1 << 3)
+
+/**
+ * Organisation of the registers.
+ * You need to map this structure to the base address of the IPMbox.
+ * \see IPMbox specification document.
+ */
+typedef struct ipmbox_registers_t
+{
+ u32 a2l_it;
+ u32 a2l_it_mask;
+ u32 l2a_it;
+ u32 l2a_it_mask;
+ u32 a2l_tail;
+ u32 a2l_head;
+ u32 l2a_tail;
+ u32 l2a_head;
+} ipmbox_registers_t;
+
+#endif /* common_ipmbox_registers_h */
diff --git a/common/ipmbox/src/queue.c b/common/ipmbox/src/queue.c
new file mode 100644
index 0000000000..5d899db24c
--- /dev/null
+++ b/common/ipmbox/src/queue.c
@@ -0,0 +1,75 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/ipmbox/src/queue.c
+ * \brief IPMbox queue management
+ */
+#include "common/universe.h"
+
+#include "common/ipmbox/queue.h"
+
+void
+ipmbox_queue_copy_to (ipmbox_queue_t *queue, u32 *data,
+ unsigned int size)
+{
+ u32 *end, *tail;
+
+ /* Check parameters. */
+ dbg_claim (queue);
+ dbg_claim (data);
+ dbg_claim (size && size < queue->size);
+
+ /* Initialize local pointers. */
+ end = queue->end_ptr;
+ tail = ipmbox_queue_phys_to_virt (queue, queue->ptr->tail);
+
+ /* Copy each data. */
+ while (size--)
+ {
+ /* Copy data. */
+ *tail++ = *data++;
+ /* If we reach end of queue, rollover. */
+ if (tail == end)
+ tail = queue->base_ptr;
+ }
+
+ /* Update tail pointer. */
+ arch_reorder_barrier ();
+ queue->ptr->tail = ipmbox_queue_virt_to_phys (queue, tail);
+}
+
+void
+ipmbox_queue_copy_from (ipmbox_queue_t *queue, u32 *data,
+ unsigned int size)
+{
+ u32 *end, *head;
+
+ /* Check parameters. */
+ dbg_claim (queue);
+ dbg_claim (data);
+ dbg_claim (size && size < queue->size);
+
+ /* Initialize local queue pointer. */
+ head = ipmbox_queue_phys_to_virt (queue, queue->ptr->head);
+ end = queue->end_ptr;
+
+ /* Get data. */
+ while (size--)
+ {
+ /* Get data. */
+ *data++ = *head++;
+ /* If we reach end of queue, rollover. */
+ if (head == end)
+ head = queue->base_ptr;
+ }
+
+ /* Update head pointer. */
+ arch_reorder_barrier ();
+ queue->ptr->head = ipmbox_queue_virt_to_phys (queue, head);
+}
+