def test_mat(): cpupaths = acpi.get_cpupaths() procid_apicid, uid_x2apicid = acpi.parse_apic() for cpupath in cpupaths: # Find the ProcId defined by the processor object processor = acpi.evaluate(cpupath) # Find the UID defined by the processor object's _UID method uid = acpi.evaluate(cpupath + "._UID") mat_buffer = acpi.evaluate(cpupath + "._MAT") if mat_buffer is None: continue # Process each _MAT subtable mat = acpi._MAT(mat_buffer) for index, subtable in enumerate(mat.subtables): if subtable.type == acpi.MADT_TYPE_LOCAL_APIC: if subtable.enabled: testsuite.test("{} Processor declaration ProcId = _MAT ProcId".format(cpupath), processor.ProcId == subtable.proc_id) testsuite.print_detail("{} ProcId ({:#02x}) != _MAT ProcId ({:#02x})".format(cpupath, processor.ProcId, subtable.proc_id)) testsuite.print_detail("Processor Declaration: {}".format(processor)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if testsuite.test("{} with local APIC in _MAT has local APIC in MADT".format(cpupath), processor.ProcId in procid_apicid): testsuite.test("{} ApicId derived using Processor declaration ProcId = _MAT ApicId".format(cpupath), procid_apicid[processor.ProcId] == subtable.apic_id) testsuite.print_detail("{} ApicId derived from MADT ({:#02x}) != _MAT ApicId ({:#02x})".format(cpupath, procid_apicid[processor.ProcId], subtable.apic_id)) testsuite.print_detail("Processor Declaration: {}".format(processor)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if subtable.type == acpi.MADT_TYPE_LOCAL_X2APIC: if subtable.enabled: if testsuite.test("{} with x2Apic in _MAT has _UID".format(cpupath), uid is not None): testsuite.test("{}._UID = _MAT UID".format(cpupath), uid == subtable.uid) testsuite.print_detail("{}._UID ({:#x}) != _MAT UID ({:#x})".format(cpupath, uid, subtable.uid)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if testsuite.test("{} with _MAT x2Apic has x2Apic in MADT".format(cpupath), subtable.uid in uid_x2apicid): testsuite.test("{} x2ApicId derived from MADT using UID = _MAT x2ApicId".format(cpupath), uid_x2apicid[subtable.uid] == subtable.x2apicid) testsuite.print_detail("{} x2ApicId derived from MADT ({:#02x}) != _MAT x2ApicId ({:#02x})".format(cpupath, uid_x2apicid[subtable.uid], subtable.x2apicid)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, x2Apic))
def test_mat(): cpupaths = acpi.get_cpupaths() apic = acpi.parse_apic() procid_apicid = apic.procid_apicid uid_x2apicid = apic.uid_x2apicid for cpupath in cpupaths: # Find the ProcId defined by the processor object processor = acpi.evaluate(cpupath) # Find the UID defined by the processor object's _UID method uid = acpi.evaluate(cpupath + "._UID") mat_buffer = acpi.evaluate(cpupath + "._MAT") if mat_buffer is None: continue # Process each _MAT subtable mat = acpi._MAT(mat_buffer) for index, subtable in enumerate(mat): if subtable.subtype == acpi.MADT_TYPE_LOCAL_APIC: if subtable.flags.bits.enabled: testsuite.test("{} Processor declaration ProcId = _MAT ProcId".format(cpupath), processor.ProcId == subtable.proc_id) testsuite.print_detail("{} ProcId ({:#02x}) != _MAT ProcId ({:#02x})".format(cpupath, processor.ProcId, subtable.proc_id)) testsuite.print_detail("Processor Declaration: {}".format(processor)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if testsuite.test("{} with local APIC in _MAT has local APIC in MADT".format(cpupath), processor.ProcId in procid_apicid): testsuite.test("{} ApicId derived using Processor declaration ProcId = _MAT ApicId".format(cpupath), procid_apicid[processor.ProcId] == subtable.apic_id) testsuite.print_detail("{} ApicId derived from MADT ({:#02x}) != _MAT ApicId ({:#02x})".format(cpupath, procid_apicid[processor.ProcId], subtable.apic_id)) testsuite.print_detail("Processor Declaration: {}".format(processor)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if subtable.subtype == acpi.MADT_TYPE_LOCAL_X2APIC: if subtable.flags.bits.enabled: if testsuite.test("{} with x2Apic in _MAT has _UID".format(cpupath), uid is not None): testsuite.test("{}._UID = _MAT UID".format(cpupath), uid == subtable.uid) testsuite.print_detail("{}._UID ({:#x}) != _MAT UID ({:#x})".format(cpupath, uid, subtable.uid)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable)) if testsuite.test("{} with _MAT x2Apic has x2Apic in MADT".format(cpupath), subtable.uid in uid_x2apicid): testsuite.test("{} x2ApicId derived from MADT using UID = _MAT x2ApicId".format(cpupath), uid_x2apicid[subtable.uid] == subtable.x2apicid) testsuite.print_detail("{} x2ApicId derived from MADT ({:#02x}) != _MAT x2ApicId ({:#02x})".format(cpupath, uid_x2apicid[subtable.uid], subtable.x2apicid)) testsuite.print_detail("_MAT entry[{}]: {}".format(index, subtable))
def test_psd_thread_scope(): uniques = acpi.parse_cpu_method("_PSD") if not testsuite.test("_PSD (P-State Dependency) must exist for each processor", None not in uniques): testsuite.print_detail(acpi.factor_commonprefix(uniques[None])) testsuite.print_detail('No _PSD exists') return unique_num_dependencies = {} unique_num_entries = {} unique_revision = {} unique_domain = {} unique_coordination_type = {} unique_num_processors = {} for value, cpupaths in uniques.iteritems(): unique_num_dependencies.setdefault(len(value.dependencies), []).extend(cpupaths) unique_num_entries.setdefault(value.dependencies[0].num_entries, []).extend(cpupaths) unique_revision.setdefault(value.dependencies[0].revision, []).extend(cpupaths) unique_domain.setdefault(value.dependencies[0].domain, []).extend(cpupaths) unique_coordination_type.setdefault(value.dependencies[0].coordination_type, []).extend(cpupaths) unique_num_processors.setdefault(value.dependencies[0].num_processors, []).extend(cpupaths) def detail(d, fmt): for value, cpupaths in sorted(d.iteritems(), key=(lambda (k,v): v)): testsuite.print_detail(acpi.factor_commonprefix(cpupaths)) testsuite.print_detail(fmt.format(value)) testsuite.test('Dependency count for each processor must be 1', unique_num_dependencies.keys() == [1]) detail(unique_num_dependencies, 'Dependency count for each processor = {} (Expected 1)') testsuite.test('_PSD.num_entries must be 5', unique_num_entries.keys() == [5]) detail(unique_num_entries, 'num_entries = {} (Expected 5)') testsuite.test('_PSD.revision must be 0', unique_revision.keys() == [0]) detail(unique_revision, 'revision = {}') testsuite.test('_PSD.coordination_type must be 0xFE (HW_ALL)', unique_coordination_type.keys() == [0xfe]) detail(unique_coordination_type, 'coordination_type = {:#x} (Expected 0xFE HW_ALL)') testsuite.test('_PSD.domain must be unique (thread-scoped) for each processor', len(unique_domain) == len(acpi.get_cpupaths())) detail(unique_domain, 'domain = {:#x} (Expected a unique value for each processor)') testsuite.test('_PSD.num_processors must be 1', unique_num_processors.keys() == [1]) detail(unique_num_processors, 'num_processors = {} (Expected 1)')