VirtualBox

Changeset 36630 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Apr 8, 2011 6:41:51 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71093
Message:

PCI: Main and VBoxManage work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pci.h

    r36562 r36630  
    10181018
    10191019#if defined(__cplusplus) && defined(IN_RING3)
    1020 /**
    1021  * Document me.
     1020/* For RTStrPrintf(). */
     1021#include <iprt/string.h>
     1022
     1023/**
     1024 * Class representing PCI address. PCI device consist of
     1025 * bus, device and function numbers. Generally device PCI
     1026 * address could be changed during runtime, but only by
     1027 * an OS PCI driver.
    10221028 *
    10231029 * @remarks C++ classes (structs included) are not generally accepted in
     
    10281034struct PciBusAddress
    10291035{
    1030     /** @todo r=bird: Add 'm', or 'm_' to data members. This is general
    1031      *        practice in most of the source tree. */
    1032     int  iBus;
    1033     int  iDevice;
    1034     int  iFn;
     1036    /** @todo: think if we'll need domain, which is higher
     1037     *  word of the address. */
     1038    int  miBus;
     1039    int  miDevice;
     1040    int  miFn;
    10351041
    10361042    PciBusAddress()
     
    10391045    }
    10401046
    1041     PciBusAddress(int bus, int device, int fn)
    1042     {
    1043         init(bus, device, fn);
     1047    PciBusAddress(int iBus, int iDevice, int iFn)
     1048    {
     1049        init(iBus, iDevice, iFn);
    10441050    }
    10451051
    10461052    PciBusAddress& clear()
    10471053    {
    1048         iBus = iDevice = iFn = -1;
     1054        miBus = miDevice = miFn = -1;
    10491055        return *this;
    10501056    }
    10511057
    1052     void init(int bus, int device, int fn)
    1053     {
    1054         iBus = bus;
    1055         iDevice = device;
    1056         iFn = fn;
     1058    void init(int iBus, int iDevice, int iFn)
     1059    {
     1060        miBus    = iBus;
     1061        miDevice = iDevice;
     1062        miFn     = iFn;
    10571063    }
    10581064
    10591065    void init(const PciBusAddress &a)
    10601066    {
    1061         iBus = a.iBus;
    1062         iDevice = a.iDevice;
    1063         iFn = a.iFn;
     1067        miBus    = a.miBus;
     1068        miDevice = a.miDevice;
     1069        miFn     = a.miFn;
    10641070    }
    10651071
    10661072    bool operator<(const PciBusAddress &a) const
    10671073    {
    1068         if (iBus < a.iBus)
     1074        if (miBus < a.miBus)
    10691075            return true;
    10701076
    1071         if (iBus > a.iBus)
     1077        if (miBus > a.miBus)
    10721078            return false;
    10731079
    1074         if (iDevice < a.iDevice)
     1080        if (miDevice < a.miDevice)
    10751081            return true;
    10761082
    1077         if (iDevice > a.iDevice)
     1083        if (miDevice > a.miDevice)
    10781084            return false;
    10791085
    1080         if (iFn < a.iFn)
     1086        if (miFn < a.miFn)
    10811087            return true;
    10821088
    1083         if (iFn > a.iFn)
     1089        if (miFn > a.miFn)
    10841090            return false;
    10851091
     
    10891095    bool operator==(const PciBusAddress &a) const
    10901096    {
    1091         return     (iBus == a.iBus)
    1092                 && (iDevice == a.iDevice)
    1093                 && (iFn == a.iFn);
     1097        return     (miBus    == a.miBus)
     1098                && (miDevice == a.miDevice)
     1099                && (miFn     == a.miFn);
    10941100    }
    10951101
    10961102    bool operator!=(const PciBusAddress &a) const
    10971103    {
    1098         return     (iBus != a.iBus)
    1099                 || (iDevice != a.iDevice)
    1100                 || (iFn  != a.iFn);
     1104        return     (miBus    != a.miBus)
     1105                || (miDevice != a.miDevice)
     1106                || (miFn     != a.miFn);
    11011107    }
    11021108
    11031109    bool valid() const
    11041110    {
    1105         return (iBus != -1) && (iDevice != -1) && (iFn != -1);
     1111        return (miBus    != -1)
     1112            && (miDevice != -1)
     1113            && (miFn     != -1);
    11061114    }
    11071115
     
    11091117    {
    11101118        Assert(valid());
    1111         return (iBus << 8) | (iDevice << 3) | iFn;
     1119        return (miBus << 8) | (miDevice << 3) | miFn;
    11121120    }
    11131121
    11141122    PciBusAddress& fromLong(int32_t value)
    11151123    {
    1116         iBus = (value >> 8) & 0xff;
    1117         iDevice = (value & 0xff) >> 3;
    1118         iFn = (value & 7);
     1124        miBus = (value >> 8) & 0xff;
     1125        miDevice = (value & 0xff) >> 3;
     1126        miFn = (value & 7);
    11191127        return *this;
     1128    }
     1129
     1130    /** Create string representation of this PCI address. */
     1131    bool format(char* szBuf, int32_t cBufSize)
     1132    {
     1133        if (cBufSize < (/* bus */ 2 + /* : */ 1 + /* device */ 2 + /* . */ 1 + /* function*/ 1 + /* \0 */1))
     1134            return false;
     1135       
     1136        if (valid())
     1137            RTStrPrintf(szBuf, cBufSize, "%02x:%02x.%01x", miBus, miDevice, miFn);
     1138        else
     1139            RTStrPrintf(szBuf, cBufSize, "%s", "<bad>");
     1140       
     1141        return true;
    11201142    }
    11211143};
Note: See TracChangeset for help on using the changeset viewer.

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