process.cc
来自「M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作」· CC 代码 · 共 588 行 · 第 1/3 页
CC
588 行
/* * Copyright (c) 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: Steven K. Reinhardt * Ali G. Saidi */#include "arch/alpha/linux/linux.hh"#include "arch/alpha/linux/process.hh"#include "arch/alpha/isa_traits.hh"#include "base/trace.hh"#include "cpu/thread_context.hh"#include "kern/linux/linux.hh"#include "sim/process.hh"#include "sim/syscall_emul.hh"using namespace std;using namespace AlphaISA;/// Target uname() handler.static SyscallReturnunameFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *tc){ TypedBufferArg<Linux::utsname> name(tc->getSyscallArg(0)); strcpy(name->sysname, "Linux"); strcpy(name->nodename, "m5.eecs.umich.edu"); strcpy(name->release, "2.4.20"); strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "alpha"); name.copyOut(tc->getMemPort()); return 0;}/// Target osf_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 SyscallReturnosf_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *tc){ unsigned op = tc->getSyscallArg(0); // unsigned nbytes = tc->getSyscallArg(2); switch (op) { case 45: { // GSI_IEEE_FP_CONTROL TypedBufferArg<uint64_t> fpcr(tc->getSyscallArg(1)); // I don't think this exactly matches the HW FPCR *fpcr = 0; fpcr.copyOut(tc->getMemPort()); return 0; } default: cerr << "osf_getsysinfo: unknown op " << op << endl; abort(); break; } return 1;}/// Target osf_setsysinfo() handler.static SyscallReturnosf_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *tc){ unsigned op = tc->getSyscallArg(0); // unsigned nbytes = tc->getSyscallArg(2); switch (op) { case 14: { // SSI_IEEE_FP_CONTROL TypedBufferArg<uint64_t> fpcr(tc->getSyscallArg(1)); // I don't think this exactly matches the HW FPCR fpcr.copyIn(tc->getMemPort()); DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): " " setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr)); return 0; } default: cerr << "osf_setsysinfo: unknown op " << op << endl; abort(); break; } return 1;}SyscallDesc AlphaLinuxProcess::syscallDescs[] = { /* 0 */ SyscallDesc("osf_syscall", unimplementedFunc), /* 1 */ SyscallDesc("exit", exitFunc), /* 2 */ SyscallDesc("fork", unimplementedFunc), /* 3 */ SyscallDesc("read", readFunc), /* 4 */ SyscallDesc("write", writeFunc), /* 5 */ SyscallDesc("osf_old_open", unimplementedFunc), /* 6 */ SyscallDesc("close", closeFunc), /* 7 */ SyscallDesc("osf_wait4", unimplementedFunc), /* 8 */ SyscallDesc("osf_old_creat", unimplementedFunc), /* 9 */ SyscallDesc("link", unimplementedFunc), /* 10 */ SyscallDesc("unlink", unlinkFunc), /* 11 */ SyscallDesc("osf_execve", unimplementedFunc), /* 12 */ SyscallDesc("chdir", unimplementedFunc), /* 13 */ SyscallDesc("fchdir", unimplementedFunc), /* 14 */ SyscallDesc("mknod", unimplementedFunc), /* 15 */ SyscallDesc("chmod", chmodFunc<AlphaLinux>), /* 16 */ SyscallDesc("chown", chownFunc), /* 17 */ SyscallDesc("brk", obreakFunc), /* 18 */ SyscallDesc("osf_getfsstat", unimplementedFunc), /* 19 */ SyscallDesc("lseek", lseekFunc), /* 20 */ SyscallDesc("getxpid", getpidPseudoFunc), /* 21 */ SyscallDesc("osf_mount", unimplementedFunc), /* 22 */ SyscallDesc("umount", unimplementedFunc), /* 23 */ SyscallDesc("setuid", setuidFunc), /* 24 */ SyscallDesc("getxuid", getuidPseudoFunc), /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc), /* 26 */ SyscallDesc("osf_ptrace", unimplementedFunc), /* 27 */ SyscallDesc("osf_nrecvmsg", unimplementedFunc), /* 28 */ SyscallDesc("osf_nsendmsg", unimplementedFunc), /* 29 */ SyscallDesc("osf_nrecvfrom", unimplementedFunc), /* 30 */ SyscallDesc("osf_naccept", unimplementedFunc), /* 31 */ SyscallDesc("osf_ngetpeername", unimplementedFunc), /* 32 */ SyscallDesc("osf_ngetsockname", unimplementedFunc), /* 33 */ SyscallDesc("access", unimplementedFunc), /* 34 */ SyscallDesc("osf_chflags", unimplementedFunc), /* 35 */ SyscallDesc("osf_fchflags", unimplementedFunc), /* 36 */ SyscallDesc("sync", unimplementedFunc), /* 37 */ SyscallDesc("kill", unimplementedFunc), /* 38 */ SyscallDesc("osf_old_stat", unimplementedFunc), /* 39 */ SyscallDesc("setpgid", unimplementedFunc), /* 40 */ SyscallDesc("osf_old_lstat", unimplementedFunc), /* 41 */ SyscallDesc("dup", dupFunc), /* 42 */ SyscallDesc("pipe", pipePseudoFunc), /* 43 */ SyscallDesc("osf_set_program_attributes", unimplementedFunc), /* 44 */ SyscallDesc("osf_profil", unimplementedFunc), /* 45 */ SyscallDesc("open", openFunc<AlphaLinux>), /* 46 */ SyscallDesc("osf_old_sigaction", unimplementedFunc), /* 47 */ SyscallDesc("getxgid", getgidPseudoFunc), /* 48 */ SyscallDesc("osf_sigprocmask", ignoreFunc), /* 49 */ SyscallDesc("osf_getlogin", unimplementedFunc), /* 50 */ SyscallDesc("osf_setlogin", unimplementedFunc), /* 51 */ SyscallDesc("acct", unimplementedFunc), /* 52 */ SyscallDesc("sigpending", unimplementedFunc), /* 53 */ SyscallDesc("osf_classcntl", unimplementedFunc), /* 54 */ SyscallDesc("ioctl", ioctlFunc<AlphaLinux>), /* 55 */ SyscallDesc("osf_reboot", unimplementedFunc), /* 56 */ SyscallDesc("osf_revoke", unimplementedFunc), /* 57 */ SyscallDesc("symlink", unimplementedFunc), /* 58 */ SyscallDesc("readlink", unimplementedFunc), /* 59 */ SyscallDesc("execve", unimplementedFunc), /* 60 */ SyscallDesc("umask", unimplementedFunc), /* 61 */ SyscallDesc("chroot", unimplementedFunc), /* 62 */ SyscallDesc("osf_old_fstat", unimplementedFunc), /* 63 */ SyscallDesc("getpgrp", unimplementedFunc), /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc), /* 65 */ SyscallDesc("osf_mremap", unimplementedFunc), /* 66 */ SyscallDesc("vfork", unimplementedFunc), /* 67 */ SyscallDesc("stat", statFunc<AlphaLinux>), /* 68 */ SyscallDesc("lstat", lstatFunc<AlphaLinux>), /* 69 */ SyscallDesc("osf_sbrk", unimplementedFunc), /* 70 */ SyscallDesc("osf_sstk", unimplementedFunc), /* 71 */ SyscallDesc("mmap", mmapFunc<AlphaLinux>), /* 72 */ SyscallDesc("osf_old_vadvise", unimplementedFunc),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?