SConscript revision 6121
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu#
294484Sbinkertn@umich.edu# Authors: Steve Reinhardt
304484Sbinkertn@umich.edu
314494Ssaidi@eecs.umich.eduImport('*')
324484Sbinkertn@umich.edu
334484Sbinkertn@umich.edu#################################################################
344484Sbinkertn@umich.edu#
354484Sbinkertn@umich.edu# Generate StaticInst execute() method signatures.
364484Sbinkertn@umich.edu#
374484Sbinkertn@umich.edu# There must be one signature for each CPU model compiled in.
384781Snate@binkert.org# Since the set of compiled-in models is flexible, we generate a
394484Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly.
404484Sbinkertn@umich.edu#
414484Sbinkertn@umich.edu#################################################################
424484Sbinkertn@umich.edu
434484Sbinkertn@umich.edu# CPU model-specific data is contained in cpu_models.py
444484Sbinkertn@umich.edu# Convert to SCons File node to get path handling
454484Sbinkertn@umich.edumodels_db = File('cpu_models.py')
464484Sbinkertn@umich.edu# slurp in contents of file
474484Sbinkertn@umich.eduexecfile(models_db.srcnode().abspath)
484484Sbinkertn@umich.edu
494484Sbinkertn@umich.edu# Template for execute() signature.
504484Sbinkertn@umich.eduexec_sig_template = '''
514484Sbinkertn@umich.eduvirtual Fault execute(%(type)s *xc, Trace::InstRecord *traceData) const = 0;
524484Sbinkertn@umich.eduvirtual Fault initiateAcc(%(type)s *xc, Trace::InstRecord *traceData) const
534484Sbinkertn@umich.edu{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
544484Sbinkertn@umich.eduvirtual Fault completeAcc(Packet *pkt, %(type)s *xc,
554484Sbinkertn@umich.edu                          Trace::InstRecord *traceData) const
564484Sbinkertn@umich.edu{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
574484Sbinkertn@umich.eduvirtual int memAccSize(%(type)s *xc)
584484Sbinkertn@umich.edu{ panic("memAccSize not defined!"); M5_DUMMY_RETURN };
594484Sbinkertn@umich.edu'''
604484Sbinkertn@umich.edu
614484Sbinkertn@umich.edumem_ini_sig_template = '''
624484Sbinkertn@umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
634484Sbinkertn@umich.edu'''
644484Sbinkertn@umich.edu
654484Sbinkertn@umich.edumem_comp_sig_template = '''
664484Sbinkertn@umich.eduvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
674484Sbinkertn@umich.edu'''
684484Sbinkertn@umich.edu
694484Sbinkertn@umich.edu# Generate a temporary CPU list, including the CheckerCPU if
704484Sbinkertn@umich.edu# it's enabled.  This isn't used for anything else other than StaticInst
714484Sbinkertn@umich.edu# headers.
724484Sbinkertn@umich.edutemp_cpu_list = env['CPU_MODELS'][:]
734484Sbinkertn@umich.edu
744484Sbinkertn@umich.eduif env['USE_CHECKER']:
754484Sbinkertn@umich.edu    temp_cpu_list.append('CheckerCPU')
764484Sbinkertn@umich.edu    SimObject('CheckerCPU.py')
774484Sbinkertn@umich.edu
784484Sbinkertn@umich.edu# Generate header.
794484Sbinkertn@umich.edudef gen_cpu_exec_signatures(target, source, env):
804484Sbinkertn@umich.edu    f = open(str(target[0]), 'w')
814484Sbinkertn@umich.edu    print >> f, '''
824484Sbinkertn@umich.edu#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
834484Sbinkertn@umich.edu#define __CPU_STATIC_INST_EXEC_SIGS_HH__
844484Sbinkertn@umich.edu'''
854484Sbinkertn@umich.edu    for cpu in temp_cpu_list:
864484Sbinkertn@umich.edu        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
874484Sbinkertn@umich.edu        print >> f, exec_sig_template % { 'type' : xc_type }
884484Sbinkertn@umich.edu    print >> f, '''
894484Sbinkertn@umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
904484Sbinkertn@umich.edu'''
914494Ssaidi@eecs.umich.edu
924494Ssaidi@eecs.umich.edu# Generate string that gets printed when header is rebuilt
934494Ssaidi@eecs.umich.edudef gen_sigs_string(target, source, env):
944494Ssaidi@eecs.umich.edu    return "Generating static_inst_exec_sigs.hh: " \
954496Ssaidi@eecs.umich.edu           + ', '.join(temp_cpu_list)
964494Ssaidi@eecs.umich.edu
974504Ssaidi@eecs.umich.edu# Add command to generate header to environment.
984494Ssaidi@eecs.umich.eduenv.Command('static_inst_exec_sigs.hh', models_db,
994494Ssaidi@eecs.umich.edu            Action(gen_cpu_exec_signatures, gen_sigs_string,
1004496Ssaidi@eecs.umich.edu                   varlist = temp_cpu_list))
1014504Ssaidi@eecs.umich.edu
1024504Ssaidi@eecs.umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1034500Sbinkertn@umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1044500Sbinkertn@umich.edu
1054496Ssaidi@eecs.umich.edu# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1064496Ssaidi@eecs.umich.edu# and one of these are not being used.
1074487Sstever@eecs.umich.eduCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1084487Sstever@eecs.umich.edu
1094484Sbinkertn@umich.eduSimObject('BaseCPU.py')
1104484Sbinkertn@umich.eduSimObject('FuncUnit.py')
1114484Sbinkertn@umich.eduSimObject('ExeTracer.py')
1124484Sbinkertn@umich.eduSimObject('IntelTrace.py')
1134484Sbinkertn@umich.edu
1144484Sbinkertn@umich.eduSource('activity.cc')
1154484Sbinkertn@umich.eduSource('base.cc')
1164484Sbinkertn@umich.eduSource('cpuevent.cc')
1174484Sbinkertn@umich.eduSource('exetrace.cc')
1184484Sbinkertn@umich.eduSource('func_unit.cc')
1194484Sbinkertn@umich.eduSource('inteltrace.cc')
1204494Ssaidi@eecs.umich.eduSource('pc_event.cc')
121Source('quiesce_event.cc')
122Source('static_inst.cc')
123Source('simple_thread.cc')
124Source('thread_context.cc')
125Source('thread_state.cc')
126
127if env['FULL_SYSTEM']:
128    SimObject('IntrControl.py')
129
130    Source('intr_control.cc')
131    Source('profile.cc')
132
133    if env['TARGET_ISA'] == 'sparc':
134        SimObject('LegionTrace.py')
135        Source('legiontrace.cc')
136
137if env['TARGET_ISA'] == 'x86':
138    SimObject('NativeTrace.py')
139    Source('nativetrace.cc')
140
141if env['USE_CHECKER']:
142    Source('checker/cpu.cc')
143    TraceFlag('Checker')
144    checker_supports = False
145    for i in CheckerSupportedCPUList:
146        if i in env['CPU_MODELS']:
147            checker_supports = True
148    if not checker_supports:
149        print "Checker only supports CPU models",
150        for i in CheckerSupportedCPUList:
151            print i,
152        print ", please set USE_CHECKER=False or use one of those CPU models"
153        Exit(1)
154
155TraceFlag('Activity')
156TraceFlag('Commit')
157TraceFlag('Context')
158TraceFlag('Decode')
159TraceFlag('DynInst')
160TraceFlag('ExecEnable')
161TraceFlag('ExecCPSeq')
162TraceFlag('ExecEffAddr')
163TraceFlag('ExecFetchSeq')
164TraceFlag('ExecOpClass')
165TraceFlag('ExecRegDelta')
166TraceFlag('ExecResult')
167TraceFlag('ExecSpeculative')
168TraceFlag('ExecSymbol')
169TraceFlag('ExecThread')
170TraceFlag('ExecTicks')
171TraceFlag('ExecMicro')
172TraceFlag('ExecMacro')
173TraceFlag('Fetch')
174TraceFlag('IntrControl')
175TraceFlag('PCEvent')
176TraceFlag('Quiesce')
177
178CompoundFlag('Exec', [ 'ExecEnable', 'ExecTicks', 'ExecOpClass', 'ExecThread',
179    'ExecEffAddr', 'ExecResult', 'ExecSymbol', 'ExecMicro' ])
180CompoundFlag('ExecNoTicks', [ 'ExecEnable', 'ExecOpClass', 'ExecThread',
181    'ExecEffAddr', 'ExecResult', 'ExecMicro' ])
182