1# Copyright (c) 2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 57 unchanged lines hidden (view full) ---

66import smartdict
67build_env = smartdict.SmartDict()
68build_env.update(defines.m5_build_env)
69
70# make a SmartDict out of the OS environment too
71env = smartdict.SmartDict()
72env.update(os.environ)
73
74# Function to provide to C++ so it can look up instances based on paths
75def resolveSimObject(name):
76 obj = config.instanceDict[name]
77 return obj.getCCObject()
78
74from main import options, arguments, main
75
76# The final hook to generate .ini files. Called from the user script
77# once the config is built.
78def instantiate(root):
84 config.ticks_per_sec = float(root.clock.frequency)
79 params.ticks_per_sec = float(root.clock.frequency)
80 # ugly temporary hack to get output to config.ini
81 sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w')
82 root.print_ini()
83 sys.stdout.close() # close config.ini
84 sys.stdout = sys.__stdout__ # restore to original
85 cc_main.loadIniFile(resolveSimObject) # load config.ini into C++
86 root.createCCObject()
87 root.connectPorts()

--- 11 unchanged lines hidden (view full) ---

99
100# Export curTick to user script.
101def curTick():
102 return cc_main.cvar.curTick
103
104# register our C++ exit callback function with Python
105atexit.register(cc_main.doExitCleanup)
106
112# This import allows user scripts to reference 'm5.objects.Foo' after
113# just doing an 'import m5' (without an 'import m5.objects'). May not
114# matter since most scripts will probably 'from m5.objects import *'.
115import objects
116
107# This loops until all objects have been fully drained.
108def doDrain(root):
109 all_drained = drain(root)
110 while (not all_drained):
111 all_drained = drain(root)
112
113# Tries to drain all objects. Draining might not be completed unless
114# all objects return that they are drained on the first call. This is

--- 76 unchanged lines hidden (view full) ---

191 for old_cpu in old_cpus:
192 old_cpu._ccObject.switchOut()
193 index = 0
194 print "Switching CPUs"
195 for new_cpu in new_cpus:
196 new_cpu.takeOverFrom(old_cpus[index])
197 new_cpu._ccObject.resume()
198 index += 1
199
200# Since we have so many mutual imports in this package, we should:
201# 1. Put all intra-package imports at the *bottom* of the file, unless
202# they're absolutely needed before that (for top-level statements
203# or class attributes). Imports of "trivial" packages that don't
204# import other packages (e.g., 'smartdict') can be at the top.
205# 2. Never use 'from foo import *' on an intra-package import since
206# you can get the wrong result if foo is only partially imported
207# at the point you do that (i.e., because foo is in the middle of
208# importing *you*).
209import objects
210import params