process.hh revision 5128:69fb816fa927
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    virtual void flushWindows(ThreadContext *tc) = 0;
70};
71
72struct M5_32_auxv_t
73{
74    int32_t a_type;
75    union {
76        int32_t a_val;
77        int32_t a_ptr;
78        int32_t a_fcn;
79    };
80
81    M5_32_auxv_t()
82    {}
83
84    M5_32_auxv_t(int32_t type, int32_t val);
85};
86
87class Sparc32LiveProcess : public SparcLiveProcess
88{
89  protected:
90
91    std::vector<M5_32_auxv_t> auxv;
92
93    Sparc32LiveProcess(const std::string &nm, ObjectFile *objFile,
94                System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
95                std::vector<std::string> &argv,
96                std::vector<std::string> &envp,
97                const std::string &cwd,
98                uint64_t _uid, uint64_t _euid,
99                uint64_t _gid, uint64_t _egid,
100                uint64_t _pid, uint64_t _ppid) :
101            SparcLiveProcess(nm, objFile, _system,
102                         stdin_fd, stdout_fd, stderr_fd,
103                         argv, envp, cwd,
104                         _uid, _euid, _gid, _egid, _pid, _ppid)
105    {
106        // Set up stack. On SPARC Linux, stack goes from the top of memory
107        // downward, less the hole for the kernel address space.
108        stack_base = (Addr)0xf0000000ULL;
109
110        // Set up region for mmaps.
111        mmap_start = mmap_end = 0x70000000;
112    }
113
114    void startup();
115
116  public:
117
118    void argsInit(int intSize, int pageSize);
119
120    void flushWindows(ThreadContext *tc);
121};
122
123struct M5_64_auxv_t
124{
125    int64_t a_type;
126    union {
127        int64_t a_val;
128        int64_t a_ptr;
129        int64_t a_fcn;
130    };
131
132    M5_64_auxv_t()
133    {}
134
135    M5_64_auxv_t(int64_t type, int64_t val);
136};
137
138class Sparc64LiveProcess : public SparcLiveProcess
139{
140  protected:
141
142    static const Addr StackBias = 2047;
143
144    std::vector<M5_64_auxv_t> auxv;
145
146    Sparc64LiveProcess(const std::string &nm, ObjectFile *objFile,
147                System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
148                std::vector<std::string> &argv,
149                std::vector<std::string> &envp,
150                const std::string &cwd,
151                uint64_t _uid, uint64_t _euid,
152                uint64_t _gid, uint64_t _egid,
153                uint64_t _pid, uint64_t _ppid) :
154            SparcLiveProcess(nm, objFile, _system,
155                         stdin_fd, stdout_fd, stderr_fd,
156                         argv, envp, cwd,
157                         _uid, _euid, _gid, _egid, _pid, _ppid)
158    {
159        // Set up stack. On SPARC Linux, stack goes from the top of memory
160        // downward, less the hole for the kernel address space.
161        stack_base = (Addr)0x80000000000ULL;
162
163        // Set up region for mmaps.  Tru64 seems to start just above 0 and
164        // grow up from there.
165        mmap_start = mmap_end = 0xfffff80000000000ULL;
166    }
167
168    void startup();
169
170  public:
171
172    void argsInit(int intSize, int pageSize);
173
174    void flushWindows(ThreadContext *tc);
175};
176
177#endif // __SPARC_PROCESS_HH__
178