VBoxPciInternal.h revision f73c68fe41a3db55167b7266efd6955e5dbd0b47
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync/* $Id$ */
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync/** @file
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * VBoxPci - PCI driver (Host), Internal Header.
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync */
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync/*
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * Copyright (C) 2011 Oracle Corporation
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync *
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * available from http://www.virtualbox.org. This file is free software;
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * General Public License (GPL) as published by the Free Software
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync */
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#ifndef ___VBoPciInternal_h___
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#define ___VBoxPciInternal_h___
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#include <VBox/sup.h>
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#include <VBox/rawpci.h>
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#include <iprt/semaphore.h>
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync#include <iprt/assert.h>
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsyncRT_C_DECLS_BEGIN
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync/* Forward declaration. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsynctypedef struct VBOXRAWPCIGLOBALS *PVBOXRAWPCIGLOBALS;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsynctypedef struct VBOXRAWPCIINS *PVBOXRAWPCIINS;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync/**
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * The per-instance data of the VBox raw PCI interface.
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync *
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * This is data associated with a host PCI card which
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * the filter driver has been or may be attached to. When possible it is
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * attached dynamically, but this may not be possible on all OSes so we have
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * to be flexible about things.
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync *
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsynctypedef struct VBOXRAWPCIINS
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync{
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Pointer to the globals. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync PVBOXRAWPCIGLOBALS pGlobals;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** The spinlock protecting the state variables and host interface handle. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync RTSPINLOCK hSpinlock;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Pointer to the next device in the list. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync PVBOXRAWPCIINS pNext;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Reference count. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync uint32_t volatile cRefs;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /* Host PCI address of this device. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync uint32_t HostPciAddress;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Port, given to the outside world. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync RAWPCIDEVPORT DevPort;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync} VBOXRAWPCIINS;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync/**
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * The global data of the VBox PCI driver.
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync *
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * This contains the bit required for communicating with support driver, VBoxDrv
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * (start out as SupDrv).
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsynctypedef struct VBOXRAWPCIGLOBALS
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync{
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Mutex protecting the list of instances and state changes. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync RTSEMFASTMUTEX hFastMtx;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Pointer to a list of instance data. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync PVBOXRAWPCIINS pInstanceHead;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** The raw PCI interface factory. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync RAWPCIFACTORY RawPciFactory;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** The SUPDRV component factory registration. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync SUPDRVFACTORY SupDrvFactory;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** The number of current factory references. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync int32_t volatile cFactoryRefs;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** Whether the IDC connection is open or not.
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync * This is only for cleaning up correctly after the separate IDC init on Windows. */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync bool fIDCOpen;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync /** The SUPDRV IDC handle (opaque struct). */
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync SUPDRVIDCHANDLE SupDrvIDC;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync} VBOXRAWPCIGLOBALS;
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsyncDECLHIDDEN(int) vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsyncDECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsyncRT_C_DECLS_END
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync
f73c68fe41a3db55167b7266efd6955e5dbd0b47vboxsync#endif