<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:#002060;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#002060">Hi Experts,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">I am working on a virtual device model that plugs in to PDM.  The model actually includes a PCI switch and one or more downstream end points of potentially different types.  These end points use MSI for interrupts,
 so I am using the ICH9 chipset.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">Basic initialization goes OK.  I register the device as a PCI switch, VBox enumerates on the downsteam bus, and finds my end point (just one for now, I will add more after I get the first one working).  MSI initialization
 looks good, the config word in the MSI struct is read as 0x80 and then set to 0x81 (64-bit addressing, no per-vector masking, MSI enabled).  The BIOS and Guest are able to read/write to the MMIO space of the end point.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">My problem is when the end point tries to generate an interrupt.  I see the upstream write indicating MSI, and call PDMDevHlpPCISetIrq () to signal the interrupt instead of passing the write up stream.  However,
 I only have one PPDMDEVINS pDevIns handle, which had been passed to my constructor, and that corresponds to the switch itself.  So when I get down to ich9pciSetIrqInternal(), it’s looking at the MSI struct of the switch when it really needs to be looking at
 the MSI struct of the end point.  And when there are more than one EP, it has to be the correct one.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">Presumably I need to have separate device instances for the switch and each downstream end point, so that when I signal an interrupt it knows which end point it’s coming from.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">My question, then, is how can I allocate additional device handles?  The only way I know how to allocate a device handle is through the CFGM database, with Devices/xyz/0 entries.  But that requires knowing what
 end points there are in advance, and taking steps to configure CFGM accordingly.  What I really want to do is notice when the bus enumeration finds an end point, and allocate a device instance for it dynamically.  Is there a way to do this?  Or some other
 way to associate an interrupt request with its source?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">BTW, I am using OSE 5.0.16 which I built from the tarball on the virtualbox.org site, running on Ubuntu 14 host with Ubuntu 14 guest (both 64 bits).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#002060">_____________________________________________<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="color:#002060">Ric Vilbig</span></b><span style="color:#002060"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060">Mentor Graphics, Emulation Division</span><span style="font-size:10.0pt;color:#002060"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060">46871 Bayside Parkway, Fremont CA, 94538<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060">Phone:  510-354-7360<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060">Mobile: 408-529-2365<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060">email:  <a href="mailto:ric_vilbig@mentor.com">
<span style="color:blue">ric_vilbig@mentor.com</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>