Make stuff build on openbsd
[gem5.git] / arch / alpha / alpha_tru64_process.cc
1 /*
2 * Copyright (c) 2003 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
29 #include <errno.h>
30 #include <unistd.h>
31 #include <fcntl.h> // for host open() flags
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <string.h> // for memset()
35 #include <dirent.h>
36
37 #include "sim/host.hh"
38 #include "cpu/base_cpu.hh"
39 #include "mem/functional_mem/functional_memory.hh"
40 #include "sim/process.hh"
41 #include "cpu/exec_context.hh"
42 #include "sim/fake_syscall.hh"
43
44 #include "arch/alpha/alpha_common_syscall_emul.hh"
45 #include "arch/alpha/alpha_tru64_process.hh"
46
47 #include "sim/syscall_emul.hh"
48 #include "sim/universe.hh" // for curTick & ticksPerSecond
49
50 #include "base/trace.hh"
51
52 using namespace std;
53
54 ///
55 /// This class encapsulates the types, structures, constants,
56 /// functions, and syscall-number mappings specific to the Alpha Tru64
57 /// syscall interface.
58 ///
59 class Tru64 {
60
61 public:
62
63 //@{
64 /// Basic Tru64 types.
65 typedef uint64_t size_t;
66 typedef uint64_t off_t;
67 typedef uint16_t nlink_t;
68 typedef int32_t dev_t;
69 typedef uint32_t uid_t;
70 typedef uint32_t gid_t;
71 typedef uint32_t time_t;
72 typedef uint32_t mode_t;
73 typedef uint32_t ino_t;
74 //@}
75
76 //@{
77 /// open(2) flag values.
78 static const int TGT_O_RDONLY = 00000000;
79 static const int TGT_O_WRONLY = 00000001;
80 static const int TGT_O_RDWR = 00000002;
81 static const int TGT_O_NONBLOCK = 00000004;
82 static const int TGT_O_APPEND = 00000010;
83 static const int TGT_O_CREAT = 00001000;
84 static const int TGT_O_TRUNC = 00002000;
85 static const int TGT_O_EXCL = 00004000;
86 static const int TGT_O_NOCTTY = 00010000;
87 static const int TGT_O_SYNC = 00040000;
88 static const int TGT_O_DRD = 00100000;
89 static const int TGT_O_DIRECTIO = 00200000;
90 static const int TGT_O_CACHE = 00400000;
91 static const int TGT_O_DSYNC = 02000000;
92 static const int TGT_O_RSYNC = 04000000;
93 //@}
94
95 /// This table maps the target open() flags to the corresponding
96 /// host open() flags.
97 static OpenFlagTransTable openFlagTable[];
98
99 /// Number of entries in openFlagTable[].
100 static const int NUM_OPEN_FLAGS;
101
102 /// Stat buffer. Note that Tru64 v5.0+ use a new "F64" stat structure,
103 /// and a new set of syscall numbers for stat calls. Backwards
104 /// compatibility with v4.x should be feasible by implementing
105 /// another set of stat functions using the old structure
106 /// definition and binding them to the old syscall numbers, but we
107 /// haven't done that yet.
108 struct F64_stat {
109 dev_t st_dev; //!< st_dev
110 int32_t st_retired1; //!< st_retired1
111 mode_t st_mode; //!< st_mode
112 nlink_t st_nlink; //!< st_nlink
113 uint16_t st_nlink_reserved; //!< st_nlink_reserved
114 uid_t st_uid; //!< st_uid
115 gid_t st_gid; //!< st_gid
116 dev_t st_rdev; //!< st_rdev
117 dev_t st_ldev; //!< st_ldev
118 off_t st_size; //!< st_size
119 time_t st_retired2; //!< st_retired2
120 int32_t st_uatime; //!< st_uatime
121 time_t st_retired3; //!< st_retired3
122 int32_t st_umtime; //!< st_umtime
123 time_t st_retired4; //!< st_retired4
124 int32_t st_uctime; //!< st_uctime
125 int32_t st_retired5; //!< st_retired5
126 int32_t st_retired6; //!< st_retired6
127 uint32_t st_flags; //!< st_flags
128 uint32_t st_gen; //!< st_gen
129 uint64_t st_spare[4]; //!< st_spare[4]
130 ino_t st_ino; //!< st_ino
131 int32_t st_ino_reserved; //!< st_ino_reserved
132 time_t st_atimeX; //!< st_atime
133 int32_t st_atime_reserved; //!< st_atime_reserved
134 time_t st_mtimeX; //!< st_mtime
135 int32_t st_mtime_reserved; //!< st_mtime_reserved
136 time_t st_ctimeX; //!< st_ctime
137 int32_t st_ctime_reserved; //!< st_ctime_reserved
138 uint64_t st_blksize; //!< st_blksize
139 uint64_t st_blocks; //!< st_blocks
140 };
141
142
143 /// For getdirentries().
144 struct dirent
145 {
146 ino_t d_ino; //!< file number of entry
147 uint16_t d_reclen; //!< length of this record
148 uint16_t d_namlen; //!< length of string in d_name
149 char d_name[256]; //!< dummy name length
150 };
151
152
153 /// Length of strings in struct utsname (plus 1 for null char).
154 static const int _SYS_NMLN = 32;
155
156 /// Interface struct for uname().
157 struct utsname {
158 char sysname[_SYS_NMLN]; //!< System name.
159 char nodename[_SYS_NMLN]; //!< Node name.
160 char release[_SYS_NMLN]; //!< OS release.
161 char version[_SYS_NMLN]; //!< OS version.
162 char machine[_SYS_NMLN]; //!< Machine type.
163 };
164
165 //@{
166 /// ioctl() command codes.
167 static const unsigned TIOCGETP = 0x40067408;
168 static const unsigned TIOCSETP = 0x80067409;
169 static const unsigned TIOCSETN = 0x8006740a;
170 static const unsigned TIOCSETC = 0x80067411;
171 static const unsigned TIOCGETC = 0x40067412;
172 static const unsigned FIONREAD = 0x4004667f;
173 static const unsigned TIOCISATTY = 0x2000745e;
174 //@}
175
176 /// Resource enumeration for getrlimit().
177 enum rlimit_resources {
178 RLIMIT_CPU = 0,
179 RLIMIT_FSIZE = 1,
180 RLIMIT_DATA = 2,
181 RLIMIT_STACK = 3,
182 RLIMIT_CORE = 4,
183 RLIMIT_RSS = 5,
184 RLIMIT_NOFILE = 6,
185 RLIMIT_AS = 7,
186 RLIMIT_VMEM = 7
187 };
188
189 /// Limit struct for getrlimit/setrlimit.
190 struct rlimit {
191 uint64_t rlim_cur; //!< soft limit
192 uint64_t rlim_max; //!< hard limit
193 };
194
195
196 /// For mmap().
197 static const unsigned TGT_MAP_ANONYMOUS = 0x10;
198
199
200 //@{
201 /// For getsysinfo().
202 static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
203 static const unsigned GSI_CPU_INFO = 59; //!< CPU information
204 static const unsigned GSI_PROC_TYPE = 60; //!< get proc_type
205 static const unsigned GSI_MAX_CPU = 30; //!< max # cpu's on this machine
206 static const unsigned GSI_CPUS_IN_BOX = 55; //!< number of CPUs in system
207 static const unsigned GSI_PHYSMEM = 19; //!< Physical memory in KB
208 static const unsigned GSI_CLK_TCK = 42; //!< clock freq in Hz
209 //@}
210
211 /// For getsysinfo() GSI_CPU_INFO option.
212 struct cpu_info {
213 uint32_t current_cpu; //!< current_cpu
214 uint32_t cpus_in_box; //!< cpus_in_box
215 uint32_t cpu_type; //!< cpu_type
216 uint32_t ncpus; //!< ncpus
217 uint64_t cpus_present; //!< cpus_present
218 uint64_t cpus_running; //!< cpus_running
219 uint64_t cpu_binding; //!< cpu_binding
220 uint64_t cpu_ex_binding; //!< cpu_ex_binding
221 uint32_t mhz; //!< mhz
222 uint32_t unused[3]; //!< future expansion
223 };
224
225 /// For gettimeofday.
226 struct timeval {
227 uint32_t tv_sec; //!< seconds
228 uint32_t tv_usec; //!< microseconds
229 };
230
231 //@{
232 /// For getrusage().
233 static const int RUSAGE_THREAD = 1;
234 static const int RUSAGE_SELF = 0;
235 static const int RUSAGE_CHILDREN = -1;
236 //@}
237
238 /// For getrusage().
239 struct rusage {
240 struct timeval ru_utime; //!< user time used
241 struct timeval ru_stime; //!< system time used
242 uint64_t ru_maxrss; //!< ru_maxrss
243 uint64_t ru_ixrss; //!< integral shared memory size
244 uint64_t ru_idrss; //!< integral unshared data "
245 uint64_t ru_isrss; //!< integral unshared stack "
246 uint64_t ru_minflt; //!< page reclaims - total vmfaults
247 uint64_t ru_majflt; //!< page faults
248 uint64_t ru_nswap; //!< swaps
249 uint64_t ru_inblock; //!< block input operations
250 uint64_t ru_oublock; //!< block output operations
251 uint64_t ru_msgsnd; //!< messages sent
252 uint64_t ru_msgrcv; //!< messages received
253 uint64_t ru_nsignals; //!< signals received
254 uint64_t ru_nvcsw; //!< voluntary context switches
255 uint64_t ru_nivcsw; //!< involuntary "
256 };
257
258 /// For sigreturn().
259 struct sigcontext {
260 int64_t sc_onstack; //!< sigstack state to restore
261 int64_t sc_mask; //!< signal mask to restore
262 int64_t sc_pc; //!< pc at time of signal
263 int64_t sc_ps; //!< psl to retore
264 int64_t sc_regs[32]; //!< processor regs 0 to 31
265 int64_t sc_ownedfp; //!< fp has been used
266 int64_t sc_fpregs[32]; //!< fp regs 0 to 31
267 uint64_t sc_fpcr; //!< floating point control reg
268 uint64_t sc_fp_control; //!< software fpcr
269 int64_t sc_reserved1; //!< reserved for kernel
270 uint32_t sc_kreserved1; //!< reserved for kernel
271 uint32_t sc_kreserved2; //!< reserved for kernel
272 size_t sc_ssize; //!< stack size
273 caddr_t sc_sbase; //!< stack start
274 uint64_t sc_traparg_a0; //!< a0 argument to trap on exc
275 uint64_t sc_traparg_a1; //!< a1 argument to trap on exc
276 uint64_t sc_traparg_a2; //!< a2 argument to trap on exc
277 uint64_t sc_fp_trap_pc; //!< imprecise pc
278 uint64_t sc_fp_trigger_sum; //!< Exception summary at trigg
279 uint64_t sc_fp_trigger_inst; //!< Instruction at trigger pc
280 };
281
282
283 /// For table().
284 static const int TBL_SYSINFO = 12;
285
286 /// For table().
287 struct tbl_sysinfo {
288 uint64_t si_user; //!< User time
289 uint64_t si_nice; //!< Nice time
290 uint64_t si_sys; //!< System time
291 uint64_t si_idle; //!< Idle time
292 uint64_t si_hz; //!< hz
293 uint64_t si_phz; //!< phz
294 uint64_t si_boottime; //!< Boot time in seconds
295 uint64_t wait; //!< Wait time
296 uint32_t si_max_procs; //!< rpb->rpb_numprocs
297 uint32_t pad; //!< padding
298 };
299
300
301 /// For stack_create.
302 struct vm_stack {
303 // was void *
304 Addr address; //!< address hint
305 size_t rsize; //!< red zone size
306 size_t ysize; //!< yellow zone size
307 size_t gsize; //!< green zone size
308 size_t swap; //!< amount of swap to reserve
309 size_t incr; //!< growth increment
310 uint64_t align; //!< address alignment
311 uint64_t flags; //!< MAP_FIXED etc.
312 // was struct memalloc_attr *
313 Addr attr; //!< allocation policy
314 uint64_t reserved; //!< reserved
315 };
316
317 /// Return values for nxm calls.
318 enum {
319 KERN_NOT_RECEIVER = 7,
320 KERN_NOT_IN_SET = 12
321 };
322
323 /// For nxm_task_init.
324 static const int NXM_TASK_INIT_VP = 2; //!< initial thread is VP
325
326 /// Task attribute structure.
327 struct nxm_task_attr {
328 int64_t nxm_callback; //!< nxm_callback
329 unsigned int nxm_version; //!< nxm_version
330 unsigned short nxm_uniq_offset; //!< nxm_uniq_offset
331 unsigned short flags; //!< flags
332 int nxm_quantum; //!< nxm_quantum
333 int pad1; //!< pad1
334 int64_t pad2; //!< pad2
335 };
336
337 /// Signal set.
338 typedef uint64_t sigset_t;
339
340 /// Thread state shared between user & kernel.
341 struct ushared_state {
342 sigset_t sigmask; //!< thread signal mask
343 sigset_t sig; //!< thread pending mask
344 // struct nxm_pth_state *
345 Addr pth_id; //!< out-of-line state
346 int flags; //!< shared flags
347 #define US_SIGSTACK 0x1 // thread called sigaltstack
348 #define US_ONSTACK 0x2 // thread is running on altstack
349 #define US_PROFILE 0x4 // thread called profil
350 #define US_SYSCALL 0x8 // thread in syscall
351 #define US_TRAP 0x10 // thread has trapped
352 #define US_YELLOW 0x20 // thread has mellowed yellow
353 #define US_YZONE 0x40 // thread has zoned out
354 #define US_FP_OWNED 0x80 // thread used floating point
355
356 int cancel_state; //!< thread's cancelation state
357 #define US_CANCEL 0x1 // cancel pending
358 #define US_NOCANCEL 0X2 // synch cancel disabled
359 #define US_SYS_NOCANCEL 0x4 // syscall cancel disabled
360 #define US_ASYNC_NOCANCEL 0x8 // asynch cancel disabled
361 #define US_CANCEL_BITS (US_NOCANCEL|US_SYS_NOCANCEL|US_ASYNC_NOCANCEL)
362 #define US_CANCEL_MASK (US_CANCEL|US_NOCANCEL|US_SYS_NOCANCEL| \
363 US_ASYNC_NOCANCEL)
364
365 // These are semi-shared. They are always visible to
366 // the kernel but are never context-switched by the library.
367
368 int nxm_ssig; //!< scheduler's synchronous signals
369 int reserved1; //!< reserved1
370 int64_t nxm_active; //!< scheduler active
371 int64_t reserved2; //!< reserved2
372 };
373
374 struct nxm_sched_state {
375 struct ushared_state nxm_u; //!< state own by user thread
376 unsigned int nxm_bits; //!< scheduler state / slot
377 int nxm_quantum; //!< quantum count-down value
378 int nxm_set_quantum; //!< quantum reset value
379 int nxm_sysevent; //!< syscall state
380 // struct nxm_upcall *
381 Addr nxm_uc_ret; //!< stack ptr of null thread
382 // void *
383 Addr nxm_tid; //!< scheduler's thread id
384 int64_t nxm_va; //!< page fault address
385 // struct nxm_pth_state *
386 Addr nxm_pthid; //!< id of null thread
387 uint64_t nxm_bound_pcs_count; //!< bound PCS thread count
388 int64_t pad[2]; //!< pad
389 };
390
391 /// nxm_shared.
392 struct nxm_shared {
393 int64_t nxm_callback; //!< address of upcall routine
394 unsigned int nxm_version; //!< version number
395 unsigned short nxm_uniq_offset; //!< correction factor for TEB
396 unsigned short pad1; //!< pad1
397 int64_t space[2]; //!< future growth
398 struct nxm_sched_state nxm_ss[1]; //!< array of shared areas
399 };
400
401 /// nxm_slot_state_t.
402 enum nxm_slot_state_t {
403 NXM_SLOT_AVAIL,
404 NXM_SLOT_BOUND,
405 NXM_SLOT_UNBOUND,
406 NXM_SLOT_EMPTY
407 };
408
409 /// nxm_config_info
410 struct nxm_config_info {
411 int nxm_nslots_per_rad; //!< max number of VP slots per RAD
412 int nxm_nrads; //!< max number of RADs
413 // nxm_slot_state_t *
414 Addr nxm_slot_state; //!< per-VP slot state
415 // struct nxm_shared *
416 Addr nxm_rad[1]; //!< per-RAD shared areas
417 };
418
419 /// For nxm_thread_create.
420 enum nxm_thread_type {
421 NXM_TYPE_SCS = 0,
422 NXM_TYPE_VP = 1,
423 NXM_TYPE_MANAGER = 2
424 };
425
426 /// Thread attributes.
427 struct nxm_thread_attr {
428 int version; //!< version
429 int type; //!< type
430 int cancel_flags; //!< cancel_flags
431 int priority; //!< priority
432 int policy; //!< policy
433 int signal_type; //!< signal_type
434 // void *
435 Addr pthid; //!< pthid
436 sigset_t sigmask; //!< sigmask
437 /// Initial register values.
438 struct {
439 uint64_t pc; //!< pc
440 uint64_t sp; //!< sp
441 uint64_t a0; //!< a0
442 } registers;
443 uint64_t pad2[2]; //!< pad2
444 };
445
446 /// Helper function to convert a host stat buffer to a target stat
447 /// buffer. Also copies the target buffer out to the simulated
448 /// memorty space. Used by stat(), fstat(), and lstat().
449 static void
450 copyOutStatBuf(FunctionalMemory *mem, Addr addr, struct stat *host)
451 {
452 TypedBufferArg<Tru64::F64_stat> tgt(addr);
453
454 tgt->st_dev = host->st_dev;
455 tgt->st_ino = host->st_ino;
456 tgt->st_mode = host->st_mode;
457 tgt->st_nlink = host->st_nlink;
458 tgt->st_uid = host->st_uid;
459 tgt->st_gid = host->st_gid;
460 tgt->st_rdev = host->st_rdev;
461 tgt->st_size = host->st_size;
462 tgt->st_atimeX = host->st_atime;
463 tgt->st_mtimeX = host->st_mtime;
464 tgt->st_ctimeX = host->st_ctime;
465 tgt->st_blksize = host->st_blksize;
466 tgt->st_blocks = host->st_blocks;
467
468 tgt.copyOut(mem);
469 }
470
471
472 /// The target system's hostname.
473 static const char *hostname;
474
475 /// Target uname() handler.
476 static int
477 unameFunc(SyscallDesc *desc, int callnum, Process *process,
478 ExecContext *xc)
479 {
480 TypedBufferArg<Tru64::utsname> name(xc->getSyscallArg(0));
481
482 strcpy(name->sysname, "OSF1");
483 strcpy(name->nodename, hostname);
484 strcpy(name->release, "V5.1");
485 strcpy(name->version, "732");
486 strcpy(name->machine, "alpha");
487
488 name.copyOut(xc->mem);
489 return 0;
490 }
491
492
493 /// Target getsysyinfo() handler.
494 static int
495 getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
496 ExecContext *xc)
497 {
498 unsigned op = xc->getSyscallArg(0);
499 unsigned nbytes = xc->getSyscallArg(2);
500
501 switch (op) {
502
503 case Tru64::GSI_MAX_CPU: {
504 TypedBufferArg<uint32_t> max_cpu(xc->getSyscallArg(1));
505 *max_cpu = process->numCpus();
506 max_cpu.copyOut(xc->mem);
507 return 1;
508 }
509
510 case Tru64::GSI_CPUS_IN_BOX: {
511 TypedBufferArg<uint32_t> cpus_in_box(xc->getSyscallArg(1));
512 *cpus_in_box = process->numCpus();
513 cpus_in_box.copyOut(xc->mem);
514 return 1;
515 }
516
517 case Tru64::GSI_PHYSMEM: {
518 TypedBufferArg<uint64_t> physmem(xc->getSyscallArg(1));
519 *physmem = 1024 * 1024; // physical memory in KB
520 physmem.copyOut(xc->mem);
521 return 1;
522 }
523
524 case Tru64::GSI_CPU_INFO: {
525 TypedBufferArg<Tru64::cpu_info> infop(xc->getSyscallArg(1));
526
527 infop->current_cpu = 0;
528 infop->cpus_in_box = process->numCpus();
529 infop->cpu_type = 57;
530 infop->ncpus = process->numCpus();
531 int cpumask = (1 << process->numCpus()) - 1;
532 infop->cpus_present = infop->cpus_running = cpumask;
533 infop->cpu_binding = 0;
534 infop->cpu_ex_binding = 0;
535 infop->mhz = 667;
536
537 infop.copyOut(xc->mem);
538 return 1;
539 }
540
541 case Tru64::GSI_PROC_TYPE: {
542 TypedBufferArg<uint64_t> proc_type(xc->getSyscallArg(1));
543 *proc_type = 11;
544 proc_type.copyOut(xc->mem);
545 return 1;
546 }
547
548 case Tru64::GSI_PLATFORM_NAME: {
549 BufferArg bufArg(xc->getSyscallArg(1), nbytes);
550 strncpy((char *)bufArg.bufferPtr(),
551 "COMPAQ Professional Workstation XP1000",
552 nbytes);
553 bufArg.copyOut(xc->mem);
554 return 1;
555 }
556
557 case Tru64::GSI_CLK_TCK: {
558 TypedBufferArg<uint64_t> clk_hz(xc->getSyscallArg(1));
559 *clk_hz = 1024;
560 clk_hz.copyOut(xc->mem);
561 return 1;
562 }
563
564 default:
565 cerr << "getsysinfo: unknown op " << op << endl;
566 abort();
567 break;
568 }
569
570 return 0;
571 }
572
573 /// Target fnctl() handler.
574 static int
575 fcntlFunc(SyscallDesc *desc, int callnum, Process *process,
576 ExecContext *xc)
577 {
578 int fd = xc->getSyscallArg(0);
579
580 if (fd < 0 || process->sim_fd(fd) < 0)
581 return -EBADF;
582
583 int cmd = xc->getSyscallArg(1);
584 switch (cmd) {
585 case 0: // F_DUPFD
586 // if we really wanted to support this, we'd need to do it
587 // in the target fd space.
588 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd);
589 return -EMFILE;
590
591 case 1: // F_GETFD (get close-on-exec flag)
592 case 2: // F_SETFD (set close-on-exec flag)
593 return 0;
594
595 case 3: // F_GETFL (get file flags)
596 case 4: // F_SETFL (set file flags)
597 // not sure if this is totally valid, but we'll pass it through
598 // to the underlying OS
599 warn("fcntl(%d, %d) passed through to host\n", fd, cmd);
600 return fcntl(process->sim_fd(fd), cmd);
601 // return 0;
602
603 case 7: // F_GETLK (get lock)
604 case 8: // F_SETLK (set lock)
605 case 9: // F_SETLKW (set lock and wait)
606 // don't mess with file locking... just act like it's OK
607 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd, cmd);
608 return 0;
609
610 default:
611 warn("Unknown fcntl command %d\n", cmd);
612 return 0;
613 }
614 }
615
616
617 /// Target getdirentries() handler.
618 static int
619 getdirentriesFunc(SyscallDesc *desc, int callnum, Process *process,
620 ExecContext *xc)
621 {
622 int fd = process->sim_fd(xc->getSyscallArg(0));
623 Addr tgt_buf = xc->getSyscallArg(1);
624 int tgt_nbytes = xc->getSyscallArg(2);
625 Addr tgt_basep = xc->getSyscallArg(3);
626
627 char * const host_buf = new char[tgt_nbytes];
628
629 // just pass basep through uninterpreted.
630 TypedBufferArg<int64_t> basep(tgt_basep);
631 basep.copyIn(xc->mem);
632 long host_basep = (off_t)*basep;
633 int host_result = getdirentries(fd, host_buf, tgt_nbytes, &host_basep);
634
635 // check for error
636 if (host_result < 0) {
637 delete [] host_buf;
638 return -errno;
639 }
640
641 // no error: copy results back to target space
642 Addr tgt_buf_ptr = tgt_buf;
643 char *host_buf_ptr = host_buf;
644 char *host_buf_end = host_buf + host_result;
645 while (host_buf_ptr < host_buf_end) {
646 struct dirent *host_dp = (struct dirent *)host_buf_ptr;
647 int namelen = strlen(host_dp->d_name);
648
649 // Actual size includes padded string rounded up for alignment.
650 // Subtract 256 for dummy char array in Tru64::dirent definition.
651 // Add 1 to namelen for terminating null char.
652 int tgt_bufsize = sizeof(Tru64::dirent) - 256 + RoundUp(namelen+1, 8);
653 TypedBufferArg<Tru64::dirent> tgt_dp(tgt_buf_ptr, tgt_bufsize);
654 tgt_dp->d_ino = host_dp->d_ino;
655 tgt_dp->d_reclen = tgt_bufsize;
656 tgt_dp->d_namlen = namelen;
657 strcpy(tgt_dp->d_name, host_dp->d_name);
658 tgt_dp.copyOut(xc->mem);
659
660 tgt_buf_ptr += tgt_bufsize;
661 host_buf_ptr += host_dp->d_reclen;
662 }
663
664 delete [] host_buf;
665
666 *basep = host_basep;
667 basep.copyOut(xc->mem);
668
669 return (tgt_buf_ptr - tgt_buf);
670 }
671
672 /// Target sigreturn() handler.
673 static int
674 sigreturnFunc(SyscallDesc *desc, int callnum, Process *process,
675 ExecContext *xc)
676 {
677 RegFile *regs = &xc->regs;
678 TypedBufferArg<Tru64::sigcontext> sc(xc->getSyscallArg(0));
679
680 sc.copyIn(xc->mem);
681
682 // Restore state from sigcontext structure.
683 // Note that we'll advance PC <- NPC before the end of the cycle,
684 // so we need to restore the desired PC into NPC.
685 // The current regs->pc will get clobbered.
686 regs->npc = sc->sc_pc;
687
688 for (int i = 0; i < 31; ++i) {
689 regs->intRegFile[i] = sc->sc_regs[i];
690 regs->floatRegFile.q[i] = sc->sc_fpregs[i];
691 }
692
693 regs->miscRegs.fpcr = sc->sc_fpcr;
694
695 return 0;
696 }
697
698 /// Target table() handler.
699 static int
700 tableFunc(SyscallDesc *desc, int callnum, Process *process,
701 ExecContext *xc)
702 {
703 int id = xc->getSyscallArg(0); // table ID
704 int index = xc->getSyscallArg(1); // index into table
705 // arg 2 is buffer pointer; type depends on table ID
706 int nel = xc->getSyscallArg(3); // number of elements
707 int lel = xc->getSyscallArg(4); // expected element size
708
709 switch (id) {
710 case Tru64::TBL_SYSINFO: {
711 if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo))
712 return -EINVAL;
713 TypedBufferArg<Tru64::tbl_sysinfo> elp(xc->getSyscallArg(2));
714
715 const int clk_hz = one_million;
716 elp->si_user = curTick / (ticksPerSecond / clk_hz);
717 elp->si_nice = 0;
718 elp->si_sys = 0;
719 elp->si_idle = 0;
720 elp->wait = 0;
721 elp->si_hz = clk_hz;
722 elp->si_phz = clk_hz;
723 elp->si_boottime = seconds_since_epoch; // seconds since epoch?
724 elp->si_max_procs = process->numCpus();
725 elp.copyOut(xc->mem);
726 return 0;
727 }
728
729 default:
730 cerr << "table(): id " << id << " unknown." << endl;
731 return -EINVAL;
732 }
733 }
734
735 /// Array of syscall descriptors, indexed by call number.
736 static SyscallDesc syscallDescs[];
737
738 /// Number of syscalls in syscallDescs[].
739 static const int Num_Syscall_Descs;
740
741 /// Max supported syscall number.
742 static const int Max_Syscall_Desc;
743
744 //
745 // Mach syscalls -- identified by negated syscall numbers
746 //
747
748 /// Create a stack region for a thread.
749 static int
750 stack_createFunc(SyscallDesc *desc, int callnum, Process *process,
751 ExecContext *xc)
752 {
753 TypedBufferArg<Tru64::vm_stack> argp(xc->getSyscallArg(0));
754
755 argp.copyIn(xc->mem);
756
757 // if the user chose an address, just let them have it. Otherwise
758 // pick one for them.
759 if (argp->address == 0) {
760 argp->address = process->next_thread_stack_base;
761 int stack_size = (argp->rsize + argp->ysize + argp->gsize);
762 process->next_thread_stack_base -= stack_size;
763 argp.copyOut(xc->mem);
764 }
765
766 return 0;
767 }
768
769 /// NXM library version stamp.
770 static
771 const int NXM_LIB_VERSION = 301003;
772
773 /// This call sets up the interface between the user and kernel
774 /// schedulers by creating a shared-memory region. The shared memory
775 /// region has several structs, some global, some per-RAD, some per-VP.
776 static int
777 nxm_task_initFunc(SyscallDesc *desc, int callnum, Process *process,
778 ExecContext *xc)
779 {
780 TypedBufferArg<Tru64::nxm_task_attr> attrp(xc->getSyscallArg(0));
781 TypedBufferArg<Addr> configptr_ptr(xc->getSyscallArg(1));
782
783 attrp.copyIn(xc->mem);
784
785 if (attrp->nxm_version != NXM_LIB_VERSION) {
786 cerr << "nxm_task_init: thread library version mismatch! "
787 << "got " << attrp->nxm_version
788 << ", expected " << NXM_LIB_VERSION << endl;
789 abort();
790 }
791
792 if (attrp->flags != Tru64::NXM_TASK_INIT_VP) {
793 cerr << "nxm_task_init: bad flag value " << attrp->flags
794 << " (expected " << Tru64::NXM_TASK_INIT_VP << ")" << endl;
795 abort();
796 }
797
798 const Addr base_addr = 0x12000; // was 0x3f0000000LL;
799 Addr cur_addr = base_addr; // next addresses to use
800 // first comes the config_info struct
801 Addr config_addr = cur_addr;
802 cur_addr += sizeof(Tru64::nxm_config_info);
803 // next comes the per-cpu state vector
804 Addr slot_state_addr = cur_addr;
805 int slot_state_size =
806 process->numCpus() * sizeof(Tru64::nxm_slot_state_t);
807 cur_addr += slot_state_size;
808 // now the per-RAD state struct (we only support one RAD)
809 cur_addr = 0x14000; // bump up addr for alignment
810 Addr rad_state_addr = cur_addr;
811 int rad_state_size =
812 (sizeof(Tru64::nxm_shared)
813 + (process->numCpus()-1) * sizeof(Tru64::nxm_sched_state));
814 cur_addr += rad_state_size;
815
816 // now initialize a config_info struct and copy it out to user space
817 TypedBufferArg<Tru64::nxm_config_info> config(config_addr);
818
819 config->nxm_nslots_per_rad = process->numCpus();
820 config->nxm_nrads = 1; // only one RAD in our system!
821 config->nxm_slot_state = slot_state_addr;
822 config->nxm_rad[0] = rad_state_addr;
823
824 config.copyOut(xc->mem);
825
826 // initialize the slot_state array and copy it out
827 TypedBufferArg<Tru64::nxm_slot_state_t> slot_state(slot_state_addr,
828 slot_state_size);
829 for (int i = 0; i < process->numCpus(); ++i) {
830 // CPU 0 is bound to the calling process; all others are available
831 slot_state[i] =
832 (i == 0) ? Tru64::NXM_SLOT_BOUND : Tru64::NXM_SLOT_AVAIL;
833 }
834
835 slot_state.copyOut(xc->mem);
836
837 // same for the per-RAD "shared" struct. Note that we need to
838 // allocate extra bytes for the per-VP array which is embedded at
839 // the end.
840 TypedBufferArg<Tru64::nxm_shared> rad_state(rad_state_addr,
841 rad_state_size);
842
843 rad_state->nxm_callback = attrp->nxm_callback;
844 rad_state->nxm_version = attrp->nxm_version;
845 rad_state->nxm_uniq_offset = attrp->nxm_uniq_offset;
846 for (int i = 0; i < process->numCpus(); ++i) {
847 Tru64::nxm_sched_state *ssp = &rad_state->nxm_ss[i];
848 ssp->nxm_u.sigmask = 0;
849 ssp->nxm_u.sig = 0;
850 ssp->nxm_u.flags = 0;
851 ssp->nxm_u.cancel_state = 0;
852 ssp->nxm_u.nxm_ssig = 0;
853 ssp->nxm_bits = 0;
854 ssp->nxm_quantum = attrp->nxm_quantum;
855 ssp->nxm_set_quantum = attrp->nxm_quantum;
856 ssp->nxm_sysevent = 0;
857
858 if (i == 0) {
859 uint64_t uniq = xc->regs.miscRegs.uniq;
860 ssp->nxm_u.pth_id = uniq + attrp->nxm_uniq_offset;
861 ssp->nxm_u.nxm_active = uniq | 1;
862 }
863 else {
864 ssp->nxm_u.pth_id = 0;
865 ssp->nxm_u.nxm_active = 0;
866 }
867 }
868
869 rad_state.copyOut(xc->mem);
870
871 //
872 // copy pointer to shared config area out to user
873 //
874 *configptr_ptr = config_addr;
875 configptr_ptr.copyOut(xc->mem);
876
877 return 0;
878 }
879
880 /// Initialize execution context.
881 static void
882 init_exec_context(ExecContext *ec,
883 Tru64::nxm_thread_attr *attrp, uint64_t uniq_val)
884 {
885 memset(&ec->regs, 0, sizeof(ec->regs));
886
887 ec->regs.intRegFile[ArgumentReg0] = attrp->registers.a0;
888 ec->regs.intRegFile[27/*t12*/] = attrp->registers.pc;
889 ec->regs.intRegFile[StackPointerReg] = attrp->registers.sp;
890 ec->regs.miscRegs.uniq = uniq_val;
891
892 ec->regs.pc = attrp->registers.pc;
893 ec->regs.npc = attrp->registers.pc + sizeof(MachInst);
894
895 ec->activate();
896 }
897
898 /// Create thread.
899 static int
900 nxm_thread_createFunc(SyscallDesc *desc, int callnum, Process *process,
901 ExecContext *xc)
902 {
903 TypedBufferArg<Tru64::nxm_thread_attr> attrp(xc->getSyscallArg(0));
904 TypedBufferArg<uint64_t> kidp(xc->getSyscallArg(1));
905 int thread_index = xc->getSyscallArg(2);
906
907 // get attribute args
908 attrp.copyIn(xc->mem);
909
910 if (attrp->version != NXM_LIB_VERSION) {
911 cerr << "nxm_thread_create: thread library version mismatch! "
912 << "got " << attrp->version
913 << ", expected " << NXM_LIB_VERSION << endl;
914 abort();
915 }
916
917 if (thread_index < 0 | thread_index > process->numCpus()) {
918 cerr << "nxm_thread_create: bad thread index " << thread_index
919 << endl;
920 abort();
921 }
922
923 // On a real machine, the per-RAD shared structure is in
924 // shared memory, so both the user and kernel can get at it.
925 // We don't have that luxury, so we just copy it in and then
926 // back out again.
927 int rad_state_size =
928 (sizeof(Tru64::nxm_shared) +
929 (process->numCpus()-1) * sizeof(Tru64::nxm_sched_state));
930
931 TypedBufferArg<Tru64::nxm_shared> rad_state(0x14000,
932 rad_state_size);
933 rad_state.copyIn(xc->mem);
934
935 uint64_t uniq_val = attrp->pthid - rad_state->nxm_uniq_offset;
936
937 if (attrp->type == Tru64::NXM_TYPE_MANAGER) {
938 // DEC pthreads seems to always create one of these (in
939 // addition to N application threads), but we don't use it,
940 // so don't bother creating it.
941
942 // This is supposed to be a port number. Make something up.
943 *kidp = 99;
944 kidp.copyOut(xc->mem);
945
946 return 0;
947 } else if (attrp->type == Tru64::NXM_TYPE_VP) {
948 // A real "virtual processor" kernel thread. Need to fork
949 // this thread on another CPU.
950 Tru64::nxm_sched_state *ssp = &rad_state->nxm_ss[thread_index];
951
952 if (ssp->nxm_u.nxm_active != 0)
953 return Tru64::KERN_NOT_RECEIVER;
954
955 ssp->nxm_u.pth_id = attrp->pthid;
956 ssp->nxm_u.nxm_active = uniq_val | 1;
957
958 rad_state.copyOut(xc->mem);
959
960 Addr slot_state_addr = 0x12000 + sizeof(Tru64::nxm_config_info);
961 int slot_state_size =
962 process->numCpus() * sizeof(Tru64::nxm_slot_state_t);
963
964 TypedBufferArg<Tru64::nxm_slot_state_t>
965 slot_state(slot_state_addr,
966 slot_state_size);
967
968 slot_state.copyIn(xc->mem);
969
970 if (slot_state[thread_index] != Tru64::NXM_SLOT_AVAIL) {
971 cerr << "nxm_thread_createFunc: requested VP slot "
972 << thread_index << " not available!" << endl;
973 fatal("");
974 }
975
976 slot_state[thread_index] = Tru64::NXM_SLOT_BOUND;
977
978 slot_state.copyOut(xc->mem);
979
980 // Find a free simulator execution context.
981 for (int i = 0; i < process->numCpus(); ++i) {
982 ExecContext *xc = process->execContexts[i];
983
984 if (xc->status() == ExecContext::Unallocated) {
985 // inactive context... grab it
986 init_exec_context(xc, attrp, uniq_val);
987
988 // This is supposed to be a port number, but we'll try
989 // and get away with just sticking the thread index
990 // here.
991 *kidp = thread_index;
992 kidp.copyOut(xc->mem);
993
994 return 0;
995 }
996 }
997
998 // fell out of loop... no available inactive context
999 cerr << "nxm_thread_create: no idle contexts available." << endl;
1000 abort();
1001 } else {
1002 cerr << "nxm_thread_create: can't handle thread type "
1003 << attrp->type << endl;
1004 abort();
1005 }
1006
1007 return 0;
1008 }
1009
1010 /// Thread idle call (like yield()).
1011 static int
1012 nxm_idleFunc(SyscallDesc *desc, int callnum, Process *process,
1013 ExecContext *xc)
1014 {
1015 return 0;
1016 }
1017
1018 /// Block thread.
1019 static int
1020 nxm_thread_blockFunc(SyscallDesc *desc, int callnum, Process *process,
1021 ExecContext *xc)
1022 {
1023 uint64_t tid = xc->getSyscallArg(0);
1024 uint64_t secs = xc->getSyscallArg(1);
1025 uint64_t flags = xc->getSyscallArg(2);
1026 uint64_t action = xc->getSyscallArg(3);
1027 uint64_t usecs = xc->getSyscallArg(4);
1028
1029 cout << xc->cpu->name() << ": nxm_thread_block " << tid << " " << secs
1030 << " " << flags << " " << action << " " << usecs << endl;
1031
1032 return 0;
1033 }
1034
1035 /// block.
1036 static int
1037 nxm_blockFunc(SyscallDesc *desc, int callnum, Process *process,
1038 ExecContext *xc)
1039 {
1040 Addr uaddr = xc->getSyscallArg(0);
1041 uint64_t val = xc->getSyscallArg(1);
1042 uint64_t secs = xc->getSyscallArg(2);
1043 uint64_t usecs = xc->getSyscallArg(3);
1044 uint64_t flags = xc->getSyscallArg(4);
1045
1046 BaseCPU *cpu = xc->cpu;
1047
1048 cout << cpu->name() << ": nxm_block "
1049 << hex << uaddr << dec << " " << val
1050 << " " << secs << " " << usecs
1051 << " " << flags << endl;
1052
1053 return 0;
1054 }
1055
1056 /// Unblock thread.
1057 static int
1058 nxm_unblockFunc(SyscallDesc *desc, int callnum, Process *process,
1059 ExecContext *xc)
1060 {
1061 Addr uaddr = xc->getSyscallArg(0);
1062
1063 cout << xc->cpu->name() << ": nxm_unblock "
1064 << hex << uaddr << dec << endl;
1065
1066 return 0;
1067 }
1068
1069 /// Switch thread priority.
1070 static int
1071 swtch_priFunc(SyscallDesc *desc, int callnum, Process *process,
1072 ExecContext *xc)
1073 {
1074 // Attempts to switch to another runnable thread (if there is
1075 // one). Returns false if there are no other threads to run
1076 // (i.e., the thread can reasonably spin-wait) or true if there
1077 // are other threads.
1078 //
1079 // Since we assume at most one "kernel" thread per CPU, it's
1080 // always safe to return false here.
1081 return false;
1082 }
1083
1084
1085 /// Activate exec context waiting on a channel. Just activate one
1086 /// by default.
1087 static int
1088 activate_waiting_context(Addr uaddr, Process *process,
1089 bool activate_all = false)
1090 {
1091 int num_activated = 0;
1092
1093 list<Process::WaitRec>::iterator i = process->waitList.begin();
1094 list<Process::WaitRec>::iterator end = process->waitList.end();
1095
1096 while (i != end && (num_activated == 0 || activate_all)) {
1097 if (i->waitChan == uaddr) {
1098 // found waiting process: make it active
1099 ExecContext *newCtx = i->waitingContext;
1100 assert(newCtx->status() == ExecContext::Suspended);
1101 newCtx->activate();
1102
1103 // get rid of this record
1104 i = process->waitList.erase(i);
1105
1106 ++num_activated;
1107 } else {
1108 ++i;
1109 }
1110 }
1111
1112 return num_activated;
1113 }
1114
1115 /// M5 hacked-up lock acquire.
1116 static void
1117 m5_lock_mutex(Addr uaddr, Process *process, ExecContext *xc)
1118 {
1119 TypedBufferArg<uint64_t> lockp(uaddr);
1120
1121 lockp.copyIn(xc->mem);
1122
1123 if (*lockp == 0) {
1124 // lock is free: grab it
1125 *lockp = 1;
1126 lockp.copyOut(xc->mem);
1127 } else {
1128 // lock is busy: disable until free
1129 process->waitList.push_back(Process::WaitRec(uaddr, xc));
1130 xc->suspend();
1131 }
1132 }
1133
1134 /// M5 unlock call.
1135 static void
1136 m5_unlock_mutex(Addr uaddr, Process *process, ExecContext *xc)
1137 {
1138 TypedBufferArg<uint64_t> lockp(uaddr);
1139
1140 lockp.copyIn(xc->mem);
1141 assert(*lockp != 0);
1142
1143 // Check for a process waiting on the lock.
1144 int num_waiting = activate_waiting_context(uaddr, process);
1145
1146 // clear lock field if no waiting context is taking over the lock
1147 if (num_waiting == 0) {
1148 *lockp = 0;
1149 lockp.copyOut(xc->mem);
1150 }
1151 }
1152
1153 /// Lock acquire syscall handler.
1154 static int
1155 m5_mutex_lockFunc(SyscallDesc *desc, int callnum, Process *process,
1156 ExecContext *xc)
1157 {
1158 Addr uaddr = xc->getSyscallArg(0);
1159
1160 m5_lock_mutex(uaddr, process, xc);
1161
1162 // Return 0 since we will always return to the user with the lock
1163 // acquired. We will just keep the context inactive until that is
1164 // true.
1165 return 0;
1166 }
1167
1168 /// Try lock (non-blocking).
1169 static int
1170 m5_mutex_trylockFunc(SyscallDesc *desc, int callnum, Process *process,
1171 ExecContext *xc)
1172 {
1173 Addr uaddr = xc->getSyscallArg(0);
1174 TypedBufferArg<uint64_t> lockp(uaddr);
1175
1176 lockp.copyIn(xc->mem);
1177
1178 if (*lockp == 0) {
1179 // lock is free: grab it
1180 *lockp = 1;
1181 lockp.copyOut(xc->mem);
1182 return 0;
1183 } else {
1184 return 1;
1185 }
1186 }
1187
1188 /// Unlock syscall handler.
1189 static int
1190 m5_mutex_unlockFunc(SyscallDesc *desc, int callnum, Process *process,
1191 ExecContext *xc)
1192 {
1193 Addr uaddr = xc->getSyscallArg(0);
1194
1195 m5_unlock_mutex(uaddr, process, xc);
1196
1197 return 0;
1198 }
1199
1200 /// Signal ocndition.
1201 static int
1202 m5_cond_signalFunc(SyscallDesc *desc, int callnum, Process *process,
1203 ExecContext *xc)
1204 {
1205 Addr cond_addr = xc->getSyscallArg(0);
1206
1207 // Wake up one process waiting on the condition variable.
1208 activate_waiting_context(cond_addr, process);
1209
1210 return 0;
1211 }
1212
1213 /// Wake up all processes waiting on the condition variable.
1214 static int
1215 m5_cond_broadcastFunc(SyscallDesc *desc, int callnum, Process *process,
1216 ExecContext *xc)
1217 {
1218 Addr cond_addr = xc->getSyscallArg(0);
1219
1220 activate_waiting_context(cond_addr, process, true);
1221
1222 return 0;
1223 }
1224
1225 /// Wait on a condition.
1226 static int
1227 m5_cond_waitFunc(SyscallDesc *desc, int callnum, Process *process,
1228 ExecContext *xc)
1229 {
1230 Addr cond_addr = xc->getSyscallArg(0);
1231 Addr lock_addr = xc->getSyscallArg(1);
1232 TypedBufferArg<uint64_t> condp(cond_addr);
1233 TypedBufferArg<uint64_t> lockp(lock_addr);
1234
1235 // user is supposed to acquire lock before entering
1236 lockp.copyIn(xc->mem);
1237 assert(*lockp != 0);
1238
1239 m5_unlock_mutex(lock_addr, process, xc);
1240
1241 process->waitList.push_back(Process::WaitRec(cond_addr, xc));
1242 xc->suspend();
1243
1244 return 0;
1245 }
1246
1247 /// Thread exit.
1248 static int
1249 m5_thread_exitFunc(SyscallDesc *desc, int callnum, Process *process,
1250 ExecContext *xc)
1251 {
1252 assert(xc->status() == ExecContext::Active);
1253 xc->deallocate();
1254
1255 return 0;
1256 }
1257
1258 /// Array of syscall descriptors for Mach syscalls, indexed by
1259 /// (negated) call number.
1260 static SyscallDesc machSyscallDescs[];
1261
1262 /// Number of syscalls in machSyscallDescs[].
1263 static const int Num_Mach_Syscall_Descs;
1264
1265 /// Max supported Mach syscall number.
1266 static const int Max_Mach_Syscall_Desc;
1267
1268 /// Since negated values are used to identify Mach syscalls, the
1269 /// minimum (signed) valid syscall number is the negated max Mach
1270 /// syscall number.
1271 static const int Min_Syscall_Desc;
1272
1273 /// Do the specified syscall. Just looks the call number up in
1274 /// the table and invokes the appropriate handler.
1275 static void
1276 doSyscall(int callnum, Process *process, ExecContext *xc)
1277 {
1278 if (callnum < Min_Syscall_Desc || callnum > Max_Syscall_Desc) {
1279 cerr << "Syscall " << callnum << " out of range" << endl;
1280 abort();
1281 }
1282
1283 SyscallDesc *desc =
1284 (callnum < 0) ?
1285 &machSyscallDescs[-callnum] : &syscallDescs[callnum];
1286
1287 desc->doSyscall(callnum, process, xc);
1288 }
1289
1290 /// Indirect syscall invocation (call #0).
1291 static int
1292 indirectSyscallFunc(SyscallDesc *desc, int callnum, Process *process,
1293 ExecContext *xc)
1294 {
1295 int new_callnum = xc->getSyscallArg(0);
1296
1297 for (int i = 0; i < 5; ++i)
1298 xc->setSyscallArg(i, xc->getSyscallArg(i+1));
1299
1300 doSyscall(new_callnum, process, xc);
1301
1302 return 0;
1303 }
1304
1305 }; // class Tru64
1306
1307
1308 // open(2) flags translation table
1309 OpenFlagTransTable Tru64::openFlagTable[] = {
1310 #ifdef _MSC_VER
1311 { Tru64::TGT_O_RDONLY, _O_RDONLY },
1312 { Tru64::TGT_O_WRONLY, _O_WRONLY },
1313 { Tru64::TGT_O_RDWR, _O_RDWR },
1314 { Tru64::TGT_O_APPEND, _O_APPEND },
1315 { Tru64::TGT_O_CREAT, _O_CREAT },
1316 { Tru64::TGT_O_TRUNC, _O_TRUNC },
1317 { Tru64::TGT_O_EXCL, _O_EXCL },
1318 #ifdef _O_NONBLOCK
1319 { Tru64::TGT_O_NONBLOCK, _O_NONBLOCK },
1320 #endif
1321 #ifdef _O_NOCTTY
1322 { Tru64::TGT_O_NOCTTY, _O_NOCTTY },
1323 #endif
1324 #ifdef _O_SYNC
1325 { Tru64::TGT_O_SYNC, _O_SYNC },
1326 #endif
1327 #else /* !_MSC_VER */
1328 { Tru64::TGT_O_RDONLY, O_RDONLY },
1329 { Tru64::TGT_O_WRONLY, O_WRONLY },
1330 { Tru64::TGT_O_RDWR, O_RDWR },
1331 { Tru64::TGT_O_APPEND, O_APPEND },
1332 { Tru64::TGT_O_CREAT, O_CREAT },
1333 { Tru64::TGT_O_TRUNC, O_TRUNC },
1334 { Tru64::TGT_O_EXCL, O_EXCL },
1335 { Tru64::TGT_O_NONBLOCK, O_NONBLOCK },
1336 { Tru64::TGT_O_NOCTTY, O_NOCTTY },
1337 #ifdef O_SYNC
1338 { Tru64::TGT_O_SYNC, O_SYNC },
1339 #endif
1340 #endif /* _MSC_VER */
1341 };
1342
1343 const int Tru64::NUM_OPEN_FLAGS = (sizeof(Tru64::openFlagTable)/sizeof(Tru64::openFlagTable[0]));
1344
1345 const char *Tru64::hostname = "m5.eecs.umich.edu";
1346
1347 SyscallDesc Tru64::syscallDescs[] = {
1348 /* 0 */ SyscallDesc("syscall (#0)", indirectSyscallFunc,
1349 SyscallDesc::SuppressReturnValue),
1350 /* 1 */ SyscallDesc("exit", exitFunc),
1351 /* 2 */ SyscallDesc("fork", unimplementedFunc),
1352 /* 3 */ SyscallDesc("read", readFunc),
1353 /* 4 */ SyscallDesc("write", writeFunc),
1354 /* 5 */ SyscallDesc("old_open", unimplementedFunc),
1355 /* 6 */ SyscallDesc("close", closeFunc),
1356 /* 7 */ SyscallDesc("wait4", unimplementedFunc),
1357 /* 8 */ SyscallDesc("old_creat", unimplementedFunc),
1358 /* 9 */ SyscallDesc("link", unimplementedFunc),
1359 /* 10 */ SyscallDesc("unlink", unimplementedFunc),
1360 /* 11 */ SyscallDesc("execv", unimplementedFunc),
1361 /* 12 */ SyscallDesc("chdir", unimplementedFunc),
1362 /* 13 */ SyscallDesc("fchdir", unimplementedFunc),
1363 /* 14 */ SyscallDesc("mknod", unimplementedFunc),
1364 /* 15 */ SyscallDesc("chmod", unimplementedFunc),
1365 /* 16 */ SyscallDesc("chown", unimplementedFunc),
1366 /* 17 */ SyscallDesc("obreak", obreakFunc),
1367 /* 18 */ SyscallDesc("pre_F64_getfsstat", unimplementedFunc),
1368 /* 19 */ SyscallDesc("lseek", lseekFunc),
1369 /* 20 */ SyscallDesc("getpid", getpidFunc),
1370 /* 21 */ SyscallDesc("mount", unimplementedFunc),
1371 /* 22 */ SyscallDesc("unmount", unimplementedFunc),
1372 /* 23 */ SyscallDesc("setuid", setuidFunc),
1373 /* 24 */ SyscallDesc("getuid", getuidFunc),
1374 /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc),
1375 /* 26 */ SyscallDesc("ptrace", unimplementedFunc),
1376 /* 27 */ SyscallDesc("recvmsg", unimplementedFunc),
1377 /* 28 */ SyscallDesc("sendmsg", unimplementedFunc),
1378 /* 29 */ SyscallDesc("recvfrom", unimplementedFunc),
1379 /* 30 */ SyscallDesc("accept", unimplementedFunc),
1380 /* 31 */ SyscallDesc("getpeername", unimplementedFunc),
1381 /* 32 */ SyscallDesc("getsockname", unimplementedFunc),
1382 /* 33 */ SyscallDesc("access", unimplementedFunc),
1383 /* 34 */ SyscallDesc("chflags", unimplementedFunc),
1384 /* 35 */ SyscallDesc("fchflags", unimplementedFunc),
1385 /* 36 */ SyscallDesc("sync", unimplementedFunc),
1386 /* 37 */ SyscallDesc("kill", unimplementedFunc),
1387 /* 38 */ SyscallDesc("old_stat", unimplementedFunc),
1388 /* 39 */ SyscallDesc("setpgid", unimplementedFunc),
1389 /* 40 */ SyscallDesc("old_lstat", unimplementedFunc),
1390 /* 41 */ SyscallDesc("dup", unimplementedFunc),
1391 /* 42 */ SyscallDesc("pipe", unimplementedFunc),
1392 /* 43 */ SyscallDesc("set_program_attributes", unimplementedFunc),
1393 /* 44 */ SyscallDesc("profil", unimplementedFunc),
1394 /* 45 */ SyscallDesc("open", openFunc<Tru64>),
1395 /* 46 */ SyscallDesc("obsolete osigaction", unimplementedFunc),
1396 /* 47 */ SyscallDesc("getgid", getgidFunc),
1397 /* 48 */ SyscallDesc("sigprocmask", ignoreFunc),
1398 /* 49 */ SyscallDesc("getlogin", unimplementedFunc),
1399 /* 50 */ SyscallDesc("setlogin", unimplementedFunc),
1400 /* 51 */ SyscallDesc("acct", unimplementedFunc),
1401 /* 52 */ SyscallDesc("sigpending", unimplementedFunc),
1402 /* 53 */ SyscallDesc("classcntl", unimplementedFunc),
1403 /* 54 */ SyscallDesc("ioctl", ioctlFunc<Tru64>),
1404 /* 55 */ SyscallDesc("reboot", unimplementedFunc),
1405 /* 56 */ SyscallDesc("revoke", unimplementedFunc),
1406 /* 57 */ SyscallDesc("symlink", unimplementedFunc),
1407 /* 58 */ SyscallDesc("readlink", unimplementedFunc),
1408 /* 59 */ SyscallDesc("execve", unimplementedFunc),
1409 /* 60 */ SyscallDesc("umask", unimplementedFunc),
1410 /* 61 */ SyscallDesc("chroot", unimplementedFunc),
1411 /* 62 */ SyscallDesc("old_fstat", unimplementedFunc),
1412 /* 63 */ SyscallDesc("getpgrp", unimplementedFunc),
1413 /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc),
1414 /* 65 */ SyscallDesc("mremap", unimplementedFunc),
1415 /* 66 */ SyscallDesc("vfork", unimplementedFunc),
1416 /* 67 */ SyscallDesc("pre_F64_stat", unimplementedFunc),
1417 /* 68 */ SyscallDesc("pre_F64_lstat", unimplementedFunc),
1418 /* 69 */ SyscallDesc("sbrk", unimplementedFunc),
1419 /* 70 */ SyscallDesc("sstk", unimplementedFunc),
1420 /* 71 */ SyscallDesc("mmap", mmapFunc<Tru64>),
1421 /* 72 */ SyscallDesc("ovadvise", unimplementedFunc),
1422 /* 73 */ SyscallDesc("munmap", munmapFunc),
1423 /* 74 */ SyscallDesc("mprotect", ignoreFunc),
1424 /* 75 */ SyscallDesc("madvise", unimplementedFunc),
1425 /* 76 */ SyscallDesc("old_vhangup", unimplementedFunc),
1426 /* 77 */ SyscallDesc("kmodcall", unimplementedFunc),
1427 /* 78 */ SyscallDesc("mincore", unimplementedFunc),
1428 /* 79 */ SyscallDesc("getgroups", unimplementedFunc),
1429 /* 80 */ SyscallDesc("setgroups", unimplementedFunc),
1430 /* 81 */ SyscallDesc("old_getpgrp", unimplementedFunc),
1431 /* 82 */ SyscallDesc("setpgrp", unimplementedFunc),
1432 /* 83 */ SyscallDesc("setitimer", unimplementedFunc),
1433 /* 84 */ SyscallDesc("old_wait", unimplementedFunc),
1434 /* 85 */ SyscallDesc("table", tableFunc),
1435 /* 86 */ SyscallDesc("getitimer", unimplementedFunc),
1436 /* 87 */ SyscallDesc("gethostname", gethostnameFunc),
1437 /* 88 */ SyscallDesc("sethostname", unimplementedFunc),
1438 /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc),
1439 /* 90 */ SyscallDesc("dup2", unimplementedFunc),
1440 /* 91 */ SyscallDesc("pre_F64_fstat", unimplementedFunc),
1441 /* 92 */ SyscallDesc("fcntl", fcntlFunc),
1442 /* 93 */ SyscallDesc("select", unimplementedFunc),
1443 /* 94 */ SyscallDesc("poll", unimplementedFunc),
1444 /* 95 */ SyscallDesc("fsync", unimplementedFunc),
1445 /* 96 */ SyscallDesc("setpriority", unimplementedFunc),
1446 /* 97 */ SyscallDesc("socket", unimplementedFunc),
1447 /* 98 */ SyscallDesc("connect", unimplementedFunc),
1448 /* 99 */ SyscallDesc("old_accept", unimplementedFunc),
1449 /* 100 */ SyscallDesc("getpriority", unimplementedFunc),
1450 /* 101 */ SyscallDesc("old_send", unimplementedFunc),
1451 /* 102 */ SyscallDesc("old_recv", unimplementedFunc),
1452 /* 103 */ SyscallDesc("sigreturn", sigreturnFunc,
1453 SyscallDesc::SuppressReturnValue),
1454 /* 104 */ SyscallDesc("bind", unimplementedFunc),
1455 /* 105 */ SyscallDesc("setsockopt", unimplementedFunc),
1456 /* 106 */ SyscallDesc("listen", unimplementedFunc),
1457 /* 107 */ SyscallDesc("plock", unimplementedFunc),
1458 /* 108 */ SyscallDesc("old_sigvec", unimplementedFunc),
1459 /* 109 */ SyscallDesc("old_sigblock", unimplementedFunc),
1460 /* 110 */ SyscallDesc("old_sigsetmask", unimplementedFunc),
1461 /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc),
1462 /* 112 */ SyscallDesc("sigstack", ignoreFunc),
1463 /* 113 */ SyscallDesc("old_recvmsg", unimplementedFunc),
1464 /* 114 */ SyscallDesc("old_sendmsg", unimplementedFunc),
1465 /* 115 */ SyscallDesc("obsolete vtrace", unimplementedFunc),
1466 /* 116 */ SyscallDesc("gettimeofday", gettimeofdayFunc<Tru64>),
1467 /* 117 */ SyscallDesc("getrusage", getrusageFunc<Tru64>),
1468 /* 118 */ SyscallDesc("getsockopt", unimplementedFunc),
1469 /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc),
1470 /* 120 */ SyscallDesc("readv", unimplementedFunc),
1471 /* 121 */ SyscallDesc("writev", unimplementedFunc),
1472 /* 122 */ SyscallDesc("settimeofday", unimplementedFunc),
1473 /* 123 */ SyscallDesc("fchown", unimplementedFunc),
1474 /* 124 */ SyscallDesc("fchmod", unimplementedFunc),
1475 /* 125 */ SyscallDesc("old_recvfrom", unimplementedFunc),
1476 /* 126 */ SyscallDesc("setreuid", unimplementedFunc),
1477 /* 127 */ SyscallDesc("setregid", unimplementedFunc),
1478 /* 128 */ SyscallDesc("rename", unimplementedFunc),
1479 /* 129 */ SyscallDesc("truncate", unimplementedFunc),
1480 /* 130 */ SyscallDesc("ftruncate", unimplementedFunc),
1481 /* 131 */ SyscallDesc("flock", unimplementedFunc),
1482 /* 132 */ SyscallDesc("setgid", unimplementedFunc),
1483 /* 133 */ SyscallDesc("sendto", unimplementedFunc),
1484 /* 134 */ SyscallDesc("shutdown", unimplementedFunc),
1485 /* 135 */ SyscallDesc("socketpair", unimplementedFunc),
1486 /* 136 */ SyscallDesc("mkdir", unimplementedFunc),
1487 /* 137 */ SyscallDesc("rmdir", unimplementedFunc),
1488 /* 138 */ SyscallDesc("utimes", unimplementedFunc),
1489 /* 139 */ SyscallDesc("obsolete 4.2 sigreturn", unimplementedFunc),
1490 /* 140 */ SyscallDesc("adjtime", unimplementedFunc),
1491 /* 141 */ SyscallDesc("old_getpeername", unimplementedFunc),
1492 /* 142 */ SyscallDesc("gethostid", unimplementedFunc),
1493 /* 143 */ SyscallDesc("sethostid", unimplementedFunc),
1494 /* 144 */ SyscallDesc("getrlimit", getrlimitFunc<Tru64>),
1495 /* 145 */ SyscallDesc("setrlimit", unimplementedFunc),
1496 /* 146 */ SyscallDesc("old_killpg", unimplementedFunc),
1497 /* 147 */ SyscallDesc("setsid", unimplementedFunc),
1498 /* 148 */ SyscallDesc("quotactl", unimplementedFunc),
1499 /* 149 */ SyscallDesc("oldquota", unimplementedFunc),
1500 /* 150 */ SyscallDesc("old_getsockname", unimplementedFunc),
1501 /* 151 */ SyscallDesc("pread", unimplementedFunc),
1502 /* 152 */ SyscallDesc("pwrite", unimplementedFunc),
1503 /* 153 */ SyscallDesc("pid_block", unimplementedFunc),
1504 /* 154 */ SyscallDesc("pid_unblock", unimplementedFunc),
1505 /* 155 */ SyscallDesc("signal_urti", unimplementedFunc),
1506 /* 156 */ SyscallDesc("sigaction", ignoreFunc),
1507 /* 157 */ SyscallDesc("sigwaitprim", unimplementedFunc),
1508 /* 158 */ SyscallDesc("nfssvc", unimplementedFunc),
1509 /* 159 */ SyscallDesc("getdirentries", getdirentriesFunc),
1510 /* 160 */ SyscallDesc("pre_F64_statfs", unimplementedFunc),
1511 /* 161 */ SyscallDesc("pre_F64_fstatfs", unimplementedFunc),
1512 /* 162 */ SyscallDesc("unknown #162", unimplementedFunc),
1513 /* 163 */ SyscallDesc("async_daemon", unimplementedFunc),
1514 /* 164 */ SyscallDesc("getfh", unimplementedFunc),
1515 /* 165 */ SyscallDesc("getdomainname", unimplementedFunc),
1516 /* 166 */ SyscallDesc("setdomainname", unimplementedFunc),
1517 /* 167 */ SyscallDesc("unknown #167", unimplementedFunc),
1518 /* 168 */ SyscallDesc("unknown #168", unimplementedFunc),
1519 /* 169 */ SyscallDesc("exportfs", unimplementedFunc),
1520 /* 170 */ SyscallDesc("unknown #170", unimplementedFunc),
1521 /* 171 */ SyscallDesc("unknown #171", unimplementedFunc),
1522 /* 172 */ SyscallDesc("unknown #172", unimplementedFunc),
1523 /* 173 */ SyscallDesc("unknown #173", unimplementedFunc),
1524 /* 174 */ SyscallDesc("unknown #174", unimplementedFunc),
1525 /* 175 */ SyscallDesc("unknown #175", unimplementedFunc),
1526 /* 176 */ SyscallDesc("unknown #176", unimplementedFunc),
1527 /* 177 */ SyscallDesc("unknown #177", unimplementedFunc),
1528 /* 178 */ SyscallDesc("unknown #178", unimplementedFunc),
1529 /* 179 */ SyscallDesc("unknown #179", unimplementedFunc),
1530 /* 180 */ SyscallDesc("unknown #180", unimplementedFunc),
1531 /* 181 */ SyscallDesc("alt_plock", unimplementedFunc),
1532 /* 182 */ SyscallDesc("unknown #182", unimplementedFunc),
1533 /* 183 */ SyscallDesc("unknown #183", unimplementedFunc),
1534 /* 184 */ SyscallDesc("getmnt", unimplementedFunc),
1535 /* 185 */ SyscallDesc("unknown #185", unimplementedFunc),
1536 /* 186 */ SyscallDesc("unknown #186", unimplementedFunc),
1537 /* 187 */ SyscallDesc("alt_sigpending", unimplementedFunc),
1538 /* 188 */ SyscallDesc("alt_setsid", unimplementedFunc),
1539 /* 189 */ SyscallDesc("unknown #189", unimplementedFunc),
1540 /* 190 */ SyscallDesc("unknown #190", unimplementedFunc),
1541 /* 191 */ SyscallDesc("unknown #191", unimplementedFunc),
1542 /* 192 */ SyscallDesc("unknown #192", unimplementedFunc),
1543 /* 193 */ SyscallDesc("unknown #193", unimplementedFunc),
1544 /* 194 */ SyscallDesc("unknown #194", unimplementedFunc),
1545 /* 195 */ SyscallDesc("unknown #195", unimplementedFunc),
1546 /* 196 */ SyscallDesc("unknown #196", unimplementedFunc),
1547 /* 197 */ SyscallDesc("unknown #197", unimplementedFunc),
1548 /* 198 */ SyscallDesc("unknown #198", unimplementedFunc),
1549 /* 199 */ SyscallDesc("swapon", unimplementedFunc),
1550 /* 200 */ SyscallDesc("msgctl", unimplementedFunc),
1551 /* 201 */ SyscallDesc("msgget", unimplementedFunc),
1552 /* 202 */ SyscallDesc("msgrcv", unimplementedFunc),
1553 /* 203 */ SyscallDesc("msgsnd", unimplementedFunc),
1554 /* 204 */ SyscallDesc("semctl", unimplementedFunc),
1555 /* 205 */ SyscallDesc("semget", unimplementedFunc),
1556 /* 206 */ SyscallDesc("semop", unimplementedFunc),
1557 /* 207 */ SyscallDesc("uname", unameFunc),
1558 /* 208 */ SyscallDesc("lchown", unimplementedFunc),
1559 /* 209 */ SyscallDesc("shmat", unimplementedFunc),
1560 /* 210 */ SyscallDesc("shmctl", unimplementedFunc),
1561 /* 211 */ SyscallDesc("shmdt", unimplementedFunc),
1562 /* 212 */ SyscallDesc("shmget", unimplementedFunc),
1563 /* 213 */ SyscallDesc("mvalid", unimplementedFunc),
1564 /* 214 */ SyscallDesc("getaddressconf", unimplementedFunc),
1565 /* 215 */ SyscallDesc("msleep", unimplementedFunc),
1566 /* 216 */ SyscallDesc("mwakeup", unimplementedFunc),
1567 /* 217 */ SyscallDesc("msync", unimplementedFunc),
1568 /* 218 */ SyscallDesc("signal", unimplementedFunc),
1569 /* 219 */ SyscallDesc("utc_gettime", unimplementedFunc),
1570 /* 220 */ SyscallDesc("utc_adjtime", unimplementedFunc),
1571 /* 221 */ SyscallDesc("unknown #221", unimplementedFunc),
1572 /* 222 */ SyscallDesc("security", unimplementedFunc),
1573 /* 223 */ SyscallDesc("kloadcall", unimplementedFunc),
1574 /* 224 */ SyscallDesc("stat", statFunc<Tru64>),
1575 /* 225 */ SyscallDesc("lstat", lstatFunc<Tru64>),
1576 /* 226 */ SyscallDesc("fstat", fstatFunc<Tru64>),
1577 /* 227 */ SyscallDesc("statfs", unimplementedFunc),
1578 /* 228 */ SyscallDesc("fstatfs", unimplementedFunc),
1579 /* 229 */ SyscallDesc("getfsstat", unimplementedFunc),
1580 /* 230 */ SyscallDesc("gettimeofday64", unimplementedFunc),
1581 /* 231 */ SyscallDesc("settimeofday64", unimplementedFunc),
1582 /* 232 */ SyscallDesc("unknown #232", unimplementedFunc),
1583 /* 233 */ SyscallDesc("getpgid", unimplementedFunc),
1584 /* 234 */ SyscallDesc("getsid", unimplementedFunc),
1585 /* 235 */ SyscallDesc("sigaltstack", ignoreFunc),
1586 /* 236 */ SyscallDesc("waitid", unimplementedFunc),
1587 /* 237 */ SyscallDesc("priocntlset", unimplementedFunc),
1588 /* 238 */ SyscallDesc("sigsendset", unimplementedFunc),
1589 /* 239 */ SyscallDesc("set_speculative", unimplementedFunc),
1590 /* 240 */ SyscallDesc("msfs_syscall", unimplementedFunc),
1591 /* 241 */ SyscallDesc("sysinfo", unimplementedFunc),
1592 /* 242 */ SyscallDesc("uadmin", unimplementedFunc),
1593 /* 243 */ SyscallDesc("fuser", unimplementedFunc),
1594 /* 244 */ SyscallDesc("proplist_syscall", unimplementedFunc),
1595 /* 245 */ SyscallDesc("ntp_adjtime", unimplementedFunc),
1596 /* 246 */ SyscallDesc("ntp_gettime", unimplementedFunc),
1597 /* 247 */ SyscallDesc("pathconf", unimplementedFunc),
1598 /* 248 */ SyscallDesc("fpathconf", unimplementedFunc),
1599 /* 249 */ SyscallDesc("sync2", unimplementedFunc),
1600 /* 250 */ SyscallDesc("uswitch", unimplementedFunc),
1601 /* 251 */ SyscallDesc("usleep_thread", unimplementedFunc),
1602 /* 252 */ SyscallDesc("audcntl", unimplementedFunc),
1603 /* 253 */ SyscallDesc("audgen", unimplementedFunc),
1604 /* 254 */ SyscallDesc("sysfs", unimplementedFunc),
1605 /* 255 */ SyscallDesc("subsys_info", unimplementedFunc),
1606 /* 256 */ SyscallDesc("getsysinfo", getsysinfoFunc),
1607 /* 257 */ SyscallDesc("setsysinfo", unimplementedFunc),
1608 /* 258 */ SyscallDesc("afs_syscall", unimplementedFunc),
1609 /* 259 */ SyscallDesc("swapctl", unimplementedFunc),
1610 /* 260 */ SyscallDesc("memcntl", unimplementedFunc),
1611 /* 261 */ SyscallDesc("fdatasync", unimplementedFunc),
1612 /* 262 */ SyscallDesc("oflock", unimplementedFunc),
1613 /* 263 */ SyscallDesc("F64_readv", unimplementedFunc),
1614 /* 264 */ SyscallDesc("F64_writev", unimplementedFunc),
1615 /* 265 */ SyscallDesc("cdslxlate", unimplementedFunc),
1616 /* 266 */ SyscallDesc("sendfile", unimplementedFunc),
1617 };
1618
1619 const int Tru64::Num_Syscall_Descs =
1620 sizeof(Tru64::syscallDescs) / sizeof(SyscallDesc);
1621
1622 const int Tru64::Max_Syscall_Desc = Tru64::Num_Syscall_Descs - 1;
1623
1624 SyscallDesc Tru64::machSyscallDescs[] = {
1625 /* 0 */ SyscallDesc("kern_invalid", unimplementedFunc),
1626 /* 1 */ SyscallDesc("m5_mutex_lock", m5_mutex_lockFunc),
1627 /* 2 */ SyscallDesc("m5_mutex_trylock", m5_mutex_trylockFunc),
1628 /* 3 */ SyscallDesc("m5_mutex_unlock", m5_mutex_unlockFunc),
1629 /* 4 */ SyscallDesc("m5_cond_signal", m5_cond_signalFunc),
1630 /* 5 */ SyscallDesc("m5_cond_broadcast", m5_cond_broadcastFunc),
1631 /* 6 */ SyscallDesc("m5_cond_wait", m5_cond_waitFunc),
1632 /* 7 */ SyscallDesc("m5_thread_exit", m5_thread_exitFunc),
1633 /* 8 */ SyscallDesc("kern_invalid", unimplementedFunc),
1634 /* 9 */ SyscallDesc("kern_invalid", unimplementedFunc),
1635 /* 10 */ SyscallDesc("task_self", unimplementedFunc),
1636 /* 11 */ SyscallDesc("thread_reply", unimplementedFunc),
1637 /* 12 */ SyscallDesc("task_notify", unimplementedFunc),
1638 /* 13 */ SyscallDesc("thread_self", unimplementedFunc),
1639 /* 14 */ SyscallDesc("kern_invalid", unimplementedFunc),
1640 /* 15 */ SyscallDesc("kern_invalid", unimplementedFunc),
1641 /* 16 */ SyscallDesc("kern_invalid", unimplementedFunc),
1642 /* 17 */ SyscallDesc("kern_invalid", unimplementedFunc),
1643 /* 18 */ SyscallDesc("kern_invalid", unimplementedFunc),
1644 /* 19 */ SyscallDesc("kern_invalid", unimplementedFunc),
1645 /* 20 */ SyscallDesc("msg_send_trap", unimplementedFunc),
1646 /* 21 */ SyscallDesc("msg_receive_trap", unimplementedFunc),
1647 /* 22 */ SyscallDesc("msg_rpc_trap", unimplementedFunc),
1648 /* 23 */ SyscallDesc("kern_invalid", unimplementedFunc),
1649 /* 24 */ SyscallDesc("nxm_block", nxm_blockFunc),
1650 /* 25 */ SyscallDesc("nxm_unblock", nxm_unblockFunc),
1651 /* 26 */ SyscallDesc("kern_invalid", unimplementedFunc),
1652 /* 27 */ SyscallDesc("kern_invalid", unimplementedFunc),
1653 /* 28 */ SyscallDesc("kern_invalid", unimplementedFunc),
1654 /* 29 */ SyscallDesc("nxm_thread_destroy", unimplementedFunc),
1655 /* 30 */ SyscallDesc("lw_wire", unimplementedFunc),
1656 /* 31 */ SyscallDesc("lw_unwire", unimplementedFunc),
1657 /* 32 */ SyscallDesc("nxm_thread_create", nxm_thread_createFunc),
1658 /* 33 */ SyscallDesc("nxm_task_init", nxm_task_initFunc),
1659 /* 34 */ SyscallDesc("kern_invalid", unimplementedFunc),
1660 /* 35 */ SyscallDesc("nxm_idle", nxm_idleFunc),
1661 /* 36 */ SyscallDesc("nxm_wakeup_idle", unimplementedFunc),
1662 /* 37 */ SyscallDesc("nxm_set_pthid", unimplementedFunc),
1663 /* 38 */ SyscallDesc("nxm_thread_kill", unimplementedFunc),
1664 /* 39 */ SyscallDesc("nxm_thread_block", nxm_thread_blockFunc),
1665 /* 40 */ SyscallDesc("nxm_thread_wakeup", unimplementedFunc),
1666 /* 41 */ SyscallDesc("init_process", unimplementedFunc),
1667 /* 42 */ SyscallDesc("nxm_get_binding", unimplementedFunc),
1668 /* 43 */ SyscallDesc("map_fd", unimplementedFunc),
1669 /* 44 */ SyscallDesc("nxm_resched", unimplementedFunc),
1670 /* 45 */ SyscallDesc("nxm_set_cancel", unimplementedFunc),
1671 /* 46 */ SyscallDesc("nxm_set_binding", unimplementedFunc),
1672 /* 47 */ SyscallDesc("stack_create", stack_createFunc),
1673 /* 48 */ SyscallDesc("nxm_get_state", unimplementedFunc),
1674 /* 49 */ SyscallDesc("nxm_thread_suspend", unimplementedFunc),
1675 /* 50 */ SyscallDesc("nxm_thread_resume", unimplementedFunc),
1676 /* 51 */ SyscallDesc("nxm_signal_check", unimplementedFunc),
1677 /* 52 */ SyscallDesc("htg_unix_syscall", unimplementedFunc),
1678 /* 53 */ SyscallDesc("kern_invalid", unimplementedFunc),
1679 /* 54 */ SyscallDesc("kern_invalid", unimplementedFunc),
1680 /* 55 */ SyscallDesc("host_self", unimplementedFunc),
1681 /* 56 */ SyscallDesc("host_priv_self", unimplementedFunc),
1682 /* 57 */ SyscallDesc("kern_invalid", unimplementedFunc),
1683 /* 58 */ SyscallDesc("kern_invalid", unimplementedFunc),
1684 /* 59 */ SyscallDesc("swtch_pri", swtch_priFunc),
1685 /* 60 */ SyscallDesc("swtch", unimplementedFunc),
1686 /* 61 */ SyscallDesc("thread_switch", unimplementedFunc),
1687 /* 62 */ SyscallDesc("semop_fast", unimplementedFunc),
1688 /* 63 */ SyscallDesc("nxm_pshared_init", unimplementedFunc),
1689 /* 64 */ SyscallDesc("nxm_pshared_block", unimplementedFunc),
1690 /* 65 */ SyscallDesc("nxm_pshared_unblock", unimplementedFunc),
1691 /* 66 */ SyscallDesc("nxm_pshared_destroy", unimplementedFunc),
1692 /* 67 */ SyscallDesc("nxm_swtch_pri", swtch_priFunc),
1693 /* 68 */ SyscallDesc("lw_syscall", unimplementedFunc),
1694 /* 69 */ SyscallDesc("kern_invalid", unimplementedFunc),
1695 /* 70 */ SyscallDesc("mach_sctimes_0", unimplementedFunc),
1696 /* 71 */ SyscallDesc("mach_sctimes_1", unimplementedFunc),
1697 /* 72 */ SyscallDesc("mach_sctimes_2", unimplementedFunc),
1698 /* 73 */ SyscallDesc("mach_sctimes_3", unimplementedFunc),
1699 /* 74 */ SyscallDesc("mach_sctimes_4", unimplementedFunc),
1700 /* 75 */ SyscallDesc("mach_sctimes_5", unimplementedFunc),
1701 /* 76 */ SyscallDesc("mach_sctimes_6", unimplementedFunc),
1702 /* 77 */ SyscallDesc("mach_sctimes_7", unimplementedFunc),
1703 /* 78 */ SyscallDesc("mach_sctimes_8", unimplementedFunc),
1704 /* 79 */ SyscallDesc("mach_sctimes_9", unimplementedFunc),
1705 /* 80 */ SyscallDesc("mach_sctimes_10", unimplementedFunc),
1706 /* 81 */ SyscallDesc("mach_sctimes_11", unimplementedFunc),
1707 /* 82 */ SyscallDesc("mach_sctimes_port_alloc_dealloc", unimplementedFunc)
1708 };
1709
1710 const int Tru64::Num_Mach_Syscall_Descs =
1711 sizeof(Tru64::machSyscallDescs) / sizeof(SyscallDesc);
1712 const int Tru64::Max_Mach_Syscall_Desc = Tru64::Num_Mach_Syscall_Descs - 1;
1713 const int Tru64::Min_Syscall_Desc = -Tru64::Max_Mach_Syscall_Desc;
1714
1715
1716 void
1717 AlphaTru64Process::syscall(ExecContext *xc)
1718 {
1719 num_syscalls++;
1720
1721 int64_t callnum = xc->regs.intRegFile[ReturnValueReg];
1722
1723 Tru64::doSyscall(callnum, this, xc);
1724 }
1725
1726
1727 AlphaTru64Process::AlphaTru64Process(const std::string &name,
1728 ObjectFile *objFile,
1729 int stdin_fd,
1730 int stdout_fd,
1731 int stderr_fd,
1732 std::vector<std::string> &argv,
1733 std::vector<std::string> &envp)
1734 : LiveProcess(name, objFile, stdin_fd, stdout_fd, stderr_fd, argv, envp)
1735 {
1736 }