tru64.hh
来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· HH 代码 · 共 1,211 行 · 第 1/3 页
HH
1,211 行
/* * 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. * * 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. * * Authors: Nathan L. Binkert * Ali G. Saidi */#ifndef __TRU64_HH__#define __TRU64_HH__#include "config/full_system.hh"#include "kern/operatingsystem.hh"#if FULL_SYSTEMclass Tru64 {};#else //!FULL_SYSTEM#include <sys/types.h>#include <sys/stat.h>#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD__)#include <sys/param.h>#include <sys/mount.h>#else#include <sys/statfs.h>#endif#include <dirent.h>#include <errno.h>#include <fcntl.h>#include <string.h> // for memset()#include <unistd.h>#include "cpu/base.hh"#include "sim/core.hh"#include "sim/syscall_emul.hh"typedef struct stat global_stat;typedef struct statfs global_statfs;typedef struct dirent global_dirent;class TranslatingPort;////// This class encapsulates the types, structures, constants,/// functions, and syscall-number mappings specific to the Alpha Tru64/// syscall interface.///class Tru64 : public OperatingSystem{ 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; //@} /// 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. }; /// Limit struct for getrlimit/setrlimit. struct rlimit { uint64_t rlim_cur; //!< soft limit uint64_t rlim_max; //!< hard limit }; /// 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 gettimeofday. struct timeval { uint32_t tv_sec; //!< seconds uint32_t tv_usec; //!< microseconds }; /// 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(). 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 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(TranslatingPort *mem, Addr addr, global_statfs *host) { using namespace TheISA;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?