4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/** @file
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * PDM - Pluggable Device Manager, raw PCI Devices. (VMM)
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/*
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Copyright (C) 2010-2011 Oracle Corporation
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * available from http://www.virtualbox.org. This file is free software;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * you can redistribute it and/or modify it under the terms of the GNU
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * General Public License (GPL) as published by the Free Software
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * The contents of this file may alternatively be used under the terms
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * of the Common Development and Distribution License Version 1.0
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * VirtualBox OSE distribution, in which case the provisions of the
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * CDDL are applicable instead of those of the GPL.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * You may elect to license modified versions of this file under the
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * terms and conditions of either the GPL or the CDDL or both.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#ifndef ___VBox_vmm_pdmpci_h
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#define ___VBox_vmm_pdmpci_h
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#include <VBox/types.h>
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#include <VBox/rawpci.h>
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncRT_C_DECLS_BEGIN
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/** @defgroup grp_pdm_pcidev The raw PCI Devices API
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @ingroup grp_pdm
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @{
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsynctypedef struct PDMIPCIRAW *PPDMIPCIRAW;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsynctypedef struct PDMIPCIRAW
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync{
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify virtual device that interrupt has arrived.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * For this callback to be called, interface have to be
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * registered with PDMIPCIRAWUP::pfnRegisterInterruptListener.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @note no level parameter, as we can only support flip-flop.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iGuestIrq Guest interrupt number, passed earlier when registering listener.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnInterruptRequest ,(PPDMIPCIRAW pInterface, int32_t iGuestIrq));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync} PDMIPCIRAW;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsynctypedef struct PDMIPCIRAWUP *PPDMIPCIRAWUP;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsynctypedef struct PDMIPCIRAWUP
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync{
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Host PCI MMIO access function.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request driver info about PCI region on host PCI device.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns true, if region is present, and out parameters are correct
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iRegion Region number.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pRegStart Where to store region base address (guest).
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param piRegSize Where to store region size.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param fMmio If region is MMIO or IO.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(bool, pfnGetRegionInfo, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync int32_t iRegion,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTGCPHYS *pRegStart,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint64_t *piRegSize,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t *pfFlags
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request driver to map part of host device's MMIO region to the VM process and maybe kernel.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Shall only be issued within earlier obtained with pfnGetRegionInfo()
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * host physical address ranges for the device BARs. Even if failed, device still may function
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * using pfnMmio* and pfnPio* operations, just much slower.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iRegion Number of the region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param StartAddress Host physical address of start.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iRegionSize Size of the region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param fFlags Flags, currently lowest significant bit set if R0 mapping requested too
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param ppvAddressR3 Where to store mapped region address for R3 (can be 0, if cannot map into userland)
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param ppvAddressR0 Where to store mapped region address for R0 (can be 0, if cannot map into kernel)
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnMapRegion, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync int32_t iRegion,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTHCPHYS StartAddress,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint64_t iRegionSize,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t fFlags,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR3PTR *ppvAddressR3,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR0PTR *ppvAddressR0
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request driver to unmap part of host device's MMIO region to the VM process.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Shall only be issued with pointer earlier obtained with pfnMapRegion().
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iRegion Number of the region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param StartAddress Host physical address of start.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iRegionSize Size of the region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pvAddressR3 R3 address of mapped region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pvAddressR0 R0 address of mapped region.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnUnmapRegion, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync int iRegion,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTHCPHYS StartAddress,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint64_t iRegionSize,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR3PTR pvAddressR3,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR0PTR pvAddressR0
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request port IO write.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iPort IO port.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iValue Value to write.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPioWrite, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint16_t iPort,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t iValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request port IO read.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iPort IO port.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param piValue Place to store read value.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPioRead, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint16_t iPort,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t *piValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request MMIO write. This callback is only called if driver wants to receive MMIO via
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * pu32Flags argument of pfnPciDeviceConstructStart().
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param Address Guest physical address.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pValue Address of value to write.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnMmioWrite, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR0PTR Address,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync void const *pValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request MMIO read.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param Address Guest physical address.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pValue Place to store read value.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnMmioRead, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync RTR0PTR Address,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync void *pValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Host PCI config space accessors.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request driver to write value to host device's PCI config space.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Host specific way (PIO or MCFG) is used to perform actual operation.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iOffset Offset in PCI config space.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iValue Value to write.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPciCfgWrite, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t iOffset,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync void* pValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request driver to read value from host device's PCI config space.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Host specific way (PIO or MCFG) is used to perform actual operation.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iOffset Offset in PCI config space.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pValue Where to store read value.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param cb Access width.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread EMT thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPciCfgRead, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t iOffset,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync void *pValue,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync unsigned cb ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request to enable interrupt notifications. Please note that this is purely
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * R3 interface, so it's up to implementor to perform necessary machinery
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * for communications with host OS kernel driver. Typical implementation will start
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * userland thread waiting on shared semaphore (such as using SUPSEMEVENT),
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * notified by the kernel interrupt handler, and then will call
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * upper port pfnInterruptRequest() based on data provided by the driver.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * This apporach is taken, as calling VBox code from an asyncronous R0
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * interrupt handler when VMM may not be even running doesn't look
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * like a good idea.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pListener Pointer to the listener object.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iGuestIrq Guest IRQ to be passed to pfnInterruptRequest().
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread, pfnInterruptRequest() will be usually invoked on a dedicated thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnEnableInterruptNotifications, (PPDMIPCIRAWUP pInterface, int32_t iGuestIrq
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Request to disable interrupt notifications.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnDisableInterruptNotifications, (PPDMIPCIRAWUP pInterface
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync ));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notification APIs.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify driver when raw PCI device construction starts. Have to be the first operation
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * as initializes internal state and opens host device driver.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @returns status code
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iHostAddress Host PCI address of device attached.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param iGuestAddress Guest PCI address of device attached.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param szDeviceName Human readable device name.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param fDeviceFlags Flags for the host device.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pu32Flags Flags for virtual device, from the upper driver.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPciDeviceConstructStart, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t iHostAddress,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t iGuestAddress,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync const char* szDeviceName,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t fDeviceFlags,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t *pu32Flags));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify driver when raw PCI device construction completes, so that it may
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * perform further actions depending on success or failure of this operation.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Standard action is to raise global IHostPciDevicePlugEvent.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param rc Result code of the operation.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(void, pfnPciDeviceConstructComplete, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync int rc));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify driver on finalization of raw PCI device.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPciDeviceDestruct, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint32_t fFlags));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify driver on guest power state change.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param aState New power state.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pu64Param State-specific in/out parameter. For now only used during power-on to provide VM caps.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnPciDevicePowerStateChange, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWPOWERSTATE aState,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint64_t *pu64Param));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Notify driver about runtime error.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param pInterface Pointer to this interface structure.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param fFatal If error is fatal.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param szErrorId Error ID.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @param szMessage Error message.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync *
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * @thread Any thread.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync DECLR3CALLBACKMEMBER(int, pfnReportRuntimeError, (PPDMIPCIRAWUP pInterface,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync uint8_t fFatal,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync const char* szErrorId,
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync const char* szMessage));
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync} PDMIPCIRAWUP;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Init R0 PCI module.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncPCIRAWR0DECL(int) PciRawR0Init(void);
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Process request (in R0).
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncPCIRAWR0DECL(int) PciRawR0ProcessReq(PSUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq);
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Terminate R0 PCI module.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncPCIRAWR0DECL(void) PciRawR0Term(void);
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Per-VM R0 module init.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncPCIRAWR0DECL(int) PciRawR0InitVM(PVM pVM);
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Per-VM R0 module termination routine.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncPCIRAWR0DECL(void) PciRawR0TermVM(PVM pVM);
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/**
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * Flags returned by pfnPciDeviceConstructStart(), to notify device
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync * how it shall handle device IO traffic.
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsynctypedef enum PCIRAWDEVICEFLAGS
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync{
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /** Intercept port IO (R3 PIO always go to the driver). */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWRFLAG_CAPTURE_PIO = (1 << 0),
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /** Intercept MMIO. */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWRFLAG_CAPTURE_MMIO = (1 << 1),
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /** Allow bus mastering by physical device (requires IOMMU). */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWRFLAG_ALLOW_BM = (1 << 2),
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /** Allow R3 MMIO mapping. */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWRFLAG_ALLOW_R3MAP = (1 << 3),
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync /** The usual 32-bit type blow up. */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync PCIRAWRFLAG_32BIT_HACK = 0x7fffffff
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync} PCIRAWDEVICEFLAGS;
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#define PDMIPCIRAWUP_IID "06daa17f-097b-4ebe-a626-15f467b1de12"
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#define PDMIPCIRAW_IID "68c6e4c4-4223-47e0-9134-e3c297992543"
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync/** @} */
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsyncRT_C_DECLS_END
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync
4ada10ecfeb543208799e4bdc71ab184d8f6faa5vboxsync#endif