⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alpha_tru64_process.cc

📁 linux下基于c++的处理器仿真平台。具有处理器流水线
💻 CC
📖 第 1 页 / 共 5 页
字号:
/* * Copyright (c) 2001, 2002, 2003, 2004, 2005 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator, developed by Nathan Binkert, * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions * from Ron Dreslinski, Dave Greene, Lisa Hsu, Kevin Lim, Ali Saidi, * and Andrew Schultz. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. */#include <sys/types.h>#include <sys/stat.h>#if defined(__OpenBSD__)#include <sys/param.h>#include <sys/mount.h>#else#include <sys/statfs.h>#endif#include <dirent.h>#include <errno.h>#include <fcntl.h>	// for host open() flags#include <string.h>	// for memset()#include <unistd.h>#include "arch/alpha/alpha_common_syscall_emul.hh"#include "arch/alpha/alpha_tru64_process.hh"#include "base/trace.hh"#include "cpu/base.hh"#include "cpu/exec_context.hh"#include "mem/functional/functional.hh"#include "sim/fake_syscall.hh"#include "sim/host.hh"#include "sim/process.hh"#include "sim/root.hh"#include "sim/syscall_emul.hh"using namespace std;typedef struct stat global_stat;typedef struct statfs global_statfs;typedef struct dirent global_dirent;////// This class encapsulates the types, structures, constants,/// functions, and syscall-number mappings specific to the Alpha Tru64/// syscall interface.///class Tru64 {  public:    //@{    /// Basic Tru64 types.    typedef uint64_t size_t;    typedef uint64_t off_t;    typedef uint16_t nlink_t;    typedef int32_t  dev_t;    typedef uint32_t uid_t;    typedef uint32_t gid_t;    typedef uint32_t time_t;    typedef uint32_t mode_t;    typedef uint32_t ino_t;    typedef struct { int val[2]; } quad;    typedef quad fsid_t;    //@}    //@{    /// open(2) flag values.    static const int TGT_O_RDONLY	= 00000000;    static const int TGT_O_WRONLY	= 00000001;    static const int TGT_O_RDWR	 	= 00000002;    static const int TGT_O_NONBLOCK 	= 00000004;    static const int TGT_O_APPEND	= 00000010;    static const int TGT_O_CREAT	= 00001000;    static const int TGT_O_TRUNC	= 00002000;    static const int TGT_O_EXCL	 	= 00004000;    static const int TGT_O_NOCTTY	= 00010000;    static const int TGT_O_SYNC	 	= 00040000;    static const int TGT_O_DRD	 	= 00100000;    static const int TGT_O_DIRECTIO  	= 00200000;    static const int TGT_O_CACHE	= 00400000;    static const int TGT_O_DSYNC	= 02000000;    static const int TGT_O_RSYNC	= 04000000;    //@}    /// 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;    /// Stat buffer.  Note that Tru64 v5.0+ use a new "F64" stat    /// structure, and a new set of syscall numbers for stat calls.    /// On some hosts (notably Linux) define st_atime, st_mtime, and    /// st_ctime as macros, so we append an X to get around this.    struct F64_stat {	dev_t	st_dev;			//!< st_dev	int32_t	st_retired1;		//!< st_retired1	mode_t	st_mode;		//!< st_mode	nlink_t	st_nlink;		//!< st_nlink	uint16_t st_nlink_reserved;	//!< st_nlink_reserved	uid_t	st_uid;			//!< st_uid	gid_t	st_gid;			//!< st_gid	dev_t	st_rdev;		//!< st_rdev	dev_t	st_ldev;		//!< st_ldev	off_t	st_size;		//!< st_size	time_t	st_retired2;		//!< st_retired2	int32_t	st_uatime;		//!< st_uatime	time_t	st_retired3;		//!< st_retired3	int32_t	st_umtime;		//!< st_umtime	time_t	st_retired4;		//!< st_retired4	int32_t	st_uctime;		//!< st_uctime	int32_t	st_retired5;		//!< st_retired5	int32_t	st_retired6;		//!< st_retired6	uint32_t	st_flags;	//!< st_flags	uint32_t	st_gen;		//!< st_gen	uint64_t	st_spare[4];	//!< st_spare[4]	ino_t	st_ino;			//!< st_ino	int32_t	st_ino_reserved;	//!< st_ino_reserved	time_t	st_atimeX;		//!< st_atime	int32_t	st_atime_reserved;	//!< st_atime_reserved	time_t	st_mtimeX;		//!< st_mtime	int32_t	st_mtime_reserved;	//!< st_mtime_reserved	time_t	st_ctimeX;		//!< st_ctime	int32_t	st_ctime_reserved;	//!< st_ctime_reserved	uint64_t	st_blksize;	//!< st_blksize	uint64_t	st_blocks;	//!< st_blocks    };    /// Old Tru64 v4.x stat struct.    /// Tru64 maintains backwards compatibility with v4.x by    /// implementing another set of stat functions using the old    /// structure definition and binding them to the old syscall    /// numbers.    struct pre_F64_stat {        dev_t   st_dev;        ino_t   st_ino;        mode_t  st_mode;        nlink_t st_nlink;        uid_t   st_uid;        gid_t   st_gid;        dev_t   st_rdev;        off_t   st_size;        time_t  st_atimeX;        int32_t st_uatime;        time_t  st_mtimeX;        int32_t st_umtime;        time_t  st_ctimeX;        int32_t st_uctime;        uint32_t st_blksize;        int32_t st_blocks;        uint32_t st_flags;        uint32_t st_gen;    };    /// For statfs().    struct F64_statfs {	int16_t   f_type;        int16_t   f_flags;        int32_t     f_retired1;        int32_t     f_retired2;        int32_t     f_retired3;        int32_t     f_retired4;        int32_t     f_retired5;        int32_t     f_retired6;        int32_t     f_retired7;        fsid_t	f_fsid;        int32_t     f_spare[9];        char    f_retired8[90];        char    f_retired9[90];        uint64_t dummy[10]; // was union mount_info mount_info;        uint64_t  f_flags2;        int64_t    f_spare2[14];        int64_t    f_fsize;        int64_t    f_bsize;        int64_t    f_blocks;        int64_t    f_bfree;        int64_t    f_bavail;        int64_t    f_files;        int64_t    f_ffree;        char    f_mntonname[1024];        char    f_mntfromname[1024];    };    /// For old Tru64 v4.x statfs()    struct pre_F64_statfs {        int16_t   f_type;        int16_t   f_flags;        int32_t     f_fsize;        int32_t     f_bsize;        int32_t     f_blocks;        int32_t     f_bfree;        int32_t     f_bavail;        int32_t     f_files;        int32_t     f_ffree;        fsid_t  f_fsid;        int32_t     f_spare[9];        char    f_mntonname[90];        char    f_mntfromname[90];        uint64_t dummy[10]; // was union mount_info mount_info;    };    /// For getdirentries().    struct dirent    {	ino_t d_ino;		//!< file number of entry	uint16_t d_reclen;	//!< length of this record	uint16_t d_namlen;	//!< length of string in d_name	char d_name[256];	//!< dummy name length    };    /// Length of strings in struct utsname (plus 1 for null char).    static const int _SYS_NMLN = 32;    /// Interface struct for uname().    struct utsname {	char sysname[_SYS_NMLN];        //!< System name. 	char nodename[_SYS_NMLN];       //!< Node name.	char release[_SYS_NMLN];        //!< OS release.  	char version[_SYS_NMLN];        //!< OS version.  	char machine[_SYS_NMLN];        //!< Machine type.    };    //@{    /// ioctl() command codes.    static const unsigned TIOCGETP   = 0x40067408;    static const unsigned TIOCSETP   = 0x80067409;    static const unsigned TIOCSETN   = 0x8006740a;    static const unsigned TIOCSETC   = 0x80067411;    static const unsigned TIOCGETC   = 0x40067412;    static const unsigned FIONREAD   = 0x4004667f;    static const unsigned TIOCISATTY = 0x2000745e;    // TIOCGETS not defined in tru64, so I made up a number    static const unsigned TIOCGETS   = 0x40000000;    static const unsigned TIOCGETA   = 0x402c7413;    //@}    /// Resource enumeration for getrlimit().    enum rlimit_resources {	RLIMIT_CPU = 0,	RLIMIT_FSIZE = 1,	RLIMIT_DATA = 2,	RLIMIT_STACK = 3,	RLIMIT_CORE = 4,	RLIMIT_RSS = 5,	RLIMIT_NOFILE = 6,	RLIMIT_AS = 7,	RLIMIT_VMEM = 7    };    /// Limit struct for getrlimit/setrlimit.    struct rlimit { 	uint64_t  rlim_cur;	//!< soft limit	uint64_t  rlim_max;	//!< hard limit    };    /// For mmap().    static const unsigned TGT_MAP_ANONYMOUS = 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 getsysinfo() GSI_CPU_INFO option.    struct cpu_info {	uint32_t     current_cpu;	//!< current_cpu	uint32_t     cpus_in_box;	//!< cpus_in_box	uint32_t     cpu_type;		//!< cpu_type	uint32_t     ncpus;		//!< ncpus	uint64_t     cpus_present;	//!< cpus_present	uint64_t     cpus_running;	//!< cpus_running	uint64_t     cpu_binding;	//!< cpu_binding	uint64_t     cpu_ex_binding;	//!< cpu_ex_binding	uint32_t     mhz;		//!< mhz	uint32_t     unused[3];		//!< future expansion    };    //@{    /// For setsysinfo().    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()    //@}    /// For gettimeofday.    struct timeval {	uint32_t tv_sec;	//!< seconds	uint32_t tv_usec;	//!< microseconds    };    //@{    /// For getrusage().    static const int RUSAGE_THREAD = 1;    static const int RUSAGE_SELF = 0;    static const int RUSAGE_CHILDREN = -1;    //@}    /// For getrusage().    struct rusage {	struct timeval ru_utime;	//!< user time used	struct timeval ru_stime;	//!< system time used	uint64_t ru_maxrss;		//!< ru_maxrss	uint64_t ru_ixrss;		//!< integral shared memory size	uint64_t ru_idrss;		//!< integral unshared data "	uint64_t ru_isrss;		//!< integral unshared stack "	uint64_t ru_minflt;		//!< page reclaims - total vmfaults	uint64_t ru_majflt;		//!< page faults	uint64_t ru_nswap;		//!< swaps	uint64_t ru_inblock;		//!< block input operations	uint64_t ru_oublock;		//!< block output operations	uint64_t ru_msgsnd;		//!< messages sent	uint64_t ru_msgrcv;		//!< messages received	uint64_t ru_nsignals;		//!< signals received	uint64_t ru_nvcsw;		//!< voluntary context switches	uint64_t ru_nivcsw;		//!< involuntary "    };    /// For sigreturn().    struct sigcontext {	int64_t sc_onstack;		//!< sigstack state to restore	int64_t sc_mask;		//!< signal mask to restore	int64_t sc_pc;			//!< pc at time of signal	int64_t sc_ps;			//!< psl to retore	int64_t sc_regs[32];		//!< processor regs 0 to 31	int64_t sc_ownedfp;		//!< fp has been used	int64_t sc_fpregs[32];		//!< fp regs 0 to 31	uint64_t sc_fpcr;		//!< floating point control reg	uint64_t sc_fp_control;		//!< software fpcr	int64_t sc_reserved1;		//!< reserved for kernel	uint32_t sc_kreserved1;		//!< reserved for kernel	uint32_t sc_kreserved2;		//!< reserved for kernel	size_t  sc_ssize;		//!< stack size	caddr_t sc_sbase;		//!< stack start	uint64_t sc_traparg_a0;		//!< a0 argument to trap on exc	uint64_t sc_traparg_a1;		//!< a1 argument to trap on exc	uint64_t sc_traparg_a2;		//!< a2 argument to trap on exc	uint64_t sc_fp_trap_pc;		//!< imprecise pc	uint64_t sc_fp_trigger_sum;	//!< Exception summary at trigg	uint64_t sc_fp_trigger_inst; 	//!< Instruction at trigger pc    };    /// For table().    static const int TBL_SYSINFO = 12;    /// For table().

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -