process.hh revision 4111
1/* 2 * Copyright (c) 2003-2004 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 * Ali Saidi 30 */ 31 32#ifndef __SPARC_PROCESS_HH__ 33#define __SPARC_PROCESS_HH__ 34 35#include <string> 36#include <vector> 37#include "sim/process.hh" 38 39class ObjectFile; 40class System; 41 42class SparcLiveProcess : public LiveProcess 43{ 44 protected: 45 46 //The locations of the fill and spill handlers 47 Addr fillStart, spillStart; 48 49 SparcLiveProcess(const std::string &nm, ObjectFile *objFile, 50 System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 51 std::vector<std::string> &argv, 52 std::vector<std::string> &envp, 53 const std::string &cwd, 54 uint64_t _uid, uint64_t _euid, 55 uint64_t _gid, uint64_t _egid, 56 uint64_t _pid, uint64_t _ppid); 57 58 public: 59 60 //Handles traps which request services from the operating system 61 virtual void handleTrap(int trapNum, ThreadContext *tc); 62 63 Addr readFillStart() 64 { return fillStart; } 65 66 Addr readSpillStart() 67 { return spillStart; } 68 69}; 70 71struct M5_32_auxv_t 72{ 73 int32_t a_type; 74 union { 75 int32_t a_val; 76 int32_t a_ptr; 77 int32_t a_fcn; 78 }; 79 80 M5_32_auxv_t() 81 {} 82 83 M5_32_auxv_t(int32_t type, int32_t val); 84}; 85 86class Sparc32LiveProcess : public SparcLiveProcess 87{ 88 protected: 89 90 std::vector<M5_32_auxv_t> auxv; 91 92 Sparc32LiveProcess(const std::string &nm, ObjectFile *objFile, 93 System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 94 std::vector<std::string> &argv, 95 std::vector<std::string> &envp, 96 const std::string &cwd, 97 uint64_t _uid, uint64_t _euid, 98 uint64_t _gid, uint64_t _egid, 99 uint64_t _pid, uint64_t _ppid) : 100 SparcLiveProcess(nm, objFile, _system, 101 stdin_fd, stdout_fd, stderr_fd, 102 argv, envp, cwd, 103 _uid, _euid, _gid, _egid, _pid, _ppid) 104 { 105 // Set up stack. On SPARC Linux, stack goes from the top of memory 106 // downward, less the hole for the kernel address space. 107 stack_base = (Addr)0xf0000000ULL; 108 109 // Set up region for mmaps. 110 mmap_start = mmap_end = 0x70000000; 111 } 112 113 void startup(); 114 115 public: 116 117 void argsInit(int intSize, int pageSize); 118 119}; 120 121struct M5_64_auxv_t 122{ 123 int64_t a_type; 124 union { 125 int64_t a_val; 126 int64_t a_ptr; 127 int64_t a_fcn; 128 }; 129 130 M5_64_auxv_t() 131 {} 132 133 M5_64_auxv_t(int64_t type, int64_t val); 134}; 135 136class Sparc64LiveProcess : public SparcLiveProcess 137{ 138 protected: 139 140 static const Addr StackBias = 2047; 141 142 std::vector<M5_64_auxv_t> auxv; 143 144 Sparc64LiveProcess(const std::string &nm, ObjectFile *objFile, 145 System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 146 std::vector<std::string> &argv, 147 std::vector<std::string> &envp, 148 const std::string &cwd, 149 uint64_t _uid, uint64_t _euid, 150 uint64_t _gid, uint64_t _egid, 151 uint64_t _pid, uint64_t _ppid) : 152 SparcLiveProcess(nm, objFile, _system, 153 stdin_fd, stdout_fd, stderr_fd, 154 argv, envp, cwd, 155 _uid, _euid, _gid, _egid, _pid, _ppid) 156 { 157 // Set up stack. On SPARC Linux, stack goes from the top of memory 158 // downward, less the hole for the kernel address space. 159 stack_base = (Addr)0x80000000000ULL; 160 161 // Set up region for mmaps. Tru64 seems to start just above 0 and 162 // grow up from there. 163 mmap_start = mmap_end = 0xfffff80000000000ULL; 164 } 165 166 void startup(); 167 168 public: 169 170 void argsInit(int intSize, int pageSize); 171 172}; 173 174#endif // __SPARC_PROCESS_HH__ 175