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

📄 alpha_tru64_process.cc

📁 linux下基于c++的处理器仿真平台。具有处理器流水线
💻 CC
📖 第 1 页 / 共 5 页
字号:
    struct tbl_sysinfo {	uint64_t si_user;	//!< User time	uint64_t si_nice;	//!< Nice time	uint64_t si_sys;	//!< System time	uint64_t si_idle;	//!< Idle time	uint64_t si_hz;		//!< hz	uint64_t si_phz;	//!< phz	uint64_t si_boottime;	//!< Boot time in seconds	uint64_t wait;		//!< Wait time	uint32_t  si_max_procs;	//!< rpb->rpb_numprocs	uint32_t  pad;		//!< padding    };    /// For stack_create.    struct vm_stack {	// was void *	Addr	address;	//!< address hint	size_t	rsize;		//!< red zone size	size_t	ysize;		//!< yellow zone size	size_t	gsize;		//!< green zone size	size_t	swap;		//!< amount of swap to reserve	size_t	incr;		//!< growth increment	uint64_t	align;		//!< address alignment	uint64_t	flags;		//!< MAP_FIXED etc.	// was struct memalloc_attr *	Addr	attr;		//!< allocation policy	uint64_t reserved;	//!< reserved    };    /// Return values for nxm calls.    enum {	KERN_NOT_RECEIVER = 7,	KERN_NOT_IN_SET = 12    };    /// For nxm_task_init.    static const int NXM_TASK_INIT_VP = 2;	//!< initial thread is VP    /// Task attribute structure.    struct nxm_task_attr {	int64_t nxm_callback;	//!< nxm_callback	unsigned int nxm_version;	//!< nxm_version	unsigned short nxm_uniq_offset;	//!< nxm_uniq_offset	unsigned short flags;	//!< flags	int nxm_quantum;	//!< nxm_quantum	int pad1;		//!< pad1	int64_t pad2;		//!< pad2    };    /// Signal set.    typedef uint64_t   sigset_t;    /// Thread state shared between user & kernel.    struct ushared_state {	sigset_t        sigmask;        //!< thread signal mask	sigset_t        sig;            //!< thread pending mask	// struct nxm_pth_state *	Addr pth_id; //!< out-of-line state	int             flags;          //!< shared flags#define US_SIGSTACK     0x1             // thread called sigaltstack#define US_ONSTACK      0x2             // thread is running on altstack#define US_PROFILE      0x4             // thread called profil#define US_SYSCALL      0x8             // thread in syscall#define US_TRAP         0x10            // thread has trapped#define US_YELLOW       0x20            // thread has mellowed yellow#define US_YZONE        0x40            // thread has zoned out#define US_FP_OWNED     0x80            // thread used floating point	int             cancel_state;   //!< thread's cancelation state#define US_CANCEL         0x1           // cancel pending#define US_NOCANCEL       0X2           // synch cancel disabled#define US_SYS_NOCANCEL   0x4           // syscall cancel disabled#define US_ASYNC_NOCANCEL 0x8           // asynch cancel disabled#define US_CANCEL_BITS  (US_NOCANCEL|US_SYS_NOCANCEL|US_ASYNC_NOCANCEL)#define US_CANCEL_MASK  (US_CANCEL|US_NOCANCEL|US_SYS_NOCANCEL| \                         US_ASYNC_NOCANCEL)	// These are semi-shared. They are always visible to	// the kernel but are never context-switched by the library.	int             nxm_ssig;       //!< scheduler's synchronous signals	int             reserved1;	//!< reserved1	int64_t            nxm_active;     //!< scheduler active	int64_t            reserved2;	//!< reserved2    };    struct nxm_sched_state {	struct          ushared_state nxm_u;    //!< state own by user thread	unsigned int    nxm_bits;               //!< scheduler state / slot	int             nxm_quantum;            //!< quantum count-down value	int             nxm_set_quantum;        //!< quantum reset value	int             nxm_sysevent;           //!< syscall state	// struct nxm_upcall *	Addr	    nxm_uc_ret; //!< stack ptr of null thread	// void *	Addr nxm_tid;               //!< scheduler's thread id	int64_t            nxm_va;                 //!< page fault address	// struct nxm_pth_state *	Addr nxm_pthid; //!< id of null thread	uint64_t   nxm_bound_pcs_count;    //!< bound PCS thread count	int64_t            pad[2];	   //!< pad    };    /// nxm_shared.    struct nxm_shared {	int64_t nxm_callback;              //!< address of upcall routine	unsigned int nxm_version;       //!< version number	unsigned short nxm_uniq_offset; //!< correction factor for TEB	unsigned short pad1;		//!< pad1	int64_t space[2];                  //!< future growth	struct nxm_sched_state nxm_ss[1]; //!< array of shared areas    };    /// nxm_slot_state_t.    enum nxm_slot_state_t {	NXM_SLOT_AVAIL,	NXM_SLOT_BOUND,	NXM_SLOT_UNBOUND,	NXM_SLOT_EMPTY    };    /// nxm_config_info    struct nxm_config_info {	int nxm_nslots_per_rad;         //!< max number of VP slots per RAD	int nxm_nrads;                  //!< max number of RADs	// nxm_slot_state_t *	Addr nxm_slot_state; //!< per-VP slot state	// struct nxm_shared *	Addr nxm_rad[1];  //!< per-RAD shared areas    };    /// For nxm_thread_create.    enum nxm_thread_type {	NXM_TYPE_SCS	= 0,	NXM_TYPE_VP		= 1,	NXM_TYPE_MANAGER	= 2    };    /// Thread attributes.    struct nxm_thread_attr {	int version;	//!< version	int type;	//!< type	int cancel_flags;	//!< cancel_flags	int priority;	//!< priority	int policy;	//!< policy	int signal_type;	//!< signal_type	// void *	Addr pthid;	//!< pthid	sigset_t sigmask;	//!< sigmask	/// Initial register values.	struct {	    uint64_t pc;	//!< pc	    uint64_t sp;	//!< sp	    uint64_t a0;	//!< a0	} registers;	uint64_t pad2[2];	//!< pad2    };    /// Helper function to convert a host stat buffer to a target stat    /// buffer.  Also copies the target buffer out to the simulated    /// memory space.  Used by stat(), fstat(), and lstat().    template <class T>    static void    copyOutStatBuf(FunctionalMemory *mem, Addr addr, global_stat *host)    {	TypedBufferArg<T> tgt(addr);	tgt->st_dev = host->st_dev;	tgt->st_ino = host->st_ino;	tgt->st_mode = host->st_mode;	tgt->st_nlink = host->st_nlink;	tgt->st_uid = host->st_uid;	tgt->st_gid = host->st_gid;	tgt->st_rdev = host->st_rdev;	tgt->st_size = host->st_size;	tgt->st_atimeX = host->st_atime;	tgt->st_mtimeX = host->st_mtime;	tgt->st_ctimeX = host->st_ctime;	tgt->st_blksize = host->st_blksize;	tgt->st_blocks = host->st_blocks;	tgt.copyOut(mem);    }    /// Helper function to convert a host statfs buffer to a target statfs    /// buffer.  Also copies the target buffer out to the simulated    /// memory space.  Used by statfs() and fstatfs().    template <class T>    static void    copyOutStatfsBuf(FunctionalMemory *mem, Addr addr, global_statfs *host)    {	TypedBufferArg<T> tgt(addr);#if defined(__OpenBSD__)	tgt->f_type = 0;#else	tgt->f_type = host->f_type;#endif	tgt->f_bsize = host->f_bsize;	tgt->f_blocks = host->f_blocks;	tgt->f_bfree = host->f_bfree;	tgt->f_bavail = host->f_bavail;	tgt->f_files = host->f_files;	tgt->f_ffree = host->f_ffree;	memcpy(&tgt->f_fsid, &host->f_fsid, sizeof(host->f_fsid)); 	tgt.copyOut(mem);    }    class F64 {      public:	static void copyOutStatBuf(FunctionalMemory *mem, Addr addr,				   global_stat *host)	{	    Tru64::copyOutStatBuf<Tru64::F64_stat>(mem, addr, host);	}	static void copyOutStatfsBuf(FunctionalMemory *mem, Addr addr,				     global_statfs *host)	{	    Tru64::copyOutStatfsBuf<Tru64::F64_statfs>(mem, addr, host);	}    };        class PreF64 {      public:	static void copyOutStatBuf(FunctionalMemory *mem, Addr addr,				   global_stat *host)	{	    Tru64::copyOutStatBuf<Tru64::pre_F64_stat>(mem, addr, host);	}	static void copyOutStatfsBuf(FunctionalMemory *mem, Addr addr,				     global_statfs *host)	{	    Tru64::copyOutStatfsBuf<Tru64::pre_F64_statfs>(mem, addr, host);	}    };        /// Helper function to convert a host stat buffer to an old pre-F64    /// (4.x) target stat buffer.  Also copies the target buffer out to    /// the simulated memory space.  Used by pre_F64_stat(),    /// pre_F64_fstat(), and pre_F64_lstat().    static void    copyOutPreF64StatBuf(FunctionalMemory *mem, Addr addr, struct stat *host)    {	TypedBufferArg<Tru64::pre_F64_stat> tgt(addr);	tgt->st_dev = host->st_dev;	tgt->st_ino = host->st_ino;	tgt->st_mode = host->st_mode;	tgt->st_nlink = host->st_nlink;	tgt->st_uid = host->st_uid;	tgt->st_gid = host->st_gid;	tgt->st_rdev = host->st_rdev;	tgt->st_size = host->st_size;	tgt->st_atimeX = host->st_atime;	tgt->st_mtimeX = host->st_mtime;	tgt->st_ctimeX = host->st_ctime;	tgt->st_blksize = host->st_blksize;	tgt->st_blocks = host->st_blocks;	tgt.copyOut(mem);    }        /// The target system's hostname.    static const char *hostname;    /// Target uname() handler.    static SyscallReturn     unameFunc(SyscallDesc *desc, int callnum, Process *process,	      ExecContext *xc)    {	TypedBufferArg<Tru64::utsname> name(xc->getSyscallArg(0));	strcpy(name->sysname, "OSF1");	strcpy(name->nodename, hostname);	strcpy(name->release, "V5.1");	strcpy(name->version, "732");	strcpy(name->machine, "alpha");	name.copyOut(xc->mem);	return 0;    }    /// Target getsysyinfo() handler.    static SyscallReturn    getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,		   ExecContext *xc)    {	unsigned op = xc->getSyscallArg(0);	unsigned nbytes = xc->getSyscallArg(2);	switch (op) {	  case Tru64::GSI_MAX_CPU: {	      TypedBufferArg<uint32_t> max_cpu(xc->getSyscallArg(1));	      *max_cpu = process->numCpus();	      max_cpu.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_CPUS_IN_BOX: {	      TypedBufferArg<uint32_t> cpus_in_box(xc->getSyscallArg(1));	      *cpus_in_box = process->numCpus();	      cpus_in_box.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_PHYSMEM: {	      TypedBufferArg<uint64_t> physmem(xc->getSyscallArg(1));	      *physmem = 1024 * 1024;	// physical memory in KB	      physmem.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_CPU_INFO: {	      TypedBufferArg<Tru64::cpu_info> infop(xc->getSyscallArg(1));	      infop->current_cpu = 0;	      infop->cpus_in_box = process->numCpus();	      infop->cpu_type = 57;	      infop->ncpus = process->numCpus();	      int cpumask = (1 << process->numCpus()) - 1;	      infop->cpus_present = infop->cpus_running = cpumask;	      infop->cpu_binding = 0;	      infop->cpu_ex_binding = 0;	      infop->mhz = 667;	      infop.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_PROC_TYPE: {	      TypedBufferArg<uint64_t> proc_type(xc->getSyscallArg(1));	      *proc_type = 11;	      proc_type.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_PLATFORM_NAME: {	      BufferArg bufArg(xc->getSyscallArg(1), nbytes);	      strncpy((char *)bufArg.bufferPtr(),		      "COMPAQ Professional Workstation XP1000",		      nbytes);	      bufArg.copyOut(xc->mem);	      return 1;	  }	  case Tru64::GSI_CLK_TCK: {	      TypedBufferArg<uint64_t> clk_hz(xc->getSyscallArg(1));	      *clk_hz = 1024;	      clk_hz.copyOut(xc->mem);	      return 1;	  }	  default:	    warn("getsysinfo: unknown op %d\n", op);	    break;	}	return 0;    }    /// Target setsysyinfo() handler.    static SyscallReturn    setsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,		   ExecContext *xc)    {	unsigned op = xc->getSyscallArg(0);	switch (op) {	  case SSI_IEEE_FP_CONTROL:	    warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n",		 xc->getSyscallArg(1));

⌨️ 快捷键说明

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