62a63,67
> _memory_modes = {
> "atomic" : objects.params.atomic,
> "timing" : objects.params.timing,
> }
>
205c210
< def changeMemoryMode(system, mode):
---
> def _changeMemoryMode(system, mode):
215,217c220,221
< def changeToAtomic(system, **kwargs):
< print "Changing memory mode to atomic"
< changeMemoryMode(system, objects.params.atomic, **kwargs)
---
> def switchCpus(system, cpuList, do_drain=True):
> """Switch CPUs in a system.
219,221c223,227
< def changeToTiming(system, **kwargs):
< print "Changing memory mode to timing"
< changeMemoryMode(system, objects.params.timing, **kwargs)
---
> By default, this method drains and resumes the system. This
> behavior can be disabled by setting the keyword argument
> 'do_drain' to false, which might be desirable if multiple
> operations requiring a drained system are going to be performed in
> sequence.
223c229,239
< def switchCpus(cpuList):
---
> Note: This method may switch the memory mode of the system if that
> is required by the CPUs. It may also flush all caches in the
> system.
>
> Arguments:
> system -- Simulated system.
> cpuList -- (old_cpu, new_cpu) tuples
>
> Keyword Arguments:
> do_drain -- Perform a drain/resume of the system when switching.
> """
231c247,250
< old_cpu_set = set([old_cpu for old_cpu, new_cpu in cpuList])
---
> old_cpus = [old_cpu for old_cpu, new_cpu in cpuList]
> new_cpus = [new_cpu for old_cpu, new_cpu in cpuList]
> old_cpu_set = set(old_cpus)
> memory_mode_name = new_cpus[0].memory_mode()
242a262,268
> if not new_cpu.support_take_over():
> raise RuntimeError, \
> "New CPU (%s) does not support CPU handover." % (old_cpu,)
> if new_cpu.memory_mode() != memory_mode_name:
> raise RuntimeError, \
> "%s and %s require different memory modes." % (new_cpu,
> new_cpus[0])
245a272,274
> if not old_cpu.support_take_over():
> raise RuntimeError, \
> "Old CPU (%s) does not support CPU handover." % (old_cpu,)
246a276,283
> try:
> memory_mode = _memory_modes[memory_mode_name]
> except KeyError:
> raise RuntimeError, "Invalid memory mode (%s)" % memory_mode_name
>
> if do_drain:
> drain(system)
>
250a288,292
> # Change the memory mode if required. We check if this is needed
> # to avoid printing a warning if no switch was performed.
> if system.getMemoryMode() != memory_mode:
> _changeMemoryMode(system, memory_mode)
>
253a296,298
> if do_drain:
> resume(system)
>