Пример #1
0
    def getIommuAGAW(self, iommuaddr, devmem, capoffset, capbytesize, agawbitstart):
        "Gets the AGAW name from a given iommuaddr, at the capability offset"
        AGAW_39_BITNO = 1
        AGAW_48_BITNO = 2
        AGAW_39_NAME = "39"
        AGAW_48_NAME = "48"

        name = "agaw"
        try:
            startaddr = int(iommuaddr, 16) + int(capoffset, 16)
            capreg = extractor.extractBinaryData(devmem,
                                                 startaddr,
                                                 capbytesize)
        except IOError:
            message.addError("Could not access file: %s" % devmem, False)
        else:
            agaw = (int(capreg, 16) >> agawbitstart) & 0x1F  # See 5 bits
            if util.getBit(agaw, AGAW_39_BITNO):
                name = AGAW_39_NAME
            elif util.getBit(agaw, AGAW_48_BITNO):
                name = AGAW_48_NAME
            else:
                message.addError("AGAW Capability could not be found for IOMMU "
                                 "device at: %s" % iommuaddr, False)
        return name
Пример #2
0
 def getVmxFromMSR(self, msrpath, offset, vmxbitsize):
     "Gets VmxTimerRate value from a given msr path"
     # Try to find MSR file
     byte = extractor.extractBinaryData(msrpath, offset, 1)
     # Raises IOError here if not found
     vmxbits = 0
     # Get bits from VMX_BITS_START to VMX_BITS_END
     for bitnum in range(0, vmxbitsize):
         vmxbits += util.getBit(int(byte, 16), bitnum) << bitnum
     vmxTimerRate = int(vmxbits)
     return vmxTimerRate
Пример #3
0
    def _extractCapability(self, devicepath, configfilename):
        "Gets capability for device"
        CAPABILITY_START = 0x34
        STATUS_REG_LOCATION = 0x6
        CAPABILITY_BIT_POS = 4
        NEXT_OFFSET = 1
        CAP_SIZE = 1
        STOP_ID = 0x00
        CAPABILITY_NUM = 48
        CONFIG_PATH = os.path.join(devicepath, configfilename)

        # Checks config file whether capability bit is activated
        capbyte = extractor.extractBinaryData(
            CONFIG_PATH, STATUS_REG_LOCATION, 1)
        capint = int(capbyte, 16)
        if util.getBit(capint, CAPABILITY_BIT_POS):
            # Checks config file, starting at CAPABILITY_START and moving
            # through linked list
            self.capabilities[devicepath] = self._readCapFile(CONFIG_PATH,
                                                              CAPABILITY_START,
                                                              CAP_SIZE,
                                                              NEXT_OFFSET,
                                                              STOP_ID,
                                                              CAPABILITY_NUM)
Пример #4
0
def get_cap_msix(fileobj):
    byte = struct.unpack('B', fileobj.read(1))[0]
    enablebit = util.getBit(byte, 0)  # Last bit
    value = CAP_MSIX_VALUE(enable=enablebit)
    return value