From 215d5e4096cb4b06aa7fd5e9936440b28d8fe034 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 28 Aug 2018 11:56:55 +0100 Subject: config: Move KVM CPU checking to CpuConfig helper module Both se.py and fs.py need to check if a CPU is a KVM CPU. This is somewhat involved since CPUs can be disabled at compile time. Enable better code reuse by moving it to the CpuConfig module. Change-Id: I47b1512ecb62e757399a407a0e41be83b9f83be3 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/12418 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- configs/common/CpuConfig.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'configs/common/CpuConfig.py') diff --git a/configs/common/CpuConfig.py b/configs/common/CpuConfig.py index 3f193ae60..d70e6cfa7 100644 --- a/configs/common/CpuConfig.py +++ b/configs/common/CpuConfig.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012, 2017 ARM Limited +# Copyright (c) 2012, 2017-2018 ARM Limited # All rights reserved. # # The license below extends only to copyright in the software and shall @@ -59,6 +59,17 @@ def is_cpu_class(cls): except (TypeError, AttributeError): return False +def _cpu_subclass_tester(name): + cpu_class = getattr(m5.objects, name, None) + + def tester(cls): + return cpu_class is not None and cls is not None and \ + issubclass(cls, cpu_class) + + return tester + +is_kvm_cpu = _cpu_subclass_tester("BaseKvmCPU") + def get(name): """Get a CPU class from a user provided class name or alias.""" -- cgit v1.2.3