SConscript revision 4484
12929Sktlim@umich.edu# -*- mode:python -*-
22929Sktlim@umich.edu
32932Sktlim@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
42929Sktlim@umich.edu# All rights reserved.
52929Sktlim@umich.edu#
62929Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without
72929Sktlim@umich.edu# modification, are permitted provided that the following conditions are
82929Sktlim@umich.edu# met: redistributions of source code must retain the above copyright
92929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer;
102929Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright
112929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the
122929Sktlim@umich.edu# documentation and/or other materials provided with the distribution;
132929Sktlim@umich.edu# neither the name of the copyright holders nor the names of its
142929Sktlim@umich.edu# contributors may be used to endorse or promote products derived from
152929Sktlim@umich.edu# this software without specific prior written permission.
162929Sktlim@umich.edu#
172929Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182929Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192929Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202929Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212929Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222929Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232929Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242929Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252929Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262929Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272929Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282932Sktlim@umich.edu#
292932Sktlim@umich.edu# Authors: Steve Reinhardt
302932Sktlim@umich.edu
312929Sktlim@umich.eduImport('*')
326007Ssteve.reinhardt@amd.com
332929Sktlim@umich.edu#################################################################
342929Sktlim@umich.edu#
352929Sktlim@umich.edu# Generate StaticInst execute() method signatures.
362929Sktlim@umich.edu#
372929Sktlim@umich.edu# There must be one signature for each CPU model compiled in.
382929Sktlim@umich.edu# Since the set of compiled-in models is flexible, we generate a
392929Sktlim@umich.edu# header containing the appropriate set of signatures on the fly.
402929Sktlim@umich.edu#
412929Sktlim@umich.edu#################################################################
422929Sktlim@umich.edu
432929Sktlim@umich.edu# CPU model-specific data is contained in cpu_models.py
442929Sktlim@umich.edu# Convert to SCons File node to get path handling
452929Sktlim@umich.edumodels_db = File('cpu_models.py')
462929Sktlim@umich.edu# slurp in contents of file
476007Ssteve.reinhardt@amd.comexecfile(models_db.srcnode().abspath)
486007Ssteve.reinhardt@amd.com
496007Ssteve.reinhardt@amd.com# Template for execute() signature.
506007Ssteve.reinhardt@amd.comexec_sig_template = '''
516007Ssteve.reinhardt@amd.comvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
526007Ssteve.reinhardt@amd.comvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
536007Ssteve.reinhardt@amd.com{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
546007Ssteve.reinhardt@amd.comvirtual Fault completeAcc(Packet *pkt, %s *xc,
556007Ssteve.reinhardt@amd.com                          Trace::InstRecord *traceData) const
566007Ssteve.reinhardt@amd.com{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
576007Ssteve.reinhardt@amd.com'''
586007Ssteve.reinhardt@amd.com
596007Ssteve.reinhardt@amd.commem_ini_sig_template = '''
606007Ssteve.reinhardt@amd.comvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
616007Ssteve.reinhardt@amd.com'''
626007Ssteve.reinhardt@amd.com
636007Ssteve.reinhardt@amd.commem_comp_sig_template = '''
646007Ssteve.reinhardt@amd.comvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
656007Ssteve.reinhardt@amd.com'''
666007Ssteve.reinhardt@amd.com
676007Ssteve.reinhardt@amd.com# Generate a temporary CPU list, including the CheckerCPU if
686007Ssteve.reinhardt@amd.com# it's enabled.  This isn't used for anything else other than StaticInst
696007Ssteve.reinhardt@amd.com# headers.
706007Ssteve.reinhardt@amd.comtemp_cpu_list = env['CPU_MODELS'][:]
716007Ssteve.reinhardt@amd.com
726007Ssteve.reinhardt@amd.comif env['USE_CHECKER']:
736007Ssteve.reinhardt@amd.com    temp_cpu_list.append('CheckerCPU')
746007Ssteve.reinhardt@amd.com
756007Ssteve.reinhardt@amd.com# Generate header.  
762929Sktlim@umich.edudef gen_cpu_exec_signatures(target, source, env):
772929Sktlim@umich.edu    f = open(str(target[0]), 'w')
782929Sktlim@umich.edu    print >> f, '''
796007Ssteve.reinhardt@amd.com#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
806007Ssteve.reinhardt@amd.com#define __CPU_STATIC_INST_EXEC_SIGS_HH__
816007Ssteve.reinhardt@amd.com'''
826007Ssteve.reinhardt@amd.com    for cpu in temp_cpu_list:
836007Ssteve.reinhardt@amd.com        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
846007Ssteve.reinhardt@amd.com        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
852929Sktlim@umich.edu    print >> f, '''
862929Sktlim@umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
872929Sktlim@umich.edu'''
882929Sktlim@umich.edu
892929Sktlim@umich.edu# Generate string that gets printed when header is rebuilt
906011Ssteve.reinhardt@amd.comdef gen_sigs_string(target, source, env):
916007Ssteve.reinhardt@amd.com    return "Generating static_inst_exec_sigs.hh: " \
926007Ssteve.reinhardt@amd.com           + ', '.join(temp_cpu_list)
936007Ssteve.reinhardt@amd.com
946007Ssteve.reinhardt@amd.com# Add command to generate header to environment.
956007Ssteve.reinhardt@amd.comenv.Command('static_inst_exec_sigs.hh', models_db,
966007Ssteve.reinhardt@amd.com            Action(gen_cpu_exec_signatures, gen_sigs_string,
976007Ssteve.reinhardt@amd.com                   varlist = temp_cpu_list))
986007Ssteve.reinhardt@amd.com
996007Ssteve.reinhardt@amd.comenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1006007Ssteve.reinhardt@amd.comenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1016007Ssteve.reinhardt@amd.com
1026007Ssteve.reinhardt@amd.com# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1036007Ssteve.reinhardt@amd.com# and one of these are not being used.
1046007Ssteve.reinhardt@amd.comCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1056011Ssteve.reinhardt@amd.com
1066007Ssteve.reinhardt@amd.comSource('activity.cc')
1076007Ssteve.reinhardt@amd.comSource('base.cc')
1086007Ssteve.reinhardt@amd.comSource('cpuevent.cc')
1096007Ssteve.reinhardt@amd.comSource('exetrace.cc')
1106007Ssteve.reinhardt@amd.comSource('func_unit.cc')
1116007Ssteve.reinhardt@amd.comSource('op_class.cc')
1126007Ssteve.reinhardt@amd.comSource('pc_event.cc')
1136011Ssteve.reinhardt@amd.comSource('quiesce_event.cc')
1146007Ssteve.reinhardt@amd.comSource('static_inst.cc')
1156007Ssteve.reinhardt@amd.comSource('simple_thread.cc')
1166007Ssteve.reinhardt@amd.comSource('thread_state.cc')
1176007Ssteve.reinhardt@amd.com
1186007Ssteve.reinhardt@amd.comif env['FULL_SYSTEM']:
1196007Ssteve.reinhardt@amd.com    Source('intr_control.cc')
1206007Ssteve.reinhardt@amd.com    Source('profile.cc')
1216011Ssteve.reinhardt@amd.com
1226007Ssteve.reinhardt@amd.comif env['USE_CHECKER']:
1236007Ssteve.reinhardt@amd.com    Source('checker/cpu.cc')
1246007Ssteve.reinhardt@amd.com    checker_supports = False
1256007Ssteve.reinhardt@amd.com    for i in CheckerSupportedCPUList:
1266007Ssteve.reinhardt@amd.com        if i in env['CPU_MODELS']:
1276008Ssteve.reinhardt@amd.com            checker_supports = True
1286007Ssteve.reinhardt@amd.com    if not checker_supports:
1296008Ssteve.reinhardt@amd.com        print "Checker only supports CPU models",
1306008Ssteve.reinhardt@amd.com        for i in CheckerSupportedCPUList:
1316008Ssteve.reinhardt@amd.com            print i,
1326008Ssteve.reinhardt@amd.com        print ", please set USE_CHECKER=False or use one of those CPU models"
1336008Ssteve.reinhardt@amd.com        Exit(1)
1346008Ssteve.reinhardt@amd.com