process.cc (11886:43b882cada33) process.cc (11905:4a771f8756ad)
1/*
2 * Copyright (c) 2007-2008 The Florida State University
3 * Copyright (c) 2009 The University of Edinburgh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Stephen Hines
30 * Timothy M. Jones
31 */
32
33#include "arch/power/process.hh"
34
35#include "arch/power/isa_traits.hh"
36#include "arch/power/types.hh"
37#include "base/loader/elf_object.hh"
38#include "base/loader/object_file.hh"
39#include "base/misc.hh"
40#include "cpu/thread_context.hh"
41#include "debug/Stack.hh"
42#include "mem/page_table.hh"
43#include "sim/aux_vector.hh"
44#include "sim/process_impl.hh"
45#include "sim/syscall_return.hh"
46#include "sim/system.hh"
47
48using namespace std;
49using namespace PowerISA;
50
51PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile)
52 : Process(params, objFile)
53{
1/*
2 * Copyright (c) 2007-2008 The Florida State University
3 * Copyright (c) 2009 The University of Edinburgh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Stephen Hines
30 * Timothy M. Jones
31 */
32
33#include "arch/power/process.hh"
34
35#include "arch/power/isa_traits.hh"
36#include "arch/power/types.hh"
37#include "base/loader/elf_object.hh"
38#include "base/loader/object_file.hh"
39#include "base/misc.hh"
40#include "cpu/thread_context.hh"
41#include "debug/Stack.hh"
42#include "mem/page_table.hh"
43#include "sim/aux_vector.hh"
44#include "sim/process_impl.hh"
45#include "sim/syscall_return.hh"
46#include "sim/system.hh"
47
48using namespace std;
49using namespace PowerISA;
50
51PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile)
52 : Process(params, objFile)
53{
54 memState->stackBase = 0xbf000000L;
54 // Set up break point (Top of Heap)
55 Addr brk_point = objFile->dataBase() + objFile->dataSize() +
56 objFile->bssSize();
57 brk_point = roundUp(brk_point, PageBytes);
55
58
56 // Set pointer for next thread stack. Reserve 8M for main stack.
57 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
59 Addr stack_base = 0xbf000000L;
58
60
59 // Set up break point (Top of Heap)
60 memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
61 objFile->bssSize();
62 memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
61 Addr max_stack_size = 8 * 1024 * 1024;
63
62
63 // Set pointer for next thread stack. Reserve 8M for main stack.
64 Addr next_thread_stack_base = stack_base - max_stack_size;
65
64 // Set up region for mmaps. For now, start at bottom of kuseg space.
66 // Set up region for mmaps. For now, start at bottom of kuseg space.
65 memState->mmapEnd = 0x70000000L;
67 Addr mmap_end = 0x70000000L;
68
69 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
70 next_thread_stack_base, mmap_end);
66}
67
68void
69PowerProcess::initState()
70{
71 Process::initState();
72
73 argsInit(MachineBytes, PageBytes);
74}
75
76void
77PowerProcess::argsInit(int intSize, int pageSize)
78{
79 typedef AuxVector<uint32_t> auxv_t;
80 std::vector<auxv_t> auxv;
81
82 string filename;
83 if (argv.size() < 1)
84 filename = "";
85 else
86 filename = argv[0];
87
88 //We want 16 byte alignment
89 uint64_t align = 16;
90
91 // Patch the ld_bias for dynamic executables.
92 updateBias();
93
94 // load object file into target memory
95 objFile->loadSections(initVirtMem);
96
97 //Setup the auxilliary vectors. These will already have endian conversion.
98 //Auxilliary vectors are loaded only for elf formatted executables.
99 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
100 if (elfObject) {
101 uint32_t features = 0;
102
103 //Bits which describe the system hardware capabilities
104 //XXX Figure out what these should be
105 auxv.push_back(auxv_t(M5_AT_HWCAP, features));
106 //The system page size
107 auxv.push_back(auxv_t(M5_AT_PAGESZ, PowerISA::PageBytes));
108 //Frequency at which times() increments
109 auxv.push_back(auxv_t(M5_AT_CLKTCK, 0x64));
110 // For statically linked executables, this is the virtual address of the
111 // program header tables if they appear in the executable image
112 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
113 // This is the size of a program header entry from the elf file.
114 auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
115 // This is the number of program headers from the original elf file.
116 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
117 // This is the base address of the ELF interpreter; it should be
118 // zero for static executables or contain the base address for
119 // dynamic executables.
120 auxv.push_back(auxv_t(M5_AT_BASE, getBias()));
121 //XXX Figure out what this should be.
122 auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
123 //The entry point to the program
124 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
125 //Different user and group IDs
126 auxv.push_back(auxv_t(M5_AT_UID, uid()));
127 auxv.push_back(auxv_t(M5_AT_EUID, euid()));
128 auxv.push_back(auxv_t(M5_AT_GID, gid()));
129 auxv.push_back(auxv_t(M5_AT_EGID, egid()));
130 //Whether to enable "secure mode" in the executable
131 auxv.push_back(auxv_t(M5_AT_SECURE, 0));
132 //The filename of the program
133 auxv.push_back(auxv_t(M5_AT_EXECFN, 0));
134 //The string "v51" with unknown meaning
135 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0));
136 }
137
138 //Figure out how big the initial stack nedes to be
139
140 // A sentry NULL void pointer at the top of the stack.
141 int sentry_size = intSize;
142
143 string platform = "v51";
144 int platform_size = platform.size() + 1;
145
146 // The aux vectors are put on the stack in two groups. The first group are
147 // the vectors that are generated as the elf is loaded. The second group
148 // are the ones that were computed ahead of time and include the platform
149 // string.
150 int aux_data_size = filename.size() + 1;
151
152 int env_data_size = 0;
153 for (int i = 0; i < envp.size(); ++i) {
154 env_data_size += envp[i].size() + 1;
155 }
156 int arg_data_size = 0;
157 for (int i = 0; i < argv.size(); ++i) {
158 arg_data_size += argv[i].size() + 1;
159 }
160
161 int info_block_size =
162 sentry_size + env_data_size + arg_data_size +
163 aux_data_size + platform_size;
164
165 //Each auxilliary vector is two 4 byte words
166 int aux_array_size = intSize * 2 * (auxv.size() + 1);
167
168 int envp_array_size = intSize * (envp.size() + 1);
169 int argv_array_size = intSize * (argv.size() + 1);
170
171 int argc_size = intSize;
172
173 //Figure out the size of the contents of the actual initial frame
174 int frame_size =
175 info_block_size +
176 aux_array_size +
177 envp_array_size +
178 argv_array_size +
179 argc_size;
180
181 //There needs to be padding after the auxiliary vector data so that the
182 //very bottom of the stack is aligned properly.
183 int partial_size = frame_size;
184 int aligned_partial_size = roundUp(partial_size, align);
185 int aux_padding = aligned_partial_size - partial_size;
186
187 int space_needed = frame_size + aux_padding;
188
71}
72
73void
74PowerProcess::initState()
75{
76 Process::initState();
77
78 argsInit(MachineBytes, PageBytes);
79}
80
81void
82PowerProcess::argsInit(int intSize, int pageSize)
83{
84 typedef AuxVector<uint32_t> auxv_t;
85 std::vector<auxv_t> auxv;
86
87 string filename;
88 if (argv.size() < 1)
89 filename = "";
90 else
91 filename = argv[0];
92
93 //We want 16 byte alignment
94 uint64_t align = 16;
95
96 // Patch the ld_bias for dynamic executables.
97 updateBias();
98
99 // load object file into target memory
100 objFile->loadSections(initVirtMem);
101
102 //Setup the auxilliary vectors. These will already have endian conversion.
103 //Auxilliary vectors are loaded only for elf formatted executables.
104 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
105 if (elfObject) {
106 uint32_t features = 0;
107
108 //Bits which describe the system hardware capabilities
109 //XXX Figure out what these should be
110 auxv.push_back(auxv_t(M5_AT_HWCAP, features));
111 //The system page size
112 auxv.push_back(auxv_t(M5_AT_PAGESZ, PowerISA::PageBytes));
113 //Frequency at which times() increments
114 auxv.push_back(auxv_t(M5_AT_CLKTCK, 0x64));
115 // For statically linked executables, this is the virtual address of the
116 // program header tables if they appear in the executable image
117 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
118 // This is the size of a program header entry from the elf file.
119 auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
120 // This is the number of program headers from the original elf file.
121 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
122 // This is the base address of the ELF interpreter; it should be
123 // zero for static executables or contain the base address for
124 // dynamic executables.
125 auxv.push_back(auxv_t(M5_AT_BASE, getBias()));
126 //XXX Figure out what this should be.
127 auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
128 //The entry point to the program
129 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
130 //Different user and group IDs
131 auxv.push_back(auxv_t(M5_AT_UID, uid()));
132 auxv.push_back(auxv_t(M5_AT_EUID, euid()));
133 auxv.push_back(auxv_t(M5_AT_GID, gid()));
134 auxv.push_back(auxv_t(M5_AT_EGID, egid()));
135 //Whether to enable "secure mode" in the executable
136 auxv.push_back(auxv_t(M5_AT_SECURE, 0));
137 //The filename of the program
138 auxv.push_back(auxv_t(M5_AT_EXECFN, 0));
139 //The string "v51" with unknown meaning
140 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0));
141 }
142
143 //Figure out how big the initial stack nedes to be
144
145 // A sentry NULL void pointer at the top of the stack.
146 int sentry_size = intSize;
147
148 string platform = "v51";
149 int platform_size = platform.size() + 1;
150
151 // The aux vectors are put on the stack in two groups. The first group are
152 // the vectors that are generated as the elf is loaded. The second group
153 // are the ones that were computed ahead of time and include the platform
154 // string.
155 int aux_data_size = filename.size() + 1;
156
157 int env_data_size = 0;
158 for (int i = 0; i < envp.size(); ++i) {
159 env_data_size += envp[i].size() + 1;
160 }
161 int arg_data_size = 0;
162 for (int i = 0; i < argv.size(); ++i) {
163 arg_data_size += argv[i].size() + 1;
164 }
165
166 int info_block_size =
167 sentry_size + env_data_size + arg_data_size +
168 aux_data_size + platform_size;
169
170 //Each auxilliary vector is two 4 byte words
171 int aux_array_size = intSize * 2 * (auxv.size() + 1);
172
173 int envp_array_size = intSize * (envp.size() + 1);
174 int argv_array_size = intSize * (argv.size() + 1);
175
176 int argc_size = intSize;
177
178 //Figure out the size of the contents of the actual initial frame
179 int frame_size =
180 info_block_size +
181 aux_array_size +
182 envp_array_size +
183 argv_array_size +
184 argc_size;
185
186 //There needs to be padding after the auxiliary vector data so that the
187 //very bottom of the stack is aligned properly.
188 int partial_size = frame_size;
189 int aligned_partial_size = roundUp(partial_size, align);
190 int aux_padding = aligned_partial_size - partial_size;
191
192 int space_needed = frame_size + aux_padding;
193
189 memState->stackMin = memState->stackBase - space_needed;
190 memState->stackMin = roundDown(memState->stackMin, align);
191 memState->stackSize = memState->stackBase - memState->stackMin;
194 Addr stack_min = memState->getStackBase() - space_needed;
195 stack_min = roundDown(stack_min, align);
192
196
197 memState->setStackSize(memState->getStackBase() - stack_min);
198
193 // map memory
199 // map memory
194 allocateMem(roundDown(memState->stackMin, pageSize),
195 roundUp(memState->stackSize, pageSize));
200 allocateMem(roundDown(stack_min, pageSize),
201 roundUp(memState->getStackSize(), pageSize));
196
197 // map out initial stack contents
202
203 // map out initial stack contents
198 uint32_t sentry_base = memState->stackBase - sentry_size;
204 uint32_t sentry_base = memState->getStackBase() - sentry_size;
199 uint32_t aux_data_base = sentry_base - aux_data_size;
200 uint32_t env_data_base = aux_data_base - env_data_size;
201 uint32_t arg_data_base = env_data_base - arg_data_size;
202 uint32_t platform_base = arg_data_base - platform_size;
203 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
204 uint32_t envp_array_base = auxv_array_base - envp_array_size;
205 uint32_t argv_array_base = envp_array_base - argv_array_size;
206 uint32_t argc_base = argv_array_base - argc_size;
207
208 DPRINTF(Stack, "The addresses of items on the initial stack:\n");
209 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
210 DPRINTF(Stack, "0x%x - env data\n", env_data_base);
211 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
212 DPRINTF(Stack, "0x%x - platform base\n", platform_base);
213 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
214 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
215 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
216 DPRINTF(Stack, "0x%x - argc \n", argc_base);
205 uint32_t aux_data_base = sentry_base - aux_data_size;
206 uint32_t env_data_base = aux_data_base - env_data_size;
207 uint32_t arg_data_base = env_data_base - arg_data_size;
208 uint32_t platform_base = arg_data_base - platform_size;
209 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
210 uint32_t envp_array_base = auxv_array_base - envp_array_size;
211 uint32_t argv_array_base = envp_array_base - argv_array_size;
212 uint32_t argc_base = argv_array_base - argc_size;
213
214 DPRINTF(Stack, "The addresses of items on the initial stack:\n");
215 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
216 DPRINTF(Stack, "0x%x - env data\n", env_data_base);
217 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
218 DPRINTF(Stack, "0x%x - platform base\n", platform_base);
219 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
220 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
221 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
222 DPRINTF(Stack, "0x%x - argc \n", argc_base);
217 DPRINTF(Stack, "0x%x - stack min\n", memState->stackMin);
223 DPRINTF(Stack, "0x%x - stack min\n", stack_min);
218
219 // write contents to stack
220
221 // figure out argc
222 uint32_t argc = argv.size();
223 uint32_t guestArgc = PowerISA::htog(argc);
224
225 //Write out the sentry void *
226 uint32_t sentry_NULL = 0;
227 initVirtMem.writeBlob(sentry_base,
228 (uint8_t*)&sentry_NULL, sentry_size);
229
230 //Fix up the aux vectors which point to other data
231 for (int i = auxv.size() - 1; i >= 0; i--) {
232 if (auxv[i].a_type == M5_AT_PLATFORM) {
233 auxv[i].a_val = platform_base;
234 initVirtMem.writeString(platform_base, platform.c_str());
235 } else if (auxv[i].a_type == M5_AT_EXECFN) {
236 auxv[i].a_val = aux_data_base;
237 initVirtMem.writeString(aux_data_base, filename.c_str());
238 }
239 }
240
241 //Copy the aux stuff
242 for (int x = 0; x < auxv.size(); x++)
243 {
244 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
245 (uint8_t*)&(auxv[x].a_type), intSize);
246 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
247 (uint8_t*)&(auxv[x].a_val), intSize);
248 }
249 //Write out the terminating zeroed auxilliary vector
250 const uint64_t zero = 0;
251 initVirtMem.writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
252 (uint8_t*)&zero, 2 * intSize);
253
254 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
255 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
256
257 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
258
259 ThreadContext *tc = system->getThreadContext(contextIds[0]);
260
261 //Set the stack pointer register
224
225 // write contents to stack
226
227 // figure out argc
228 uint32_t argc = argv.size();
229 uint32_t guestArgc = PowerISA::htog(argc);
230
231 //Write out the sentry void *
232 uint32_t sentry_NULL = 0;
233 initVirtMem.writeBlob(sentry_base,
234 (uint8_t*)&sentry_NULL, sentry_size);
235
236 //Fix up the aux vectors which point to other data
237 for (int i = auxv.size() - 1; i >= 0; i--) {
238 if (auxv[i].a_type == M5_AT_PLATFORM) {
239 auxv[i].a_val = platform_base;
240 initVirtMem.writeString(platform_base, platform.c_str());
241 } else if (auxv[i].a_type == M5_AT_EXECFN) {
242 auxv[i].a_val = aux_data_base;
243 initVirtMem.writeString(aux_data_base, filename.c_str());
244 }
245 }
246
247 //Copy the aux stuff
248 for (int x = 0; x < auxv.size(); x++)
249 {
250 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
251 (uint8_t*)&(auxv[x].a_type), intSize);
252 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
253 (uint8_t*)&(auxv[x].a_val), intSize);
254 }
255 //Write out the terminating zeroed auxilliary vector
256 const uint64_t zero = 0;
257 initVirtMem.writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
258 (uint8_t*)&zero, 2 * intSize);
259
260 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
261 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
262
263 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
264
265 ThreadContext *tc = system->getThreadContext(contextIds[0]);
266
267 //Set the stack pointer register
262 tc->setIntReg(StackPointerReg, memState->stackMin);
268 tc->setIntReg(StackPointerReg, stack_min);
263
264 tc->pcState(getStartPC());
265
266 //Align the "stack_min" to a page boundary.
269
270 tc->pcState(getStartPC());
271
272 //Align the "stack_min" to a page boundary.
267 memState->stackMin = roundDown(memState->stackMin, pageSize);
273 memState->setStackMin(roundDown(stack_min, pageSize));
268}
269
270PowerISA::IntReg
271PowerProcess::getSyscallArg(ThreadContext *tc, int &i)
272{
273 assert(i < 5);
274 return tc->readIntReg(ArgumentReg0 + i++);
275}
276
277void
278PowerProcess::setSyscallArg(ThreadContext *tc, int i, PowerISA::IntReg val)
279{
280 assert(i < 5);
281 tc->setIntReg(ArgumentReg0 + i, val);
282}
283
284void
285PowerProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
286{
287 Cr cr = tc->readIntReg(INTREG_CR);
288 if (sysret.successful()) {
289 cr.cr0.so = 0;
290 } else {
291 cr.cr0.so = 1;
292 }
293 tc->setIntReg(INTREG_CR, cr);
294 tc->setIntReg(ReturnValueReg, sysret.encodedValue());
295}
274}
275
276PowerISA::IntReg
277PowerProcess::getSyscallArg(ThreadContext *tc, int &i)
278{
279 assert(i < 5);
280 return tc->readIntReg(ArgumentReg0 + i++);
281}
282
283void
284PowerProcess::setSyscallArg(ThreadContext *tc, int i, PowerISA::IntReg val)
285{
286 assert(i < 5);
287 tc->setIntReg(ArgumentReg0 + i, val);
288}
289
290void
291PowerProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
292{
293 Cr cr = tc->readIntReg(INTREG_CR);
294 if (sysret.successful()) {
295 cr.cr0.so = 0;
296 } else {
297 cr.cr0.so = 1;
298 }
299 tc->setIntReg(INTREG_CR, cr);
300 tc->setIntReg(ReturnValueReg, sysret.encodedValue());
301}