process.cc (11794:97eebddaae84) process.cc (11851:824055fe6b30)
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 40 unchanged lines hidden (view full) ---

49#include "sim/syscall_desc.hh"
50#include "sim/syscall_emul.hh"
51
52using namespace std;
53using namespace X86ISA;
54
55/// Target uname() handler.
56static SyscallReturn
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 40 unchanged lines hidden (view full) ---

49#include "sim/syscall_desc.hh"
50#include "sim/syscall_emul.hh"
51
52using namespace std;
53using namespace X86ISA;
54
55/// Target uname() handler.
56static SyscallReturn
57unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
57unameFunc(SyscallDesc *desc, int callnum, Process *process,
58 ThreadContext *tc)
59{
60 int index = 0;
61 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
62
63 strcpy(name->sysname, "Linux");
64 strcpy(name->nodename, "sim.gem5.org");
65 strcpy(name->release, "3.0.0");
66 strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
67 strcpy(name->machine, "x86_64");
68
69 name.copyOut(tc->getMemProxy());
70
71 return 0;
72}
73
74static SyscallReturn
58 ThreadContext *tc)
59{
60 int index = 0;
61 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
62
63 strcpy(name->sysname, "Linux");
64 strcpy(name->nodename, "sim.gem5.org");
65 strcpy(name->release, "3.0.0");
66 strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
67 strcpy(name->machine, "x86_64");
68
69 name.copyOut(tc->getMemProxy());
70
71 return 0;
72}
73
74static SyscallReturn
75archPrctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
75archPrctlFunc(SyscallDesc *desc, int callnum, Process *process,
76 ThreadContext *tc)
77{
78 enum ArchPrctlCodes
79 {
80 SetFS = 0x1002,
81 GetFS = 0x1003,
82 SetGS = 0x1001,
83 GetGS = 0x1004

--- 50 unchanged lines hidden (view full) ---

134 uint32_t __padding1;
135 uint64_t base_addr;
136 uint32_t limit;
137 uint32_t flags;
138};
139
140static SyscallReturn
141setThreadArea32Func(SyscallDesc *desc, int callnum,
76 ThreadContext *tc)
77{
78 enum ArchPrctlCodes
79 {
80 SetFS = 0x1002,
81 GetFS = 0x1003,
82 SetGS = 0x1001,
83 GetGS = 0x1004

--- 50 unchanged lines hidden (view full) ---

134 uint32_t __padding1;
135 uint64_t base_addr;
136 uint32_t limit;
137 uint32_t flags;
138};
139
140static SyscallReturn
141setThreadArea32Func(SyscallDesc *desc, int callnum,
142 LiveProcess *process, ThreadContext *tc)
142 Process *process, ThreadContext *tc)
143{
144 const int minTLSEntry = 6;
145 const int numTLSEntries = 3;
146 const int maxTLSEntry = minTLSEntry + numTLSEntries - 1;
147
143{
144 const int minTLSEntry = 6;
145 const int numTLSEntries = 3;
146 const int maxTLSEntry = minTLSEntry + numTLSEntries - 1;
147
148 X86LiveProcess *x86lp = dynamic_cast<X86LiveProcess *>(process);
149 assert(x86lp);
148 X86Process *x86p = dynamic_cast<X86Process *>(process);
149 assert(x86p);
150
150
151 assert((maxTLSEntry + 1) * sizeof(uint64_t) <= x86lp->gdtSize());
151 assert((maxTLSEntry + 1) * sizeof(uint64_t) <= x86p->gdtSize());
152
153 int argIndex = 0;
154 TypedBufferArg<UserDesc32> userDesc(process->getSyscallArg(tc, argIndex));
155 TypedBufferArg<uint64_t>
152
153 int argIndex = 0;
154 TypedBufferArg<UserDesc32> userDesc(process->getSyscallArg(tc, argIndex));
155 TypedBufferArg<uint64_t>
156 gdt(x86lp->gdtStart() + minTLSEntry * sizeof(uint64_t),
157 numTLSEntries * sizeof(uint64_t));
156 gdt(x86p->gdtStart() + minTLSEntry * sizeof(uint64_t),
157 numTLSEntries * sizeof(uint64_t));
158
159 if (!userDesc.copyIn(tc->getMemProxy()))
160 return -EFAULT;
161
162 if (!gdt.copyIn(tc->getMemProxy()))
163 panic("Failed to copy in GDT for %s.\n", desc->name());
164
165 if (userDesc->entry_number == (uint32_t)(-1)) {

--- 365 unchanged lines hidden (view full) ---

531 /* 308 */ SyscallDesc("setns", unimplementedFunc),
532 /* 309 */ SyscallDesc("getcpu", unimplementedFunc),
533 /* 310 */ SyscallDesc("proess_vm_readv", unimplementedFunc),
534 /* 311 */ SyscallDesc("proess_vm_writev", unimplementedFunc),
535 /* 312 */ SyscallDesc("kcmp", unimplementedFunc),
536 /* 313 */ SyscallDesc("finit_module", unimplementedFunc),
537};
538
158
159 if (!userDesc.copyIn(tc->getMemProxy()))
160 return -EFAULT;
161
162 if (!gdt.copyIn(tc->getMemProxy()))
163 panic("Failed to copy in GDT for %s.\n", desc->name());
164
165 if (userDesc->entry_number == (uint32_t)(-1)) {

--- 365 unchanged lines hidden (view full) ---

531 /* 308 */ SyscallDesc("setns", unimplementedFunc),
532 /* 309 */ SyscallDesc("getcpu", unimplementedFunc),
533 /* 310 */ SyscallDesc("proess_vm_readv", unimplementedFunc),
534 /* 311 */ SyscallDesc("proess_vm_writev", unimplementedFunc),
535 /* 312 */ SyscallDesc("kcmp", unimplementedFunc),
536 /* 313 */ SyscallDesc("finit_module", unimplementedFunc),
537};
538
539X86_64LinuxProcess::X86_64LinuxProcess(LiveProcessParams * params,
540 ObjectFile *objFile)
541 : X86_64LiveProcess(params, objFile, syscallDescs64,
542 sizeof(syscallDescs64) / sizeof(SyscallDesc))
539X86_64LinuxProcess::X86_64LinuxProcess(ProcessParams * params,
540 ObjectFile *objFile)
541 : X86_64Process(params, objFile, syscallDescs64,
542 sizeof(syscallDescs64) / sizeof(SyscallDesc))
543{}
544
545static SyscallDesc syscallDescs32[] = {
546 /* 0 */ SyscallDesc("restart_syscall", unimplementedFunc),
547 /* 1 */ SyscallDesc("exit", exitFunc),
548 /* 2 */ SyscallDesc("fork", unimplementedFunc),
549 /* 3 */ SyscallDesc("read", readFunc),
550 /* 4 */ SyscallDesc("write", writeFunc),

--- 313 unchanged lines hidden (view full) ---

864 /* 318 */ SyscallDesc("getcpu", unimplementedFunc),
865 /* 319 */ SyscallDesc("epoll_pwait", unimplementedFunc),
866 /* 320 */ SyscallDesc("utimensat", unimplementedFunc),
867 /* 321 */ SyscallDesc("signalfd", unimplementedFunc),
868 /* 322 */ SyscallDesc("timerfd", unimplementedFunc),
869 /* 323 */ SyscallDesc("eventfd", unimplementedFunc)
870};
871
543{}
544
545static SyscallDesc syscallDescs32[] = {
546 /* 0 */ SyscallDesc("restart_syscall", unimplementedFunc),
547 /* 1 */ SyscallDesc("exit", exitFunc),
548 /* 2 */ SyscallDesc("fork", unimplementedFunc),
549 /* 3 */ SyscallDesc("read", readFunc),
550 /* 4 */ SyscallDesc("write", writeFunc),

--- 313 unchanged lines hidden (view full) ---

864 /* 318 */ SyscallDesc("getcpu", unimplementedFunc),
865 /* 319 */ SyscallDesc("epoll_pwait", unimplementedFunc),
866 /* 320 */ SyscallDesc("utimensat", unimplementedFunc),
867 /* 321 */ SyscallDesc("signalfd", unimplementedFunc),
868 /* 322 */ SyscallDesc("timerfd", unimplementedFunc),
869 /* 323 */ SyscallDesc("eventfd", unimplementedFunc)
870};
871
872I386LinuxProcess::I386LinuxProcess(LiveProcessParams * params,
873 ObjectFile *objFile)
874 : I386LiveProcess(params, objFile, syscallDescs32,
875 sizeof(syscallDescs32) / sizeof(SyscallDesc))
872I386LinuxProcess::I386LinuxProcess(ProcessParams * params, ObjectFile *objFile)
873 : I386Process(params, objFile, syscallDescs32,
874 sizeof(syscallDescs32) / sizeof(SyscallDesc))
876{}
875{}