コード例 #1
0
ファイル: einj.py プロジェクト: xk/bits
def display_vendor_error_type_extension():
    with ttypager.page():
        entry = get_action(SET_ERROR_TYPE_WITH_ADDRESS)
        set_err = acpi.set_error_type_with_addr.from_address(entry.register_region.address)
        vendor_err_addr = entry.register_region.address + set_err.vendor_error_type_extension_structure_offset
        vendor_err = acpi.vendor_error_type_extension.from_address(vendor_err_addr)
        print(vendor_err)
コード例 #2
0
def show_autodemotion():
    with ttypager.page():
        if bitfields.getbits(bits.rdmsr(bits.bsp_apicid(), 0xe2), 26,
                             25) == 0x3:
            print("C1 and C3 autodemotion are enabled")
        else:
            print("C1 and C3 autodemotion are disabled")
コード例 #3
0
ファイル: mtrr.py プロジェクト: sykeben/BITS-PyOS
def variable_mtrrs(apicid=bits.bsp_apicid()):
    assert apicid in bits.cpus()

    ia32_mtrrcap_msr = IA32_MTRRCAP( bits.rdmsr(apicid, IA32_MTRRCAP_REG) )
    ia32_mtrr_def_type_msr = IA32_MTRR_DEF_TYPE(bits.rdmsr(apicid, IA32_MTRR_DEF_TYPE_REG))

    with ttypager.page():
        print("Summary:")
        print("Default memory type: {}".format(_memory_type_str(ia32_mtrr_def_type_msr.type)))
        for i in range(ia32_mtrrcap_msr.VCNT):
            ia32_mtrr_physbase_msr = IA32_MTRR_PHYSBASE(bits.rdmsr(apicid, IA32_MTRR_PHYSBASEn_REG(i)))
            ia32_mtrr_physmask_msr = IA32_MTRR_PHYSMASK(bits.rdmsr(apicid, IA32_MTRR_PHYSMASKn_REG(i)))
            if (ia32_mtrr_physmask_msr.V):
                print("MTRR{}: type={:20}   base={:10}   size={:10}".format(i, _memory_type_str(ia32_mtrr_physbase_msr.Type), _physbase_str(ia32_mtrr_physbase_msr.PhysBase), _physmask_str(ia32_mtrr_physmask_msr.PhysMask)))
        print()
        print(ia32_mtrrcap_msr, end='\n\n')
        print(ia32_mtrr_def_type_msr, end='\n\n')
        for i in range(ia32_mtrrcap_msr.VCNT):
            msr_num = IA32_MTRR_PHYSBASEn_REG(i)
            ia32_mtrr_physbase_msr = IA32_MTRR_PHYSBASE( bits.rdmsr(apicid, msr_num) )
            print("IA32_MTRR_PHYSBASE[{}] MSR {:#x}".format(i, msr_num))
            print(ia32_mtrr_physbase_msr, end='\n\n')

            msr_num = IA32_MTRR_PHYSMASKn_REG(i)
            ia32_mtrr_physmask_msr = IA32_MTRR_PHYSMASK( bits.rdmsr(apicid, msr_num) )
            print("IA32_MTRR_PHYSMASK[{}] MSR {:#x}".format(i, msr_num))
            print(ia32_mtrr_physmask_msr, end='\n\n')
コード例 #4
0
def print_fields(cls):
    with ttypager.page():
        print("{}".format(cls.__name__))
        print("{:20s} {:6} {:6}".format('field', 'length', 'offset'))
        for f in cls._fields_:
            a = getattr(cls, f[0])
            print("{:20s} {:6} {:6}".format(f[0], a.size, a.offset))
コード例 #5
0
ファイル: cdata.py プロジェクト: Tourountzis/bits
def print_fields(cls):
    with ttypager.page():
        print("{}".format(cls.__name__))
        print("{:20s} {:6} {:6}".format('field', 'length', 'offset'))
        for f in cls._fields_:
            a = getattr(cls, f[0])
            print("{:20s} {:6} {:6}".format(f[0], a.size, a.offset))
コード例 #6
0
ファイル: mwaitmenu.py プロジェクト: Tourountzis/bits
def mwait_callback(use_mwait, name="", hint=0):
    for cpu in bits.cpus():
        bits.set_mwait(cpu, use_mwait, hint, int_break_event)
    with ttypager.page():
        if use_mwait:
            print("MWAIT enabled: {}".format(name))
        else:
            print("MWAIT disabled")
コード例 #7
0
def mwait_callback(use_mwait, name="", hint=0):
    for cpu in bits.cpus():
        bits.set_mwait(cpu, use_mwait, hint, int_break_event)
    with ttypager.page():
        if use_mwait:
            print("MWAIT enabled: {}".format(name))
        else:
            print("MWAIT disabled")
