<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1435604059172_2814"><span id="yui_3_16_0_1_1435604059172_2902">The code belongs to our company, and it's quite complicated, so I can't share the code here. I can answer questions.</span></div><div id="yui_3_16_0_1_1435604059172_2814"><span><br></span></div><div id="yui_3_16_0_1_1435604059172_2814">This is roughly the components you will need:</div><div id="yui_3_16_0_1_1435604059172_2814"><br></div><div id="yui_3_16_0_1_1435604059172_2814">(1) linux user mode: test.c   --- (open and read/write /dev/vbox_pipe)</div><div id="yui_3_16_0_1_1435604059172_2814"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">(2) linux kernel driver: vbox_pipe.ko</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">Windows host plugins for the virtual PCI device:</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">(3)vbox_pipe_pci.dll</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">(4) vbox_pipe_driver.dll</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">You need two additions, one is the virtual PCI device itself, and the other is the driver to handle the i/o of the virtual device, to pipe in/out to other processes, for example.</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">Inside vbox_pipe_pci.dll, you  create a PCI device, register some register and map some memory I/O spaces.</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">Good lucks,</div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr"><br></div><div id="yui_3_16_0_1_1435604059172_2814" dir="ltr">- Huihong</div><br>  <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1435604059172_2756"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1435604059172_2755"> <div dir="ltr" id="yui_3_16_0_1_1435604059172_2805"> <hr size="1" id="yui_3_16_0_1_1435604059172_2813">  <font size="2" face="Arial" id="yui_3_16_0_1_1435604059172_2812"> <b><span style="font-weight:bold;">From:</span></b> 星策DRACULAX <DRACULAX@vszone.cn><br> <b><span style="font-weight: bold;">To:</span></b> 'Huihong Luo' <huisinro@yahoo.com>; vbox-dev@virtualbox.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, June 29, 2015 3:01 AM<br> <b id="yui_3_16_0_1_1435604059172_3059"><span style="font-weight: bold;" id="yui_3_16_0_1_1435604059172_3058">Subject:</span></b> 答复: [vbox-dev] How add device or driver (PDM) to VirtualBox<br> </font> </div> <div class="y_msg_container" id="yui_3_16_0_1_1435604059172_2754"><br><div id="yiv9128755192"><style>#yiv9128755192 #yiv9128755192 --
 
 _filtered #yiv9128755192 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;}
 _filtered #yiv9128755192 {font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}
 _filtered #yiv9128755192 {panose-1:2 4 5 3 5 4 6 3 2 4;}
 _filtered #yiv9128755192 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
 _filtered #yiv9128755192 {panose-1:2 1 6 0 3 1 1 1 1 1;}
#yiv9128755192  
#yiv9128755192 p.yiv9128755192MsoNormal, #yiv9128755192 li.yiv9128755192MsoNormal, #yiv9128755192 div.yiv9128755192MsoNormal
        {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:宋体;}
#yiv9128755192 a:link, #yiv9128755192 span.yiv9128755192MsoHyperlink
        {color:blue;text-decoration:underline;}
#yiv9128755192 a:visited, #yiv9128755192 span.yiv9128755192MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
#yiv9128755192 p.yiv9128755192MsoAcetate, #yiv9128755192 li.yiv9128755192MsoAcetate, #yiv9128755192 div.yiv9128755192MsoAcetate
        {margin:0cm;margin-bottom:.0001pt;font-size:9.0pt;font-family:宋体;}
