2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
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.
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.
29 #include <sys/types.h>
31 #if defined(__OpenBSD__)
32 #include <sys/param.h>
33 #include <sys/mount.h>
35 #include <sys/statfs.h>
40 #include <fcntl.h> // for host open() flags
41 #include <string.h> // for memset()
44 #include "arch/alpha/isa_traits.hh"
45 #include "arch/alpha/alpha_common_syscall_emul.hh"
46 #include "arch/alpha/alpha_tru64_process.hh"
47 #include "base/trace.hh"
48 #include "cpu/base.hh"
49 #include "cpu/exec_context.hh"
50 #include "mem/functional/functional.hh"
51 #include "sim/fake_syscall.hh"
52 #include "sim/host.hh"
53 #include "sim/process.hh"
54 #include "sim/root.hh"
55 #include "sim/syscall_emul.hh"
59 typedef struct stat global_stat
;
60 typedef struct statfs global_statfs
;
61 typedef struct dirent global_dirent
;
64 /// This class encapsulates the types, structures, constants,
65 /// functions, and syscall-number mappings specific to the Alpha Tru64
66 /// syscall interface.
73 /// Basic Tru64 types.
74 typedef uint64_t size_t;
75 typedef uint64_t off_t
;
76 typedef uint16_t nlink_t
;
77 typedef int32_t dev_t
;
78 typedef uint32_t uid_t
;
79 typedef uint32_t gid_t
;
80 typedef uint32_t time_t;
81 typedef uint32_t mode_t
;
82 typedef uint32_t ino_t
;
83 typedef struct { int val
[2]; } quad
;
88 /// open(2) flag values.
89 static const int TGT_O_RDONLY
= 00000000;
90 static const int TGT_O_WRONLY
= 00000001;
91 static const int TGT_O_RDWR
= 00000002;
92 static const int TGT_O_NONBLOCK
= 00000004;
93 static const int TGT_O_APPEND
= 00000010;
94 static const int TGT_O_CREAT
= 00001000;
95 static const int TGT_O_TRUNC
= 00002000;
96 static const int TGT_O_EXCL
= 00004000;
97 static const int TGT_O_NOCTTY
= 00010000;
98 static const int TGT_O_SYNC
= 00040000;
99 static const int TGT_O_DRD
= 00100000;
100 static const int TGT_O_DIRECTIO
= 00200000;
101 static const int TGT_O_CACHE
= 00400000;
102 static const int TGT_O_DSYNC
= 02000000;
103 static const int TGT_O_RSYNC
= 04000000;
106 /// This table maps the target open() flags to the corresponding
107 /// host open() flags.
108 static OpenFlagTransTable openFlagTable
[];
110 /// Number of entries in openFlagTable[].
111 static const int NUM_OPEN_FLAGS
;
113 /// Stat buffer. Note that Tru64 v5.0+ use a new "F64" stat
114 /// structure, and a new set of syscall numbers for stat calls.
115 /// On some hosts (notably Linux) define st_atime, st_mtime, and
116 /// st_ctime as macros, so we append an X to get around this.
118 dev_t st_dev
; //!< st_dev
119 int32_t st_retired1
; //!< st_retired1
120 mode_t st_mode
; //!< st_mode
121 nlink_t st_nlink
; //!< st_nlink
122 uint16_t st_nlink_reserved
; //!< st_nlink_reserved
123 uid_t st_uid
; //!< st_uid
124 gid_t st_gid
; //!< st_gid
125 dev_t st_rdev
; //!< st_rdev
126 dev_t st_ldev
; //!< st_ldev
127 off_t st_size
; //!< st_size
128 time_t st_retired2
; //!< st_retired2
129 int32_t st_uatime
; //!< st_uatime
130 time_t st_retired3
; //!< st_retired3
131 int32_t st_umtime
; //!< st_umtime
132 time_t st_retired4
; //!< st_retired4
133 int32_t st_uctime
; //!< st_uctime
134 int32_t st_retired5
; //!< st_retired5
135 int32_t st_retired6
; //!< st_retired6
136 uint32_t st_flags
; //!< st_flags
137 uint32_t st_gen
; //!< st_gen
138 uint64_t st_spare
[4]; //!< st_spare[4]
139 ino_t st_ino
; //!< st_ino
140 int32_t st_ino_reserved
; //!< st_ino_reserved
141 time_t st_atimeX
; //!< st_atime
142 int32_t st_atime_reserved
; //!< st_atime_reserved
143 time_t st_mtimeX
; //!< st_mtime
144 int32_t st_mtime_reserved
; //!< st_mtime_reserved
145 time_t st_ctimeX
; //!< st_ctime
146 int32_t st_ctime_reserved
; //!< st_ctime_reserved
147 uint64_t st_blksize
; //!< st_blksize
148 uint64_t st_blocks
; //!< st_blocks
152 /// Old Tru64 v4.x stat struct.
153 /// Tru64 maintains backwards compatibility with v4.x by
154 /// implementing another set of stat functions using the old
155 /// structure definition and binding them to the old syscall
157 struct pre_F64_stat
{
193 uint64_t dummy
[10]; // was union mount_info mount_info;
195 int64_t f_spare2
[14];
203 char f_mntonname
[1024];
204 char f_mntfromname
[1024];
207 /// For old Tru64 v4.x statfs()
208 struct pre_F64_statfs
{
220 char f_mntonname
[90];
221 char f_mntfromname
[90];
222 uint64_t dummy
[10]; // was union mount_info mount_info;
225 /// For getdirentries().
228 ino_t d_ino
; //!< file number of entry
229 uint16_t d_reclen
; //!< length of this record
230 uint16_t d_namlen
; //!< length of string in d_name
231 char d_name
[256]; //!< dummy name length
235 /// Length of strings in struct utsname (plus 1 for null char).
236 static const int _SYS_NMLN
= 32;
238 /// Interface struct for uname().
240 char sysname
[_SYS_NMLN
]; //!< System name.
241 char nodename
[_SYS_NMLN
]; //!< Node name.
242 char release
[_SYS_NMLN
]; //!< OS release.
243 char version
[_SYS_NMLN
]; //!< OS version.
244 char machine
[_SYS_NMLN
]; //!< Machine type.
248 /// ioctl() command codes.
249 static const unsigned TIOCGETP
= 0x40067408;
250 static const unsigned TIOCSETP
= 0x80067409;
251 static const unsigned TIOCSETN
= 0x8006740a;
252 static const unsigned TIOCSETC
= 0x80067411;
253 static const unsigned TIOCGETC
= 0x40067412;
254 static const unsigned FIONREAD
= 0x4004667f;
255 static const unsigned TIOCISATTY
= 0x2000745e;
256 // TIOCGETS not defined in tru64, so I made up a number
257 static const unsigned TIOCGETS
= 0x40000000;
258 static const unsigned TIOCGETA
= 0x402c7413;
261 /// Resource enumeration for getrlimit().
262 enum rlimit_resources
{
274 /// Limit struct for getrlimit/setrlimit.
276 uint64_t rlim_cur
; //!< soft limit
277 uint64_t rlim_max
; //!< hard limit
282 static const unsigned TGT_MAP_ANONYMOUS
= 0x10;
286 /// For getsysinfo().
287 static const unsigned GSI_PLATFORM_NAME
= 103; //!< platform name as string
288 static const unsigned GSI_CPU_INFO
= 59; //!< CPU information
289 static const unsigned GSI_PROC_TYPE
= 60; //!< get proc_type
290 static const unsigned GSI_MAX_CPU
= 30; //!< max # cpu's on this machine
291 static const unsigned GSI_CPUS_IN_BOX
= 55; //!< number of CPUs in system
292 static const unsigned GSI_PHYSMEM
= 19; //!< Physical memory in KB
293 static const unsigned GSI_CLK_TCK
= 42; //!< clock freq in Hz
296 /// For getsysinfo() GSI_CPU_INFO option.
298 uint32_t current_cpu
; //!< current_cpu
299 uint32_t cpus_in_box
; //!< cpus_in_box
300 uint32_t cpu_type
; //!< cpu_type
301 uint32_t ncpus
; //!< ncpus
302 uint64_t cpus_present
; //!< cpus_present
303 uint64_t cpus_running
; //!< cpus_running
304 uint64_t cpu_binding
; //!< cpu_binding
305 uint64_t cpu_ex_binding
; //!< cpu_ex_binding
306 uint32_t mhz
; //!< mhz
307 uint32_t unused
[3]; //!< future expansion
311 /// For setsysinfo().
312 static const unsigned SSI_IEEE_FP_CONTROL
= 14; //!< ieee_set_fp_control()
315 /// For gettimeofday.
317 uint32_t tv_sec
; //!< seconds
318 uint32_t tv_usec
; //!< microseconds
323 static const int RUSAGE_THREAD
= 1;
324 static const int RUSAGE_SELF
= 0;
325 static const int RUSAGE_CHILDREN
= -1;
330 struct timeval ru_utime
; //!< user time used
331 struct timeval ru_stime
; //!< system time used
332 uint64_t ru_maxrss
; //!< ru_maxrss
333 uint64_t ru_ixrss
; //!< integral shared memory size
334 uint64_t ru_idrss
; //!< integral unshared data "
335 uint64_t ru_isrss
; //!< integral unshared stack "
336 uint64_t ru_minflt
; //!< page reclaims - total vmfaults
337 uint64_t ru_majflt
; //!< page faults
338 uint64_t ru_nswap
; //!< swaps
339 uint64_t ru_inblock
; //!< block input operations
340 uint64_t ru_oublock
; //!< block output operations
341 uint64_t ru_msgsnd
; //!< messages sent
342 uint64_t ru_msgrcv
; //!< messages received
343 uint64_t ru_nsignals
; //!< signals received
344 uint64_t ru_nvcsw
; //!< voluntary context switches
345 uint64_t ru_nivcsw
; //!< involuntary "
350 int64_t sc_onstack
; //!< sigstack state to restore
351 int64_t sc_mask
; //!< signal mask to restore
352 int64_t sc_pc
; //!< pc at time of signal
353 int64_t sc_ps
; //!< psl to retore
354 int64_t sc_regs
[32]; //!< processor regs 0 to 31
355 int64_t sc_ownedfp
; //!< fp has been used
356 int64_t sc_fpregs
[32]; //!< fp regs 0 to 31
357 uint64_t sc_fpcr
; //!< floating point control reg
358 uint64_t sc_fp_control
; //!< software fpcr
359 int64_t sc_reserved1
; //!< reserved for kernel
360 uint32_t sc_kreserved1
; //!< reserved for kernel
361 uint32_t sc_kreserved2
; //!< reserved for kernel
362 size_t sc_ssize
; //!< stack size
363 caddr_t sc_sbase
; //!< stack start
364 uint64_t sc_traparg_a0
; //!< a0 argument to trap on exc
365 uint64_t sc_traparg_a1
; //!< a1 argument to trap on exc
366 uint64_t sc_traparg_a2
; //!< a2 argument to trap on exc
367 uint64_t sc_fp_trap_pc
; //!< imprecise pc
368 uint64_t sc_fp_trigger_sum
; //!< Exception summary at trigg
369 uint64_t sc_fp_trigger_inst
; //!< Instruction at trigger pc
374 static const int TBL_SYSINFO
= 12;
378 uint64_t si_user
; //!< User time
379 uint64_t si_nice
; //!< Nice time
380 uint64_t si_sys
; //!< System time
381 uint64_t si_idle
; //!< Idle time
382 uint64_t si_hz
; //!< hz
383 uint64_t si_phz
; //!< phz
384 uint64_t si_boottime
; //!< Boot time in seconds
385 uint64_t wait
; //!< Wait time
386 uint32_t si_max_procs
; //!< rpb->rpb_numprocs
387 uint32_t pad
; //!< padding
391 /// For stack_create.
394 Addr address
; //!< address hint
395 size_t rsize
; //!< red zone size
396 size_t ysize
; //!< yellow zone size
397 size_t gsize
; //!< green zone size
398 size_t swap
; //!< amount of swap to reserve
399 size_t incr
; //!< growth increment
400 uint64_t align
; //!< address alignment
401 uint64_t flags
; //!< MAP_FIXED etc.
402 // was struct memalloc_attr *
403 Addr attr
; //!< allocation policy
404 uint64_t reserved
; //!< reserved
407 /// Return values for nxm calls.
409 KERN_NOT_RECEIVER
= 7,
413 /// For nxm_task_init.
414 static const int NXM_TASK_INIT_VP
= 2; //!< initial thread is VP
416 /// Task attribute structure.
417 struct nxm_task_attr
{
418 int64_t nxm_callback
; //!< nxm_callback
419 unsigned int nxm_version
; //!< nxm_version
420 unsigned short nxm_uniq_offset
; //!< nxm_uniq_offset
421 unsigned short flags
; //!< flags
422 int nxm_quantum
; //!< nxm_quantum
424 int64_t pad2
; //!< pad2
428 typedef uint64_t sigset_t
;
430 /// Thread state shared between user & kernel.
431 struct ushared_state
{
432 sigset_t sigmask
; //!< thread signal mask
433 sigset_t sig
; //!< thread pending mask
434 // struct nxm_pth_state *
435 Addr pth_id
; //!< out-of-line state
436 int flags
; //!< shared flags
437 #define US_SIGSTACK 0x1 // thread called sigaltstack
438 #define US_ONSTACK 0x2 // thread is running on altstack
439 #define US_PROFILE 0x4 // thread called profil
440 #define US_SYSCALL 0x8 // thread in syscall
441 #define US_TRAP 0x10 // thread has trapped
442 #define US_YELLOW 0x20 // thread has mellowed yellow
443 #define US_YZONE 0x40 // thread has zoned out
444 #define US_FP_OWNED 0x80 // thread used floating point
446 int cancel_state
; //!< thread's cancelation state
447 #define US_CANCEL 0x1 // cancel pending
448 #define US_NOCANCEL 0X2 // synch cancel disabled
449 #define US_SYS_NOCANCEL 0x4 // syscall cancel disabled
450 #define US_ASYNC_NOCANCEL 0x8 // asynch cancel disabled
451 #define US_CANCEL_BITS (US_NOCANCEL|US_SYS_NOCANCEL|US_ASYNC_NOCANCEL)
452 #define US_CANCEL_MASK (US_CANCEL|US_NOCANCEL|US_SYS_NOCANCEL| \
455 // These are semi-shared. They are always visible to
456 // the kernel but are never context-switched by the library.
458 int nxm_ssig
; //!< scheduler's synchronous signals
459 int reserved1
; //!< reserved1
460 int64_t nxm_active
; //!< scheduler active
461 int64_t reserved2
; //!< reserved2
464 struct nxm_sched_state
{
465 struct ushared_state nxm_u
; //!< state own by user thread
466 unsigned int nxm_bits
; //!< scheduler state / slot
467 int nxm_quantum
; //!< quantum count-down value
468 int nxm_set_quantum
; //!< quantum reset value
469 int nxm_sysevent
; //!< syscall state
470 // struct nxm_upcall *
471 Addr nxm_uc_ret
; //!< stack ptr of null thread
473 Addr nxm_tid
; //!< scheduler's thread id
474 int64_t nxm_va
; //!< page fault address
475 // struct nxm_pth_state *
476 Addr nxm_pthid
; //!< id of null thread
477 uint64_t nxm_bound_pcs_count
; //!< bound PCS thread count
478 int64_t pad
[2]; //!< pad
483 int64_t nxm_callback
; //!< address of upcall routine
484 unsigned int nxm_version
; //!< version number
485 unsigned short nxm_uniq_offset
; //!< correction factor for TEB
486 unsigned short pad1
; //!< pad1
487 int64_t space
[2]; //!< future growth
488 struct nxm_sched_state nxm_ss
[1]; //!< array of shared areas
491 /// nxm_slot_state_t.
492 enum nxm_slot_state_t
{
500 struct nxm_config_info
{
501 int nxm_nslots_per_rad
; //!< max number of VP slots per RAD
502 int nxm_nrads
; //!< max number of RADs
503 // nxm_slot_state_t *
504 Addr nxm_slot_state
; //!< per-VP slot state
505 // struct nxm_shared *
506 Addr nxm_rad
[1]; //!< per-RAD shared areas
509 /// For nxm_thread_create.
510 enum nxm_thread_type
{
516 /// Thread attributes.
517 struct nxm_thread_attr
{
518 int version
; //!< version
520 int cancel_flags
; //!< cancel_flags
521 int priority
; //!< priority
522 int policy
; //!< policy
523 int signal_type
; //!< signal_type
525 Addr pthid
; //!< pthid
526 sigset_t sigmask
; //!< sigmask
527 /// Initial register values.
533 uint64_t pad2
[2]; //!< pad2
536 /// Helper function to convert a host stat buffer to a target stat
537 /// buffer. Also copies the target buffer out to the simulated
538 /// memory space. Used by stat(), fstat(), and lstat().
541 copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
, global_stat
*host
)
543 TypedBufferArg
<T
> tgt(addr
);
545 tgt
->st_dev
= host
->st_dev
;
546 tgt
->st_ino
= host
->st_ino
;
547 tgt
->st_mode
= host
->st_mode
;
548 tgt
->st_nlink
= host
->st_nlink
;
549 tgt
->st_uid
= host
->st_uid
;
550 tgt
->st_gid
= host
->st_gid
;
551 tgt
->st_rdev
= host
->st_rdev
;
552 tgt
->st_size
= host
->st_size
;
553 tgt
->st_atimeX
= host
->st_atime
;
554 tgt
->st_mtimeX
= host
->st_mtime
;
555 tgt
->st_ctimeX
= host
->st_ctime
;
556 tgt
->st_blksize
= host
->st_blksize
;
557 tgt
->st_blocks
= host
->st_blocks
;
562 /// Helper function to convert a host statfs buffer to a target statfs
563 /// buffer. Also copies the target buffer out to the simulated
564 /// memory space. Used by statfs() and fstatfs().
567 copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
, global_statfs
*host
)
569 TypedBufferArg
<T
> tgt(addr
);
571 #if defined(__OpenBSD__)
574 tgt
->f_type
= host
->f_type
;
576 tgt
->f_bsize
= host
->f_bsize
;
577 tgt
->f_blocks
= host
->f_blocks
;
578 tgt
->f_bfree
= host
->f_bfree
;
579 tgt
->f_bavail
= host
->f_bavail
;
580 tgt
->f_files
= host
->f_files
;
581 tgt
->f_ffree
= host
->f_ffree
;
582 memcpy(&tgt
->f_fsid
, &host
->f_fsid
, sizeof(host
->f_fsid
));
589 static void copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
,
592 Tru64::copyOutStatBuf
<Tru64::F64_stat
>(mem
, addr
, host
);
595 static void copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
,
598 Tru64::copyOutStatfsBuf
<Tru64::F64_statfs
>(mem
, addr
, host
);
604 static void copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
,
607 Tru64::copyOutStatBuf
<Tru64::pre_F64_stat
>(mem
, addr
, host
);
610 static void copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
,
613 Tru64::copyOutStatfsBuf
<Tru64::pre_F64_statfs
>(mem
, addr
, host
);
617 /// Helper function to convert a host stat buffer to an old pre-F64
618 /// (4.x) target stat buffer. Also copies the target buffer out to
619 /// the simulated memory space. Used by pre_F64_stat(),
620 /// pre_F64_fstat(), and pre_F64_lstat().
622 copyOutPreF64StatBuf(FunctionalMemory
*mem
, Addr addr
, struct stat
*host
)
624 TypedBufferArg
<Tru64::pre_F64_stat
> tgt(addr
);
626 tgt
->st_dev
= host
->st_dev
;
627 tgt
->st_ino
= host
->st_ino
;
628 tgt
->st_mode
= host
->st_mode
;
629 tgt
->st_nlink
= host
->st_nlink
;
630 tgt
->st_uid
= host
->st_uid
;
631 tgt
->st_gid
= host
->st_gid
;
632 tgt
->st_rdev
= host
->st_rdev
;
633 tgt
->st_size
= host
->st_size
;
634 tgt
->st_atimeX
= host
->st_atime
;
635 tgt
->st_mtimeX
= host
->st_mtime
;
636 tgt
->st_ctimeX
= host
->st_ctime
;
637 tgt
->st_blksize
= host
->st_blksize
;
638 tgt
->st_blocks
= host
->st_blocks
;
644 /// The target system's hostname.
645 static const char *hostname
;
647 /// Target uname() handler.
649 unameFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
652 TypedBufferArg
<Tru64::utsname
> name(xc
->getSyscallArg(0));
654 strcpy(name
->sysname
, "OSF1");
655 strcpy(name
->nodename
, hostname
);
656 strcpy(name
->release
, "V5.1");
657 strcpy(name
->version
, "732");
658 strcpy(name
->machine
, "alpha");
660 name
.copyOut(xc
->mem
);
665 /// Target getsysyinfo() handler.
667 getsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
670 unsigned op
= xc
->getSyscallArg(0);
671 unsigned nbytes
= xc
->getSyscallArg(2);
675 case Tru64::GSI_MAX_CPU
: {
676 TypedBufferArg
<uint32_t> max_cpu(xc
->getSyscallArg(1));
677 *max_cpu
= process
->numCpus();
678 max_cpu
.copyOut(xc
->mem
);
682 case Tru64::GSI_CPUS_IN_BOX
: {
683 TypedBufferArg
<uint32_t> cpus_in_box(xc
->getSyscallArg(1));
684 *cpus_in_box
= process
->numCpus();
685 cpus_in_box
.copyOut(xc
->mem
);
689 case Tru64::GSI_PHYSMEM
: {
690 TypedBufferArg
<uint64_t> physmem(xc
->getSyscallArg(1));
691 *physmem
= 1024 * 1024; // physical memory in KB
692 physmem
.copyOut(xc
->mem
);
696 case Tru64::GSI_CPU_INFO
: {
697 TypedBufferArg
<Tru64::cpu_info
> infop(xc
->getSyscallArg(1));
699 infop
->current_cpu
= 0;
700 infop
->cpus_in_box
= process
->numCpus();
701 infop
->cpu_type
= 57;
702 infop
->ncpus
= process
->numCpus();
703 int cpumask
= (1 << process
->numCpus()) - 1;
704 infop
->cpus_present
= infop
->cpus_running
= cpumask
;
705 infop
->cpu_binding
= 0;
706 infop
->cpu_ex_binding
= 0;
709 infop
.copyOut(xc
->mem
);
713 case Tru64::GSI_PROC_TYPE
: {
714 TypedBufferArg
<uint64_t> proc_type(xc
->getSyscallArg(1));
716 proc_type
.copyOut(xc
->mem
);
720 case Tru64::GSI_PLATFORM_NAME
: {
721 BufferArg
bufArg(xc
->getSyscallArg(1), nbytes
);
722 strncpy((char *)bufArg
.bufferPtr(),
723 "COMPAQ Professional Workstation XP1000",
725 bufArg
.copyOut(xc
->mem
);
729 case Tru64::GSI_CLK_TCK
: {
730 TypedBufferArg
<uint64_t> clk_hz(xc
->getSyscallArg(1));
732 clk_hz
.copyOut(xc
->mem
);
737 warn("getsysinfo: unknown op %d\n", op
);
744 /// Target setsysyinfo() handler.
746 setsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
749 unsigned op
= xc
->getSyscallArg(0);
752 case SSI_IEEE_FP_CONTROL
:
753 warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n",
754 xc
->getSyscallArg(1));
758 warn("setsysinfo: unknown op %d\n", op
);
765 /// Target fnctl() handler.
767 fcntlFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
770 int fd
= xc
->getSyscallArg(0);
772 if (fd
< 0 || process
->sim_fd(fd
) < 0)
775 int cmd
= xc
->getSyscallArg(1);
778 // if we really wanted to support this, we'd need to do it
779 // in the target fd space.
780 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd
);
783 case 1: // F_GETFD (get close-on-exec flag)
784 case 2: // F_SETFD (set close-on-exec flag)
787 case 3: // F_GETFL (get file flags)
788 case 4: // F_SETFL (set file flags)
789 // not sure if this is totally valid, but we'll pass it through
790 // to the underlying OS
791 warn("fcntl(%d, %d) passed through to host\n", fd
, cmd
);
792 return fcntl(process
->sim_fd(fd
), cmd
);
795 case 7: // F_GETLK (get lock)
796 case 8: // F_SETLK (set lock)
797 case 9: // F_SETLKW (set lock and wait)
798 // don't mess with file locking... just act like it's OK
799 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd
, cmd
);
803 warn("Unknown fcntl command %d\n", cmd
);
809 /// Target getdirentries() handler.
811 getdirentriesFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
815 panic("getdirent not implemented on cygwin!");
817 int fd
= process
->sim_fd(xc
->getSyscallArg(0));
818 Addr tgt_buf
= xc
->getSyscallArg(1);
819 int tgt_nbytes
= xc
->getSyscallArg(2);
820 Addr tgt_basep
= xc
->getSyscallArg(3);
822 char * const host_buf
= new char[tgt_nbytes
];
824 // just pass basep through uninterpreted.
825 TypedBufferArg
<int64_t> basep(tgt_basep
);
826 basep
.copyIn(xc
->mem
);
827 long host_basep
= (off_t
)*basep
;
828 int host_result
= getdirentries(fd
, host_buf
, tgt_nbytes
, &host_basep
);
831 if (host_result
< 0) {
836 // no error: copy results back to target space
837 Addr tgt_buf_ptr
= tgt_buf
;
838 char *host_buf_ptr
= host_buf
;
839 char *host_buf_end
= host_buf
+ host_result
;
840 while (host_buf_ptr
< host_buf_end
) {
841 global_dirent
*host_dp
= (global_dirent
*)host_buf_ptr
;
842 int namelen
= strlen(host_dp
->d_name
);
844 // Actual size includes padded string rounded up for alignment.
845 // Subtract 256 for dummy char array in Tru64::dirent definition.
846 // Add 1 to namelen for terminating null char.
847 int tgt_bufsize
= sizeof(Tru64::dirent
) - 256 + roundUp(namelen
+1, 8);
848 TypedBufferArg
<Tru64::dirent
> tgt_dp(tgt_buf_ptr
, tgt_bufsize
);
849 tgt_dp
->d_ino
= host_dp
->d_ino
;
850 tgt_dp
->d_reclen
= tgt_bufsize
;
851 tgt_dp
->d_namlen
= namelen
;
852 strcpy(tgt_dp
->d_name
, host_dp
->d_name
);
853 tgt_dp
.copyOut(xc
->mem
);
855 tgt_buf_ptr
+= tgt_bufsize
;
856 host_buf_ptr
+= host_dp
->d_reclen
;
862 basep
.copyOut(xc
->mem
);
864 return tgt_buf_ptr
- tgt_buf
;
868 /// Target sigreturn() handler.
870 sigreturnFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
873 RegFile
*regs
= &xc
->regs
;
874 TypedBufferArg
<Tru64::sigcontext
> sc(xc
->getSyscallArg(0));
878 // Restore state from sigcontext structure.
879 // Note that we'll advance PC <- NPC before the end of the cycle,
880 // so we need to restore the desired PC into NPC.
881 // The current regs->pc will get clobbered.
882 regs
->npc
= sc
->sc_pc
;
884 for (int i
= 0; i
< 31; ++i
) {
885 regs
->intRegFile
[i
] = sc
->sc_regs
[i
];
886 regs
->floatRegFile
.q
[i
] = sc
->sc_fpregs
[i
];
889 regs
->miscRegs
.fpcr
= sc
->sc_fpcr
;
894 /// Target table() handler.
896 tableFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
899 int id
= xc
->getSyscallArg(0); // table ID
900 int index
= xc
->getSyscallArg(1); // index into table
901 // arg 2 is buffer pointer; type depends on table ID
902 int nel
= xc
->getSyscallArg(3); // number of elements
903 int lel
= xc
->getSyscallArg(4); // expected element size
906 case Tru64::TBL_SYSINFO
: {
907 if (index
!= 0 || nel
!= 1 || lel
!= sizeof(Tru64::tbl_sysinfo
))
909 TypedBufferArg
<Tru64::tbl_sysinfo
> elp(xc
->getSyscallArg(2));
911 const int clk_hz
= one_million
;
912 elp
->si_user
= curTick
/ (Clock::Frequency
/ clk_hz
);
918 elp
->si_phz
= clk_hz
;
919 elp
->si_boottime
= seconds_since_epoch
; // seconds since epoch?
920 elp
->si_max_procs
= process
->numCpus();
921 elp
.copyOut(xc
->mem
);
926 cerr
<< "table(): id " << id
<< " unknown." << endl
;
931 /// Array of syscall descriptors, indexed by call number.
932 static SyscallDesc syscallDescs
[];
934 /// Number of syscalls in syscallDescs[].
935 static const int Num_Syscall_Descs
;
937 /// Max supported syscall number.
938 static const int Max_Syscall_Desc
;
941 // Mach syscalls -- identified by negated syscall numbers
944 /// Create a stack region for a thread.
946 stack_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
949 TypedBufferArg
<Tru64::vm_stack
> argp(xc
->getSyscallArg(0));
951 argp
.copyIn(xc
->mem
);
953 // if the user chose an address, just let them have it. Otherwise
954 // pick one for them.
955 if (argp
->address
== 0) {
956 argp
->address
= process
->next_thread_stack_base
;
957 int stack_size
= (argp
->rsize
+ argp
->ysize
+ argp
->gsize
);
958 process
->next_thread_stack_base
-= stack_size
;
959 argp
.copyOut(xc
->mem
);
965 /// NXM library version stamp.
967 const int NXM_LIB_VERSION
= 301003;
969 /// This call sets up the interface between the user and kernel
970 /// schedulers by creating a shared-memory region. The shared memory
971 /// region has several structs, some global, some per-RAD, some per-VP.
973 nxm_task_initFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
976 TypedBufferArg
<Tru64::nxm_task_attr
> attrp(xc
->getSyscallArg(0));
977 TypedBufferArg
<Addr
> configptr_ptr(xc
->getSyscallArg(1));
979 attrp
.copyIn(xc
->mem
);
981 if (attrp
->nxm_version
!= NXM_LIB_VERSION
) {
982 cerr
<< "nxm_task_init: thread library version mismatch! "
983 << "got " << attrp
->nxm_version
984 << ", expected " << NXM_LIB_VERSION
<< endl
;
988 if (attrp
->flags
!= Tru64::NXM_TASK_INIT_VP
) {
989 cerr
<< "nxm_task_init: bad flag value " << attrp
->flags
990 << " (expected " << Tru64::NXM_TASK_INIT_VP
<< ")" << endl
;
994 const Addr base_addr
= 0x12000; // was 0x3f0000000LL;
995 Addr cur_addr
= base_addr
; // next addresses to use
996 // first comes the config_info struct
997 Addr config_addr
= cur_addr
;
998 cur_addr
+= sizeof(Tru64::nxm_config_info
);
999 // next comes the per-cpu state vector
1000 Addr slot_state_addr
= cur_addr
;
1001 int slot_state_size
=
1002 process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
1003 cur_addr
+= slot_state_size
;
1004 // now the per-RAD state struct (we only support one RAD)
1005 cur_addr
= 0x14000; // bump up addr for alignment
1006 Addr rad_state_addr
= cur_addr
;
1007 int rad_state_size
=
1008 (sizeof(Tru64::nxm_shared
)
1009 + (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
1010 cur_addr
+= rad_state_size
;
1012 // now initialize a config_info struct and copy it out to user space
1013 TypedBufferArg
<Tru64::nxm_config_info
> config(config_addr
);
1015 config
->nxm_nslots_per_rad
= process
->numCpus();
1016 config
->nxm_nrads
= 1; // only one RAD in our system!
1017 config
->nxm_slot_state
= slot_state_addr
;
1018 config
->nxm_rad
[0] = rad_state_addr
;
1020 config
.copyOut(xc
->mem
);
1022 // initialize the slot_state array and copy it out
1023 TypedBufferArg
<Tru64::nxm_slot_state_t
> slot_state(slot_state_addr
,
1025 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1026 // CPU 0 is bound to the calling process; all others are available
1028 (i
== 0) ? Tru64::NXM_SLOT_BOUND
: Tru64::NXM_SLOT_AVAIL
;
1031 slot_state
.copyOut(xc
->mem
);
1033 // same for the per-RAD "shared" struct. Note that we need to
1034 // allocate extra bytes for the per-VP array which is embedded at
1036 TypedBufferArg
<Tru64::nxm_shared
> rad_state(rad_state_addr
,
1039 rad_state
->nxm_callback
= attrp
->nxm_callback
;
1040 rad_state
->nxm_version
= attrp
->nxm_version
;
1041 rad_state
->nxm_uniq_offset
= attrp
->nxm_uniq_offset
;
1042 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1043 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[i
];
1044 ssp
->nxm_u
.sigmask
= 0;
1046 ssp
->nxm_u
.flags
= 0;
1047 ssp
->nxm_u
.cancel_state
= 0;
1048 ssp
->nxm_u
.nxm_ssig
= 0;
1050 ssp
->nxm_quantum
= attrp
->nxm_quantum
;
1051 ssp
->nxm_set_quantum
= attrp
->nxm_quantum
;
1052 ssp
->nxm_sysevent
= 0;
1055 uint64_t uniq
= xc
->regs
.miscRegs
.uniq
;
1056 ssp
->nxm_u
.pth_id
= uniq
+ attrp
->nxm_uniq_offset
;
1057 ssp
->nxm_u
.nxm_active
= uniq
| 1;
1060 ssp
->nxm_u
.pth_id
= 0;
1061 ssp
->nxm_u
.nxm_active
= 0;
1065 rad_state
.copyOut(xc
->mem
);
1068 // copy pointer to shared config area out to user
1070 *configptr_ptr
= config_addr
;
1071 configptr_ptr
.copyOut(xc
->mem
);
1073 // Register this as a valid address range with the process
1074 process
->nxm_start
= base_addr
;
1075 process
->nxm_end
= cur_addr
;
1080 /// Initialize execution context.
1082 init_exec_context(ExecContext
*ec
,
1083 Tru64::nxm_thread_attr
*attrp
, uint64_t uniq_val
)
1085 memset(&ec
->regs
, 0, sizeof(ec
->regs
));
1087 ec
->regs
.intRegFile
[ArgumentReg0
] = attrp
->registers
.a0
;
1088 ec
->regs
.intRegFile
[27/*t12*/] = attrp
->registers
.pc
;
1089 ec
->regs
.intRegFile
[StackPointerReg
] = attrp
->registers
.sp
;
1090 ec
->regs
.miscRegs
.uniq
= uniq_val
;
1092 ec
->regs
.pc
= attrp
->registers
.pc
;
1093 ec
->regs
.npc
= attrp
->registers
.pc
+ sizeof(MachInst
);
1099 static SyscallReturn
1100 nxm_thread_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1103 TypedBufferArg
<Tru64::nxm_thread_attr
> attrp(xc
->getSyscallArg(0));
1104 TypedBufferArg
<uint64_t> kidp(xc
->getSyscallArg(1));
1105 int thread_index
= xc
->getSyscallArg(2);
1107 // get attribute args
1108 attrp
.copyIn(xc
->mem
);
1110 if (attrp
->version
!= NXM_LIB_VERSION
) {
1111 cerr
<< "nxm_thread_create: thread library version mismatch! "
1112 << "got " << attrp
->version
1113 << ", expected " << NXM_LIB_VERSION
<< endl
;
1117 if (thread_index
< 0 | thread_index
> process
->numCpus()) {
1118 cerr
<< "nxm_thread_create: bad thread index " << thread_index
1123 // On a real machine, the per-RAD shared structure is in
1124 // shared memory, so both the user and kernel can get at it.
1125 // We don't have that luxury, so we just copy it in and then
1127 int rad_state_size
=
1128 (sizeof(Tru64::nxm_shared
) +
1129 (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
1131 TypedBufferArg
<Tru64::nxm_shared
> rad_state(0x14000,
1133 rad_state
.copyIn(xc
->mem
);
1135 uint64_t uniq_val
= attrp
->pthid
- rad_state
->nxm_uniq_offset
;
1137 if (attrp
->type
== Tru64::NXM_TYPE_MANAGER
) {
1138 // DEC pthreads seems to always create one of these (in
1139 // addition to N application threads), but we don't use it,
1140 // so don't bother creating it.
1142 // This is supposed to be a port number. Make something up.
1144 kidp
.copyOut(xc
->mem
);
1147 } else if (attrp
->type
== Tru64::NXM_TYPE_VP
) {
1148 // A real "virtual processor" kernel thread. Need to fork
1149 // this thread on another CPU.
1150 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[thread_index
];
1152 if (ssp
->nxm_u
.nxm_active
!= 0)
1153 return (int) Tru64::KERN_NOT_RECEIVER
;
1155 ssp
->nxm_u
.pth_id
= attrp
->pthid
;
1156 ssp
->nxm_u
.nxm_active
= uniq_val
| 1;
1158 rad_state
.copyOut(xc
->mem
);
1160 Addr slot_state_addr
= 0x12000 + sizeof(Tru64::nxm_config_info
);
1161 int slot_state_size
=
1162 process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
1164 TypedBufferArg
<Tru64::nxm_slot_state_t
>
1165 slot_state(slot_state_addr
,
1168 slot_state
.copyIn(xc
->mem
);
1170 if (slot_state
[thread_index
] != Tru64::NXM_SLOT_AVAIL
) {
1171 cerr
<< "nxm_thread_createFunc: requested VP slot "
1172 << thread_index
<< " not available!" << endl
;
1176 slot_state
[thread_index
] = Tru64::NXM_SLOT_BOUND
;
1178 slot_state
.copyOut(xc
->mem
);
1180 // Find a free simulator execution context.
1181 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1182 ExecContext
*xc
= process
->execContexts
[i
];
1184 if (xc
->status() == ExecContext::Unallocated
) {
1185 // inactive context... grab it
1186 init_exec_context(xc
, attrp
, uniq_val
);
1188 // This is supposed to be a port number, but we'll try
1189 // and get away with just sticking the thread index
1191 *kidp
= thread_index
;
1192 kidp
.copyOut(xc
->mem
);
1198 // fell out of loop... no available inactive context
1199 cerr
<< "nxm_thread_create: no idle contexts available." << endl
;
1202 cerr
<< "nxm_thread_create: can't handle thread type "
1203 << attrp
->type
<< endl
;
1210 /// Thread idle call (like yield()).
1211 static SyscallReturn
1212 nxm_idleFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1219 static SyscallReturn
1220 nxm_thread_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1223 uint64_t tid
= xc
->getSyscallArg(0);
1224 uint64_t secs
= xc
->getSyscallArg(1);
1225 uint64_t flags
= xc
->getSyscallArg(2);
1226 uint64_t action
= xc
->getSyscallArg(3);
1227 uint64_t usecs
= xc
->getSyscallArg(4);
1229 cout
<< xc
->cpu
->name() << ": nxm_thread_block " << tid
<< " " << secs
1230 << " " << flags
<< " " << action
<< " " << usecs
<< endl
;
1236 static SyscallReturn
1237 nxm_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1240 Addr uaddr
= xc
->getSyscallArg(0);
1241 uint64_t val
= xc
->getSyscallArg(1);
1242 uint64_t secs
= xc
->getSyscallArg(2);
1243 uint64_t usecs
= xc
->getSyscallArg(3);
1244 uint64_t flags
= xc
->getSyscallArg(4);
1246 BaseCPU
*cpu
= xc
->cpu
;
1248 cout
<< cpu
->name() << ": nxm_block "
1249 << hex
<< uaddr
<< dec
<< " " << val
1250 << " " << secs
<< " " << usecs
1251 << " " << flags
<< endl
;
1257 static SyscallReturn
1258 nxm_unblockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1261 Addr uaddr
= xc
->getSyscallArg(0);
1263 cout
<< xc
->cpu
->name() << ": nxm_unblock "
1264 << hex
<< uaddr
<< dec
<< endl
;
1269 /// Switch thread priority.
1270 static SyscallReturn
1271 swtch_priFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1274 // Attempts to switch to another runnable thread (if there is
1275 // one). Returns false if there are no other threads to run
1276 // (i.e., the thread can reasonably spin-wait) or true if there
1277 // are other threads.
1279 // Since we assume at most one "kernel" thread per CPU, it's
1280 // always safe to return false here.
1285 /// Activate exec context waiting on a channel. Just activate one
1288 activate_waiting_context(Addr uaddr
, Process
*process
,
1289 bool activate_all
= false)
1291 int num_activated
= 0;
1293 list
<Process::WaitRec
>::iterator i
= process
->waitList
.begin();
1294 list
<Process::WaitRec
>::iterator end
= process
->waitList
.end();
1296 while (i
!= end
&& (num_activated
== 0 || activate_all
)) {
1297 if (i
->waitChan
== uaddr
) {
1298 // found waiting process: make it active
1299 ExecContext
*newCtx
= i
->waitingContext
;
1300 assert(newCtx
->status() == ExecContext::Suspended
);
1303 // get rid of this record
1304 i
= process
->waitList
.erase(i
);
1312 return num_activated
;
1315 /// M5 hacked-up lock acquire.
1317 m5_lock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1319 TypedBufferArg
<uint64_t> lockp(uaddr
);
1321 lockp
.copyIn(xc
->mem
);
1324 // lock is free: grab it
1326 lockp
.copyOut(xc
->mem
);
1328 // lock is busy: disable until free
1329 process
->waitList
.push_back(Process::WaitRec(uaddr
, xc
));
1336 m5_unlock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1338 TypedBufferArg
<uint64_t> lockp(uaddr
);
1340 lockp
.copyIn(xc
->mem
);
1341 assert(*lockp
!= 0);
1343 // Check for a process waiting on the lock.
1344 int num_waiting
= activate_waiting_context(uaddr
, process
);
1346 // clear lock field if no waiting context is taking over the lock
1347 if (num_waiting
== 0) {
1349 lockp
.copyOut(xc
->mem
);
1353 /// Lock acquire syscall handler.
1354 static SyscallReturn
1355 m5_mutex_lockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1358 Addr uaddr
= xc
->getSyscallArg(0);
1360 m5_lock_mutex(uaddr
, process
, xc
);
1362 // Return 0 since we will always return to the user with the lock
1363 // acquired. We will just keep the context inactive until that is
1368 /// Try lock (non-blocking).
1369 static SyscallReturn
1370 m5_mutex_trylockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1373 Addr uaddr
= xc
->getSyscallArg(0);
1374 TypedBufferArg
<uint64_t> lockp(uaddr
);
1376 lockp
.copyIn(xc
->mem
);
1379 // lock is free: grab it
1381 lockp
.copyOut(xc
->mem
);
1388 /// Unlock syscall handler.
1389 static SyscallReturn
1390 m5_mutex_unlockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1393 Addr uaddr
= xc
->getSyscallArg(0);
1395 m5_unlock_mutex(uaddr
, process
, xc
);
1400 /// Signal ocndition.
1401 static SyscallReturn
1402 m5_cond_signalFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1405 Addr cond_addr
= xc
->getSyscallArg(0);
1407 // Wake up one process waiting on the condition variable.
1408 activate_waiting_context(cond_addr
, process
);
1413 /// Wake up all processes waiting on the condition variable.
1414 static SyscallReturn
1415 m5_cond_broadcastFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1418 Addr cond_addr
= xc
->getSyscallArg(0);
1420 activate_waiting_context(cond_addr
, process
, true);
1425 /// Wait on a condition.
1426 static SyscallReturn
1427 m5_cond_waitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1430 Addr cond_addr
= xc
->getSyscallArg(0);
1431 Addr lock_addr
= xc
->getSyscallArg(1);
1432 TypedBufferArg
<uint64_t> condp(cond_addr
);
1433 TypedBufferArg
<uint64_t> lockp(lock_addr
);
1435 // user is supposed to acquire lock before entering
1436 lockp
.copyIn(xc
->mem
);
1437 assert(*lockp
!= 0);
1439 m5_unlock_mutex(lock_addr
, process
, xc
);
1441 process
->waitList
.push_back(Process::WaitRec(cond_addr
, xc
));
1448 static SyscallReturn
1449 m5_thread_exitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1452 assert(xc
->status() == ExecContext::Active
);
1458 /// Array of syscall descriptors for Mach syscalls, indexed by
1459 /// (negated) call number.
1460 static SyscallDesc machSyscallDescs
[];
1462 /// Number of syscalls in machSyscallDescs[].
1463 static const int Num_Mach_Syscall_Descs
;
1465 /// Max supported Mach syscall number.
1466 static const int Max_Mach_Syscall_Desc
;
1468 /// Since negated values are used to identify Mach syscalls, the
1469 /// minimum (signed) valid syscall number is the negated max Mach
1471 static const int Min_Syscall_Desc
;
1473 /// Do the specified syscall. Just looks the call number up in
1474 /// the table and invokes the appropriate handler.
1476 doSyscall(int callnum
, Process
*process
, ExecContext
*xc
)
1478 if (callnum
< Min_Syscall_Desc
|| callnum
> Max_Syscall_Desc
) {
1479 fatal("Syscall %d out of range\n", callnum
);
1484 &machSyscallDescs
[-callnum
] : &syscallDescs
[callnum
];
1486 desc
->doSyscall(callnum
, process
, xc
);
1489 /// Indirect syscall invocation (call #0).
1490 static SyscallReturn
1491 indirectSyscallFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1494 int new_callnum
= xc
->getSyscallArg(0);
1496 for (int i
= 0; i
< 5; ++i
)
1497 xc
->setSyscallArg(i
, xc
->getSyscallArg(i
+1));
1499 doSyscall(new_callnum
, process
, xc
);
1507 // open(2) flags translation table
1508 OpenFlagTransTable
Tru64::openFlagTable
[] = {
1510 { Tru64::TGT_O_RDONLY
, _O_RDONLY
},
1511 { Tru64::TGT_O_WRONLY
, _O_WRONLY
},
1512 { Tru64::TGT_O_RDWR
, _O_RDWR
},
1513 { Tru64::TGT_O_APPEND
, _O_APPEND
},
1514 { Tru64::TGT_O_CREAT
, _O_CREAT
},
1515 { Tru64::TGT_O_TRUNC
, _O_TRUNC
},
1516 { Tru64::TGT_O_EXCL
, _O_EXCL
},
1518 { Tru64::TGT_O_NONBLOCK
, _O_NONBLOCK
},
1521 { Tru64::TGT_O_NOCTTY
, _O_NOCTTY
},
1524 { Tru64::TGT_O_SYNC
, _O_SYNC
},
1526 #else /* !_MSC_VER */
1527 { Tru64::TGT_O_RDONLY
, O_RDONLY
},
1528 { Tru64::TGT_O_WRONLY
, O_WRONLY
},
1529 { Tru64::TGT_O_RDWR
, O_RDWR
},
1530 { Tru64::TGT_O_APPEND
, O_APPEND
},
1531 { Tru64::TGT_O_CREAT
, O_CREAT
},
1532 { Tru64::TGT_O_TRUNC
, O_TRUNC
},
1533 { Tru64::TGT_O_EXCL
, O_EXCL
},
1534 { Tru64::TGT_O_NONBLOCK
, O_NONBLOCK
},
1535 { Tru64::TGT_O_NOCTTY
, O_NOCTTY
},
1537 { Tru64::TGT_O_SYNC
, O_SYNC
},
1539 #endif /* _MSC_VER */
1542 const int Tru64::NUM_OPEN_FLAGS
= (sizeof(Tru64::openFlagTable
)/sizeof(Tru64::openFlagTable
[0]));
1544 const char *Tru64::hostname
= "m5.eecs.umich.edu";
1546 SyscallDesc
Tru64::syscallDescs
[] = {
1547 /* 0 */ SyscallDesc("syscall (#0)", indirectSyscallFunc
,
1548 SyscallDesc::SuppressReturnValue
),
1549 /* 1 */ SyscallDesc("exit", exitFunc
),
1550 /* 2 */ SyscallDesc("fork", unimplementedFunc
),
1551 /* 3 */ SyscallDesc("read", readFunc
),
1552 /* 4 */ SyscallDesc("write", writeFunc
),
1553 /* 5 */ SyscallDesc("old_open", unimplementedFunc
),
1554 /* 6 */ SyscallDesc("close", closeFunc
),
1555 /* 7 */ SyscallDesc("wait4", unimplementedFunc
),
1556 /* 8 */ SyscallDesc("old_creat", unimplementedFunc
),
1557 /* 9 */ SyscallDesc("link", unimplementedFunc
),
1558 /* 10 */ SyscallDesc("unlink", unlinkFunc
),
1559 /* 11 */ SyscallDesc("execv", unimplementedFunc
),
1560 /* 12 */ SyscallDesc("chdir", unimplementedFunc
),
1561 /* 13 */ SyscallDesc("fchdir", unimplementedFunc
),
1562 /* 14 */ SyscallDesc("mknod", unimplementedFunc
),
1563 /* 15 */ SyscallDesc("chmod", unimplementedFunc
),
1564 /* 16 */ SyscallDesc("chown", unimplementedFunc
),
1565 /* 17 */ SyscallDesc("obreak", obreakFunc
),
1566 /* 18 */ SyscallDesc("pre_F64_getfsstat", unimplementedFunc
),
1567 /* 19 */ SyscallDesc("lseek", lseekFunc
),
1568 /* 20 */ SyscallDesc("getpid", getpidFunc
),
1569 /* 21 */ SyscallDesc("mount", unimplementedFunc
),
1570 /* 22 */ SyscallDesc("unmount", unimplementedFunc
),
1571 /* 23 */ SyscallDesc("setuid", setuidFunc
),
1572 /* 24 */ SyscallDesc("getuid", getuidFunc
),
1573 /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc
),
1574 /* 26 */ SyscallDesc("ptrace", unimplementedFunc
),
1575 /* 27 */ SyscallDesc("recvmsg", unimplementedFunc
),
1576 /* 28 */ SyscallDesc("sendmsg", unimplementedFunc
),
1577 /* 29 */ SyscallDesc("recvfrom", unimplementedFunc
),
1578 /* 30 */ SyscallDesc("accept", unimplementedFunc
),
1579 /* 31 */ SyscallDesc("getpeername", unimplementedFunc
),
1580 /* 32 */ SyscallDesc("getsockname", unimplementedFunc
),
1581 /* 33 */ SyscallDesc("access", unimplementedFunc
),
1582 /* 34 */ SyscallDesc("chflags", unimplementedFunc
),
1583 /* 35 */ SyscallDesc("fchflags", unimplementedFunc
),
1584 /* 36 */ SyscallDesc("sync", unimplementedFunc
),
1585 /* 37 */ SyscallDesc("kill", unimplementedFunc
),
1586 /* 38 */ SyscallDesc("old_stat", unimplementedFunc
),
1587 /* 39 */ SyscallDesc("setpgid", unimplementedFunc
),
1588 /* 40 */ SyscallDesc("old_lstat", unimplementedFunc
),
1589 /* 41 */ SyscallDesc("dup", unimplementedFunc
),
1590 /* 42 */ SyscallDesc("pipe", unimplementedFunc
),
1591 /* 43 */ SyscallDesc("set_program_attributes", unimplementedFunc
),
1592 /* 44 */ SyscallDesc("profil", unimplementedFunc
),
1593 /* 45 */ SyscallDesc("open", openFunc
<Tru64
>),
1594 /* 46 */ SyscallDesc("obsolete osigaction", unimplementedFunc
),
1595 /* 47 */ SyscallDesc("getgid", getgidFunc
),
1596 /* 48 */ SyscallDesc("sigprocmask", ignoreFunc
),
1597 /* 49 */ SyscallDesc("getlogin", unimplementedFunc
),
1598 /* 50 */ SyscallDesc("setlogin", unimplementedFunc
),
1599 /* 51 */ SyscallDesc("acct", unimplementedFunc
),
1600 /* 52 */ SyscallDesc("sigpending", unimplementedFunc
),
1601 /* 53 */ SyscallDesc("classcntl", unimplementedFunc
),
1602 /* 54 */ SyscallDesc("ioctl", ioctlFunc
<Tru64
>),
1603 /* 55 */ SyscallDesc("reboot", unimplementedFunc
),
1604 /* 56 */ SyscallDesc("revoke", unimplementedFunc
),
1605 /* 57 */ SyscallDesc("symlink", unimplementedFunc
),
1606 /* 58 */ SyscallDesc("readlink", unimplementedFunc
),
1607 /* 59 */ SyscallDesc("execve", unimplementedFunc
),
1608 /* 60 */ SyscallDesc("umask", unimplementedFunc
),
1609 /* 61 */ SyscallDesc("chroot", unimplementedFunc
),
1610 /* 62 */ SyscallDesc("old_fstat", unimplementedFunc
),
1611 /* 63 */ SyscallDesc("getpgrp", unimplementedFunc
),
1612 /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc
),
1613 /* 65 */ SyscallDesc("mremap", unimplementedFunc
),
1614 /* 66 */ SyscallDesc("vfork", unimplementedFunc
),
1615 /* 67 */ SyscallDesc("pre_F64_stat", statFunc
<Tru64::PreF64
>),
1616 /* 68 */ SyscallDesc("pre_F64_lstat", lstatFunc
<Tru64::PreF64
>),
1617 /* 69 */ SyscallDesc("sbrk", unimplementedFunc
),
1618 /* 70 */ SyscallDesc("sstk", unimplementedFunc
),
1619 /* 71 */ SyscallDesc("mmap", mmapFunc
<Tru64
>),
1620 /* 72 */ SyscallDesc("ovadvise", unimplementedFunc
),
1621 /* 73 */ SyscallDesc("munmap", munmapFunc
),
1622 /* 74 */ SyscallDesc("mprotect", ignoreFunc
),
1623 /* 75 */ SyscallDesc("madvise", unimplementedFunc
),
1624 /* 76 */ SyscallDesc("old_vhangup", unimplementedFunc
),
1625 /* 77 */ SyscallDesc("kmodcall", unimplementedFunc
),
1626 /* 78 */ SyscallDesc("mincore", unimplementedFunc
),
1627 /* 79 */ SyscallDesc("getgroups", unimplementedFunc
),
1628 /* 80 */ SyscallDesc("setgroups", unimplementedFunc
),
1629 /* 81 */ SyscallDesc("old_getpgrp", unimplementedFunc
),
1630 /* 82 */ SyscallDesc("setpgrp", unimplementedFunc
),
1631 /* 83 */ SyscallDesc("setitimer", unimplementedFunc
),
1632 /* 84 */ SyscallDesc("old_wait", unimplementedFunc
),
1633 /* 85 */ SyscallDesc("table", tableFunc
),
1634 /* 86 */ SyscallDesc("getitimer", unimplementedFunc
),
1635 /* 87 */ SyscallDesc("gethostname", gethostnameFunc
),
1636 /* 88 */ SyscallDesc("sethostname", unimplementedFunc
),
1637 /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc
),
1638 /* 90 */ SyscallDesc("dup2", unimplementedFunc
),
1639 /* 91 */ SyscallDesc("pre_F64_fstat", fstatFunc
<Tru64::PreF64
>),
1640 /* 92 */ SyscallDesc("fcntl", fcntlFunc
),
1641 /* 93 */ SyscallDesc("select", unimplementedFunc
),
1642 /* 94 */ SyscallDesc("poll", unimplementedFunc
),
1643 /* 95 */ SyscallDesc("fsync", unimplementedFunc
),
1644 /* 96 */ SyscallDesc("setpriority", unimplementedFunc
),
1645 /* 97 */ SyscallDesc("socket", unimplementedFunc
),
1646 /* 98 */ SyscallDesc("connect", unimplementedFunc
),
1647 /* 99 */ SyscallDesc("old_accept", unimplementedFunc
),
1648 /* 100 */ SyscallDesc("getpriority", unimplementedFunc
),
1649 /* 101 */ SyscallDesc("old_send", unimplementedFunc
),
1650 /* 102 */ SyscallDesc("old_recv", unimplementedFunc
),
1651 /* 103 */ SyscallDesc("sigreturn", sigreturnFunc
,
1652 SyscallDesc::SuppressReturnValue
),
1653 /* 104 */ SyscallDesc("bind", unimplementedFunc
),
1654 /* 105 */ SyscallDesc("setsockopt", unimplementedFunc
),
1655 /* 106 */ SyscallDesc("listen", unimplementedFunc
),
1656 /* 107 */ SyscallDesc("plock", unimplementedFunc
),
1657 /* 108 */ SyscallDesc("old_sigvec", unimplementedFunc
),
1658 /* 109 */ SyscallDesc("old_sigblock", unimplementedFunc
),
1659 /* 110 */ SyscallDesc("old_sigsetmask", unimplementedFunc
),
1660 /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc
),
1661 /* 112 */ SyscallDesc("sigstack", ignoreFunc
),
1662 /* 113 */ SyscallDesc("old_recvmsg", unimplementedFunc
),
1663 /* 114 */ SyscallDesc("old_sendmsg", unimplementedFunc
),
1664 /* 115 */ SyscallDesc("obsolete vtrace", unimplementedFunc
),
1665 /* 116 */ SyscallDesc("gettimeofday", gettimeofdayFunc
<Tru64
>),
1666 /* 117 */ SyscallDesc("getrusage", getrusageFunc
<Tru64
>),
1667 /* 118 */ SyscallDesc("getsockopt", unimplementedFunc
),
1668 /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc
),
1669 /* 120 */ SyscallDesc("readv", unimplementedFunc
),
1670 /* 121 */ SyscallDesc("writev", unimplementedFunc
),
1671 /* 122 */ SyscallDesc("settimeofday", unimplementedFunc
),
1672 /* 123 */ SyscallDesc("fchown", unimplementedFunc
),
1673 /* 124 */ SyscallDesc("fchmod", unimplementedFunc
),
1674 /* 125 */ SyscallDesc("old_recvfrom", unimplementedFunc
),
1675 /* 126 */ SyscallDesc("setreuid", unimplementedFunc
),
1676 /* 127 */ SyscallDesc("setregid", unimplementedFunc
),
1677 /* 128 */ SyscallDesc("rename", renameFunc
),
1678 /* 129 */ SyscallDesc("truncate", truncateFunc
),
1679 /* 130 */ SyscallDesc("ftruncate", ftruncateFunc
),
1680 /* 131 */ SyscallDesc("flock", unimplementedFunc
),
1681 /* 132 */ SyscallDesc("setgid", unimplementedFunc
),
1682 /* 133 */ SyscallDesc("sendto", unimplementedFunc
),
1683 /* 134 */ SyscallDesc("shutdown", unimplementedFunc
),
1684 /* 135 */ SyscallDesc("socketpair", unimplementedFunc
),
1685 /* 136 */ SyscallDesc("mkdir", unimplementedFunc
),
1686 /* 137 */ SyscallDesc("rmdir", unimplementedFunc
),
1687 /* 138 */ SyscallDesc("utimes", unimplementedFunc
),
1688 /* 139 */ SyscallDesc("obsolete 4.2 sigreturn", unimplementedFunc
),
1689 /* 140 */ SyscallDesc("adjtime", unimplementedFunc
),
1690 /* 141 */ SyscallDesc("old_getpeername", unimplementedFunc
),
1691 /* 142 */ SyscallDesc("gethostid", unimplementedFunc
),
1692 /* 143 */ SyscallDesc("sethostid", unimplementedFunc
),
1693 /* 144 */ SyscallDesc("getrlimit", getrlimitFunc
<Tru64
>),
1694 /* 145 */ SyscallDesc("setrlimit", ignoreFunc
),
1695 /* 146 */ SyscallDesc("old_killpg", unimplementedFunc
),
1696 /* 147 */ SyscallDesc("setsid", unimplementedFunc
),
1697 /* 148 */ SyscallDesc("quotactl", unimplementedFunc
),
1698 /* 149 */ SyscallDesc("oldquota", unimplementedFunc
),
1699 /* 150 */ SyscallDesc("old_getsockname", unimplementedFunc
),
1700 /* 151 */ SyscallDesc("pread", unimplementedFunc
),
1701 /* 152 */ SyscallDesc("pwrite", unimplementedFunc
),
1702 /* 153 */ SyscallDesc("pid_block", unimplementedFunc
),
1703 /* 154 */ SyscallDesc("pid_unblock", unimplementedFunc
),
1704 /* 155 */ SyscallDesc("signal_urti", unimplementedFunc
),
1705 /* 156 */ SyscallDesc("sigaction", ignoreFunc
),
1706 /* 157 */ SyscallDesc("sigwaitprim", unimplementedFunc
),
1707 /* 158 */ SyscallDesc("nfssvc", unimplementedFunc
),
1708 /* 159 */ SyscallDesc("getdirentries", getdirentriesFunc
),
1709 /* 160 */ SyscallDesc("pre_F64_statfs", statfsFunc
<Tru64::PreF64
>),
1710 /* 161 */ SyscallDesc("pre_F64_fstatfs", fstatfsFunc
<Tru64::PreF64
>),
1711 /* 162 */ SyscallDesc("unknown #162", unimplementedFunc
),
1712 /* 163 */ SyscallDesc("async_daemon", unimplementedFunc
),
1713 /* 164 */ SyscallDesc("getfh", unimplementedFunc
),
1714 /* 165 */ SyscallDesc("getdomainname", unimplementedFunc
),
1715 /* 166 */ SyscallDesc("setdomainname", unimplementedFunc
),
1716 /* 167 */ SyscallDesc("unknown #167", unimplementedFunc
),
1717 /* 168 */ SyscallDesc("unknown #168", unimplementedFunc
),
1718 /* 169 */ SyscallDesc("exportfs", unimplementedFunc
),
1719 /* 170 */ SyscallDesc("unknown #170", unimplementedFunc
),
1720 /* 171 */ SyscallDesc("unknown #171", unimplementedFunc
),
1721 /* 172 */ SyscallDesc("unknown #172", unimplementedFunc
),
1722 /* 173 */ SyscallDesc("unknown #173", unimplementedFunc
),
1723 /* 174 */ SyscallDesc("unknown #174", unimplementedFunc
),
1724 /* 175 */ SyscallDesc("unknown #175", unimplementedFunc
),
1725 /* 176 */ SyscallDesc("unknown #176", unimplementedFunc
),
1726 /* 177 */ SyscallDesc("unknown #177", unimplementedFunc
),
1727 /* 178 */ SyscallDesc("unknown #178", unimplementedFunc
),
1728 /* 179 */ SyscallDesc("unknown #179", unimplementedFunc
),
1729 /* 180 */ SyscallDesc("unknown #180", unimplementedFunc
),
1730 /* 181 */ SyscallDesc("alt_plock", unimplementedFunc
),
1731 /* 182 */ SyscallDesc("unknown #182", unimplementedFunc
),
1732 /* 183 */ SyscallDesc("unknown #183", unimplementedFunc
),
1733 /* 184 */ SyscallDesc("getmnt", unimplementedFunc
),
1734 /* 185 */ SyscallDesc("unknown #185", unimplementedFunc
),
1735 /* 186 */ SyscallDesc("unknown #186", unimplementedFunc
),
1736 /* 187 */ SyscallDesc("alt_sigpending", unimplementedFunc
),
1737 /* 188 */ SyscallDesc("alt_setsid", unimplementedFunc
),
1738 /* 189 */ SyscallDesc("unknown #189", unimplementedFunc
),
1739 /* 190 */ SyscallDesc("unknown #190", unimplementedFunc
),
1740 /* 191 */ SyscallDesc("unknown #191", unimplementedFunc
),
1741 /* 192 */ SyscallDesc("unknown #192", unimplementedFunc
),
1742 /* 193 */ SyscallDesc("unknown #193", unimplementedFunc
),
1743 /* 194 */ SyscallDesc("unknown #194", unimplementedFunc
),
1744 /* 195 */ SyscallDesc("unknown #195", unimplementedFunc
),
1745 /* 196 */ SyscallDesc("unknown #196", unimplementedFunc
),
1746 /* 197 */ SyscallDesc("unknown #197", unimplementedFunc
),
1747 /* 198 */ SyscallDesc("unknown #198", unimplementedFunc
),
1748 /* 199 */ SyscallDesc("swapon", unimplementedFunc
),
1749 /* 200 */ SyscallDesc("msgctl", unimplementedFunc
),
1750 /* 201 */ SyscallDesc("msgget", unimplementedFunc
),
1751 /* 202 */ SyscallDesc("msgrcv", unimplementedFunc
),
1752 /* 203 */ SyscallDesc("msgsnd", unimplementedFunc
),
1753 /* 204 */ SyscallDesc("semctl", unimplementedFunc
),
1754 /* 205 */ SyscallDesc("semget", unimplementedFunc
),
1755 /* 206 */ SyscallDesc("semop", unimplementedFunc
),
1756 /* 207 */ SyscallDesc("uname", unameFunc
),
1757 /* 208 */ SyscallDesc("lchown", unimplementedFunc
),
1758 /* 209 */ SyscallDesc("shmat", unimplementedFunc
),
1759 /* 210 */ SyscallDesc("shmctl", unimplementedFunc
),
1760 /* 211 */ SyscallDesc("shmdt", unimplementedFunc
),
1761 /* 212 */ SyscallDesc("shmget", unimplementedFunc
),
1762 /* 213 */ SyscallDesc("mvalid", unimplementedFunc
),
1763 /* 214 */ SyscallDesc("getaddressconf", unimplementedFunc
),
1764 /* 215 */ SyscallDesc("msleep", unimplementedFunc
),
1765 /* 216 */ SyscallDesc("mwakeup", unimplementedFunc
),
1766 /* 217 */ SyscallDesc("msync", unimplementedFunc
),
1767 /* 218 */ SyscallDesc("signal", unimplementedFunc
),
1768 /* 219 */ SyscallDesc("utc_gettime", unimplementedFunc
),
1769 /* 220 */ SyscallDesc("utc_adjtime", unimplementedFunc
),
1770 /* 221 */ SyscallDesc("unknown #221", unimplementedFunc
),
1771 /* 222 */ SyscallDesc("security", unimplementedFunc
),
1772 /* 223 */ SyscallDesc("kloadcall", unimplementedFunc
),
1773 /* 224 */ SyscallDesc("stat", statFunc
<Tru64::F64
>),
1774 /* 225 */ SyscallDesc("lstat", lstatFunc
<Tru64::F64
>),
1775 /* 226 */ SyscallDesc("fstat", fstatFunc
<Tru64::F64
>),
1776 /* 227 */ SyscallDesc("statfs", statfsFunc
<Tru64::F64
>),
1777 /* 228 */ SyscallDesc("fstatfs", fstatfsFunc
<Tru64::F64
>),
1778 /* 229 */ SyscallDesc("getfsstat", unimplementedFunc
),
1779 /* 230 */ SyscallDesc("gettimeofday64", unimplementedFunc
),
1780 /* 231 */ SyscallDesc("settimeofday64", unimplementedFunc
),
1781 /* 232 */ SyscallDesc("unknown #232", unimplementedFunc
),
1782 /* 233 */ SyscallDesc("getpgid", unimplementedFunc
),
1783 /* 234 */ SyscallDesc("getsid", unimplementedFunc
),
1784 /* 235 */ SyscallDesc("sigaltstack", ignoreFunc
),
1785 /* 236 */ SyscallDesc("waitid", unimplementedFunc
),
1786 /* 237 */ SyscallDesc("priocntlset", unimplementedFunc
),
1787 /* 238 */ SyscallDesc("sigsendset", unimplementedFunc
),
1788 /* 239 */ SyscallDesc("set_speculative", unimplementedFunc
),
1789 /* 240 */ SyscallDesc("msfs_syscall", unimplementedFunc
),
1790 /* 241 */ SyscallDesc("sysinfo", unimplementedFunc
),
1791 /* 242 */ SyscallDesc("uadmin", unimplementedFunc
),
1792 /* 243 */ SyscallDesc("fuser", unimplementedFunc
),
1793 /* 244 */ SyscallDesc("proplist_syscall", unimplementedFunc
),
1794 /* 245 */ SyscallDesc("ntp_adjtime", unimplementedFunc
),
1795 /* 246 */ SyscallDesc("ntp_gettime", unimplementedFunc
),
1796 /* 247 */ SyscallDesc("pathconf", unimplementedFunc
),
1797 /* 248 */ SyscallDesc("fpathconf", unimplementedFunc
),
1798 /* 249 */ SyscallDesc("sync2", unimplementedFunc
),
1799 /* 250 */ SyscallDesc("uswitch", unimplementedFunc
),
1800 /* 251 */ SyscallDesc("usleep_thread", unimplementedFunc
),
1801 /* 252 */ SyscallDesc("audcntl", unimplementedFunc
),
1802 /* 253 */ SyscallDesc("audgen", unimplementedFunc
),
1803 /* 254 */ SyscallDesc("sysfs", unimplementedFunc
),
1804 /* 255 */ SyscallDesc("subsys_info", unimplementedFunc
),
1805 /* 256 */ SyscallDesc("getsysinfo", getsysinfoFunc
),
1806 /* 257 */ SyscallDesc("setsysinfo", setsysinfoFunc
),
1807 /* 258 */ SyscallDesc("afs_syscall", unimplementedFunc
),
1808 /* 259 */ SyscallDesc("swapctl", unimplementedFunc
),
1809 /* 260 */ SyscallDesc("memcntl", unimplementedFunc
),
1810 /* 261 */ SyscallDesc("fdatasync", unimplementedFunc
),
1811 /* 262 */ SyscallDesc("oflock", unimplementedFunc
),
1812 /* 263 */ SyscallDesc("F64_readv", unimplementedFunc
),
1813 /* 264 */ SyscallDesc("F64_writev", unimplementedFunc
),
1814 /* 265 */ SyscallDesc("cdslxlate", unimplementedFunc
),
1815 /* 266 */ SyscallDesc("sendfile", unimplementedFunc
),
1818 const int Tru64::Num_Syscall_Descs
=
1819 sizeof(Tru64::syscallDescs
) / sizeof(SyscallDesc
);
1821 const int Tru64::Max_Syscall_Desc
= Tru64::Num_Syscall_Descs
- 1;
1823 SyscallDesc
Tru64::machSyscallDescs
[] = {
1824 /* 0 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1825 /* 1 */ SyscallDesc("m5_mutex_lock", m5_mutex_lockFunc
),
1826 /* 2 */ SyscallDesc("m5_mutex_trylock", m5_mutex_trylockFunc
),
1827 /* 3 */ SyscallDesc("m5_mutex_unlock", m5_mutex_unlockFunc
),
1828 /* 4 */ SyscallDesc("m5_cond_signal", m5_cond_signalFunc
),
1829 /* 5 */ SyscallDesc("m5_cond_broadcast", m5_cond_broadcastFunc
),
1830 /* 6 */ SyscallDesc("m5_cond_wait", m5_cond_waitFunc
),
1831 /* 7 */ SyscallDesc("m5_thread_exit", m5_thread_exitFunc
),
1832 /* 8 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1833 /* 9 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1834 /* 10 */ SyscallDesc("task_self", unimplementedFunc
),
1835 /* 11 */ SyscallDesc("thread_reply", unimplementedFunc
),
1836 /* 12 */ SyscallDesc("task_notify", unimplementedFunc
),
1837 /* 13 */ SyscallDesc("thread_self", unimplementedFunc
),
1838 /* 14 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1839 /* 15 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1840 /* 16 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1841 /* 17 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1842 /* 18 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1843 /* 19 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1844 /* 20 */ SyscallDesc("msg_send_trap", unimplementedFunc
),
1845 /* 21 */ SyscallDesc("msg_receive_trap", unimplementedFunc
),
1846 /* 22 */ SyscallDesc("msg_rpc_trap", unimplementedFunc
),
1847 /* 23 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1848 /* 24 */ SyscallDesc("nxm_block", nxm_blockFunc
),
1849 /* 25 */ SyscallDesc("nxm_unblock", nxm_unblockFunc
),
1850 /* 26 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1851 /* 27 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1852 /* 28 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1853 /* 29 */ SyscallDesc("nxm_thread_destroy", unimplementedFunc
),
1854 /* 30 */ SyscallDesc("lw_wire", unimplementedFunc
),
1855 /* 31 */ SyscallDesc("lw_unwire", unimplementedFunc
),
1856 /* 32 */ SyscallDesc("nxm_thread_create", nxm_thread_createFunc
),
1857 /* 33 */ SyscallDesc("nxm_task_init", nxm_task_initFunc
),
1858 /* 34 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1859 /* 35 */ SyscallDesc("nxm_idle", nxm_idleFunc
),
1860 /* 36 */ SyscallDesc("nxm_wakeup_idle", unimplementedFunc
),
1861 /* 37 */ SyscallDesc("nxm_set_pthid", unimplementedFunc
),
1862 /* 38 */ SyscallDesc("nxm_thread_kill", unimplementedFunc
),
1863 /* 39 */ SyscallDesc("nxm_thread_block", nxm_thread_blockFunc
),
1864 /* 40 */ SyscallDesc("nxm_thread_wakeup", unimplementedFunc
),
1865 /* 41 */ SyscallDesc("init_process", unimplementedFunc
),
1866 /* 42 */ SyscallDesc("nxm_get_binding", unimplementedFunc
),
1867 /* 43 */ SyscallDesc("map_fd", unimplementedFunc
),
1868 /* 44 */ SyscallDesc("nxm_resched", unimplementedFunc
),
1869 /* 45 */ SyscallDesc("nxm_set_cancel", unimplementedFunc
),
1870 /* 46 */ SyscallDesc("nxm_set_binding", unimplementedFunc
),
1871 /* 47 */ SyscallDesc("stack_create", stack_createFunc
),
1872 /* 48 */ SyscallDesc("nxm_get_state", unimplementedFunc
),
1873 /* 49 */ SyscallDesc("nxm_thread_suspend", unimplementedFunc
),
1874 /* 50 */ SyscallDesc("nxm_thread_resume", unimplementedFunc
),
1875 /* 51 */ SyscallDesc("nxm_signal_check", unimplementedFunc
),
1876 /* 52 */ SyscallDesc("htg_unix_syscall", unimplementedFunc
),
1877 /* 53 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1878 /* 54 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1879 /* 55 */ SyscallDesc("host_self", unimplementedFunc
),
1880 /* 56 */ SyscallDesc("host_priv_self", unimplementedFunc
),
1881 /* 57 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1882 /* 58 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1883 /* 59 */ SyscallDesc("swtch_pri", swtch_priFunc
),
1884 /* 60 */ SyscallDesc("swtch", unimplementedFunc
),
1885 /* 61 */ SyscallDesc("thread_switch", unimplementedFunc
),
1886 /* 62 */ SyscallDesc("semop_fast", unimplementedFunc
),
1887 /* 63 */ SyscallDesc("nxm_pshared_init", unimplementedFunc
),
1888 /* 64 */ SyscallDesc("nxm_pshared_block", unimplementedFunc
),
1889 /* 65 */ SyscallDesc("nxm_pshared_unblock", unimplementedFunc
),
1890 /* 66 */ SyscallDesc("nxm_pshared_destroy", unimplementedFunc
),
1891 /* 67 */ SyscallDesc("nxm_swtch_pri", swtch_priFunc
),
1892 /* 68 */ SyscallDesc("lw_syscall", unimplementedFunc
),
1893 /* 69 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1894 /* 70 */ SyscallDesc("mach_sctimes_0", unimplementedFunc
),
1895 /* 71 */ SyscallDesc("mach_sctimes_1", unimplementedFunc
),
1896 /* 72 */ SyscallDesc("mach_sctimes_2", unimplementedFunc
),
1897 /* 73 */ SyscallDesc("mach_sctimes_3", unimplementedFunc
),
1898 /* 74 */ SyscallDesc("mach_sctimes_4", unimplementedFunc
),
1899 /* 75 */ SyscallDesc("mach_sctimes_5", unimplementedFunc
),
1900 /* 76 */ SyscallDesc("mach_sctimes_6", unimplementedFunc
),
1901 /* 77 */ SyscallDesc("mach_sctimes_7", unimplementedFunc
),
1902 /* 78 */ SyscallDesc("mach_sctimes_8", unimplementedFunc
),
1903 /* 79 */ SyscallDesc("mach_sctimes_9", unimplementedFunc
),
1904 /* 80 */ SyscallDesc("mach_sctimes_10", unimplementedFunc
),
1905 /* 81 */ SyscallDesc("mach_sctimes_11", unimplementedFunc
),
1906 /* 82 */ SyscallDesc("mach_sctimes_port_alloc_dealloc", unimplementedFunc
)
1909 const int Tru64::Num_Mach_Syscall_Descs
=
1910 sizeof(Tru64::machSyscallDescs
) / sizeof(SyscallDesc
);
1911 const int Tru64::Max_Mach_Syscall_Desc
= Tru64::Num_Mach_Syscall_Descs
- 1;
1912 const int Tru64::Min_Syscall_Desc
= -Tru64::Max_Mach_Syscall_Desc
;
1916 AlphaTru64Process::syscall(ExecContext
*xc
)
1920 int64_t callnum
= xc
->regs
.intRegFile
[ReturnValueReg
];
1922 Tru64::doSyscall(callnum
, this, xc
);
1926 AlphaTru64Process::AlphaTru64Process(const std::string
&name
,
1927 ObjectFile
*objFile
,
1931 std::vector
<std::string
> &argv
,
1932 std::vector
<std::string
> &envp
)
1933 : LiveProcess(name
, objFile
, stdin_fd
, stdout_fd
, stderr_fd
, argv
, envp
)