Changeset 12988 in vbox
- Timestamp:
- Oct 6, 2008 12:20:09 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDM.cpp
r12987 r12988 24 24 * 25 25 * VirtualBox is designed to be very configurable, i.e. the ability to select 26 * virtual devices and configure them uniquely for a VM. For this reason virtual27 * devices are not statically linked with the VMM but loaded, linked and26 * virtual devices and configure them uniquely for a VM. For this reason 27 * virtual devices are not statically linked with the VMM but loaded, linked and 28 28 * instantiated at runtime by PDM using the information found in the 29 29 * Configuration Manager (CFGM). … … 35 35 * 36 36 * 37 * @section sec_pdm_dev 38 * 39 * Devices register themselves when the module containing them is loaded. PDM37 * @section sec_pdm_dev The Pluggable Devices 38 * 39 * Devices register themselves when the module containing them is loaded. PDM 40 40 * will call the entry point 'VBoxDevicesRegister' when loading a device module. 41 41 * The device module will then use the supplied callback table to check the VMM 42 * version and to register its devices. Each device have an unique (for the43 * configured VM) name. The name is not only used in PDM but also in CFGM (to42 * version and to register its devices. Each device have an unique (for the 43 * configured VM) name. The name is not only used in PDM but also in CFGM (to 44 44 * organize device and device instance settings) and by anyone who wants to talk 45 45 * to a specific device instance. 46 46 * 47 47 * When all device modules have been successfully loaded PDM will instantiate 48 * those devices which are configured for the VM. Note that a device may have 49 * more than one instance, see network adaptors for instance. When instantiating 50 * a device PDM provides device instance memory and a callback table (aka Device 51 * Helpers / DevHlp) with the VM APIs which the device instance is trusted with. 52 * 53 * Some devices are trusted devices, most are not. The trusted devices are an 48 * those devices which are configured for the VM. Note that a device may have 49 * more than one instance, see network adaptors for instance. When 50 * instantiating a device PDM provides device instance memory and a callback 51 * table (aka Device Helpers / DevHlp) with the VM APIs which the device 52 * instance is trusted with. 53 * 54 * Some devices are trusted devices, most are not. The trusted devices are an 54 55 * integrated part of the VM and can obtain the VM handle from their device 55 * instance handles, thus enabling them to call any VM api. Untrusted devices56 * instance handles, thus enabling them to call any VM api. Untrusted devices 56 57 * can only use the callbacks provided during device instantiation. 57 58 * … … 59 60 * the VM handle and let them call the internal VM APIs directly, is both to 60 61 * create a binary interface that can be supported accross releases and to 61 * create a barrier between devices and the VM. (The trusted / untrusted bit62 * create a barrier between devices and the VM. (The trusted / untrusted bit 62 63 * hasn't turned out to be of much use btw., but it's easy to maintain so there 63 64 * isn't any point in removing it.) … … 65 66 * A device can provide a ring-0 and/or a raw-mode context extension to improve 66 67 * the VM performance by handling exits and traps (respectively) without 67 * requiring context switches (to ring-3). Callbacks for MMIO and I/O ports can68 * requiring context switches (to ring-3). Callbacks for MMIO and I/O ports can 68 69 * needs to be registered specifically for the additional contexts for this to 69 * make sense. Also, the device has to be trusted to be loaded into R0/RC70 * because of the extra privilege it entails. Note that raw-mode code and data70 * make sense. Also, the device has to be trusted to be loaded into R0/RC 71 * because of the extra privilege it entails. Note that raw-mode code and data 71 72 * will be subject to relocation. 72 73 * 73 74 * 74 * @section sec_pdm_drv The Pluggable Drivers 75 * @section sec_pdm_special_devs Special Devices 76 * 77 * Several kinds of devices interacts with the VMM and/or other device and PDM 78 * will work like a mediator for these. The typical pattern is that the device 79 * calls a special registration device helper with a set of callbacks, PDM 80 * responds by copying this and providing a pointer to a set helper callbacks 81 * for that particular kind of device. Unlike interfaces where the callback 82 * table pointer is used a 'this' pointer, these arrangements will use the 83 * device instance pointer (PPDMDEVINS) as a kind of 'this' pointer. 84 * 85 * For an example of this kind of setup, see the PIC. The PIC registers itself 86 * by calling PDMDEVHLPR3::pfnPICRegister. PDM saves the device instance, 87 * copies the callback tables (PDMPICREG), resolving the ring-0 and raw-mode 88 * addresses in the process, and hands back the pointer to a set of helper 89 * methods (PDMPICHLPR3). The PCI device then queries the ring-0 and raw-mode 90 * helpers using PDMPICHLPR3::pfnGetR0Helpers and PDMPICHLPR3::pfnGetRCHelpers. 91 * The PCI device repeates ths pfnGetRCHelpers call in it's relocation method 92 * since the address changes when RC is relocated. 93 * 94 * 95 * 96 * @section sec_pdm_usbdev The Pluggable USB Devices 97 * 98 * USB devices are handled a little bit differently than other devices. The 99 * general concepts wrt. pluggability are mostly the same, but the details 100 * varies. The registration entry point is 'VBoxUsbRegister', the device 101 * instance is PDMUSBINS and the callbacks helpers are different. Also, USB 102 * device are restricted to ring-3 and cannot have any ring-0 or raw-mode 103 * extensions (at least not yet). 104 * 105 * The way USB devices work differs greatly from other devices though since they 106 * aren't attaches directly to the PCI/ISA/whatever system buses but via a 107 * USB host control (OHCI, UHCI or EHCI). USB devices handles USB requests 108 * (URBs) and does not register I/O ports, MMIO ranges or PCI bus 109 * devices/functions. 110 * 111 * 112 * 113 * @section sec_pdm_drv The Pluggable Drivers 75 114 * 76 115 * The VM devices are often accessing host hardware or OS facilities. For most … … 97 136 * 98 137 * It is possible to configure many levels of drivers inserting filters, loggers, 99 * or whatever you desire into the chain. We're using this for network sniffing138 * or whatever you desire into the chain. We're using this for network sniffing 100 139 * for instance. 101 140 * … … 105 144 * 106 145 * 107 * @subsection sec_pdm_drv_interfaces Interfaces 108 * 109 * The pluggable drivers exposes one standard interface (callback table) which 110 * is used to construct, destruct, attach, detach, and query other interfaces. 111 * A device will query the interfaces required for it's operation during init 112 * and hotplug. PDM will query some interfaces during runtime mounting too. 113 * 114 * ... list interfaces ... 115 * 116 * 117 * @section sec_pdm_utils Utilities 118 * 119 * @todo 146 * 147 * @section sec_pdm_ifs Interfaces 148 * 149 * The pluggable drivers and devices exposes one standard interface (callback 150 * table) which is used to construct, destruct, attach, detach,( ++,) and query 151 * other interfaces. A device will query the interfaces required for it's 152 * operation during init and hotplug. PDM may query some interfaces during 153 * runtime mounting too. 154 * 155 * An interface here means a function table contained within the device or 156 * driver instance data. Its method are invoked with the function table pointer 157 * as the first argument and they will calculate the address of the device or 158 * driver instance data from it. (This is one of the aspects which *might* have 159 * been better done in C++.) 160 * 161 * 162 * 163 * @section sec_pdm_utils Utilities 164 * 165 * As mentioned earlier, PDM is the location of any usful constrcts that doesn't 166 * quite fit into IPRT. The next subsections will discuss these. 167 * 168 * One thing these APIs all have in common is that resources will be associated 169 * with a device / driver and automatically freed after it has been destroyed if 170 * the destructor didn't do this. 120 171 * 121 172 * 122 173 * @subsection sec_pdm_thread Async I/O 123 174 * 124 * @todo 175 * The PDM Async I/O API provides a somewhat platform agnostic interface for 176 * asynchronous I/O. For reasons of performance and complexcity this does not 177 * build upon any IPRT API. 178 * 179 * @todo more details. 125 180 * 126 181 * 127 182 * @subsection sec_pdm_thread Critical Section 128 183 * 129 * @todo 184 * The PDM Critical Section API is currently building on the IPRT API with the 185 * same name. It adds the posibility to use critical sections in ring-0 and 186 * raw-mode as well as in ring-3. There are certain restrictions on the RC and 187 * R0 usage though since we're not able to wait on it, nor wake up anyone that 188 * is waiting on it. These restrictions origins with the use of a ring-3 event 189 * semaphore. In a later incarnation we plan to replace the ring-3 event 190 * semaphore with a ring-0 one, thus enabling us to wake up waiters while 191 * exectuing in ring-0 and making the hardware assisted execution mode more 192 * efficient. (Raw-mode won't benefit much from this, naturally.) 130 193 * 131 194 * 132 195 * @subsection sec_pdm_thread Queue 133 196 * 134 * @todo 197 * The PDM Queue API is for queuing one or more tasks for later consumption in 198 * ring-3 by EMT, and optinally forcing a delayed or ASAP return to ring-3. The 199 * queues can also be run on a timer basis as an alternative to the ASAP thing. 200 * The queue will be flushed at forced action time. 201 * 202 * A queue can also be used by another thread (a I/O worker for instance) to 203 * send work / events over to the EMT. 135 204 * 136 205 * 137 206 * @subsection sec_pdm_thread Task - not implemented yet 138 207 * 139 * @todo 208 * The PDM Task API is for flagging a task for execution at a later point when 209 * we're back in ring-3, optionally forcing the ring-3 return to happen ASAP. 210 * As you can see the concept is similar to queues only simpler. 211 * 212 * A task can also be scheduled by another thread (a I/O worker for instance) as 213 * a mean of getting something done in EMT. 214 * 140 215 * 141 216 * @subsection sec_pdm_thread Thread 217 * 218 * The PDM Thread API is there to help devices and drivers manage their threads 219 * correctly wrt. power on, suspend, resume, power off and destruction. 220 * 221 * The general usage pattern for threads in the employ of devices and drivers is 222 * that they shuffle data or requests while the VM is running and stop doing 223 * this when the VM is paused or powered down. Rogue threads running while the 224 * VM is paused can cause the state to change during saving or have other 225 * unwanted side effects. The PDM Threads API ensures that this won't happen. 142 226 * 143 227 */
Note:
See TracChangeset
for help on using the changeset viewer.