process.cc revision 4188
14309Sgblack@eecs.umich.edu/* 24309Sgblack@eecs.umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan 35426Sgblack@eecs.umich.edu * All rights reserved. 44309Sgblack@eecs.umich.edu * 54309Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 64309Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 74309Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 84309Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 94309Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 104309Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 114309Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 124309Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 134309Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 144309Sgblack@eecs.umich.edu * this software without specific prior written permission. 154309Sgblack@eecs.umich.edu * 164309Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174309Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184309Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194309Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204309Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214309Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224309Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234309Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244309Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254309Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264309Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274309Sgblack@eecs.umich.edu * 284309Sgblack@eecs.umich.edu * Authors: Steve Reinhardt 294309Sgblack@eecs.umich.edu * Gabe Black 304309Sgblack@eecs.umich.edu * Ali Saidi 314309Sgblack@eecs.umich.edu */ 324309Sgblack@eecs.umich.edu 334309Sgblack@eecs.umich.edu#include "arch/sparc/isa_traits.hh" 344309Sgblack@eecs.umich.edu#include "arch/sparc/linux/process.hh" 354309Sgblack@eecs.umich.edu#include "arch/sparc/regfile.hh" 364309Sgblack@eecs.umich.edu 374309Sgblack@eecs.umich.edu#include "base/trace.hh" 384309Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 394309Sgblack@eecs.umich.edu#include "kern/linux/linux.hh" 404309Sgblack@eecs.umich.edu 414309Sgblack@eecs.umich.edu#include "sim/process.hh" 424309Sgblack@eecs.umich.edu#include "sim/syscall_emul.hh" 434309Sgblack@eecs.umich.edu 444309Sgblack@eecs.umich.eduusing namespace std; 454309Sgblack@eecs.umich.eduusing namespace SparcISA; 464309Sgblack@eecs.umich.edu 474309Sgblack@eecs.umich.eduSyscallDesc* 484309Sgblack@eecs.umich.eduSparcLinuxProcess::getDesc(int callnum) 494309Sgblack@eecs.umich.edu{ 504309Sgblack@eecs.umich.edu if (callnum < 0 || callnum > Num_Syscall_Descs) 514309Sgblack@eecs.umich.edu return NULL; 524309Sgblack@eecs.umich.edu return &syscallDescs[callnum]; 534309Sgblack@eecs.umich.edu} 544309Sgblack@eecs.umich.edu 554309Sgblack@eecs.umich.eduSyscallDesc* 564309Sgblack@eecs.umich.eduSparcLinuxProcess::getDesc32(int callnum) 574309Sgblack@eecs.umich.edu{ 584533Sgblack@eecs.umich.edu if (callnum < 0 || callnum > Num_Syscall32_Descs) 594679Sgblack@eecs.umich.edu return NULL; 604679Sgblack@eecs.umich.edu return &syscall32Descs[callnum]; 614679Sgblack@eecs.umich.edu} 624533Sgblack@eecs.umich.edu 634533Sgblack@eecs.umich.eduSparcLinuxProcess::SparcLinuxProcess() : 644537Sgblack@eecs.umich.edu Num_Syscall_Descs(284), //sizeof(syscallDescs) / sizeof(SyscallDesc)), 654533Sgblack@eecs.umich.edu Num_Syscall32_Descs(299) //sizeof(syscall32Descs) / sizeof(SyscallDesc)) 664528Sgblack@eecs.umich.edu{ 675666Sgblack@eecs.umich.edu // The sparc syscall table must be <= 284 entries because that is all there 685666Sgblack@eecs.umich.edu // is space for. 695666Sgblack@eecs.umich.edu assert(Num_Syscall_Descs <= 284); 704528Sgblack@eecs.umich.edu // The sparc 32 bit syscall table bust be <= 299 entries because that is 714528Sgblack@eecs.umich.edu // all there is space for. 724528Sgblack@eecs.umich.edu assert(Num_Syscall_Descs <= 299); 734528Sgblack@eecs.umich.edu} 744605Sgblack@eecs.umich.edu 755666Sgblack@eecs.umich.eduSparc32LinuxProcess::Sparc32LinuxProcess(const std::string &name, 765666Sgblack@eecs.umich.edu ObjectFile *objFile, 774528Sgblack@eecs.umich.edu System * system, 784615Sgblack@eecs.umich.edu int stdin_fd, 794615Sgblack@eecs.umich.edu int stdout_fd, 804615Sgblack@eecs.umich.edu int stderr_fd, 815045Sgblack@eecs.umich.edu std::vector<std::string> &argv, 825045Sgblack@eecs.umich.edu std::vector<std::string> &envp, 834615Sgblack@eecs.umich.edu const std::string &cwd, 844615Sgblack@eecs.umich.edu uint64_t _uid, uint64_t _euid, 854615Sgblack@eecs.umich.edu uint64_t _gid, uint64_t _egid, 865291Sgblack@eecs.umich.edu uint64_t _pid, uint64_t _ppid) 875428Sgblack@eecs.umich.edu : Sparc32LiveProcess(name, objFile, system, 885428Sgblack@eecs.umich.edu stdin_fd, stdout_fd, stderr_fd, argv, envp, cwd, 895428Sgblack@eecs.umich.edu _uid, _euid, _gid, _egid, _pid, _ppid) 905428Sgblack@eecs.umich.edu{} 915428Sgblack@eecs.umich.edu 925294Sgblack@eecs.umich.eduvoid Sparc32LinuxProcess::handleTrap(int trapNum, ThreadContext *tc) 935291Sgblack@eecs.umich.edu{ 945291Sgblack@eecs.umich.edu switch(trapNum) 955294Sgblack@eecs.umich.edu { 965294Sgblack@eecs.umich.edu case 0x10: //Linux 32 bit syscall trap 975294Sgblack@eecs.umich.edu tc->syscall(tc->readIntReg(1)); 984615Sgblack@eecs.umich.edu break; 994615Sgblack@eecs.umich.edu default: 1004615Sgblack@eecs.umich.edu SparcLiveProcess::handleTrap(trapNum, tc); 1015029Sgblack@eecs.umich.edu } 1025029Sgblack@eecs.umich.edu} 1034615Sgblack@eecs.umich.edu 1045029Sgblack@eecs.umich.eduSparc64LinuxProcess::Sparc64LinuxProcess(const std::string &name, 1055029Sgblack@eecs.umich.edu ObjectFile *objFile, 1065161Sgblack@eecs.umich.edu System * system, 1075161Sgblack@eecs.umich.edu int stdin_fd, 1084863Sgblack@eecs.umich.edu int stdout_fd, 1094615Sgblack@eecs.umich.edu int stderr_fd, 1104615Sgblack@eecs.umich.edu std::vector<std::string> &argv, 1114615Sgblack@eecs.umich.edu std::vector<std::string> &envp, 1124615Sgblack@eecs.umich.edu const std::string &cwd, 1134953Sgblack@eecs.umich.edu uint64_t _uid, uint64_t _euid, 1144615Sgblack@eecs.umich.edu uint64_t _gid, uint64_t _egid, 1154615Sgblack@eecs.umich.edu uint64_t _pid, uint64_t _ppid) 1164863Sgblack@eecs.umich.edu : Sparc64LiveProcess(name, objFile, system, 1174863Sgblack@eecs.umich.edu stdin_fd, stdout_fd, stderr_fd, argv, envp, cwd, 1185326Sgblack@eecs.umich.edu _uid, _euid, _gid, _egid, _pid, _ppid) 1195326Sgblack@eecs.umich.edu{} 1205326Sgblack@eecs.umich.edu 1215326Sgblack@eecs.umich.eduvoid Sparc64LinuxProcess::handleTrap(int trapNum, ThreadContext *tc) 1225326Sgblack@eecs.umich.edu{ 1235326Sgblack@eecs.umich.edu switch(trapNum) 1245326Sgblack@eecs.umich.edu { 1255326Sgblack@eecs.umich.edu //case 0x10: //Linux 32 bit syscall trap 1265326Sgblack@eecs.umich.edu case 0x6d: //Linux 64 bit syscall trap 1274863Sgblack@eecs.umich.edu tc->syscall(tc->readIntReg(1)); 1284863Sgblack@eecs.umich.edu break; 1294863Sgblack@eecs.umich.edu default: 1304863Sgblack@eecs.umich.edu SparcLiveProcess::handleTrap(trapNum, tc); 1314863Sgblack@eecs.umich.edu } 1324620Sgblack@eecs.umich.edu} 1335149Sgblack@eecs.umich.edu