コード例 #8
0
ファイル: platform.py プロジェクト: Tourountzis/bits
def dump():
    with ttypager.page():
        for num, apicid in enumerate(bits.cpus()):
            heading = "Processor {} -- APIC ID {:#x}".format(num, apicid)
            cpu = cpus[apicid]
            print "{}\n{}".format(heading, "="*len(heading))
            print "\n\n{}\n".format("".join(str(cpuid) for cpuid in cpu.cpuids))
            print "\n\n{}\n".format("".join(str(msr) for msr in cpu.msrs))
コード例 #9
0
def dump():
    with ttypager.page():
        for num, apicid in enumerate(bits.cpus()):
            heading = "Processor {} -- APIC ID {:#x}".format(num, apicid)
            cpu = cpus[apicid]
            print "{}\n{}".format(heading, "=" * len(heading))
            print "\n\n{}\n".format("".join(
                str(cpuid) for cpuid in cpu.cpuids))
            print "\n\n{}\n".format("".join(str(msr) for msr in cpu.msrs))
コード例 #10
0
ファイル: cpumenu.py プロジェクト: coldmind/bits
def callback():
    with ttypager.page():
        print(bits.brandstring())
        if cpulib.__name__ == "cpu_gen":
            print("No processor-specific test exists!")
            print("Menu entries will only include generic tests that apply to all processors.")
        else:
            print("Detected as CPU codename: {}".format(cpulib.name))
            print("Menu entries have been tailored to target this specific processor")
コード例 #11
0
ファイル: einj.py プロジェクト: sykeben/BITS-PyOS
def display_vendor_error_type_extension():
    with ttypager.page():
        entry = get_action(SET_ERROR_TYPE_WITH_ADDRESS)
        set_err = acpi.set_error_type_with_addr.from_address(
            entry.register_region.address)
        vendor_err_addr = entry.register_region.address + set_err.vendor_error_type_extension_structure_offset
        vendor_err = acpi.vendor_error_type_extension.from_address(
            vendor_err_addr)
        print(vendor_err)
コード例 #12
0
ファイル: topology.py プロジェクト: Tourountzis/bits
def display():
    """Print processor topology to the screen via pager."""
    with ttypager.page():
        socket_dict = topology()
        for socket, core_dict in socket_dict.iteritems():
            print 'socket {}'.format(_display_apicid(socket))
            for core, threads in core_dict.iteritems():
                print '| core {}'.format(_display_apicid(core))
                for thread in threads:
                    print '| | thread {}'.format(_display_apicid(thread))
            print
コード例 #13
0
def display():
    """Print processor topology to the screen via pager."""
    with ttypager.page():
        socket_dict = topology()
        for socket, core_dict in socket_dict.iteritems():
            print 'socket {}'.format(_display_apicid(socket))
            for core, threads in core_dict.iteritems():
                print '| core {}'.format(_display_apicid(core))
                for thread in threads:
                    print '| | thread {}'.format(_display_apicid(thread))
            print
コード例 #14
0
ファイル: mwaitmenu.py プロジェクト: Tourountzis/bits
def test_latency(count=0x10000):
    start = time.time()
    cpu_ping(count)
    stop = time.time()
    elapsed_ms = int((stop - start) * 1000)
    try:
        itermsg = "with {0} iteration/ms".format(int(round(count / elapsed_ms)))
    except ZeroDivisionError:
        itermsg = "cannot compute iterations/ms"
    with ttypager.page():
        print("elapsed time = {} ms; {}".format(elapsed_ms, itermsg))
コード例 #15
0
def test_latency(count=0x10000):
    start = time.time()
    cpu_ping(count)
    stop = time.time()
    elapsed_ms = int((stop - start) * 1000)
    try:
        itermsg = "with {0} iteration/ms".format(int(round(count /
                                                           elapsed_ms)))
    except ZeroDivisionError:
        itermsg = "cannot compute iterations/ms"
    with ttypager.page():
        print("elapsed time = {} ms; {}".format(elapsed_ms, itermsg))
コード例 #16
0
ファイル: cpumenu.py プロジェクト: sykeben/BITS-PyOS
def callback():
    with ttypager.page():
        print(bits.brandstring())
        if cpulib.__name__ == "cpu_gen":
            print("No processor-specific test exists!")
            print(
                "Menu entries will only include generic tests that apply to all processors."
            )
        else:
            print("Detected as CPU codename: {}".format(cpulib.name))
            print(
                "Menu entries have been tailored to target this specific processor"
            )
