process.hh (12431:000549e1f497) process.hh (13583:f7482392b097)
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 <memory>
36#include <string>
37#include <vector>
38
39#include "arch/sparc/isa_traits.hh"
40#include "base/loader/object_file.hh"
41#include "mem/page_table.hh"
42#include "sim/byteswap.hh"
43#include "sim/process.hh"
44
45class SparcProcess : public Process
46{
47 protected:
48
49 const Addr StackBias;
50
51 // The locations of the fill and spill handlers
52 Addr fillStart, spillStart;
53
54 SparcProcess(ProcessParams * params, ObjectFile *objFile,
55 Addr _StackBias);
56
57 void initState();
58
59 template<class IntType>
60 void argsInit(int pageSize);
61
62 public:
63
64 // Handles traps which request services from the operating system
65 virtual void handleTrap(int trapNum, ThreadContext *tc, Fault *fault);
66
67 Addr readFillStart() { return fillStart; }
68 Addr readSpillStart() { return spillStart; }
69
70 virtual void flushWindows(ThreadContext *tc) = 0;
71 void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
72};
73
74class Sparc32Process : public SparcProcess
75{
76 protected:
77
78 Sparc32Process(ProcessParams * params, ObjectFile *objFile)
79 : SparcProcess(params, objFile, 0)
80 {
81 Addr brk_point = objFile->dataBase() + objFile->dataSize() +
82 objFile->bssSize();
83 brk_point = roundUp(brk_point, SparcISA::PageBytes);
84
85 // Reserve 8M for main stack.
86 Addr max_stack_size = 8 * 1024 * 1024;
87
88 // Set up stack. On SPARC Linux, stack goes from the top of memory
89 // downward, less the hole for the kernel address space.
90 Addr stack_base = 0xf0000000ULL;
91
92 // Set pointer for next thread stack.
93 Addr next_thread_stack_base = stack_base - max_stack_size;
94
95 // Set up region for mmaps.
96 Addr mmap_end = 0x70000000;
97
98 memState = std::make_shared<MemState>(brk_point, stack_base,
99 max_stack_size,
100 next_thread_stack_base,
101 mmap_end);
102 }
103
104 void initState();
105
106 public:
107
108 void argsInit(int intSize, int pageSize);
109
110 void flushWindows(ThreadContext *tc);
111
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 <memory>
36#include <string>
37#include <vector>
38
39#include "arch/sparc/isa_traits.hh"
40#include "base/loader/object_file.hh"
41#include "mem/page_table.hh"
42#include "sim/byteswap.hh"
43#include "sim/process.hh"
44
45class SparcProcess : public Process
46{
47 protected:
48
49 const Addr StackBias;
50
51 // The locations of the fill and spill handlers
52 Addr fillStart, spillStart;
53
54 SparcProcess(ProcessParams * params, ObjectFile *objFile,
55 Addr _StackBias);
56
57 void initState();
58
59 template<class IntType>
60 void argsInit(int pageSize);
61
62 public:
63
64 // Handles traps which request services from the operating system
65 virtual void handleTrap(int trapNum, ThreadContext *tc, Fault *fault);
66
67 Addr readFillStart() { return fillStart; }
68 Addr readSpillStart() { return spillStart; }
69
70 virtual void flushWindows(ThreadContext *tc) = 0;
71 void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
72};
73
74class Sparc32Process : public SparcProcess
75{
76 protected:
77
78 Sparc32Process(ProcessParams * params, ObjectFile *objFile)
79 : SparcProcess(params, objFile, 0)
80 {
81 Addr brk_point = objFile->dataBase() + objFile->dataSize() +
82 objFile->bssSize();
83 brk_point = roundUp(brk_point, SparcISA::PageBytes);
84
85 // Reserve 8M for main stack.
86 Addr max_stack_size = 8 * 1024 * 1024;
87
88 // Set up stack. On SPARC Linux, stack goes from the top of memory
89 // downward, less the hole for the kernel address space.
90 Addr stack_base = 0xf0000000ULL;
91
92 // Set pointer for next thread stack.
93 Addr next_thread_stack_base = stack_base - max_stack_size;
94
95 // Set up region for mmaps.
96 Addr mmap_end = 0x70000000;
97
98 memState = std::make_shared<MemState>(brk_point, stack_base,
99 max_stack_size,
100 next_thread_stack_base,
101 mmap_end);
102 }
103
104 void initState();
105
106 public:
107
108 void argsInit(int intSize, int pageSize);
109
110 void flushWindows(ThreadContext *tc);
111
112 SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
112 RegVal getSyscallArg(ThreadContext *tc, int &i);
113 /// Explicitly import the otherwise hidden getSyscallArg
114 using Process::getSyscallArg;
115
113 /// Explicitly import the otherwise hidden getSyscallArg
114 using Process::getSyscallArg;
115
116 void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
116 void setSyscallArg(ThreadContext *tc, int i, RegVal val);
117};
118
119class Sparc64Process : public SparcProcess
120{
121 protected:
122
123 Sparc64Process(ProcessParams * params, ObjectFile *objFile)
124 : SparcProcess(params, objFile, 2047)
125 {
126 Addr brk_point = objFile->dataBase() + objFile->dataSize() +
127 objFile->bssSize();
128 brk_point = roundUp(brk_point, SparcISA::PageBytes);
129
130 Addr max_stack_size = 8 * 1024 * 1024;
131
132 // Set up stack. On SPARC Linux, stack goes from the top of memory
133 // downward, less the hole for the kernel address space.
134 Addr stack_base = 0x80000000000ULL;
135
136 // Set pointer for next thread stack. Reserve 8M for main stack.
137 Addr next_thread_stack_base = stack_base - max_stack_size;
138
139 // Set up region for mmaps.
140 Addr mmap_end = 0xfffff80000000000ULL;
141
142 memState = std::make_shared<MemState>(brk_point, stack_base,
143 max_stack_size,
144 next_thread_stack_base,
145 mmap_end);
146 }
147
148 void initState();
149
150 public:
151
152 void argsInit(int intSize, int pageSize);
153
154 void flushWindows(ThreadContext *tc);
155
117};
118
119class Sparc64Process : public SparcProcess
120{
121 protected:
122
123 Sparc64Process(ProcessParams * params, ObjectFile *objFile)
124 : SparcProcess(params, objFile, 2047)
125 {
126 Addr brk_point = objFile->dataBase() + objFile->dataSize() +
127 objFile->bssSize();
128 brk_point = roundUp(brk_point, SparcISA::PageBytes);
129
130 Addr max_stack_size = 8 * 1024 * 1024;
131
132 // Set up stack. On SPARC Linux, stack goes from the top of memory
133 // downward, less the hole for the kernel address space.
134 Addr stack_base = 0x80000000000ULL;
135
136 // Set pointer for next thread stack. Reserve 8M for main stack.
137 Addr next_thread_stack_base = stack_base - max_stack_size;
138
139 // Set up region for mmaps.
140 Addr mmap_end = 0xfffff80000000000ULL;
141
142 memState = std::make_shared<MemState>(brk_point, stack_base,
143 max_stack_size,
144 next_thread_stack_base,
145 mmap_end);
146 }
147
148 void initState();
149
150 public:
151
152 void argsInit(int intSize, int pageSize);
153
154 void flushWindows(ThreadContext *tc);
155
156 SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
156 RegVal getSyscallArg(ThreadContext *tc, int &i);
157 /// Explicitly import the otherwise hidden getSyscallArg
158 using Process::getSyscallArg;
159
157 /// Explicitly import the otherwise hidden getSyscallArg
158 using Process::getSyscallArg;
159
160 void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
160 void setSyscallArg(ThreadContext *tc, int i, RegVal val);
161};
162
163#endif // __SPARC_PROCESS_HH__
161};
162
163#endif // __SPARC_PROCESS_HH__