pci.h revision 5c85b3c44a1183799f6cd41665aed33310dfa26b
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @file
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * PCI - The PCI Controller And Devices.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/*
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync *
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * available from http://www.virtualbox.org. This file is free software;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * General Public License as published by the Free Software Foundation,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync *
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * If you received this file as part of a commercial VirtualBox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * distribution, then only the terms of your commercial VirtualBox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * license agreement apply instead of the previous paragraph.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#ifndef __VBox_pci_h__
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define __VBox_pci_h__
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#include <VBox/cdefs.h>
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#include <VBox/types.h>
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @defgroup grp_pci PCI - The PCI Controller.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @{
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a PCI device. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef struct PCIDevice *PPCIDEVICE;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * PCI configuration word 4 (command) and word 6 (status).
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef enum PCICONFIGCOMMAND
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync{
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Supports/uses memory accesses. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_COMMAND_IOACCESS = 0x0001,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_COMMAND_MEMACCESS = 0x0002,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_COMMAND_BUSMASTER = 0x0004
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync} PCICONFIGCOMMAND;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * PCI Address space specification.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This is used when registering a I/O region.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef enum PCIADDRESSSPACE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync{
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Memory. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_ADDRESS_SPACE_MEM = 0x00,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** I/O space. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_ADDRESS_SPACE_IO = 0x01,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Prefetch memory. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCI_ADDRESS_SPACE_MEM_PREFETCH = 0x08
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync} PCIADDRESSSPACE;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Callback function for mapping an PCI I/O region.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync *
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @return VBox status code.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param iRegion The region number.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * I/O port, else it's a physical address.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This address is *NOT* relative to pci_mem_base like earlier!
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param enmType One of the PCI_ADDRESS_SPACE_* values.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef DECLCALLBACK(int) FNPCIIOREGIONMAP(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType);
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a FNPCIIOREGIONMAP() function. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef FNPCIIOREGIONMAP *PFNPCIIOREGIONMAP;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Callback function for reading from the PCI configuration space.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync *
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @returns The register value.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param Address The configuration space register address. [0..255]
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param cb The register size. [1,2,4]
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef DECLCALLBACK(uint32_t) FNPCICONFIGREAD(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb);
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a FNPCICONFIGREAD() function. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef FNPCICONFIGREAD *PFNPCICONFIGREAD;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a PFNPCICONFIGREAD. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef PFNPCICONFIGREAD *PPFNPCICONFIGREAD;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Callback function for writing to the PCI configuration space.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync *
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param Address The configuration space register address. [0..255]
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param u32Value The value that's being written. The number of bits actually used from
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * this value is determined by the cb parameter.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @param cb The register size. [1,2,4]
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
254365851c06fac7efeae0a0bf727ed6c6940611vboxsynctypedef DECLCALLBACK(void) FNPCICONFIGWRITE(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb);
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a FNPCICONFIGWRITE() function. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef FNPCICONFIGWRITE *PFNPCICONFIGWRITE;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Pointer to a PFNPCICONFIGWRITE. */
254365851c06fac7efeae0a0bf727ed6c6940611vboxsynctypedef PFNPCICONFIGWRITE *PPFNPCICONFIGWRITE;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** Fixed I/O region number for ROM. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define PCI_ROM_SLOT 6
254365851c06fac7efeae0a0bf727ed6c6940611vboxsync/** Max number of I/O regions. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define PCI_NUM_REGIONS 7
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/*
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Hack to include the PCIDEVICEINT structure at the right place
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * to avoid duplications of FNPCIIOREGIONMAP and PCI_NUM_REGIONS.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#ifdef PCI_INCLUDE_PRIVATE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# include "PCIInternal.h"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#endif
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/**
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * PCI Device structure.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef struct PCIDevice
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync{
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** PCI config space. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync uint8_t config[256];
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Internal data. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync union
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync {
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#ifdef __PCIDEVICEINT_DECLARED__
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PCIDEVICEINT s;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#endif
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync char padding[224];
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync } Int;
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Read only data.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @{
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** PCI device number on the pci bus. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync int32_t devfn;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync uint32_t Alignment0; /**< Alignment. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Device name. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync R3PTRTYPE(const char *) name;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** Pointer to the device instance which registered the device. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync PPDMDEVINSR3 pDevIns;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** @} */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync} PCIDEVICE;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @} */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#endif
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync