VirtualBox

Changeset 12721 in vbox for trunk/src


Ignore:
Timestamp:
Sep 25, 2008 11:57:28 AM (16 years ago)
Author:
vboxsync
Message:

#1865: IOM - doc update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/IOM.cpp

    r12703 r12721  
    2424 *
    2525 * The input/output monitor will handle I/O exceptions routing them to the
    26  * appropriate device. It implements an API to register and deregister
    27  * virtual port I/O handler and memory mapped I/O handlers. A handler is
    28  * PDM devices and a set of callback functions.
    29  *
    30  * Port I/O (PIO) is easily trapped by ensuring IOPL is 0, thus causing \#GP(0) on
    31  * any access to I/O ports. Using the dissassembler (DIS) the faulting
    32  * instruction will be interpreted determing the port and if there is a handler
    33  * for it. If a handler exists it will be called, else default action will be
    34  * performed.
    35  *
    36  * Memory Mapped I/O (MMIO) is gonna be worse since there are numerous instructions
    37  * which can access memory. I'm afraid we might have to emulate each
    38  * instruction which faults. The Execution Monitor (EM) will provide facilities
    39  * for doing this using DIS.
    40  *
    41  * Emulating I/O port access is less complex and sligtly faster than emulating MMIO,
    42  * so in most cases we should encourage the OS to use PIO. Devices which are freqently
    43  * accessed should register GC handlers to speed up execution.
     26 * appropriate device. It implements an API to register and deregister virtual
     27 * I/0 port handlers and memory mapped I/O handlers. A handler is PDM devices
     28 * and a set of callback functions.
     29 *
     30 *
     31 * @section sec_iom_rawmode     Raw-Mode
     32 *
     33 * In raw-mode I/O port access is trapped (\#GP(0)) by ensuring that the actual
     34 * IOPL is 0 regardless of what the guest IOPL is. The \#GP handler use the
     35 * dissassembler (DIS) to figure which instruction caused it (there are a number
     36 * of instructions in addition to the I/O ones) and if it's an I/O port access
     37 * it will hand it to IOMGCIOPortHandler (via EMInterpretPortIO).
     38 * IOMGCIOPortHandler will lookup the port in the AVL tree of registered
     39 * handlers. If found, the handler will be called otherwise default action is
     40 * taken. (Default action is to write into the void and read all set bits.)
     41 *
     42 * Memory Mapped I/O (MMIO) is implemented as a sligtly special case of PGM
     43 * access handlers. An MMIO range is registered with IOM which then registers it
     44 * with the PGM access handler sub-system. The access handler catches all
     45 * access and will be called in the context of a \#PF handler. In RC and R0 this
     46 * handler is IOMMMIOHandler while in ring-3 it's IOMR3MMIOHandler (althought in
     47 * ring-3 there can be alternative ways). IOMMMIOHandler will attempt to emulate
     48 * the instruction that is doing the access and pass the corresponding reads /
     49 * writes to the device.
     50 *
     51 * Emulating I/O port access is less complex and should be sligtly faster than
     52 * emulating MMIO, so in most cases we should encourage the OS to use port I/O.
     53 * Devices which are freqently accessed should register GC handlers to speed up
     54 * execution.
     55 *
     56 *
     57 * @section sec_iom_hwaccm     Hardware Assisted Virtualization Mode
     58 *
     59 * When running in hardware assisted virtualization mode we'll be doing much the
     60 * same things as in raw-mode. The main difference is that we're running in the
     61 * host ring-0 context and that we don't get faults (\#GP(0) and \#PG) but
     62 * exits.
     63 *
     64 *
     65 * @section sec_iom_rem         Recompiled Execution Mode
     66 *
     67 * When running in the recompiler things are different. I/O port access is
     68 * handled by calling IOMIOPortRead and IOMIOPortWrite directly. While MMIO can
     69 * be handled in one of two ways. The normal way is that we have a registered a
     70 * special RAM range with the recompiler and in the three callbacks (for byte,
     71 * word and dword access) we call IOMMMIORead and IOMMMIOWrite directly. The
     72 * alternative ways that the physical memory access which goes via PGM will take
     73 * care of it by calling IOMR3MMIOHandler via the PGM access handler machinery
     74 * - this shouldn't happen but it is an alternative...
     75 *
     76 *
     77 * @section sec_iom_other       Other Accesses
     78 *
     79 * I/O ports aren't really exposed in any other way, unless you count the
     80 * instruction interpreter in EM, but that's just what we're doing in the
     81 * raw-mode \#GP(0) case really. Now it's possible to call IOMIOPortRead and
     82 * IOMIOPortWrite directly to talk to a device, but this is really bad behavior
     83 * and should only be done as temporary hacks (the PC BIOS device used to
     84 * setup the CMOS this way back in the dark ages).
     85 *
     86 * MMIO has similar direct routes as the I/O ports and these shouldn't be used
     87 * for the same reasons and with the same restrictions. OTOH since MMIO is
     88 * mapped into the physical memory address space, it can be accessed in a number
     89 * of ways thru PGM.
    4490 *
    4591 */
Note: See TracChangeset for help on using the changeset viewer.

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