SConscript revision 4382
1955SN/A# -*- mode:python -*- 2955SN/A 31762SN/A# Copyright (c) 2006 The Regents of The University of Michigan 4955SN/A# All rights reserved. 5955SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 294762Snate@binkert.org# Authors: Steve Reinhardt 30955SN/A 315522Snate@binkert.orgImport('*') 324762Snate@binkert.org 335522Snate@binkert.org################################################################# 34955SN/A# 355522Snate@binkert.org# Generate StaticInst execute() method signatures. 36955SN/A# 375522Snate@binkert.org# There must be one signature for each CPU model compiled in. 384202Sbinkertn@umich.edu# Since the set of compiled-in models is flexible, we generate a 395742Snate@binkert.org# header containing the appropriate set of signatures on the fly. 40955SN/A# 414381Sbinkertn@umich.edu################################################################# 424381Sbinkertn@umich.edu 43955SN/A# CPU model-specific data is contained in cpu_models.py 44955SN/A# Convert to SCons File node to get path handling 45955SN/Amodels_db = File('cpu_models.py') 464202Sbinkertn@umich.edu# slurp in contents of file 47955SN/Aexecfile(models_db.srcnode().abspath) 484382Sbinkertn@umich.edu 494382Sbinkertn@umich.edu# Template for execute() signature. 504382Sbinkertn@umich.eduexec_sig_template = ''' 515517Snate@binkert.orgvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 525517Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const 534762Snate@binkert.org{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN }; 544762Snate@binkert.orgvirtual Fault completeAcc(Packet *pkt, %s *xc, 554762Snate@binkert.org Trace::InstRecord *traceData) const 564762Snate@binkert.org{ panic("completeAcc not defined!"); M5_DUMMY_RETURN }; 574762Snate@binkert.org''' 584762Snate@binkert.org 594762Snate@binkert.orgmem_ini_sig_template = ''' 604762Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN }; 614762Snate@binkert.org''' 624762Snate@binkert.org 635522Snate@binkert.orgmem_comp_sig_template = ''' 645604Snate@binkert.orgvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN }; 655604Snate@binkert.org''' 665604Snate@binkert.org 674762Snate@binkert.org# Generate a temporary CPU list, including the CheckerCPU if 684762Snate@binkert.org# it's enabled. This isn't used for anything else other than StaticInst 694762Snate@binkert.org# headers. 705522Snate@binkert.orgtemp_cpu_list = env['CPU_MODELS'][:] 715522Snate@binkert.org 725522Snate@binkert.orgif env['USE_CHECKER']: 735522Snate@binkert.org temp_cpu_list.append('CheckerCPU') 745604Snate@binkert.org 755604Snate@binkert.org# Generate header. 764762Snate@binkert.orgdef gen_cpu_exec_signatures(target, source, env): 774762Snate@binkert.org f = open(str(target[0]), 'w') 784762Snate@binkert.org print >> f, ''' 794762Snate@binkert.org#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 805522Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 814762Snate@binkert.org''' 824762Snate@binkert.org for cpu in temp_cpu_list: 835604Snate@binkert.org xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 845604Snate@binkert.org print >> f, exec_sig_template % (xc_type, xc_type, xc_type) 855604Snate@binkert.org print >> f, ''' 865604Snate@binkert.org#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 875604Snate@binkert.org''' 885604Snate@binkert.org 894762Snate@binkert.org# Generate string that gets printed when header is rebuilt 904762Snate@binkert.orgdef gen_sigs_string(target, source, env): 914762Snate@binkert.org return "Generating static_inst_exec_sigs.hh: " \ 924762Snate@binkert.org + ', '.join(temp_cpu_list) 935604Snate@binkert.org 944762Snate@binkert.org# Add command to generate header to environment. 955522Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db, 965522Snate@binkert.org Action(gen_cpu_exec_signatures, gen_sigs_string, 975522Snate@binkert.org varlist = temp_cpu_list)) 984762Snate@binkert.org 994382Sbinkertn@umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER'])) 1004762Snate@binkert.orgenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS'])) 1014382Sbinkertn@umich.edu 1025522Snate@binkert.org# List of suppported CPUs by the Checker. Errors out if USE_CHECKER=True 1034381Sbinkertn@umich.edu# and one of these are not being used. 1045522Snate@binkert.orgCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU'] 1054762Snate@binkert.org 1064762Snate@binkert.orgSource('activity.cc') 1074762Snate@binkert.orgSource('base.cc') 1085522Snate@binkert.orgSource('cpuevent.cc') 1095522Snate@binkert.orgSource('exetrace.cc') 1105522Snate@binkert.orgSource('func_unit.cc') 1115522Snate@binkert.orgSource('op_class.cc') 1125522Snate@binkert.orgSource('pc_event.cc') 1135522Snate@binkert.orgSource('quiesce_event.cc') 1145522Snate@binkert.orgSource('static_inst.cc') 1155522Snate@binkert.orgSource('simple_thread.cc') 1165522Snate@binkert.orgSource('thread_state.cc') 1174762Snate@binkert.org 1184762Snate@binkert.orgif env['FULL_SYSTEM']: 1194762Snate@binkert.org Source('intr_control.cc') 1204762Snate@binkert.org Source('profile.cc') 1214762Snate@binkert.org 1224762Snate@binkert.orgif env['USE_CHECKER']: 1234762Snate@binkert.org Source('checker/cpu.cc') 1244762Snate@binkert.org checker_supports = False 1254762Snate@binkert.org for i in CheckerSupportedCPUList: 1264762Snate@binkert.org if i in env['CPU_MODELS']: 1274762Snate@binkert.org checker_supports = True 1284762Snate@binkert.org if not checker_supports: 1294762Snate@binkert.org print "Checker only supports CPU models", 1304762Snate@binkert.org for i in CheckerSupportedCPUList: 1314762Snate@binkert.org print i, 1324762Snate@binkert.org print ", please set USE_CHECKER=False or use one of those CPU models" 1334762Snate@binkert.org Exit(1) 1344762Snate@binkert.org