rawpci.h revision 1fff175c9a0fea173ee52a209224dc6ecbd39572
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** @file
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * PDM - Pluggable Device Manager, raw PCI Devices. (VMM)
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2010-2011 Oracle Corporation
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * available from http://www.virtualbox.org. This file is free software;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * you can redistribute it and/or modify it under the terms of the GNU
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * General Public License (GPL) as published by the Free Software
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * The contents of this file may alternatively be used under the terms
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * of the Common Development and Distribution License Version 1.0
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * VirtualBox OSE distribution, in which case the provisions of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * CDDL are applicable instead of those of the GPL.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * You may elect to license modified versions of this file under the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * terms and conditions of either the GPL or the CDDL or both.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync#ifndef ___VBox_rawpci_h
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync#define ___VBox_rawpci_h
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync#include <iprt/types.h>
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncRT_C_DECLS_BEGIN
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Handle for the raw PCI device.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef RTR0PTR PCIRAWDEVHANDLE;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** Parameters buffer for PCIRAWR0_DO_OPEN_DEVICE call */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef struct
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync{
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /* in */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync uint32_t PciAddress;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync uint32_t fFlags;
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /* out */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWDEVHANDLE Device;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync} PCIRAWREQOPENDEVICE;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** Parameters buffer for PCIRAWR0_DO_CLOSE_DEVICE call */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsynctypedef struct
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync{
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* in */
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync uint32_t fFlags;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync} PCIRAWREQCLOSEDEVICE;
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync/** Parameters buffer for PCIRAWR0_DO_GET_REGION_INFO call */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsynctypedef struct
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync{
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync /* in */
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync int32_t iRegion;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync /* out */
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync RTGCPHYS RegionStart;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync uint64_t u64RegionSize;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync bool fPresent;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync uint32_t fFlags;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync} PCIRAWREQGETREGIONINFO;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync/** Parameters buffer for PCIRAWR0_DO_MAP_REGION call. */
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsynctypedef struct
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync{
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync /* in */
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync RTGCPHYS StartAddress;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync uint64_t iRegionSize;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync int32_t iRegion;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync uint32_t fFlags;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync /* out */
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync RTR3PTR pvAddressR3;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync RTR0PTR pvAddressR0;
3fd65c821ad93f378baf8c75b30dcb6a17a5dd77vboxsync} PCIRAWREQMAPREGION;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync/** Parameters buffer for PCIRAWR0_DO_UNMAP_REGION call. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsynctypedef struct
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync{
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync /* in */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RTGCPHYS StartAddress;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync uint64_t iRegionSize;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RTR3PTR pvAddressR3;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync RTR0PTR pvAddressR0;
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync int32_t iRegion;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync} PCIRAWREQUNMAPREGION;
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync/** Parameters buffer for PCIRAWR0_DO_PIO_WRITE call. */
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsynctypedef struct
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync{
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync /* in */
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync uint16_t iPort;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync uint16_t cb;
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync uint32_t iValue;
5e5603ae40c7a0a884fe91e269b7d6d6c0ba56f5vboxsync} PCIRAWREQPIOWRITE;
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync/** Parameters buffer for PCIRAWR0_DO_PIO_READ call. */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsynctypedef struct
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync{
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync /* in */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync uint16_t iPort;
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync uint16_t cb;
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync /* out */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync uint32_t iValue;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync} PCIRAWREQPIOREAD;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync/** Memory operand. */
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsynctypedef struct
0cde281779e97ead3181bbd3b628451fa2b1efe1vboxsync{
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync union
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync {
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync uint8_t u8;
6a5bc4dc98789eb202e249b189f036e5ff9129ccvboxsync uint16_t u16;
2235e7604f29ce0edc7a1d9aa829668563f86867vboxsync uint32_t u32;
2235e7604f29ce0edc7a1d9aa829668563f86867vboxsync uint64_t u64;
2235e7604f29ce0edc7a1d9aa829668563f86867vboxsync } u;
2235e7604f29ce0edc7a1d9aa829668563f86867vboxsync uint8_t cb;
6a5bc4dc98789eb202e249b189f036e5ff9129ccvboxsync} PCIRAWMEMLOC;
6a5bc4dc98789eb202e249b189f036e5ff9129ccvboxsync
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync/** Parameters buffer for PCIRAWR0_DO_MMIO_WRITE call. */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsynctypedef struct
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync{
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync /* in */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync RTR0PTR Address;
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync PCIRAWMEMLOC Value;
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync} PCIRAWREQMMIOWRITE;
3c1c973ceaac2fdf7f3b0305f57ae30531acb9ccvboxsync
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync/** Parameters buffer for PCIRAWR0_DO_MMIO_READ call. */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsynctypedef struct
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync{
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync /* in */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync RTR0PTR Address;
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync /* inout (Value.cb is in) */
ab7139411cba3600213877c953b69fc11a7ef0cfvboxsync PCIRAWMEMLOC Value;
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync} PCIRAWREQMMIOREAD;
04bce18d27791abed8346aba0de41c53a2acd81avboxsync
04bce18d27791abed8346aba0de41c53a2acd81avboxsync/* Parameters buffer for PCIRAWR0_DO_PCICFG_WRITE call. */
04bce18d27791abed8346aba0de41c53a2acd81avboxsynctypedef struct
04bce18d27791abed8346aba0de41c53a2acd81avboxsync{
04bce18d27791abed8346aba0de41c53a2acd81avboxsync /* in */
04bce18d27791abed8346aba0de41c53a2acd81avboxsync uint32_t iOffset;
6bfca32c67f507f862b751d90d7fa364d3f3844avboxsync PCIRAWMEMLOC Value;
04bce18d27791abed8346aba0de41c53a2acd81avboxsync} PCIRAWREQPCICFGWRITE;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync/** Parameters buffer for PCIRAWR0_DO_PCICFG_READ call. */
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsynctypedef struct
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync{
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync /* in */
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync uint32_t iOffset;
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync /* inout (Value.cb is in) */
2a560b28131ee7efa5b73a9e9cbfdb08eae28624vboxsync PCIRAWMEMLOC Value;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync} PCIRAWREQPCICFGREAD;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync/** Parameters buffer for PCIRAWR0_DO_REGISTER_R0_IRQ_HANDLER call. */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsynctypedef struct
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync{
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync /* in */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync int32_t iGuestIrq;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync RTR0PTR pfnHandler;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync RTR0PTR pfnHandlerContext;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync /* out */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync int32_t iHostIrq;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync} PCIRAWREQREGISTERR0IRQHANDLER;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync/** Parameters buffer for PCIRAWR0_DO_UNREGISTER_R0_IRQ_HANDLER call. */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsynctypedef struct
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync{
04bce18d27791abed8346aba0de41c53a2acd81avboxsync /* in */
04bce18d27791abed8346aba0de41c53a2acd81avboxsync int32_t iHostIrq;
04bce18d27791abed8346aba0de41c53a2acd81avboxsync} PCIRAWREQUNREGISTERR0IRQHANDLER;
04bce18d27791abed8346aba0de41c53a2acd81avboxsync
04bce18d27791abed8346aba0de41c53a2acd81avboxsync/**
04bce18d27791abed8346aba0de41c53a2acd81avboxsync * Request buffer use for communication with the driver.
04bce18d27791abed8346aba0de41c53a2acd81avboxsync */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsynctypedef struct PCIRAWSENDREQ
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync{
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync /** The request header. */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync SUPVMMR0REQHDR Hdr;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync /** Alternative to passing the taking the session from the VM handle.
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync * Either use this member or use the VM handle, don't do both.
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync */
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync PSUPDRVSESSION pSession;
e3e8bde164b5715114ebf596187b5512fa9b75advboxsync /** Request type. */
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync int32_t iRequest;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync /** Host device request targetted to. */
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWDEVHANDLE TargetDevice;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync /** Call parameters. */
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync union
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync {
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQOPENDEVICE aOpenDevice;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQCLOSEDEVICE aCloseDevice;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWREQGETREGIONINFO aGetRegionInfo;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWREQMAPREGION aMapRegion;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWREQUNMAPREGION aUnmapRegion;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWREQPIOWRITE aPioWrite;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQPIOREAD aPioRead;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync PCIRAWREQMMIOWRITE aMmioWrite;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQMMIOREAD aMmioRead;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQPCICFGWRITE aPciCfgWrite;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQPCICFGREAD aPciCfgRead;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQREGISTERR0IRQHANDLER aRegisterR0IrqHandler;
5a7d67754026bd3654a2464799f0db1790ecf183vboxsync PCIRAWREQUNREGISTERR0IRQHANDLER aUnregisterR0IrqHandler;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync } u;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsync} PCIRAWSENDREQ;
1df297ea8319f3f3afddb73e6ea2fd9c7f0e5eb4vboxsynctypedef PCIRAWSENDREQ *PPCIRAWSENDREQ;
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync/**
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync * Operations performed by the driver.
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync */
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsynctypedef enum PCIRAWR0OPERATION
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync{
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync /* Open device. */
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync PCIRAWR0_DO_OPEN_DEVICE,
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync /* Close device. */
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync PCIRAWR0_DO_CLOSE_DEVICE,
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync /* Get PCI region info. */
c00fd08041e14ed8ad7733165f855bfbbc818a0evboxsync PCIRAWR0_DO_GET_REGION_INFO,
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /* Map PCI region into VM address space. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWR0_DO_MAP_REGION,
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /* Unmap PCI region from VM address space. */
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync PCIRAWR0_DO_UNMAP_REGION,
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync /* Perform PIO write. */
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync PCIRAWR0_DO_PIO_WRITE,
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync /* Perform PIO read. */
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync PCIRAWR0_DO_PIO_READ,
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync /* Perform MMIO write. */
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync PCIRAWR0_DO_MMIO_WRITE,
d9658602103599d13b5449fc1ea49d765a23e6f1vboxsync /* Perform MMIO read. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWR0_DO_MMIO_READ,
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /* Perform PCI config write. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWR0_DO_PCICFG_WRITE,
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /* Perform PCI config read. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWR0_DO_PCICFG_READ,
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /* Register device IRQ R0 handler. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync PCIRAWR0_DO_REGISTER_R0_IRQ_HANDLER,
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /* Unregister device IRQ R0 handler. */
e0dec59adb362e8486c0622785420ad10e720972vboxsync PCIRAWR0_DO_UNREGISTER_R0_IRQ_HANDLER,
e0dec59adb362e8486c0622785420ad10e720972vboxsync /** The usual 32-bit type blow up. */
e0dec59adb362e8486c0622785420ad10e720972vboxsync PCIRAWR0_DO_32BIT_HACK = 0x7fffffff
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync} PCIRAWR0OPERATION;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** Forward declarations. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsynctypedef struct RAWPCIFACTORY *PRAWPCIFACTORY;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef struct RAWPCIDEVPORT *PRAWPCIDEVPORT;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/**
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * Interrupt service routine callback.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * @param pvContext Opaque user data which to the handler.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * @param iIrq Interrupt number.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef DECLCALLBACK(void) FNRAWPCIISR(void *pvContext, int32_t iIrq);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef FNRAWPCIISR *PFNRAWPCIISR;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
e0dec59adb362e8486c0622785420ad10e720972vboxsync/**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * This is the port on the device interface, i.e. the driver side which the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * host device is connected to.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * This is only used for the in-kernel PCI device connections.
fa86ccda70bc5dd1ae28597340f252b212dcf36dvboxsync */
fa86ccda70bc5dd1ae28597340f252b212dcf36dvboxsynctypedef struct RAWPCIDEVPORT
fa86ccda70bc5dd1ae28597340f252b212dcf36dvboxsync{
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Structure version number. (RAWPCIDEVPORT_VERSION) */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync uint32_t u32Version;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Retain the object.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync *
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * It will normally be called while owning the internal semaphore.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param pPort Pointer to this structure.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync DECLR0CALLBACKMEMBER(void, pfnRetain,(PRAWPCIDEVPORT pPort));
e0dec59adb362e8486c0622785420ad10e720972vboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Releases the object.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * This must be called for every pfnRetain call.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param pPort Pointer to this structure.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync DECLR0CALLBACKMEMBER(void, pfnRelease,(PRAWPCIDEVPORT pPort));
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Init device.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync *
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * @param pPort Pointer to this structure.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param fFlags Initialization flags.
e0dec59adb362e8486c0622785420ad10e720972vboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync DECLR0CALLBACKMEMBER(int, pfnInit,(PRAWPCIDEVPORT pPort,
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync uint32_t fFlags));
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync /**
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync * Deinit device.
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync *
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync * @param pPort Pointer to this structure.
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync * @param fFlags Initialization flags.
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync */
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync DECLR0CALLBACKMEMBER(int, pfnDeinit,(PRAWPCIDEVPORT pPort,
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync uint32_t fFlags));
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync /**
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync * Get PCI region info.
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync *
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync * @param pPort Pointer to this structure.
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync */
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync DECLR0CALLBACKMEMBER(int, pfnGetRegionInfo,(PRAWPCIDEVPORT pPort,
1d8f69ceb39fecbf9a7c95dbac083f3ce5c4efd9vboxsync int32_t iRegion,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync RTHCPHYS *pRegionStart,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint64_t *pu64RegionSize,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync bool *pfPresent,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint32_t *pfFlags));
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync /**
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * Map PCI region.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync *
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pPort Pointer to this structure.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync */
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync DECLR0CALLBACKMEMBER(int, pfnMapRegion,(PRAWPCIDEVPORT pPort,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync int32_t iRegion,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync RTHCPHYS RegionStart,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint64_t u64RegionSize,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync int32_t fFlags,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync RTR0PTR *pRegionBaseR0));
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync /**
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * Unmap PCI region.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync *
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pPort Pointer to this structure.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync */
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync DECLR0CALLBACKMEMBER(int, pfnUnmapRegion,(PRAWPCIDEVPORT pPort,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync int32_t iRegion,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync RTHCPHYS RegionStart,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint64_t u64RegionSize,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync RTR0PTR RegionBase));
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync /**
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * Read device PCI register.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync *
34bfec0bd844700e3b769dcfad1a869ca6b8a0d8vboxsync * @param pPort Pointer to this structure.
34bfec0bd844700e3b769dcfad1a869ca6b8a0d8vboxsync * @param fFlags Initialization flags.
34bfec0bd844700e3b769dcfad1a869ca6b8a0d8vboxsync */
34bfec0bd844700e3b769dcfad1a869ca6b8a0d8vboxsync DECLR0CALLBACKMEMBER(int, pfnPciCfgRead,(PRAWPCIDEVPORT pPort,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint32_t Register,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync PCIRAWMEMLOC *pValue));
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync /**
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * Write device PCI register.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync *
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pPort Pointer to this structure.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param fFlags Initialization flags.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync */
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync DECLR0CALLBACKMEMBER(int, pfnPciCfgWrite,(PRAWPCIDEVPORT pPort,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync uint32_t Register,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync PCIRAWMEMLOC *pValue));
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync /**
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * Request to register interrupt handler.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync *
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pPort Pointer to this structure.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pfnHandler Pointer to the handler.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param pIrqContext Context passed to the handler.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync * @param piHostIrq Which host IRQ is used.
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync */
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync DECLR0CALLBACKMEMBER(int, pfnRegisterIrqHandler,(PRAWPCIDEVPORT pPort,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync PFNRAWPCIISR pfnHandler,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync void* pIrqContext,
0aaf889969ebdaba8a310db13adcec8c10174796vboxsync int32_t *piHostIrq));
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /**
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Request to unregister interrupt handler.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync *
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsync * @param pPort Pointer to this structure.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param iHostIrq Which host IRQ was used (retured by earlier pfnRegisterIrqHandler).
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync DECLR0CALLBACKMEMBER(int, pfnUnregisterIrqHandler,(PRAWPCIDEVPORT pPort,
int32_t iHostIrq));
/** Structure version number. (RAWPCIDEVPORT_VERSION) */
uint32_t u32VersionEnd;
} RAWPCIDEVPORT;
/** Version number for the RAWPCIDEVPORT::u32Version and RAWPCIIFPORT::u32VersionEnd fields. */
#define RAWPCIDEVPORT_VERSION UINT32_C(0xAFBDCC01)
/**
* 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.
*/
DECLR0CALLBACKMEMBER(void, pfnRelease,(PRAWPCIFACTORY pFactory));
/**
* 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.
*
*/
DECLR0CALLBACKMEMBER(int, pfnCreateAndConnect,(PRAWPCIFACTORY pFactory,
uint32_t u32HostAddress,
uint32_t fFlags,
PRAWPCIDEVPORT *ppDevPort));
} RAWPCIFACTORY;
#define RAWPCIFACTORY_UUID_STR "c0268f49-e1e4-402b-b7e0-eb8d09659a9b"
/**
* 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
} PCIRAWDRIVERFLAGS;
/**
* 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. */
PCIRAW_ADDRESS_SPACE_MEM_PREFETCH = 0x08,
/** The usual 32-bit type blow up. */
PCIRAW_ADDRESS_SPACE_32BIT_HACK = 0x7fffffff
} PCIRAWADDRESSSPACE;
RT_C_DECLS_END
#endif