示例#1
0
    def check_spd_wd(self):
        self.logger.start_test("SPD Write Disable")

        try:
            _smbus = smbus.SMBus(self.cs)
            _spd = spd.SPD(_smbus)
        except BaseException as msg:
            self.logger.error(msg)
            self.res = ModuleResult.ERROR
            return self.res

        spd_wd_reg = self.cs.read_register('SMBUS_HCFG')
        spd_wd = self.cs.get_register_field('SMBUS_HCFG', spd_wd_reg, 'SPD_WD')

        dimms = _spd.detect()

        if 1 == spd_wd:
            self.logger.log_passed_check("SPD Write Disable is set")
            self.res = ModuleResult.PASSED
        else:
            if dimms:
                self.logger.log_failed_check(
                    "SPD Write Disable is not set and SPDs were detected")
                self.res = ModuleResult.FAILED
            else:
                self.logger.log_information_check(
                    "SPD Write Disable is not set, but no SPDs detected")
                self.res = ModuleResult.INFORMATION

        return self.res
示例#2
0
    def run(self):
        if len(self.argv) < 3:
            print SPDCommand.__doc__
            return

        try:
            _smbus = smbus.SMBus(self.cs)
            _spd = spd.SPD(_smbus)
        except BaseException, msg:
            print msg
            return
示例#3
0
    def run(self):
        try:
            _smbus = smbus.SMBus(self.cs)
            self._spd = spd.SPD(_smbus)
        except BaseException as msg:
            self.logger.error(msg)
            return

        t = time.time()

        if not _smbus.is_SMBus_supported():
            self.logger.log("[CHIPSEC] SMBus controller is not supported")
            return

        self.dev_addr = spd.SPD_SMBUS_ADDRESS
        self.func()

        self.logger.log(
            "[CHIPSEC] (spd) time elapsed {:.3f}".format(time.time() - t))
示例#4
0
文件: spd_cmd.py 项目: leojdh/chipsec
    def run(self):
        if len(self.argv) < 3:
            print(SPDCommand.__doc__)
            return

        try:
            _smbus = smbus.SMBus(self.cs)
            _spd = spd.SPD(_smbus)
        except BaseException as msg:
            print(msg)
            return

        op = self.argv[2]
        t = time.time()

        if not _smbus.is_SMBus_supported():
            self.logger.log("[CHIPSEC] SMBus controller is not supported")
            return
        #smbus.display_SMBus_info()

        dev_addr = spd.SPD_SMBUS_ADDRESS

        if ('detect' == op):

            self.logger.log("[CHIPSEC] Searching for DIMMs with SPD..")
            _dimms = _spd.detect()
            if _dimms is not None:
                self.logger.log("Detected the following SPD devices:")
                for _dimm in _dimms:
                    self.logger.log("{}: 0x{:02X}".format(
                        spd.SPD_DIMMS[_dimm], _dimm))

        elif ('dump' == op):

            if len(self.argv) > 3:
                dev = self.argv[3].upper()
                dev_addr = spd.SPD_DIMM_ADDRESSES[
                    dev] if dev in spd.SPD_DIMM_ADDRESSES else int(
                        self.argv[3], 16)
                if not _spd.isSPDPresent(dev_addr):
                    self.logger.log(
                        "[CHIPSEC] SPD for DIMM 0x{:X} is not found".format(
                            dev_addr))
                    return
                _spd.decode(dev_addr)
            else:
                _dimms = _spd.detect()
                for d in _dimms:
                    _spd.decode(d)

        elif ('read' == op) or ('write' == op):

            if len(self.argv) > 3:
                dev = self.argv[3].upper()
                dev_addr = spd.SPD_DIMM_ADDRESSES[
                    dev] if dev in spd.SPD_DIMM_ADDRESSES else int(
                        self.argv[3], 16)
            if not _spd.isSPDPresent(dev_addr):
                self.logger.log(
                    "[CHIPSEC] SPD for DIMM 0x{:X} is not found".format(
                        dev_addr))
                return

            off = int(self.argv[4], 16)
            if ('read' == op):
                val = _spd.read_byte(off, dev_addr)
                self.logger.log(
                    "[CHIPSEC] SPD read: offset 0x{:X} = 0x{:X}".format(
                        off, val))
            elif ('write' == op):
                val = int(self.argv[5], 16)
                self.logger.log(
                    "[CHIPSEC] SPD write: offset 0x{:X} = 0x{:X}".format(
                        off, val))
                _spd.write_byte(off, val, dev_addr)

        else:
            self.logger.error(
                "unknown command-line option '{:.32}'".format(op))
            self.logger.log(SPDCommand.__doc__)
            return

        self.logger.log(
            "[CHIPSEC] (spd) time elapsed {:.3f}".format(time.time() - t))