Adding gem5 source to svn.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1819 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
40
simulators/gem5/src/arch/mips/BISystem.py
Executable file
40
simulators/gem5/src/arch/mips/BISystem.py
Executable file
@ -0,0 +1,40 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Jaidev Patwardhan
|
||||
|
||||
from m5.defines import buildEnv
|
||||
|
||||
from System import *
|
||||
|
||||
class BareIronMipsSystem(MipsSystem):
|
||||
type = 'BareIronMipsSystem'
|
||||
system_type = 34
|
||||
system_rev = 1 << 10
|
||||
hex_file_name = Param.String('test.hex',"hex file that contains [address,data] pairs")
|
||||
|
||||
92
simulators/gem5/src/arch/mips/MipsCPU.py
Normal file
92
simulators/gem5/src/arch/mips/MipsCPU.py
Normal file
@ -0,0 +1,92 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Jaidev Patwardhan
|
||||
# Korey Sewell
|
||||
|
||||
from m5.defines import buildEnv
|
||||
from m5.params import *
|
||||
|
||||
from BaseCPU import BaseCPU
|
||||
|
||||
class BaseMipsCPU(BaseCPU)
|
||||
if buildEnv['TARGET_ISA'] == 'mips':
|
||||
CP0_IntCtl_IPTI = Param.Unsigned(0,"No Description")
|
||||
CP0_IntCtl_IPPCI = Param.Unsigned(0,"No Description")
|
||||
CP0_SrsCtl_HSS = Param.Unsigned(0,"No Description")
|
||||
CP0_EBase_CPUNum = Param.Unsigned(0,"No Description")
|
||||
CP0_PRId_CompanyOptions = Param.Unsigned(0,"Company Options in Processor ID Register")
|
||||
CP0_PRId_CompanyID = Param.Unsigned(0,"Company Identifier in Processor ID Register")
|
||||
CP0_PRId_ProcessorID = Param.Unsigned(1,"Processor ID (0=>Not MIPS32/64 Processor, 1=>MIPS, 2-255 => Other Company")
|
||||
CP0_PRId_Revision = Param.Unsigned(0,"Processor Revision Number in Processor ID Register")
|
||||
CP0_Config_BE = Param.Unsigned(0,"Big Endian?")
|
||||
CP0_Config_AT = Param.Unsigned(0,"No Description")
|
||||
CP0_Config_AR = Param.Unsigned(0,"No Description")
|
||||
CP0_Config_MT = Param.Unsigned(0,"No Description")
|
||||
CP0_Config_VI = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_M = Param.Unsigned(0,"Config2 Implemented?")
|
||||
CP0_Config1_MMU = Param.Unsigned(0,"MMU Type")
|
||||
CP0_Config1_IS = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_IL = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_IA = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_DS = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_DL = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_DA = Param.Unsigned(0,"No Description")
|
||||
CP0_Config1_C2 = Param.Bool(False,"No Description")
|
||||
CP0_Config1_MD = Param.Bool(False,"No Description")
|
||||
CP0_Config1_PC = Param.Bool(False,"No Description")
|
||||
CP0_Config1_WR = Param.Bool(False,"No Description")
|
||||
CP0_Config1_CA = Param.Bool(False,"No Description")
|
||||
CP0_Config1_EP = Param.Bool(False,"No Description")
|
||||
CP0_Config1_FP = Param.Bool(False,"FPU Implemented?")
|
||||
CP0_Config2_M = Param.Bool(False,"Config3 Implemented?")
|
||||
CP0_Config2_TU = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_TS = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_TL = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_TA = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_SU = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_SS = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_SL = Param.Unsigned(0,"No Description")
|
||||
CP0_Config2_SA = Param.Unsigned(0,"No Description")
|
||||
CP0_Config3_M = Param.Bool(False,"Config4 Implemented?")
|
||||
CP0_Config3_DSPP = Param.Bool(False,"DSP Extensions Present?")
|
||||
CP0_Config3_LPA = Param.Bool(False,"No Description")
|
||||
CP0_Config3_VEIC = Param.Bool(False,"No Description")
|
||||
CP0_Config3_VInt = Param.Bool(False,"No Description")
|
||||
CP0_Config3_SP = Param.Bool(False,"No Description")
|
||||
CP0_Config3_MT = Param.Bool(False,"Multithreading Extensions Present?")
|
||||
CP0_Config3_SM = Param.Bool(False,"No Description")
|
||||
CP0_Config3_TL = Param.Bool(False,"No Description")
|
||||
CP0_WatchHi_M = Param.Bool(False,"No Description")
|
||||
CP0_PerfCtr_M = Param.Bool(False,"No Description")
|
||||
CP0_PerfCtr_W = Param.Bool(False,"No Description")
|
||||
CP0_PRId = Param.Unsigned(0,"CP0 Status Register")
|
||||
CP0_Config = Param.Unsigned(0,"CP0 Config Register")
|
||||
CP0_Config1 = Param.Unsigned(0,"CP0 Config1 Register")
|
||||
CP0_Config2 = Param.Unsigned(0,"CP0 Config2 Register")
|
||||
CP0_Config3 = Param.Unsigned(0,"CP0 Config3 Register")
|
||||
33
simulators/gem5/src/arch/mips/MipsInterrupts.py
Normal file
33
simulators/gem5/src/arch/mips/MipsInterrupts.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2008 The Regents of The University of Michigan
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Gabe Black
|
||||
|
||||
from m5.SimObject import SimObject
|
||||
|
||||
class MipsInterrupts(SimObject):
|
||||
type = 'MipsInterrupts'
|
||||
cxx_class = 'MipsISA::Interrupts'
|
||||
60
simulators/gem5/src/arch/mips/MipsSystem.py
Normal file
60
simulators/gem5/src/arch/mips/MipsSystem.py
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Jaidev Patwardhan
|
||||
|
||||
from m5.defines import buildEnv
|
||||
from m5.params import *
|
||||
from m5.proxy import *
|
||||
|
||||
from System import System
|
||||
|
||||
class MipsSystem(System):
|
||||
type = 'MipsSystem'
|
||||
console = Param.String("file that contains the console code")
|
||||
bare_iron = Param.Bool(False, "Using Bare Iron Mode?")
|
||||
hex_file_name = Param.String("test.hex","hex file that contains [address,data] pairs")
|
||||
system_type = Param.UInt64("Type of system we are emulating")
|
||||
system_rev = Param.UInt64("Revision of system we are emulating")
|
||||
load_addr_mask = 0xffffffffff
|
||||
|
||||
class LinuxMipsSystem(MipsSystem):
|
||||
type = 'LinuxMipsSystem'
|
||||
system_type = 34
|
||||
system_rev = 1 << 10
|
||||
|
||||
boot_cpu_frequency = Param.Frequency(Self.cpu[0].clock.frequency,
|
||||
"boot processor frequency")
|
||||
|
||||
class BareIronMipsSystem(MipsSystem):
|
||||
type = 'BareIronMipsSystem'
|
||||
bare_iron = True
|
||||
system_type = 34
|
||||
system_rev = 1 << 10
|
||||
hex_file_name = Param.String('test.hex',"hex file that contains [address,data] pairs")
|
||||
|
||||
40
simulators/gem5/src/arch/mips/MipsTLB.py
Normal file
40
simulators/gem5/src/arch/mips/MipsTLB.py
Normal file
@ -0,0 +1,40 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Jaidev Patwardhan
|
||||
# Korey Sewell
|
||||
|
||||
from m5.SimObject import SimObject
|
||||
from m5.params import *
|
||||
|
||||
from BaseTLB import BaseTLB
|
||||
|
||||
class MipsTLB(BaseTLB):
|
||||
type = 'MipsTLB'
|
||||
cxx_class = 'MipsISA::TLB'
|
||||
size = Param.Int(64, "TLB size")
|
||||
66
simulators/gem5/src/arch/mips/SConscript
Normal file
66
simulators/gem5/src/arch/mips/SConscript
Normal file
@ -0,0 +1,66 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2004-2006 The Regents of The University of Michigan
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Gabe Black
|
||||
# Steve Reinhardt
|
||||
# Korey Sewell
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['TARGET_ISA'] == 'mips':
|
||||
Source('bare_iron/system.cc')
|
||||
Source('decoder.cc')
|
||||
Source('dsp.cc')
|
||||
Source('faults.cc')
|
||||
Source('idle_event.cc')
|
||||
Source('interrupts.cc')
|
||||
Source('isa.cc')
|
||||
Source('linux/linux.cc')
|
||||
Source('linux/process.cc')
|
||||
Source('linux/system.cc')
|
||||
Source('pagetable.cc')
|
||||
Source('process.cc')
|
||||
Source('remote_gdb.cc')
|
||||
Source('stacktrace.cc')
|
||||
Source('system.cc')
|
||||
Source('tlb.cc')
|
||||
Source('utility.cc')
|
||||
Source('vtophys.cc')
|
||||
|
||||
SimObject('MipsInterrupts.py')
|
||||
SimObject('MipsSystem.py')
|
||||
SimObject('MipsTLB.py')
|
||||
|
||||
DebugFlag('MipsPRA')
|
||||
|
||||
# Add in files generated by the ISA description.
|
||||
isa_desc_files = env.ISADesc('isa/main.isa')
|
||||
# Only non-header files need to be compiled.
|
||||
for f in isa_desc_files:
|
||||
if not f.path.endswith('.hh'):
|
||||
Source(f)
|
||||
33
simulators/gem5/src/arch/mips/SConsopts
Normal file
33
simulators/gem5/src/arch/mips/SConsopts
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
all_isa_list.append('mips')
|
||||
46
simulators/gem5/src/arch/mips/bare_iron/system.cc
Executable file
46
simulators/gem5/src/arch/mips/bare_iron/system.cc
Executable file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#include "arch/mips/bare_iron/system.hh"
|
||||
#include "params/BareIronMipsSystem.hh"
|
||||
|
||||
BareIronMipsSystem::BareIronMipsSystem(Params *p)
|
||||
: MipsSystem(p)
|
||||
{ }
|
||||
|
||||
BareIronMipsSystem::~BareIronMipsSystem()
|
||||
{ }
|
||||
|
||||
BareIronMipsSystem *
|
||||
BareIronMipsSystemParams::create()
|
||||
{
|
||||
return new BareIronMipsSystem(this);
|
||||
}
|
||||
|
||||
51
simulators/gem5/src/arch/mips/bare_iron/system.hh
Executable file
51
simulators/gem5/src/arch/mips/bare_iron/system.hh
Executable file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_BARE_IRON_SYSTEM_HH__
|
||||
#define __ARCH_MIPS_BARE_IRON_SYSTEM_HH__
|
||||
|
||||
#include "arch/mips/system.hh"
|
||||
#include "params/BareIronMipsSystem.hh"
|
||||
|
||||
/**
|
||||
* This class contains linux specific system code (Loading, Events).
|
||||
* It points to objects that are the system binaries to load and patches them
|
||||
* appropriately to work in simulator.
|
||||
*/
|
||||
class BareIronMipsSystem : public MipsSystem
|
||||
{
|
||||
public:
|
||||
static const int CommandLineSize = 256;
|
||||
|
||||
BareIronMipsSystem(Params *p);
|
||||
~BareIronMipsSystem();
|
||||
};
|
||||
|
||||
#endif // __ARCH_MIPS_BARE_IRON_SYSTEM_HH__
|
||||
38
simulators/gem5/src/arch/mips/decoder.cc
Normal file
38
simulators/gem5/src/arch/mips/decoder.cc
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Google
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
*/
|
||||
|
||||
#include "arch/mips/decoder.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
GenericISA::BasicDecodeCache Decoder::defaultCache;
|
||||
|
||||
}
|
||||
128
simulators/gem5/src/arch/mips/decoder.hh
Normal file
128
simulators/gem5/src/arch/mips/decoder.hh
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Google
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_DECODER_HH__
|
||||
#define __ARCH_MIPS_DECODER_HH__
|
||||
|
||||
#include "arch/generic/decode_cache.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/types.hh"
|
||||
#include "cpu/static_inst.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
class Decoder
|
||||
{
|
||||
protected:
|
||||
ThreadContext * tc;
|
||||
//The extended machine instruction being generated
|
||||
ExtMachInst emi;
|
||||
bool instDone;
|
||||
|
||||
public:
|
||||
Decoder(ThreadContext * _tc) : tc(_tc), instDone(false)
|
||||
{}
|
||||
|
||||
ThreadContext *getTC()
|
||||
{
|
||||
return tc;
|
||||
}
|
||||
|
||||
void
|
||||
setTC(ThreadContext *_tc)
|
||||
{
|
||||
tc = _tc;
|
||||
}
|
||||
|
||||
void
|
||||
process()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
reset()
|
||||
{
|
||||
instDone = false;
|
||||
}
|
||||
|
||||
//Use this to give data to the decoder. This should be used
|
||||
//when there is control flow.
|
||||
void
|
||||
moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
|
||||
{
|
||||
emi = inst;
|
||||
instDone = true;
|
||||
}
|
||||
|
||||
bool
|
||||
needMoreBytes()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
instReady()
|
||||
{
|
||||
return instDone;
|
||||
}
|
||||
|
||||
protected:
|
||||
/// A cache of decoded instruction objects.
|
||||
static GenericISA::BasicDecodeCache defaultCache;
|
||||
|
||||
public:
|
||||
StaticInstPtr decodeInst(ExtMachInst mach_inst);
|
||||
|
||||
/// Decode a machine instruction.
|
||||
/// @param mach_inst The binary instruction to decode.
|
||||
/// @retval A pointer to the corresponding StaticInst object.
|
||||
StaticInstPtr
|
||||
decode(ExtMachInst mach_inst, Addr addr)
|
||||
{
|
||||
return defaultCache.decode(this, mach_inst, addr);
|
||||
}
|
||||
|
||||
StaticInstPtr
|
||||
decode(MipsISA::PCState &nextPC)
|
||||
{
|
||||
if (!instDone)
|
||||
return NULL;
|
||||
instDone = false;
|
||||
return decode(emi, nextPC.instAddr());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif // __ARCH_MIPS_DECODER_HH__
|
||||
1190
simulators/gem5/src/arch/mips/dsp.cc
Executable file
1190
simulators/gem5/src/arch/mips/dsp.cc
Executable file
File diff suppressed because it is too large
Load Diff
203
simulators/gem5/src/arch/mips/dsp.hh
Executable file
203
simulators/gem5/src/arch/mips/dsp.hh
Executable file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Brett Miller
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_DSP_HH__
|
||||
#define __ARCH_MIPS_DSP_HH__
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/types.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA {
|
||||
|
||||
// SIMD formats
|
||||
enum {
|
||||
SIMD_FMT_L, // long word
|
||||
SIMD_FMT_W, // word
|
||||
SIMD_FMT_PH, // paired halfword
|
||||
SIMD_FMT_QB, // quad byte
|
||||
SIMD_NUM_FMTS
|
||||
};
|
||||
|
||||
// DSPControl Fields
|
||||
enum {
|
||||
DSP_POS, // insertion bitfield position
|
||||
DSP_SCOUNT, // insertion bitfield size
|
||||
DSP_C, // carry bit
|
||||
DSP_OUFLAG, // overflow-underflow flag
|
||||
DSP_CCOND, // condition code
|
||||
DSP_EFI, // extract fail indicator bit
|
||||
DSP_NUM_FIELDS
|
||||
};
|
||||
|
||||
// compare instruction operations
|
||||
enum {
|
||||
CMP_EQ, // equal
|
||||
CMP_LT, // less than
|
||||
CMP_LE // less than or equal
|
||||
};
|
||||
|
||||
// SIMD operation order modes
|
||||
enum {
|
||||
MODE_L, // left
|
||||
MODE_R, // right
|
||||
MODE_LA, // left-alternate
|
||||
MODE_RA, // right-alternate
|
||||
MODE_X // cross
|
||||
};
|
||||
|
||||
// dsp operation parameters
|
||||
enum { UNSIGNED, SIGNED };
|
||||
enum { NOSATURATE, SATURATE };
|
||||
enum { NOROUND, ROUND };
|
||||
|
||||
// DSPControl field positions and masks
|
||||
const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS] = { 0, 7, 13, 16, 24, 14 };
|
||||
const uint32_t DSP_CTL_MASK[DSP_NUM_FIELDS] =
|
||||
{ 0x0000003f, 0x00001f80, 0x00002000,
|
||||
0x00ff0000, 0x0f000000, 0x00004000 };
|
||||
|
||||
/*
|
||||
* SIMD format constants
|
||||
*/
|
||||
|
||||
// maximum values per register
|
||||
const uint32_t SIMD_MAX_VALS = 4;
|
||||
// number of values in fmt
|
||||
const uint32_t SIMD_NVALS[SIMD_NUM_FMTS] = { 1, 1, 2, 4 };
|
||||
// number of bits per value
|
||||
const uint32_t SIMD_NBITS[SIMD_NUM_FMTS] = { 64, 32, 16, 8 };
|
||||
// log2(bits per value)
|
||||
const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS] = { 6, 5, 4, 3 };
|
||||
|
||||
|
||||
// DSP maximum values
|
||||
const uint64_t FIXED_L_SMAX = ULL(0x7fffffffffffffff);
|
||||
const uint64_t FIXED_W_SMAX = ULL(0x000000007fffffff);
|
||||
const uint64_t FIXED_H_SMAX = ULL(0x0000000000007fff);
|
||||
const uint64_t FIXED_B_SMAX = ULL(0x000000000000007f);
|
||||
const uint64_t FIXED_L_UMAX = ULL(0xffffffffffffffff);
|
||||
const uint64_t FIXED_W_UMAX = ULL(0x00000000ffffffff);
|
||||
const uint64_t FIXED_H_UMAX = ULL(0x000000000000ffff);
|
||||
const uint64_t FIXED_B_UMAX = ULL(0x00000000000000ff);
|
||||
const uint64_t FIXED_SMAX[SIMD_NUM_FMTS] =
|
||||
{ FIXED_L_SMAX, FIXED_W_SMAX, FIXED_H_SMAX, FIXED_B_SMAX };
|
||||
const uint64_t FIXED_UMAX[SIMD_NUM_FMTS] =
|
||||
{ FIXED_L_UMAX, FIXED_W_UMAX, FIXED_H_UMAX, FIXED_B_UMAX };
|
||||
|
||||
// DSP minimum values
|
||||
const uint64_t FIXED_L_SMIN = ULL(0x8000000000000000);
|
||||
const uint64_t FIXED_W_SMIN = ULL(0xffffffff80000000);
|
||||
const uint64_t FIXED_H_SMIN = ULL(0xffffffffffff8000);
|
||||
const uint64_t FIXED_B_SMIN = ULL(0xffffffffffffff80);
|
||||
const uint64_t FIXED_L_UMIN = ULL(0x0000000000000000);
|
||||
const uint64_t FIXED_W_UMIN = ULL(0x0000000000000000);
|
||||
const uint64_t FIXED_H_UMIN = ULL(0x0000000000000000);
|
||||
const uint64_t FIXED_B_UMIN = ULL(0x0000000000000000);
|
||||
const uint64_t FIXED_SMIN[SIMD_NUM_FMTS] =
|
||||
{ FIXED_L_SMIN, FIXED_W_SMIN, FIXED_H_SMIN, FIXED_B_SMIN };
|
||||
const uint64_t FIXED_UMIN[SIMD_NUM_FMTS] =
|
||||
{ FIXED_L_UMIN, FIXED_W_UMIN, FIXED_H_UMIN, FIXED_B_UMIN };
|
||||
|
||||
// DSP utility functions
|
||||
int32_t bitrev(int32_t value);
|
||||
uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign,
|
||||
uint32_t *overflow);
|
||||
uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign,
|
||||
uint32_t *overflow);
|
||||
uint64_t signExtend(uint64_t value, int32_t signpos);
|
||||
uint64_t addHalfLsb(uint64_t value, int32_t lsbpos);
|
||||
int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl);
|
||||
int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
|
||||
int32_t sign, uint32_t *dspctl);
|
||||
int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round,
|
||||
int32_t sign);
|
||||
int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
|
||||
int32_t sign, uint32_t *dspctl);
|
||||
int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round,
|
||||
int32_t sign);
|
||||
int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate,
|
||||
int32_t sign, uint32_t *dspctl);
|
||||
int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign);
|
||||
int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round,
|
||||
int32_t sign, uint32_t *dspctl);
|
||||
int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
|
||||
uint32_t *dspctl);
|
||||
int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate,
|
||||
int32_t round, uint32_t *dspctl);
|
||||
int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
|
||||
int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl);
|
||||
int64_t dspDpaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
|
||||
int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
|
||||
uint32_t *dspctl);
|
||||
int64_t dspDpsq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
|
||||
int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode,
|
||||
uint32_t *dspctl);
|
||||
int64_t dspDpa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
|
||||
int32_t sign, int32_t mode);
|
||||
int64_t dspDps(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
|
||||
int32_t sign, int32_t mode);
|
||||
int64_t dspMaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
|
||||
int32_t fmt, int32_t mode, int32_t saturate, uint32_t *dspctl);
|
||||
int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt);
|
||||
int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt,
|
||||
uint32_t *dspctl);
|
||||
void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
|
||||
uint32_t *dspctl);
|
||||
int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op);
|
||||
int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op,
|
||||
uint32_t *dspctl);
|
||||
int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt,
|
||||
int32_t outsign, int32_t mode);
|
||||
int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl);
|
||||
int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
|
||||
int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt,
|
||||
int32_t round);
|
||||
int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl);
|
||||
int32_t dspPack(int32_t a, int32_t b, int32_t fmt);
|
||||
int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round,
|
||||
int32_t saturate, uint32_t *dspctl);
|
||||
int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl);
|
||||
int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl);
|
||||
|
||||
// SIMD pack/unpack utility functions
|
||||
void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt);
|
||||
void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign);
|
||||
|
||||
// DSPControl r/w utility functions
|
||||
void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask);
|
||||
uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask);
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif // __ARCH_MIPS_DSP_HH__
|
||||
136
simulators/gem5/src/arch/mips/dt_constants.hh
Executable file
136
simulators/gem5/src/arch/mips/dt_constants.hh
Executable file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_DT_CONSTANTS_HH__
|
||||
#define __ARCH_MIPS_DT_CONSTANTS_HH__
|
||||
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/bitunion.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
BitUnion32(DebugReg)
|
||||
Bitfield<31> dbd;
|
||||
Bitfield<30> dm;
|
||||
Bitfield<29> nodcr;
|
||||
Bitfield<28> lsnm;
|
||||
Bitfield<27> doze;
|
||||
Bitfield<26> halt;
|
||||
Bitfield<25> conutdm;
|
||||
Bitfield<24> ibusep;
|
||||
Bitfield<23> mcheckep;
|
||||
Bitfield<22> cacheep;
|
||||
Bitfield<21> dbusep;
|
||||
Bitfield<20, 19> iexi;
|
||||
Bitfield<19> ddbsImpr;
|
||||
Bitfield<18> ddblImpr;
|
||||
SubBitUnion(ejtagVer, 17, 15)
|
||||
Bitfield<17> ejtagVer2;
|
||||
Bitfield<16> ejtagVer1;
|
||||
Bitfield<15> ejtagVer0;
|
||||
EndSubBitUnion(ejtagVer)
|
||||
Bitfield<14, 10> dexcCode;
|
||||
Bitfield<9> nosst;
|
||||
Bitfield<8> sst;
|
||||
Bitfield<7> offline;
|
||||
Bitfield<6> dibimpr;
|
||||
Bitfield<5> dint;
|
||||
Bitfield<4> dib;
|
||||
Bitfield<3> ddbs;
|
||||
Bitfield<2> ddbl;
|
||||
Bitfield<1> dbp;
|
||||
Bitfield<0> dss;
|
||||
EndBitUnion(DebugReg)
|
||||
|
||||
BitUnion32(TraceControlReg)
|
||||
Bitfield<31> ts;
|
||||
Bitfield<30> ut;
|
||||
Bitfield<27> tb;
|
||||
Bitfield<26> io;
|
||||
Bitfield<25> d;
|
||||
Bitfield<24> e;
|
||||
Bitfield<23> k;
|
||||
Bitfield<22> s;
|
||||
Bitfield<21> u;
|
||||
Bitfield<20, 13> asidM;
|
||||
Bitfield<12, 5> asid;
|
||||
Bitfield<4> g;
|
||||
Bitfield<3> tfcr;
|
||||
Bitfield<2> tlsm;
|
||||
Bitfield<1> tim;
|
||||
Bitfield<0> on;
|
||||
EndBitUnion(TraceControlReg)
|
||||
|
||||
BitUnion32(TraceControl2Reg)
|
||||
Bitfield<29> cpuidv;
|
||||
Bitfield<28, 21> cpuid;
|
||||
Bitfield<20> tcv;
|
||||
Bitfield<19, 12> tcnum;
|
||||
Bitfield<11, 7> mode;
|
||||
Bitfield<6, 5> validModes;
|
||||
Bitfield<4> tbi;
|
||||
Bitfield<3> tbu;
|
||||
Bitfield<2, 0> syp;
|
||||
EndBitUnion(TraceControl2Reg)
|
||||
|
||||
BitUnion32(TraceBPCReg)
|
||||
Bitfield<31> mb;
|
||||
Bitfield<28> e;
|
||||
Bitfield<27> ate;
|
||||
Bitfield<26, 24> bpc8;
|
||||
Bitfield<23, 21> bpc7;
|
||||
Bitfield<20, 18> bpc6;
|
||||
Bitfield<17, 15> bpc5;
|
||||
Bitfield<14, 12> bpc4;
|
||||
Bitfield<11, 9> bpc3;
|
||||
Bitfield<8, 6> bpc2;
|
||||
Bitfield<5, 3> bpc1;
|
||||
Bitfield<2, 0> bpc0;
|
||||
EndBitUnion(TraceBPCReg)
|
||||
|
||||
BitUnion32(TraceBPC2Reg)
|
||||
Bitfield<17, 15> bpc14;
|
||||
Bitfield<14, 12> bpc13;
|
||||
Bitfield<11, 9> bpc12;
|
||||
Bitfield<8, 6> bpc11;
|
||||
Bitfield<5, 3> bpc10;
|
||||
Bitfield<2, 0> bpc9;
|
||||
EndBitUnion(TraceBPC2Reg)
|
||||
|
||||
BitUnion32(Debug2Reg)
|
||||
Bitfield<3> prm;
|
||||
Bitfield<2> dq;
|
||||
Bitfield<1> tup;
|
||||
Bitfield<0> paco;
|
||||
EndBitUnion(Debug2Reg)
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
175
simulators/gem5/src/arch/mips/faults.cc
Normal file
175
simulators/gem5/src/arch/mips/faults.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Korey Sewell
|
||||
* Jaidev Patwardhan
|
||||
* Zhengxing Li
|
||||
* Deyuan Guo
|
||||
*/
|
||||
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/MipsPRA.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/process.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
typedef MipsFaultBase::FaultVals FaultVals;
|
||||
|
||||
template <> FaultVals MipsFault<SystemCallFault>::vals =
|
||||
{ "Syscall", 0x180, ExcCodeSys };
|
||||
|
||||
template <> FaultVals MipsFault<ReservedInstructionFault>::vals =
|
||||
{ "Reserved Instruction Fault", 0x180, ExcCodeRI };
|
||||
|
||||
template <> FaultVals MipsFault<ThreadFault>::vals =
|
||||
{ "Thread Fault", 0x180, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<IntegerOverflowFault>::vals =
|
||||
{ "Integer Overflow Exception", 0x180, ExcCodeOv };
|
||||
|
||||
template <> FaultVals MipsFault<TrapFault>::vals =
|
||||
{ "Trap", 0x180, ExcCodeTr };
|
||||
|
||||
template <> FaultVals MipsFault<BreakpointFault>::vals =
|
||||
{ "Breakpoint", 0x180, ExcCodeBp };
|
||||
|
||||
template <> FaultVals MipsFault<DspStateDisabledFault>::vals =
|
||||
{ "DSP Disabled Fault", 0x180, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<MachineCheckFault>::vals =
|
||||
{ "Machine Check", 0x180, ExcCodeMCheck };
|
||||
|
||||
template <> FaultVals MipsFault<ResetFault>::vals =
|
||||
{ "Reset Fault", 0x000, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<SoftResetFault>::vals =
|
||||
{ "Soft Reset Fault", 0x000, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<NonMaskableInterrupt>::vals =
|
||||
{ "Non Maskable Interrupt", 0x000, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<CoprocessorUnusableFault>::vals =
|
||||
{ "Coprocessor Unusable Fault", 0x180, ExcCodeCpU };
|
||||
|
||||
template <> FaultVals MipsFault<InterruptFault>::vals =
|
||||
{ "Interrupt", 0x000, ExcCodeInt };
|
||||
|
||||
template <> FaultVals MipsFault<AddressErrorFault>::vals =
|
||||
{ "Address Error", 0x180, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<TlbInvalidFault>::vals =
|
||||
{ "Invalid TLB Entry Exception", 0x180, ExcCodeDummy };
|
||||
|
||||
template <> FaultVals MipsFault<TlbRefillFault>::vals =
|
||||
{ "TLB Refill Exception", 0x180, ExcCodeDummy };
|
||||
|
||||
template <> MipsFaultBase::FaultVals MipsFault<TlbModifiedFault>::vals =
|
||||
{ "TLB Modified Exception", 0x180, ExcCodeMod };
|
||||
|
||||
void
|
||||
MipsFaultBase::setExceptionState(ThreadContext *tc, uint8_t excCode)
|
||||
{
|
||||
// modify SRS Ctl - Save CSS, put ESS into CSS
|
||||
StatusReg status = tc->readMiscReg(MISCREG_STATUS);
|
||||
if (status.exl != 1 && status.bev != 1) {
|
||||
// SRS Ctl is modified only if Status_EXL and Status_BEV are not set
|
||||
SRSCtlReg srsCtl = tc->readMiscReg(MISCREG_SRSCTL);
|
||||
srsCtl.pss = srsCtl.css;
|
||||
srsCtl.css = srsCtl.ess;
|
||||
tc->setMiscRegNoEffect(MISCREG_SRSCTL, srsCtl);
|
||||
}
|
||||
|
||||
// set EXL bit (don't care if it is already set!)
|
||||
status.exl = 1;
|
||||
tc->setMiscRegNoEffect(MISCREG_STATUS, status);
|
||||
|
||||
// write EPC
|
||||
PCState pc = tc->pcState();
|
||||
DPRINTF(MipsPRA, "PC: %s\n", pc);
|
||||
bool delay_slot = pc.pc() + sizeof(MachInst) != pc.npc();
|
||||
tc->setMiscRegNoEffect(MISCREG_EPC,
|
||||
pc.pc() - (delay_slot ? sizeof(MachInst) : 0));
|
||||
|
||||
// Set Cause_EXCCODE field
|
||||
CauseReg cause = tc->readMiscReg(MISCREG_CAUSE);
|
||||
cause.excCode = excCode;
|
||||
cause.bd = delay_slot ? 1 : 0;
|
||||
cause.ce = 0;
|
||||
tc->setMiscRegNoEffect(MISCREG_CAUSE, cause);
|
||||
}
|
||||
|
||||
void
|
||||
MipsFaultBase::invoke(ThreadContext *tc, StaticInstPtr inst)
|
||||
{
|
||||
if (FullSystem) {
|
||||
DPRINTF(MipsPRA, "Fault %s encountered.\n", name());
|
||||
setExceptionState(tc, code());
|
||||
tc->pcState(vect(tc));
|
||||
} else {
|
||||
panic("Fault %s encountered.\n", name());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ResetFault::invoke(ThreadContext *tc, StaticInstPtr inst)
|
||||
{
|
||||
if (FullSystem) {
|
||||
DPRINTF(MipsPRA, "%s encountered.\n", name());
|
||||
/* All reset activity must be invoked from here */
|
||||
Addr handler = vect(tc);
|
||||
tc->pcState(handler);
|
||||
DPRINTF(MipsPRA, "ResetFault::invoke : PC set to %x", handler);
|
||||
}
|
||||
|
||||
// Set Coprocessor 1 (Floating Point) To Usable
|
||||
StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS);
|
||||
status.cu.cu1 = 1;
|
||||
tc->setMiscReg(MISCREG_STATUS, status);
|
||||
}
|
||||
|
||||
void
|
||||
SoftResetFault::invoke(ThreadContext *tc, StaticInstPtr inst)
|
||||
{
|
||||
panic("Soft reset not implemented.\n");
|
||||
}
|
||||
|
||||
void
|
||||
NonMaskableInterrupt::invoke(ThreadContext *tc, StaticInstPtr inst)
|
||||
{
|
||||
panic("Non maskable interrupt not implemented.\n");
|
||||
}
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
308
simulators/gem5/src/arch/mips/faults.hh
Normal file
308
simulators/gem5/src/arch/mips/faults.hh
Normal file
@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Korey Sewell
|
||||
* Jaidev Patwardhan
|
||||
* Zhengxing Li
|
||||
* Deyuan Guo
|
||||
*/
|
||||
|
||||
#ifndef __MIPS_FAULTS_HH__
|
||||
#define __MIPS_FAULTS_HH__
|
||||
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/MipsPRA.hh"
|
||||
#include "sim/faults.hh"
|
||||
#include "sim/full_system.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
typedef const Addr FaultVect;
|
||||
|
||||
enum ExcCode {
|
||||
// A dummy value to use when the code isn't defined or doesn't matter.
|
||||
ExcCodeDummy = 0,
|
||||
|
||||
ExcCodeInt = 0,
|
||||
ExcCodeMod = 1,
|
||||
ExcCodeTlbL = 2,
|
||||
ExcCodeTlbS = 3,
|
||||
ExcCodeAdEL = 4,
|
||||
ExcCodeAdES = 5,
|
||||
ExcCodeIBE = 6,
|
||||
ExcCodeDBE = 7,
|
||||
ExcCodeSys = 8,
|
||||
ExcCodeBp = 9,
|
||||
ExcCodeRI = 10,
|
||||
ExcCodeCpU = 11,
|
||||
ExcCodeOv = 12,
|
||||
ExcCodeTr = 13,
|
||||
ExcCodeC2E = 18,
|
||||
ExcCodeMDMX = 22,
|
||||
ExcCodeWatch = 23,
|
||||
ExcCodeMCheck = 24,
|
||||
ExcCodeThread = 25,
|
||||
ExcCodeCacheErr = 30
|
||||
};
|
||||
|
||||
class MipsFaultBase : public FaultBase
|
||||
{
|
||||
public:
|
||||
struct FaultVals
|
||||
{
|
||||
const FaultName name;
|
||||
const FaultVect offset;
|
||||
const ExcCode code;
|
||||
};
|
||||
|
||||
void setExceptionState(ThreadContext *, uint8_t);
|
||||
|
||||
virtual FaultVect offset(ThreadContext *tc) const = 0;
|
||||
virtual ExcCode code() const = 0;
|
||||
virtual FaultVect base(ThreadContext *tc) const
|
||||
{
|
||||
StatusReg status = tc->readMiscReg(MISCREG_STATUS);
|
||||
if (!status.bev)
|
||||
return tc->readMiscReg(MISCREG_EBASE);
|
||||
else
|
||||
return 0xbfc00200;
|
||||
}
|
||||
|
||||
FaultVect
|
||||
vect(ThreadContext *tc) const
|
||||
{
|
||||
return base(tc) + offset(tc);
|
||||
}
|
||||
|
||||
void invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class MipsFault : public MipsFaultBase
|
||||
{
|
||||
protected:
|
||||
static FaultVals vals;
|
||||
public:
|
||||
FaultName name() const { return vals.name; }
|
||||
FaultVect offset(ThreadContext *tc) const { return vals.offset; }
|
||||
ExcCode code() const { return vals.code; }
|
||||
};
|
||||
|
||||
class SystemCallFault : public MipsFault<SystemCallFault> {};
|
||||
class ReservedInstructionFault : public MipsFault<ReservedInstructionFault> {};
|
||||
class ThreadFault : public MipsFault<ThreadFault> {};
|
||||
class IntegerOverflowFault : public MipsFault<IntegerOverflowFault> {};
|
||||
class TrapFault : public MipsFault<TrapFault> {};
|
||||
class BreakpointFault : public MipsFault<BreakpointFault> {};
|
||||
class DspStateDisabledFault : public MipsFault<DspStateDisabledFault> {};
|
||||
|
||||
class MachineCheckFault : public MipsFault<MachineCheckFault>
|
||||
{
|
||||
public:
|
||||
bool isMachineCheckFault() { return true; }
|
||||
};
|
||||
|
||||
class ResetFault : public MipsFault<ResetFault>
|
||||
{
|
||||
public:
|
||||
void invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
||||
|
||||
};
|
||||
|
||||
class SoftResetFault : public MipsFault<SoftResetFault>
|
||||
{
|
||||
public:
|
||||
void invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
||||
};
|
||||
|
||||
class NonMaskableInterrupt : public MipsFault<NonMaskableInterrupt>
|
||||
{
|
||||
public:
|
||||
void invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr);
|
||||
};
|
||||
|
||||
class CoprocessorUnusableFault : public MipsFault<CoprocessorUnusableFault>
|
||||
{
|
||||
protected:
|
||||
int coProcID;
|
||||
public:
|
||||
CoprocessorUnusableFault(int _procid) : coProcID(_procid)
|
||||
{}
|
||||
|
||||
void
|
||||
invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr)
|
||||
{
|
||||
MipsFault<CoprocessorUnusableFault>::invoke(tc, inst);
|
||||
if (FullSystem) {
|
||||
CauseReg cause = tc->readMiscReg(MISCREG_CAUSE);
|
||||
cause.ce = coProcID;
|
||||
tc->setMiscRegNoEffect(MISCREG_CAUSE, cause);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class InterruptFault : public MipsFault<InterruptFault>
|
||||
{
|
||||
public:
|
||||
FaultVect
|
||||
offset(ThreadContext *tc) const
|
||||
{
|
||||
CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE);
|
||||
// offset 0x200 for release 2, 0x180 for release 1.
|
||||
return cause.iv ? 0x200 : 0x180;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class AddressFault : public MipsFault<T>
|
||||
{
|
||||
protected:
|
||||
Addr vaddr;
|
||||
bool store;
|
||||
|
||||
AddressFault(Addr _vaddr, bool _store) : vaddr(_vaddr), store(_store)
|
||||
{}
|
||||
|
||||
void
|
||||
invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr)
|
||||
{
|
||||
MipsFault<T>::invoke(tc, inst);
|
||||
if (FullSystem)
|
||||
tc->setMiscRegNoEffect(MISCREG_BADVADDR, vaddr);
|
||||
}
|
||||
};
|
||||
|
||||
class AddressErrorFault : public AddressFault<AddressErrorFault>
|
||||
{
|
||||
public:
|
||||
AddressErrorFault(Addr _vaddr, bool _store) :
|
||||
AddressFault<AddressErrorFault>(_vaddr, _store)
|
||||
{}
|
||||
|
||||
ExcCode
|
||||
code() const
|
||||
{
|
||||
return store ? ExcCodeAdES : ExcCodeAdEL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class TlbFault : public AddressFault<T>
|
||||
{
|
||||
protected:
|
||||
Addr asid;
|
||||
Addr vpn;
|
||||
|
||||
TlbFault(Addr _asid, Addr _vaddr, Addr _vpn, bool _store) :
|
||||
AddressFault<T>(_vaddr, _store), asid(_asid), vpn(_vpn)
|
||||
{}
|
||||
|
||||
void
|
||||
setTlbExceptionState(ThreadContext *tc, uint8_t excCode)
|
||||
{
|
||||
this->setExceptionState(tc, excCode);
|
||||
|
||||
tc->setMiscRegNoEffect(MISCREG_BADVADDR, this->vaddr);
|
||||
EntryHiReg entryHi = tc->readMiscReg(MISCREG_ENTRYHI);
|
||||
entryHi.asid = this->asid;
|
||||
entryHi.vpn2 = this->vpn >> 2;
|
||||
entryHi.vpn2x = this->vpn & 0x3;
|
||||
tc->setMiscRegNoEffect(MISCREG_ENTRYHI, entryHi);
|
||||
|
||||
ContextReg context = tc->readMiscReg(MISCREG_CONTEXT);
|
||||
context.badVPN2 = this->vpn >> 2;
|
||||
tc->setMiscRegNoEffect(MISCREG_CONTEXT, context);
|
||||
}
|
||||
|
||||
void
|
||||
invoke(ThreadContext * tc,
|
||||
StaticInstPtr inst = StaticInst::nullStaticInstPtr)
|
||||
{
|
||||
if (FullSystem) {
|
||||
DPRINTF(MipsPRA, "Fault %s encountered.\n", this->name());
|
||||
Addr vect = this->vect(tc);
|
||||
setTlbExceptionState(tc, this->code());
|
||||
tc->pcState(vect);
|
||||
} else {
|
||||
AddressFault<T>::invoke(tc, inst);
|
||||
}
|
||||
}
|
||||
|
||||
ExcCode
|
||||
code() const
|
||||
{
|
||||
return this->store ? ExcCodeTlbS : ExcCodeTlbL;
|
||||
}
|
||||
};
|
||||
|
||||
class TlbRefillFault : public TlbFault<TlbRefillFault>
|
||||
{
|
||||
public:
|
||||
TlbRefillFault(Addr asid, Addr vaddr, Addr vpn, bool store) :
|
||||
TlbFault<TlbRefillFault>(asid, vaddr, vpn, store)
|
||||
{}
|
||||
|
||||
FaultVect
|
||||
offset(ThreadContext *tc) const
|
||||
{
|
||||
StatusReg status = tc->readMiscReg(MISCREG_STATUS);
|
||||
return status.exl ? 0x180 : 0x000;
|
||||
}
|
||||
};
|
||||
|
||||
class TlbInvalidFault : public TlbFault<TlbInvalidFault>
|
||||
{
|
||||
public:
|
||||
TlbInvalidFault(Addr asid, Addr vaddr, Addr vpn, bool store) :
|
||||
TlbFault<TlbInvalidFault>(asid, vaddr, vpn, store)
|
||||
{}
|
||||
};
|
||||
|
||||
class TlbModifiedFault : public TlbFault<TlbModifiedFault>
|
||||
{
|
||||
public:
|
||||
TlbModifiedFault(Addr asid, Addr vaddr, Addr vpn) :
|
||||
TlbFault<TlbModifiedFault>(asid, vaddr, vpn, false)
|
||||
{}
|
||||
|
||||
ExcCode code() const { return MipsFault<TlbModifiedFault>::code(); }
|
||||
};
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif // __MIPS_FAULTS_HH__
|
||||
43
simulators/gem5/src/arch/mips/idle_event.cc
Normal file
43
simulators/gem5/src/arch/mips/idle_event.cc
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Lisa Hsu
|
||||
* Ali Saidi
|
||||
*/
|
||||
|
||||
#include "arch/mips/idle_event.hh"
|
||||
#include "arch/mips/kernel_stats.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
|
||||
using namespace MipsISA;
|
||||
|
||||
void
|
||||
IdleStartEvent::process(ThreadContext *tc)
|
||||
{
|
||||
fatal("Idle Start Event Not Defined for MIPS ISA ");
|
||||
}
|
||||
47
simulators/gem5/src/arch/mips/idle_event.hh
Normal file
47
simulators/gem5/src/arch/mips/idle_event.hh
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Lisa Hsu
|
||||
* Ali Saidi
|
||||
*/
|
||||
|
||||
#ifndef __KERN_MIPS_IDLE_EVENT_HH__
|
||||
#define __KERN_MIPS_IDLE_EVENT_HH__
|
||||
|
||||
#include "cpu/pc_event.hh"
|
||||
|
||||
class IdleStartEvent : public PCEvent
|
||||
{
|
||||
public:
|
||||
IdleStartEvent(PCEventQueue *q, const std::string &desc, Addr addr)
|
||||
: PCEvent(q, desc, addr)
|
||||
{}
|
||||
virtual void process(ThreadContext *tc);
|
||||
};
|
||||
|
||||
#endif // __KERN_ALPHA_IDLE_EVENT_HH__
|
||||
173
simulators/gem5/src/arch/mips/interrupts.cc
Executable file
173
simulators/gem5/src/arch/mips/interrupts.cc
Executable file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Steve Reinhardt
|
||||
* Kevin Lim
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#include "arch/mips/interrupts.hh"
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Interrupt.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
static inline uint8_t
|
||||
getCauseIP(ThreadContext *tc) {
|
||||
CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE);
|
||||
return cause.ip;
|
||||
}
|
||||
|
||||
static inline void
|
||||
setCauseIP(ThreadContext *tc, uint8_t val) {
|
||||
CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE);
|
||||
cause.ip = val;
|
||||
tc->setMiscRegNoEffect(MISCREG_CAUSE, cause);
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::post(int int_num, ThreadContext* tc)
|
||||
{
|
||||
DPRINTF(Interrupt, "Interrupt %d posted\n", int_num);
|
||||
if (int_num < 0 || int_num >= NumInterruptLevels)
|
||||
panic("int_num out of bounds\n");
|
||||
|
||||
uint8_t intstatus = getCauseIP(tc);
|
||||
intstatus |= 1 << int_num;
|
||||
setCauseIP(tc, intstatus);
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::post(int int_num, int index)
|
||||
{
|
||||
fatal("Must use Thread Context when posting MIPS Interrupts in M5");
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::clear(int int_num, ThreadContext* tc)
|
||||
{
|
||||
DPRINTF(Interrupt, "Interrupt %d cleared\n", int_num);
|
||||
if (int_num < 0 || int_num >= NumInterruptLevels)
|
||||
panic("int_num out of bounds\n");
|
||||
|
||||
uint8_t intstatus = getCauseIP(tc);
|
||||
intstatus &= ~(1 << int_num);
|
||||
setCauseIP(tc, intstatus);
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::clear(int int_num, int index)
|
||||
{
|
||||
fatal("Must use Thread Context when clearing MIPS Interrupts in M5");
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::clearAll(ThreadContext *tc)
|
||||
{
|
||||
DPRINTF(Interrupt, "Interrupts all cleared\n");
|
||||
uint8_t intstatus = 0;
|
||||
setCauseIP(tc, intstatus);
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::clearAll()
|
||||
{
|
||||
fatal("Must use Thread Context when clearing MIPS Interrupts in M5");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Fault
|
||||
Interrupts::getInterrupt(ThreadContext * tc)
|
||||
{
|
||||
DPRINTF(Interrupt, "Interrupts getInterrupt\n");
|
||||
|
||||
//Check if there are any outstanding interrupts
|
||||
StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS);
|
||||
// Interrupts must be enabled, error level must be 0 or interrupts
|
||||
// inhibited, and exception level must be 0 or interrupts inhibited
|
||||
if ((status.ie == 1) && (status.erl == 0) && (status.exl == 0)) {
|
||||
// Software interrupts & hardware interrupts are handled in software.
|
||||
// So if any interrupt that isn't masked is detected, jump to interrupt
|
||||
// handler
|
||||
CauseReg cause = tc->readMiscRegNoEffect(MISCREG_CAUSE);
|
||||
if (status.im && cause.ip) {
|
||||
DPRINTF(Interrupt, "Interrupt! IM[7:0]=%d IP[7:0]=%d \n",
|
||||
(unsigned)status.im, (unsigned)cause.ip);
|
||||
return new InterruptFault;
|
||||
}
|
||||
}
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
bool
|
||||
Interrupts::onCpuTimerInterrupt(ThreadContext * tc) const
|
||||
{
|
||||
MiscReg compare = tc->readMiscRegNoEffect(MISCREG_COMPARE);
|
||||
MiscReg count = tc->readMiscRegNoEffect(MISCREG_COUNT);
|
||||
if (compare == count && count != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Interrupts::updateIntrInfo(ThreadContext *tc) const
|
||||
{
|
||||
//Nothing needs to be done.
|
||||
}
|
||||
|
||||
bool
|
||||
Interrupts::interruptsPending(ThreadContext *tc) const
|
||||
{
|
||||
//if there is a on cpu timer interrupt (i.e. Compare == Count)
|
||||
//update CauseIP before proceeding to interrupt
|
||||
if (onCpuTimerInterrupt(tc)) {
|
||||
DPRINTF(Interrupt, "Interrupts OnCpuTimerINterrupt(tc) == true\n");
|
||||
//determine timer interrupt IP #
|
||||
IntCtlReg intCtl = tc->readMiscRegNoEffect(MISCREG_INTCTL);
|
||||
uint8_t intStatus = getCauseIP(tc);
|
||||
intStatus |= 1 << intCtl.ipti;
|
||||
setCauseIP(tc, intStatus);
|
||||
}
|
||||
|
||||
return (getCauseIP(tc) != 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MipsISA::Interrupts *
|
||||
MipsInterruptsParams::create()
|
||||
{
|
||||
return new MipsISA::Interrupts(this);
|
||||
}
|
||||
140
simulators/gem5/src/arch/mips/interrupts.hh
Executable file
140
simulators/gem5/src/arch/mips/interrupts.hh
Executable file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Rick Strong
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_INTERRUPT_HH__
|
||||
#define __ARCH_MIPS_INTERRUPT_HH__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "base/compiler.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "params/MipsInterrupts.hh"
|
||||
#include "sim/serialize.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class BaseCPU;
|
||||
class Checkpoint;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
class Interrupts : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef MipsInterruptsParams Params;
|
||||
|
||||
const Params *
|
||||
params() const
|
||||
{
|
||||
return dynamic_cast<const Params *>(_params);
|
||||
}
|
||||
|
||||
Interrupts(Params * p) : SimObject(p)
|
||||
{
|
||||
newInfoSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
setCPU(BaseCPU *_cpu)
|
||||
{}
|
||||
|
||||
// post(int int_num, int index) is responsible
|
||||
// for posting an interrupt. It sets a bit
|
||||
// in intstatus corresponding to Cause IP*. The
|
||||
// MIPS register Cause is updated by updateIntrInfo
|
||||
// which is called by checkInterrupts
|
||||
//
|
||||
void post(int int_num, ThreadContext *tc);
|
||||
void post(int int_num, int index);
|
||||
|
||||
// clear(int int_num, int index) is responsible
|
||||
// for clearing an interrupt. It clear a bit
|
||||
// in intstatus corresponding to Cause IP*. The
|
||||
// MIPS register Cause is updated by updateIntrInfo
|
||||
// which is called by checkInterrupts
|
||||
//
|
||||
void clear(int int_num, ThreadContext* tc);
|
||||
void clear(int int_num, int index);
|
||||
|
||||
// clearAll() is responsible
|
||||
// for clearing all interrupts. It clears all bits
|
||||
// in intstatus corresponding to Cause IP*. The
|
||||
// MIPS register Cause is updated by updateIntrInfo
|
||||
// which is called by checkInterrupts
|
||||
//
|
||||
void clearAll(ThreadContext *tc);
|
||||
void clearAll();
|
||||
|
||||
// getInterrupt(ThreadContext * tc) checks if an interrupt
|
||||
// should be returned. It ands the interrupt mask and
|
||||
// and interrupt pending bits to see if one exists. It
|
||||
// also makes sure interrupts are enabled (IE) and
|
||||
// that ERL and ERX are not set
|
||||
//
|
||||
Fault getInterrupt(ThreadContext *tc);
|
||||
|
||||
// updateIntrInfo(ThreadContext *tc) const syncs the
|
||||
// MIPS cause register with the instatus variable. instatus
|
||||
// is essentially a copy of the MIPS cause[IP7:IP0]
|
||||
//
|
||||
void updateIntrInfo(ThreadContext *tc) const;
|
||||
bool interruptsPending(ThreadContext *tc) const;
|
||||
bool onCpuTimerInterrupt(ThreadContext *tc) const;
|
||||
|
||||
bool
|
||||
checkInterrupts(ThreadContext *tc) const
|
||||
{
|
||||
return interruptsPending(tc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
serialize(std::ostream &os)
|
||||
{
|
||||
fatal("Serialization of Interrupts Unimplemented for MIPS");
|
||||
}
|
||||
|
||||
void
|
||||
unserialize(Checkpoint *cp, const std::string §ion)
|
||||
{
|
||||
fatal("Unserialization of Interrupts Unimplemented for MIPS");
|
||||
}
|
||||
|
||||
private:
|
||||
bool newInfoSet;
|
||||
int newIpl;
|
||||
int newSummary;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
588
simulators/gem5/src/arch/mips/isa.cc
Normal file
588
simulators/gem5/src/arch/mips/isa.cc
Normal file
@ -0,0 +1,588 @@
|
||||
/*
|
||||
* Copyright (c) 2009 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
*/
|
||||
|
||||
#include "arch/mips/isa.hh"
|
||||
#include "arch/mips/mt.hh"
|
||||
#include "arch/mips/mt_constants.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "base/bitfield.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/MipsPRA.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
std::string
|
||||
ISA::miscRegNames[NumMiscRegs] =
|
||||
{
|
||||
"Index", "MVPControl", "MVPConf0", "MVPConf1", "", "", "", "",
|
||||
"Random", "VPEControl", "VPEConf0", "VPEConf1",
|
||||
"YQMask", "VPESchedule", "VPEScheFBack", "VPEOpt",
|
||||
"EntryLo0", "TCStatus", "TCBind", "TCRestart",
|
||||
"TCHalt", "TCContext", "TCSchedule", "TCScheFBack",
|
||||
"EntryLo1", "", "", "", "", "", "", "",
|
||||
"Context", "ContextConfig", "", "", "", "", "", "",
|
||||
"PageMask", "PageGrain", "", "", "", "", "", "",
|
||||
"Wired", "SRSConf0", "SRCConf1", "SRSConf2",
|
||||
"SRSConf3", "SRSConf4", "", "",
|
||||
"HWREna", "", "", "", "", "", "", "",
|
||||
"BadVAddr", "", "", "", "", "", "", "",
|
||||
"Count", "", "", "", "", "", "", "",
|
||||
"EntryHi", "", "", "", "", "", "", "",
|
||||
"Compare", "", "", "", "", "", "", "",
|
||||
"Status", "IntCtl", "SRSCtl", "SRSMap", "", "", "", "",
|
||||
"Cause", "", "", "", "", "", "", "",
|
||||
"EPC", "", "", "", "", "", "", "",
|
||||
"PRId", "EBase", "", "", "", "", "", "",
|
||||
"Config", "Config1", "Config2", "Config3", "", "", "", "",
|
||||
"LLAddr", "", "", "", "", "", "", "",
|
||||
"WatchLo0", "WatchLo1", "WatchLo2", "WatchLo3",
|
||||
"WatchLo4", "WatchLo5", "WatchLo6", "WatchLo7",
|
||||
"WatchHi0", "WatchHi1", "WatchHi2", "WatchHi3",
|
||||
"WatchHi4", "WatchHi5", "WatchHi6", "WatchHi7",
|
||||
"XCContext64", "", "", "", "", "", "", "",
|
||||
"", "", "", "", "", "", "", "",
|
||||
"", "", "", "", "", "", "", "",
|
||||
"Debug", "TraceControl1", "TraceControl2", "UserTraceData",
|
||||
"TraceBPC", "", "", "",
|
||||
"DEPC", "", "", "", "", "", "", "",
|
||||
"PerfCnt0", "PerfCnt1", "PerfCnt2", "PerfCnt3",
|
||||
"PerfCnt4", "PerfCnt5", "PerfCnt6", "PerfCnt7",
|
||||
"ErrCtl", "", "", "", "", "", "", "",
|
||||
"CacheErr0", "CacheErr1", "CacheErr2", "CacheErr3", "", "", "", "",
|
||||
"TagLo0", "DataLo1", "TagLo2", "DataLo3",
|
||||
"TagLo4", "DataLo5", "TagLo6", "DataLo7",
|
||||
"TagHi0", "DataHi1", "TagHi2", "DataHi3",
|
||||
"TagHi4", "DataHi5", "TagHi6", "DataHi7",
|
||||
"ErrorEPC", "", "", "", "", "", "", "",
|
||||
"DESAVE", "", "", "", "", "", "", "",
|
||||
"LLFlag"
|
||||
};
|
||||
|
||||
ISA::ISA(uint8_t num_threads, uint8_t num_vpes)
|
||||
{
|
||||
numThreads = num_threads;
|
||||
numVpes = num_vpes;
|
||||
|
||||
miscRegFile.resize(NumMiscRegs);
|
||||
bankType.resize(NumMiscRegs);
|
||||
|
||||
for (int i=0; i < NumMiscRegs; i++) {
|
||||
miscRegFile[i].resize(1);
|
||||
bankType[i] = perProcessor;
|
||||
}
|
||||
|
||||
miscRegFile_WriteMask.resize(NumMiscRegs);
|
||||
|
||||
for (int i = 0; i < NumMiscRegs; i++) {
|
||||
miscRegFile_WriteMask[i].push_back(0);
|
||||
}
|
||||
|
||||
// Initialize all Per-VPE regs
|
||||
uint32_t per_vpe_regs[] = { MISCREG_VPE_CONTROL,
|
||||
MISCREG_VPE_CONF0, MISCREG_VPE_CONF1,
|
||||
MISCREG_YQMASK,
|
||||
MISCREG_VPE_SCHEDULE, MISCREG_VPE_SCHEFBACK,
|
||||
MISCREG_VPE_OPT, MISCREG_SRS_CONF0,
|
||||
MISCREG_SRS_CONF1, MISCREG_SRS_CONF2,
|
||||
MISCREG_SRS_CONF3, MISCREG_SRS_CONF4,
|
||||
MISCREG_EBASE
|
||||
};
|
||||
uint32_t num_vpe_regs = sizeof(per_vpe_regs) / 4;
|
||||
for (int i = 0; i < num_vpe_regs; i++) {
|
||||
if (numVpes > 1) {
|
||||
miscRegFile[per_vpe_regs[i]].resize(numVpes);
|
||||
}
|
||||
bankType[per_vpe_regs[i]] = perVirtProcessor;
|
||||
}
|
||||
|
||||
// Initialize all Per-TC regs
|
||||
uint32_t per_tc_regs[] = { MISCREG_STATUS,
|
||||
MISCREG_TC_STATUS, MISCREG_TC_BIND,
|
||||
MISCREG_TC_RESTART, MISCREG_TC_HALT,
|
||||
MISCREG_TC_CONTEXT, MISCREG_TC_SCHEDULE,
|
||||
MISCREG_TC_SCHEFBACK,
|
||||
MISCREG_DEBUG, MISCREG_LLADDR
|
||||
};
|
||||
uint32_t num_tc_regs = sizeof(per_tc_regs) / 4;
|
||||
|
||||
for (int i = 0; i < num_tc_regs; i++) {
|
||||
miscRegFile[per_tc_regs[i]].resize(numThreads);
|
||||
bankType[per_tc_regs[i]] = perThreadContext;
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
void
|
||||
ISA::clear()
|
||||
{
|
||||
for(int i = 0; i < NumMiscRegs; i++) {
|
||||
for (int j = 0; j < miscRegFile[i].size(); j++)
|
||||
miscRegFile[i][j] = 0;
|
||||
|
||||
for (int k = 0; k < miscRegFile_WriteMask[i].size(); k++)
|
||||
miscRegFile_WriteMask[i][k] = (long unsigned int)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ISA::configCP()
|
||||
{
|
||||
DPRINTF(MipsPRA, "Resetting CP0 State with %i TCs and %i VPEs\n",
|
||||
numThreads, numVpes);
|
||||
|
||||
CoreSpecific cp;
|
||||
panic("CP state must be set before the following code is used");
|
||||
|
||||
// Do Default CP0 initialization HERE
|
||||
|
||||
// Do Initialization for MT cores here (eventually use
|
||||
// core_name parameter to toggle this initialization)
|
||||
// ===================================================
|
||||
DPRINTF(MipsPRA, "Initializing CP0 State.... ");
|
||||
|
||||
PRIdReg procId = readMiscRegNoEffect(MISCREG_PRID);
|
||||
procId.coOp = cp.CP0_PRId_CompanyOptions;
|
||||
procId.coId = cp.CP0_PRId_CompanyID;
|
||||
procId.procId = cp.CP0_PRId_ProcessorID;
|
||||
procId.rev = cp.CP0_PRId_Revision;
|
||||
setMiscRegNoEffect(MISCREG_PRID, procId);
|
||||
|
||||
// Now, create Write Mask for ProcID register
|
||||
MiscReg procIDMask = 0; // Read-Only register
|
||||
replaceBits(procIDMask, 0, 32, 0);
|
||||
setRegMask(MISCREG_PRID, procIDMask);
|
||||
|
||||
// Config
|
||||
ConfigReg cfg = readMiscRegNoEffect(MISCREG_CONFIG);
|
||||
cfg.be = cp.CP0_Config_BE;
|
||||
cfg.at = cp.CP0_Config_AT;
|
||||
cfg.ar = cp.CP0_Config_AR;
|
||||
cfg.mt = cp.CP0_Config_MT;
|
||||
cfg.vi = cp.CP0_Config_VI;
|
||||
cfg.m = 1;
|
||||
setMiscRegNoEffect(MISCREG_CONFIG, cfg);
|
||||
// Now, create Write Mask for Config register
|
||||
MiscReg cfg_Mask = 0x7FFF0007;
|
||||
replaceBits(cfg_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CONFIG, cfg_Mask);
|
||||
|
||||
// Config1
|
||||
Config1Reg cfg1 = readMiscRegNoEffect(MISCREG_CONFIG1);
|
||||
cfg1.mmuSize = cp.CP0_Config1_MMU;
|
||||
cfg1.is = cp.CP0_Config1_IS;
|
||||
cfg1.il = cp.CP0_Config1_IL;
|
||||
cfg1.ia = cp.CP0_Config1_IA;
|
||||
cfg1.ds = cp.CP0_Config1_DS;
|
||||
cfg1.dl = cp.CP0_Config1_DL;
|
||||
cfg1.da = cp.CP0_Config1_DA;
|
||||
cfg1.fp = cp.CP0_Config1_FP;
|
||||
cfg1.ep = cp.CP0_Config1_EP;
|
||||
cfg1.wr = cp.CP0_Config1_WR;
|
||||
cfg1.md = cp.CP0_Config1_MD;
|
||||
cfg1.c2 = cp.CP0_Config1_C2;
|
||||
cfg1.pc = cp.CP0_Config1_PC;
|
||||
cfg1.m = cp.CP0_Config1_M;
|
||||
setMiscRegNoEffect(MISCREG_CONFIG1, cfg1);
|
||||
// Now, create Write Mask for Config register
|
||||
MiscReg cfg1_Mask = 0; // Read Only Register
|
||||
replaceBits(cfg1_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CONFIG1, cfg1_Mask);
|
||||
|
||||
// Config2
|
||||
Config2Reg cfg2 = readMiscRegNoEffect(MISCREG_CONFIG2);
|
||||
cfg2.tu = cp.CP0_Config2_TU;
|
||||
cfg2.ts = cp.CP0_Config2_TS;
|
||||
cfg2.tl = cp.CP0_Config2_TL;
|
||||
cfg2.ta = cp.CP0_Config2_TA;
|
||||
cfg2.su = cp.CP0_Config2_SU;
|
||||
cfg2.ss = cp.CP0_Config2_SS;
|
||||
cfg2.sl = cp.CP0_Config2_SL;
|
||||
cfg2.sa = cp.CP0_Config2_SA;
|
||||
cfg2.m = cp.CP0_Config2_M;
|
||||
setMiscRegNoEffect(MISCREG_CONFIG2, cfg2);
|
||||
// Now, create Write Mask for Config register
|
||||
MiscReg cfg2_Mask = 0x7000F000; // Read Only Register
|
||||
replaceBits(cfg2_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CONFIG2, cfg2_Mask);
|
||||
|
||||
// Config3
|
||||
Config3Reg cfg3 = readMiscRegNoEffect(MISCREG_CONFIG3);
|
||||
cfg3.dspp = cp.CP0_Config3_DSPP;
|
||||
cfg3.lpa = cp.CP0_Config3_LPA;
|
||||
cfg3.veic = cp.CP0_Config3_VEIC;
|
||||
cfg3.vint = cp.CP0_Config3_VInt;
|
||||
cfg3.sp = cp.CP0_Config3_SP;
|
||||
cfg3.mt = cp.CP0_Config3_MT;
|
||||
cfg3.sm = cp.CP0_Config3_SM;
|
||||
cfg3.tl = cp.CP0_Config3_TL;
|
||||
setMiscRegNoEffect(MISCREG_CONFIG3, cfg3);
|
||||
// Now, create Write Mask for Config register
|
||||
MiscReg cfg3_Mask = 0; // Read Only Register
|
||||
replaceBits(cfg3_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CONFIG3, cfg3_Mask);
|
||||
|
||||
// EBase - CPUNum
|
||||
EBaseReg eBase = readMiscRegNoEffect(MISCREG_EBASE);
|
||||
eBase.cpuNum = cp.CP0_EBase_CPUNum;
|
||||
replaceBits(eBase, 31, 31, 1);
|
||||
setMiscRegNoEffect(MISCREG_EBASE, eBase);
|
||||
// Now, create Write Mask for Config register
|
||||
MiscReg EB_Mask = 0x3FFFF000;// Except Exception Base, the
|
||||
// entire register is read only
|
||||
replaceBits(EB_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_EBASE, EB_Mask);
|
||||
|
||||
// SRS Control - HSS (Highest Shadow Set)
|
||||
SRSCtlReg scsCtl = readMiscRegNoEffect(MISCREG_SRSCTL);
|
||||
scsCtl.hss = cp.CP0_SrsCtl_HSS;
|
||||
setMiscRegNoEffect(MISCREG_SRSCTL, scsCtl);
|
||||
// Now, create Write Mask for the SRS Ctl register
|
||||
MiscReg SC_Mask = 0x0000F3C0;
|
||||
replaceBits(SC_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_SRSCTL, SC_Mask);
|
||||
|
||||
// IntCtl - IPTI, IPPCI
|
||||
IntCtlReg intCtl = readMiscRegNoEffect(MISCREG_INTCTL);
|
||||
intCtl.ipti = cp.CP0_IntCtl_IPTI;
|
||||
intCtl.ippci = cp.CP0_IntCtl_IPPCI;
|
||||
setMiscRegNoEffect(MISCREG_INTCTL, intCtl);
|
||||
// Now, create Write Mask for the IntCtl register
|
||||
MiscReg IC_Mask = 0x000003E0;
|
||||
replaceBits(IC_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_INTCTL, IC_Mask);
|
||||
|
||||
// Watch Hi - M - FIXME (More than 1 Watch register)
|
||||
WatchHiReg watchHi = readMiscRegNoEffect(MISCREG_WATCHHI0);
|
||||
watchHi.m = cp.CP0_WatchHi_M;
|
||||
setMiscRegNoEffect(MISCREG_WATCHHI0, watchHi);
|
||||
// Now, create Write Mask for the IntCtl register
|
||||
MiscReg wh_Mask = 0x7FFF0FFF;
|
||||
replaceBits(wh_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_WATCHHI0, wh_Mask);
|
||||
|
||||
// Perf Ctr - M - FIXME (More than 1 PerfCnt Pair)
|
||||
PerfCntCtlReg perfCntCtl = readMiscRegNoEffect(MISCREG_PERFCNT0);
|
||||
perfCntCtl.m = cp.CP0_PerfCtr_M;
|
||||
perfCntCtl.w = cp.CP0_PerfCtr_W;
|
||||
setMiscRegNoEffect(MISCREG_PERFCNT0, perfCntCtl);
|
||||
// Now, create Write Mask for the IntCtl register
|
||||
MiscReg pc_Mask = 0x00007FF;
|
||||
replaceBits(pc_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_PERFCNT0, pc_Mask);
|
||||
|
||||
// Random
|
||||
setMiscRegNoEffect(MISCREG_CP0_RANDOM, 63);
|
||||
// Now, create Write Mask for the IntCtl register
|
||||
MiscReg random_Mask = 0;
|
||||
replaceBits(random_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CP0_RANDOM, random_Mask);
|
||||
|
||||
// PageGrain
|
||||
PageGrainReg pageGrain = readMiscRegNoEffect(MISCREG_PAGEGRAIN);
|
||||
pageGrain.esp = cp.CP0_Config3_SP;
|
||||
setMiscRegNoEffect(MISCREG_PAGEGRAIN, pageGrain);
|
||||
// Now, create Write Mask for the IntCtl register
|
||||
MiscReg pg_Mask = 0x10000000;
|
||||
replaceBits(pg_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_PAGEGRAIN, pg_Mask);
|
||||
|
||||
// Status
|
||||
StatusReg status = readMiscRegNoEffect(MISCREG_STATUS);
|
||||
// Only CU0 and IE are modified on a reset - everything else needs
|
||||
// to be controlled on a per CPU model basis
|
||||
|
||||
// Enable CP0 on reset
|
||||
// status.cu0 = 1;
|
||||
|
||||
// Enable ERL bit on a reset
|
||||
status.erl = 1;
|
||||
// Enable BEV bit on a reset
|
||||
status.bev = 1;
|
||||
|
||||
setMiscRegNoEffect(MISCREG_STATUS, status);
|
||||
// Now, create Write Mask for the Status register
|
||||
MiscReg stat_Mask = 0xFF78FF17;
|
||||
replaceBits(stat_Mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_STATUS, stat_Mask);
|
||||
|
||||
|
||||
// MVPConf0
|
||||
MVPConf0Reg mvpConf0 = readMiscRegNoEffect(MISCREG_MVP_CONF0);
|
||||
mvpConf0.tca = 1;
|
||||
mvpConf0.pvpe = numVpes - 1;
|
||||
mvpConf0.ptc = numThreads - 1;
|
||||
setMiscRegNoEffect(MISCREG_MVP_CONF0, mvpConf0);
|
||||
|
||||
// VPEConf0
|
||||
VPEConf0Reg vpeConf0 = readMiscRegNoEffect(MISCREG_VPE_CONF0);
|
||||
vpeConf0.mvp = 1;
|
||||
setMiscRegNoEffect(MISCREG_VPE_CONF0, vpeConf0);
|
||||
|
||||
// TCBind
|
||||
for (ThreadID tid = 0; tid < numThreads; tid++) {
|
||||
TCBindReg tcBind = readMiscRegNoEffect(MISCREG_TC_BIND, tid);
|
||||
tcBind.curTC = tid;
|
||||
setMiscRegNoEffect(MISCREG_TC_BIND, tcBind, tid);
|
||||
}
|
||||
// TCHalt
|
||||
TCHaltReg tcHalt = readMiscRegNoEffect(MISCREG_TC_HALT);
|
||||
tcHalt.h = 0;
|
||||
setMiscRegNoEffect(MISCREG_TC_HALT, tcHalt);
|
||||
|
||||
// TCStatus
|
||||
// Set TCStatus Activated to 1 for the initial thread that is running
|
||||
TCStatusReg tcStatus = readMiscRegNoEffect(MISCREG_TC_STATUS);
|
||||
tcStatus.a = 1;
|
||||
setMiscRegNoEffect(MISCREG_TC_STATUS, tcStatus);
|
||||
|
||||
// Set Dynamically Allocatable bit to 1 for all other threads
|
||||
for (ThreadID tid = 1; tid < numThreads; tid++) {
|
||||
tcStatus = readMiscRegNoEffect(MISCREG_TC_STATUS, tid);
|
||||
tcStatus.da = 1;
|
||||
setMiscRegNoEffect(MISCREG_TC_STATUS, tcStatus, tid);
|
||||
}
|
||||
|
||||
|
||||
MiscReg mask = 0x7FFFFFFF;
|
||||
|
||||
// Now, create Write Mask for the Index register
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_INDEX, mask);
|
||||
|
||||
mask = 0x3FFFFFFF;
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_ENTRYLO0, mask);
|
||||
setRegMask(MISCREG_ENTRYLO1, mask);
|
||||
|
||||
mask = 0xFF800000;
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CONTEXT, mask);
|
||||
|
||||
mask = 0x1FFFF800;
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_PAGEMASK, mask);
|
||||
|
||||
mask = 0x0;
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_BADVADDR, mask);
|
||||
setRegMask(MISCREG_LLADDR, mask);
|
||||
|
||||
mask = 0x08C00300;
|
||||
replaceBits(mask, 0, 32, 0);
|
||||
setRegMask(MISCREG_CAUSE, mask);
|
||||
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
ISA::getVPENum(ThreadID tid)
|
||||
{
|
||||
TCBindReg tcBind = miscRegFile[MISCREG_TC_BIND][tid];
|
||||
return tcBind.curVPE;
|
||||
}
|
||||
|
||||
MiscReg
|
||||
ISA::readMiscRegNoEffect(int misc_reg, ThreadID tid)
|
||||
{
|
||||
unsigned reg_sel = (bankType[misc_reg] == perThreadContext)
|
||||
? tid : getVPENum(tid);
|
||||
DPRINTF(MipsPRA, "Reading CP0 Register:%u Select:%u (%s) (%lx).\n",
|
||||
misc_reg / 8, misc_reg % 8, miscRegNames[misc_reg],
|
||||
miscRegFile[misc_reg][reg_sel]);
|
||||
return miscRegFile[misc_reg][reg_sel];
|
||||
}
|
||||
|
||||
//@TODO: MIPS MT's register view automatically connects
|
||||
// Status to TCStatus depending on current thread
|
||||
//template <class TC>
|
||||
MiscReg
|
||||
ISA::readMiscReg(int misc_reg, ThreadContext *tc, ThreadID tid)
|
||||
{
|
||||
unsigned reg_sel = (bankType[misc_reg] == perThreadContext)
|
||||
? tid : getVPENum(tid);
|
||||
DPRINTF(MipsPRA,
|
||||
"Reading CP0 Register:%u Select:%u (%s) with effect (%lx).\n",
|
||||
misc_reg / 8, misc_reg % 8, miscRegNames[misc_reg],
|
||||
miscRegFile[misc_reg][reg_sel]);
|
||||
|
||||
return miscRegFile[misc_reg][reg_sel];
|
||||
}
|
||||
|
||||
void
|
||||
ISA::setMiscRegNoEffect(int misc_reg, const MiscReg &val, ThreadID tid)
|
||||
{
|
||||
unsigned reg_sel = (bankType[misc_reg] == perThreadContext)
|
||||
? tid : getVPENum(tid);
|
||||
DPRINTF(MipsPRA,
|
||||
"[tid:%i]: Setting (direct set) CP0 Register:%u "
|
||||
"Select:%u (%s) to %#x.\n",
|
||||
tid, misc_reg / 8, misc_reg % 8, miscRegNames[misc_reg], val);
|
||||
|
||||
miscRegFile[misc_reg][reg_sel] = val;
|
||||
}
|
||||
|
||||
void
|
||||
ISA::setRegMask(int misc_reg, const MiscReg &val, ThreadID tid)
|
||||
{
|
||||
unsigned reg_sel = (bankType[misc_reg] == perThreadContext)
|
||||
? tid : getVPENum(tid);
|
||||
DPRINTF(MipsPRA,
|
||||
"[tid:%i]: Setting CP0 Register: %u Select: %u (%s) to %#x\n",
|
||||
tid, misc_reg / 8, misc_reg % 8, miscRegNames[misc_reg], val);
|
||||
miscRegFile_WriteMask[misc_reg][reg_sel] = val;
|
||||
}
|
||||
|
||||
// PROGRAMMER'S NOTES:
|
||||
// (1) Some CP0 Registers have fields that cannot
|
||||
// be overwritten. Make sure to handle those particular registers
|
||||
// with care!
|
||||
void
|
||||
ISA::setMiscReg(int misc_reg, const MiscReg &val,
|
||||
ThreadContext *tc, ThreadID tid)
|
||||
{
|
||||
int reg_sel = (bankType[misc_reg] == perThreadContext)
|
||||
? tid : getVPENum(tid);
|
||||
|
||||
DPRINTF(MipsPRA,
|
||||
"[tid:%i]: Setting CP0 Register:%u "
|
||||
"Select:%u (%s) to %#x, with effect.\n",
|
||||
tid, misc_reg / 8, misc_reg % 8, miscRegNames[misc_reg], val);
|
||||
|
||||
MiscReg cp0_val = filterCP0Write(misc_reg, reg_sel, val);
|
||||
|
||||
miscRegFile[misc_reg][reg_sel] = cp0_val;
|
||||
|
||||
scheduleCP0Update(tc->getCpuPtr(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method doesn't need to adjust the Control Register Offset
|
||||
* since it has already been done in the calling method
|
||||
* (setRegWithEffect)
|
||||
*/
|
||||
MiscReg
|
||||
ISA::filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val)
|
||||
{
|
||||
MiscReg retVal = val;
|
||||
|
||||
// Mask off read-only regions
|
||||
retVal &= miscRegFile_WriteMask[misc_reg][reg_sel];
|
||||
MiscReg curVal = miscRegFile[misc_reg][reg_sel];
|
||||
// Mask off current alue with inverse mask (clear writeable bits)
|
||||
curVal &= (~miscRegFile_WriteMask[misc_reg][reg_sel]);
|
||||
retVal |= curVal; // Combine the two
|
||||
DPRINTF(MipsPRA,
|
||||
"filterCP0Write: Mask: %lx, Inverse Mask: %lx, write Val: %x, "
|
||||
"current val: %lx, written val: %x\n",
|
||||
miscRegFile_WriteMask[misc_reg][reg_sel],
|
||||
~miscRegFile_WriteMask[misc_reg][reg_sel],
|
||||
val, miscRegFile[misc_reg][reg_sel], retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void
|
||||
ISA::scheduleCP0Update(BaseCPU *cpu, int delay)
|
||||
{
|
||||
if (!cp0Updated) {
|
||||
cp0Updated = true;
|
||||
|
||||
//schedule UPDATE
|
||||
CP0Event *cp0_event = new CP0Event(this, cpu, UpdateCP0);
|
||||
cpu->schedule(cp0_event, curTick() + cpu->ticks(delay));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ISA::updateCPU(BaseCPU *cpu)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// EVALUATE CP0 STATE FOR MIPS MT
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
MVPConf0Reg mvpConf0 = readMiscRegNoEffect(MISCREG_MVP_CONF0);
|
||||
ThreadID num_threads = mvpConf0.ptc + 1;
|
||||
|
||||
for (ThreadID tid = 0; tid < num_threads; tid++) {
|
||||
TCStatusReg tcStatus = readMiscRegNoEffect(MISCREG_TC_STATUS, tid);
|
||||
TCHaltReg tcHalt = readMiscRegNoEffect(MISCREG_TC_HALT, tid);
|
||||
|
||||
//@todo: add vpe/mt check here thru mvpcontrol & vpecontrol regs
|
||||
if (tcHalt.h == 1 || tcStatus.a == 0) {
|
||||
haltThread(cpu->getContext(tid));
|
||||
} else if (tcHalt.h == 0 && tcStatus.a == 1) {
|
||||
restoreThread(cpu->getContext(tid));
|
||||
}
|
||||
}
|
||||
|
||||
num_threads = mvpConf0.ptc + 1;
|
||||
|
||||
// Toggle update flag after we finished updating
|
||||
cp0Updated = false;
|
||||
}
|
||||
|
||||
ISA::CP0Event::CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type)
|
||||
: Event(CPU_Tick_Pri), cp0(_cp0), cpu(_cpu), cp0EventType(e_type)
|
||||
{ }
|
||||
|
||||
void
|
||||
ISA::CP0Event::process()
|
||||
{
|
||||
switch (cp0EventType)
|
||||
{
|
||||
case UpdateCP0:
|
||||
cp0->updateCPU(cpu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
ISA::CP0Event::description() const
|
||||
{
|
||||
return "Coprocessor-0 event";
|
||||
}
|
||||
|
||||
void
|
||||
ISA::CP0Event::scheduleEvent(int delay)
|
||||
{
|
||||
cpu->reschedule(this, curTick() + cpu->ticks(delay), true);
|
||||
}
|
||||
|
||||
void
|
||||
ISA::CP0Event::unscheduleEvent()
|
||||
{
|
||||
if (scheduled())
|
||||
squash();
|
||||
}
|
||||
|
||||
}
|
||||
179
simulators/gem5/src/arch/mips/isa.hh
Normal file
179
simulators/gem5/src/arch/mips/isa.hh
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 2009 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_ISA_HH__
|
||||
#define __ARCH_MIPS_ISA_HH__
|
||||
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "arch/mips/registers.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "sim/eventq.hh"
|
||||
#include "sim/fault_fwd.hh"
|
||||
|
||||
class BaseCPU;
|
||||
class Checkpoint;
|
||||
class EventManager;
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
class ISA
|
||||
{
|
||||
public:
|
||||
// The MIPS name for this file is CP0 or Coprocessor 0
|
||||
typedef ISA CP0;
|
||||
|
||||
protected:
|
||||
// Number of threads and vpes an individual ISA state can handle
|
||||
uint8_t numThreads;
|
||||
uint8_t numVpes;
|
||||
|
||||
enum BankType {
|
||||
perProcessor,
|
||||
perThreadContext,
|
||||
perVirtProcessor
|
||||
};
|
||||
|
||||
std::vector<std::vector<MiscReg> > miscRegFile;
|
||||
std::vector<std::vector<MiscReg> > miscRegFile_WriteMask;
|
||||
std::vector<BankType> bankType;
|
||||
|
||||
public:
|
||||
ISA(uint8_t num_threads = 1, uint8_t num_vpes = 1);
|
||||
|
||||
void clear();
|
||||
|
||||
void configCP();
|
||||
|
||||
unsigned getVPENum(ThreadID tid);
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// READ/WRITE CP0 STATE
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
//@TODO: MIPS MT's register view automatically connects
|
||||
// Status to TCStatus depending on current thread
|
||||
void updateCP0ReadView(int misc_reg, ThreadID tid) { }
|
||||
MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0);
|
||||
|
||||
//template <class TC>
|
||||
MiscReg readMiscReg(int misc_reg,
|
||||
ThreadContext *tc, ThreadID tid = 0);
|
||||
|
||||
MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val);
|
||||
void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0);
|
||||
void setMiscRegNoEffect(int misc_reg, const MiscReg &val,
|
||||
ThreadID tid = 0);
|
||||
|
||||
//template <class TC>
|
||||
void setMiscReg(int misc_reg, const MiscReg &val,
|
||||
ThreadContext *tc, ThreadID tid = 0);
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0)
|
||||
// TO SCHEDULE EVENTS
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
// Flag that is set when CP0 state has been written to.
|
||||
bool cp0Updated;
|
||||
|
||||
// Enumerated List of CP0 Event Types
|
||||
enum CP0EventType {
|
||||
UpdateCP0
|
||||
};
|
||||
|
||||
// Declare A CP0Event Class for scheduling
|
||||
class CP0Event : public Event
|
||||
{
|
||||
protected:
|
||||
ISA::CP0 *cp0;
|
||||
BaseCPU *cpu;
|
||||
CP0EventType cp0EventType;
|
||||
Fault fault;
|
||||
|
||||
public:
|
||||
/** Constructs a CP0 event. */
|
||||
CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type);
|
||||
|
||||
/** Process this event. */
|
||||
virtual void process();
|
||||
|
||||
/** Returns the description of this event. */
|
||||
const char *description() const;
|
||||
|
||||
/** Schedule This Event */
|
||||
void scheduleEvent(int delay);
|
||||
|
||||
/** Unschedule This Event */
|
||||
void unscheduleEvent();
|
||||
};
|
||||
|
||||
// Schedule a CP0 Update Event
|
||||
void scheduleCP0Update(BaseCPU *cpu, int delay = 0);
|
||||
|
||||
// If any changes have been made, then check the state for changes
|
||||
// and if necessary alert the CPU
|
||||
void updateCPU(BaseCPU *cpu);
|
||||
|
||||
// Keep a List of CPU Events that need to be deallocated
|
||||
std::queue<CP0Event*> cp0EventRemoveList;
|
||||
|
||||
static std::string miscRegNames[NumMiscRegs];
|
||||
|
||||
public:
|
||||
|
||||
int
|
||||
flattenIntIndex(int reg)
|
||||
{
|
||||
return reg;
|
||||
}
|
||||
|
||||
int
|
||||
flattenFloatIndex(int reg)
|
||||
{
|
||||
return reg;
|
||||
}
|
||||
|
||||
void serialize(EventManager *em, std::ostream &os)
|
||||
{}
|
||||
void unserialize(EventManager *em, Checkpoint *cp,
|
||||
const std::string §ion)
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
118
simulators/gem5/src/arch/mips/isa/base.isa
Normal file
118
simulators/gem5/src/arch/mips/isa/base.isa
Normal file
@ -0,0 +1,118 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base class for MIPS instructions, and some support functions
|
||||
//
|
||||
|
||||
//Outputs to decoder.hh
|
||||
output header {{
|
||||
|
||||
using namespace MipsISA;
|
||||
|
||||
/**
|
||||
* Base class for all MIPS static instructions.
|
||||
*/
|
||||
class MipsStaticInst : public StaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
// Constructor
|
||||
MipsStaticInst(const char *mnem, MachInst _machInst, OpClass __opClass)
|
||||
: StaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
/// Print a register name for disassembly given the unique
|
||||
/// dependence tag number (FP or int).
|
||||
void printReg(std::ostream &os, int reg) const;
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
public:
|
||||
void
|
||||
advancePC(MipsISA::PCState &pc) const
|
||||
{
|
||||
pc.advance();
|
||||
}
|
||||
};
|
||||
|
||||
}};
|
||||
|
||||
//Ouputs to decoder.cc
|
||||
output decoder {{
|
||||
|
||||
void MipsStaticInst::printReg(std::ostream &os, int reg) const
|
||||
{
|
||||
if (reg < FP_Base_DepTag) {
|
||||
ccprintf(os, "r%d", reg);
|
||||
}
|
||||
else {
|
||||
ccprintf(os, "f%d", reg - FP_Base_DepTag);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MipsStaticInst::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
// Need to find standard way to not print
|
||||
// this info. Maybe add bool variable to
|
||||
// class?
|
||||
if (strcmp(mnemonic, "syscall") != 0) {
|
||||
if(_numDestRegs > 0){
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
}
|
||||
|
||||
if(_numSrcRegs > 0) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
if(_numSrcRegs > 1) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Should we define a separate inst. class
|
||||
// just for two insts?
|
||||
if (strcmp(mnemonic, "sll") == 0 || strcmp(mnemonic, "sra") == 0) {
|
||||
ccprintf(ss,", %d",SA);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
124
simulators/gem5/src/arch/mips/isa/bitfields.isa
Normal file
124
simulators/gem5/src/arch/mips/isa/bitfields.isa
Normal file
@ -0,0 +1,124 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
// Jaidev Patwardhan
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitfield definitions.
|
||||
//
|
||||
|
||||
def bitfield OPCODE <31:26>;
|
||||
def bitfield OPCODE_HI <31:29>;
|
||||
def bitfield OPCODE_LO <28:26>;
|
||||
|
||||
def bitfield REGIMM <20:16>;
|
||||
def bitfield REGIMM_HI <20:19>;
|
||||
def bitfield REGIMM_LO <18:16>;
|
||||
|
||||
def bitfield FUNCTION < 5: 0>;
|
||||
def bitfield FUNCTION_HI < 5: 3>;
|
||||
def bitfield FUNCTION_LO < 2: 0>;
|
||||
|
||||
def bitfield RS <25:21>;
|
||||
def bitfield RS_MSB <25:25>;
|
||||
def bitfield RS_HI <25:24>;
|
||||
def bitfield RS_LO <23:21>;
|
||||
def bitfield RS_SRL <25:22>;
|
||||
def bitfield RS_RT <25:16>;
|
||||
def bitfield RT <20:16>;
|
||||
def bitfield RT_HI <20:19>;
|
||||
def bitfield RT_LO <18:16>;
|
||||
def bitfield RT_RD <20:11>;
|
||||
def bitfield RD <15:11>;
|
||||
|
||||
def bitfield INTIMM <15: 0>;
|
||||
def bitfield RS_RT_INTIMM <25: 0>;
|
||||
|
||||
// Floating-point operate format
|
||||
def bitfield FMT <25:21>;
|
||||
def bitfield FR <25:21>;
|
||||
def bitfield FT <20:16>;
|
||||
def bitfield FS <15:11>;
|
||||
def bitfield FD <10:6>;
|
||||
|
||||
def bitfield ND <17:17>;
|
||||
def bitfield TF <16:16>;
|
||||
def bitfield MOVCI <16:16>;
|
||||
def bitfield MOVCF <16:16>;
|
||||
def bitfield SRL <21:21>;
|
||||
def bitfield SRLV < 6: 6>;
|
||||
def bitfield SA <10: 6>;
|
||||
|
||||
// Floating Point Condition Codes
|
||||
def bitfield CC <10:8>;
|
||||
def bitfield BRANCH_CC <20:18>;
|
||||
|
||||
// CP0 Register Select
|
||||
def bitfield SEL < 2: 0>;
|
||||
|
||||
// INTERRUPTS
|
||||
def bitfield SC < 5: 5>;
|
||||
|
||||
// Branch format
|
||||
def bitfield OFFSET <15: 0>; // displacement
|
||||
|
||||
// Jmp format
|
||||
def bitfield JMPTARG <25: 0>;
|
||||
def bitfield HINT <10: 6>;
|
||||
|
||||
def bitfield SYSCALLCODE <25: 6>;
|
||||
def bitfield TRAPCODE <15:13>;
|
||||
|
||||
// EXT/INS instructions
|
||||
def bitfield MSB <15:11>;
|
||||
def bitfield LSB <10: 6>;
|
||||
|
||||
// M5 instructions
|
||||
def bitfield M5FUNC <7:0>;
|
||||
|
||||
// DSP instructions
|
||||
def bitfield OP <10:6>;
|
||||
def bitfield OP_HI <10:9>;
|
||||
def bitfield OP_LO <8:6>;
|
||||
def bitfield DSPSA <23:21>;
|
||||
def bitfield HILOSA <25:20>;
|
||||
def bitfield RDDSPMASK <21:16>;
|
||||
def bitfield WRDSPMASK <16:11>;
|
||||
def bitfield ACSRC <22:21>;
|
||||
def bitfield ACDST <12:11>;
|
||||
def bitfield BP <12:11>;
|
||||
|
||||
// MT Instructions
|
||||
def bitfield POS <10: 6>;
|
||||
def bitfield MT_U <5:5>;
|
||||
def bitfield MT_H <4:4>;
|
||||
|
||||
//Cache Ops
|
||||
def bitfield CACHE_OP <20:16>;
|
||||
2521
simulators/gem5/src/arch/mips/isa/decoder.isa
Normal file
2521
simulators/gem5/src/arch/mips/isa/decoder.isa
Normal file
File diff suppressed because it is too large
Load Diff
99
simulators/gem5/src/arch/mips/isa/formats/basic.isa
Normal file
99
simulators/gem5/src/arch/mips/isa/formats/basic.isa
Normal file
@ -0,0 +1,99 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Steve Reinhardt
|
||||
// Korey Sewell
|
||||
|
||||
// Declarations for execute() methods.
|
||||
def template BasicExecDeclare {{
|
||||
Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
|
||||
}};
|
||||
|
||||
// Basic instruction class declaration template.
|
||||
def template BasicDeclare {{
|
||||
/**
|
||||
* Static instruction class for "%(mnemonic)s".
|
||||
*/
|
||||
class %(class_name)s : public %(base_class)s
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
%(class_name)s(MachInst machInst);
|
||||
%(BasicExecDeclare)s
|
||||
};
|
||||
}};
|
||||
|
||||
// Basic instruction class constructor template.
|
||||
def template BasicConstructor {{
|
||||
inline %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
|
||||
{
|
||||
%(constructor)s;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
// Basic instruction class execute method template.
|
||||
def template BasicExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(code)s;
|
||||
if(fault == NoFault){
|
||||
%(op_wb)s;
|
||||
}
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// Basic decode template.
|
||||
def template BasicDecode {{
|
||||
return new %(class_name)s(machInst);
|
||||
}};
|
||||
|
||||
// Basic decode template, passing mnemonic in as string arg to constructor.
|
||||
def template BasicDecodeWithMnemonic {{
|
||||
return new %(class_name)s("%(mnemonic)s", machInst);
|
||||
}};
|
||||
|
||||
// The most basic instruction format...
|
||||
def format BasicOp(code, *flags) {{
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
329
simulators/gem5/src/arch/mips/isa/formats/branch.isa
Normal file
329
simulators/gem5/src/arch/mips/isa/formats/branch.isa
Normal file
@ -0,0 +1,329 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Control transfer instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Base class for instructions whose disassembly is not purely a
|
||||
* function of the machine instruction (i.e., it depends on the
|
||||
* PC). This class overrides the disassemble() method to check
|
||||
* the PC and symbol table values before re-using a cached
|
||||
* disassembly string. This is necessary for branches and jumps,
|
||||
* where the disassembly string includes the target address (which
|
||||
* may depend on the PC and/or symbol table).
|
||||
*/
|
||||
class PCDependentDisassembly : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
/// Cached program counter from last disassembly
|
||||
mutable Addr cachedPC;
|
||||
|
||||
/// Cached symbol table pointer from last disassembly
|
||||
mutable const SymbolTable *cachedSymtab;
|
||||
|
||||
/// Constructor
|
||||
PCDependentDisassembly(const char *mnem, MachInst _machInst,
|
||||
OpClass __opClass)
|
||||
: MipsStaticInst(mnem, _machInst, __opClass),
|
||||
cachedPC(0), cachedSymtab(0)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string &
|
||||
disassemble(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for branches (PC-relative control transfers),
|
||||
* conditional or unconditional.
|
||||
*/
|
||||
class Branch : public PCDependentDisassembly
|
||||
{
|
||||
protected:
|
||||
/// target address (signed) Displacement .
|
||||
int32_t disp;
|
||||
|
||||
/// Constructor.
|
||||
Branch(const char *mnem, MachInst _machInst, OpClass __opClass)
|
||||
: PCDependentDisassembly(mnem, _machInst, __opClass),
|
||||
disp(OFFSET << 2)
|
||||
{
|
||||
//If Bit 17 is 1 then Sign Extend
|
||||
if ( (disp & 0x00020000) > 0 ) {
|
||||
disp |= 0xFFFE0000;
|
||||
}
|
||||
}
|
||||
|
||||
MipsISA::PCState branchTarget(const MipsISA::PCState &branchPC) const;
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for jumps (register-indirect control transfers). In
|
||||
* the Mips ISA, these are always unconditional.
|
||||
*/
|
||||
class Jump : public PCDependentDisassembly
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Displacement to target address (signed).
|
||||
int32_t disp;
|
||||
|
||||
uint32_t target;
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
Jump(const char *mnem, MachInst _machInst, OpClass __opClass)
|
||||
: PCDependentDisassembly(mnem, _machInst, __opClass),
|
||||
disp(JMPTARG << 2)
|
||||
{
|
||||
}
|
||||
|
||||
MipsISA::PCState branchTarget(ThreadContext *tc) const;
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
MipsISA::PCState
|
||||
Branch::branchTarget(const MipsISA::PCState &branchPC) const
|
||||
{
|
||||
MipsISA::PCState target = branchPC;
|
||||
target.advance();
|
||||
target.npc(branchPC.pc() + sizeof(MachInst) + disp);
|
||||
target.nnpc(target.npc() + sizeof(MachInst));
|
||||
return target;
|
||||
}
|
||||
|
||||
MipsISA::PCState
|
||||
Jump::branchTarget(ThreadContext *tc) const
|
||||
{
|
||||
MipsISA::PCState target = tc->pcState();
|
||||
Addr pc = target.pc();
|
||||
target.advance();
|
||||
target.npc((pc & 0xF0000000) | disp);
|
||||
target.nnpc(target.npc() + sizeof(MachInst));
|
||||
return target;
|
||||
}
|
||||
|
||||
const std::string &
|
||||
PCDependentDisassembly::disassemble(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
if (!cachedDisassembly ||
|
||||
pc != cachedPC || symtab != cachedSymtab)
|
||||
{
|
||||
if (cachedDisassembly)
|
||||
delete cachedDisassembly;
|
||||
|
||||
cachedDisassembly =
|
||||
new std::string(generateDisassembly(pc, symtab));
|
||||
cachedPC = pc;
|
||||
cachedSymtab = symtab;
|
||||
}
|
||||
|
||||
return *cachedDisassembly;
|
||||
}
|
||||
|
||||
std::string
|
||||
Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
// There's only one register arg (RA), but it could be
|
||||
// either a source (the condition for conditional
|
||||
// branches) or a destination (the link reg for
|
||||
// unconditional branches)
|
||||
if (_numSrcRegs == 1) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
ss << ", ";
|
||||
} else if(_numSrcRegs == 2) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
ss << ", ";
|
||||
}
|
||||
|
||||
Addr target = pc + 4 + disp;
|
||||
|
||||
std::string str;
|
||||
if (symtab && symtab->findSymbol(target, str))
|
||||
ss << str;
|
||||
else
|
||||
ccprintf(ss, "0x%x", target);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string
|
||||
Jump::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
if ( strcmp(mnemonic,"jal") == 0 ) {
|
||||
Addr npc = pc + 4;
|
||||
ccprintf(ss,"0x%x",(npc & 0xF0000000) | disp);
|
||||
} else if (_numSrcRegs == 0) {
|
||||
std::string str;
|
||||
if (symtab && symtab->findSymbol(disp, str))
|
||||
ss << str;
|
||||
else
|
||||
ccprintf(ss, "0x%x", disp);
|
||||
} else if (_numSrcRegs == 1) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
} else if(_numSrcRegs == 2) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
}};
|
||||
|
||||
def format Branch(code, *opt_flags) {{
|
||||
not_taken_code = 'NNPC = NNPC; NPC = NPC;'
|
||||
|
||||
#Build Instruction Flags
|
||||
#Use Link & Likely Flags to Add Link/Condition Code
|
||||
inst_flags = ('IsDirectControl', )
|
||||
for x in opt_flags:
|
||||
if x == 'Link':
|
||||
code += 'R31 = NNPC;\n'
|
||||
elif x == 'Likely':
|
||||
not_taken_code = 'NNPC = NPC; NPC = PC;'
|
||||
inst_flags += ('IsCondDelaySlot', )
|
||||
else:
|
||||
inst_flags += (x, )
|
||||
|
||||
#Take into account uncond. branch instruction
|
||||
if 'cond = 1' in code:
|
||||
inst_flags += ('IsUncondControl', )
|
||||
else:
|
||||
inst_flags += ('IsCondControl', )
|
||||
|
||||
#Condition code
|
||||
code = '''
|
||||
bool cond;
|
||||
%(code)s
|
||||
if (cond) {
|
||||
NNPC = NPC + disp;
|
||||
} else {
|
||||
%(not_taken_code)s
|
||||
}
|
||||
''' % { "code" : code, "not_taken_code" : not_taken_code }
|
||||
|
||||
iop = InstObjParams(name, Name, 'Branch', code, inst_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format DspBranch(code, *opt_flags) {{
|
||||
not_taken_code = 'NNPC = NNPC; NPC = NPC;'
|
||||
|
||||
#Build Instruction Flags
|
||||
#Use Link & Likely Flags to Add Link/Condition Code
|
||||
inst_flags = ('IsDirectControl', )
|
||||
for x in opt_flags:
|
||||
if x == 'Link':
|
||||
code += 'R32 = NNPC;'
|
||||
elif x == 'Likely':
|
||||
not_taken_code = 'NNPC = NPC, NPC = PC;'
|
||||
inst_flags += ('IsCondDelaySlot', )
|
||||
else:
|
||||
inst_flags += (x, )
|
||||
|
||||
#Take into account uncond. branch instruction
|
||||
if 'cond = 1' in code:
|
||||
inst_flags += ('IsUncondControl', )
|
||||
else:
|
||||
inst_flags += ('IsCondControl', )
|
||||
|
||||
#Condition code
|
||||
code = '''
|
||||
bool cond;
|
||||
uint32_t dspctl = DSPControl;
|
||||
%(code)s
|
||||
if (cond) {
|
||||
NNPC = NPC + disp;
|
||||
} else {
|
||||
%(not_taken_code)s
|
||||
}
|
||||
''' % { "code" : code, "not_taken_code" : not_taken_code }
|
||||
|
||||
iop = InstObjParams(name, Name, 'Branch', code, inst_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format Jump(code, *opt_flags) {{
|
||||
#Build Instruction Flags
|
||||
#Use Link Flag to Add Link Code
|
||||
inst_flags = ('IsIndirectControl', 'IsUncondControl')
|
||||
for x in opt_flags:
|
||||
if x == 'Link':
|
||||
code = '''
|
||||
R31 = NNPC;
|
||||
''' + code
|
||||
elif x == 'ClearHazards':
|
||||
code += '/* Code Needed to Clear Execute & Inst Hazards */\n'
|
||||
else:
|
||||
inst_flags += (x, )
|
||||
|
||||
iop = InstObjParams(name, Name, 'Jump', code, inst_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
247
simulators/gem5/src/arch/mips/isa/formats/control.isa
Normal file
247
simulators/gem5/src/arch/mips/isa/formats/control.isa
Normal file
@ -0,0 +1,247 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
// Jaidev Patwardhan
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Coprocessor instructions
|
||||
//
|
||||
|
||||
//Outputs to decoder.hh
|
||||
output header {{
|
||||
|
||||
class CP0Control : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
CP0Control(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
class CP0TLB : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
CP0TLB(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
|
||||
class CP1Control : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
CP1Control(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
}};
|
||||
|
||||
// Basic instruction class execute method template.
|
||||
def template CP0Execute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
if (isCoprocessorEnabled(xc, 0)) {
|
||||
%(code)s;
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
} else {
|
||||
fault = new CoprocessorUnusableFault(0);
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template CP1Execute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
if (isCoprocessorEnabled(xc, 1)) {
|
||||
%(code)s;
|
||||
} else {
|
||||
fault = new CoprocessorUnusableFault(1);
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
// Basic instruction class execute method template.
|
||||
def template ControlTLBExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
if (FullSystem) {
|
||||
if (isCoprocessor0Enabled(xc)) {
|
||||
if(isMMUTLB(xc)){
|
||||
%(code)s;
|
||||
} else {
|
||||
fault = new ReservedInstructionFault();
|
||||
}
|
||||
} else {
|
||||
fault = new CoprocessorUnusableFault(0);
|
||||
}
|
||||
} else { // Syscall Emulation Mode - No TLB Instructions
|
||||
fault = new ReservedInstructionFault();
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
//Outputs to decoder.cc
|
||||
output decoder {{
|
||||
std::string CP0Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ccprintf(ss, "%-10s r%d, %d, %d", mnemonic, RT, RD, SEL);
|
||||
return ss.str();
|
||||
}
|
||||
std::string CP0TLB::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ccprintf(ss, "%-10s r%d, %d, %d", mnemonic, RT, RD, SEL);
|
||||
return ss.str();
|
||||
}
|
||||
std::string CP1Control::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ccprintf(ss, "%-10s r%d, f%d", mnemonic, RT, FS);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
bool
|
||||
isCoprocessorEnabled(%(CPU_exec_context)s *xc, unsigned cop_num)
|
||||
{
|
||||
if (!FullSystem)
|
||||
return true;
|
||||
|
||||
MiscReg Stat = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (cop_num == 0) {
|
||||
MiscReg Dbg = xc->readMiscReg(MISCREG_DEBUG);
|
||||
// In Stat, EXL, ERL or CU0 set, CP0 accessible
|
||||
// In Dbg, DM bit set, CP0 accessible
|
||||
// In Stat, KSU = 0, kernel mode is base mode
|
||||
return (Stat & 0x10000006) ||
|
||||
(Dbg & 0x40000000) ||
|
||||
!(Stat & 0x00000018);
|
||||
} else if (cop_num < 4) {
|
||||
return Stat & (0x10000000 << cop_num); // CU is reset
|
||||
} else {
|
||||
panic("Invalid Coprocessor Number Specified");
|
||||
}
|
||||
}
|
||||
|
||||
bool inline
|
||||
isCoprocessor0Enabled(%(CPU_exec_context)s *xc)
|
||||
{
|
||||
if (FullSystem) {
|
||||
MiscReg Stat = xc->readMiscReg(MISCREG_STATUS);
|
||||
MiscReg Dbg = xc->readMiscReg(MISCREG_DEBUG);
|
||||
// In Stat, EXL, ERL or CU0 set, CP0 accessible
|
||||
// In Dbg, DM bit set, CP0 accessible
|
||||
// In Stat KSU = 0, kernel mode is base mode
|
||||
return (Stat & 0x10000006) || (Dbg & 0x40000000) ||
|
||||
!(Stat & 0x00000018);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
isMMUTLB(%(CPU_exec_context)s *xc)
|
||||
{
|
||||
MiscReg Config = xc->readMiscReg(MISCREG_CONFIG);
|
||||
return FullSystem && (Config & 0x380) == 0x80;
|
||||
}
|
||||
}};
|
||||
|
||||
def format CP0Control(code, *flags) {{
|
||||
flags += ('IsNonSpeculative', )
|
||||
iop = InstObjParams(name, Name, 'CP0Control', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = CP0Execute.subst(iop)
|
||||
}};
|
||||
def format CP0TLB(code, *flags) {{
|
||||
flags += ('IsNonSpeculative', )
|
||||
iop = InstObjParams(name, Name, 'CP0Control', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = ControlTLBExecute.subst(iop)
|
||||
}};
|
||||
def format CP1Control(code, *flags) {{
|
||||
flags += ('IsNonSpeculative', )
|
||||
iop = InstObjParams(name, Name, 'CP1Control', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = CP1Execute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
213
simulators/gem5/src/arch/mips/isa/formats/dsp.isa
Executable file
213
simulators/gem5/src/arch/mips/isa/formats/dsp.isa
Executable file
@ -0,0 +1,213 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
// Brett Miller
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DSP integer operate instructions
|
||||
//
|
||||
output header {{
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
/**
|
||||
* Base class for integer operations.
|
||||
*/
|
||||
class DspIntOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
DspIntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DspHiLoOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
DspHiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
};
|
||||
}};
|
||||
|
||||
// Dsp instruction class execute method template.
|
||||
def template DspExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(op_decl)s;
|
||||
|
||||
if (isDspPresent(xc))
|
||||
{
|
||||
if (isDspEnabled(xc))
|
||||
{
|
||||
%(op_rd)s;
|
||||
%(code)s;
|
||||
}
|
||||
else
|
||||
{
|
||||
fault = new DspStateDisabledFault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fault = new ReservedInstructionFault();
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// DspHiLo instruction class execute method template.
|
||||
def template DspHiLoExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(op_decl)s;
|
||||
|
||||
if (isDspPresent(xc))
|
||||
{
|
||||
if (isDspEnabled(xc))
|
||||
{
|
||||
%(op_rd)s;
|
||||
%(code)s;
|
||||
}
|
||||
else
|
||||
{
|
||||
fault = new DspStateDisabledFault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fault = new ReservedInstructionFault();
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
//If there are 2 Destination Registers then
|
||||
//concatenate the values for the traceData
|
||||
if(traceData && _numDestRegs == 2) {
|
||||
// FIXME - set the trace value correctly here
|
||||
//uint64_t hilo_final_val = (uint64_t)HI_RD_SEL << 32 | LO_RD_SEL;
|
||||
//traceData->setData(hilo_final_val);
|
||||
}
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
//Outputs to decoder.cc
|
||||
output decoder {{
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
bool
|
||||
isDspEnabled(%(CPU_exec_context)s *xc)
|
||||
{
|
||||
return !FullSystem || bits(xc->readMiscReg(MISCREG_STATUS), 24);
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
bool
|
||||
isDspPresent(%(CPU_exec_context)s *xc)
|
||||
{
|
||||
return !FullSystem || bits(xc->readMiscReg(MISCREG_CONFIG3), 10);
|
||||
}
|
||||
}};
|
||||
|
||||
// add code to fetch the DSPControl register
|
||||
// and write it back after execution, giving
|
||||
// the instruction the opportunity to modify
|
||||
// it if necessary
|
||||
def format DspIntOp(code, *opt_flags) {{
|
||||
|
||||
decl_code = 'uint32_t dspctl;\n'
|
||||
decl_code += 'dspctl = DSPControl;\n'
|
||||
|
||||
write_code = 'DSPControl = dspctl;\n'
|
||||
|
||||
code = decl_code + code + write_code
|
||||
|
||||
opt_flags += ('IsDspOp',)
|
||||
|
||||
iop = InstObjParams(name, Name, 'DspIntOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = DspExecute.subst(iop)
|
||||
}};
|
||||
|
||||
// add code to fetch the DSPControl register
|
||||
// and write it back after execution, giving
|
||||
// the instruction the opportunity to modify
|
||||
// it if necessary; also, fetch the appropriate
|
||||
// HI/LO register pair, based on the AC
|
||||
// instruction field.
|
||||
|
||||
def format DspHiLoOp(code, *opt_flags) {{
|
||||
|
||||
decl_code = 'int64_t dspac;\n'
|
||||
decl_code += 'uint32_t dspctl;\n'
|
||||
|
||||
fetch_code = 'dspctl = DSPControl;\n'
|
||||
fetch_code += 'dspac = HI_RD_SEL;\n'
|
||||
fetch_code += 'dspac = dspac << 32 | LO_RD_SEL;\n'
|
||||
|
||||
write_code = 'DSPControl = dspctl;\n'
|
||||
write_code += 'HI_RD_SEL = dspac<63:32>;\n'
|
||||
write_code += 'LO_RD_SEL = dspac<31:0>;\n'
|
||||
|
||||
code = decl_code + fetch_code + code + write_code
|
||||
|
||||
opt_flags += ('IsDspOp',)
|
||||
|
||||
iop = InstObjParams(name, Name, 'DspHiLoOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = DspHiLoExecute.subst(iop)
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
69
simulators/gem5/src/arch/mips/isa/formats/formats.isa
Normal file
69
simulators/gem5/src/arch/mips/isa/formats/formats.isa
Normal file
@ -0,0 +1,69 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
//Templates from this format are used later
|
||||
//Include the basic format
|
||||
##include "basic.isa"
|
||||
|
||||
//Include the basic format
|
||||
##include "noop.isa"
|
||||
|
||||
//Include utility functions
|
||||
##include "util.isa"
|
||||
|
||||
//Include the control/cp0/cp1 formats
|
||||
##include "control.isa"
|
||||
|
||||
//Include the integer formats
|
||||
##include "int.isa"
|
||||
|
||||
//Include the DSP integer format
|
||||
##include "dsp.isa"
|
||||
|
||||
//Include the floatOp format
|
||||
##include "fp.isa"
|
||||
|
||||
//Include the mem format
|
||||
##include "mem.isa"
|
||||
|
||||
//Include the mem format
|
||||
##include "mt.isa"
|
||||
|
||||
//Include the trap format
|
||||
##include "trap.isa"
|
||||
|
||||
//Include the branch format
|
||||
##include "branch.isa"
|
||||
|
||||
//Include the noop format
|
||||
##include "unimp.isa"
|
||||
|
||||
//Include the noop format
|
||||
##include "unknown.isa"
|
||||
370
simulators/gem5/src/arch/mips/isa/formats/fp.isa
Normal file
370
simulators/gem5/src/arch/mips/isa/formats/fp.isa
Normal file
@ -0,0 +1,370 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Floating Point operate instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Base class for FP operations.
|
||||
*/
|
||||
class FPOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
FPOp(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
//std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
//needs function to check for fpEnable or not
|
||||
};
|
||||
|
||||
class FPCompareOp : public FPOp
|
||||
{
|
||||
protected:
|
||||
FPCompareOp(const char *mnem, MachInst _machInst, OpClass __opClass) : FPOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string FPCompareOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
ccprintf(ss,"%d",CC);
|
||||
|
||||
if(_numSrcRegs > 0) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
if(_numSrcRegs > 1) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
inline Fault checkFpEnableFault(%(CPU_exec_context)s *xc)
|
||||
{
|
||||
//@TODO: Implement correct CP0 checks to see if the CP1
|
||||
// unit is enable or not
|
||||
if (!isCoprocessorEnabled(xc, 1))
|
||||
return new CoprocessorUnusableFault(1);
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
//If any operand is Nan return the appropriate QNaN
|
||||
template <class T>
|
||||
bool
|
||||
fpNanOperands(FPOp *inst, %(CPU_exec_context)s *xc, const T &src_type,
|
||||
Trace::InstRecord *traceData)
|
||||
{
|
||||
uint64_t mips_nan = 0;
|
||||
assert(sizeof(T) == 4);
|
||||
|
||||
for (int i = 0; i < inst->numSrcRegs(); i++) {
|
||||
uint64_t src_bits = xc->readFloatRegOperandBits(inst, 0);
|
||||
|
||||
if (isNan(&src_bits, 32) ) {
|
||||
mips_nan = MIPS32_QNAN;
|
||||
xc->setFloatRegOperandBits(inst, 0, mips_nan);
|
||||
if (traceData) { traceData->setData(mips_nan); }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
fpInvalidOp(FPOp *inst, %(CPU_exec_context)s *cpu, const T dest_val,
|
||||
Trace::InstRecord *traceData)
|
||||
{
|
||||
uint64_t mips_nan = 0;
|
||||
T src_op = dest_val;
|
||||
assert(sizeof(T) == 4);
|
||||
|
||||
if (isNan(&src_op, 32)) {
|
||||
mips_nan = MIPS32_QNAN;
|
||||
|
||||
//Set value to QNAN
|
||||
cpu->setFloatRegOperandBits(inst, 0, mips_nan);
|
||||
|
||||
//Read FCSR from FloatRegFile
|
||||
uint32_t fcsr_bits =
|
||||
cpu->tcBase()->readFloatRegBits(FLOATREG_FCSR);
|
||||
|
||||
uint32_t new_fcsr = genInvalidVector(fcsr_bits);
|
||||
|
||||
//Write FCSR from FloatRegFile
|
||||
cpu->tcBase()->setFloatRegBits(FLOATREG_FCSR, new_fcsr);
|
||||
|
||||
if (traceData) { traceData->setData(mips_nan); }
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
fpResetCauseBits(%(CPU_exec_context)s *cpu)
|
||||
{
|
||||
//Read FCSR from FloatRegFile
|
||||
uint32_t fcsr = cpu->tcBase()->readFloatRegBits(FLOATREG_FCSR);
|
||||
|
||||
// TODO: Use utility function here
|
||||
fcsr = bits(fcsr, 31, 18) << 18 | bits(fcsr, 11, 0);
|
||||
|
||||
//Write FCSR from FloatRegFile
|
||||
cpu->tcBase()->setFloatRegBits(FLOATREG_FCSR, fcsr);
|
||||
}
|
||||
}};
|
||||
|
||||
def template FloatingPointExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
|
||||
|
||||
//When is the right time to reset cause bits?
|
||||
//start of every instruction or every cycle?
|
||||
if (FullSystem)
|
||||
fpResetCauseBits(xc);
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
//Check if any FP operand is a NaN value
|
||||
if (!fpNanOperands((FPOp*)this, xc, Fd, traceData)) {
|
||||
%(code)s;
|
||||
|
||||
//Change this code for Full-System/Sycall Emulation
|
||||
//separation
|
||||
//----
|
||||
//Should Full System-Mode throw a fault here?
|
||||
//----
|
||||
//Check for IEEE 754 FP Exceptions
|
||||
//fault = fpNanOperands((FPOp*)this, xc, Fd, traceData);
|
||||
bool invalid_op = false;
|
||||
if (FullSystem) {
|
||||
invalid_op =
|
||||
fpInvalidOp((FPOp*)this, xc, Fd, traceData);
|
||||
}
|
||||
if (!invalid_op && fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// Primary format for float point operate instructions:
|
||||
def format FloatOp(code, *flags) {{
|
||||
iop = InstObjParams(name, Name, 'FPOp', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = FloatingPointExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format FloatCompareOp(cond_code, *flags) {{
|
||||
import sys
|
||||
|
||||
code = 'bool cond;\n'
|
||||
if '_sf' in cond_code or 'SinglePrecision' in flags:
|
||||
if 'QnanException' in flags:
|
||||
code += 'if (isQnan(&Fs_sf, 32) || isQnan(&Ft_sf, 32)) {\n'
|
||||
code += '\tFCSR = genInvalidVector(FCSR);\n'
|
||||
code += '\treturn NoFault;'
|
||||
code += '}\n else '
|
||||
code += 'if (isNan(&Fs_sf, 32) || isNan(&Ft_sf, 32)) {\n'
|
||||
elif '_df' in cond_code or 'DoublePrecision' in flags:
|
||||
if 'QnanException' in flags:
|
||||
code += 'if (isQnan(&Fs_df, 64) || isQnan(&Ft_df, 64)) {\n'
|
||||
code += '\tFCSR = genInvalidVector(FCSR);\n'
|
||||
code += '\treturn NoFault;'
|
||||
code += '}\n else '
|
||||
code += 'if (isNan(&Fs_df, 64) || isNan(&Ft_df, 64)) {\n'
|
||||
else:
|
||||
sys.exit('Decoder Failed: Can\'t Determine Operand Type\n')
|
||||
|
||||
if 'UnorderedTrue' in flags:
|
||||
code += 'cond = 1;\n'
|
||||
elif 'UnorderedFalse' in flags:
|
||||
code += 'cond = 0;\n'
|
||||
else:
|
||||
sys.exit('Decoder Failed: Float Compare Instruction Needs A Unordered Flag\n')
|
||||
|
||||
code += '} else {\n'
|
||||
code += cond_code + '}'
|
||||
code += 'FCSR = genCCVector(FCSR, CC, cond);\n'
|
||||
|
||||
iop = InstObjParams(name, Name, 'FPCompareOp', code)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format FloatConvertOp(code, *flags) {{
|
||||
import sys
|
||||
|
||||
#Determine Source Type
|
||||
convert = 'fpConvert('
|
||||
if '_sf' in code:
|
||||
code = 'float ' + code + '\n'
|
||||
convert += 'SINGLE_TO_'
|
||||
elif '_df' in code:
|
||||
code = 'double ' + code + '\n'
|
||||
convert += 'DOUBLE_TO_'
|
||||
elif '_uw' in code:
|
||||
code = 'uint32_t ' + code + '\n'
|
||||
convert += 'WORD_TO_'
|
||||
elif '_ud' in code:
|
||||
code = 'uint64_t ' + code + '\n'
|
||||
convert += 'LONG_TO_'
|
||||
else:
|
||||
sys.exit("Error Determining Source Type for Conversion")
|
||||
|
||||
#Determine Destination Type
|
||||
if 'ToSingle' in flags:
|
||||
code += 'Fd_uw = ' + convert + 'SINGLE, '
|
||||
elif 'ToDouble' in flags:
|
||||
code += 'Fd_ud = ' + convert + 'DOUBLE, '
|
||||
elif 'ToWord' in flags:
|
||||
code += 'Fd_uw = ' + convert + 'WORD, '
|
||||
elif 'ToLong' in flags:
|
||||
code += 'Fd_ud = ' + convert + 'LONG, '
|
||||
else:
|
||||
sys.exit("Error Determining Destination Type for Conversion")
|
||||
|
||||
#Figure out how to round value
|
||||
if 'Ceil' in flags:
|
||||
code += 'ceil(val)); '
|
||||
elif 'Floor' in flags:
|
||||
code += 'floor(val)); '
|
||||
elif 'Round' in flags:
|
||||
code += 'roundFP(val, 0)); '
|
||||
elif 'Trunc' in flags:
|
||||
code += 'truncFP(val));'
|
||||
else:
|
||||
code += 'val); '
|
||||
|
||||
iop = InstObjParams(name, Name, 'FPOp', code)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format FloatAccOp(code, *flags) {{
|
||||
iop = InstObjParams(name, Name, 'FPOp', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
// Primary format for float64 operate instructions:
|
||||
def format Float64Op(code, *flags) {{
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format FloatPSCompareOp(cond_code1, cond_code2, *flags) {{
|
||||
import sys
|
||||
|
||||
code = 'bool cond1, cond2;\n'
|
||||
code += 'bool code_block1, code_block2;\n'
|
||||
code += 'code_block1 = code_block2 = true;\n'
|
||||
|
||||
if 'QnanException' in flags:
|
||||
code += 'if (isQnan(&Fs1_sf, 32) || isQnan(&Ft1_sf, 32)) {\n'
|
||||
code += '\tFCSR = genInvalidVector(FCSR);\n'
|
||||
code += 'code_block1 = false;'
|
||||
code += '}\n'
|
||||
code += 'if (isQnan(&Fs2_sf, 32) || isQnan(&Ft2_sf, 32)) {\n'
|
||||
code += '\tFCSR = genInvalidVector(FCSR);\n'
|
||||
code += 'code_block2 = false;'
|
||||
code += '}\n'
|
||||
|
||||
code += 'if (code_block1) {'
|
||||
code += '\tif (isNan(&Fs1_sf, 32) || isNan(&Ft1_sf, 32)) {\n'
|
||||
if 'UnorderedTrue' in flags:
|
||||
code += 'cond1 = 1;\n'
|
||||
elif 'UnorderedFalse' in flags:
|
||||
code += 'cond1 = 0;\n'
|
||||
else:
|
||||
sys.exit('Decoder Failed: Float Compare Instruction Needs A Unordered Flag\n')
|
||||
code += '} else {\n'
|
||||
code += cond_code1
|
||||
code += 'FCSR = genCCVector(FCSR, CC, cond1);}\n}\n'
|
||||
|
||||
code += 'if (code_block2) {'
|
||||
code += '\tif (isNan(&Fs2_sf, 32) || isNan(&Ft2_sf, 32)) {\n'
|
||||
if 'UnorderedTrue' in flags:
|
||||
code += 'cond2 = 1;\n'
|
||||
elif 'UnorderedFalse' in flags:
|
||||
code += 'cond2 = 0;\n'
|
||||
else:
|
||||
sys.exit('Decoder Failed: Float Compare Instruction Needs A Unordered Flag\n')
|
||||
code += '} else {\n'
|
||||
code += cond_code2
|
||||
code += 'FCSR = genCCVector(FCSR, CC, cond2);}\n}'
|
||||
|
||||
iop = InstObjParams(name, Name, 'FPCompareOp', code)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
381
simulators/gem5/src/arch/mips/isa/formats/int.isa
Normal file
381
simulators/gem5/src/arch/mips/isa/formats/int.isa
Normal file
@ -0,0 +1,381 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Integer operate instructions
|
||||
//
|
||||
output header {{
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
/**
|
||||
* Base class for integer operations.
|
||||
*/
|
||||
class IntOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
IntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
|
||||
class HiLoOp: public IntOp
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
HiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
IntOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
class HiLoRsSelOp: public HiLoOp
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
HiLoRsSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
HiLoOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
class HiLoRdSelOp: public HiLoOp
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
HiLoRdSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
HiLoOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
class HiLoRdSelValOp: public HiLoOp
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
HiLoRdSelValOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
HiLoOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
class IntImmOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
int16_t imm;
|
||||
int32_t sextImm;
|
||||
uint32_t zextImm;
|
||||
|
||||
/// Constructor
|
||||
IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass),imm(INTIMM),
|
||||
sextImm(INTIMM),zextImm(0x0000FFFF & INTIMM)
|
||||
{
|
||||
//If Bit 15 is 1 then Sign Extend
|
||||
int32_t temp = sextImm & 0x00008000;
|
||||
if (temp > 0 && strcmp(mnemonic,"lui") != 0) {
|
||||
sextImm |= 0xFFFF0000;
|
||||
}
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}};
|
||||
|
||||
// HiLo instruction class execute method template.
|
||||
def template HiLoExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(code)s;
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// HiLoRsSel instruction class execute method template.
|
||||
def template HiLoRsSelExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(op_decl)s;
|
||||
|
||||
if( ACSRC > 0 && !isDspEnabled(xc) )
|
||||
{
|
||||
fault = new DspStateDisabledFault();
|
||||
}
|
||||
else
|
||||
{
|
||||
%(op_rd)s;
|
||||
%(code)s;
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// HiLoRdSel instruction class execute method template.
|
||||
def template HiLoRdSelExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(op_decl)s;
|
||||
|
||||
if( ACDST > 0 && !isDspEnabled(xc) )
|
||||
{
|
||||
fault = new DspStateDisabledFault();
|
||||
}
|
||||
else
|
||||
{
|
||||
%(op_rd)s;
|
||||
%(code)s;
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
//Outputs to decoder.cc
|
||||
output decoder {{
|
||||
std::string IntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
// just print the first dest... if there's a second one,
|
||||
// it's generally implicit
|
||||
if (_numDestRegs > 0) {
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
ss << ", ";
|
||||
}
|
||||
|
||||
// just print the first two source regs... if there's
|
||||
// a third one, it's a read-modify-write dest (Rc),
|
||||
// e.g. for CMOVxx
|
||||
if (_numSrcRegs > 0) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
if (_numSrcRegs > 1) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string HiLoOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
//Destination Registers are implicit for HI/LO ops
|
||||
if (_numSrcRegs > 0) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
if (_numSrcRegs > 1) {
|
||||
ss << ", ";
|
||||
printReg(ss, _srcRegIdx[1]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string HiLoRsSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
} else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string HiLoRdSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
} else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string HiLoRdSelValOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
} else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string IntImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ccprintf(ss, "%-10s ", mnemonic);
|
||||
|
||||
if (_numDestRegs > 0) {
|
||||
printReg(ss, _destRegIdx[0]);
|
||||
}
|
||||
|
||||
ss << ", ";
|
||||
|
||||
if (_numSrcRegs > 0) {
|
||||
printReg(ss, _srcRegIdx[0]);
|
||||
ss << ", ";
|
||||
}
|
||||
|
||||
if(strcmp(mnemonic,"lui") == 0)
|
||||
ccprintf(ss, "0x%x ", sextImm);
|
||||
else
|
||||
ss << (int) sextImm;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
def format IntOp(code, *opt_flags) {{
|
||||
iop = InstObjParams(name, Name, 'IntOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = RegNopCheckDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format IntImmOp(code, *opt_flags) {{
|
||||
iop = InstObjParams(name, Name, 'IntImmOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = ImmNopCheckDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format HiLoRsSelOp(code, *opt_flags) {{
|
||||
iop = InstObjParams(name, Name, 'HiLoRsSelOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = HiLoRsSelExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format HiLoRdSelOp(code, *opt_flags) {{
|
||||
iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = HiLoRdSelExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format HiLoRdSelValOp(code, *opt_flags) {{
|
||||
|
||||
if '_sd' in code:
|
||||
code = 'int64_t ' + code
|
||||
elif '_ud' in code:
|
||||
code = 'uint64_t ' + code
|
||||
|
||||
code += 'HI_RD_SEL = val<63:32>;\n'
|
||||
code += 'LO_RD_SEL = val<31:0>;\n'
|
||||
|
||||
iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = HiLoRdSelExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format HiLoOp(code, *opt_flags) {{
|
||||
iop = InstObjParams(name, Name, 'HiLoOp', code, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = HiLoExecute.subst(iop)
|
||||
}};
|
||||
596
simulators/gem5/src/arch/mips/isa/formats/mem.isa
Normal file
596
simulators/gem5/src/arch/mips/isa/formats/mem.isa
Normal file
@ -0,0 +1,596 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Steve Reinhardt
|
||||
// Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Memory-format instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Base class for general Mips memory-format instructions.
|
||||
*/
|
||||
class Memory : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
/// Memory request flags. See mem_req_base.hh.
|
||||
Request::Flags memAccessFlags;
|
||||
|
||||
/// Displacement for EA calculation (signed).
|
||||
int32_t disp;
|
||||
|
||||
/// Constructor
|
||||
Memory(const char *mnem, MachInst _machInst, OpClass __opClass)
|
||||
: MipsStaticInst(mnem, _machInst, __opClass),
|
||||
disp(sext<16>(OFFSET))
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for a few miscellaneous memory-format insts
|
||||
* that don't interpret the disp field
|
||||
*/
|
||||
class MemoryNoDisp : public Memory
|
||||
{
|
||||
protected:
|
||||
/// Constructor
|
||||
MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
|
||||
: Memory(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
|
||||
output decoder {{
|
||||
std::string
|
||||
Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s %c%d, %d(r%d)", mnemonic,
|
||||
flags[IsFloating] ? 'f' : 'r', RT, disp, RS);
|
||||
}
|
||||
|
||||
std::string
|
||||
MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s %c%d, r%d(r%d)", mnemonic,
|
||||
flags[IsFloating] ? 'f' : 'r',
|
||||
flags[IsFloating] ? FD : RD,
|
||||
RS, RT);
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
/** return data in cases where there the size of data is only
|
||||
known in the packet
|
||||
*/
|
||||
uint64_t getMemData(%(CPU_exec_context)s *xc, Packet *packet) {
|
||||
switch (packet->getSize())
|
||||
{
|
||||
case 1:
|
||||
return packet->get<uint8_t>();
|
||||
|
||||
case 2:
|
||||
return packet->get<uint16_t>();
|
||||
|
||||
case 4:
|
||||
return packet->get<uint32_t>();
|
||||
|
||||
case 8:
|
||||
return packet->get<uint64_t>();
|
||||
|
||||
default:
|
||||
std::cerr << "bad store data size = " << packet->getSize() << std::endl;
|
||||
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}};
|
||||
|
||||
def template LoadStoreDeclare {{
|
||||
/**
|
||||
* Static instruction class for "%(mnemonic)s".
|
||||
*/
|
||||
class %(class_name)s : public %(base_class)s
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor.
|
||||
%(class_name)s(ExtMachInst machInst);
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
%(EACompDeclare)s
|
||||
|
||||
%(InitiateAccDeclare)s
|
||||
|
||||
%(CompleteAccDeclare)s
|
||||
};
|
||||
}};
|
||||
|
||||
def template EACompDeclare {{
|
||||
Fault eaComp(%(CPU_exec_context)s *, Trace::InstRecord *) const;
|
||||
}};
|
||||
|
||||
def template InitiateAccDeclare {{
|
||||
Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const;
|
||||
}};
|
||||
|
||||
|
||||
def template CompleteAccDeclare {{
|
||||
Fault completeAcc(Packet *, %(CPU_exec_context)s *, Trace::InstRecord *) const;
|
||||
}};
|
||||
|
||||
def template LoadStoreConstructor {{
|
||||
inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
|
||||
: %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
|
||||
{
|
||||
%(constructor)s;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def template EACompExecute {{
|
||||
Fault
|
||||
%(class_name)s::eaComp(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
if (this->isFloating()) {
|
||||
%(fp_enable_check)s;
|
||||
|
||||
if(fault != NoFault)
|
||||
return fault;
|
||||
}
|
||||
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
// NOTE: Trace Data is written using execute or completeAcc templates
|
||||
if (fault == NoFault) {
|
||||
xc->setEA(EA);
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template LoadExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
if (this->isFloating()) {
|
||||
%(fp_enable_check)s;
|
||||
|
||||
if(fault != NoFault)
|
||||
return fault;
|
||||
}
|
||||
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def template LoadInitiateAcc {{
|
||||
Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
if (this->isFloating()) {
|
||||
%(fp_enable_check)s;
|
||||
|
||||
if(fault != NoFault)
|
||||
return fault;
|
||||
}
|
||||
|
||||
%(op_src_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = readMemTiming(xc, traceData, EA, Mem, memAccessFlags);
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template LoadCompleteAcc {{
|
||||
Fault %(class_name)s::completeAcc(Packet *pkt,
|
||||
%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
if (this->isFloating()) {
|
||||
%(fp_enable_check)s;
|
||||
|
||||
if(fault != NoFault)
|
||||
return fault;
|
||||
}
|
||||
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
getMem(pkt, Mem, traceData);
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template StoreExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(postacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def template StoreFPExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
if(fault != NoFault)
|
||||
return fault;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(postacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template StoreCondExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
uint64_t write_result = 0;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = writeMemAtomic(xc, traceData, Mem, EA, memAccessFlags,
|
||||
&write_result);
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(postacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template StoreInitiateAcc {{
|
||||
Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
fault = writeMemTiming(xc, traceData, Mem, EA, memAccessFlags,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def template StoreCompleteAcc {{
|
||||
Fault %(class_name)s::completeAcc(Packet *pkt,
|
||||
%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template StoreCondCompleteAcc {{
|
||||
Fault %(class_name)s::completeAcc(Packet *pkt,
|
||||
%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_dest_decl)s;
|
||||
|
||||
uint64_t write_result = pkt->req->getExtraData();
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(postacc_code)s;
|
||||
}
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template MiscExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
Addr EA M5_VAR_USED = 0;
|
||||
Fault fault = NoFault;
|
||||
|
||||
%(fp_enable_check)s;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
if (fault == NoFault) {
|
||||
%(memacc_code)s;
|
||||
}
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template MiscInitiateAcc {{
|
||||
Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
panic("Misc instruction does not support split access method!");
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def template MiscCompleteAcc {{
|
||||
Fault %(class_name)s::completeAcc(Packet *pkt,
|
||||
%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
panic("Misc instruction does not support split access method!");
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
def format LoadMemory(memacc_code, ea_code = {{ EA = Rs + disp; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
decode_template = ImmNopCheckDecode,
|
||||
exec_template_base = 'Load')
|
||||
}};
|
||||
|
||||
|
||||
def format StoreMemory(memacc_code, ea_code = {{ EA = Rs + disp; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
exec_template_base = 'Store')
|
||||
}};
|
||||
|
||||
def format LoadIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
inst_flags += ['IsIndexed']
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
decode_template = ImmNopCheckDecode,
|
||||
exec_template_base = 'Load')
|
||||
}};
|
||||
|
||||
def format StoreIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
inst_flags += ['IsIndexed']
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
exec_template_base = 'Store')
|
||||
}};
|
||||
|
||||
def format LoadFPIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
inst_flags += ['IsIndexed', 'IsFloating']
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
decode_template = ImmNopCheckDecode,
|
||||
exec_template_base = 'Load')
|
||||
}};
|
||||
|
||||
def format StoreFPIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
inst_flags += ['IsIndexed', 'IsFloating']
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
exec_template_base = 'Store')
|
||||
}};
|
||||
|
||||
|
||||
def format LoadUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
decl_code = '''
|
||||
uint32_t mem_word = Mem_uw;
|
||||
uint32_t unalign_addr = Rs + disp;
|
||||
uint32_t byte_offset = unalign_addr & 3;
|
||||
if (GuestByteOrder == BigEndianByteOrder)
|
||||
byte_offset ^= 3;
|
||||
'''
|
||||
|
||||
memacc_code = decl_code + memacc_code
|
||||
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
decode_template = ImmNopCheckDecode,
|
||||
exec_template_base = 'Load')
|
||||
}};
|
||||
|
||||
def format StoreUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
decl_code = '''
|
||||
uint32_t mem_word = 0;
|
||||
uint32_t unaligned_addr = Rs + disp;
|
||||
uint32_t byte_offset = unaligned_addr & 3;
|
||||
if (GuestByteOrder == BigEndianByteOrder)
|
||||
byte_offset ^= 3;
|
||||
fault = readMemAtomic(xc, traceData, EA, mem_word, memAccessFlags);
|
||||
'''
|
||||
memacc_code = decl_code + memacc_code + '\nMem = mem_word;\n'
|
||||
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
exec_template_base = 'Store')
|
||||
}};
|
||||
|
||||
def format Prefetch(ea_code = {{ EA = Rs + disp; }},
|
||||
mem_flags = [], pf_flags = [], inst_flags = []) {{
|
||||
pf_mem_flags = mem_flags + pf_flags + ['PREFETCH']
|
||||
pf_inst_flags = inst_flags
|
||||
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code,
|
||||
'warn_once("Prefetching not implemented for MIPS\\n");',
|
||||
pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc')
|
||||
|
||||
}};
|
||||
|
||||
def format StoreCond(memacc_code, postacc_code,
|
||||
ea_code = {{ EA = Rs + disp; }},
|
||||
mem_flags = [], inst_flags = []) {{
|
||||
(header_output, decoder_output, decode_block, exec_output) = \
|
||||
LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
postacc_code, exec_template_base = 'StoreCond')
|
||||
}};
|
||||
216
simulators/gem5/src/arch/mips/isa/formats/mt.isa
Normal file
216
simulators/gem5/src/arch/mips/isa/formats/mt.isa
Normal file
@ -0,0 +1,216 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MT instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Base class for MIPS MT ASE operations.
|
||||
*/
|
||||
class MTOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
MTOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass), user_mode(false)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
bool user_mode;
|
||||
};
|
||||
|
||||
class MTUserModeOp : public MTOp
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
MTUserModeOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MTOp(mnem, _machInst, __opClass)
|
||||
{
|
||||
user_mode = true;
|
||||
}
|
||||
|
||||
//std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string MTOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if (strcmp(mnemonic,"mttc0") == 0 || strcmp(mnemonic,"mftc0") == 0) {
|
||||
ccprintf(ss, "%-10s r%d, r%d, %d", mnemonic, RT, RD, SEL);
|
||||
} else if (strcmp(mnemonic,"mftgpr") == 0) {
|
||||
ccprintf(ss, "%-10s r%d, r%d", mnemonic, RD, RT);
|
||||
} else {
|
||||
ccprintf(ss, "%-10s r%d, r%d", mnemonic, RT, RD);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
void getThrRegExValues(%(CPU_exec_context)s *xc,
|
||||
VPEConf0Reg &vpe_conf0, TCBindReg &tc_bind_mt,
|
||||
TCBindReg &tc_bind, VPEControlReg &vpe_control,
|
||||
MVPConf0Reg &mvp_conf0)
|
||||
{
|
||||
vpe_conf0 = xc->readMiscReg(MISCREG_VPE_CONF0);
|
||||
tc_bind_mt = xc->readRegOtherThread(MISCREG_TC_BIND + Ctrl_Base_DepTag);
|
||||
tc_bind = xc->readMiscReg(MISCREG_TC_BIND);
|
||||
vpe_control = xc->readMiscReg(MISCREG_VPE_CONTROL);
|
||||
mvp_conf0 = xc->readMiscReg(MISCREG_MVP_CONF0);
|
||||
}
|
||||
|
||||
void getMTExValues(%(CPU_exec_context)s *xc, Config3Reg &config3)
|
||||
{
|
||||
config3 = xc->readMiscReg(MISCREG_CONFIG3);
|
||||
}
|
||||
}};
|
||||
|
||||
def template ThreadRegisterExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
int64_t data M5_VAR_USED;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
VPEConf0Reg vpeConf0;
|
||||
TCBindReg tcBindMT;
|
||||
TCBindReg tcBind;
|
||||
VPEControlReg vpeControl;
|
||||
MVPConf0Reg mvpConf0;
|
||||
|
||||
getThrRegExValues(xc, vpeConf0, tcBindMT,
|
||||
tcBind, vpeControl, mvpConf0);
|
||||
|
||||
if (isCoprocessorEnabled(xc, 0)) {
|
||||
if (vpeConf0.mvp == 0 && tcBindMT.curVPE != tcBind.curVPE) {
|
||||
data = -1;
|
||||
} else if (vpeControl.targTC > mvpConf0.ptc) {
|
||||
data = -1;
|
||||
} else {
|
||||
%(code)s;
|
||||
}
|
||||
} else {
|
||||
fault = new CoprocessorUnusableFault(0);
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
def template MTExecute{{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
|
||||
Config3Reg config3;
|
||||
|
||||
getMTExValues(xc, config3);
|
||||
|
||||
if (isCoprocessorEnabled(xc, 0)) {
|
||||
if (config3.mt == 1) {
|
||||
%(code)s;
|
||||
} else {
|
||||
fault = new ReservedInstructionFault();
|
||||
}
|
||||
} else {
|
||||
fault = new CoprocessorUnusableFault(0);
|
||||
}
|
||||
|
||||
if(fault == NoFault)
|
||||
{
|
||||
%(op_wb)s;
|
||||
}
|
||||
return fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// Primary format for integer operate instructions:
|
||||
def format MT_Control(code, *opt_flags) {{
|
||||
inst_flags = ('IsNonSpeculative', )
|
||||
op_type = 'MTOp'
|
||||
|
||||
for x in opt_flags:
|
||||
if x == 'UserMode':
|
||||
op_type = 'MTUserModeOp'
|
||||
else:
|
||||
inst_flags += (x, )
|
||||
|
||||
iop = InstObjParams(name, Name, op_type, code, inst_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = MTExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format MT_MFTR(code, *flags) {{
|
||||
flags += ('IsNonSpeculative', )
|
||||
# code = 'std::cerr << curTick() << \": T\" << xc->tcBase()->threadId() << \": Executing MT INST: ' + name + '\" << endl;\n' + code
|
||||
|
||||
code += '''
|
||||
if (MT_H)
|
||||
data = bits(data, 63, 32);
|
||||
Rd = data;
|
||||
'''
|
||||
|
||||
iop = InstObjParams(name, Name, 'MTOp', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = ThreadRegisterExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format MT_MTTR(code, *flags) {{
|
||||
flags += ('IsNonSpeculative', )
|
||||
# code = 'std::cerr << curTick() << \": T\" << xc->tcBase()->threadId() << \": Executing MT INST: ' + name + '\" << endl;\n' + code
|
||||
iop = InstObjParams(name, Name, 'MTOp', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = ThreadRegisterExecute.subst(iop)
|
||||
}};
|
||||
139
simulators/gem5/src/arch/mips/isa/formats/noop.isa
Normal file
139
simulators/gem5/src/arch/mips/isa/formats/noop.isa
Normal file
@ -0,0 +1,139 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Nop
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Static instruction class for no-ops. This is a leaf class.
|
||||
*/
|
||||
class Nop : public MipsStaticInst
|
||||
{
|
||||
/// Disassembly of original instruction.
|
||||
const std::string originalDisassembly;
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
Nop(const std::string _originalDisassembly, MachInst _machInst)
|
||||
: MipsStaticInst("nop", _machInst, No_OpClass),
|
||||
originalDisassembly(_originalDisassembly)
|
||||
{
|
||||
flags[IsNop] = true;
|
||||
}
|
||||
|
||||
~Nop() { }
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string Nop::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s %s", "nop", originalDisassembly);
|
||||
}
|
||||
|
||||
/// Helper function for decoding nops. Substitute Nop object
|
||||
/// for original inst passed in as arg (and delete latter).
|
||||
inline
|
||||
MipsStaticInst *
|
||||
makeNop(MipsStaticInst *inst)
|
||||
{
|
||||
std::string nop_str = "(" + inst->disassemble(0) + ")";
|
||||
MipsStaticInst *nop = new Nop(nop_str, inst->machInst);
|
||||
delete inst;
|
||||
return nop;
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
Fault
|
||||
Nop::execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
|
||||
{
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
// Int & FP operate instructions use RD as dest, so check for
|
||||
// RD == 0 to detect nops
|
||||
def template RegNopCheckDecode {{
|
||||
{
|
||||
MipsStaticInst *i = new %(class_name)s(machInst);
|
||||
//if (RD == 0) {
|
||||
//i = makeNop(i);
|
||||
//}
|
||||
return i;
|
||||
}
|
||||
}};
|
||||
|
||||
def template OperateNopCheckDecode {{
|
||||
{
|
||||
MipsStaticInst *i = new %(class_name)s(machInst);
|
||||
//if (RD == 0) {
|
||||
// i = makeNop(i);
|
||||
//}
|
||||
return i;
|
||||
}
|
||||
}};
|
||||
|
||||
// IntImm & Memory instructions use Rt as dest, so check for
|
||||
// Rt == 0 to detect nops
|
||||
def template ImmNopCheckDecode {{
|
||||
{
|
||||
MipsStaticInst *i = new %(class_name)s(machInst);
|
||||
//if (RT == 0) {
|
||||
// i = makeNop(i);
|
||||
// }
|
||||
return i;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
// Like BasicOperate format, but generates NOP if RC/FC == 31
|
||||
def format BasicOperateWithNopCheck(code, *opt_args) {{
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', code,
|
||||
opt_args)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = OperateNopCheckDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
def format Nop() {{
|
||||
decode_block = 'return new Nop(\"\",machInst);\n'
|
||||
}};
|
||||
|
||||
80
simulators/gem5/src/arch/mips/isa/formats/tlbop.isa
Normal file
80
simulators/gem5/src/arch/mips/isa/formats/tlbop.isa
Normal file
@ -0,0 +1,80 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TlbOp instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Base class for integer operations.
|
||||
*/
|
||||
class TlbOp : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
TlbOp(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string TlbOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return "Disassembly of integer instruction\n";
|
||||
}
|
||||
}};
|
||||
|
||||
def template TlbOpExecute {{
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
//Write the resulting state to the execution context
|
||||
%(op_wb)s;
|
||||
|
||||
//Call into the trap handler with the appropriate fault
|
||||
return No_Fault;
|
||||
}
|
||||
}};
|
||||
|
||||
// Primary format for integer operate instructions:
|
||||
def format TlbOp(code, *opt_flags) {{
|
||||
orig_code = code
|
||||
cblk = code
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
exec_output = TlbOpExecute.subst(iop)
|
||||
}};
|
||||
115
simulators/gem5/src/arch/mips/isa/formats/trap.isa
Normal file
115
simulators/gem5/src/arch/mips/isa/formats/trap.isa
Normal file
@ -0,0 +1,115 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
// Jaidev Patwardhan
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Trap instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Base class for integer operations.
|
||||
*/
|
||||
class Trap : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
Trap(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
class TrapImm : public MipsStaticInst
|
||||
{
|
||||
protected:
|
||||
|
||||
int16_t imm;
|
||||
|
||||
/// Constructor
|
||||
TrapImm(const char *mnem, MachInst _machInst, OpClass __opClass) :
|
||||
MipsStaticInst(mnem, _machInst, __opClass),imm(INTIMM)
|
||||
{
|
||||
}
|
||||
|
||||
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string Trap::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return "Disassembly of trap instruction\n";
|
||||
}
|
||||
std::string TrapImm::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return "Disassembly of trap instruction\n";
|
||||
}
|
||||
}};
|
||||
|
||||
def template TrapExecute {{
|
||||
//Edit This Template When Traps Are Implemented
|
||||
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
|
||||
{
|
||||
//Write the resulting state to the execution context
|
||||
%(op_wb)s;
|
||||
|
||||
//Call into the trap handler with the appropriate fault
|
||||
return No_Fault;
|
||||
}
|
||||
}};
|
||||
def format Trap(code, *flags) {{
|
||||
|
||||
code ='bool cond;\n' + code
|
||||
code += 'if (cond) {\n'
|
||||
code += 'fault = new TrapFault();\n};'
|
||||
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
def format TrapImm(code, *flags) {{
|
||||
|
||||
code ='bool cond;\n' + code
|
||||
code += 'if (cond) {\n'
|
||||
code += 'fault = new TrapFault();\n};'
|
||||
iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags)
|
||||
header_output = BasicDeclare.subst(iop)
|
||||
decoder_output = BasicConstructor.subst(iop)
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
278
simulators/gem5/src/arch/mips/isa/formats/unimp.isa
Normal file
278
simulators/gem5/src/arch/mips/isa/formats/unimp.isa
Normal file
@ -0,0 +1,278 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Unimplemented instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Static instruction class for unimplemented instructions that
|
||||
* cause simulator termination. Note that these are recognized
|
||||
* (legal) instructions that the simulator does not support; the
|
||||
* 'Unknown' class is used for unrecognized/illegal instructions.
|
||||
* This is a leaf class.
|
||||
*/
|
||||
class FailUnimplemented : public MipsStaticInst
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
FailUnimplemented(const char *_mnemonic, MachInst _machInst)
|
||||
: MipsStaticInst(_mnemonic, _machInst, No_OpClass)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
class CP0Unimplemented : public MipsStaticInst
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CP0Unimplemented(const char *_mnemonic, MachInst _machInst)
|
||||
: MipsStaticInst(_mnemonic, _machInst, No_OpClass)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
class CP1Unimplemented : public MipsStaticInst
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CP1Unimplemented(const char *_mnemonic, MachInst _machInst)
|
||||
: MipsStaticInst(_mnemonic, _machInst, No_OpClass)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
class CP2Unimplemented : public MipsStaticInst
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CP2Unimplemented(const char *_mnemonic, MachInst _machInst)
|
||||
: MipsStaticInst(_mnemonic, _machInst, No_OpClass)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for unimplemented instructions that cause a warning
|
||||
* to be printed (but do not terminate simulation). This
|
||||
* implementation is a little screwy in that it will print a
|
||||
* warning for each instance of a particular unimplemented machine
|
||||
* instruction, not just for each unimplemented opcode. Should
|
||||
* probably make the 'warned' flag a static member of the derived
|
||||
* class.
|
||||
*/
|
||||
class WarnUnimplemented : public MipsStaticInst
|
||||
{
|
||||
private:
|
||||
/// Have we warned on this instruction yet?
|
||||
mutable bool warned;
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
|
||||
: MipsStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string
|
||||
FailUnimplemented::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (unimplemented)", mnemonic);
|
||||
}
|
||||
|
||||
std::string
|
||||
CP0Unimplemented::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (unimplemented)", mnemonic);
|
||||
}
|
||||
|
||||
std::string
|
||||
CP1Unimplemented::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (unimplemented)", mnemonic);
|
||||
}
|
||||
std::string
|
||||
CP2Unimplemented::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (unimplemented)", mnemonic);
|
||||
}
|
||||
|
||||
std::string
|
||||
WarnUnimplemented::generateDisassembly(Addr pc,
|
||||
const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (unimplemented)", mnemonic);
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
Fault
|
||||
FailUnimplemented::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
panic("attempt to execute unimplemented instruction '%s' "
|
||||
"(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
|
||||
inst2string(machInst));
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
Fault
|
||||
CP0Unimplemented::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
if (FullSystem) {
|
||||
if (!isCoprocessorEnabled(xc, 0))
|
||||
return new CoprocessorUnusableFault(0);
|
||||
else
|
||||
return new ReservedInstructionFault;
|
||||
} else {
|
||||
panic("attempt to execute unimplemented instruction '%s' "
|
||||
"(inst %#08x, opcode %#x, binary:%s)",
|
||||
mnemonic, machInst, OPCODE, inst2string(machInst));
|
||||
return NoFault;
|
||||
}
|
||||
}
|
||||
|
||||
Fault
|
||||
CP1Unimplemented::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
if (FullSystem) {
|
||||
if (!isCoprocessorEnabled(xc, 1))
|
||||
return new CoprocessorUnusableFault(1);
|
||||
else
|
||||
return new ReservedInstructionFault;
|
||||
} else {
|
||||
panic("attempt to execute unimplemented instruction '%s' "
|
||||
"(inst %#08x, opcode %#x, binary:%s)",
|
||||
mnemonic, machInst, OPCODE, inst2string(machInst));
|
||||
return NoFault;
|
||||
}
|
||||
}
|
||||
|
||||
Fault
|
||||
CP2Unimplemented::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
if (FullSystem) {
|
||||
if (!isCoprocessorEnabled(xc, 2))
|
||||
return new CoprocessorUnusableFault(2);
|
||||
else
|
||||
return new ReservedInstructionFault;
|
||||
} else {
|
||||
panic("attempt to execute unimplemented instruction '%s' "
|
||||
"(inst %#08x, opcode %#x, binary:%s)",
|
||||
mnemonic, machInst, OPCODE, inst2string(machInst));
|
||||
return NoFault;
|
||||
}
|
||||
}
|
||||
|
||||
Fault
|
||||
WarnUnimplemented::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
if (!warned) {
|
||||
warn("\tinstruction '%s' unimplemented\n", mnemonic);
|
||||
warned = true;
|
||||
}
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
def format FailUnimpl() {{
|
||||
iop = InstObjParams(name, 'FailUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
|
||||
}};
|
||||
def format CP0Unimpl() {{
|
||||
iop = InstObjParams(name, 'CP0Unimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
def format CP1Unimpl() {{
|
||||
iop = InstObjParams(name, 'CP1Unimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
def format CP2Unimpl() {{
|
||||
iop = InstObjParams(name, 'CP2Unimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
def format WarnUnimpl() {{
|
||||
iop = InstObjParams(name, 'WarnUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
|
||||
82
simulators/gem5/src/arch/mips/isa/formats/unknown.isa
Normal file
82
simulators/gem5/src/arch/mips/isa/formats/unknown.isa
Normal file
@ -0,0 +1,82 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2006 The Regents of The University of Michigan
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Unknown instructions
|
||||
//
|
||||
|
||||
output header {{
|
||||
/**
|
||||
* Static instruction class for unknown (illegal) instructions.
|
||||
* These cause simulator termination if they are executed in a
|
||||
* non-speculative mode. This is a leaf class.
|
||||
*/
|
||||
class Unknown : public MipsStaticInst
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
Unknown(MachInst _machInst)
|
||||
: MipsStaticInst("unknown", _machInst, No_OpClass)
|
||||
{
|
||||
// don't call execute() (which panics) if we're on a
|
||||
// speculative path
|
||||
flags[IsNonSpeculative] = true;
|
||||
}
|
||||
|
||||
%(BasicExecDeclare)s
|
||||
|
||||
std::string
|
||||
generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
||||
};
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
std::string
|
||||
Unknown::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
||||
{
|
||||
return csprintf("%-10s (inst 0x%x, opcode 0x%x, binary:%s)",
|
||||
"unknown", machInst, OPCODE, inst2string(machInst));
|
||||
}
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
Fault
|
||||
Unknown::execute(%(CPU_exec_context)s *xc,
|
||||
Trace::InstRecord *traceData) const
|
||||
{
|
||||
return new ReservedInstructionFault;
|
||||
}
|
||||
}};
|
||||
|
||||
def format Unknown() {{
|
||||
decode_block = 'return new Unknown(machInst);\n'
|
||||
}};
|
||||
|
||||
103
simulators/gem5/src/arch/mips/isa/formats/util.isa
Normal file
103
simulators/gem5/src/arch/mips/isa/formats/util.isa
Normal file
@ -0,0 +1,103 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Steve Reinhardt
|
||||
// Korey Sewell
|
||||
|
||||
let {{
|
||||
def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
|
||||
postacc_code = '', base_class = 'Memory',
|
||||
decode_template = BasicDecode, exec_template_base = ''):
|
||||
# Make sure flags are in lists (convert to lists if not).
|
||||
mem_flags = makeList(mem_flags)
|
||||
inst_flags = makeList(inst_flags)
|
||||
|
||||
# Some CPU models execute the memory operation as an atomic unit,
|
||||
# while others want to separate them into an effective address
|
||||
# computation and a memory access operation. As a result, we need
|
||||
# to generate three StaticInst objects. Note that the latter two
|
||||
# are nested inside the larger "atomic" one.
|
||||
|
||||
# Generate InstObjParams for each of the three objects. Note that
|
||||
# they differ only in the set of code objects contained (which in
|
||||
# turn affects the object's overall operand list).
|
||||
iop = InstObjParams(name, Name, base_class,
|
||||
{ 'ea_code':ea_code, 'memacc_code':memacc_code, 'postacc_code':postacc_code },
|
||||
inst_flags)
|
||||
|
||||
if mem_flags:
|
||||
mem_flags = [ 'Request::%s' % flag for flag in mem_flags ]
|
||||
s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
|
||||
iop.constructor += s
|
||||
|
||||
# select templates
|
||||
|
||||
# The InitiateAcc template is the same for StoreCond templates as the
|
||||
# corresponding Store template..
|
||||
StoreCondInitiateAcc = StoreInitiateAcc
|
||||
|
||||
fullExecTemplate = eval(exec_template_base + 'Execute')
|
||||
initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
|
||||
completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
|
||||
|
||||
# (header_output, decoder_output, decode_block, exec_output)
|
||||
return (LoadStoreDeclare.subst(iop),
|
||||
LoadStoreConstructor.subst(iop),
|
||||
decode_template.subst(iop),
|
||||
fullExecTemplate.subst(iop)
|
||||
+ EACompExecute.subst(iop)
|
||||
+ initiateAccTemplate.subst(iop)
|
||||
+ completeAccTemplate.subst(iop))
|
||||
}};
|
||||
|
||||
output header {{
|
||||
std::string inst2string(MachInst machInst);
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
|
||||
std::string inst2string(MachInst machInst)
|
||||
{
|
||||
string str = "";
|
||||
uint32_t mask = 0x80000000;
|
||||
|
||||
for(int i=0; i < 32; i++) {
|
||||
if ((machInst & mask) == 0) {
|
||||
str += "0";
|
||||
} else {
|
||||
str += "1";
|
||||
}
|
||||
|
||||
mask = mask >> 1;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
}};
|
||||
103
simulators/gem5/src/arch/mips/isa/includes.isa
Normal file
103
simulators/gem5/src/arch/mips/isa/includes.isa
Normal file
@ -0,0 +1,103 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Output include file directives.
|
||||
//
|
||||
|
||||
output header {{
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "cpu/static_inst.hh"
|
||||
#include "mem/packet.hh"
|
||||
}};
|
||||
|
||||
output decoder {{
|
||||
#include <cmath>
|
||||
|
||||
#include "arch/mips/decoder.hh"
|
||||
#include "arch/mips/dsp.hh"
|
||||
#include "arch/mips/dt_constants.hh"
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/mt_constants.hh"
|
||||
#include "arch/mips/pagetable.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "arch/mips/tlb.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "base/cprintf.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "mem/packet.hh"
|
||||
#include "sim/full_system.hh"
|
||||
#if defined(linux)
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
using namespace MipsISA;
|
||||
}};
|
||||
|
||||
output exec {{
|
||||
#include <cmath>
|
||||
|
||||
#include "arch/generic/memhelpers.hh"
|
||||
#include "arch/mips/dsp.hh"
|
||||
#include "arch/mips/dt_constants.hh"
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/mt.hh"
|
||||
#include "arch/mips/mt_constants.hh"
|
||||
#include "arch/mips/pagetable.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "arch/mips/tlb.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
#if defined(linux)
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
#include "base/condcodes.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "cpu/exetrace.hh"
|
||||
#include "debug/MipsPRA.hh"
|
||||
#include "mem/packet.hh"
|
||||
#include "mem/packet_access.hh"
|
||||
#include "sim/eventq.hh"
|
||||
#include "sim/full_system.hh"
|
||||
#include "sim/sim_events.hh"
|
||||
#include "sim/sim_exit.hh"
|
||||
|
||||
using namespace MipsISA;
|
||||
}};
|
||||
|
||||
61
simulators/gem5/src/arch/mips/isa/main.isa
Normal file
61
simulators/gem5/src/arch/mips/isa/main.isa
Normal file
@ -0,0 +1,61 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MIPS ISA description file.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Include the C++ include directives
|
||||
##include "includes.isa"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Namespace statement. Everything below this line will be in the
|
||||
// MipsISAInst namespace.
|
||||
//
|
||||
|
||||
namespace MipsISA;
|
||||
|
||||
//Include the bitfield definitions
|
||||
##include "bitfields.isa"
|
||||
|
||||
//Include the operand_types and operand definitions
|
||||
##include "operands.isa"
|
||||
|
||||
//Include the base class for mips instructions, and some support code
|
||||
##include "base.isa"
|
||||
|
||||
//Include the definitions for the instruction formats
|
||||
##include "formats/formats.isa"
|
||||
|
||||
//Include the decoder definition
|
||||
##include "decoder.isa"
|
||||
157
simulators/gem5/src/arch/mips/isa/operands.isa
Normal file
157
simulators/gem5/src/arch/mips/isa/operands.isa
Normal file
@ -0,0 +1,157 @@
|
||||
// -*- mode:c++ -*-
|
||||
|
||||
// Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met: redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer;
|
||||
// redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution;
|
||||
// neither the name of the copyright holders nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Korey Sewell
|
||||
// Jaidev Patwardhan
|
||||
|
||||
def operand_types {{
|
||||
'sb' : 'int8_t',
|
||||
'ub' : 'uint8_t',
|
||||
'sh' : 'int16_t',
|
||||
'uh' : 'uint16_t',
|
||||
'sw' : 'int32_t',
|
||||
'uw' : 'uint32_t',
|
||||
'sd' : 'int64_t',
|
||||
'ud' : 'uint64_t',
|
||||
'sf' : 'float',
|
||||
'df' : 'double'
|
||||
}};
|
||||
|
||||
def operands {{
|
||||
#General Purpose Integer Reg Operands
|
||||
'Rd': ('IntReg', 'uw', 'RD', 'IsInteger', 1),
|
||||
'Rs': ('IntReg', 'uw', 'RS', 'IsInteger', 2),
|
||||
'Rt': ('IntReg', 'uw', 'RT', 'IsInteger', 3),
|
||||
|
||||
#Immediate Value operand
|
||||
'IntImm': ('IntReg', 'uw', 'INTIMM', 'IsInteger', 3),
|
||||
|
||||
#Operands used for Link or Syscall Insts
|
||||
'R31': ('IntReg', 'uw','31','IsInteger', 4),
|
||||
'R2': ('IntReg', 'uw','2', 'IsInteger', 5),
|
||||
|
||||
#Special Integer Reg operands
|
||||
'LO0': ('IntReg', 'uw','INTREG_LO', 'IsInteger', 6),
|
||||
'HI0': ('IntReg', 'uw','INTREG_HI', 'IsInteger', 7),
|
||||
|
||||
#Bitfield-dependent HI/LO Register Access
|
||||
'LO_RD_SEL': ('IntReg','uw','INTREG_DSP_LO0 + ACDST*3', None, 6),
|
||||
'HI_RD_SEL': ('IntReg','uw','INTREG_DSP_HI0 + ACDST*3', None, 7),
|
||||
'LO_RS_SEL': ('IntReg','uw','INTREG_DSP_LO0 + ACSRC*3', None, 6),
|
||||
'HI_RS_SEL': ('IntReg','uw','INTREG_DSP_HI0 + ACSRC*3', None, 7),
|
||||
|
||||
#DSP Special Purpose Integer Operands
|
||||
'DSPControl': ('IntReg', 'uw', 'INTREG_DSP_CONTROL', None, 8),
|
||||
'DSPLo0': ('IntReg', 'uw', 'INTREG_LO', None, 1),
|
||||
'DSPHi0': ('IntReg', 'uw', 'INTREG_HI', None, 1),
|
||||
'DSPACX0': ('IntReg', 'uw', 'INTREG_DSP_ACX0', None, 1),
|
||||
'DSPLo1': ('IntReg', 'uw', 'INTREG_DSP_LO1', None, 1),
|
||||
'DSPHi1': ('IntReg', 'uw', 'INTREG_DSP_HI1', None, 1),
|
||||
'DSPACX1': ('IntReg', 'uw', 'INTREG_DSP_ACX1', None, 1),
|
||||
'DSPLo2': ('IntReg', 'uw', 'INTREG_DSP_LO2', None, 1),
|
||||
'DSPHi2': ('IntReg', 'uw', 'INTREG_DSP_HI2', None, 1),
|
||||
'DSPACX2': ('IntReg', 'uw', 'INTREG_DSP_ACX2', None, 1),
|
||||
'DSPLo3': ('IntReg', 'uw', 'INTREG_DSP_LO3', None, 1),
|
||||
'DSPHi3': ('IntReg', 'uw', 'INTREG_DSP_HI3', None, 1),
|
||||
'DSPACX3': ('IntReg', 'uw', 'INTREG_DSP_ACX3', None, 1),
|
||||
|
||||
#Floating Point Reg Operands
|
||||
'Fd': ('FloatReg', 'sf', 'FD', 'IsFloating', 1),
|
||||
'Fs': ('FloatReg', 'sf', 'FS', 'IsFloating', 2),
|
||||
'Ft': ('FloatReg', 'sf', 'FT', 'IsFloating', 3),
|
||||
'Fr': ('FloatReg', 'sf', 'FR', 'IsFloating', 3),
|
||||
|
||||
#Special Purpose Floating Point Control Reg Operands
|
||||
'FIR': ('FloatReg', 'uw', 'FLOATREG_FIR', 'IsFloating', 1),
|
||||
'FCCR': ('FloatReg', 'uw', 'FLOATREG_FCCR', 'IsFloating', 2),
|
||||
'FEXR': ('FloatReg', 'uw', 'FLOATREG_FEXR', 'IsFloating', 3),
|
||||
'FENR': ('FloatReg', 'uw', 'FLOATREG_FENR', 'IsFloating', 3),
|
||||
'FCSR': ('FloatReg', 'uw', 'FLOATREG_FCSR', 'IsFloating', 3),
|
||||
|
||||
#Operands For Paired Singles FP Operations
|
||||
'Fd1': ('FloatReg', 'sf', 'FD', 'IsFloating', 4),
|
||||
'Fd2': ('FloatReg', 'sf', 'FD+1', 'IsFloating', 4),
|
||||
'Fs1': ('FloatReg', 'sf', 'FS', 'IsFloating', 5),
|
||||
'Fs2': ('FloatReg', 'sf', 'FS+1', 'IsFloating', 5),
|
||||
'Ft1': ('FloatReg', 'sf', 'FT', 'IsFloating', 6),
|
||||
'Ft2': ('FloatReg', 'sf', 'FT+1', 'IsFloating', 6),
|
||||
'Fr1': ('FloatReg', 'sf', 'FR', 'IsFloating', 7),
|
||||
'Fr2': ('FloatReg', 'sf', 'FR+1', 'IsFloating', 7),
|
||||
|
||||
#Status Control Reg
|
||||
'Status': ('ControlReg', 'uw', 'MISCREG_STATUS', None, 1),
|
||||
|
||||
#LL Flag
|
||||
'LLFlag': ('ControlReg', 'uw', 'MISCREG_LLFLAG', None, 1),
|
||||
|
||||
#Thread pointer value for SE mode
|
||||
'TpValue': ('ControlReg', 'ud', 'MISCREG_TP_VALUE', None, 1),
|
||||
|
||||
# Index Register
|
||||
'Index': ('ControlReg','uw','MISCREG_INDEX',None,1),
|
||||
|
||||
|
||||
'CP0_RD_SEL': ('ControlReg', 'uw', '(RD << 3 | SEL)', None, 1),
|
||||
|
||||
#MT Control Regs
|
||||
'MVPConf0': ('ControlReg', 'uw', 'MISCREG_MVP_CONF0', None, 1),
|
||||
'MVPControl': ('ControlReg', 'uw', 'MISCREG_MVP_CONTROL', None, 1),
|
||||
'TCBind': ('ControlReg', 'uw', 'MISCREG_TC_BIND', None, 1),
|
||||
'TCStatus': ('ControlReg', 'uw', 'MISCREG_TC_STATUS', None, 1),
|
||||
'TCRestart': ('ControlReg', 'uw', 'MISCREG_TC_RESTART', None, 1),
|
||||
'VPEConf0': ('ControlReg', 'uw', 'MISCREG_VPE_CONF0', None, 1),
|
||||
'VPEControl': ('ControlReg', 'uw', 'MISCREG_VPE_CONTROL', None, 1),
|
||||
'YQMask': ('ControlReg', 'uw', 'MISCREG_YQMASK', None, 1),
|
||||
|
||||
#CP0 Control Regs
|
||||
'EntryHi': ('ControlReg','uw', 'MISCREG_ENTRYHI',None,1),
|
||||
'EntryLo0': ('ControlReg','uw', 'MISCREG_ENTRYLO0',None,1),
|
||||
'EntryLo1': ('ControlReg','uw', 'MISCREG_ENTRYLO1',None,1),
|
||||
'PageMask': ('ControlReg','uw', 'MISCREG_PAGEMASK',None,1),
|
||||
'Random': ('ControlReg','uw', 'MISCREG_CP0_RANDOM',None,1),
|
||||
'ErrorEPC': ('ControlReg','uw', 'MISCREG_ERROR_EPC',None,1),
|
||||
'EPC': ('ControlReg','uw', 'MISCREG_EPC',None,1),
|
||||
'DEPC': ('ControlReg','uw', 'MISCREG_DEPC',None,1),
|
||||
'IntCtl': ('ControlReg','uw', 'MISCREG_INTCTL',None,1),
|
||||
'SRSCtl': ('ControlReg','uw', 'MISCREG_SRSCTL',None,1),
|
||||
'Config': ('ControlReg','uw', 'MISCREG_CONFIG',None,1),
|
||||
'Config3': ('ControlReg','uw', 'MISCREG_CONFIG3',None,1),
|
||||
'Config1': ('ControlReg','uw', 'MISCREG_CONFIG1',None,1),
|
||||
'Config2': ('ControlReg','uw', 'MISCREG_CONFIG2',None,1),
|
||||
'PageGrain': ('ControlReg','uw', 'MISCREG_PAGEGRAIN',None,1),
|
||||
'Debug': ('ControlReg','uw', 'MISCREG_DEBUG',None,1),
|
||||
'Cause': ('ControlReg','uw', 'MISCREG_CAUSE',None,1),
|
||||
|
||||
#Memory Operand
|
||||
'Mem': ('Mem', 'uw', None, ('IsMemRef', 'IsLoad', 'IsStore'), 4),
|
||||
|
||||
#Program Counter Operands
|
||||
'PC': ('PCState', 'uw', 'pc', (None, None, 'IsControl'), 4),
|
||||
'NPC': ('PCState', 'uw', 'npc', (None, None, 'IsControl'), 4),
|
||||
'NNPC': ('PCState', 'uw', 'nnpc', (None, None, 'IsControl'), 4)
|
||||
}};
|
||||
165
simulators/gem5/src/arch/mips/isa_traits.hh
Normal file
165
simulators/gem5/src/arch/mips/isa_traits.hh
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Korey Sewell
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_ISA_TRAITS_HH__
|
||||
#define __ARCH_MIPS_ISA_TRAITS_HH__
|
||||
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/types.hh"
|
||||
#include "cpu/static_inst_fwd.hh"
|
||||
|
||||
namespace LittleEndianGuest {}
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
using namespace LittleEndianGuest;
|
||||
|
||||
StaticInstPtr decodeInst(ExtMachInst);
|
||||
|
||||
// MIPS DOES have a delay slot
|
||||
#define ISA_HAS_DELAY_SLOT 1
|
||||
|
||||
const Addr PageShift = 13;
|
||||
const Addr PageBytes = ULL(1) << PageShift;
|
||||
const Addr Page_Mask = ~(PageBytes - 1);
|
||||
const Addr PageOffset = PageBytes - 1;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Translation stuff
|
||||
//
|
||||
|
||||
const Addr PteShift = 3;
|
||||
const Addr NPtePageShift = PageShift - PteShift;
|
||||
const Addr NPtePage = ULL(1) << NPtePageShift;
|
||||
const Addr PteMask = NPtePage - 1;
|
||||
|
||||
//// All 'Mapped' segments go through the TLB
|
||||
//// All other segments are translated by dropping the MSB, to give
|
||||
//// the corresponding physical address
|
||||
// User Segment - Mapped
|
||||
const Addr USegBase = ULL(0x0);
|
||||
const Addr USegEnd = ULL(0x7FFFFFFF);
|
||||
|
||||
// Kernel Segment 0 - Unmapped
|
||||
const Addr KSeg0End = ULL(0x9FFFFFFF);
|
||||
const Addr KSeg0Base = ULL(0x80000000);
|
||||
const Addr KSeg0Mask = ULL(0x1FFFFFFF);
|
||||
|
||||
// Kernel Segment 1 - Unmapped, Uncached
|
||||
const Addr KSeg1End = ULL(0xBFFFFFFF);
|
||||
const Addr KSeg1Base = ULL(0xA0000000);
|
||||
const Addr KSeg1Mask = ULL(0x1FFFFFFF);
|
||||
|
||||
// Kernel/Supervisor Segment - Mapped
|
||||
const Addr KSSegEnd = ULL(0xDFFFFFFF);
|
||||
const Addr KSSegBase = ULL(0xC0000000);
|
||||
|
||||
// Kernel Segment 3 - Mapped
|
||||
const Addr KSeg3End = ULL(0xFFFFFFFF);
|
||||
const Addr KSeg3Base = ULL(0xE0000000);
|
||||
|
||||
|
||||
inline Addr Phys2K0Seg(Addr addr)
|
||||
{
|
||||
return addr | KSeg0Base;
|
||||
}
|
||||
|
||||
|
||||
const unsigned VABits = 32;
|
||||
const unsigned PABits = 32; // Is this correct?
|
||||
const Addr VAddrImplMask = (ULL(1) << VABits) - 1;
|
||||
const Addr VAddrUnImplMask = ~VAddrImplMask;
|
||||
inline Addr VAddrImpl(Addr a) { return a & VAddrImplMask; }
|
||||
inline Addr VAddrVPN(Addr a) { return a >> MipsISA::PageShift; }
|
||||
inline Addr VAddrOffset(Addr a) { return a & MipsISA::PageOffset; }
|
||||
|
||||
const Addr PAddrImplMask = (ULL(1) << PABits) - 1;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Interrupt levels
|
||||
//
|
||||
enum InterruptLevels
|
||||
{
|
||||
INTLEVEL_SOFTWARE_MIN = 4,
|
||||
INTLEVEL_SOFTWARE_MAX = 19,
|
||||
|
||||
INTLEVEL_EXTERNAL_MIN = 20,
|
||||
INTLEVEL_EXTERNAL_MAX = 34,
|
||||
|
||||
INTLEVEL_IRQ0 = 20,
|
||||
INTLEVEL_IRQ1 = 21,
|
||||
INTINDEX_ETHERNET = 0,
|
||||
INTINDEX_SCSI = 1,
|
||||
INTLEVEL_IRQ2 = 22,
|
||||
INTLEVEL_IRQ3 = 23,
|
||||
|
||||
INTLEVEL_SERIAL = 33,
|
||||
|
||||
NumInterruptLevels = INTLEVEL_EXTERNAL_MAX
|
||||
};
|
||||
|
||||
// MIPS modes
|
||||
enum mode_type
|
||||
{
|
||||
mode_kernel = 0, // kernel
|
||||
mode_supervisor = 1, // supervisor
|
||||
mode_user = 2, // user mode
|
||||
mode_debug = 3, // debug mode
|
||||
mode_number // number of modes
|
||||
};
|
||||
|
||||
// return a no-op instruction... used for instruction fetch faults
|
||||
const ExtMachInst NoopMachInst = 0x00000000;
|
||||
|
||||
const int LogVMPageSize = 13; // 8K bytes
|
||||
const int VMPageSize = (1 << LogVMPageSize);
|
||||
|
||||
const int BranchPredAddrShiftAmt = 2; // instructions are 4-byte aligned
|
||||
|
||||
const int MachineBytes = 4;
|
||||
const int WordBytes = 4;
|
||||
const int HalfwordBytes = 2;
|
||||
const int ByteBytes = 1;
|
||||
|
||||
const int ANNOTE_NONE = 0;
|
||||
const uint32_t ITOUCH_ANNOTE = 0xffffffff;
|
||||
|
||||
const bool HasUnalignedMemAcc = true;
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif // __ARCH_MIPS_ISA_TRAITS_HH__
|
||||
54
simulators/gem5/src/arch/mips/kernel_stats.hh
Normal file
54
simulators/gem5/src/arch/mips/kernel_stats.hh
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Lisa Hsu
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_KERNEL_STATS_HH__
|
||||
#define __ARCH_MIPS_KERNEL_STATS_HH__
|
||||
|
||||
#include "kern/kernel_stats.hh"
|
||||
|
||||
namespace MipsISA {
|
||||
namespace Kernel {
|
||||
|
||||
enum cpu_mode { kernel, user, idle, cpu_mode_num };
|
||||
extern const char *modestr[];
|
||||
|
||||
class Statistics : public ::Kernel::Statistics
|
||||
{
|
||||
public:
|
||||
Statistics(System *system) : ::Kernel::Statistics(system)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
} // namespace MipsISA::Kernel
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif // __ARCH_MIPS_KERNEL_STATS_HH__
|
||||
50
simulators/gem5/src/arch/mips/linux/aligned.hh
Normal file
50
simulators/gem5/src/arch/mips/linux/aligned.hh
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2004 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_ALIGNED_HH__
|
||||
#define __ARCH_MIPS_LINUX_ALIGNED_HH__
|
||||
|
||||
|
||||
/* GCC 3.3.X has a bug in which attributes+typedefs don't work. 3.2.X is fine
|
||||
* as in 3.4.X, but the bug is marked will not fix in 3.3.X so here is
|
||||
* the work around.
|
||||
*/
|
||||
#if (__GNUC__ == 3 && __GNUC_MINOR__ != 3) || __GNUC__ > 3
|
||||
typedef uint64_t uint64_ta __attribute__ ((aligned (8))) ;
|
||||
typedef int64_t int64_ta __attribute__ ((aligned (8))) ;
|
||||
typedef Addr Addr_a __attribute__ ((aligned (8))) ;
|
||||
#else
|
||||
#define uint64_ta uint64_t __attribute__ ((aligned (8)))
|
||||
#define int64_ta int64_t __attribute__ ((aligned (8)))
|
||||
#define Addr_a Addr __attribute__ ((aligned (8)))
|
||||
#endif /* __GNUC__ __GNUC_MINOR__ */
|
||||
|
||||
#endif /* __ARCH_MIPS_LINUX_ALIGNED_HH__ */
|
||||
42
simulators/gem5/src/arch/mips/linux/hwrpb.hh
Normal file
42
simulators/gem5/src/arch/mips/linux/hwrpb.hh
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 1990 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_HWRPB_HH__
|
||||
#define __ARCH_MIPS_LINUX_HWRPB_HH__
|
||||
|
||||
#include "arch/mips/linux/aligned.hh"
|
||||
|
||||
namespace Linux {
|
||||
struct pcb_struct {
|
||||
uint64_ta rpb_ksp;
|
||||
uint64_ta rpb_usp;
|
||||
uint64_ta rpb_ptbr;
|
||||
uint32_t rpb_cc;
|
||||
uint32_t rpb_psn;
|
||||
uint64_ta rpb_unique;
|
||||
uint64_ta rpb_fen;
|
||||
uint64_ta res1, res2;
|
||||
};
|
||||
}
|
||||
#endif // __ARCH_MIPS_LINUX_HWRPB_HH__
|
||||
71
simulators/gem5/src/arch/mips/linux/linux.cc
Normal file
71
simulators/gem5/src/arch/mips/linux/linux.cc
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "arch/mips/linux/linux.hh"
|
||||
|
||||
// open(2) flags translation table
|
||||
OpenFlagTransTable MipsLinux::openFlagTable[] = {
|
||||
#ifdef _MSC_VER
|
||||
{ MipsLinux::TGT_O_RDONLY, _O_RDONLY },
|
||||
{ MipsLinux::TGT_O_WRONLY, _O_WRONLY },
|
||||
{ MipsLinux::TGT_O_RDWR, _O_RDWR },
|
||||
{ MipsLinux::TGT_O_APPEND, _O_APPEND },
|
||||
{ MipsLinux::TGT_O_CREAT, _O_CREAT },
|
||||
{ MipsLinux::TGT_O_TRUNC, _O_TRUNC },
|
||||
{ MipsLinux::TGT_O_EXCL, _O_EXCL },
|
||||
#ifdef _O_NONBLOCK
|
||||
{ MipsLinux::TGT_O_NONBLOCK, _O_NONBLOCK },
|
||||
#endif
|
||||
#ifdef _O_NOCTTY
|
||||
{ MipsLinux::TGT_O_NOCTTY, _O_NOCTTY },
|
||||
#endif
|
||||
#ifdef _O_SYNC
|
||||
{ MipsLinux::TGT_O_SYNC, _O_SYNC },
|
||||
#endif
|
||||
#else /* !_MSC_VER */
|
||||
{ MipsLinux::TGT_O_RDONLY, O_RDONLY },
|
||||
{ MipsLinux::TGT_O_WRONLY, O_WRONLY },
|
||||
{ MipsLinux::TGT_O_RDWR, O_RDWR },
|
||||
{ MipsLinux::TGT_O_APPEND, O_APPEND },
|
||||
{ MipsLinux::TGT_O_CREAT, O_CREAT },
|
||||
{ MipsLinux::TGT_O_TRUNC, O_TRUNC },
|
||||
{ MipsLinux::TGT_O_EXCL, O_EXCL },
|
||||
{ MipsLinux::TGT_O_NONBLOCK, O_NONBLOCK },
|
||||
{ MipsLinux::TGT_O_NOCTTY, O_NOCTTY },
|
||||
#ifdef O_SYNC
|
||||
{ MipsLinux::TGT_O_SYNC, O_SYNC },
|
||||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
};
|
||||
|
||||
const int MipsLinux::NUM_OPEN_FLAGS =
|
||||
(sizeof(MipsLinux::openFlagTable)/sizeof(MipsLinux::openFlagTable[0]));
|
||||
149
simulators/gem5/src/arch/mips/linux/linux.hh
Normal file
149
simulators/gem5/src/arch/mips/linux/linux.hh
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_LINUX_HH__
|
||||
#define __ARCH_MIPS_LINUX_LINUX_HH__
|
||||
|
||||
#include "kern/linux/linux.hh"
|
||||
|
||||
class MipsLinux : public Linux
|
||||
{
|
||||
public:
|
||||
|
||||
/// This table maps the target open() flags to the corresponding
|
||||
/// host open() flags.
|
||||
static OpenFlagTransTable openFlagTable[];
|
||||
|
||||
/// Number of entries in openFlagTable[].
|
||||
static const int NUM_OPEN_FLAGS;
|
||||
|
||||
//@{
|
||||
/// open(2) flag values.
|
||||
static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
|
||||
static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
|
||||
static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
|
||||
static const int TGT_O_NONBLOCK = 0x00000080; //!< O_NONBLOCK
|
||||
static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
|
||||
static const int TGT_O_CREAT = 0x00000100; //!< O_CREAT
|
||||
static const int TGT_O_TRUNC = 0x00000200; //!< O_TRUNC
|
||||
static const int TGT_O_EXCL = 0x00000400; //!< O_EXCL
|
||||
static const int TGT_O_NOCTTY = 0x00000800; //!< O_NOCTTY
|
||||
static const int TGT_O_SYNC = 0x00000010; //!< O_SYNC
|
||||
static const int TGT_O_DRD = 0x00010000; //!< O_DRD
|
||||
static const int TGT_O_DIRECTIO = 0x00020000; //!< O_DIRECTIO
|
||||
static const int TGT_O_CACHE = 0x00002000; //!< O_CACHE
|
||||
static const int TGT_O_DSYNC = 0x00008000; //!< O_DSYNC
|
||||
static const int TGT_O_RSYNC = 0x00040000; //!< O_RSYNC
|
||||
//@}
|
||||
|
||||
/// For mmap().
|
||||
static const unsigned TGT_MAP_ANONYMOUS = 0x800;
|
||||
static const unsigned TGT_MAP_FIXED = 0x10;
|
||||
|
||||
//@{
|
||||
/// For getsysinfo().
|
||||
static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
|
||||
static const unsigned GSI_CPU_INFO = 59; //!< CPU information
|
||||
static const unsigned GSI_PROC_TYPE = 60; //!< get proc_type
|
||||
static const unsigned GSI_MAX_CPU = 30; //!< max # cpu's on this machine
|
||||
static const unsigned GSI_CPUS_IN_BOX = 55; //!< number of CPUs in system
|
||||
static const unsigned GSI_PHYSMEM = 19; //!< Physical memory in KB
|
||||
static const unsigned GSI_CLK_TCK = 42; //!< clock freq in Hz
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// For getrusage().
|
||||
static const int TGT_RUSAGE_SELF = 0;
|
||||
static const int TGT_RUSAGE_CHILDREN = -1;
|
||||
static const int TGT_RUSAGE_BOTH = -2;
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// For setsysinfo().
|
||||
static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// ioctl() command codes.
|
||||
static const unsigned TIOCGETP_ = 0x7408;
|
||||
static const unsigned TIOCSETP_ = 0x7409;
|
||||
static const unsigned TIOCSETN_ = 0x740a;
|
||||
static const unsigned TIOCSETC_ = 0x7411;
|
||||
static const unsigned TIOCGETC_ = 0x7412;
|
||||
static const unsigned FIONREAD_ = 0x467f;
|
||||
static const unsigned TIOCISATTY_ = 0x5480;
|
||||
static const unsigned TIOCGETS_ = 0x540d;
|
||||
static const unsigned TIOCGETA_ = 0x7417;
|
||||
static const unsigned TCSETAW_ = 0x5403; // 2.6.15 kernel
|
||||
//@}
|
||||
|
||||
/// For table().
|
||||
static const int TBL_SYSINFO = 12;
|
||||
|
||||
/// Resource enumeration for getrlimit()/setrlimit().
|
||||
enum rlimit_resources {
|
||||
TGT_RLIMIT_CPU = 0,
|
||||
TGT_RLIMIT_FSIZE = 1,
|
||||
TGT_RLIMIT_DATA = 2,
|
||||
TGT_RLIMIT_STACK = 3,
|
||||
TGT_RLIMIT_CORE = 4,
|
||||
TGT_RLIMIT_NOFILE = 5,
|
||||
TGT_RLIMIT_AS = 6,
|
||||
TGT_RLIMIT_RSS = 7,
|
||||
TGT_RLIMIT_VMEM = 7,
|
||||
TGT_RLIMIT_NPROC = 8,
|
||||
TGT_RLIMIT_MEMLOCK = 9,
|
||||
TGT_RLIMIT_LOCKS = 10,
|
||||
NUM_RLIMIT_RESOURCES
|
||||
};
|
||||
|
||||
/// Offset used to make sure that processes don't
|
||||
/// assign themselves to process IDs reserved for
|
||||
/// the root users.
|
||||
static const int NUM_ROOT_PROCS = 2;
|
||||
|
||||
typedef struct {
|
||||
int32_t uptime; /* Seconds since boot */
|
||||
uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint32_t totalram; /* Total usable main memory size */
|
||||
uint32_t freeram; /* Available memory size */
|
||||
uint32_t sharedram; /* Amount of shared memory */
|
||||
uint32_t bufferram; /* Memory used by buffers */
|
||||
uint32_t totalswap; /* Total swap space size */
|
||||
uint32_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint32_t totalhigh; /* Total high memory size */
|
||||
uint32_t freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
482
simulators/gem5/src/arch/mips/linux/process.cc
Normal file
482
simulators/gem5/src/arch/mips/linux/process.cc
Normal file
@ -0,0 +1,482 @@
|
||||
/*
|
||||
* Copyright (c) 2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#include "arch/mips/linux/linux.hh"
|
||||
#include "arch/mips/linux/process.hh"
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/SyscallVerbose.hh"
|
||||
#include "kern/linux/linux.hh"
|
||||
#include "sim/eventq.hh"
|
||||
#include "sim/process.hh"
|
||||
#include "sim/syscall_emul.hh"
|
||||
#include "sim/system.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||
ThreadContext *tc)
|
||||
{
|
||||
int index = 0;
|
||||
TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
|
||||
|
||||
strcpy(name->sysname, "Linux");
|
||||
strcpy(name->nodename,"m5.eecs.umich.edu");
|
||||
strcpy(name->release, "2.6.35");
|
||||
strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
|
||||
strcpy(name->machine, "mips");
|
||||
|
||||
name.copyOut(tc->getMemProxy());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Target sys_getsysyinfo() handler. Even though this call is
|
||||
/// borrowed from Tru64, the subcases that get used appear to be
|
||||
/// different in practice from those used by Tru64 processes.
|
||||
static SyscallReturn
|
||||
sys_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||
ThreadContext *tc)
|
||||
{
|
||||
int index = 0;
|
||||
unsigned op = process->getSyscallArg(tc, index);
|
||||
unsigned bufPtr = process->getSyscallArg(tc, index);
|
||||
// unsigned nbytes = process->getSyscallArg(tc, index);
|
||||
|
||||
switch (op) {
|
||||
case 45:
|
||||
{
|
||||
// GSI_IEEE_FP_CONTROL
|
||||
TypedBufferArg<uint64_t> fpcr(bufPtr);
|
||||
// I don't think this exactly matches the HW FPCR
|
||||
*fpcr = 0;
|
||||
fpcr.copyOut(tc->getMemProxy());
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
cerr << "sys_getsysinfo: unknown op " << op << endl;
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Target sys_setsysinfo() handler.
|
||||
static SyscallReturn
|
||||
sys_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||
ThreadContext *tc)
|
||||
{
|
||||
int index = 0;
|
||||
unsigned op = process->getSyscallArg(tc, index);
|
||||
Addr bufPtr = process->getSyscallArg(tc, index);
|
||||
// unsigned nbytes = process->getSyscallArg(tc, index);
|
||||
|
||||
switch (op) {
|
||||
|
||||
case 14:
|
||||
{
|
||||
// SSI_IEEE_FP_CONTROL
|
||||
TypedBufferArg<uint64_t> fpcr(bufPtr);
|
||||
// I don't think this exactly matches the HW FPCR
|
||||
fpcr.copyIn(tc->getMemProxy());
|
||||
DPRINTFR(SyscallVerbose, "sys_setsysinfo(SSI_IEEE_FP_CONTROL): "
|
||||
" setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr));
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
cerr << "sys_setsysinfo: unknown op " << op << endl;
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static SyscallReturn
|
||||
setThreadAreaFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||
ThreadContext *tc)
|
||||
{
|
||||
int index = 0;
|
||||
Addr addr = process->getSyscallArg(tc, index);
|
||||
tc->setMiscRegNoEffect(MISCREG_TP_VALUE, addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SyscallDesc MipsLinuxProcess::syscallDescs[] = {
|
||||
/* 0 */ SyscallDesc("syscall", unimplementedFunc),
|
||||
/* 1 */ SyscallDesc("exit", exitFunc),
|
||||
/* 2 */ SyscallDesc("fork", unimplementedFunc),
|
||||
/* 3 */ SyscallDesc("read", readFunc),
|
||||
/* 4 */ SyscallDesc("write", writeFunc),
|
||||
/* 5 */ SyscallDesc("open", openFunc<MipsLinux>),
|
||||
/* 6 */ SyscallDesc("close", closeFunc),
|
||||
/* 7 */ SyscallDesc("waitpid", unimplementedFunc),
|
||||
/* 8 */ SyscallDesc("creat", unimplementedFunc),
|
||||
/* 9 */ SyscallDesc("link", unimplementedFunc),
|
||||
/* 10 */ SyscallDesc("unlink", unlinkFunc),
|
||||
/* 11 */ SyscallDesc("execve", unimplementedFunc),
|
||||
/* 12 */ SyscallDesc("chdir", unimplementedFunc),
|
||||
/* 13 */ SyscallDesc("time", unimplementedFunc),
|
||||
/* 14 */ SyscallDesc("mknod", unimplementedFunc),
|
||||
/* 15 */ SyscallDesc("chmod", chmodFunc<MipsLinux>),
|
||||
/* 16 */ SyscallDesc("lchown", chownFunc),
|
||||
/* 17 */ SyscallDesc("break", brkFunc),
|
||||
/* 18 */ SyscallDesc("unused#18", unimplementedFunc),
|
||||
/* 19 */ SyscallDesc("lseek", lseekFunc),
|
||||
/* 20 */ SyscallDesc("getpid", getpidFunc),
|
||||
/* 21 */ SyscallDesc("mount", unimplementedFunc),
|
||||
/* 22 */ SyscallDesc("umount", unimplementedFunc),
|
||||
/* 23 */ SyscallDesc("setuid", setuidFunc),
|
||||
/* 24 */ SyscallDesc("getuid", getuidFunc),
|
||||
/* 25 */ SyscallDesc("stime", unimplementedFunc),
|
||||
/* 26 */ SyscallDesc("ptrace", unimplementedFunc),
|
||||
/* 27 */ SyscallDesc("alarm", unimplementedFunc),
|
||||
/* 28 */ SyscallDesc("unused#28", unimplementedFunc),
|
||||
/* 29 */ SyscallDesc("pause", unimplementedFunc),
|
||||
/* 30 */ SyscallDesc("utime", unimplementedFunc),
|
||||
/* 31 */ SyscallDesc("stty", unimplementedFunc),
|
||||
/* 32 */ SyscallDesc("gtty", unimplementedFunc),
|
||||
/* 33 */ SyscallDesc("access", unimplementedFunc),
|
||||
/* 34 */ SyscallDesc("nice", unimplementedFunc),
|
||||
/* 35 */ SyscallDesc("ftime", unimplementedFunc),
|
||||
/* 36 */ SyscallDesc("sync", unimplementedFunc),
|
||||
/* 37 */ SyscallDesc("kill", unimplementedFunc),
|
||||
/* 38 */ SyscallDesc("rename", unimplementedFunc),
|
||||
/* 39 */ SyscallDesc("mkdir", mkdirFunc),
|
||||
/* 40 */ SyscallDesc("rmdir", unimplementedFunc),
|
||||
/* 41 */ SyscallDesc("dup", unimplementedFunc),
|
||||
/* 42 */ SyscallDesc("pipe", pipePseudoFunc),
|
||||
/* 43 */ SyscallDesc("times", unimplementedFunc),
|
||||
/* 44 */ SyscallDesc("prof", unimplementedFunc),
|
||||
/* 45 */ SyscallDesc("brk", brkFunc),
|
||||
/* 46 */ SyscallDesc("setgid", unimplementedFunc),
|
||||
/* 47 */ SyscallDesc("getgid", getgidFunc),
|
||||
/* 48 */ SyscallDesc("signal", ignoreFunc),
|
||||
/* 49 */ SyscallDesc("geteuid", geteuidFunc),
|
||||
/* 50 */ SyscallDesc("getegid", getegidFunc),
|
||||
/* 51 */ SyscallDesc("acct", unimplementedFunc),
|
||||
/* 52 */ SyscallDesc("umount2", unimplementedFunc),
|
||||
/* 53 */ SyscallDesc("lock", unimplementedFunc),
|
||||
/* 54 */ SyscallDesc("ioctl", ioctlFunc<MipsLinux>),
|
||||
/* 55 */ SyscallDesc("fcntl", fcntlFunc),
|
||||
/* 56 */ SyscallDesc("mpx", unimplementedFunc),
|
||||
/* 57 */ SyscallDesc("setpgid", unimplementedFunc),
|
||||
/* 58 */ SyscallDesc("ulimit", unimplementedFunc),
|
||||
/* 59 */ SyscallDesc("unused#59", unimplementedFunc),
|
||||
/* 60 */ SyscallDesc("umask", umaskFunc),
|
||||
/* 61 */ SyscallDesc("chroot", unimplementedFunc),
|
||||
/* 62 */ SyscallDesc("ustat", unimplementedFunc),
|
||||
/* 63 */ SyscallDesc("dup2", unimplementedFunc),
|
||||
/* 64 */ SyscallDesc("getppid", getpagesizeFunc),
|
||||
/* 65 */ SyscallDesc("getpgrp", unimplementedFunc),
|
||||
/* 66 */ SyscallDesc("setsid", unimplementedFunc),
|
||||
/* 67 */ SyscallDesc("sigaction",unimplementedFunc),
|
||||
/* 68 */ SyscallDesc("sgetmask", unimplementedFunc),
|
||||
/* 69 */ SyscallDesc("ssetmask", unimplementedFunc),
|
||||
/* 70 */ SyscallDesc("setreuid", unimplementedFunc),
|
||||
/* 71 */ SyscallDesc("setregid", unimplementedFunc),
|
||||
/* 72 */ SyscallDesc("sigsuspend", unimplementedFunc),
|
||||
/* 73 */ SyscallDesc("sigpending", unimplementedFunc),
|
||||
/* 74 */ SyscallDesc("sethostname", ignoreFunc),
|
||||
/* 75 */ SyscallDesc("setrlimit", unimplementedFunc),
|
||||
/* 76 */ SyscallDesc("getrlimit", unimplementedFunc),
|
||||
/* 77 */ SyscallDesc("getrusage", getrusageFunc<MipsLinux>),
|
||||
/* 78 */ SyscallDesc("gettimeofday", unimplementedFunc),
|
||||
/* 79 */ SyscallDesc("settimeofday", unimplementedFunc),
|
||||
/* 80 */ SyscallDesc("getgroups", unimplementedFunc),
|
||||
/* 81 */ SyscallDesc("setgroups", unimplementedFunc),
|
||||
/* 82 */ SyscallDesc("reserved#82", unimplementedFunc),
|
||||
/* 83 */ SyscallDesc("symlink", unimplementedFunc),
|
||||
/* 84 */ SyscallDesc("unused#84", unimplementedFunc),
|
||||
/* 85 */ SyscallDesc("readlink", readlinkFunc),
|
||||
/* 86 */ SyscallDesc("uselib", unimplementedFunc),
|
||||
/* 87 */ SyscallDesc("swapon", gethostnameFunc),
|
||||
/* 88 */ SyscallDesc("reboot", unimplementedFunc),
|
||||
/* 89 */ SyscallDesc("readdir", unimplementedFunc),
|
||||
/* 90 */ SyscallDesc("mmap", mmapFunc<MipsLinux>),
|
||||
/* 91 */ SyscallDesc("munmap",munmapFunc),
|
||||
/* 92 */ SyscallDesc("truncate", truncateFunc),
|
||||
/* 93 */ SyscallDesc("ftruncate", ftruncateFunc),
|
||||
/* 94 */ SyscallDesc("fchmod", fchmodFunc<MipsLinux>),
|
||||
/* 95 */ SyscallDesc("fchown", fchownFunc),
|
||||
/* 96 */ SyscallDesc("getpriority", unimplementedFunc),
|
||||
/* 97 */ SyscallDesc("setpriority", unimplementedFunc),
|
||||
/* 98 */ SyscallDesc("profil", unimplementedFunc),
|
||||
/* 99 */ SyscallDesc("statfs", unimplementedFunc),
|
||||
/* 100 */ SyscallDesc("fstatfs", unimplementedFunc),
|
||||
/* 101 */ SyscallDesc("ioperm", unimplementedFunc),
|
||||
/* 102 */ SyscallDesc("socketcall", unimplementedFunc),
|
||||
/* 103 */ SyscallDesc("syslog", unimplementedFunc),
|
||||
/* 104 */ SyscallDesc("setitimer", unimplementedFunc),
|
||||
/* 105 */ SyscallDesc("getitimer", unimplementedFunc),
|
||||
/* 106 */ SyscallDesc("stat", statFunc<MipsLinux>),
|
||||
/* 107 */ SyscallDesc("lstat", unimplementedFunc),
|
||||
/* 108 */ SyscallDesc("fstat", fstatFunc<MipsLinux>),
|
||||
/* 109 */ SyscallDesc("unused#109", unimplementedFunc),
|
||||
/* 110 */ SyscallDesc("iopl", unimplementedFunc),
|
||||
/* 111 */ SyscallDesc("vhangup", unimplementedFunc),
|
||||
/* 112 */ SyscallDesc("idle", ignoreFunc),
|
||||
/* 113 */ SyscallDesc("vm86", unimplementedFunc),
|
||||
/* 114 */ SyscallDesc("wait4", unimplementedFunc),
|
||||
/* 115 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", sysinfoFunc<MipsLinux>),
|
||||
/* 117 */ SyscallDesc("ipc", unimplementedFunc),
|
||||
/* 118 */ SyscallDesc("fsync", unimplementedFunc),
|
||||
/* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
|
||||
/* 120 */ SyscallDesc("clone", unimplementedFunc),
|
||||
/* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
|
||||
/* 122 */ SyscallDesc("uname", unameFunc),
|
||||
/* 123 */ SyscallDesc("modify_ldt", unimplementedFunc),
|
||||
/* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
|
||||
/* 125 */ SyscallDesc("mprotect", ignoreFunc),
|
||||
/* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
|
||||
/* 127 */ SyscallDesc("create_module", unimplementedFunc),
|
||||
/* 128 */ SyscallDesc("init_module", unimplementedFunc),
|
||||
/* 129 */ SyscallDesc("delete_module", unimplementedFunc),
|
||||
/* 130 */ SyscallDesc("get_kernel_syms", unimplementedFunc),
|
||||
/* 131 */ SyscallDesc("quotactl", unimplementedFunc),
|
||||
/* 132 */ SyscallDesc("getpgid", unimplementedFunc),
|
||||
/* 133 */ SyscallDesc("fchdir", unimplementedFunc),
|
||||
/* 134 */ SyscallDesc("bdflush", unimplementedFunc),
|
||||
/* 135 */ SyscallDesc("sysfs", unimplementedFunc),
|
||||
/* 136 */ SyscallDesc("personality", unimplementedFunc),
|
||||
/* 137 */ SyscallDesc("afs_syscall", unimplementedFunc),
|
||||
/* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
|
||||
/* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
|
||||
/* 140 */ SyscallDesc("llseek", unimplementedFunc),
|
||||
/* 141 */ SyscallDesc("getdents", unimplementedFunc),
|
||||
/* 142 */ SyscallDesc("newselect", unimplementedFunc),
|
||||
/* 143 */ SyscallDesc("flock", unimplementedFunc),
|
||||
/* 144 */ SyscallDesc("msync", unimplementedFunc),
|
||||
/* 145 */ SyscallDesc("readv", unimplementedFunc),
|
||||
/* 146 */ SyscallDesc("writev", writevFunc<MipsLinux>),
|
||||
/* 147 */ SyscallDesc("cacheflush", unimplementedFunc),
|
||||
/* 148 */ SyscallDesc("cachectl", unimplementedFunc),
|
||||
/* 149 */ SyscallDesc("sysmips", unimplementedFunc),
|
||||
/* 150 */ SyscallDesc("unused#150", unimplementedFunc),
|
||||
/* 151 */ SyscallDesc("getsid", unimplementedFunc),
|
||||
/* 152 */ SyscallDesc("fdatasync", unimplementedFunc),
|
||||
/* 153 */ SyscallDesc("sysctl", ignoreFunc),
|
||||
/* 154 */ SyscallDesc("mlock", unimplementedFunc),
|
||||
/* 155 */ SyscallDesc("munlock", unimplementedFunc),
|
||||
/* 156 */ SyscallDesc("mlockall", unimplementedFunc),
|
||||
/* 157 */ SyscallDesc("munlockall", unimplementedFunc),
|
||||
/* 158 */ SyscallDesc("sched_setparam", unimplementedFunc),
|
||||
/* 159 */ SyscallDesc("sched_getparam", unimplementedFunc),
|
||||
/* 160 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
|
||||
/* 161 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
|
||||
/* 162 */ SyscallDesc("sched_yield", unimplementedFunc),
|
||||
/* 163 */ SyscallDesc("sched_get_prioritymax", unimplementedFunc),
|
||||
/* 164 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
|
||||
/* 165 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
|
||||
/* 166 */ SyscallDesc("nanosleep", unimplementedFunc),
|
||||
/* 167 */ SyscallDesc("mremap", mremapFunc<MipsLinux>),
|
||||
/* 168 */ SyscallDesc("accept", unimplementedFunc),
|
||||
/* 169 */ SyscallDesc("bind", unimplementedFunc),
|
||||
/* 170 */ SyscallDesc("connect", unimplementedFunc),
|
||||
/* 171 */ SyscallDesc("getpeername", unimplementedFunc),
|
||||
/* 172 */ SyscallDesc("getsockname", unimplementedFunc),
|
||||
/* 173 */ SyscallDesc("getsockopt", unimplementedFunc),
|
||||
/* 174 */ SyscallDesc("listen", unimplementedFunc),
|
||||
/* 175 */ SyscallDesc("recv", unimplementedFunc),
|
||||
/* 176 */ SyscallDesc("recvmsg", unimplementedFunc),
|
||||
/* 177 */ SyscallDesc("send", unimplementedFunc),
|
||||
/* 178 */ SyscallDesc("sendmsg", ignoreFunc),
|
||||
/* 179 */ SyscallDesc("sendto", unimplementedFunc),
|
||||
/* 180 */ SyscallDesc("setsockopt", unimplementedFunc),
|
||||
/* 181 */ SyscallDesc("shutdown", unimplementedFunc),
|
||||
/* 182 */ SyscallDesc("unknown #182", unimplementedFunc),
|
||||
/* 183 */ SyscallDesc("socket", ignoreFunc),
|
||||
/* 184 */ SyscallDesc("socketpair", unimplementedFunc),
|
||||
/* 185 */ SyscallDesc("setresuid", unimplementedFunc),
|
||||
/* 186 */ SyscallDesc("getresuid", unimplementedFunc),
|
||||
/* 187 */ SyscallDesc("query_module", unimplementedFunc),
|
||||
/* 188 */ SyscallDesc("poll", unimplementedFunc),
|
||||
/* 189 */ SyscallDesc("nfsservctl", unimplementedFunc),
|
||||
/* 190 */ SyscallDesc("setresgid", unimplementedFunc),
|
||||
/* 191 */ SyscallDesc("getresgid", unimplementedFunc),
|
||||
/* 192 */ SyscallDesc("prctl", unimplementedFunc),
|
||||
/* 193 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
|
||||
/* 194 */ SyscallDesc("rt_sigaction", unimplementedFunc),
|
||||
/* 195 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
|
||||
/* 196 */ SyscallDesc("rt_sigpending", unimplementedFunc),
|
||||
/* 197 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
|
||||
/* 198 */ SyscallDesc("rt_sigqueueinfo", ignoreFunc),
|
||||
/* 199 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
|
||||
/* 200 */ SyscallDesc("pread64", unimplementedFunc),
|
||||
/* 201 */ SyscallDesc("pwrite64", unimplementedFunc),
|
||||
/* 202 */ SyscallDesc("chown", unimplementedFunc),
|
||||
/* 203 */ SyscallDesc("getcwd", getcwdFunc),
|
||||
/* 204 */ SyscallDesc("capget", unimplementedFunc),
|
||||
/* 205 */ SyscallDesc("capset", unimplementedFunc),
|
||||
/* 206 */ SyscallDesc("sigalstack", unimplementedFunc),
|
||||
/* 207 */ SyscallDesc("sendfile", unimplementedFunc),
|
||||
/* 208 */ SyscallDesc("getpmsg", unimplementedFunc),
|
||||
/* 209 */ SyscallDesc("putpmsg", unimplementedFunc),
|
||||
/* 210 */ SyscallDesc("mmap2", unimplementedFunc),
|
||||
/* 211 */ SyscallDesc("truncate64", unimplementedFunc),
|
||||
/* 212 */ SyscallDesc("ftruncate64", unimplementedFunc),
|
||||
/* 213 */ SyscallDesc("stat64", unimplementedFunc),
|
||||
/* 214 */ SyscallDesc("lstat64", lstat64Func<MipsLinux>),
|
||||
/* 215 */ SyscallDesc("fstat64", fstat64Func<MipsLinux>),
|
||||
/* 216 */ SyscallDesc("pivot_root", unimplementedFunc),
|
||||
/* 217 */ SyscallDesc("mincore", unimplementedFunc),
|
||||
/* 218 */ SyscallDesc("madvise", unimplementedFunc),
|
||||
/* 219 */ SyscallDesc("getdents64", unimplementedFunc),
|
||||
/* 220 */ SyscallDesc("fcntl64", fcntl64Func),
|
||||
/* 221 */ SyscallDesc("reserved#221", unimplementedFunc),
|
||||
/* 222 */ SyscallDesc("gettid", unimplementedFunc),
|
||||
/* 223 */ SyscallDesc("readahead", unimplementedFunc),
|
||||
/* 224 */ SyscallDesc("setxattr", unimplementedFunc),
|
||||
/* 225 */ SyscallDesc("lsetxattr", unimplementedFunc),
|
||||
/* 226 */ SyscallDesc("fsetxattr", unimplementedFunc),
|
||||
/* 227 */ SyscallDesc("getxattr", unimplementedFunc),
|
||||
/* 228 */ SyscallDesc("lgetxattr", unimplementedFunc),
|
||||
/* 229 */ SyscallDesc("fgetxattr", unimplementedFunc),
|
||||
/* 230 */ SyscallDesc("listxattr", unimplementedFunc),
|
||||
/* 231 */ SyscallDesc("llistxattr", unimplementedFunc),
|
||||
/* 232 */ SyscallDesc("flistxattr", unimplementedFunc),
|
||||
/* 233 */ SyscallDesc("removexattr", unimplementedFunc),
|
||||
/* 234 */ SyscallDesc("lremovexattr", unimplementedFunc),
|
||||
/* 235 */ SyscallDesc("fremovexattr", ignoreFunc),
|
||||
/* 236 */ SyscallDesc("tkill", unimplementedFunc),
|
||||
/* 237 */ SyscallDesc("sendfile64", unimplementedFunc),
|
||||
/* 238 */ SyscallDesc("futex", unimplementedFunc),
|
||||
/* 239 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
|
||||
/* 240 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
|
||||
/* 241 */ SyscallDesc("io_setup", unimplementedFunc),
|
||||
/* 242 */ SyscallDesc("io_destroy", unimplementedFunc),
|
||||
/* 243 */ SyscallDesc("io_getevents", unimplementedFunc),
|
||||
/* 244 */ SyscallDesc("io_submit", unimplementedFunc),
|
||||
/* 245 */ SyscallDesc("io_cancel", unimplementedFunc),
|
||||
/* 246 */ SyscallDesc("exit_group", exitFunc),
|
||||
/* 247 */ SyscallDesc("lookup_dcookie", unimplementedFunc),
|
||||
/* 248 */ SyscallDesc("epoll_create", unimplementedFunc),
|
||||
/* 249 */ SyscallDesc("epoll_ctl", unimplementedFunc),
|
||||
/* 250 */ SyscallDesc("epoll_wait", unimplementedFunc),
|
||||
/* 251 */ SyscallDesc("remap_file_pages", unimplementedFunc),
|
||||
/* 252 */ SyscallDesc("set_tid_address", unimplementedFunc),
|
||||
/* 253 */ SyscallDesc("restart_syscall", unimplementedFunc),
|
||||
/* 254 */ SyscallDesc("fadvise64", unimplementedFunc),
|
||||
/* 255 */ SyscallDesc("statfs64", unimplementedFunc),
|
||||
/* 256 */ SyscallDesc("fstafs64", unimplementedFunc),
|
||||
/* 257 */ SyscallDesc("timer_create", sys_getsysinfoFunc),
|
||||
/* 258 */ SyscallDesc("timer_settime", sys_setsysinfoFunc),
|
||||
/* 259 */ SyscallDesc("timer_gettime", unimplementedFunc),
|
||||
/* 260 */ SyscallDesc("timer_getoverrun", unimplementedFunc),
|
||||
/* 261 */ SyscallDesc("timer_delete", unimplementedFunc),
|
||||
/* 262 */ SyscallDesc("clock_settime", unimplementedFunc),
|
||||
/* 263 */ SyscallDesc("clock_gettime", unimplementedFunc),
|
||||
/* 264 */ SyscallDesc("clock_getres", unimplementedFunc),
|
||||
/* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
|
||||
/* 266 */ SyscallDesc("tgkill", unimplementedFunc),
|
||||
/* 267 */ SyscallDesc("utimes", unimplementedFunc),
|
||||
/* 268 */ SyscallDesc("mbind", unimplementedFunc),
|
||||
/* 269 */ SyscallDesc("get_mempolicy", unimplementedFunc),
|
||||
/* 270 */ SyscallDesc("set_mempolicy", unimplementedFunc),
|
||||
/* 271 */ SyscallDesc("mq_open", unimplementedFunc),
|
||||
/* 272 */ SyscallDesc("mq_unlink", unimplementedFunc),
|
||||
/* 273 */ SyscallDesc("mq_timedsend", unimplementedFunc),
|
||||
/* 274 */ SyscallDesc("mq_timedreceive", unimplementedFunc),
|
||||
/* 275 */ SyscallDesc("mq_notify", unimplementedFunc),
|
||||
/* 276 */ SyscallDesc("mq_getsetattr", unimplementedFunc),
|
||||
/* 277 */ SyscallDesc("vserver", unimplementedFunc),
|
||||
/* 278 */ SyscallDesc("waitid", unimplementedFunc),
|
||||
/* 279 */ SyscallDesc("unknown #279", unimplementedFunc),
|
||||
/* 280 */ SyscallDesc("add_key", unimplementedFunc),
|
||||
/* 281 */ SyscallDesc("request_key", unimplementedFunc),
|
||||
/* 282 */ SyscallDesc("keyctl", unimplementedFunc),
|
||||
/* 283 */ SyscallDesc("set_thread_area", setThreadAreaFunc),
|
||||
/* 284 */ SyscallDesc("inotify_init", unimplementedFunc),
|
||||
/* 285 */ SyscallDesc("inotify_add_watch", unimplementedFunc),
|
||||
/* 286 */ SyscallDesc("inotify_rm_watch", unimplementedFunc),
|
||||
/* 287 */ SyscallDesc("migrate_pages", unimplementedFunc),
|
||||
/* 288 */ SyscallDesc("openat", unimplementedFunc),
|
||||
/* 289 */ SyscallDesc("mkdirat", unimplementedFunc),
|
||||
/* 290 */ SyscallDesc("mknodat", unimplementedFunc),
|
||||
/* 291 */ SyscallDesc("fchownat", unimplementedFunc),
|
||||
/* 292 */ SyscallDesc("futimesat", unimplementedFunc),
|
||||
/* 293 */ SyscallDesc("fstatat64", unimplementedFunc),
|
||||
/* 294 */ SyscallDesc("unlinkat", unimplementedFunc),
|
||||
/* 295 */ SyscallDesc("renameat", unimplementedFunc),
|
||||
/* 296 */ SyscallDesc("linkat", unimplementedFunc),
|
||||
/* 297 */ SyscallDesc("symlinkat", unimplementedFunc),
|
||||
/* 298 */ SyscallDesc("readlinkat", unimplementedFunc),
|
||||
/* 299 */ SyscallDesc("fchmodat", unimplementedFunc),
|
||||
/* 300 */ SyscallDesc("faccessat", unimplementedFunc),
|
||||
/* 301 */ SyscallDesc("pselect6", unimplementedFunc),
|
||||
/* 302 */ SyscallDesc("ppoll", unimplementedFunc),
|
||||
/* 303 */ SyscallDesc("unshare", unimplementedFunc),
|
||||
/* 304 */ SyscallDesc("splice", unimplementedFunc),
|
||||
/* 305 */ SyscallDesc("sync_file_range", unimplementedFunc),
|
||||
/* 306 */ SyscallDesc("tee", unimplementedFunc),
|
||||
/* 307 */ SyscallDesc("vmsplice", unimplementedFunc),
|
||||
/* 308 */ SyscallDesc("move_pages", unimplementedFunc),
|
||||
/* 309 */ SyscallDesc("set_robust_list", unimplementedFunc),
|
||||
/* 310 */ SyscallDesc("get_robust_list", unimplementedFunc),
|
||||
/* 311 */ SyscallDesc("kexec_load", unimplementedFunc),
|
||||
/* 312 */ SyscallDesc("getcpu", unimplementedFunc),
|
||||
/* 313 */ SyscallDesc("epoll_pwait", unimplementedFunc),
|
||||
/* 314 */ SyscallDesc("ioprio_set", unimplementedFunc),
|
||||
/* 315 */ SyscallDesc("ioprio_get", unimplementedFunc),
|
||||
/* 316 */ SyscallDesc("utimensat", unimplementedFunc),
|
||||
/* 317 */ SyscallDesc("signalfd", unimplementedFunc),
|
||||
/* 318 */ SyscallDesc("timerfd", unimplementedFunc),
|
||||
/* 319 */ SyscallDesc("eventfd", unimplementedFunc)
|
||||
};
|
||||
|
||||
MipsLinuxProcess::MipsLinuxProcess(LiveProcessParams * params,
|
||||
ObjectFile *objFile)
|
||||
: MipsLiveProcess(params, objFile),
|
||||
Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
|
||||
{ }
|
||||
|
||||
SyscallDesc*
|
||||
MipsLinuxProcess::getDesc(int callnum)
|
||||
{
|
||||
//MIPS32 syscalls are in the range of 4000 - 4999
|
||||
int m5_sys_idx = callnum - 4000;
|
||||
|
||||
if (m5_sys_idx < 0 || m5_sys_idx >= Num_Syscall_Descs)
|
||||
return NULL;
|
||||
|
||||
return &syscallDescs[m5_sys_idx];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
59
simulators/gem5/src/arch/mips/linux/process.hh
Normal file
59
simulators/gem5/src/arch/mips/linux/process.hh
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2004 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __MIPS_LINUX_PROCESS_HH__
|
||||
#define __MIPS_LINUX_PROCESS_HH__
|
||||
|
||||
#include "arch/mips/linux/linux.hh"
|
||||
#include "arch/mips/process.hh"
|
||||
#include "sim/eventq.hh"
|
||||
|
||||
/// A process with emulated Mips/Linux syscalls.
|
||||
class MipsLinuxProcess : public MipsLiveProcess
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
MipsLinuxProcess(LiveProcessParams * params, ObjectFile *objFile);
|
||||
|
||||
virtual SyscallDesc* getDesc(int callnum);
|
||||
|
||||
/// The target system's hostname.
|
||||
static const char *hostname;
|
||||
|
||||
/// ID of the thread group leader for the process
|
||||
uint64_t __tgid;
|
||||
|
||||
/// Array of syscall descriptors, indexed by call number.
|
||||
static SyscallDesc syscallDescs[];
|
||||
const int Num_Syscall_Descs;
|
||||
};
|
||||
|
||||
#endif // __MIPS_LINUX_PROCESS_HH__
|
||||
101
simulators/gem5/src/arch/mips/linux/system.cc
Normal file
101
simulators/gem5/src/arch/mips/linux/system.cc
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Lisa Hsu
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This code loads the linux kernel, console, pal and patches certain
|
||||
* functions. The symbol tables are loaded so that traces can show
|
||||
* the executing function and we can skip functions. Various delay
|
||||
* loops are skipped and their final values manually computed to speed
|
||||
* up boot time.
|
||||
*/
|
||||
|
||||
#include "arch/mips/linux/system.hh"
|
||||
#include "arch/mips/linux/threadinfo.hh"
|
||||
#include "arch/mips/idle_event.hh"
|
||||
#include "arch/mips/system.hh"
|
||||
#include "arch/vtophys.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Thread.hh"
|
||||
#include "dev/platform.hh"
|
||||
#include "kern/linux/events.hh"
|
||||
#include "kern/linux/printk.hh"
|
||||
#include "mem/physical.hh"
|
||||
#include "mem/port.hh"
|
||||
#include "sim/arguments.hh"
|
||||
#include "sim/byteswap.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
using namespace Linux;
|
||||
|
||||
LinuxMipsSystem::LinuxMipsSystem(Params *p)
|
||||
: MipsSystem(p)
|
||||
{
|
||||
}
|
||||
|
||||
LinuxMipsSystem::~LinuxMipsSystem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LinuxMipsSystem::setDelayLoop(ThreadContext *tc)
|
||||
{
|
||||
panic("setDelayLoop not implemented.\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LinuxMipsSystem::SkipDelayLoopEvent::process(ThreadContext *tc)
|
||||
{
|
||||
SkipFuncEvent::process(tc);
|
||||
// calculate and set loops_per_jiffy
|
||||
((LinuxMipsSystem *)tc->getSystemPtr())->setDelayLoop(tc);
|
||||
}
|
||||
|
||||
void
|
||||
LinuxMipsSystem::PrintThreadInfo::process(ThreadContext *tc)
|
||||
{
|
||||
Linux::ThreadInfo ti(tc);
|
||||
|
||||
DPRINTF(Thread, "Currently Executing Thread %s, pid %d, started at: %d\n",
|
||||
ti.curTaskName(), ti.curTaskPID(), ti.curTaskStart());
|
||||
}
|
||||
|
||||
LinuxMipsSystem *
|
||||
LinuxMipsSystemParams::create()
|
||||
{
|
||||
return new LinuxMipsSystem(this);
|
||||
}
|
||||
137
simulators/gem5/src/arch/mips/linux/system.hh
Normal file
137
simulators/gem5/src/arch/mips/linux/system.hh
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Lisa Hsu
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_SYSTEM_HH__
|
||||
#define __ARCH_MIPS_LINUX_SYSTEM_HH__
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
class BreakPCEvent;
|
||||
class IdleStartEvent;
|
||||
|
||||
#include "arch/mips/idle_event.hh"
|
||||
#include "arch/mips/system.hh"
|
||||
#include "kern/linux/events.hh"
|
||||
#include "params/LinuxMipsSystem.hh"
|
||||
|
||||
/**
|
||||
* This class contains linux specific system code (Loading, Events).
|
||||
* It points to objects that are the system binaries to load and patches them
|
||||
* appropriately to work in simulator.
|
||||
*/
|
||||
class LinuxMipsSystem : public MipsSystem
|
||||
{
|
||||
private:
|
||||
class SkipDelayLoopEvent : public SkipFuncEvent
|
||||
{
|
||||
public:
|
||||
SkipDelayLoopEvent(PCEventQueue *q, const std::string &desc, Addr addr)
|
||||
: SkipFuncEvent(q, desc, addr) {}
|
||||
virtual void process(ThreadContext *tc);
|
||||
};
|
||||
|
||||
class PrintThreadInfo : public PCEvent
|
||||
{
|
||||
public:
|
||||
PrintThreadInfo(PCEventQueue *q, const std::string &desc, Addr addr)
|
||||
: PCEvent(q, desc, addr) {}
|
||||
virtual void process(ThreadContext *tc);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Addresses defining where the kernel bootloader places various
|
||||
* elements. Details found in include/asm-mips/system.h
|
||||
*/
|
||||
Addr KernelStart; // Lookup the symbol swapper_pg_dir
|
||||
|
||||
public:
|
||||
Addr InitStack() const { return KernelStart + 0x02000; }
|
||||
Addr EmptyPGT() const { return KernelStart + 0x04000; }
|
||||
Addr EmptyPGE() const { return KernelStart + 0x08000; }
|
||||
Addr ZeroPGE() const { return KernelStart + 0x0A000; }
|
||||
Addr StartAddr() const { return KernelStart + 0x10000; }
|
||||
|
||||
Addr Param() const { return ZeroPGE() + 0x0; }
|
||||
Addr CommandLine() const { return Param() + 0x0; }
|
||||
Addr InitrdStart() const { return Param() + 0x100; }
|
||||
Addr InitrdSize() const { return Param() + 0x108; }
|
||||
static const int CommandLineSize = 256;
|
||||
|
||||
private:
|
||||
#ifndef NDEBUG
|
||||
/** Event to halt the simulator if the kernel calls panic() */
|
||||
BreakPCEvent *kernelPanicEvent;
|
||||
|
||||
/** Event to halt the simulator if the kernel calls die_if_kernel */
|
||||
BreakPCEvent *kernelDieEvent;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Event to skip determine_cpu_caches() because we don't support
|
||||
* the IPRs that the code can access to figure out cache sizes
|
||||
*/
|
||||
SkipFuncEvent *skipCacheProbeEvent;
|
||||
|
||||
/** PC based event to skip the ide_delay_50ms() call */
|
||||
SkipFuncEvent *skipIdeDelay50msEvent;
|
||||
|
||||
/**
|
||||
* PC based event to skip the dprink() call and emulate its
|
||||
* functionality
|
||||
*/
|
||||
Linux::DebugPrintkEvent *debugPrintkEvent;
|
||||
|
||||
/**
|
||||
* Skip calculate_delay_loop() rather than waiting for this to be
|
||||
* calculated
|
||||
*/
|
||||
SkipDelayLoopEvent *skipDelayLoopEvent;
|
||||
|
||||
/**
|
||||
* Event to print information about thread switches if the trace flag
|
||||
* Thread is set
|
||||
*/
|
||||
PrintThreadInfo *printThreadEvent;
|
||||
|
||||
/** Grab the PCBB of the idle process when it starts */
|
||||
IdleStartEvent *idleStartEvent;
|
||||
|
||||
public:
|
||||
typedef LinuxMipsSystemParams Params;
|
||||
LinuxMipsSystem(Params *p);
|
||||
~LinuxMipsSystem();
|
||||
|
||||
void setDelayLoop(ThreadContext *tc);
|
||||
};
|
||||
|
||||
#endif // __ARCH_MIPS_LINUX_SYSTEM_HH__
|
||||
44
simulators/gem5/src/arch/mips/linux/thread_info.hh
Normal file
44
simulators/gem5/src/arch/mips/linux/thread_info.hh
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2004 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_THREAD_INFO_H__
|
||||
#define __ARCH_MIPS_LINUX_THREAD_INFO_H__
|
||||
|
||||
#include "arch/mips/linux/hwrpb.hh"
|
||||
|
||||
namespace Linux {
|
||||
struct thread_info {
|
||||
struct pcb_struct pcb;
|
||||
Addr_a task;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __ARCH_MIPS_LINUX_THREAD_INFO_H__
|
||||
153
simulators/gem5/src/arch/mips/linux/threadinfo.hh
Normal file
153
simulators/gem5/src/arch/mips/linux/threadinfo.hh
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2004 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LINUX_LINUX_TREADNIFO_HH__
|
||||
#define __ARCH_MIPS_LINUX_LINUX_TREADNIFO_HH__
|
||||
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "sim/system.hh"
|
||||
#include "sim/vptr.hh"
|
||||
|
||||
namespace Linux {
|
||||
|
||||
class ThreadInfo
|
||||
{
|
||||
private:
|
||||
ThreadContext *tc;
|
||||
System *sys;
|
||||
Addr pcbb;
|
||||
|
||||
template <typename T>
|
||||
bool
|
||||
get_data(const char *symbol, T &data)
|
||||
{
|
||||
Addr addr = 0;
|
||||
if (!sys->kernelSymtab->findAddress(symbol, addr))
|
||||
return false;
|
||||
|
||||
CopyOut(tc, &data, addr, sizeof(T));
|
||||
|
||||
data = MipsISA::gtoh(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
ThreadInfo(ThreadContext *_tc, Addr _pcbb = 0)
|
||||
: tc(_tc), sys(tc->getSystemPtr()), pcbb(_pcbb)
|
||||
{
|
||||
|
||||
}
|
||||
~ThreadInfo()
|
||||
{}
|
||||
|
||||
inline Addr
|
||||
curThreadInfo()
|
||||
{
|
||||
panic("curThreadInfo not implemented for MIPS");
|
||||
Addr addr = pcbb;
|
||||
Addr sp;
|
||||
|
||||
if (!addr)
|
||||
addr = tc->readMiscRegNoEffect(0/*MipsISA::IPR_PALtemp23*/);
|
||||
|
||||
PortProxy &p = tc->getPhysProxy();
|
||||
p.readBlob(addr, (uint8_t *)&sp, sizeof(Addr));
|
||||
|
||||
return sp & ~ULL(0x3fff);
|
||||
}
|
||||
|
||||
inline Addr
|
||||
curTaskInfo(Addr thread_info = 0)
|
||||
{
|
||||
int32_t offset;
|
||||
if (!get_data("thread_info_task", offset))
|
||||
return 0;
|
||||
|
||||
if (!thread_info)
|
||||
thread_info = curThreadInfo();
|
||||
|
||||
Addr addr;
|
||||
CopyOut(tc, &addr, thread_info + offset, sizeof(addr));
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
int32_t
|
||||
curTaskPID(Addr thread_info = 0)
|
||||
{
|
||||
Addr offset;
|
||||
if (!get_data("task_struct_pid", offset))
|
||||
return -1;
|
||||
|
||||
int32_t pid;
|
||||
CopyOut(tc, &pid, curTaskInfo(thread_info) + offset, sizeof(pid));
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
int64_t
|
||||
curTaskStart(Addr thread_info = 0)
|
||||
{
|
||||
Addr offset;
|
||||
if (!get_data("task_struct_start_time", offset))
|
||||
return -1;
|
||||
|
||||
int64_t data;
|
||||
// start_time is actually of type timespec, but if we just
|
||||
// grab the first long, we'll get the seconds out of it
|
||||
CopyOut(tc, &data, curTaskInfo(thread_info) + offset, sizeof(data));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
std::string
|
||||
curTaskName(Addr thread_info = 0)
|
||||
{
|
||||
int32_t offset;
|
||||
int32_t size;
|
||||
|
||||
if (!get_data("task_struct_comm", offset))
|
||||
return "FailureIn_curTaskName";
|
||||
|
||||
if (!get_data("task_struct_comm_size", size))
|
||||
return "FailureIn_curTaskName";
|
||||
|
||||
char buffer[size + 1];
|
||||
CopyStringOut(tc, buffer, curTaskInfo(thread_info) + offset, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Linux
|
||||
|
||||
#endif // __ARCH_MIPS_LINUX_LINUX_THREADINFO_HH__
|
||||
111
simulators/gem5/src/arch/mips/locked_mem.hh
Normal file
111
simulators/gem5/src/arch/mips/locked_mem.hh
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Steve Reinhardt
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_LOCKED_MEM_HH__
|
||||
#define __ARCH_MIPS_LOCKED_MEM_HH__
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* ISA-specific helper functions for locked memory accesses.
|
||||
*/
|
||||
|
||||
#include "arch/registers.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "debug/LLSC.hh"
|
||||
#include "mem/request.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
template <class XC>
|
||||
inline void
|
||||
handleLockedRead(XC *xc, Request *req)
|
||||
{
|
||||
xc->setMiscReg(MISCREG_LLADDR, req->getPaddr() & ~0xf);
|
||||
xc->setMiscReg(MISCREG_LLFLAG, true);
|
||||
DPRINTF(LLSC, "[tid:%i]: Load-Link Flag Set & Load-Link"
|
||||
" Address set to %x.\n",
|
||||
req->threadId(), req->getPaddr() & ~0xf);
|
||||
}
|
||||
|
||||
template <class XC>
|
||||
inline bool
|
||||
handleLockedWrite(XC *xc, Request *req)
|
||||
{
|
||||
if (req->isUncacheable()) {
|
||||
// Funky Turbolaser mailbox access...don't update
|
||||
// result register (see stq_c in decoder.isa)
|
||||
req->setExtraData(2);
|
||||
} else {
|
||||
// standard store conditional
|
||||
bool lock_flag = xc->readMiscReg(MISCREG_LLFLAG);
|
||||
Addr lock_addr = xc->readMiscReg(MISCREG_LLADDR);
|
||||
|
||||
if (!lock_flag || (req->getPaddr() & ~0xf) != lock_addr) {
|
||||
// Lock flag not set or addr mismatch in CPU;
|
||||
// don't even bother sending to memory system
|
||||
req->setExtraData(0);
|
||||
xc->setMiscReg(MISCREG_LLFLAG, false);
|
||||
|
||||
// the rest of this code is not architectural;
|
||||
// it's just a debugging aid to help detect
|
||||
// livelock by warning on long sequences of failed
|
||||
// store conditionals
|
||||
int stCondFailures = xc->readStCondFailures();
|
||||
stCondFailures++;
|
||||
xc->setStCondFailures(stCondFailures);
|
||||
if (stCondFailures % 100000 == 0) {
|
||||
warn("%i: context %d: %d consecutive "
|
||||
"store conditional failures\n",
|
||||
curTick(), xc->contextId(), stCondFailures);
|
||||
}
|
||||
|
||||
if (!lock_flag){
|
||||
DPRINTF(LLSC, "[tid:%i]: Lock Flag Set, "
|
||||
"Store Conditional Failed.\n",
|
||||
req->threadId());
|
||||
} else if ((req->getPaddr() & ~0xf) != lock_addr) {
|
||||
DPRINTF(LLSC, "[tid:%i]: Load-Link Address Mismatch, "
|
||||
"Store Conditional Failed.\n",
|
||||
req->threadId());
|
||||
}
|
||||
// store conditional failed already, so don't issue it to mem
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
41
simulators/gem5/src/arch/mips/microcode_rom.hh
Normal file
41
simulators/gem5/src/arch/mips/microcode_rom.hh
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2008 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_MICROCODE_ROM_HH__
|
||||
#define __ARCH_MIPS_MICROCODE_ROM_HH__
|
||||
|
||||
#include "sim/microcode_rom.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
using ::MicrocodeRom;
|
||||
}
|
||||
|
||||
#endif // __ARCH_MIPS_MICROCODE_ROM_HH__
|
||||
62
simulators/gem5/src/arch/mips/mmapped_ipr.hh
Normal file
62
simulators/gem5/src/arch/mips/mmapped_ipr.hh
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_MMAPPED_IPR_HH__
|
||||
#define __ARCH_MIPS_MMAPPED_IPR_HH__
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* ISA-specific helper functions for memory mapped IPR accesses.
|
||||
*/
|
||||
|
||||
#include "base/misc.hh"
|
||||
#include "mem/packet.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
inline Tick
|
||||
handleIprRead(ThreadContext *xc, Packet *pkt)
|
||||
{
|
||||
panic("No implementation for handleIprRead in MIPS\n");
|
||||
}
|
||||
|
||||
inline Tick
|
||||
handleIprWrite(ThreadContext *xc, Packet *pkt)
|
||||
{
|
||||
panic("No implementation for handleIprWrite in MIPS\n");
|
||||
}
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
276
simulators/gem5/src/arch/mips/mt.hh
Executable file
276
simulators/gem5/src/arch/mips/mt.hh
Executable file
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_MT_HH__
|
||||
#define __ARCH_MIPS_MT_HH__
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* ISA-specific helper functions for multithreaded execution.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/mt_constants.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "arch/mips/registers.hh"
|
||||
#include "base/bitfield.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/trace.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
template <class TC>
|
||||
inline unsigned
|
||||
getVirtProcNum(TC *tc)
|
||||
{
|
||||
TCBindReg tcbind = tc->readMiscRegNoEffect(MISCREG_TC_BIND);
|
||||
return tcbind.curVPE;
|
||||
}
|
||||
|
||||
template <class TC>
|
||||
inline unsigned
|
||||
getTargetThread(TC *tc)
|
||||
{
|
||||
VPEControlReg vpeCtrl = tc->readMiscRegNoEffect(MISCREG_VPE_CONTROL);
|
||||
return vpeCtrl.targTC;
|
||||
}
|
||||
|
||||
template <class TC>
|
||||
inline void
|
||||
haltThread(TC *tc)
|
||||
{
|
||||
if (tc->status() == TC::Active) {
|
||||
tc->halt();
|
||||
|
||||
// Save last known PC in TCRestart
|
||||
// @TODO: Needs to check if this is a branch and if so,
|
||||
// take previous instruction
|
||||
PCState pc = tc->pcState();
|
||||
tc->setMiscReg(MISCREG_TC_RESTART, pc.npc());
|
||||
|
||||
warn("%i: Halting thread %i in %s @ PC %x, setting restart PC to %x",
|
||||
curTick(), tc->threadId(), tc->getCpuPtr()->name(),
|
||||
pc.pc(), pc.npc());
|
||||
}
|
||||
}
|
||||
|
||||
template <class TC>
|
||||
inline void
|
||||
restoreThread(TC *tc)
|
||||
{
|
||||
if (tc->status() != TC::Active) {
|
||||
// Restore PC from TCRestart
|
||||
Addr restartPC = tc->readMiscRegNoEffect(MISCREG_TC_RESTART);
|
||||
|
||||
// TODO: SET PC WITH AN EVENT INSTEAD OF INSTANTANEOUSLY
|
||||
tc->pcState(restartPC);
|
||||
tc->activate(0);
|
||||
|
||||
warn("%i: Restoring thread %i in %s @ PC %x",
|
||||
curTick(), tc->threadId(), tc->getCpuPtr()->name(), restartPC);
|
||||
}
|
||||
}
|
||||
|
||||
template <class TC>
|
||||
void
|
||||
forkThread(TC *tc, Fault &fault, int Rd_bits, int Rs, int Rt)
|
||||
{
|
||||
MVPConf0Reg mvpConf = tc->readMiscRegNoEffect(MISCREG_MVP_CONF0);
|
||||
int num_threads = mvpConf.ptc + 1;
|
||||
|
||||
int success = 0;
|
||||
for (ThreadID tid = 0; tid < num_threads && success == 0; tid++) {
|
||||
TCBindReg tidTCBind =
|
||||
tc->readRegOtherThread(MISCREG_TC_BIND + Ctrl_Base_DepTag, tid);
|
||||
TCBindReg tcBind = tc->readMiscRegNoEffect(MISCREG_TC_BIND);
|
||||
|
||||
if (tidTCBind.curVPE == tcBind.curVPE) {
|
||||
|
||||
TCStatusReg tidTCStatus =
|
||||
tc->readRegOtherThread(MISCREG_TC_STATUS +
|
||||
Ctrl_Base_DepTag,tid);
|
||||
|
||||
TCHaltReg tidTCHalt =
|
||||
tc->readRegOtherThread(MISCREG_TC_HALT + Ctrl_Base_DepTag,tid);
|
||||
|
||||
if (tidTCStatus.da == 1 && tidTCHalt.h == 0 &&
|
||||
tidTCStatus.a == 0 && success == 0) {
|
||||
|
||||
tc->setRegOtherThread(MISCREG_TC_RESTART +
|
||||
Ctrl_Base_DepTag, Rs, tid);
|
||||
tc->setRegOtherThread(Rd_bits, Rt, tid);
|
||||
|
||||
StatusReg status = tc->readMiscReg(MISCREG_STATUS);
|
||||
TCStatusReg tcStatus = tc->readMiscReg(MISCREG_TC_STATUS);
|
||||
|
||||
// Set Run-State to Running
|
||||
tidTCStatus.rnst = 0;
|
||||
// Set Delay-Slot to 0
|
||||
tidTCStatus.tds = 0;
|
||||
// Set Dirty TC to 1
|
||||
tidTCStatus.dt = 1;
|
||||
// Set Activated to 1
|
||||
tidTCStatus.a = 1;
|
||||
// Set status to previous thread's status
|
||||
tidTCStatus.tksu = status.ksu;
|
||||
// Set ASID to previous thread's state
|
||||
tidTCStatus.asid = tcStatus.asid;
|
||||
|
||||
// Write Status Register
|
||||
tc->setRegOtherThread(MISCREG_TC_STATUS + Ctrl_Base_DepTag,
|
||||
tidTCStatus, tid);
|
||||
|
||||
// Mark As Successful Fork
|
||||
success = 1;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Bad VPEs" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (success == 0) {
|
||||
VPEControlReg vpeControl =
|
||||
tc->readMiscRegNoEffect(MISCREG_VPE_CONTROL);
|
||||
vpeControl.excpt = 1;
|
||||
tc->setMiscReg(MISCREG_VPE_CONTROL, vpeControl);
|
||||
fault = new ThreadFault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class TC>
|
||||
int
|
||||
yieldThread(TC *tc, Fault &fault, int src_reg, uint32_t yield_mask)
|
||||
{
|
||||
if (src_reg == 0) {
|
||||
MVPConf0Reg mvpConf0 = tc->readMiscRegNoEffect(MISCREG_MVP_CONF0);
|
||||
ThreadID num_threads = mvpConf0.ptc + 1;
|
||||
|
||||
int ok = 0;
|
||||
|
||||
// Get Current VPE & TC numbers from calling thread
|
||||
TCBindReg tcBind = tc->readMiscRegNoEffect(MISCREG_TC_BIND);
|
||||
|
||||
for (ThreadID tid = 0; tid < num_threads; tid++) {
|
||||
TCStatusReg tidTCStatus =
|
||||
tc->readRegOtherThread(MISCREG_TC_STATUS + Ctrl_Base_DepTag,
|
||||
tid);
|
||||
TCHaltReg tidTCHalt =
|
||||
tc->readRegOtherThread(MISCREG_TC_HALT + Ctrl_Base_DepTag,
|
||||
tid);
|
||||
TCBindReg tidTCBind =
|
||||
tc->readRegOtherThread(MISCREG_TC_BIND + Ctrl_Base_DepTag,
|
||||
tid);
|
||||
|
||||
if (tidTCBind.curVPE == tcBind.curVPE &&
|
||||
tidTCBind.curTC == tcBind.curTC &&
|
||||
tidTCStatus.da == 1 &&
|
||||
tidTCHalt.h == 0 &&
|
||||
tidTCStatus.a == 1) {
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok == 1) {
|
||||
TCStatusReg tcStatus = tc->readMiscRegNoEffect(MISCREG_TC_STATUS);
|
||||
tcStatus.a = 0;
|
||||
tc->setMiscReg(MISCREG_TC_STATUS, tcStatus);
|
||||
warn("%i: Deactivating Hardware Thread Context #%i",
|
||||
curTick(), tc->threadId());
|
||||
}
|
||||
} else if (src_reg > 0) {
|
||||
if (src_reg && !yield_mask != 0) {
|
||||
VPEControlReg vpeControl = tc->readMiscReg(MISCREG_VPE_CONTROL);
|
||||
vpeControl.excpt = 2;
|
||||
tc->setMiscReg(MISCREG_VPE_CONTROL, vpeControl);
|
||||
fault = new ThreadFault();
|
||||
} else {
|
||||
}
|
||||
} else if (src_reg != -2) {
|
||||
TCStatusReg tcStatus = tc->readMiscRegNoEffect(MISCREG_TC_STATUS);
|
||||
VPEControlReg vpeControl =
|
||||
tc->readMiscRegNoEffect(MISCREG_VPE_CONTROL);
|
||||
|
||||
if (vpeControl.ysi == 1 && tcStatus.dt == 1 ) {
|
||||
vpeControl.excpt = 4;
|
||||
fault = new ThreadFault();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
return src_reg & yield_mask;
|
||||
}
|
||||
|
||||
|
||||
// TC will usually be a object derived from ThreadContext
|
||||
// (src/cpu/thread_context.hh)
|
||||
template <class TC>
|
||||
inline void
|
||||
updateStatusView(TC *tc)
|
||||
{
|
||||
// TCStatus' register view must be the same as
|
||||
// Status register view for CU, MX, KSU bits
|
||||
TCStatusReg tcStatus = tc->readMiscRegNoEffect(MISCREG_TC_STATUS);
|
||||
StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS);
|
||||
|
||||
status.cu = tcStatus.tcu;
|
||||
status.mx = tcStatus.tmx;
|
||||
status.ksu = tcStatus.tksu;
|
||||
|
||||
tc->setMiscRegNoEffect(MISCREG_STATUS, status);
|
||||
}
|
||||
|
||||
// TC will usually be a object derived from ThreadContext
|
||||
// (src/cpu/thread_context.hh)
|
||||
template <class TC>
|
||||
inline void
|
||||
updateTCStatusView(TC *tc)
|
||||
{
|
||||
// TCStatus' register view must be the same as
|
||||
// Status register view for CU, MX, KSU bits
|
||||
TCStatusReg tcStatus = tc->readMiscRegNoEffect(MISCREG_TC_STATUS);
|
||||
StatusReg status = tc->readMiscRegNoEffect(MISCREG_STATUS);
|
||||
|
||||
tcStatus.tcu = status.cu;
|
||||
tcStatus.tmx = status.mx;
|
||||
tcStatus.tksu = status.ksu;
|
||||
|
||||
tc->setMiscRegNoEffect(MISCREG_TC_STATUS, tcStatus);
|
||||
}
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
|
||||
#endif
|
||||
104
simulators/gem5/src/arch/mips/mt_constants.hh
Executable file
104
simulators/gem5/src/arch/mips/mt_constants.hh
Executable file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_MT_CONSTANTS_HH__
|
||||
#define __ARCH_MIPS_MT_CONSTANTS_HH__
|
||||
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/bitunion.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
BitUnion32(MVPControlReg)
|
||||
Bitfield<3> cpa;
|
||||
Bitfield<2> stlb;
|
||||
Bitfield<1> vpc;
|
||||
Bitfield<0> evp;
|
||||
EndBitUnion(MVPControlReg)
|
||||
|
||||
BitUnion32(MVPConf0Reg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<29> tlbs;
|
||||
Bitfield<28> gs;
|
||||
Bitfield<27> pcp;
|
||||
Bitfield<25, 16> ptlbe;
|
||||
Bitfield<15> tca;
|
||||
Bitfield<13, 10> pvpe;
|
||||
Bitfield<7, 0> ptc;
|
||||
EndBitUnion(MVPConf0Reg)
|
||||
|
||||
BitUnion32(VPEControlReg)
|
||||
Bitfield<21> ysi;
|
||||
Bitfield<18, 16> excpt;
|
||||
Bitfield<15> te;
|
||||
Bitfield<7, 0> targTC;
|
||||
EndBitUnion(VPEControlReg)
|
||||
|
||||
BitUnion32(VPEConf0Reg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<28, 21> xtc;
|
||||
Bitfield<19> tcs;
|
||||
Bitfield<18> scs;
|
||||
Bitfield<17> dcs;
|
||||
Bitfield<16> ics;
|
||||
Bitfield<1> mvp;
|
||||
Bitfield<0> vpa;
|
||||
EndBitUnion(VPEConf0Reg)
|
||||
|
||||
BitUnion32(TCBindReg)
|
||||
Bitfield<28, 21> curTC;
|
||||
Bitfield<20, 18> a0;
|
||||
Bitfield<17> tbe;
|
||||
Bitfield<3, 0> curVPE;
|
||||
EndBitUnion(TCBindReg)
|
||||
|
||||
BitUnion32(TCStatusReg)
|
||||
Bitfield<31, 28> tcu;
|
||||
Bitfield<27> tmx;
|
||||
Bitfield<24, 23> rnst;
|
||||
Bitfield<21> tds;
|
||||
Bitfield<20> dt;
|
||||
Bitfield<19, 16> impl;
|
||||
Bitfield<15> da;
|
||||
Bitfield<13> a;
|
||||
Bitfield<12, 11> tksu;
|
||||
Bitfield<10> ixmt;
|
||||
Bitfield<7, 0> asid;
|
||||
EndBitUnion(TCStatusReg)
|
||||
|
||||
BitUnion32(TCHaltReg)
|
||||
Bitfield<0> h;
|
||||
EndBitUnion(TCHaltReg)
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
78
simulators/gem5/src/arch/mips/pagetable.cc
Normal file
78
simulators/gem5/src/arch/mips/pagetable.cc
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Steve Reinhardt
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#include "arch/mips/pagetable.hh"
|
||||
#include "sim/serialize.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
void
|
||||
PTE::serialize(std::ostream &os)
|
||||
{
|
||||
SERIALIZE_SCALAR(Mask);
|
||||
SERIALIZE_SCALAR(VPN);
|
||||
SERIALIZE_SCALAR(asid);
|
||||
SERIALIZE_SCALAR(G);
|
||||
SERIALIZE_SCALAR(PFN0);
|
||||
SERIALIZE_SCALAR(D0);
|
||||
SERIALIZE_SCALAR(V0);
|
||||
SERIALIZE_SCALAR(C0);
|
||||
SERIALIZE_SCALAR(PFN1);
|
||||
SERIALIZE_SCALAR(D1);
|
||||
SERIALIZE_SCALAR(V1);
|
||||
SERIALIZE_SCALAR(C1);
|
||||
SERIALIZE_SCALAR(AddrShiftAmount);
|
||||
SERIALIZE_SCALAR(OffsetMask);
|
||||
}
|
||||
|
||||
void
|
||||
PTE::unserialize(Checkpoint *cp, const std::string §ion)
|
||||
{
|
||||
UNSERIALIZE_SCALAR(Mask);
|
||||
UNSERIALIZE_SCALAR(VPN);
|
||||
UNSERIALIZE_SCALAR(asid);
|
||||
UNSERIALIZE_SCALAR(G);
|
||||
UNSERIALIZE_SCALAR(PFN0);
|
||||
UNSERIALIZE_SCALAR(D0);
|
||||
UNSERIALIZE_SCALAR(V0);
|
||||
UNSERIALIZE_SCALAR(C0);
|
||||
UNSERIALIZE_SCALAR(PFN1);
|
||||
UNSERIALIZE_SCALAR(D1);
|
||||
UNSERIALIZE_SCALAR(V1);
|
||||
UNSERIALIZE_SCALAR(C1);
|
||||
UNSERIALIZE_SCALAR(AddrShiftAmount);
|
||||
UNSERIALIZE_SCALAR(OffsetMask);
|
||||
}
|
||||
|
||||
}
|
||||
110
simulators/gem5/src/arch/mips/pagetable.hh
Executable file
110
simulators/gem5/src/arch/mips/pagetable.hh
Executable file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Steve Reinhardt
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_PAGETABLE_H__
|
||||
#define __ARCH_MIPS_PAGETABLE_H__
|
||||
|
||||
#include "base/misc.hh"
|
||||
#include "base/types.hh"
|
||||
#include "sim/serialize.hh"
|
||||
|
||||
namespace MipsISA {
|
||||
|
||||
struct VAddr
|
||||
{
|
||||
};
|
||||
|
||||
// ITB/DTB page table entry
|
||||
struct PTE
|
||||
{
|
||||
Addr Mask;
|
||||
Addr VPN;
|
||||
uint8_t asid;
|
||||
|
||||
bool G;
|
||||
|
||||
/* Contents of Entry Lo0 */
|
||||
Addr PFN0; // Physical Frame Number - Even
|
||||
bool D0; // Even entry Dirty Bit
|
||||
bool V0; // Even entry Valid Bit
|
||||
uint8_t C0; // Cache Coherency Bits - Even
|
||||
|
||||
/* Contents of Entry Lo1 */
|
||||
Addr PFN1; // Physical Frame Number - Odd
|
||||
bool D1; // Odd entry Dirty Bit
|
||||
bool V1; // Odd entry Valid Bit
|
||||
uint8_t C1; // Cache Coherency Bits (3 bits)
|
||||
|
||||
/*
|
||||
* The next few variables are put in as optimizations to reduce
|
||||
* TLB lookup overheads. For a given Mask, what is the address shift
|
||||
* amount, and what is the OffsetMask
|
||||
*/
|
||||
int AddrShiftAmount;
|
||||
int OffsetMask;
|
||||
|
||||
bool Valid() { return (V0 | V1); };
|
||||
void serialize(std::ostream &os);
|
||||
void unserialize(Checkpoint *cp, const std::string §ion);
|
||||
};
|
||||
|
||||
// WARN: This particular TLB entry is not necessarily conformed to MIPS ISA
|
||||
struct TlbEntry
|
||||
{
|
||||
Addr _pageStart;
|
||||
TlbEntry() {}
|
||||
TlbEntry(Addr asn, Addr vaddr, Addr paddr) : _pageStart(paddr) {}
|
||||
|
||||
Addr pageStart()
|
||||
{
|
||||
return _pageStart;
|
||||
}
|
||||
|
||||
void
|
||||
updateVaddr(Addr new_vaddr) {}
|
||||
|
||||
void serialize(std::ostream &os)
|
||||
{
|
||||
SERIALIZE_SCALAR(_pageStart);
|
||||
}
|
||||
|
||||
void unserialize(Checkpoint *cp, const std::string §ion)
|
||||
{
|
||||
UNSERIALIZE_SCALAR(_pageStart);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
#endif // __ARCH_MIPS_PAGETABLE_H__
|
||||
|
||||
330
simulators/gem5/src/arch/mips/pra_constants.hh
Executable file
330
simulators/gem5/src/arch/mips/pra_constants.hh
Executable file
@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_PRA_CONSTANTS_HH__
|
||||
#define __ARCH_MIPS_PRA_CONSTANTS_HH__
|
||||
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/bitunion.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
BitUnion32(IndexReg)
|
||||
Bitfield<31> p;
|
||||
// Need to figure out how to put in the TLB specific bits here
|
||||
// For now, we assume that the entire length is used by the index
|
||||
// field In reality, Index_HI = N-1, where
|
||||
// N = Ceiling(log2(TLB Entries))
|
||||
Bitfield<30, 0> index;
|
||||
EndBitUnion(IndexReg)
|
||||
|
||||
BitUnion32(RandomReg)
|
||||
// This has a problem similar to the IndexReg index field. We'll keep
|
||||
// both consistent at 30 for now
|
||||
Bitfield<30, 0> random;
|
||||
EndBitUnion(RandomReg)
|
||||
|
||||
BitUnion64(EntryLoReg)
|
||||
Bitfield<63, 30> fill;
|
||||
Bitfield<29, 6> pfn; // Page frame number
|
||||
Bitfield<5, 3> c; // Coherency attribute
|
||||
Bitfield<2> d; // Dirty Bit
|
||||
Bitfield<1> v; // Valid Bit
|
||||
Bitfield<0> g; // Global Bit
|
||||
EndBitUnion(EntryLoReg)
|
||||
|
||||
BitUnion64(ContextReg)
|
||||
Bitfield<63, 23> pteBase;
|
||||
Bitfield<22, 4> badVPN2;
|
||||
// Bits 3-0 are 0
|
||||
EndBitUnion(ContextReg)
|
||||
|
||||
BitUnion32(PageMaskReg)
|
||||
// Bits 31-29 are 0
|
||||
Bitfield<28, 13> mask;
|
||||
Bitfield<12, 11> maskx;
|
||||
// Bits 10-0 are zero
|
||||
EndBitUnion(PageMaskReg)
|
||||
|
||||
BitUnion32(PageGrainReg)
|
||||
Bitfield<31, 30> aseUp;
|
||||
Bitfield<29> elpa;
|
||||
Bitfield<28> esp;
|
||||
// Bits 27-13 are zeros
|
||||
Bitfield<12, 8> aseDn;
|
||||
// Bits 7-0 are zeros
|
||||
EndBitUnion(PageGrainReg)
|
||||
|
||||
BitUnion32(WiredReg)
|
||||
// See note on Index register above
|
||||
Bitfield<30, 0> wired;
|
||||
EndBitUnion(WiredReg)
|
||||
|
||||
BitUnion32(HWREnaReg)
|
||||
Bitfield<31, 30> impl;
|
||||
Bitfield<3, 0> mask;
|
||||
EndBitUnion(HWREnaReg)
|
||||
|
||||
BitUnion64(EntryHiReg)
|
||||
Bitfield<63, 62> r;
|
||||
Bitfield<61, 40> fill;
|
||||
Bitfield<39, 13> vpn2;
|
||||
Bitfield<12, 11> vpn2x;
|
||||
Bitfield<7, 0> asid;
|
||||
EndBitUnion(EntryHiReg)
|
||||
|
||||
BitUnion32(StatusReg)
|
||||
SubBitUnion(cu, 31, 28)
|
||||
Bitfield<31> cu3;
|
||||
Bitfield<30> cu2;
|
||||
Bitfield<29> cu1;
|
||||
Bitfield<28> cu0;
|
||||
EndSubBitUnion(cu)
|
||||
Bitfield<27> rp;
|
||||
Bitfield<26> fr;
|
||||
Bitfield<25> re;
|
||||
Bitfield<24> mx;
|
||||
Bitfield<23> px;
|
||||
Bitfield<22> bev;
|
||||
Bitfield<21> ts;
|
||||
Bitfield<20> sr;
|
||||
Bitfield<19> nmi;
|
||||
// Bit 18 is zero
|
||||
Bitfield<17, 16> impl;
|
||||
Bitfield<15, 10> ipl;
|
||||
SubBitUnion(im, 15, 8)
|
||||
Bitfield<15> im7;
|
||||
Bitfield<14> im6;
|
||||
Bitfield<13> im5;
|
||||
Bitfield<12> im4;
|
||||
Bitfield<11> im3;
|
||||
Bitfield<10> im2;
|
||||
Bitfield<9> im1;
|
||||
Bitfield<8> im0;
|
||||
EndSubBitUnion(im)
|
||||
Bitfield<7> kx;
|
||||
Bitfield<6> sx;
|
||||
Bitfield<5> ux;
|
||||
Bitfield<4, 3> ksu;
|
||||
Bitfield<4> um;
|
||||
Bitfield<3> r0;
|
||||
Bitfield<2> erl;
|
||||
Bitfield<1> exl;
|
||||
Bitfield<0> ie;
|
||||
EndBitUnion(StatusReg)
|
||||
|
||||
BitUnion32(IntCtlReg)
|
||||
Bitfield<31, 29> ipti;
|
||||
Bitfield<28, 26> ippci;
|
||||
// Bits 26-10 are zeros
|
||||
Bitfield<9, 5> vs;
|
||||
// Bits 4-0 are zeros
|
||||
EndBitUnion(IntCtlReg)
|
||||
|
||||
BitUnion32(SRSCtlReg)
|
||||
// Bits 31-30 are zeros
|
||||
Bitfield<29, 26> hss;
|
||||
// Bits 25-22 are zeros
|
||||
Bitfield<21, 18> eicss;
|
||||
// Bits 17-16 are zeros
|
||||
Bitfield<15, 12> ess;
|
||||
// Bits 11-10 are zeros
|
||||
Bitfield<9, 6> pss;
|
||||
// Bits 5-4 are zeros
|
||||
Bitfield<3, 0> css;
|
||||
EndBitUnion(SRSCtlReg)
|
||||
|
||||
BitUnion32(SRSMapReg)
|
||||
Bitfield<31, 28> ssv7;
|
||||
Bitfield<27, 24> ssv6;
|
||||
Bitfield<23, 20> ssv5;
|
||||
Bitfield<19, 16> ssv4;
|
||||
Bitfield<15, 12> ssv3;
|
||||
Bitfield<11, 8> ssv2;
|
||||
Bitfield<7, 4> ssv1;
|
||||
Bitfield<3, 0> ssv0;
|
||||
EndBitUnion(SRSMapReg)
|
||||
|
||||
BitUnion32(CauseReg)
|
||||
Bitfield<31> bd;
|
||||
Bitfield<30> ti;
|
||||
Bitfield<29, 28> ce;
|
||||
Bitfield<27> dc;
|
||||
Bitfield<26> pci;
|
||||
// Bits 25-24 are zeros
|
||||
Bitfield<23> iv;
|
||||
Bitfield<22> wp;
|
||||
// Bits 21-16 are zeros
|
||||
Bitfield<15, 10> ripl;
|
||||
SubBitUnion(ip, 15, 8)
|
||||
Bitfield<15> ip7;
|
||||
Bitfield<14> ip6;
|
||||
Bitfield<13> ip5;
|
||||
Bitfield<12> ip4;
|
||||
Bitfield<11> ip3;
|
||||
Bitfield<10> ip2;
|
||||
Bitfield<9> ip1;
|
||||
Bitfield<8> ip0;
|
||||
EndSubBitUnion(ip);
|
||||
// Bit 7 is zero
|
||||
Bitfield<6, 2> excCode;
|
||||
// Bits 1-0 are zeros
|
||||
EndBitUnion(CauseReg)
|
||||
|
||||
BitUnion32(PRIdReg)
|
||||
Bitfield<31, 24> coOp;
|
||||
Bitfield<23, 16> coId;
|
||||
Bitfield<15, 8> procId;
|
||||
Bitfield<7, 0> rev;
|
||||
EndBitUnion(PRIdReg)
|
||||
|
||||
BitUnion32(EBaseReg)
|
||||
// Bit 31 is one
|
||||
// Bit 30 is zero
|
||||
Bitfield<29, 12> exceptionBase;
|
||||
// Bits 11-10 are zeros
|
||||
Bitfield<9, 9> cpuNum;
|
||||
EndBitUnion(EBaseReg)
|
||||
|
||||
BitUnion32(ConfigReg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<30, 28> k23;
|
||||
Bitfield<27, 25> ku;
|
||||
Bitfield<24, 16> impl;
|
||||
Bitfield<15> be;
|
||||
Bitfield<14, 13> at;
|
||||
Bitfield<12, 10> ar;
|
||||
Bitfield<9, 7> mt;
|
||||
// Bits 6-4 are zeros
|
||||
Bitfield<3> vi;
|
||||
Bitfield<2, 0> k0;
|
||||
EndBitUnion(ConfigReg)
|
||||
|
||||
BitUnion32(Config1Reg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<30, 25> mmuSize;
|
||||
Bitfield<24, 22> is;
|
||||
Bitfield<21, 19> il;
|
||||
Bitfield<18, 16> ia;
|
||||
Bitfield<15, 13> ds;
|
||||
Bitfield<12, 10> dl;
|
||||
Bitfield<9, 7> da;
|
||||
Bitfield<6> c2;
|
||||
Bitfield<5> md;
|
||||
Bitfield<4> pc;
|
||||
Bitfield<3> wr;
|
||||
Bitfield<2> ca;
|
||||
Bitfield<1> ep;
|
||||
Bitfield<0> fp;
|
||||
EndBitUnion(Config1Reg)
|
||||
|
||||
BitUnion32(Config2Reg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<30, 28> tu;
|
||||
Bitfield<27, 24> ts;
|
||||
Bitfield<23, 20> tl;
|
||||
Bitfield<19, 16> ta;
|
||||
Bitfield<15, 12> su;
|
||||
Bitfield<11, 8> ss;
|
||||
Bitfield<7, 4> sl;
|
||||
Bitfield<3, 0> sa;
|
||||
EndBitUnion(Config2Reg)
|
||||
|
||||
BitUnion32(Config3Reg)
|
||||
Bitfield<31> m;
|
||||
// Bits 30-11 are zeros
|
||||
Bitfield<10> dspp;
|
||||
// Bits 9-8 are zeros
|
||||
Bitfield<7> lpa;
|
||||
Bitfield<6> veic;
|
||||
Bitfield<5> vint;
|
||||
Bitfield<4> sp;
|
||||
// Bit 3 is zero
|
||||
Bitfield<2> mt;
|
||||
Bitfield<1> sm;
|
||||
Bitfield<0> tl;
|
||||
EndBitUnion(Config3Reg)
|
||||
|
||||
BitUnion64(WatchLoReg)
|
||||
Bitfield<63, 3> vaddr;
|
||||
Bitfield<2> i;
|
||||
Bitfield<1> r;
|
||||
Bitfield<0> w;
|
||||
EndBitUnion(WatchLoReg)
|
||||
|
||||
BitUnion32(WatchHiReg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<30> g;
|
||||
// Bits 29-24 are zeros
|
||||
Bitfield<23, 16> asid;
|
||||
// Bits 15-12 are zeros
|
||||
Bitfield<11, 3> mask;
|
||||
Bitfield<2> i;
|
||||
Bitfield<1> r;
|
||||
Bitfield<0> w;
|
||||
EndBitUnion(WatchHiReg)
|
||||
|
||||
BitUnion32(PerfCntCtlReg)
|
||||
Bitfield<31> m;
|
||||
Bitfield<30> w;
|
||||
// Bits 29-11 are zeros
|
||||
Bitfield<10, 5> event;
|
||||
Bitfield<4> ie;
|
||||
Bitfield<3> u;
|
||||
Bitfield<2> s;
|
||||
Bitfield<1> k;
|
||||
Bitfield<0> exl;
|
||||
EndBitUnion(PerfCntCtlReg)
|
||||
|
||||
BitUnion32(CacheErrReg)
|
||||
Bitfield<31> er;
|
||||
Bitfield<30> ec;
|
||||
Bitfield<29> ed;
|
||||
Bitfield<28> et;
|
||||
Bitfield<27> es;
|
||||
Bitfield<26> ee;
|
||||
Bitfield<25> eb;
|
||||
Bitfield<24, 22> impl;
|
||||
Bitfield<22, 0> index;
|
||||
EndBitUnion(CacheErrReg)
|
||||
|
||||
BitUnion32(TagLoReg)
|
||||
Bitfield<31, 8> pTagLo;
|
||||
Bitfield<7, 6> pState;
|
||||
Bitfield<5> l;
|
||||
Bitfield<4, 3> impl;
|
||||
// Bits 2-1 are zeros
|
||||
Bitfield<0> p;
|
||||
EndBitUnion(TagLoReg)
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
212
simulators/gem5/src/arch/mips/process.cc
Normal file
212
simulators/gem5/src/arch/mips/process.cc
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Ali Saidi
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/process.hh"
|
||||
#include "base/loader/elf_object.hh"
|
||||
#include "base/loader/object_file.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Loader.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/process.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
#include "sim/system.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
MipsLiveProcess::MipsLiveProcess(LiveProcessParams * params,
|
||||
ObjectFile *objFile)
|
||||
: LiveProcess(params, objFile)
|
||||
{
|
||||
// Set up stack. On MIPS, stack starts at the top of kuseg
|
||||
// user address space. MIPS stack grows down from here
|
||||
stack_base = 0x7FFFFFFF;
|
||||
|
||||
// Set pointer for next thread stack. Reserve 8M for main stack.
|
||||
next_thread_stack_base = stack_base - (8 * 1024 * 1024);
|
||||
|
||||
// Set up break point (Top of Heap)
|
||||
brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
|
||||
brk_point = roundUp(brk_point, VMPageSize);
|
||||
|
||||
// Set up region for mmaps. Start it 1GB above the top of the heap.
|
||||
mmap_start = mmap_end = brk_point + 0x40000000L;
|
||||
}
|
||||
|
||||
void
|
||||
MipsLiveProcess::initState()
|
||||
{
|
||||
LiveProcess::initState();
|
||||
|
||||
argsInit<uint32_t>(VMPageSize);
|
||||
}
|
||||
|
||||
template<class IntType>
|
||||
void
|
||||
MipsLiveProcess::argsInit(int pageSize)
|
||||
{
|
||||
int intSize = sizeof(IntType);
|
||||
|
||||
// load object file into target memory
|
||||
objFile->loadSections(initVirtMem);
|
||||
|
||||
typedef AuxVector<IntType> auxv_t;
|
||||
std::vector<auxv_t> auxv;
|
||||
|
||||
ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
|
||||
if (elfObject)
|
||||
{
|
||||
// Set the system page size
|
||||
auxv.push_back(auxv_t(M5_AT_PAGESZ, MipsISA::VMPageSize));
|
||||
// Set the frequency at which time() increments
|
||||
auxv.push_back(auxv_t(M5_AT_CLKTCK, 100));
|
||||
// For statically linked executables, this is the virtual
|
||||
// address of the program header tables if they appear in the
|
||||
// executable image.
|
||||
auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
|
||||
DPRINTF(Loader, "auxv at PHDR %08p\n", elfObject->programHeaderTable());
|
||||
// This is the size of a program header entry from the elf file.
|
||||
auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
|
||||
// This is the number of program headers from the original elf file.
|
||||
auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
|
||||
//The entry point to the program
|
||||
auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
|
||||
//Different user and group IDs
|
||||
auxv.push_back(auxv_t(M5_AT_UID, uid()));
|
||||
auxv.push_back(auxv_t(M5_AT_EUID, euid()));
|
||||
auxv.push_back(auxv_t(M5_AT_GID, gid()));
|
||||
auxv.push_back(auxv_t(M5_AT_EGID, egid()));
|
||||
}
|
||||
|
||||
// Calculate how much space we need for arg & env & auxv arrays.
|
||||
int argv_array_size = intSize * (argv.size() + 1);
|
||||
int envp_array_size = intSize * (envp.size() + 1);
|
||||
int auxv_array_size = intSize * 2 * (auxv.size() + 1);
|
||||
|
||||
int arg_data_size = 0;
|
||||
for (vector<string>::size_type i = 0; i < argv.size(); ++i) {
|
||||
arg_data_size += argv[i].size() + 1;
|
||||
}
|
||||
int env_data_size = 0;
|
||||
for (vector<string>::size_type i = 0; i < envp.size(); ++i) {
|
||||
env_data_size += envp[i].size() + 1;
|
||||
}
|
||||
|
||||
int space_needed =
|
||||
argv_array_size +
|
||||
envp_array_size +
|
||||
auxv_array_size +
|
||||
arg_data_size +
|
||||
env_data_size;
|
||||
|
||||
// set bottom of stack
|
||||
stack_min = stack_base - space_needed;
|
||||
// align it
|
||||
stack_min = roundDown(stack_min, pageSize);
|
||||
stack_size = stack_base - stack_min;
|
||||
// map memory
|
||||
allocateMem(stack_min, roundUp(stack_size, pageSize));
|
||||
|
||||
// map out initial stack contents
|
||||
IntType argv_array_base = stack_min + intSize; // room for argc
|
||||
IntType envp_array_base = argv_array_base + argv_array_size;
|
||||
IntType auxv_array_base = envp_array_base + envp_array_size;
|
||||
IntType arg_data_base = auxv_array_base + auxv_array_size;
|
||||
IntType env_data_base = arg_data_base + arg_data_size;
|
||||
|
||||
// write contents to stack
|
||||
IntType argc = argv.size();
|
||||
|
||||
argc = htog((IntType)argc);
|
||||
|
||||
initVirtMem.writeBlob(stack_min, (uint8_t*)&argc, intSize);
|
||||
|
||||
copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
|
||||
|
||||
copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
|
||||
|
||||
// Copy the aux vector
|
||||
for (typename vector<auxv_t>::size_type x = 0; x < auxv.size(); x++) {
|
||||
initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
|
||||
(uint8_t*)&(auxv[x].a_type), intSize);
|
||||
initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
|
||||
(uint8_t*)&(auxv[x].a_val), intSize);
|
||||
}
|
||||
|
||||
// Write out the terminating zeroed auxilliary vector
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
const IntType zero = 0;
|
||||
const Addr addr = auxv_array_base + 2 * intSize * (auxv.size() + i);
|
||||
initVirtMem.writeBlob(addr, (uint8_t*)&zero, intSize);
|
||||
}
|
||||
|
||||
ThreadContext *tc = system->getThreadContext(contextIds[0]);
|
||||
|
||||
setSyscallArg(tc, 0, argc);
|
||||
setSyscallArg(tc, 1, argv_array_base);
|
||||
tc->setIntReg(StackPointerReg, stack_min);
|
||||
|
||||
tc->pcState(objFile->entryPoint());
|
||||
}
|
||||
|
||||
|
||||
MipsISA::IntReg
|
||||
MipsLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
|
||||
{
|
||||
assert(i < 6);
|
||||
return tc->readIntReg(FirstArgumentReg + i++);
|
||||
}
|
||||
|
||||
void
|
||||
MipsLiveProcess::setSyscallArg(ThreadContext *tc,
|
||||
int i, MipsISA::IntReg val)
|
||||
{
|
||||
assert(i < 6);
|
||||
tc->setIntReg(FirstArgumentReg + i, val);
|
||||
}
|
||||
|
||||
void
|
||||
MipsLiveProcess::setSyscallReturn(ThreadContext *tc,
|
||||
SyscallReturn return_value)
|
||||
{
|
||||
if (return_value.successful()) {
|
||||
// no error
|
||||
tc->setIntReg(SyscallSuccessReg, 0);
|
||||
tc->setIntReg(ReturnValueReg, return_value.value());
|
||||
} else {
|
||||
// got an error, return details
|
||||
tc->setIntReg(SyscallSuccessReg, (IntReg) -1);
|
||||
tc->setIntReg(ReturnValueReg, -return_value.value());
|
||||
}
|
||||
}
|
||||
61
simulators/gem5/src/arch/mips/process.hh
Normal file
61
simulators/gem5/src/arch/mips/process.hh
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Gabe Black
|
||||
* Ali Saidi
|
||||
*/
|
||||
|
||||
#ifndef __MIPS_PROCESS_HH__
|
||||
#define __MIPS_PROCESS_HH__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "sim/process.hh"
|
||||
|
||||
class LiveProcess;
|
||||
class ObjectFile;
|
||||
class System;
|
||||
|
||||
class MipsLiveProcess : public LiveProcess
|
||||
{
|
||||
protected:
|
||||
MipsLiveProcess(LiveProcessParams * params, ObjectFile *objFile);
|
||||
|
||||
void initState();
|
||||
|
||||
template<class IntType>
|
||||
void argsInit(int pageSize);
|
||||
|
||||
public:
|
||||
MipsISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
|
||||
void setSyscallArg(ThreadContext *tc, int i, MipsISA::IntReg val);
|
||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||
};
|
||||
|
||||
|
||||
#endif // __MIPS_PROCESS_HH__
|
||||
310
simulators/gem5/src/arch/mips/registers.hh
Normal file
310
simulators/gem5/src/arch/mips/registers.hh
Normal file
@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright (c) 2006 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_REGISTERS_HH__
|
||||
#define __ARCH_MIPS_REGISTERS_HH__
|
||||
|
||||
#include "arch/mips/generated/max_inst_regs.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/types.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
using MipsISAInst::MaxInstSrcRegs;
|
||||
using MipsISAInst::MaxInstDestRegs;
|
||||
using MipsISAInst::MaxMiscDestRegs;
|
||||
|
||||
// Constants Related to the number of registers
|
||||
const int NumIntArchRegs = 32;
|
||||
const int NumIntSpecialRegs = 9;
|
||||
const int NumFloatArchRegs = 32;
|
||||
const int NumFloatSpecialRegs = 5;
|
||||
|
||||
const int MaxShadowRegSets = 16; // Maximum number of shadow register sets
|
||||
const int NumIntRegs = NumIntArchRegs + NumIntSpecialRegs; //HI & LO Regs
|
||||
const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;//
|
||||
|
||||
const uint32_t MIPS32_QNAN = 0x7fbfffff;
|
||||
const uint64_t MIPS64_QNAN = ULL(0x7ff7ffffffffffff);
|
||||
|
||||
enum FPControlRegNums {
|
||||
FLOATREG_FIR = NumFloatArchRegs,
|
||||
FLOATREG_FCCR,
|
||||
FLOATREG_FEXR,
|
||||
FLOATREG_FENR,
|
||||
FLOATREG_FCSR
|
||||
};
|
||||
|
||||
enum FCSRBits {
|
||||
Inexact = 1,
|
||||
Underflow,
|
||||
Overflow,
|
||||
DivideByZero,
|
||||
Invalid,
|
||||
Unimplemented
|
||||
};
|
||||
|
||||
enum FCSRFields {
|
||||
Flag_Field = 1,
|
||||
Enable_Field = 6,
|
||||
Cause_Field = 11
|
||||
};
|
||||
|
||||
enum MiscIntRegNums {
|
||||
INTREG_LO = NumIntArchRegs,
|
||||
INTREG_DSP_LO0 = INTREG_LO,
|
||||
INTREG_HI,
|
||||
INTREG_DSP_HI0 = INTREG_HI,
|
||||
INTREG_DSP_ACX0,
|
||||
INTREG_DSP_LO1,
|
||||
INTREG_DSP_HI1,
|
||||
INTREG_DSP_ACX1,
|
||||
INTREG_DSP_LO2,
|
||||
INTREG_DSP_HI2,
|
||||
INTREG_DSP_ACX2,
|
||||
INTREG_DSP_LO3,
|
||||
INTREG_DSP_HI3,
|
||||
INTREG_DSP_ACX3,
|
||||
INTREG_DSP_CONTROL
|
||||
};
|
||||
|
||||
// semantically meaningful register indices
|
||||
const int ZeroReg = 0;
|
||||
const int AssemblerReg = 1;
|
||||
const int SyscallSuccessReg = 7;
|
||||
const int FirstArgumentReg = 4;
|
||||
const int ReturnValueReg = 2;
|
||||
|
||||
const int KernelReg0 = 26;
|
||||
const int KernelReg1 = 27;
|
||||
const int GlobalPointerReg = 28;
|
||||
const int StackPointerReg = 29;
|
||||
const int FramePointerReg = 30;
|
||||
const int ReturnAddressReg = 31;
|
||||
|
||||
const int SyscallPseudoReturnReg = 3;
|
||||
|
||||
//@TODO: Implementing ShadowSets needs to
|
||||
//edit this value such that:
|
||||
//TotalArchRegs = NumIntArchRegs * ShadowSets
|
||||
const int TotalArchRegs = NumIntArchRegs;
|
||||
|
||||
// These help enumerate all the registers for dependence tracking.
|
||||
const int FP_Base_DepTag = NumIntRegs;
|
||||
const int Ctrl_Base_DepTag = FP_Base_DepTag + NumFloatRegs;
|
||||
|
||||
// Enumerate names for 'Control' Registers in the CPU
|
||||
// Reference MIPS32 Arch. for Programmers, Vol. III, Ch.8
|
||||
// (Register Number-Register Select) Summary of Register
|
||||
//------------------------------------------------------
|
||||
// The first set of names classify the CP0 names as Register Banks
|
||||
// for easy indexing when using the 'RD + SEL' index combination
|
||||
// in CP0 instructions.
|
||||
enum MiscRegIndex{
|
||||
MISCREG_INDEX = 0, //Bank 0: 0 - 3
|
||||
MISCREG_MVP_CONTROL,
|
||||
MISCREG_MVP_CONF0,
|
||||
MISCREG_MVP_CONF1,
|
||||
|
||||
MISCREG_CP0_RANDOM = 8, //Bank 1: 8 - 15
|
||||
MISCREG_VPE_CONTROL,
|
||||
MISCREG_VPE_CONF0,
|
||||
MISCREG_VPE_CONF1,
|
||||
MISCREG_YQMASK,
|
||||
MISCREG_VPE_SCHEDULE,
|
||||
MISCREG_VPE_SCHEFBACK,
|
||||
MISCREG_VPE_OPT,
|
||||
|
||||
MISCREG_ENTRYLO0 = 16, //Bank 2: 16 - 23
|
||||
MISCREG_TC_STATUS,
|
||||
MISCREG_TC_BIND,
|
||||
MISCREG_TC_RESTART,
|
||||
MISCREG_TC_HALT,
|
||||
MISCREG_TC_CONTEXT,
|
||||
MISCREG_TC_SCHEDULE,
|
||||
MISCREG_TC_SCHEFBACK,
|
||||
|
||||
MISCREG_ENTRYLO1 = 24, // Bank 3: 24
|
||||
|
||||
MISCREG_CONTEXT = 32, // Bank 4: 32 - 33
|
||||
MISCREG_CONTEXT_CONFIG,
|
||||
|
||||
MISCREG_PAGEMASK = 40, //Bank 5: 40 - 41
|
||||
MISCREG_PAGEGRAIN = 41,
|
||||
|
||||
MISCREG_WIRED = 48, //Bank 6:48-55
|
||||
MISCREG_SRS_CONF0,
|
||||
MISCREG_SRS_CONF1,
|
||||
MISCREG_SRS_CONF2,
|
||||
MISCREG_SRS_CONF3,
|
||||
MISCREG_SRS_CONF4,
|
||||
|
||||
MISCREG_HWRENA = 56, //Bank 7: 56-63
|
||||
|
||||
MISCREG_BADVADDR = 64, //Bank 8: 64-71
|
||||
|
||||
MISCREG_COUNT = 72, //Bank 9: 72-79
|
||||
|
||||
MISCREG_ENTRYHI = 80, //Bank 10: 80-87
|
||||
|
||||
MISCREG_COMPARE = 88, //Bank 11: 88-95
|
||||
|
||||
MISCREG_STATUS = 96, //Bank 12: 96-103
|
||||
MISCREG_INTCTL,
|
||||
MISCREG_SRSCTL,
|
||||
MISCREG_SRSMAP,
|
||||
|
||||
MISCREG_CAUSE = 104, //Bank 13: 104-111
|
||||
|
||||
MISCREG_EPC = 112, //Bank 14: 112-119
|
||||
|
||||
MISCREG_PRID = 120, //Bank 15: 120-127,
|
||||
MISCREG_EBASE,
|
||||
|
||||
MISCREG_CONFIG = 128, //Bank 16: 128-135
|
||||
MISCREG_CONFIG1,
|
||||
MISCREG_CONFIG2,
|
||||
MISCREG_CONFIG3,
|
||||
MISCREG_CONFIG4,
|
||||
MISCREG_CONFIG5,
|
||||
MISCREG_CONFIG6,
|
||||
MISCREG_CONFIG7,
|
||||
|
||||
|
||||
MISCREG_LLADDR = 136, //Bank 17: 136-143
|
||||
|
||||
MISCREG_WATCHLO0 = 144, //Bank 18: 144-151
|
||||
MISCREG_WATCHLO1,
|
||||
MISCREG_WATCHLO2,
|
||||
MISCREG_WATCHLO3,
|
||||
MISCREG_WATCHLO4,
|
||||
MISCREG_WATCHLO5,
|
||||
MISCREG_WATCHLO6,
|
||||
MISCREG_WATCHLO7,
|
||||
|
||||
MISCREG_WATCHHI0 = 152, //Bank 19: 152-159
|
||||
MISCREG_WATCHHI1,
|
||||
MISCREG_WATCHHI2,
|
||||
MISCREG_WATCHHI3,
|
||||
MISCREG_WATCHHI4,
|
||||
MISCREG_WATCHHI5,
|
||||
MISCREG_WATCHHI6,
|
||||
MISCREG_WATCHHI7,
|
||||
|
||||
MISCREG_XCCONTEXT64 = 160, //Bank 20: 160-167
|
||||
|
||||
//Bank 21: 168-175
|
||||
|
||||
//Bank 22: 176-183
|
||||
|
||||
MISCREG_DEBUG = 184, //Bank 23: 184-191
|
||||
MISCREG_TRACE_CONTROL1,
|
||||
MISCREG_TRACE_CONTROL2,
|
||||
MISCREG_USER_TRACE_DATA,
|
||||
MISCREG_TRACE_BPC,
|
||||
|
||||
MISCREG_DEPC = 192, //Bank 24: 192-199
|
||||
|
||||
MISCREG_PERFCNT0 = 200, //Bank 25: 200-207
|
||||
MISCREG_PERFCNT1,
|
||||
MISCREG_PERFCNT2,
|
||||
MISCREG_PERFCNT3,
|
||||
MISCREG_PERFCNT4,
|
||||
MISCREG_PERFCNT5,
|
||||
MISCREG_PERFCNT6,
|
||||
MISCREG_PERFCNT7,
|
||||
|
||||
MISCREG_ERRCTL = 208, //Bank 26: 208-215
|
||||
|
||||
MISCREG_CACHEERR0 = 216, //Bank 27: 216-223
|
||||
MISCREG_CACHEERR1,
|
||||
MISCREG_CACHEERR2,
|
||||
MISCREG_CACHEERR3,
|
||||
|
||||
MISCREG_TAGLO0 = 224, //Bank 28: 224-231
|
||||
MISCREG_DATALO1,
|
||||
MISCREG_TAGLO2,
|
||||
MISCREG_DATALO3,
|
||||
MISCREG_TAGLO4,
|
||||
MISCREG_DATALO5,
|
||||
MISCREG_TAGLO6,
|
||||
MISCREG_DATALO7,
|
||||
|
||||
MISCREG_TAGHI0 = 232, //Bank 29: 232-239
|
||||
MISCREG_DATAHI1,
|
||||
MISCREG_TAGHI2,
|
||||
MISCREG_DATAHI3,
|
||||
MISCREG_TAGHI4,
|
||||
MISCREG_DATAHI5,
|
||||
MISCREG_TAGHI6,
|
||||
MISCREG_DATAHI7,
|
||||
|
||||
|
||||
MISCREG_ERROR_EPC = 240, //Bank 30: 240-247
|
||||
|
||||
MISCREG_DESAVE = 248, //Bank 31: 248-256
|
||||
|
||||
MISCREG_LLFLAG = 257,
|
||||
MISCREG_TP_VALUE,
|
||||
|
||||
MISCREG_NUMREGS
|
||||
};
|
||||
|
||||
const int TotalDataRegs = NumIntRegs + NumFloatRegs;
|
||||
|
||||
const int NumMiscRegs = MISCREG_NUMREGS;
|
||||
const int Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs;
|
||||
|
||||
const int TotalNumRegs = NumIntRegs + NumFloatRegs + NumMiscRegs;
|
||||
|
||||
typedef uint16_t RegIndex;
|
||||
|
||||
typedef uint32_t IntReg;
|
||||
|
||||
// floating point register file entry type
|
||||
typedef uint32_t FloatRegBits;
|
||||
typedef float FloatReg;
|
||||
|
||||
// cop-0/cop-1 system control register
|
||||
typedef uint64_t MiscReg;
|
||||
|
||||
typedef union {
|
||||
IntReg intreg;
|
||||
FloatReg fpreg;
|
||||
MiscReg ctrlreg;
|
||||
} AnyReg;
|
||||
|
||||
} // namespace MipsISA
|
||||
|
||||
#endif
|
||||
299
simulators/gem5/src/arch/mips/remote_gdb.cc
Normal file
299
simulators/gem5/src/arch/mips/remote_gdb.cc
Normal file
@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (c) 2010 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* William Wang
|
||||
* Deyuan Guo
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993 The Regents of the University of California
|
||||
* All rights reserved
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratories.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
|
||||
*
|
||||
* Taken from NetBSD
|
||||
*
|
||||
* "Stub" to allow remote cpu to debug over a serial line using gdb.
|
||||
*/
|
||||
|
||||
#include <sys/signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "arch/mips/decoder.hh"
|
||||
#include "arch/mips/remote_gdb.hh"
|
||||
#include "arch/mips/vtophys.hh"
|
||||
#include "cpu/thread_state.hh"
|
||||
#include "debug/GDBAcc.hh"
|
||||
#include "debug/GDBMisc.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/full_system.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
|
||||
: BaseRemoteGDB(_system, tc, GdbNumRegs)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine if the mapping at va..(va+len) is valid.
|
||||
*/
|
||||
bool
|
||||
RemoteGDB::acc(Addr va, size_t len)
|
||||
{
|
||||
TlbEntry entry;
|
||||
//Check to make sure the first byte is mapped into the processes address
|
||||
//space.
|
||||
if (FullSystem)
|
||||
panic("acc not implemented for MIPS FS!");
|
||||
else
|
||||
return context->getProcessPtr()->pTable->lookup(va, entry);
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate the kernel debugger register format into the GDB register
|
||||
* format.
|
||||
*/
|
||||
void
|
||||
RemoteGDB::getregs()
|
||||
{
|
||||
DPRINTF(GDBAcc, "getregs in remotegdb \n");
|
||||
memset(gdbregs.regs, 0, gdbregs.bytes());
|
||||
|
||||
// MIPS registers are 32 bits wide, gdb registers are 64 bits wide
|
||||
// two MIPS registers are packed into one gdb register (little endian)
|
||||
|
||||
// INTREG: R0~R31
|
||||
for (int i = 0; i < GdbIntArchRegs; i++) {
|
||||
gdbregs.regs[i] = pack(
|
||||
context->readIntReg(i * 2),
|
||||
context->readIntReg(i * 2 + 1));
|
||||
}
|
||||
// SR, LO, HI, BADVADDR, CAUSE, PC
|
||||
gdbregs.regs[GdbIntArchRegs + 0] = pack(
|
||||
context->readMiscRegNoEffect(MISCREG_STATUS),
|
||||
context->readIntReg(INTREG_LO));
|
||||
gdbregs.regs[GdbIntArchRegs + 1] = pack(
|
||||
context->readIntReg(INTREG_HI),
|
||||
context->readMiscRegNoEffect(MISCREG_BADVADDR));
|
||||
gdbregs.regs[GdbIntArchRegs + 2] = pack(
|
||||
context->readMiscRegNoEffect(MISCREG_CAUSE),
|
||||
context->pcState().pc());
|
||||
// FLOATREG: F0~F31
|
||||
for (int i = 0; i < GdbFloatArchRegs; i++) {
|
||||
gdbregs.regs[GdbIntRegs + i] = pack(
|
||||
context->readFloatRegBits(i * 2),
|
||||
context->readFloatRegBits(i * 2 + 1));
|
||||
}
|
||||
// FCR, FIR
|
||||
gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0] = pack(
|
||||
context->readFloatRegBits(FLOATREG_FCCR),
|
||||
context->readFloatRegBits(FLOATREG_FIR));
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate the GDB register format into the kernel debugger register
|
||||
* format.
|
||||
*/
|
||||
void
|
||||
RemoteGDB::setregs()
|
||||
{
|
||||
DPRINTF(GDBAcc, "setregs in remotegdb \n");
|
||||
|
||||
// MIPS registers are 32 bits wide, gdb registers are 64 bits wide
|
||||
// two MIPS registers are packed into one gdb register (little endian)
|
||||
|
||||
// INTREG: R0~R31
|
||||
for (int i = 0; i < GdbIntArchRegs; i++) {
|
||||
if (i) context->setIntReg(i * 2,
|
||||
unpackLo(gdbregs.regs[i]));
|
||||
context->setIntReg(i * 2 + 1,
|
||||
unpackHi(gdbregs.regs[i]));
|
||||
}
|
||||
// SR, LO, HI, BADVADDR, CAUSE, PC
|
||||
context->setMiscRegNoEffect(MISCREG_STATUS,
|
||||
unpackLo(gdbregs.regs[GdbIntArchRegs + 0]));
|
||||
context->setIntReg(INTREG_LO,
|
||||
unpackHi(gdbregs.regs[GdbIntArchRegs + 0]));
|
||||
context->setIntReg(INTREG_HI,
|
||||
unpackLo(gdbregs.regs[GdbIntArchRegs + 1]));
|
||||
context->setMiscRegNoEffect(MISCREG_BADVADDR,
|
||||
unpackHi(gdbregs.regs[GdbIntArchRegs + 1]));
|
||||
context->setMiscRegNoEffect(MISCREG_CAUSE,
|
||||
unpackLo(gdbregs.regs[GdbIntArchRegs + 2]));
|
||||
context->pcState(
|
||||
unpackHi(gdbregs.regs[GdbIntArchRegs + 2]));
|
||||
// FLOATREG: F0~F31
|
||||
for (int i = 0; i < GdbFloatArchRegs; i++) {
|
||||
context->setFloatRegBits(i * 2,
|
||||
unpackLo(gdbregs.regs[GdbIntRegs + i]));
|
||||
context->setFloatRegBits(i * 2 + 1,
|
||||
unpackHi(gdbregs.regs[GdbIntRegs + i]));
|
||||
}
|
||||
// FCR, FIR
|
||||
context->setFloatRegBits(FLOATREG_FCCR,
|
||||
unpackLo(gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0]));
|
||||
context->setFloatRegBits(FLOATREG_FIR,
|
||||
unpackHi(gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0]));
|
||||
}
|
||||
|
||||
void
|
||||
RemoteGDB::clearSingleStep()
|
||||
{
|
||||
DPRINTF(GDBMisc, "clearSingleStep bt_addr=%#x nt_addr=%#x\n",
|
||||
takenBkpt, notTakenBkpt);
|
||||
|
||||
if (takenBkpt != 0)
|
||||
clearTempBreakpoint(takenBkpt);
|
||||
|
||||
if (notTakenBkpt != 0)
|
||||
clearTempBreakpoint(notTakenBkpt);
|
||||
}
|
||||
|
||||
void
|
||||
RemoteGDB::setSingleStep()
|
||||
{
|
||||
PCState pc = context->pcState();
|
||||
PCState bpc;
|
||||
bool set_bt = false;
|
||||
|
||||
// User was stopped at pc, e.g. the instruction at pc was not
|
||||
// executed.
|
||||
MachInst inst = read<MachInst>(pc.pc());
|
||||
StaticInstPtr si = context->getDecoderPtr()->decode(inst, pc.pc());
|
||||
if (si->hasBranchTarget(pc, context, bpc)) {
|
||||
// Don't bother setting a breakpoint on the taken branch if it
|
||||
// is the same as the next npc
|
||||
if (bpc.npc() != pc.nnpc())
|
||||
set_bt = true;
|
||||
}
|
||||
|
||||
DPRINTF(GDBMisc, "setSingleStep bt_addr=%#x nt_addr=%#x\n",
|
||||
takenBkpt, notTakenBkpt);
|
||||
|
||||
notTakenBkpt = pc.nnpc();
|
||||
setTempBreakpoint(notTakenBkpt);
|
||||
|
||||
if (set_bt) {
|
||||
takenBkpt = bpc.npc();
|
||||
setTempBreakpoint(takenBkpt);
|
||||
}
|
||||
}
|
||||
|
||||
92
simulators/gem5/src/arch/mips/remote_gdb.hh
Normal file
92
simulators/gem5/src/arch/mips/remote_gdb.hh
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2007 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_REMOTE_GDB_HH__
|
||||
#define __ARCH_MIPS_REMOTE_GDB_HH__
|
||||
|
||||
#include "arch/mips/registers.hh"
|
||||
#include "base/bitfield.hh"
|
||||
#include "base/remote_gdb.hh"
|
||||
|
||||
class System;
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
// The number of special regs depends on gdb.
|
||||
// Two 32-bit regs are packed into one 64-bit reg.
|
||||
const int GdbIntArchRegs = NumIntArchRegs / 2;
|
||||
const int GdbIntSpecialRegs = 6 / 2;
|
||||
const int GdbFloatArchRegs = NumFloatArchRegs / 2;
|
||||
const int GdbFloatSpecialRegs = 2 / 2;
|
||||
|
||||
const int GdbIntRegs = GdbIntArchRegs + GdbIntSpecialRegs;
|
||||
const int GdbFloatRegs = GdbFloatArchRegs + GdbFloatSpecialRegs;
|
||||
const int GdbNumRegs = GdbIntRegs + GdbFloatRegs;
|
||||
|
||||
class RemoteGDB : public BaseRemoteGDB
|
||||
{
|
||||
protected:
|
||||
Addr notTakenBkpt;
|
||||
Addr takenBkpt;
|
||||
|
||||
public:
|
||||
RemoteGDB(System *_system, ThreadContext *tc);
|
||||
|
||||
protected:
|
||||
bool acc(Addr addr, size_t len);
|
||||
|
||||
void getregs();
|
||||
void setregs();
|
||||
|
||||
void clearSingleStep();
|
||||
void setSingleStep();
|
||||
|
||||
private:
|
||||
uint64_t
|
||||
pack(uint32_t lo, uint32_t hi)
|
||||
{
|
||||
return static_cast<uint64_t>(hi) << 32 | lo;
|
||||
}
|
||||
uint32_t
|
||||
unpackLo(uint64_t val)
|
||||
{
|
||||
return bits(val, 31, 0);
|
||||
}
|
||||
uint32_t
|
||||
unpackHi(uint64_t val)
|
||||
{
|
||||
return bits(val, 63, 32);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __ARCH_MIPS_REMOTE_GDB_H__ */
|
||||
233
simulators/gem5/src/arch/mips/stacktrace.cc
Normal file
233
simulators/gem5/src/arch/mips/stacktrace.cc
Normal file
@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/stacktrace.hh"
|
||||
#include "arch/mips/vtophys.hh"
|
||||
#include "base/bitfield.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "mem/fs_translating_port_proxy.hh"
|
||||
#include "sim/system.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
ProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc)
|
||||
{}
|
||||
|
||||
Addr
|
||||
ProcessInfo::task(Addr ksp) const
|
||||
{
|
||||
Addr base = ksp & ~0x3fff;
|
||||
if (base == ULL(0xfffffc0000000000))
|
||||
return 0;
|
||||
|
||||
Addr tsk;
|
||||
|
||||
FSTranslatingPortProxy &vp = tc->getVirtProxy();
|
||||
tsk = vp.readGtoH<Addr>(base + task_off);
|
||||
|
||||
return tsk;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessInfo::pid(Addr ksp) const
|
||||
{
|
||||
Addr task = this->task(ksp);
|
||||
if (!task)
|
||||
return -1;
|
||||
|
||||
uint16_t pd;
|
||||
|
||||
FSTranslatingPortProxy &vp = tc->getVirtProxy();
|
||||
pd = vp.readGtoH<uint16_t>(task + pid_off);
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
string
|
||||
ProcessInfo::name(Addr ksp) const
|
||||
{
|
||||
Addr task = this->task(ksp);
|
||||
if (!task)
|
||||
return "console";
|
||||
|
||||
char comm[256];
|
||||
CopyStringOut(tc, comm, task + name_off, sizeof(comm));
|
||||
if (!comm[0])
|
||||
return "startup";
|
||||
|
||||
return comm;
|
||||
}
|
||||
|
||||
StackTrace::StackTrace()
|
||||
: tc(0), stack(64)
|
||||
{
|
||||
}
|
||||
|
||||
StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
|
||||
: tc(0), stack(64)
|
||||
{
|
||||
trace(_tc, inst);
|
||||
}
|
||||
|
||||
StackTrace::~StackTrace()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StackTrace::trace(ThreadContext *_tc, bool is_call)
|
||||
{
|
||||
tc = _tc;
|
||||
bool usermode = 0;
|
||||
|
||||
if (usermode) {
|
||||
stack.push_back(user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
StackTrace::isEntry(Addr addr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
StackTrace::decodeStack(MachInst inst, int &disp)
|
||||
{
|
||||
// lda $sp, -disp($sp)
|
||||
//
|
||||
// Opcode<31:26> == 0x08
|
||||
// RA<25:21> == 30
|
||||
// RB<20:16> == 30
|
||||
// Disp<15:0>
|
||||
const MachInst mem_mask = 0xffff0000;
|
||||
const MachInst lda_pattern = 0x23de0000;
|
||||
const MachInst lda_disp_mask = 0x0000ffff;
|
||||
|
||||
// subq $sp, disp, $sp
|
||||
// addq $sp, disp, $sp
|
||||
//
|
||||
// Opcode<31:26> == 0x10
|
||||
// RA<25:21> == 30
|
||||
// Lit<20:13>
|
||||
// One<12> = 1
|
||||
// Func<11:5> == 0x20 (addq)
|
||||
// Func<11:5> == 0x29 (subq)
|
||||
// RC<4:0> == 30
|
||||
const MachInst intop_mask = 0xffe01fff;
|
||||
const MachInst addq_pattern = 0x43c0141e;
|
||||
const MachInst subq_pattern = 0x43c0153e;
|
||||
const MachInst intop_disp_mask = 0x001fe000;
|
||||
const int intop_disp_shift = 13;
|
||||
|
||||
if ((inst & mem_mask) == lda_pattern)
|
||||
disp = -sext<16>(inst & lda_disp_mask);
|
||||
else if ((inst & intop_mask) == addq_pattern)
|
||||
disp = -int((inst & intop_disp_mask) >> intop_disp_shift);
|
||||
else if ((inst & intop_mask) == subq_pattern)
|
||||
disp = int((inst & intop_disp_mask) >> intop_disp_shift);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
StackTrace::decodeSave(MachInst inst, int ®, int &disp)
|
||||
{
|
||||
// lda $stq, disp($sp)
|
||||
//
|
||||
// Opcode<31:26> == 0x08
|
||||
// RA<25:21> == ?
|
||||
// RB<20:16> == 30
|
||||
// Disp<15:0>
|
||||
const MachInst stq_mask = 0xfc1f0000;
|
||||
const MachInst stq_pattern = 0xb41e0000;
|
||||
const MachInst stq_disp_mask = 0x0000ffff;
|
||||
const MachInst reg_mask = 0x03e00000;
|
||||
const int reg_shift = 21;
|
||||
|
||||
if ((inst & stq_mask) == stq_pattern) {
|
||||
reg = (inst & reg_mask) >> reg_shift;
|
||||
disp = sext<16>(inst & stq_disp_mask);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode the function prologue for the function we're in, and note
|
||||
* which registers are stored where, and how large the stack frame is.
|
||||
*/
|
||||
bool
|
||||
StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
|
||||
int &size, Addr &ra)
|
||||
{
|
||||
size = 0;
|
||||
ra = 0;
|
||||
|
||||
for (Addr pc = func; pc < callpc; pc += sizeof(MachInst)) {
|
||||
MachInst inst;
|
||||
CopyOut(tc, (uint8_t *)&inst, pc, sizeof(MachInst));
|
||||
|
||||
int reg, disp;
|
||||
if (decodeStack(inst, disp)) {
|
||||
if (size) {
|
||||
return true;
|
||||
}
|
||||
size += disp;
|
||||
} else if (decodeSave(inst, reg, disp)) {
|
||||
if (!ra && reg == ReturnAddressReg) {
|
||||
CopyOut(tc, (uint8_t *)&ra, sp + disp, sizeof(Addr));
|
||||
if (!ra) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if TRACING_ON
|
||||
void
|
||||
StackTrace::dump()
|
||||
{
|
||||
panic("Stack trace dump not implemented.\n");
|
||||
}
|
||||
#endif
|
||||
126
simulators/gem5/src/arch/mips/stacktrace.hh
Normal file
126
simulators/gem5/src/arch/mips/stacktrace.hh
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_STACKTRACE_HH__
|
||||
#define __ARCH_MIPS_STACKTRACE_HH__
|
||||
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/static_inst.hh"
|
||||
#include "debug/Stack.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
class ProcessInfo
|
||||
{
|
||||
private:
|
||||
ThreadContext *tc;
|
||||
|
||||
int thread_info_size;
|
||||
int task_struct_size;
|
||||
int task_off;
|
||||
int pid_off;
|
||||
int name_off;
|
||||
|
||||
public:
|
||||
ProcessInfo(ThreadContext *_tc);
|
||||
|
||||
Addr task(Addr ksp) const;
|
||||
int pid(Addr ksp) const;
|
||||
std::string name(Addr ksp) const;
|
||||
};
|
||||
|
||||
class StackTrace
|
||||
{
|
||||
protected:
|
||||
typedef MipsISA::MachInst MachInst;
|
||||
private:
|
||||
ThreadContext *tc;
|
||||
std::vector<Addr> stack;
|
||||
|
||||
private:
|
||||
bool isEntry(Addr addr);
|
||||
bool decodePrologue(Addr sp, Addr callpc, Addr func, int &size, Addr &ra);
|
||||
bool decodeSave(MachInst inst, int ®, int &disp);
|
||||
bool decodeStack(MachInst inst, int &disp);
|
||||
|
||||
void trace(ThreadContext *tc, bool is_call);
|
||||
|
||||
public:
|
||||
StackTrace();
|
||||
StackTrace(ThreadContext *tc, StaticInstPtr inst);
|
||||
~StackTrace();
|
||||
|
||||
void clear()
|
||||
{
|
||||
tc = 0;
|
||||
stack.clear();
|
||||
}
|
||||
|
||||
bool valid() const { return tc != NULL; }
|
||||
bool trace(ThreadContext *tc, StaticInstPtr inst);
|
||||
|
||||
public:
|
||||
const std::vector<Addr> &getstack() const { return stack; }
|
||||
|
||||
static const int user = 1;
|
||||
static const int console = 2;
|
||||
static const int unknown = 3;
|
||||
|
||||
#if TRACING_ON
|
||||
private:
|
||||
void dump();
|
||||
|
||||
public:
|
||||
void dprintf() { if (DTRACE(Stack)) dump(); }
|
||||
#else
|
||||
public:
|
||||
void dprintf() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
inline bool
|
||||
StackTrace::trace(ThreadContext *tc, StaticInstPtr inst)
|
||||
{
|
||||
if (!inst->isCall() && !inst->isReturn())
|
||||
return false;
|
||||
|
||||
if (valid())
|
||||
clear();
|
||||
|
||||
trace(tc, !inst->isReturn());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // __ARCH_MIPS_STACKTRACE_HH__
|
||||
88
simulators/gem5/src/arch/mips/system.cc
Executable file
88
simulators/gem5/src/arch/mips/system.cc
Executable file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#include "arch/mips/system.hh"
|
||||
#include "arch/vtophys.hh"
|
||||
#include "base/loader/hex_file.hh"
|
||||
#include "base/loader/object_file.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "mem/physical.hh"
|
||||
#include "params/MipsSystem.hh"
|
||||
#include "sim/byteswap.hh"
|
||||
|
||||
using namespace LittleEndianGuest;
|
||||
|
||||
MipsSystem::MipsSystem(Params *p) : System(p)
|
||||
{
|
||||
}
|
||||
|
||||
MipsSystem::~MipsSystem()
|
||||
{
|
||||
}
|
||||
|
||||
Addr
|
||||
MipsSystem::fixFuncEventAddr(Addr addr)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
|
||||
void
|
||||
MipsSystem::setMipsAccess(Addr access)
|
||||
{}
|
||||
|
||||
bool
|
||||
MipsSystem::breakpoint()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
MipsSystem::serialize(std::ostream &os)
|
||||
{
|
||||
System::serialize(os);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MipsSystem::unserialize(Checkpoint *cp, const std::string §ion)
|
||||
{
|
||||
System::unserialize(cp,section);
|
||||
}
|
||||
|
||||
MipsSystem *
|
||||
MipsSystemParams::create()
|
||||
{
|
||||
return new MipsSystem(this);
|
||||
}
|
||||
|
||||
99
simulators/gem5/src/arch/mips/system.hh
Executable file
99
simulators/gem5/src/arch/mips/system.hh
Executable file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_SYSTEM_HH__
|
||||
#define __ARCH_MIPS_SYSTEM_HH__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/loader/hex_file.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "cpu/pc_event.hh"
|
||||
#include "kern/system_events.hh"
|
||||
#include "params/MipsSystem.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
#include "sim/system.hh"
|
||||
|
||||
class MipsSystem : public System
|
||||
{
|
||||
public:
|
||||
typedef MipsSystemParams Params;
|
||||
MipsSystem(Params *p);
|
||||
~MipsSystem();
|
||||
|
||||
virtual bool breakpoint();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Serialization stuff
|
||||
*/
|
||||
virtual void serialize(std::ostream &os);
|
||||
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
||||
|
||||
/**
|
||||
* Set the m5MipsAccess pointer in the console
|
||||
*/
|
||||
void setMipsAccess(Addr access);
|
||||
|
||||
/** console symbol table */
|
||||
SymbolTable *consoleSymtab;
|
||||
|
||||
/** Object pointer for the console code */
|
||||
ObjectFile *console;
|
||||
|
||||
/** Used by some Bare Iron Configurations */
|
||||
HexFile *hexFile;
|
||||
|
||||
#ifndef NDEBUG
|
||||
/** Event to halt the simulator if the console calls panic() */
|
||||
BreakPCEvent *consolePanicEvent;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
/** Add a function-based event to the console code. */
|
||||
template <class T>
|
||||
T *
|
||||
addConsoleFuncEvent(const char *lbl)
|
||||
{
|
||||
return addFuncEvent<T>(consoleSymtab, lbl);
|
||||
}
|
||||
|
||||
virtual Addr fixFuncEventAddr(Addr addr);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
365
simulators/gem5/src/arch/mips/tlb.cc
Normal file
365
simulators/gem5/src/arch/mips/tlb.cc
Normal file
@ -0,0 +1,365 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Steve Reinhardt
|
||||
* Jaidev Patwardhan
|
||||
* Zhengxing Li
|
||||
* Deyuan Guo
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "arch/mips/faults.hh"
|
||||
#include "arch/mips/pagetable.hh"
|
||||
#include "arch/mips/pra_constants.hh"
|
||||
#include "arch/mips/tlb.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
#include "base/inifile.hh"
|
||||
#include "base/str.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/MipsPRA.hh"
|
||||
#include "debug/TLB.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/MipsTLB.hh"
|
||||
#include "sim/process.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MIPS TLB
|
||||
//
|
||||
|
||||
static inline mode_type
|
||||
getOperatingMode(MiscReg Stat)
|
||||
{
|
||||
if ((Stat & 0x10000006) != 0 || (Stat & 0x18) ==0) {
|
||||
return mode_kernel;
|
||||
} else if ((Stat & 0x18) == 0x8) {
|
||||
return mode_supervisor;
|
||||
} else if ((Stat & 0x18) == 0x10) {
|
||||
return mode_user;
|
||||
} else {
|
||||
return mode_number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TLB::TLB(const Params *p)
|
||||
: BaseTLB(p), size(p->size), nlu(0)
|
||||
{
|
||||
table = new PTE[size];
|
||||
memset(table, 0, sizeof(PTE[size]));
|
||||
smallPages = 0;
|
||||
}
|
||||
|
||||
TLB::~TLB()
|
||||
{
|
||||
if (table)
|
||||
delete [] table;
|
||||
}
|
||||
|
||||
// look up an entry in the TLB
|
||||
MipsISA::PTE *
|
||||
TLB::lookup(Addr vpn, uint8_t asn) const
|
||||
{
|
||||
// assume not found...
|
||||
PTE *retval = NULL;
|
||||
PageTable::const_iterator i = lookupTable.find(vpn);
|
||||
if (i != lookupTable.end()) {
|
||||
while (i->first == vpn) {
|
||||
int index = i->second;
|
||||
PTE *pte = &table[index];
|
||||
|
||||
/* 1KB TLB Lookup code - from MIPS ARM Volume III - Rev. 2.50 */
|
||||
Addr Mask = pte->Mask;
|
||||
Addr InvMask = ~Mask;
|
||||
Addr VPN = pte->VPN;
|
||||
if (((vpn & InvMask) == (VPN & InvMask)) &&
|
||||
(pte->G || (asn == pte->asid))) {
|
||||
// We have a VPN + ASID Match
|
||||
retval = pte;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
DPRINTF(TLB, "lookup %#x, asn %#x -> %s ppn %#x\n", vpn, (int)asn,
|
||||
retval ? "hit" : "miss", retval ? retval->PFN1 : 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
MipsISA::PTE*
|
||||
TLB::getEntry(unsigned Index) const
|
||||
{
|
||||
// Make sure that Index is valid
|
||||
assert(Index<size);
|
||||
return &table[Index];
|
||||
}
|
||||
|
||||
int
|
||||
TLB::probeEntry(Addr vpn, uint8_t asn) const
|
||||
{
|
||||
// assume not found...
|
||||
int Ind = -1;
|
||||
PageTable::const_iterator i = lookupTable.find(vpn);
|
||||
if (i != lookupTable.end()) {
|
||||
while (i->first == vpn) {
|
||||
int index = i->second;
|
||||
PTE *pte = &table[index];
|
||||
|
||||
/* 1KB TLB Lookup code - from MIPS ARM Volume III - Rev. 2.50 */
|
||||
Addr Mask = pte->Mask;
|
||||
Addr InvMask = ~Mask;
|
||||
Addr VPN = pte->VPN;
|
||||
if (((vpn & InvMask) == (VPN & InvMask)) &&
|
||||
(pte->G || (asn == pte->asid))) {
|
||||
// We have a VPN + ASID Match
|
||||
Ind = index;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
DPRINTF(MipsPRA,"VPN: %x, asid: %d, Result of TLBP: %d\n",vpn,asn,Ind);
|
||||
return Ind;
|
||||
}
|
||||
|
||||
inline Fault
|
||||
TLB::checkCacheability(RequestPtr &req)
|
||||
{
|
||||
Addr VAddrUncacheable = 0xA0000000;
|
||||
// In MIPS, cacheability is controlled by certain bits of the virtual
|
||||
// address or by the TLB entry
|
||||
if ((req->getVaddr() & VAddrUncacheable) == VAddrUncacheable) {
|
||||
// mark request as uncacheable
|
||||
req->setFlags(Request::UNCACHEABLE);
|
||||
}
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
void
|
||||
TLB::insertAt(PTE &pte, unsigned Index, int _smallPages)
|
||||
{
|
||||
smallPages = _smallPages;
|
||||
if (Index > size) {
|
||||
warn("Attempted to write at index (%d) beyond TLB size (%d)",
|
||||
Index, size);
|
||||
} else {
|
||||
// Update TLB
|
||||
DPRINTF(TLB, "TLB[%d]: %x %x %x %x\n",
|
||||
Index, pte.Mask << 11,
|
||||
((pte.VPN << 11) | pte.asid),
|
||||
((pte.PFN0 << 6) | (pte.C0 << 3) |
|
||||
(pte.D0 << 2) | (pte.V0 <<1) | pte.G),
|
||||
((pte.PFN1 <<6) | (pte.C1 << 3) |
|
||||
(pte.D1 << 2) | (pte.V1 <<1) | pte.G));
|
||||
if (table[Index].V0 == true || table[Index].V1 == true) {
|
||||
// Previous entry is valid
|
||||
PageTable::iterator i = lookupTable.find(table[Index].VPN);
|
||||
lookupTable.erase(i);
|
||||
}
|
||||
table[Index]=pte;
|
||||
// Update fast lookup table
|
||||
lookupTable.insert(make_pair(table[Index].VPN, Index));
|
||||
}
|
||||
}
|
||||
|
||||
// insert a new TLB entry
|
||||
void
|
||||
TLB::insert(Addr addr, PTE &pte)
|
||||
{
|
||||
fatal("TLB Insert not yet implemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
TLB::flushAll()
|
||||
{
|
||||
DPRINTF(TLB, "flushAll\n");
|
||||
memset(table, 0, sizeof(PTE[size]));
|
||||
lookupTable.clear();
|
||||
nlu = 0;
|
||||
}
|
||||
|
||||
void
|
||||
TLB::serialize(ostream &os)
|
||||
{
|
||||
SERIALIZE_SCALAR(size);
|
||||
SERIALIZE_SCALAR(nlu);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
nameOut(os, csprintf("%s.PTE%d", name(), i));
|
||||
table[i].serialize(os);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TLB::unserialize(Checkpoint *cp, const string §ion)
|
||||
{
|
||||
UNSERIALIZE_SCALAR(size);
|
||||
UNSERIALIZE_SCALAR(nlu);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
table[i].unserialize(cp, csprintf("%s.PTE%d", section, i));
|
||||
if (table[i].V0 || table[i].V1) {
|
||||
lookupTable.insert(make_pair(table[i].VPN, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TLB::regStats()
|
||||
{
|
||||
read_hits
|
||||
.name(name() + ".read_hits")
|
||||
.desc("DTB read hits")
|
||||
;
|
||||
|
||||
read_misses
|
||||
.name(name() + ".read_misses")
|
||||
.desc("DTB read misses")
|
||||
;
|
||||
|
||||
|
||||
read_accesses
|
||||
.name(name() + ".read_accesses")
|
||||
.desc("DTB read accesses")
|
||||
;
|
||||
|
||||
write_hits
|
||||
.name(name() + ".write_hits")
|
||||
.desc("DTB write hits")
|
||||
;
|
||||
|
||||
write_misses
|
||||
.name(name() + ".write_misses")
|
||||
.desc("DTB write misses")
|
||||
;
|
||||
|
||||
|
||||
write_accesses
|
||||
.name(name() + ".write_accesses")
|
||||
.desc("DTB write accesses")
|
||||
;
|
||||
|
||||
hits
|
||||
.name(name() + ".hits")
|
||||
.desc("DTB hits")
|
||||
;
|
||||
|
||||
misses
|
||||
.name(name() + ".misses")
|
||||
.desc("DTB misses")
|
||||
;
|
||||
|
||||
accesses
|
||||
.name(name() + ".accesses")
|
||||
.desc("DTB accesses")
|
||||
;
|
||||
|
||||
hits = read_hits + write_hits;
|
||||
misses = read_misses + write_misses;
|
||||
accesses = read_accesses + write_accesses;
|
||||
}
|
||||
|
||||
Fault
|
||||
TLB::translateInst(RequestPtr req, ThreadContext *tc)
|
||||
{
|
||||
if (FullSystem)
|
||||
panic("translateInst not implemented in MIPS.\n");
|
||||
|
||||
Process * p = tc->getProcessPtr();
|
||||
|
||||
Fault fault = p->pTable->translate(req);
|
||||
if (fault != NoFault)
|
||||
return fault;
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
Fault
|
||||
TLB::translateData(RequestPtr req, ThreadContext *tc, bool write)
|
||||
{
|
||||
if (FullSystem)
|
||||
panic("translateData not implemented in MIPS.\n");
|
||||
|
||||
Process * p = tc->getProcessPtr();
|
||||
|
||||
Fault fault = p->pTable->translate(req);
|
||||
if (fault != NoFault)
|
||||
return fault;
|
||||
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
Fault
|
||||
TLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
|
||||
{
|
||||
if (mode == Execute)
|
||||
return translateInst(req, tc);
|
||||
else
|
||||
return translateData(req, tc, mode == Write);
|
||||
}
|
||||
|
||||
void
|
||||
TLB::translateTiming(RequestPtr req, ThreadContext *tc,
|
||||
Translation *translation, Mode mode)
|
||||
{
|
||||
assert(translation);
|
||||
translation->finish(translateAtomic(req, tc, mode), req, tc, mode);
|
||||
}
|
||||
|
||||
Fault
|
||||
TLB::translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode)
|
||||
{
|
||||
panic("Not implemented\n");
|
||||
return NoFault;
|
||||
}
|
||||
|
||||
|
||||
MipsISA::PTE &
|
||||
TLB::index(bool advance)
|
||||
{
|
||||
PTE *pte = &table[nlu];
|
||||
|
||||
if (advance)
|
||||
nextnlu();
|
||||
|
||||
return *pte;
|
||||
}
|
||||
|
||||
MipsISA::TLB *
|
||||
MipsTLBParams::create()
|
||||
{
|
||||
return new TLB(this);
|
||||
}
|
||||
131
simulators/gem5/src/arch/mips/tlb.hh
Normal file
131
simulators/gem5/src/arch/mips/tlb.hh
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Steve Reinhardt
|
||||
* Jaidev Patwardhan
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_TLB_HH__
|
||||
#define __ARCH_MIPS_TLB_HH__
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/pagetable.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
#include "arch/mips/vtophys.hh"
|
||||
#include "base/statistics.hh"
|
||||
#include "mem/request.hh"
|
||||
#include "params/MipsTLB.hh"
|
||||
#include "sim/fault_fwd.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
#include "sim/tlb.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
/* MIPS does not distinguish between a DTLB and an ITLB -> unified TLB
|
||||
However, to maintain compatibility with other architectures, we'll
|
||||
simply create an ITLB and DTLB that will point to the real TLB */
|
||||
namespace MipsISA {
|
||||
|
||||
class TLB : public BaseTLB
|
||||
{
|
||||
protected:
|
||||
typedef std::multimap<Addr, int> PageTable;
|
||||
PageTable lookupTable; // Quick lookup into page table
|
||||
|
||||
MipsISA::PTE *table; // the Page Table
|
||||
int size; // TLB Size
|
||||
int nlu; // not last used entry (for replacement)
|
||||
|
||||
void nextnlu() { if (++nlu >= size) nlu = 0; }
|
||||
MipsISA::PTE *lookup(Addr vpn, uint8_t asn) const;
|
||||
|
||||
mutable Stats::Scalar read_hits;
|
||||
mutable Stats::Scalar read_misses;
|
||||
mutable Stats::Scalar read_acv;
|
||||
mutable Stats::Scalar read_accesses;
|
||||
mutable Stats::Scalar write_hits;
|
||||
mutable Stats::Scalar write_misses;
|
||||
mutable Stats::Scalar write_acv;
|
||||
mutable Stats::Scalar write_accesses;
|
||||
Stats::Formula hits;
|
||||
Stats::Formula misses;
|
||||
Stats::Formula accesses;
|
||||
|
||||
public:
|
||||
typedef MipsTLBParams Params;
|
||||
TLB(const Params *p);
|
||||
|
||||
int probeEntry(Addr vpn,uint8_t) const;
|
||||
MipsISA::PTE *getEntry(unsigned) const;
|
||||
virtual ~TLB();
|
||||
int smallPages;
|
||||
int getsize() const { return size; }
|
||||
|
||||
MipsISA::PTE &index(bool advance = true);
|
||||
void insert(Addr vaddr, MipsISA::PTE &pte);
|
||||
void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages);
|
||||
void flushAll();
|
||||
void demapPage(Addr vaddr, uint64_t asn)
|
||||
{
|
||||
panic("demapPage unimplemented.\n");
|
||||
}
|
||||
|
||||
// static helper functions... really
|
||||
static bool validVirtualAddress(Addr vaddr);
|
||||
|
||||
static Fault checkCacheability(RequestPtr &req);
|
||||
|
||||
// Checkpointing
|
||||
void serialize(std::ostream &os);
|
||||
void unserialize(Checkpoint *cp, const std::string §ion);
|
||||
|
||||
void regStats();
|
||||
|
||||
Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode);
|
||||
void translateTiming(RequestPtr req, ThreadContext *tc,
|
||||
Translation *translation, Mode mode);
|
||||
|
||||
/** Function stub for CheckerCPU compilation issues. MIPS does not
|
||||
* support the Checker model at the moment.
|
||||
*/
|
||||
Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode);
|
||||
|
||||
private:
|
||||
Fault translateInst(RequestPtr req, ThreadContext *tc);
|
||||
Fault translateData(RequestPtr req, ThreadContext *tc, bool write);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // __MIPS_MEMORY_HH__
|
||||
167
simulators/gem5/src/arch/mips/types.hh
Normal file
167
simulators/gem5/src/arch/mips/types.hh
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_TYPES_HH__
|
||||
#define __ARCH_MIPS_TYPES_HH__
|
||||
|
||||
#include "arch/generic/types.hh"
|
||||
#include "base/types.hh"
|
||||
|
||||
namespace MipsISA
|
||||
{
|
||||
|
||||
typedef uint32_t MachInst;
|
||||
typedef uint64_t ExtMachInst;
|
||||
|
||||
typedef GenericISA::DelaySlotPCState<MachInst> PCState;
|
||||
|
||||
typedef uint64_t LargestRead;
|
||||
|
||||
//used in FP convert & round function
|
||||
enum ConvertType{
|
||||
SINGLE_TO_DOUBLE,
|
||||
SINGLE_TO_WORD,
|
||||
SINGLE_TO_LONG,
|
||||
|
||||
DOUBLE_TO_SINGLE,
|
||||
DOUBLE_TO_WORD,
|
||||
DOUBLE_TO_LONG,
|
||||
|
||||
LONG_TO_SINGLE,
|
||||
LONG_TO_DOUBLE,
|
||||
LONG_TO_WORD,
|
||||
LONG_TO_PS,
|
||||
|
||||
WORD_TO_SINGLE,
|
||||
WORD_TO_DOUBLE,
|
||||
WORD_TO_LONG,
|
||||
WORD_TO_PS,
|
||||
|
||||
PL_TO_SINGLE,
|
||||
PU_TO_SINGLE
|
||||
};
|
||||
|
||||
//used in FP convert & round function
|
||||
enum RoundMode{
|
||||
RND_ZERO,
|
||||
RND_DOWN,
|
||||
RND_UP,
|
||||
RND_NEAREST
|
||||
};
|
||||
|
||||
struct CoreSpecific {
|
||||
CoreSpecific()
|
||||
: CP0_IntCtl_IPTI(0), CP0_IntCtl_IPPCI(0), CP0_SrsCtl_HSS(0),
|
||||
CP0_PRId_CompanyOptions(0), CP0_PRId_CompanyID(0),
|
||||
CP0_PRId_ProcessorID(0), CP0_PRId_Revision(0),
|
||||
CP0_EBase_CPUNum(0), CP0_Config_BE(0), CP0_Config_AT(0),
|
||||
CP0_Config_AR(0), CP0_Config_MT(0), CP0_Config_VI(0),
|
||||
CP0_Config1_M(0), CP0_Config1_MMU(0), CP0_Config1_IS(0),
|
||||
CP0_Config1_IL(0), CP0_Config1_IA(0), CP0_Config1_DS(0),
|
||||
CP0_Config1_DL(0), CP0_Config1_DA(0), CP0_Config1_C2(false),
|
||||
CP0_Config1_MD(false), CP0_Config1_PC(false), CP0_Config1_WR(false),
|
||||
CP0_Config1_CA(false), CP0_Config1_EP(false), CP0_Config1_FP(false),
|
||||
CP0_Config2_M(false), CP0_Config2_TU(0), CP0_Config2_TS(0),
|
||||
CP0_Config2_TL(0), CP0_Config2_TA(0), CP0_Config2_SU(0),
|
||||
CP0_Config2_SS(0), CP0_Config2_SL(0), CP0_Config2_SA(0),
|
||||
CP0_Config3_M(false), CP0_Config3_DSPP(false), CP0_Config3_LPA(false),
|
||||
CP0_Config3_VEIC(false), CP0_Config3_VInt(false),
|
||||
CP0_Config3_SP(false), CP0_Config3_MT(false), CP0_Config3_SM(false),
|
||||
CP0_Config3_TL(false), CP0_WatchHi_M(false), CP0_PerfCtr_M(false),
|
||||
CP0_PerfCtr_W(false), CP0_PRId(0), CP0_Config(0), CP0_Config1(0),
|
||||
CP0_Config2(0), CP0_Config3(0)
|
||||
{ }
|
||||
|
||||
// MIPS CP0 State - First individual variables
|
||||
// Page numbers refer to revision 2.50 (July 2005) of the MIPS32 ARM,
|
||||
// Volume III (PRA)
|
||||
unsigned CP0_IntCtl_IPTI; // Page 93, IP Timer Interrupt
|
||||
unsigned CP0_IntCtl_IPPCI; // Page 94, IP Performance Counter Interrupt
|
||||
unsigned CP0_SrsCtl_HSS; // Page 95, Highest Implemented Shadow Set
|
||||
unsigned CP0_PRId_CompanyOptions; // Page 105, Manufacture options
|
||||
unsigned CP0_PRId_CompanyID; // Page 105, Company ID - (0-255, 1=>MIPS)
|
||||
unsigned CP0_PRId_ProcessorID; // Page 105
|
||||
unsigned CP0_PRId_Revision; // Page 105
|
||||
unsigned CP0_EBase_CPUNum; // Page 106, CPU Number in a multiprocessor
|
||||
//system
|
||||
unsigned CP0_Config_BE; // Page 108, Big/Little Endian mode
|
||||
unsigned CP0_Config_AT; //Page 109
|
||||
unsigned CP0_Config_AR; //Page 109
|
||||
unsigned CP0_Config_MT; //Page 109
|
||||
unsigned CP0_Config_VI; //Page 109
|
||||
unsigned CP0_Config1_M; // Page 110
|
||||
unsigned CP0_Config1_MMU; // Page 110
|
||||
unsigned CP0_Config1_IS; // Page 110
|
||||
unsigned CP0_Config1_IL; // Page 111
|
||||
unsigned CP0_Config1_IA; // Page 111
|
||||
unsigned CP0_Config1_DS; // Page 111
|
||||
unsigned CP0_Config1_DL; // Page 112
|
||||
unsigned CP0_Config1_DA; // Page 112
|
||||
bool CP0_Config1_C2; // Page 112
|
||||
bool CP0_Config1_MD;// Page 112 - Technically not used in MIPS32
|
||||
bool CP0_Config1_PC;// Page 112
|
||||
bool CP0_Config1_WR;// Page 113
|
||||
bool CP0_Config1_CA;// Page 113
|
||||
bool CP0_Config1_EP;// Page 113
|
||||
bool CP0_Config1_FP;// Page 113
|
||||
bool CP0_Config2_M; // Page 114
|
||||
unsigned CP0_Config2_TU;// Page 114
|
||||
unsigned CP0_Config2_TS;// Page 114
|
||||
unsigned CP0_Config2_TL;// Page 115
|
||||
unsigned CP0_Config2_TA;// Page 115
|
||||
unsigned CP0_Config2_SU;// Page 115
|
||||
unsigned CP0_Config2_SS;// Page 115
|
||||
unsigned CP0_Config2_SL;// Page 116
|
||||
unsigned CP0_Config2_SA;// Page 116
|
||||
bool CP0_Config3_M; //// Page 117
|
||||
bool CP0_Config3_DSPP;// Page 117
|
||||
bool CP0_Config3_LPA;// Page 117
|
||||
bool CP0_Config3_VEIC;// Page 118
|
||||
bool CP0_Config3_VInt; // Page 118
|
||||
bool CP0_Config3_SP;// Page 118
|
||||
bool CP0_Config3_MT;// Page 119
|
||||
bool CP0_Config3_SM;// Page 119
|
||||
bool CP0_Config3_TL;// Page 119
|
||||
|
||||
bool CP0_WatchHi_M; // Page 124
|
||||
bool CP0_PerfCtr_M; // Page 130
|
||||
bool CP0_PerfCtr_W; // Page 130
|
||||
|
||||
|
||||
// Then, whole registers
|
||||
unsigned CP0_PRId;
|
||||
unsigned CP0_Config;
|
||||
unsigned CP0_Config1;
|
||||
unsigned CP0_Config2;
|
||||
unsigned CP0_Config3;
|
||||
};
|
||||
|
||||
} // namespace MipsISA
|
||||
#endif
|
||||
261
simulators/gem5/src/arch/mips/utility.cc
Normal file
261
simulators/gem5/src/arch/mips/utility.cc
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Korey Sewell
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/registers.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
#include "arch/mips/vtophys.hh"
|
||||
#include "base/bitfield.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "cpu/static_inst.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "mem/fs_translating_port_proxy.hh"
|
||||
#include "sim/serialize.hh"
|
||||
|
||||
|
||||
using namespace MipsISA;
|
||||
using namespace std;
|
||||
|
||||
namespace MipsISA {
|
||||
|
||||
uint64_t
|
||||
getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
|
||||
{
|
||||
panic("getArgument() not implemented\n");
|
||||
M5_DUMMY_RETURN
|
||||
}
|
||||
|
||||
uint64_t
|
||||
fpConvert(ConvertType cvt_type, double fp_val)
|
||||
{
|
||||
|
||||
switch (cvt_type)
|
||||
{
|
||||
case SINGLE_TO_DOUBLE:
|
||||
{
|
||||
double sdouble_val = fp_val;
|
||||
void *sdouble_ptr = &sdouble_val;
|
||||
uint64_t sdp_bits = *(uint64_t *) sdouble_ptr;
|
||||
return sdp_bits;
|
||||
}
|
||||
|
||||
case SINGLE_TO_WORD:
|
||||
{
|
||||
int32_t sword_val = (int32_t) fp_val;
|
||||
void *sword_ptr = &sword_val;
|
||||
uint64_t sword_bits= *(uint32_t *) sword_ptr;
|
||||
return sword_bits;
|
||||
}
|
||||
|
||||
case WORD_TO_SINGLE:
|
||||
{
|
||||
float wfloat_val = fp_val;
|
||||
void *wfloat_ptr = &wfloat_val;
|
||||
uint64_t wfloat_bits = *(uint32_t *) wfloat_ptr;
|
||||
return wfloat_bits;
|
||||
}
|
||||
|
||||
case WORD_TO_DOUBLE:
|
||||
{
|
||||
double wdouble_val = fp_val;
|
||||
void *wdouble_ptr = &wdouble_val;
|
||||
uint64_t wdp_bits = *(uint64_t *) wdouble_ptr;
|
||||
return wdp_bits;
|
||||
}
|
||||
|
||||
default:
|
||||
panic("Invalid Floating Point Conversion Type (%d). See \"types.hh\" for List of Conversions\n",cvt_type);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
roundFP(double val, int digits)
|
||||
{
|
||||
double digit_offset = pow(10.0,digits);
|
||||
val = val * digit_offset;
|
||||
val = val + 0.5;
|
||||
val = floor(val);
|
||||
val = val / digit_offset;
|
||||
return val;
|
||||
}
|
||||
|
||||
double
|
||||
truncFP(double val)
|
||||
{
|
||||
int trunc_val = (int) val;
|
||||
return (double) trunc_val;
|
||||
}
|
||||
|
||||
bool
|
||||
getCondCode(uint32_t fcsr, int cc_idx)
|
||||
{
|
||||
int shift = (cc_idx == 0) ? 23 : cc_idx + 24;
|
||||
bool cc_val = (fcsr >> shift) & 0x00000001;
|
||||
return cc_val;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
genCCVector(uint32_t fcsr, int cc_num, uint32_t cc_val)
|
||||
{
|
||||
int cc_idx = (cc_num == 0) ? 23 : cc_num + 24;
|
||||
|
||||
fcsr = bits(fcsr, 31, cc_idx + 1) << (cc_idx + 1) |
|
||||
cc_val << cc_idx |
|
||||
bits(fcsr, cc_idx - 1, 0);
|
||||
|
||||
return fcsr;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
genInvalidVector(uint32_t fcsr_bits)
|
||||
{
|
||||
//Set FCSR invalid in "flag" field
|
||||
int invalid_offset = Invalid + Flag_Field;
|
||||
fcsr_bits = fcsr_bits | (1 << invalid_offset);
|
||||
|
||||
//Set FCSR invalid in "cause" flag
|
||||
int cause_offset = Invalid + Cause_Field;
|
||||
fcsr_bits = fcsr_bits | (1 << cause_offset);
|
||||
|
||||
return fcsr_bits;
|
||||
}
|
||||
|
||||
bool
|
||||
isNan(void *val_ptr, int size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case 32:
|
||||
{
|
||||
uint32_t val_bits = *(uint32_t *) val_ptr;
|
||||
return (bits(val_bits, 30, 23) == 0xFF);
|
||||
}
|
||||
|
||||
case 64:
|
||||
{
|
||||
uint64_t val_bits = *(uint64_t *) val_ptr;
|
||||
return (bits(val_bits, 62, 52) == 0x7FF);
|
||||
}
|
||||
|
||||
default:
|
||||
panic("Type unsupported. Size mismatch\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
isQnan(void *val_ptr, int size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case 32:
|
||||
{
|
||||
uint32_t val_bits = *(uint32_t *) val_ptr;
|
||||
return (bits(val_bits, 30, 22) == 0x1FE);
|
||||
}
|
||||
|
||||
case 64:
|
||||
{
|
||||
uint64_t val_bits = *(uint64_t *) val_ptr;
|
||||
return (bits(val_bits, 62, 51) == 0xFFE);
|
||||
}
|
||||
|
||||
default:
|
||||
panic("Type unsupported. Size mismatch\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
isSnan(void *val_ptr, int size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case 32:
|
||||
{
|
||||
uint32_t val_bits = *(uint32_t *) val_ptr;
|
||||
return (bits(val_bits, 30, 22) == 0x1FF);
|
||||
}
|
||||
|
||||
case 64:
|
||||
{
|
||||
uint64_t val_bits = *(uint64_t *) val_ptr;
|
||||
return (bits(val_bits, 62, 51) == 0xFFF);
|
||||
}
|
||||
|
||||
default:
|
||||
panic("Type unsupported. Size mismatch\n");
|
||||
}
|
||||
}
|
||||
|
||||
template <class CPU>
|
||||
void
|
||||
zeroRegisters(CPU *cpu)
|
||||
{
|
||||
// Insure ISA semantics
|
||||
// (no longer very clean due to the change in setIntReg() in the
|
||||
// cpu model. Consider changing later.)
|
||||
cpu->thread->setIntReg(ZeroReg, 0);
|
||||
cpu->thread->setFloatReg(ZeroReg, 0.0);
|
||||
}
|
||||
|
||||
void
|
||||
startupCPU(ThreadContext *tc, int cpuId)
|
||||
{
|
||||
tc->activate(0/*tc->threadId()*/);
|
||||
}
|
||||
|
||||
void
|
||||
initCPU(ThreadContext *tc, int cpuId)
|
||||
{}
|
||||
|
||||
void
|
||||
copyRegs(ThreadContext *src, ThreadContext *dest)
|
||||
{
|
||||
panic("Copy Regs Not Implemented Yet\n");
|
||||
}
|
||||
|
||||
void
|
||||
copyMiscRegs(ThreadContext *src, ThreadContext *dest)
|
||||
{
|
||||
panic("Copy Misc. Regs Not Implemented Yet\n");
|
||||
}
|
||||
void
|
||||
skipFunction(ThreadContext *tc)
|
||||
{
|
||||
TheISA::PCState newPC = tc->pcState();
|
||||
newPC.set(tc->readIntReg(ReturnAddressReg));
|
||||
tc->pcState(newPC);
|
||||
}
|
||||
|
||||
|
||||
} // namespace MipsISA
|
||||
132
simulators/gem5/src/arch/mips/utility.hh
Normal file
132
simulators/gem5/src/arch/mips/utility.hh
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Nathan Binkert
|
||||
* Steve Reinhardt
|
||||
* Korey Sewell
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_UTILITY_HH__
|
||||
#define __ARCH_MIPS_UTILITY_HH__
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/types.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/types.hh"
|
||||
#include "cpu/static_inst.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA {
|
||||
|
||||
inline PCState
|
||||
buildRetPC(const PCState &curPC, const PCState &callPC)
|
||||
{
|
||||
PCState ret = callPC;
|
||||
ret.advance();
|
||||
ret.pc(curPC.npc());
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Floating Point Utility Functions
|
||||
//
|
||||
uint64_t fpConvert(ConvertType cvt_type, double fp_val);
|
||||
double roundFP(double val, int digits);
|
||||
double truncFP(double val);
|
||||
|
||||
bool getCondCode(uint32_t fcsr, int cc);
|
||||
uint32_t genCCVector(uint32_t fcsr, int num, uint32_t cc_val);
|
||||
uint32_t genInvalidVector(uint32_t fcsr);
|
||||
|
||||
bool isNan(void *val_ptr, int size);
|
||||
bool isQnan(void *val_ptr, int size);
|
||||
bool isSnan(void *val_ptr, int size);
|
||||
|
||||
static inline bool
|
||||
inUserMode(ThreadContext *tc)
|
||||
{
|
||||
MiscReg Stat = tc->readMiscReg(MISCREG_STATUS);
|
||||
MiscReg Dbg = tc->readMiscReg(MISCREG_DEBUG);
|
||||
|
||||
if ((Stat & 0x10000006) == 0 && // EXL, ERL or CU0 set, CP0 accessible
|
||||
(Dbg & 0x40000000) == 0 && // DM bit set, CP0 accessible
|
||||
(Stat & 0x00000018) != 0) { // KSU = 0, kernel mode is base mode
|
||||
// Unable to use Status_CU0, etc directly, using bitfields & masks
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <class CPU>
|
||||
void zeroRegisters(CPU *cpu);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Translation stuff
|
||||
//
|
||||
inline Addr
|
||||
TruncPage(Addr addr)
|
||||
{ return addr & ~(PageBytes - 1); }
|
||||
|
||||
inline Addr
|
||||
RoundPage(Addr addr)
|
||||
{ return (addr + PageBytes - 1) & ~(PageBytes - 1); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CPU Utility
|
||||
//
|
||||
void startupCPU(ThreadContext *tc, int cpuId);
|
||||
void initCPU(ThreadContext *tc, int cpuId);
|
||||
|
||||
void copyRegs(ThreadContext *src, ThreadContext *dest);
|
||||
void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
|
||||
|
||||
void skipFunction(ThreadContext *tc);
|
||||
|
||||
inline void
|
||||
advancePC(PCState &pc, const StaticInstPtr inst)
|
||||
{
|
||||
pc.advance();
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
getExecutingAsid(ThreadContext *tc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
57
simulators/gem5/src/arch/mips/vtophys.cc
Executable file
57
simulators/gem5/src/arch/mips/vtophys.cc
Executable file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "arch/mips/vtophys.hh"
|
||||
#include "base/chunk_generator.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/VtoPhys.hh"
|
||||
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
Addr
|
||||
MipsISA::vtophys(Addr vaddr)
|
||||
{
|
||||
fatal("VTOPHYS: Unimplemented on MIPS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Addr
|
||||
MipsISA::vtophys(ThreadContext *tc, Addr addr)
|
||||
{
|
||||
fatal("VTOPHYS: Unimplemented on MIPS\n");
|
||||
}
|
||||
|
||||
48
simulators/gem5/src/arch/mips/vtophys.hh
Normal file
48
simulators/gem5/src/arch/mips/vtophys.hh
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* Copyright (c) 2007 MIPS Technologies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Ali Saidi
|
||||
* Nathan Binkert
|
||||
* Jaidev Patwardhan
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_MIPS_VTOPHYS_H__
|
||||
#define __ARCH_MIPS_VTOPHYS_H__
|
||||
|
||||
#include "arch/mips/isa_traits.hh"
|
||||
#include "arch/mips/utility.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
namespace MipsISA {
|
||||
Addr vtophys(Addr vaddr);
|
||||
Addr vtophys(ThreadContext *tc, Addr vaddr);
|
||||
|
||||
};
|
||||
#endif // __ARCH_MIPS_VTOPHYS_H__
|
||||
|
||||
Reference in New Issue
Block a user