MsiCommon.cpp revision e792133826a035b6af26ba1577d38bf259680d2a
/* $Id$ */
/** @file
* MSI support routines
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define LOG_GROUP LOG_GROUP_DEV_PCI
/* Hack to get PCIDEVICEINT declare at the right point - include "PCIInternal.h". */
#define PCI_INCLUDE_PRIVATE
#include "MsiCommon.h"
/** @todo: use accessors so that raw PCI devices work correctly with MSI. */
{
}
{
return pciDevIsMsi64Capable(pDev);
}
{
}
{
}
{
}
{
}
{
if (msiIs64Bit(pDev))
{
}
else
{
}
}
{
// vector encoding into lower bits of message data
return RT_MAKE_U32(lo, 0);
}
{
}
{
}
#ifdef IN_RING3
void MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, uint32_t u32Address, uint32_t val, unsigned len)
{
{
switch (reg)
{
case 0: /* Capability ID, ro */
case 1: /* Next pointer, ro */
break;
/* don't change read-only bits: 1-3,7 */
break;
case VBOX_MSI_CAP_MESSAGE_CONTROL + 1:
/* don't change read-only bit 8, and reserved 9-15 */
break;
default:
{
/* If we're enabling masked vector, and have pending messages
for this vector, we have to send this message now */
if ( !f64Bit
&& (reg >= VBOX_MSI_CAP_MASK_BITS_32)
)
{
}
if ( f64Bit
&& (reg >= VBOX_MSI_CAP_MASK_BITS_64)
)
{
}
{
{
{
/* To ensure that we're no longer masked */
{
}
}
{
}
}
}
}
}
uAddr++;
val >>= 8;
}
}
{
switch (len)
{
case 1:
break;
case 2:
break;
case 4:
break;
default:
Assert(false);
}
return rv;
}
{
if (pMsiReg->cMsiVectors == 0)
return VINF_SUCCESS;
/* We cannot init MSI on raw devices yet. */
int iMmc;
/* Compute multiple-message capable bitfield */
{
break;
}
return VERR_TOO_MUCH_DATA;
/* We always support per-vector masking */
if (f64bit)
/* How many vectors we're capable of */
*msiGetMaskBits(pDev) = 0;
*msiGetPendingBits(pDev) = 0;
return VINF_SUCCESS;
}
#endif /* IN_RING3 */
{
}
{
/* We only trigger MSI on level up */
if ((iLevel & PDM_IRQ_LEVEL_HIGH) == 0)
{
/* @todo: maybe clear pending interrupts on level down? */
#if 0
#endif
return;
}
{
return;
}
}