VirtualBox

source: vbox/trunk/src/VBox/Devices/Bus/PCIInternal.h@ 35738

Last change on this file since 35738 was 35738, checked in by vboxsync, 14 years ago

r=bird: Clean up of r69600 (PCIRAW), left a few review notes behind.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/* $Id: PCIInternal.h 35738 2011-01-27 14:17:41Z vboxsync $ */
2/** @file
3 * DevPCI - PCI Internal header - Only for hiding bits of PCIDEVICE.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef __PCIInternal_h__
19#define __PCIInternal_h__
20
21/**
22 * PCI I/O region.
23 */
24typedef struct PCIIOREGION
25{
26 /** Current PCI mapping address, 0xffffffff means not mapped.
27 @todo: make address and size 64-bit. */
28 uint32_t addr;
29 uint32_t size;
30 uint8_t type; /* PCIADDRESSSPACE */
31 uint8_t padding[HC_ARCH_BITS == 32 ? 3 : 7];
32 /** Callback called when the region is mapped. */
33 R3PTRTYPE(PFNPCIIOREGIONMAP) map_func;
34} PCIIOREGION, PCIIORegion;
35/** Pointer to PCI I/O region. */
36typedef PCIIOREGION *PPCIIOREGION;
37
38/**
39 * Callback function for reading from the PCI configuration space.
40 *
41 * @returns The register value.
42 * @param pDevIns Pointer to the device instance of the PCI bus.
43 * @param iBus The bus number this device is on.
44 * @param iDevice The number of the device on the bus.
45 * @param Address The configuration space register address. [0..255]
46 * @param cb The register size. [1,2,4]
47 */
48typedef DECLCALLBACK(uint32_t) FNPCIBRIDGECONFIGREAD(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, unsigned cb);
49/** Pointer to a FNPCICONFIGREAD() function. */
50typedef FNPCIBRIDGECONFIGREAD *PFNPCIBRIDGECONFIGREAD;
51/** Pointer to a PFNPCICONFIGREAD. */
52typedef PFNPCIBRIDGECONFIGREAD *PPFNPCIBRIDGECONFIGREAD;
53
54/**
55 * Callback function for writing to the PCI configuration space.
56 *
57 * @param pDevIns Pointer to the device instance of the PCI bus.
58 * @param iBus The bus number this device is on.
59 * @param iDevice The number of the device on the bus.
60 * @param Address The configuration space register address. [0..255]
61 * @param u32Value The value that's being written. The number of bits actually used from
62 * this value is determined by the cb parameter.
63 * @param cb The register size. [1,2,4]
64 */
65typedef DECLCALLBACK(void) FNPCIBRIDGECONFIGWRITE(PPDMDEVINSR3 pDevIns, uint8_t iBus, uint8_t iDevice, uint32_t u32Address, uint32_t u32Value, unsigned cb);
66/** Pointer to a FNPCICONFIGWRITE() function. */
67typedef FNPCIBRIDGECONFIGWRITE *PFNPCIBRIDGECONFIGWRITE;
68/** Pointer to a PFNPCICONFIGWRITE. */
69typedef PFNPCIBRIDGECONFIGWRITE *PPFNPCIBRIDGECONFIGWRITE;
70
71/* Forward declaration */
72struct PCIBus;
73
74enum {
75 /** Set if the specific device function was requested by PDM.
76 * If clear the device and it's functions can be relocated to satisfy the slot request of another device. */
77 PCIDEV_FLAG_REQUESTED_DEVFUNC = 1<<0,
78 /** Flag whether the device is a pci-to-pci bridge.
79 * This is set prior to device registration. */
80 PCIDEV_FLAG_PCI_TO_PCI_BRIDGE = 1<<1,
81 /** Flag whether the device is a PCI Express device.
82 * This is set prior to device registration. */
83 PCIDEV_FLAG_PCI_EXPRESS_DEVICE = 1<<2,
84 /** Flag whether the device is capable of MSI.
85 * This one is set by MsiInit(). */
86 PCIDEV_FLAG_MSI_CAPABLE = 1<<3,
87 /** Flag whether the device is capable of MSI-X.
88 * This one is set by MsixInit(). */
89 PCIDEV_FLAG_MSIX_CAPABLE = 1<<4,
90 /** Flag if device represents real physical device in passthrough mode. */
91 PCIDEV_FLAG_PASSTHROUGH = 1<<5
92};
93
94/**
95 * PCI Device - Internal data.
96 */
97typedef struct PCIDEVICEINT
98{
99 /** I/O regions. */
100 PCIIOREGION aIORegions[PCI_NUM_REGIONS];
101 /** Pointer to the PCI bus of the device. (R3 ptr) */
102 R3PTRTYPE(struct PCIBus *) pBusR3;
103 /** Pointer to the PCI bus of the device. (R0 ptr) */
104 R0PTRTYPE(struct PCIBus *) pBusR0;
105 /** Pointer to the PCI bus of the device. (RC ptr) */
106 RCPTRTYPE(struct PCIBus *) pBusRC;
107#if HC_ARCH_BITS == 64
108 RTRCPTR Alignment0;
109#endif
110
111 /** Page used for MSI-X state. (R3 ptr) */
112 R3PTRTYPE(void*) pMsixPageR3;
113 /** Page used for MSI-X state. (R0 ptr) */
114 R0PTRTYPE(void*) pMsixPageR0;
115 /** Page used for MSI-X state. (RC ptr) */
116 RCPTRTYPE(void*) pMsixPageRC;
117#if HC_ARCH_BITS == 64
118 RTRCPTR Alignment1;
119#endif
120
121
122 /** Read config callback. */
123 R3PTRTYPE(PFNPCICONFIGREAD) pfnConfigRead;
124 /** Write config callback. */
125 R3PTRTYPE(PFNPCICONFIGWRITE) pfnConfigWrite;
126
127 /** Flags of this PCI device, see PCIDEV_FLAG_XXX constants.
128 * @todo s/uFlags/fFlags/g */
129 uint32_t uFlags;
130 /** Current state of the IRQ pin of the device. */
131 int32_t uIrqPinState;
132
133 /** Offset of MSI PCI capability in config space, or 0. */
134 uint8_t u8MsiCapOffset;
135 /** Size of MSI PCI capability in config space, or 0. */
136 uint8_t u8MsiCapSize;
137 /** Offset of MSI-X PCI capability in config space, or 0. */
138 uint8_t u8MsixCapOffset;
139 /** Size of MSI-X PCI capability in config space, or 0. */
140 uint8_t u8MsixCapSize;
141
142 uint32_t Alignment2;
143
144 /** Pointer to bus specific data. (R3 ptr) */
145 R3PTRTYPE(const void*) pPciBusPtrR3;
146
147 /** Read config callback for PCI bridges to pass requests
148 * to devices on another bus.
149 */
150 R3PTRTYPE(PFNPCIBRIDGECONFIGREAD) pfnBridgeConfigRead;
151 /** Write config callback for PCI bridges to pass requests
152 * to devices on another bus.
153 */
154 R3PTRTYPE(PFNPCIBRIDGECONFIGWRITE) pfnBridgeConfigWrite;
155
156} PCIDEVICEINT;
157
158/** Indicate that PCIDEVICE::Int.s can be declared. */
159#define PCIDEVICEINT_DECLARED
160
161#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette