VirtualBox

source: vbox/trunk/include/VBox/pci.h@ 2596

Last change on this file since 2596 was 2596, checked in by vboxsync, 18 years ago

Moved PFNPCICONFIGREAD and PFNPCICONFIGWRITE out in the open.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 * PCI - The PCI Controller And Devices.
3 */
4
5/*
6 * Copyright (C) 2006 InnoTek Systemberatung GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21
22#ifndef __VBox_pci_h__
23#define __VBox_pci_h__
24
25
26#include <VBox/cdefs.h>
27#include <VBox/types.h>
28
29/** @defgroup grp_pci PCI - The PCI Controller.
30 * @{
31 */
32
33/** Pointer to a PCI device. */
34typedef struct PCIDevice *PPCIDEVICE;
35
36
37/**
38 * PCI configuration word 4 (command) and word 6 (status).
39 */
40typedef enum PCICONFIGCOMMAND
41{
42 /** Supports/uses memory accesses. */
43 PCI_COMMAND_IOACCESS = 0x0001,
44 PCI_COMMAND_MEMACCESS = 0x0002,
45 PCI_COMMAND_BUSMASTER = 0x0004
46} PCICONFIGCOMMAND;
47
48
49/**
50 * PCI Address space specification.
51 * This is used when registering a I/O region.
52 */
53typedef enum PCIADDRESSSPACE
54{
55 /** Memory. */
56 PCI_ADDRESS_SPACE_MEM = 0x00,
57 /** I/O space. */
58 PCI_ADDRESS_SPACE_IO = 0x01,
59 /** Prefetch memory. */
60 PCI_ADDRESS_SPACE_MEM_PREFETCH = 0x08
61} PCIADDRESSSPACE;
62
63
64/**
65 * Callback function for mapping an PCI I/O region.
66 *
67 * @return VBox status code.
68 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
69 * @param iRegion The region number.
70 * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
71 * I/O port, else it's a physical address.
72 * This address is *NOT* relative to pci_mem_base like earlier!
73 * @param enmType One of the PCI_ADDRESS_SPACE_* values.
74 */
75typedef DECLCALLBACK(int) FNPCIIOREGIONMAP(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType);
76/** Pointer to a FNPCIIOREGIONMAP() function. */
77typedef FNPCIIOREGIONMAP *PFNPCIIOREGIONMAP;
78
79/**
80 * Callback function for reading from the PCI configuration space.
81 *
82 * @returns The register value.
83 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
84 * @param Address The configuration space register address. [0..255]
85 * @param cb The register size. [1,2,4]
86 */
87typedef DECLCALLBACK(uint32_t) FNPCICONFIGREAD(PPCIDEVICE pPciDev, uint32_t Address, unsigned cb);
88/** Pointer to a FNPCICONFIGREAD() function. */
89typedef FNPCICONFIGREAD *PFNPCICONFIGREAD;
90/** Pointer to a PFNPCICONFIGREAD. */
91typedef PFNPCICONFIGREAD *PPFNPCICONFIGREAD;
92
93/**
94 * Callback function for writing to the PCI configuration space.
95 *
96 * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
97 * @param Address The configuration space register address. [0..255]
98 * @param u32Value The value that's being written. The number of bits actually used from
99 * this value is determined by the cb parameter.
100 * @param cb The register size. [1,2,4]
101 */
102typedef DECLCALLBACK(void) FNPCICONFIGWRITE(PPCIDEVICE pPciDev, uint32_t Address, uint32_t u32Value, unsigned cb);
103/** Pointer to a FNPCICONFIGWRITE() function. */
104typedef FNPCICONFIGWRITE *PFNPCICONFIGWRITE;
105/** Pointer to a PFNPCICONFIGWRITE. */
106typedef PFNPCICONFIGWRITE *PPFNPCICONFIGWRITE;
107
108/** Fixed I/O region number for ROM. */
109#define PCI_ROM_SLOT 6
110/** Max number of I/O regions. */
111#define PCI_NUM_REGIONS 7
112
113/*
114 * Hack to include the PCIDEVICEINT structure at the right place
115 * to avoid duplications of FNPCIIOREGIONMAP and PCI_NUM_REGIONS.
116 */
117#ifdef PCI_INCLUDE_PRIVATE
118# include "PCIInternal.h"
119#endif
120
121/**
122 * PCI Device structure.
123 */
124typedef struct PCIDevice
125{
126 /** PCI config space. */
127 uint8_t config[256];
128
129 /** Internal data. */
130 union
131 {
132#ifdef __PCIDEVICEINT_DECLARED__
133 PCIDEVICEINT s;
134#endif
135 char padding[224];
136 } Int;
137
138 /** Read only data.
139 * @{
140 */
141 /** PCI device number on the pci bus. */
142 int32_t devfn;
143 uint32_t Alignment0; /**< Alignment. */
144 /** Device name. */
145 R3PTRTYPE(const char *) name;
146 /** Pointer to the device instance which registered the device. */
147 PPDMDEVINSR3 pDevIns;
148 /** @} */
149} PCIDEVICE;
150
151
152/** @} */
153
154#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