rawpci.h revision 236251994d572b829ce98ce0c2cdeb5c571cfd11
/** @file
* PDM - Pluggable Device Manager, raw PCI Devices. (VMM)
*/
/*
* Copyright (C) 2010-2011 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_rawpci_h
#define ___VBox_rawpci_h
/**
* Handle for the raw PCI device.
*/
typedef uint32_t PCIRAWDEVHANDLE;
/** Data being part of the VM structure. */
typedef struct RAWPCIVM
{
/* Shall only be interpreted by the host PCI driver. */
} RAWPCIVM;
/** Parameters buffer for PCIRAWR0_DO_OPEN_DEVICE call */
typedef struct
{
/* in */
/* out */
/** Parameters buffer for PCIRAWR0_DO_CLOSE_DEVICE call */
typedef struct
{
/* in */
/** Parameters buffer for PCIRAWR0_DO_GET_REGION_INFO call */
typedef struct
{
/* in */
/* out */
bool fPresent;
/** Parameters buffer for PCIRAWR0_DO_MAP_REGION call. */
typedef struct
{
/* in */
/* out */
/** Parameters buffer for PCIRAWR0_DO_UNMAP_REGION call. */
typedef struct
{
/* in */
/** Parameters buffer for PCIRAWR0_DO_PIO_WRITE call. */
typedef struct
{
/* in */
/** Parameters buffer for PCIRAWR0_DO_PIO_READ call. */
typedef struct
{
/* in */
/* out */
/** Memory operand. */
typedef struct
{
union
{
} u;
} PCIRAWMEMLOC;
/** Parameters buffer for PCIRAWR0_DO_MMIO_WRITE call. */
typedef struct
{
/* in */
/** Parameters buffer for PCIRAWR0_DO_MMIO_READ call. */
typedef struct
{
/* in */
/* inout (Value.cb is in) */
/* Parameters buffer for PCIRAWR0_DO_PCICFG_WRITE call. */
typedef struct
{
/* in */
/** Parameters buffer for PCIRAWR0_DO_PCICFG_READ call. */
typedef struct
{
/* in */
/* inout (Value.cb is in) */
/** Parameters buffer for PCIRAWR0_DO_REGISTER_R0_IRQ_HANDLER call. */
typedef struct
{
/* in */
/* out */
/** Parameters buffer for PCIRAWR0_DO_UNREGISTER_R0_IRQ_HANDLER call. */
typedef struct
{
/* in */
/**
* Request buffer use for communication with the driver.
*/
typedef struct PCIRAWSENDREQ
{
/** The request header. */
/** Alternative to passing the taking the session from the VM handle.
* Either use this member or use the VM handle, don't do both.
*/
/** Request type. */
/** Host device request targetted to. */
/** Call parameters. */
union
{
} u;
typedef PCIRAWSENDREQ *PPCIRAWSENDREQ;
/**
* Operations performed by the driver.
*/
typedef enum PCIRAWR0OPERATION
{
/* Open device. */
/* Close device. */
/* Get PCI region info. */
/* Map PCI region into VM address space. */
/* Unmap PCI region from VM address space. */
/* Perform PIO write. */
/* Perform PIO read. */
/* Perform MMIO write. */
/* Perform MMIO read. */
/* Perform PCI config write. */
/* Perform PCI config read. */
/* Register device IRQ R0 handler. */
/* Unregister device IRQ R0 handler. */
/** The usual 32-bit type blow up. */
PCIRAWR0_DO_32BIT_HACK = 0x7fffffff
/** Forward declarations. */
typedef struct RAWPCIFACTORY *PRAWPCIFACTORY;
typedef struct RAWPCIDEVPORT *PRAWPCIDEVPORT;
/**
* Interrupt service routine callback.
*
* @param pvContext Opaque user data which to the handler.
* @param iIrq Interrupt number.
*/
typedef FNRAWPCIISR *PFNRAWPCIISR;
/**
* This is the port on the device interface, i.e. the driver side which the
* host device is connected to.
*
* This is only used for the in-kernel PCI device connections.
*/
typedef struct RAWPCIDEVPORT
{
/** Structure version number. (RAWPCIDEVPORT_VERSION) */
/**
* Init device.
*
* @param pPort Pointer to this structure.
* @param fFlags Initialization flags.
*/
/**
* Deinit device.
*
* @param pPort Pointer to this structure.
* @param fFlags Initialization flags.
*/
/**
* Destroy device.
*
* @param pPort Pointer to this structure.
*/
/**
* Get PCI region info.
*
* @param pPort Pointer to this structure.
*/
bool *pfPresent,
/**
* Map PCI region.
*
* @param pPort Pointer to this structure.
*/
RTR0PTR *pRegionBaseR0));
/**
* Unmap PCI region.
*
* @param pPort Pointer to this structure.
*/
/**
* Read device PCI register.
*
* @param pPort Pointer to this structure.
* @param fFlags Initialization flags.
*/
PCIRAWMEMLOC *pValue));
/**
* Write device PCI register.
*
* @param pPort Pointer to this structure.
* @param fFlags Initialization flags.
*/
PCIRAWMEMLOC *pValue));
/**
* Request to register interrupt handler.
*
* @param pPort Pointer to this structure.
* @param pfnHandler Pointer to the handler.
* @param pIrqContext Context passed to the handler.
* @param piHostIrq Which host IRQ is used.
*/
void* pIrqContext,
/**
* Request to unregister interrupt handler.
*
* @param pPort Pointer to this structure.
* @param iHostIrq Which host IRQ was used (retured by earlier pfnRegisterIrqHandler).
*/
/** Structure version number. (RAWPCIDEVPORT_VERSION) */
/** Version number for the RAWPCIDEVPORT::u32Version and RAWPCIIFPORT::u32VersionEnd fields. */
/**
* The component factory interface for create a raw PCI interfaces.
*/
typedef struct RAWPCIFACTORY
{
/**
* Release this factory.
*
* SUPR0ComponentQueryFactory (SUPDRVFACTORY::pfnQueryFactoryInterface to be precise)
* will retain a reference to the factory and the caller has to call this method to
* release it once the pfnCreateAndConnect call(s) has been done.
*
* @param pIfFactory Pointer to this structure.
*/
/**
* Create an instance for the specfied host PCI card and connects it
* to the driver.
*
*
* @returns VBox status code.
*
* @param pIfFactory Pointer to this structure.
* @param u32HostAddress Address of PCI device on the host.
* @param fFlags Creation flags.
* @param ppDevPort Where to store the pointer to the device port
* on success.
*
*/
/**
* Initialize per-VM data related to PCI passthrough.
*
* @returns VBox status code.
*
* @param pIfFactory Pointer to this structure.
* @param pVM Pointer to VM structure to initialize.
* @param pPciData Pointer to PCI data.
*/
/**
* Deinitialize per-VM data related to PCI passthrough.
*
* @returns VBox status code.
*
* @param pIfFactory Pointer to this structure.
* @param pVM Pointer to VM structure to deinitialize.
* @param pPciData Pointer to PCI data.
*/
#define RAWPCIFACTORY_UUID_STR "0382086d-d37c-48e8-9749-c3bee355acf6"
/**
* Flags passed to pfnPciDeviceConstructStart(), to notify driver
* about options to be used to open device.
*/
typedef enum PCIRAWDRIVERFLAGS
{
/** If runtime shall try to detach host driver. */
PCIRAWDRIVERRFLAG_DETACH_HOST_DRIVER = (1 << 0),
/** The usual 32-bit type blow up. */
PCIRAWDRIVERRFLAG_32BIT_HACK = 0x7fffffff
/**
* Flags used to describe PCI region, matches to PCIADDRESSSPACE
* in pci.h.
*/
typedef enum PCIRAWADDRESSSPACE
{
/** Memory. */
PCIRAW_ADDRESS_SPACE_MEM = 0x00,
/** I/O space. */
PCIRAW_ADDRESS_SPACE_IO = 0x01,
/** 32-bit BAR. */
PCIRAW_ADDRESS_SPACE_BAR32 = 0x00,
/** 64-bit BAR. */
PCIRAW_ADDRESS_SPACE_BAR64 = 0x04,
/** Prefetch memory. */
/** The usual 32-bit type blow up. */
PCIRAW_ADDRESS_SPACE_32BIT_HACK = 0x7fffffff
#endif