コード例 #17
0
ファイル: einj.py プロジェクト: sykeben/BITS-PyOS
def demo():
    unc_methods = [
        inject_memory_unc_nonfatal_err,
        inject_memory_unc_fatal_err,
        inject_processor_unc_nonfatal_err,
        inject_processor_unc_fatal_err,
        inject_pcie_unc_nonfatal_err,
        inject_pcie_unc_fatal_err,
        inject_platform_unc_nonfatal_err,
        inject_platform_unc_fatal_err,
    ]
    corr_methods = [
        inject_memory_correctable_err,
        inject_processor_correctable_err,
        inject_pcie_correctable_err,
        inject_platform_correctable_err,
    ]
    display_methods = [
        display_einj,
        display_einj_address,
        display_supported_errors,
        display_triggers,
        display_vendor_error_type_extension,
    ]

    with ttypager.page():
        for item in display_methods:
            print("\n\n\nMethod name: {}".format(item.__name__))
            print("Method doc:\n{}\n\n".format(
                item.__doc__ if item.
                __doc__ else "No documentation for this method"))
            item()

        for item in corr_methods:
            print("\n\nMethod name: {}".format(item.__name__))
            print("Method doc: {}".format(item.__doc__ if item.__doc__ else
                                          "No documentation for this method"))
            item()

        for item in unc_methods:
            print("\n\n\nMethod name: {}".format(item.__name__))
            print("Method doc: {}\n\n".format(
                item.__doc__ if item.
                __doc__ else "No documentation for this method"))
            print(
                "Based on the name and documentation of this item, it is likely to be fatal."
            )
            print("Execute it directly from the python command line.")
            print(
                "Your mileage may vary and if it breaks, you get to keep all the pieces."
            )
コード例 #18
0
ファイル: einj.py プロジェクト: xk/bits
def demo():
    unc_methods = [
        inject_memory_unc_nonfatal_err,
        inject_memory_unc_fatal_err,
        inject_processor_unc_nonfatal_err,
        inject_processor_unc_fatal_err,
        inject_pcie_unc_nonfatal_err,
        inject_pcie_unc_fatal_err,
        inject_platform_unc_nonfatal_err,
        inject_platform_unc_fatal_err,
    ]
    corr_methods = [
        inject_memory_correctable_err,
        inject_processor_correctable_err,
        inject_pcie_correctable_err,
        inject_platform_correctable_err,
    ]
    display_methods = [
        display_einj,
        display_einj_address,
        display_supported_errors,
        display_triggers,
        display_vendor_error_type_extension,
    ]

    with ttypager.page():
        for item in display_methods:
            print("\n\n\nMethod name: {}".format(item.__name__))
            print("Method doc:\n{}\n\n".format(item.__doc__ if item.__doc__ else "No documentation for this method"))
            item()

        for item in corr_methods:
            print("\n\nMethod name: {}".format(item.__name__))
            print("Method doc: {}".format(item.__doc__ if item.__doc__ else "No documentation for this method"))
            item()

        for item in unc_methods:
            print("\n\n\nMethod name: {}".format(item.__name__))
            print("Method doc: {}\n\n".format(item.__doc__ if item.__doc__ else "No documentation for this method"))
            print("Based on the name and documentation of this item, it is likely to be fatal.")
            print("Execute it directly from the python command line.")
            print("Your mileage may vary and if it breaks, you get to keep all the pieces.")
コード例 #19
0
ファイル: einj.py プロジェクト: xk/bits
def display_einj():
    with ttypager.page():
        einj = acpi.parse_einj()
        if einj is None:
            raise RuntimeError("No ACPI EINJ table found")
        print(einj)
コード例 #20
0
ファイル: cpu_nhm.py プロジェクト: Tourountzis/bits
def show_autodemotion():
    with ttypager.page():
        if bitfields.getbits(bits.rdmsr(bits.bsp_apicid(), 0xe2), 26, 25) == 0x3:
            print("C1 and C3 autodemotion are enabled")
        else:
            print("C1 and C3 autodemotion are disabled")
コード例 #21
0
ファイル: einj.py プロジェクト: xk/bits
def display_triggers():
    with ttypager.page():
        print(get_trigger_action_table_op())
コード例 #22
0
def show_interrupt_break_event():
    with ttypager.page():
        if int_break_event:
            print("Interrupt Break Event is enabled")
        else:
            print("Interrupt Break Event is disabled")
コード例 #23
0
ファイル: bootmenu.py プロジェクト: Tourountzis/bits
def callback():
    with ttypager.page():
        print("{} boot detected".format(boot_str))
        print("Tests and other menu entries tailored for this environment")
コード例 #24
0
ファイル: mwaitmenu.py プロジェクト: Tourountzis/bits
def show_interrupt_break_event():
    with ttypager.page():
        if int_break_event:
            print("Interrupt Break Event is enabled")
        else:
            print("Interrupt Break Event is disabled")
コード例 #25
0
def callback():
    with ttypager.page():
        print("{} boot detected".format(boot_str))
        print("Tests and other menu entries tailored for this environment")
コード例 #26
0
ファイル: einj.py プロジェクト: sykeben/BITS-PyOS
def display_triggers():
    with ttypager.page():
        print(get_trigger_action_table_op())
コード例 #27
0
ファイル: einj.py プロジェクト: sykeben/BITS-PyOS
def display_einj():
    with ttypager.page():
        einj = acpi.parse_einj()
        if einj is None:
            raise RuntimeError("No ACPI EINJ table found")
        print(einj)