SConscript revision 4381
15647Sgblack@eecs.umich.edu# -*- mode:python -*-
25647Sgblack@eecs.umich.edu
35647Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
45647Sgblack@eecs.umich.edu# All rights reserved.
57087Snate@binkert.org#
67087Snate@binkert.org# Redistribution and use in source and binary forms, with or without
77087Snate@binkert.org# modification, are permitted provided that the following conditions are
87087Snate@binkert.org# met: redistributions of source code must retain the above copyright
97087Snate@binkert.org# notice, this list of conditions and the following disclaimer;
107087Snate@binkert.org# redistributions in binary form must reproduce the above copyright
117087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
127087Snate@binkert.org# documentation and/or other materials provided with the distribution;
135647Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
147087Snate@binkert.org# contributors may be used to endorse or promote products derived from
157087Snate@binkert.org# this software without specific prior written permission.
167087Snate@binkert.org#
177087Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
187087Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
197087Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
207087Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
217087Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
225647Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
237087Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245647Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255647Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265647Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
275647Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
285647Sgblack@eecs.umich.edu#
295647Sgblack@eecs.umich.edu# Authors: Steve Reinhardt
305647Sgblack@eecs.umich.edu
315647Sgblack@eecs.umich.eduImport('*')
325647Sgblack@eecs.umich.edu
335647Sgblack@eecs.umich.edu#################################################################
345647Sgblack@eecs.umich.edu#
355647Sgblack@eecs.umich.edu# Generate StaticInst execute() method signatures.
365647Sgblack@eecs.umich.edu#
375647Sgblack@eecs.umich.edu# There must be one signature for each CPU model compiled in.
385647Sgblack@eecs.umich.edu# Since the set of compiled-in models is flexible, we generate a
395647Sgblack@eecs.umich.edu# header containing the appropriate set of signatures on the fly.
405647Sgblack@eecs.umich.edu#
415654Sgblack@eecs.umich.edu#################################################################
427629Sgblack@eecs.umich.edu
435647Sgblack@eecs.umich.edu# CPU model-specific data is contained in cpu_models.py
446137Sgblack@eecs.umich.edu# Convert to SCons File node to get path handling
456137Sgblack@eecs.umich.edumodels_db = File('cpu_models.py')
466137Sgblack@eecs.umich.edu# slurp in contents of file
475654Sgblack@eecs.umich.eduexecfile(models_db.srcnode().abspath)
486046Sgblack@eecs.umich.edu
495647Sgblack@eecs.umich.edu# Template for execute() signature.
505648Sgblack@eecs.umich.eduexec_sig_template = '''
515648Sgblack@eecs.umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
525647Sgblack@eecs.umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
535647Sgblack@eecs.umich.edu{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
545647Sgblack@eecs.umich.eduvirtual Fault completeAcc(Packet *pkt, %s *xc,
555647Sgblack@eecs.umich.edu                          Trace::InstRecord *traceData) const
565647Sgblack@eecs.umich.edu{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
575647Sgblack@eecs.umich.edu'''
585647Sgblack@eecs.umich.edu
595647Sgblack@eecs.umich.edumem_ini_sig_template = '''
605647Sgblack@eecs.umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
615648Sgblack@eecs.umich.edu'''
625647Sgblack@eecs.umich.edu
635648Sgblack@eecs.umich.edumem_comp_sig_template = '''
645648Sgblack@eecs.umich.eduvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
655648Sgblack@eecs.umich.edu'''
665648Sgblack@eecs.umich.edu
675648Sgblack@eecs.umich.edu# Generate a temporary CPU list, including the CheckerCPU if
685648Sgblack@eecs.umich.edu# it's enabled.  This isn't used for anything else other than StaticInst
695648Sgblack@eecs.umich.edu# headers.
705648Sgblack@eecs.umich.edutemp_cpu_list = env['CPU_MODELS'][:]
715648Sgblack@eecs.umich.edu
725648Sgblack@eecs.umich.eduif env['USE_CHECKER']:
735648Sgblack@eecs.umich.edu    temp_cpu_list.append('CheckerCPU')
745648Sgblack@eecs.umich.edu
755648Sgblack@eecs.umich.edu# Generate header.  
765648Sgblack@eecs.umich.edudef gen_cpu_exec_signatures(target, source, env):
775648Sgblack@eecs.umich.edu    f = open(str(target[0]), 'w')
785648Sgblack@eecs.umich.edu    print >> f, '''
795648Sgblack@eecs.umich.edu#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
805648Sgblack@eecs.umich.edu#define __CPU_STATIC_INST_EXEC_SIGS_HH__
815648Sgblack@eecs.umich.edu'''
825648Sgblack@eecs.umich.edu    for cpu in temp_cpu_list:
835648Sgblack@eecs.umich.edu        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
845648Sgblack@eecs.umich.edu        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
855648Sgblack@eecs.umich.edu    print >> f, '''
865648Sgblack@eecs.umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
875648Sgblack@eecs.umich.edu'''
885648Sgblack@eecs.umich.edu
895648Sgblack@eecs.umich.edu# Generate string that gets printed when header is rebuilt
905648Sgblack@eecs.umich.edudef gen_sigs_string(target, source, env):
915648Sgblack@eecs.umich.edu    return "Generating static_inst_exec_sigs.hh: " \
925648Sgblack@eecs.umich.edu           + ', '.join(temp_cpu_list)
935648Sgblack@eecs.umich.edu
945648Sgblack@eecs.umich.edu# Add command to generate header to environment.
955648Sgblack@eecs.umich.eduenv.Command('static_inst_exec_sigs.hh', models_db,
965648Sgblack@eecs.umich.edu            Action(gen_cpu_exec_signatures, gen_sigs_string,
975648Sgblack@eecs.umich.edu                   varlist = temp_cpu_list))
985648Sgblack@eecs.umich.edu
995648Sgblack@eecs.umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1005648Sgblack@eecs.umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1015648Sgblack@eecs.umich.edu
1025648Sgblack@eecs.umich.edu# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1035648Sgblack@eecs.umich.edu# and one of these are not being used.
1045648Sgblack@eecs.umich.eduCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1055648Sgblack@eecs.umich.edu
1065648Sgblack@eecs.umich.eduSource('activity.cc')
1075648Sgblack@eecs.umich.eduSource('base.cc')
1085648Sgblack@eecs.umich.eduSource('cpuevent.cc')
1095648Sgblack@eecs.umich.eduSource('exetrace.cc')
1105648Sgblack@eecs.umich.eduSource('func_unit.cc')
1115648Sgblack@eecs.umich.eduSource('op_class.cc')
1125648Sgblack@eecs.umich.eduSource('pc_event.cc')
1135648Sgblack@eecs.umich.eduSource('quiesce_event.cc')
1145648Sgblack@eecs.umich.eduSource('static_inst.cc')
1155648Sgblack@eecs.umich.eduSource('simple_thread.cc')
1165648Sgblack@eecs.umich.eduSource('thread_state.cc')
1175648Sgblack@eecs.umich.edu
1185648Sgblack@eecs.umich.eduif env['FULL_SYSTEM']:
1195648Sgblack@eecs.umich.edu    Source('intr_control.cc')
1205648Sgblack@eecs.umich.edu    Source('profile.cc')
1215648Sgblack@eecs.umich.edu
1225648Sgblack@eecs.umich.eduif env['USE_CHECKER']:
1235648Sgblack@eecs.umich.edu    Source('checker/cpu.cc')
1245648Sgblack@eecs.umich.edu    checker_supports = False
1255648Sgblack@eecs.umich.edu    for i in CheckerSupportedCPUList:
1265648Sgblack@eecs.umich.edu        if i in env['CPU_MODELS']:
1275648Sgblack@eecs.umich.edu            checker_supports = True
1285648Sgblack@eecs.umich.edu    if not checker_supports:
1295648Sgblack@eecs.umich.edu        print "Checker only supports CPU models",
1305648Sgblack@eecs.umich.edu        for i in CheckerSupportedCPUList:
1315648Sgblack@eecs.umich.edu            print i,
1325648Sgblack@eecs.umich.edu        print ", please set USE_CHECKER=False or use one of those CPU models"
1335648Sgblack@eecs.umich.edu        Exit(1)
1345648Sgblack@eecs.umich.edu