summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/SConscript73
-rw-r--r--arch/alpha/SConscript49
-rw-r--r--arch/alpha/alpha_linux_process.cc27
-rw-r--r--arch/alpha/ev5.cc10
-rwxr-xr-xarch/isa_parser.py60
-rw-r--r--arch/mips/SConscript50
-rw-r--r--arch/sparc/SConscript52
7 files changed, 199 insertions, 122 deletions
diff --git a/arch/SConscript b/arch/SConscript
index 2d8e34b7b..d237b0b1f 100644
--- a/arch/SConscript
+++ b/arch/SConscript
@@ -31,11 +31,17 @@ import os.path
# Import build environment variable from SConstruct.
Import('env')
+# Right now there are no source files immediately in this directory
+sources = []
+
+#################################################################
#
# ISA "switch header" generation.
#
# Auto-generate arch headers that include the right ISA-specific
# header based on the setting of THE_ISA preprocessor variable.
+#
+#################################################################
# List of headers to generate
isa_switch_hdrs = Split('''
@@ -72,3 +78,70 @@ switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string,
# Instantiate actions for each header
for hdr in isa_switch_hdrs:
env.Command(hdr, [], switch_hdr_action)
+
+#################################################################
+#
+# Include architecture-specific files.
+#
+#################################################################
+
+#
+# Build a SCons scanner for ISA files
+#
+import SCons.Scanner
+
+def ISAScan():
+ return SCons.Scanner.Classic("ISAScan",
+ "$ISASUFFIXES",
+ "SRCDIR",
+ '^[ \t]*##[ \t]*include[ \t]*"([^>"]+)"')
+
+def ISAPath(env, dir, target=None, source=None, a=None):
+ return (Dir(env['SRCDIR']), Dir('.'))
+
+iscan = Scanner(function = ISAScan().scan, skeys = [".isa", ".ISA"],
+ path_function = ISAPath)
+env.Append(SCANNERS = iscan)
+
+#
+# Now create a Builder object that uses isa_parser.py to generate C++
+# output from the ISA description (*.isa) files.
+#
+
+# Convert to File node to fix path
+isa_parser = File('isa_parser.py')
+cpu_models_file = File('#m5/cpu/cpu_models.py')
+
+# This sucks in the defintions of the CpuModel objects.
+execfile(cpu_models_file.srcnode().abspath)
+
+# Several files are generated from the ISA description.
+# We always get the basic decoder and header file.
+isa_desc_gen_files = Split('decoder.cc decoder.hh')
+# We also get an execute file for each selected CPU model.
+isa_desc_gen_files += [CpuModel.dict[cpu].filename
+ for cpu in env['CPU_MODELS']]
+
+# The emitter patches up the sources & targets to include the
+# autogenerated files as targets and isa parser itself as a source.
+def isa_desc_emitter(target, source, env):
+ return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
+
+# Pieces are in place, so create the builder.
+isa_desc_builder = Builder(action='$SOURCES $TARGET.dir $CPU_MODELS',
+ source_scanner = iscan,
+ emitter = isa_desc_emitter)
+
+env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
+
+#
+# Now include other ISA-specific sources from the ISA subdirectories.
+#
+
+isa = env['TARGET_ISA'] # someday this may be a list of ISAs
+
+# Let the target architecture define what additional sources it needs
+sources += SConscript(os.path.join(isa, 'SConscript'),
+ exports = 'env', duplicate = False)
+
+Return('sources')
diff --git a/arch/alpha/SConscript b/arch/alpha/SConscript
index a5ae77dac..050dfb9cf 100644
--- a/arch/alpha/SConscript
+++ b/arch/alpha/SConscript
@@ -43,40 +43,45 @@ Import('env')
###################################################
# Base sources used by all configurations.
-arch_base_sources = Split('''
- arch/alpha/decoder.cc
- arch/alpha/alpha_o3_exec.cc
- arch/alpha/fast_cpu_exec.cc
- arch/alpha/simple_cpu_exec.cc
- arch/alpha/full_cpu_exec.cc
- arch/alpha/faults.cc
- arch/alpha/isa_traits.cc
+base_sources = Split('''
+ faults.cc
+ isa_traits.cc
''')
# Full-system sources
-arch_full_system_sources = Split('''
- arch/alpha/alpha_memory.cc
- arch/alpha/arguments.cc
- arch/alpha/ev5.cc
- arch/alpha/osfpal.cc
- arch/alpha/stacktrace.cc
- arch/alpha/vtophys.cc
+full_system_sources = Split('''
+ alpha_memory.cc
+ arguments.cc
+ ev5.cc
+ osfpal.cc
+ stacktrace.cc
+ vtophys.cc
''')
# Syscall emulation (non-full-system) sources
-arch_syscall_emulation_sources = Split('''
- arch/alpha/alpha_common_syscall_emul.cc
- arch/alpha/alpha_linux_process.cc
- arch/alpha/alpha_tru64_process.cc
+syscall_emulation_sources = Split('''
+ alpha_common_syscall_emul.cc
+ alpha_linux_process.cc
+ alpha_tru64_process.cc
''')
# Set up complete list of sources based on configuration.
-sources = arch_base_sources
+sources = base_sources
if env['FULL_SYSTEM']:
- sources += arch_full_system_sources
+ sources += full_system_sources
else:
- sources += arch_syscall_emulation_sources
+ sources += syscall_emulation_sources
+
+# Convert file names to SCons File objects. This takes care of the
+# path relative to the top of the directory tree.
+sources = [File(s) for s in sources]
+
+# Add in files generated by the ISA description.
+isa_desc_files = env.ISADesc('isa/main.isa')
+# Only non-header files need to be compiled.
+isa_desc_sources = [f for f in isa_desc_files if not f.path.endswith('.hh')]
+sources += isa_desc_sources
Return('sources')
diff --git a/arch/alpha/alpha_linux_process.cc b/arch/alpha/alpha_linux_process.cc
index 783b189cc..16ebcca7b 100644
--- a/arch/alpha/alpha_linux_process.cc
+++ b/arch/alpha/alpha_linux_process.cc
@@ -41,6 +41,31 @@
using namespace std;
using namespace AlphaISA;
+/// Target pipe() handler. Even though this is a generic Posix call,
+/// the Alpha return convention is funky, so that makes it
+/// Alpha-specific.
+SyscallReturn
+pipeFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ int fds[2], sim_fds[2];
+ int pipe_retval = pipe(fds);
+
+ if (pipe_retval < 0) {
+ // error
+ return pipe_retval;
+ }
+
+ sim_fds[0] = process->alloc_fd(fds[0]);
+ sim_fds[1] = process->alloc_fd(fds[1]);
+
+ // Alpha Linux convention for pipe() is that fd[0] is returned as
+ // the return value of the function, and fd[1] is returned in r20.
+ xc->regs.intRegFile[20] = sim_fds[1];
+ return sim_fds[0];
+}
+
+
/// Target uname() handler.
static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, Process *process,
@@ -159,7 +184,7 @@ SyscallDesc AlphaLinuxProcess::syscallDescs[] = {
/* 39 */ SyscallDesc("setpgid", unimplementedFunc),
/* 40 */ SyscallDesc("osf_old_lstat", unimplementedFunc),
/* 41 */ SyscallDesc("dup", unimplementedFunc),
- /* 42 */ SyscallDesc("pipe", unimplementedFunc),
+ /* 42 */ SyscallDesc("pipe", pipeFunc),
/* 43 */ SyscallDesc("osf_set_program_attributes", unimplementedFunc),
/* 44 */ SyscallDesc("osf_profil", unimplementedFunc),
/* 45 */ SyscallDesc("open", openFunc<Linux>),
diff --git a/arch/alpha/ev5.cc b/arch/alpha/ev5.cc
index 4777907e0..14b87b16f 100644
--- a/arch/alpha/ev5.cc
+++ b/arch/alpha/ev5.cc
@@ -70,12 +70,15 @@ AlphaISA::swap_palshadow(RegFile *regs, bool use_shadow)
// Machine dependent functions
//
void
-AlphaISA::initCPU(RegFile *regs)
+AlphaISA::initCPU(RegFile *regs, int cpuId)
{
- initIPRs(regs);
+ initIPRs(regs, cpuId);
// CPU comes up with PAL regs enabled
swap_palshadow(regs, true);
+ regs->intRegFile[16] = cpuId;
+ regs->intRegFile[0] = cpuId;
+
regs->pc = regs->ipr[IPR_PAL_BASE] + fault_addr(ResetFault);
regs->npc = regs->pc + sizeof(MachInst);
}
@@ -106,13 +109,14 @@ const int AlphaISA::reg_redir[AlphaISA::NumIntRegs] = {
//
//
void
-AlphaISA::initIPRs(RegFile *regs)
+AlphaISA::initIPRs(RegFile *regs, int cpuId)
{
uint64_t *ipr = regs->ipr;
bzero((char *)ipr, NumInternalProcRegs * sizeof(InternalProcReg));
ipr[IPR_PAL_BASE] = PalBase;
ipr[IPR_MCSR] = 0x6;
+ ipr[IPR_PALtemp16] = cpuId;
}
diff --git a/arch/isa_parser.py b/arch/isa_parser.py
index 0d18f4d89..6508ca02a 100755
--- a/arch/isa_parser.py
+++ b/arch/isa_parser.py
@@ -712,44 +712,6 @@ yacc.yacc()
#
#####################################################################
-################
-# CpuModel class
-#
-# The CpuModel class encapsulates everything we need to know about a
-# particular CPU model.
-
-class CpuModel:
- # List of all CPU models. Accessible as CpuModel.list.
- list = []
-
- # Constructor. Automatically adds models to CpuModel.list.
- def __init__(self, name, filename, includes, strings):
- self.name = name
- self.filename = filename # filename for output exec code
- self.includes = includes # include files needed in exec file
- # The 'strings' dict holds all the per-CPU symbols we can
- # substitute into templates etc.
- self.strings = strings
- # Add self to list.
- CpuModel.list.append(self)
-
-# Define CPU models. The following lines should contain the only
-# CPU-model-specific information in this file. Note that the ISA
-# description itself should have *no* CPU-model-specific content.
-CpuModel('SimpleCPU', 'simple_cpu_exec.cc',
- '#include "cpu/simple/cpu.hh"',
- { 'CPU_exec_context': 'SimpleCPU' })
-CpuModel('FastCPU', 'fast_cpu_exec.cc',
- '#include "cpu/fast/cpu.hh"',
- { 'CPU_exec_context': 'FastCPU' })
-CpuModel('FullCPU', 'full_cpu_exec.cc',
- '#include "encumbered/cpu/full/dyn_inst.hh"',
- { 'CPU_exec_context': 'DynInst' })
-
-CpuModel('AlphaFullCPU', 'alpha_o3_exec.cc',
- '#include "cpu/o3/alpha_dyn_inst.hh"',
- { 'CPU_exec_context': 'AlphaDynInst<AlphaSimpleImpl>' })
-
# Expand template with CPU-specific references into a dictionary with
# an entry for each CPU model name. The entry key is the model name
# and the corresponding value is the template with the CPU-specific
@@ -758,7 +720,7 @@ def expand_cpu_symbols_to_dict(template):
# Protect '%'s that don't go with CPU-specific terms
t = re.sub(r'%(?!\(CPU_)', '%%', template)
result = {}
- for cpu in CpuModel.list:
+ for cpu in cpu_models:
result[cpu.name] = t % cpu.strings
return result
@@ -817,7 +779,7 @@ class GenCode:
# concatenates all the individual strings in the operands.
def __add__(self, other):
exec_output = {}
- for cpu in CpuModel.list:
+ for cpu in cpu_models:
n = cpu.name
exec_output[n] = self.exec_output[n] + other.exec_output[n]
return GenCode(self.header_output + other.header_output,
@@ -831,7 +793,7 @@ class GenCode:
self.header_output = pre + self.header_output
self.decoder_output = pre + self.decoder_output
self.decode_block = pre + self.decode_block
- for cpu in CpuModel.list:
+ for cpu in cpu_models:
self.exec_output[cpu.name] = pre + self.exec_output[cpu.name]
# Wrap the decode block in a pair of strings (e.g., 'case foo:'
@@ -1752,7 +1714,7 @@ def preprocess_isa_desc(isa_desc):
#
# Read in and parse the ISA description.
#
-def parse_isa_desc(isa_desc_file, output_dir, include_path):
+def parse_isa_desc(isa_desc_file, output_dir):
# set a global var for the input filename... used in error messages
global input_filename
input_filename = isa_desc_file
@@ -1782,7 +1744,7 @@ def parse_isa_desc(isa_desc_file, output_dir, include_path):
update_if_needed(output_dir + '/decoder.hh', file_template % vars())
# generate decoder.cc
- includes = '#include "%s/decoder.hh"' % include_path
+ includes = '#include "decoder.hh"'
global_output = global_code.decoder_output
namespace_output = namespace_code.decoder_output
# namespace_output += namespace_code.decode_block
@@ -1790,8 +1752,8 @@ def parse_isa_desc(isa_desc_file, output_dir, include_path):
update_if_needed(output_dir + '/decoder.cc', file_template % vars())
# generate per-cpu exec files
- for cpu in CpuModel.list:
- includes = '#include "%s/decoder.hh"\n' % include_path
+ for cpu in cpu_models:
+ includes = '#include "decoder.hh"\n'
includes += cpu.includes
global_output = global_code.exec_output[cpu.name]
namespace_output = namespace_code.exec_output[cpu.name]
@@ -1799,6 +1761,12 @@ def parse_isa_desc(isa_desc_file, output_dir, include_path):
update_if_needed(output_dir + '/' + cpu.filename,
file_template % vars())
+# global list of CpuModel objects (see cpu_models.py)
+cpu_models = []
+
# Called as script: get args from command line.
+# Args are: <path to cpu_models.py> <isa desc file> <output dir> <cpu models>
if __name__ == '__main__':
- parse_isa_desc(sys.argv[1], sys.argv[2], sys.argv[3])
+ execfile(sys.argv[1]) # read in CpuModel definitions
+ cpu_models = [CpuModel.dict[cpu] for cpu in sys.argv[4:]]
+ parse_isa_desc(sys.argv[2], sys.argv[3])
diff --git a/arch/mips/SConscript b/arch/mips/SConscript
index a6af91669..b8efa7ef9 100644
--- a/arch/mips/SConscript
+++ b/arch/mips/SConscript
@@ -40,42 +40,44 @@ Import('env')
###################################################
# Base sources used by all configurations.
-arch_base_sources = Split('''
- arch/mips/decoder.cc
- arch/mips/mips_o3_exec.cc
- arch/mips/fast_cpu_exec.cc
- arch/mips/simple_cpu_exec.cc
- arch/mips/full_cpu_exec.cc
- arch/mips/faults.cc
- arch/mips/isa_traits.cc
+base_sources = Split('''
+ faults.cc
+ isa_traits.cc
''')
# Full-system sources
-arch_full_system_sources = Split('''
- arch/mips/memory.cc
- arch/mips/arguments.cc
- arch/mips/mips34k.cc
- arch/mips/osfpal.cc
- arch/mips/stacktrace.cc
- arch/mips/vtophys.cc
+full_system_sources = Split('''
+ memory.cc
+ arguments.cc
+ mips34k.cc
+ osfpal.cc
+ stacktrace.cc
+ vtophys.cc
''')
# Syscall emulation (non-full-system) sources
-arch_syscall_emulation_sources = Split('''
- arch/mips/common_syscall_emul.cc
- arch/mips/linux_process.cc
- arch/mips/tru64_process.cc
+syscall_emulation_sources = Split('''
+ common_syscall_emul.cc
+ linux_process.cc
+ tru64_process.cc
''')
# Set up complete list of sources based on configuration.
-sources = arch_base_sources
+sources = base_sources
if env['FULL_SYSTEM']:
- sources += arch_full_system_sources
+ sources += full_system_sources
else:
- sources += arch_syscall_emulation_sources
+ sources += syscall_emulation_sources
-for opt in env.ExportOptions:
- env.ConfigFile(opt)
+# Convert file names to SCons File objects. This takes care of the
+# path relative to the top of the directory tree.
+sources = [File(s) for s in sources]
+
+# Add in files generated by the ISA description.
+isa_desc_files = env.ISADesc('isa/main.isa')
+# Only non-header files need to be compiled.
+isa_desc_sources = [f for f in isa_desc_files if not f.path.endswith('.hh')]
+sources += isa_desc_sources
Return('sources')
diff --git a/arch/sparc/SConscript b/arch/sparc/SConscript
index d8a3749a1..fea31fd5d 100644
--- a/arch/sparc/SConscript
+++ b/arch/sparc/SConscript
@@ -40,43 +40,43 @@ Import('env')
###################################################
# Base sources used by all configurations.
-arch_base_sources = Split('''
- arch/sparc/decoder.cc
- arch/sparc/alpha_o3_exec.cc
- arch/sparc/fast_cpu_exec.cc
- arch/sparc/simple_cpu_exec.cc
- arch/sparc/full_cpu_exec.cc
- arch/sparc/faults.cc
- arch/sparc/isa_traits.cc
+base_sources = Split('''
+ faults.cc
+ isa_traits.cc
''')
# Full-system sources
-arch_full_system_sources = Split('''
- arch/sparc/alpha_memory.cc
- arch/sparc/arguments.cc
- arch/sparc/ev5.cc
- arch/sparc/osfpal.cc
- arch/sparc/stacktrace.cc
- arch/sparc/vtophys.cc
+full_system_sources = Split('''
+ alpha_memory.cc
+ arguments.cc
+ ev5.cc
+ osfpal.cc
+ stacktrace.cc
+ vtophys.cc
''')
# Syscall emulation (non-full-system) sources
-arch_syscall_emulation_sources = Split('''
- arch/sparc/alpha_common_syscall_emul.cc
- arch/sparc/alpha_linux_process.cc
- arch/sparc/alpha_tru64_process.cc
+syscall_emulation_sources = Split('''
+ alpha_common_syscall_emul.cc
+ alpha_linux_process.cc
+ alpha_tru64_process.cc
''')
-sources = arch_base_sources
+sources = base_sources
if env['FULL_SYSTEM']:
- sources += arch_full_system_sources
- if env['ALPHA_TLASER']:
- sources += arch_turbolaser_sources
+ sources += full_system_sources
else:
- sources += arch_syscall_emulation_sources
+ sources += syscall_emulation_sources
-for opt in env.ExportOptions:
- env.ConfigFile(opt)
+# Convert file names to SCons File objects. This takes care of the
+# path relative to the top of the directory tree.
+sources = [File(s) for s in sources]
+
+# Add in files generated by the ISA description.
+isa_desc_files = env.ISADesc('isa/main.isa')
+# Only non-header files need to be compiled.
+isa_desc_sources = [f for f in isa_desc_files if not f.path.endswith('.hh')]
+sources += isa_desc_sources
Return('sources')