#yiv9128755192 span.yiv9128755192EmailStyle17
        {color:#1F497D;}
#yiv9128755192 span.yiv9128755192Char
        {font-family:宋体;}
#yiv9128755192 .yiv9128755192MsoChpDefault
        {font-size:10.0pt;}
 _filtered #yiv9128755192 {margin:72.0pt 90.0pt 72.0pt 90.0pt;}
#yiv9128755192 div.yiv9128755192WordSection1
        {}
#yiv9128755192 </style><div id="yui_3_16_0_1_1435604059172_2753"><div class="yiv9128755192WordSection1" id="yui_3_16_0_1_1435604059172_2752"><div class="yiv9128755192MsoNormal" id="yui_3_16_0_1_1435604059172_2790"><span lang="EN-US" style="font-size:10.5pt;" id="yui_3_16_0_1_1435604059172_3055">I am doing the same work now.</span></div><div class="yiv9128755192MsoNormal" id="yui_3_16_0_1_1435604059172_3057"><span lang="EN-US" style="font-size:10.5pt;" id="yui_3_16_0_1_1435604059172_3056">I try to buile my own virtual pci device and as Luo said, I must read all the vmmdev related code.</span></div><div class="yiv9128755192MsoNormal" id="yui_3_16_0_1_1435604059172_3061"><span lang="EN-US" style="font-size:10.5pt;" id="yui_3_16_0_1_1435604059172_3062">Could you send me some document or demo on virtual pci device?</span></div><div class="yiv9128755192MsoNormal" id="yui_3_16_0_1_1435604059172_3063"><span lang="EN-US" style="font-size:10.5pt;">  </span></div><div class="qtdSeparateBR"><br><br></div><div class="yiv9128755192yqt3495223949" id="yiv9128755192yqt85441"><div id="yui_3_16_0_1_1435604059172_2751"><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm;" id="yui_3_16_0_1_1435604059172_2750"><div class="yiv9128755192MsoNormal" id="yui_3_16_0_1_1435604059172_2749"><b><span style="font-size:10.0pt;">发件人<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:10.0pt;"> Huihong Luo [mailto:huisinro@yahoo.com] <br clear="none"></span><b><span style="font-size:10.0pt;">发送时间<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:10.0pt;"> 2015</span><span style="font-size:10.0pt;">年<span lang="EN-US">6</span>月<span lang="EN-US">27</span>日<span lang="EN-US"> 14:25<br clear="none"></span><b>收件人<span lang="EN-US">:</span></b><span lang="EN-US"> Klaus Espenlaub; vbox-dev@virtualbox.org<br clear="none"></span><b>主题<span lang="EN-US">:</span></b><span lang="EN-US"> Re: [vbox-dev] How add device or driver (PDM) to VirtualBox</span></span></div></div></div><div class="yiv9128755192MsoNormal"><span lang="EN-US">  </span></div><div><div id="yiv9128755192yui_3_16_0_1_1435385835730_3149"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">I think that most likely the OP wants to develop a virtual PCI device, so the guest and the host can communicate with each other, like some kind of pipe system. The guest and the host can read/write to each other through shared memory.</span></div></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_3150"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">  </span></div></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_3152"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">If this is indeed the case, one can study vbox's builtin guest/host implementation, basically vbox itself uses a virtual PCI device (Devices/VMMDev/VMMDev.cpp), and then inside Linux guest, there is corresponding VBoxGuest.ko kernel module, which is a PCI driver to interact with the virtual device emulated by vbox. This is how vbox's guest additions work.</span></div></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_3152"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">  </span></div></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_3152"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">I have implemented a simple virtual PCI device, like QEMU's pipe. What I can tell you, this is not an easy job, and you have to understand all the concepts, plus a detailed study of vbox source code. </span></div></div><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style="">  </span></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_2829"><div id="yiv9128755192yui_3_16_0_1_1435385835730_2828"><div id="yiv9128755192yui_3_16_0_1_1435385835730_2827"><div align="center" class="yiv9128755192MsoNormal" style="text-align:center;background:white;"><span lang="EN-US" style=""></span><hr align="center" size="1" width="100%"></div><div class="yiv9128755192MsoNormal" style="background:white;"><b><span lang="EN-US" style="font-size:10.0pt;">From:</span></b><span lang="EN-US" style="font-size:10.0pt;"> Klaus Espenlaub <<a rel="nofollow" shape="rect" ymailto="mailto:klaus.espenlaub@oracle.com" target="_blank" href="mailto:klaus.espenlaub@oracle.com">klaus.espenlaub@oracle.com</a>><br clear="none"><b>To:</b> <a rel="nofollow" shape="rect" ymailto="mailto:vbox-dev@virtualbox.org" target="_blank" href="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</a> <br clear="none"><b>Sent:</b> Friday, June 26, 2015 6:22 AM<br clear="none"><b>Subject:</b> Re: [vbox-dev] How add device or driver (PDM) to VirtualBox</span><span lang="EN-US" style=""></span></div></div><div id="yiv9128755192yui_3_16_0_1_1435385835730_2830"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style=""><br clear="none">Marcin,<br clear="none"><br clear="none">On 25.06.2015 10:57, Marcin K wrote:<br clear="none">> Hi,<br clear="none">><br clear="none">> I ask about this before but don't get any answer...<br clear="none"><br clear="none">yes, sorry about that, but right now everyone in the dev team is booked <br clear="none">out with super urgent things which have to be finished before 5.0 is <br clear="none">released. There's simply not enough time right now for bigger explanations.<br clear="none"><br clear="none">><br clear="none">> How add new device/driver to Virtualbox?<br clear="none">> Is there a someone who understand how PDM works?<br clear="none">><br clear="none">> I compile VBoxSampleDevice.cpp and add it to VirtualBox but<br clear="none">> system(ubunutu 14) don't show any new device.<br clear="none">> To add dll to Virtualbox I use:<br clear="none">> VBoxManage setextradata global VBoxInternal/PDM/Devices/[[1]]/Path<br clear="none">> g:\VirtualBox\out\win.amd64\release\obj\testingDevice\VBoxSampleDevice.dll<br clear="none"><br clear="none">VBoxSampleDevice.cpp is a totally empty piece of code. It compiles, it <br clear="none">loads, but doesn't expose ANY functionality to the VM.<br clear="none"><br clear="none">> Also I try to add device using copy of Virtio device. I copy code<br clear="none">> of DevVirtioNet.cpp modify it (change some names), build dll and add to<br clear="none">> VirtualBox:<br clear="none">> VBoxManage setextradata global VBoxInternal/PDM/Devices/[[3]]/Path<br clear="none">> g:\VirtualBox\out\win.amd64\release\obj\testingDevice\testingDevice.dll<br clear="none">><br clear="none">> But still nothing change in guest system.<br clear="none">><br clear="none">> In DevVirtioNet.cpp I found a lot of code which set a lot of parameters<br clear="none">> connected with PCI. I try understand this code but this take, a lot of time.<br clear="none">><br clear="none">> I also found that I have to set which driver will be use in system also<br clear="none">> in configuration of virtual machine.<br clear="none">> I try to set net ethernet cart type but in VBoxManage I found code which<br clear="none">> allow using only build in drivers so I can't set "My" modified Virtio<br clear="none">> driver.<br clear="none">><br clear="none">> There is really no instruction or documentation how it's works?<br clear="none"><br clear="none">There are lots of examples, in the form of the various device <br clear="none">implementations :)<br clear="none"><br clear="none">Klaus</span></div><div><div class="yiv9128755192MsoNormal" style="margin-bottom:12.0pt;background:white;"><span lang="EN-US" style="">  </span></div></div><div id="yiv9128755192yqtfd20522"><div class="yiv9128755192MsoNormal" style="background:white;"><span lang="EN-US" style=""><br clear="none"><br clear="none">> I will be really gratefull for any help or instruction how add new<br clear="none">> device to VirtualBox.<br clear="none">><br clear="none">><br clear="none">> Best regards,<br clear="none">> Marcin<br clear="none"><br clear="none">_______________________________________________<br clear="none">vbox-dev mailing list<br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:vbox-dev@virtualbox.org" target="_blank" href="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="https://www.virtualbox.org/mailman/listinfo/vbox-dev">https://www.virtualbox.org/mailman/listinfo/vbox-dev</a></span></div></div><div class="yiv9128755192MsoNormal" style="margin-bottom:12.0pt;background:white;"><span lang="EN-US" style="">  </span></div></div></div></div></div></div></div></div></div><br><br></div> </div> </div>  </div></body></html>