2006-01-25 01:57:17 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2006-01-26 22:19:44 +01:00
|
|
|
#ifndef __ARCH_MIPS_ISA_TRAITS_HH__
|
|
|
|
#define __ARCH_MIPS_ISA_TRAITS_HH__
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
#include "arch/mips/constants.hh"
|
|
|
|
#include "arch/mips/types.hh"
|
|
|
|
#include "arch/mips/regfile.hh"
|
2006-04-26 22:13:47 +02:00
|
|
|
#include "arch/mips/faults.hh"
|
2006-05-08 00:50:41 +02:00
|
|
|
#include "arch/mips/utility.hh"
|
2006-01-25 01:57:17 +01:00
|
|
|
#include "base/misc.hh"
|
2006-02-22 04:02:05 +01:00
|
|
|
#include "config/full_system.hh"
|
2006-04-26 22:13:47 +02:00
|
|
|
#include "sim/byteswap.hh"
|
2006-01-25 01:57:17 +01:00
|
|
|
#include "sim/host.hh"
|
2006-02-22 04:02:05 +01:00
|
|
|
#include "sim/faults.hh"
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-03-08 08:05:38 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2006-01-25 01:57:17 +01:00
|
|
|
class FastCPU;
|
2006-01-26 22:19:44 +01:00
|
|
|
class FullCPU;
|
|
|
|
class Checkpoint;
|
2006-03-15 22:26:40 +01:00
|
|
|
class ExecContext;
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-03-08 08:05:38 +01:00
|
|
|
namespace LittleEndianGuest {};
|
|
|
|
|
2006-01-26 22:19:44 +01:00
|
|
|
#define TARGET_MIPS
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-02-22 04:02:05 +01:00
|
|
|
class StaticInst;
|
|
|
|
class StaticInstPtr;
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-02-22 04:02:05 +01:00
|
|
|
namespace MIPS34K {
|
|
|
|
int DTB_ASN_ASN(uint64_t reg);
|
|
|
|
int ITB_ASN_ASN(uint64_t reg);
|
2006-03-08 08:05:38 +01:00
|
|
|
};
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
#if !FULL_SYSTEM
|
|
|
|
class SyscallReturn {
|
|
|
|
public:
|
|
|
|
template <class T>
|
|
|
|
SyscallReturn(T v, bool s)
|
|
|
|
{
|
2006-04-10 18:23:17 +02:00
|
|
|
retval = (uint32_t)v;
|
2006-03-12 11:57:34 +01:00
|
|
|
success = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
SyscallReturn(T v)
|
|
|
|
{
|
|
|
|
success = (v >= 0);
|
2006-04-10 18:23:17 +02:00
|
|
|
retval = (uint32_t)v;
|
2006-03-12 11:57:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~SyscallReturn() {}
|
|
|
|
|
|
|
|
SyscallReturn& operator=(const SyscallReturn& s) {
|
|
|
|
retval = s.retval;
|
|
|
|
success = s.success;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool successful() { return success; }
|
|
|
|
uint64_t value() { return retval; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t retval;
|
|
|
|
bool success;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2006-02-22 04:02:05 +01:00
|
|
|
namespace MipsISA
|
2006-01-25 01:57:17 +01:00
|
|
|
{
|
Enable register windows.
arch/alpha/isa_traits.hh:
arch/mips/isa_traits.cc:
Turned the integer register file into a class instead of a typedef to an array.
arch/alpha/regfile.hh:
Changed the integer register file into a class instead of a typedef to an array. Also put the parts of the register file, ie the int, float, and misc register files, pc, npc, and nnpc, behind accessor functions. Added a changeContext function, and ContextParam and ContextVal types, so that things like the register window can be changed through call backs.
arch/mips/isa_traits.hh:
Turned the integer register file into a class instead of a typedef to an array. Also moved a "using namespace" into the namespace definition.
arch/sparc/isa_traits.hh:
Turned the integer register file into a class instead of a typedef to an array. Also "fixed" the max number of src and dest regs. They may need to be even larger.
arch/sparc/regfile.hh:
Changed the integer register file into a class instead of a typedef to an array. Also put the parts of the register file, ie the int, float, and misc register files, pc, npc, and nnpc, behind accessor functions. Added a changeContext function, and ContextParam and ContextVal types, so that things like the register window can be changed through call backs. Created setCWP and setAltGlobals functions for the IntRegFile.
cpu/cpu_exec_context.hh:
Used the accessor functions for the register file, and added a changeRegFileContext function to call back into the RegFile. Used the RegFile clear function rather than memsetting it to 0.
cpu/exec_context.hh:
Added the changeRegFileContext function.
cpu/exetrace.cc:
Use the TheISA::NumIntRegs constant, and use readReg now that the integer register file is a class instead of an array.
cpu/exetrace.hh:
Get the address of the regs object, now that it isn't an array.
--HG--
extra : convert_revision : ea2dd81be1c2e66b3c684af319eb58f8a77fd49c
2006-04-06 20:47:03 +02:00
|
|
|
using namespace LittleEndianGuest;
|
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs)
|
2006-03-15 22:26:40 +01:00
|
|
|
{
|
2006-05-08 00:50:41 +02:00
|
|
|
if (return_value.successful()) {
|
|
|
|
// no error
|
|
|
|
regs->setIntReg(SyscallSuccessReg, 0);
|
|
|
|
regs->setIntReg(ReturnValueReg1, return_value.value());
|
|
|
|
} else {
|
|
|
|
// got an error, return details
|
|
|
|
regs->setIntReg(SyscallSuccessReg, (IntReg) -1);
|
|
|
|
regs->setIntReg(ReturnValueReg1, -return_value.value());
|
Enable register windows.
arch/alpha/isa_traits.hh:
arch/mips/isa_traits.cc:
Turned the integer register file into a class instead of a typedef to an array.
arch/alpha/regfile.hh:
Changed the integer register file into a class instead of a typedef to an array. Also put the parts of the register file, ie the int, float, and misc register files, pc, npc, and nnpc, behind accessor functions. Added a changeContext function, and ContextParam and ContextVal types, so that things like the register window can be changed through call backs.
arch/mips/isa_traits.hh:
Turned the integer register file into a class instead of a typedef to an array. Also moved a "using namespace" into the namespace definition.
arch/sparc/isa_traits.hh:
Turned the integer register file into a class instead of a typedef to an array. Also "fixed" the max number of src and dest regs. They may need to be even larger.
arch/sparc/regfile.hh:
Changed the integer register file into a class instead of a typedef to an array. Also put the parts of the register file, ie the int, float, and misc register files, pc, npc, and nnpc, behind accessor functions. Added a changeContext function, and ContextParam and ContextVal types, so that things like the register window can be changed through call backs. Created setCWP and setAltGlobals functions for the IntRegFile.
cpu/cpu_exec_context.hh:
Used the accessor functions for the register file, and added a changeRegFileContext function to call back into the RegFile. Used the RegFile clear function rather than memsetting it to 0.
cpu/exec_context.hh:
Added the changeRegFileContext function.
cpu/exetrace.cc:
Use the TheISA::NumIntRegs constant, and use readReg now that the integer register file is a class instead of an array.
cpu/exetrace.hh:
Get the address of the regs object, now that it isn't an array.
--HG--
extra : convert_revision : ea2dd81be1c2e66b3c684af319eb58f8a77fd49c
2006-04-06 20:47:03 +02:00
|
|
|
}
|
2006-05-08 00:50:41 +02:00
|
|
|
}
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
StaticInstPtr decodeInst(ExtMachInst);
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
static inline ExtMachInst
|
|
|
|
makeExtMI(MachInst inst, const uint64_t &pc) {
|
|
|
|
#if FULL_SYSTEM
|
|
|
|
ExtMachInst ext_inst = inst;
|
|
|
|
if (pc && 0x1)
|
|
|
|
return ext_inst|=(static_cast<ExtMachInst>(pc & 0x1) << 32);
|
|
|
|
else
|
|
|
|
return ext_inst;
|
|
|
|
#else
|
|
|
|
return ExtMachInst(inst);
|
|
|
|
#endif
|
|
|
|
}
|
2006-03-08 08:05:38 +01:00
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
/**
|
|
|
|
* Function to insure ISA semantics about 0 registers.
|
|
|
|
* @param xc The execution context.
|
|
|
|
*/
|
|
|
|
template <class XC>
|
|
|
|
void zeroRegisters(XC *xc);
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
const Addr MaxAddr = (Addr)-1;
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
void copyRegs(ExecContext *src, ExecContext *dest);
|
2006-02-22 04:02:05 +01:00
|
|
|
|
2006-05-08 00:50:41 +02:00
|
|
|
uint64_t convert_and_round(uint32_t fp_val, ConvertType cvt_type, int rnd_mode = 0);
|
|
|
|
uint64_t convert_and_round(uint64_t fp_val, ConvertType cvt_type, int rnd_mode = 0);
|
|
|
|
uint64_t convert_and_round(double fp_val, ConvertType cvt_type, int rnd_mode = 0);
|
|
|
|
|
|
|
|
// Machine operations
|
|
|
|
|
|
|
|
void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
|
|
|
|
int regnum);
|
|
|
|
|
|
|
|
void restoreMachineReg(RegFile ®s, const AnyReg ®,
|
|
|
|
int regnum);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void serializeSpecialRegs(const Serializable::Proxy &proxy,
|
|
|
|
const RegFile ®s);
|
|
|
|
|
|
|
|
static void unserializeSpecialRegs(const IniFile *db,
|
|
|
|
const std::string &category,
|
|
|
|
ConfigNode *node,
|
|
|
|
RegFile ®s);
|
|
|
|
#endif
|
2006-02-22 04:02:05 +01:00
|
|
|
|
|
|
|
static inline Addr alignAddress(const Addr &addr,
|
|
|
|
unsigned int nbytes) {
|
|
|
|
return (addr & ~(nbytes - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instruction address compression hooks
|
|
|
|
static inline Addr realPCToFetchPC(const Addr &addr) {
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Addr fetchPCToRealPC(const Addr &addr) {
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the size of "fetched" instructions (not necessarily the size
|
|
|
|
// of real instructions for PISA)
|
|
|
|
static inline size_t fetchInstSize() {
|
|
|
|
return sizeof(MachInst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline MachInst makeRegisterCopy(int dest, int src) {
|
|
|
|
panic("makeRegisterCopy not implemented");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-25 01:57:17 +01:00
|
|
|
};
|
|
|
|
|
2006-02-22 04:02:05 +01:00
|
|
|
#if FULL_SYSTEM
|
2006-01-25 01:57:17 +01:00
|
|
|
|
2006-02-20 20:48:10 +01:00
|
|
|
#include "arch/mips/mips34k.hh"
|
2006-05-08 00:50:41 +02:00
|
|
|
|
2006-01-25 01:57:17 +01:00
|
|
|
#endif
|
|
|
|
|
2006-03-12 11:57:34 +01:00
|
|
|
using namespace MipsISA;
|
|
|
|
|
2006-01-26 22:19:44 +01:00
|
|
|
#endif // __ARCH_MIPS_ISA_TRAITS_HH__
|