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__) || defined(__APPLE__) || defined(__FreeBSD__)
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"
58 using namespace AlphaISA
;
60 typedef struct stat global_stat
;
61 typedef struct statfs global_statfs
;
62 typedef struct dirent global_dirent
;
65 /// This class encapsulates the types, structures, constants,
66 /// functions, and syscall-number mappings specific to the Alpha Tru64
67 /// syscall interface.
74 /// Basic Tru64 types.
75 typedef uint64_t size_t;
76 typedef uint64_t off_t
;
77 typedef uint16_t nlink_t
;
78 typedef int32_t dev_t
;
79 typedef uint32_t uid_t
;
80 typedef uint32_t gid_t
;
81 typedef uint32_t time_t;
82 typedef uint32_t mode_t
;
83 typedef uint32_t ino_t
;
84 typedef struct { int val
[2]; } quad
;
89 /// open(2) flag values.
90 static const int TGT_O_RDONLY
= 00000000;
91 static const int TGT_O_WRONLY
= 00000001;
92 static const int TGT_O_RDWR
= 00000002;
93 static const int TGT_O_NONBLOCK
= 00000004;
94 static const int TGT_O_APPEND
= 00000010;
95 static const int TGT_O_CREAT
= 00001000;
96 static const int TGT_O_TRUNC
= 00002000;
97 static const int TGT_O_EXCL
= 00004000;
98 static const int TGT_O_NOCTTY
= 00010000;
99 static const int TGT_O_SYNC
= 00040000;
100 static const int TGT_O_DRD
= 00100000;
101 static const int TGT_O_DIRECTIO
= 00200000;
102 static const int TGT_O_CACHE
= 00400000;
103 static const int TGT_O_DSYNC
= 02000000;
104 static const int TGT_O_RSYNC
= 04000000;
107 /// This table maps the target open() flags to the corresponding
108 /// host open() flags.
109 static OpenFlagTransTable openFlagTable
[];
111 /// Number of entries in openFlagTable[].
112 static const int NUM_OPEN_FLAGS
;
114 /// Stat buffer. Note that Tru64 v5.0+ use a new "F64" stat
115 /// structure, and a new set of syscall numbers for stat calls.
116 /// On some hosts (notably Linux) define st_atime, st_mtime, and
117 /// st_ctime as macros, so we append an X to get around this.
119 dev_t st_dev
; //!< st_dev
120 int32_t st_retired1
; //!< st_retired1
121 mode_t st_mode
; //!< st_mode
122 nlink_t st_nlink
; //!< st_nlink
123 uint16_t st_nlink_reserved
; //!< st_nlink_reserved
124 uid_t st_uid
; //!< st_uid
125 gid_t st_gid
; //!< st_gid
126 dev_t st_rdev
; //!< st_rdev
127 dev_t st_ldev
; //!< st_ldev
128 off_t st_size
; //!< st_size
129 time_t st_retired2
; //!< st_retired2
130 int32_t st_uatime
; //!< st_uatime
131 time_t st_retired3
; //!< st_retired3
132 int32_t st_umtime
; //!< st_umtime
133 time_t st_retired4
; //!< st_retired4
134 int32_t st_uctime
; //!< st_uctime
135 int32_t st_retired5
; //!< st_retired5
136 int32_t st_retired6
; //!< st_retired6
137 uint32_t st_flags
; //!< st_flags
138 uint32_t st_gen
; //!< st_gen
139 uint64_t st_spare
[4]; //!< st_spare[4]
140 ino_t st_ino
; //!< st_ino
141 int32_t st_ino_reserved
; //!< st_ino_reserved
142 time_t st_atimeX
; //!< st_atime
143 int32_t st_atime_reserved
; //!< st_atime_reserved
144 time_t st_mtimeX
; //!< st_mtime
145 int32_t st_mtime_reserved
; //!< st_mtime_reserved
146 time_t st_ctimeX
; //!< st_ctime
147 int32_t st_ctime_reserved
; //!< st_ctime_reserved
148 uint64_t st_blksize
; //!< st_blksize
149 uint64_t st_blocks
; //!< st_blocks
153 /// Old Tru64 v4.x stat struct.
154 /// Tru64 maintains backwards compatibility with v4.x by
155 /// implementing another set of stat functions using the old
156 /// structure definition and binding them to the old syscall
158 struct pre_F64_stat
{
194 uint64_t dummy
[10]; // was union mount_info mount_info;
196 int64_t f_spare2
[14];
204 char f_mntonname
[1024];
205 char f_mntfromname
[1024];
208 /// For old Tru64 v4.x statfs()
209 struct pre_F64_statfs
{
221 char f_mntonname
[90];
222 char f_mntfromname
[90];
223 uint64_t dummy
[10]; // was union mount_info mount_info;
226 /// For getdirentries().
229 ino_t d_ino
; //!< file number of entry
230 uint16_t d_reclen
; //!< length of this record
231 uint16_t d_namlen
; //!< length of string in d_name
232 char d_name
[256]; //!< dummy name length
236 /// Length of strings in struct utsname (plus 1 for null char).
237 static const int _SYS_NMLN
= 32;
239 /// Interface struct for uname().
241 char sysname
[_SYS_NMLN
]; //!< System name.
242 char nodename
[_SYS_NMLN
]; //!< Node name.
243 char release
[_SYS_NMLN
]; //!< OS release.
244 char version
[_SYS_NMLN
]; //!< OS version.
245 char machine
[_SYS_NMLN
]; //!< Machine type.
249 /// ioctl() command codes.
250 static const unsigned TIOCGETP
= 0x40067408;
251 static const unsigned TIOCSETP
= 0x80067409;
252 static const unsigned TIOCSETN
= 0x8006740a;
253 static const unsigned TIOCSETC
= 0x80067411;
254 static const unsigned TIOCGETC
= 0x40067412;
255 static const unsigned FIONREAD
= 0x4004667f;
256 static const unsigned TIOCISATTY
= 0x2000745e;
257 // TIOCGETS not defined in tru64, so I made up a number
258 static const unsigned TIOCGETS
= 0x40000000;
259 static const unsigned TIOCGETA
= 0x402c7413;
262 /// Resource enumeration for getrlimit().
263 enum rlimit_resources
{
265 TGT_RLIMIT_FSIZE
= 1,
267 TGT_RLIMIT_STACK
= 3,
270 TGT_RLIMIT_NOFILE
= 6,
275 /// Limit struct for getrlimit/setrlimit.
277 uint64_t rlim_cur
; //!< soft limit
278 uint64_t rlim_max
; //!< hard limit
283 static const unsigned TGT_MAP_ANONYMOUS
= 0x10;
287 /// For getsysinfo().
288 static const unsigned GSI_PLATFORM_NAME
= 103; //!< platform name as string
289 static const unsigned GSI_CPU_INFO
= 59; //!< CPU information
290 static const unsigned GSI_PROC_TYPE
= 60; //!< get proc_type
291 static const unsigned GSI_MAX_CPU
= 30; //!< max # cpu's on this machine
292 static const unsigned GSI_CPUS_IN_BOX
= 55; //!< number of CPUs in system
293 static const unsigned GSI_PHYSMEM
= 19; //!< Physical memory in KB
294 static const unsigned GSI_CLK_TCK
= 42; //!< clock freq in Hz
297 /// For getsysinfo() GSI_CPU_INFO option.
299 uint32_t current_cpu
; //!< current_cpu
300 uint32_t cpus_in_box
; //!< cpus_in_box
301 uint32_t cpu_type
; //!< cpu_type
302 uint32_t ncpus
; //!< ncpus
303 uint64_t cpus_present
; //!< cpus_present
304 uint64_t cpus_running
; //!< cpus_running
305 uint64_t cpu_binding
; //!< cpu_binding
306 uint64_t cpu_ex_binding
; //!< cpu_ex_binding
307 uint32_t mhz
; //!< mhz
308 uint32_t unused
[3]; //!< future expansion
312 /// For setsysinfo().
313 static const unsigned SSI_IEEE_FP_CONTROL
= 14; //!< ieee_set_fp_control()
316 /// For gettimeofday.
318 uint32_t tv_sec
; //!< seconds
319 uint32_t tv_usec
; //!< microseconds
324 static const int TGT_RUSAGE_THREAD
= 1;
325 static const int TGT_RUSAGE_SELF
= 0;
326 static const int TGT_RUSAGE_CHILDREN
= -1;
331 struct timeval ru_utime
; //!< user time used
332 struct timeval ru_stime
; //!< system time used
333 uint64_t ru_maxrss
; //!< ru_maxrss
334 uint64_t ru_ixrss
; //!< integral shared memory size
335 uint64_t ru_idrss
; //!< integral unshared data "
336 uint64_t ru_isrss
; //!< integral unshared stack "
337 uint64_t ru_minflt
; //!< page reclaims - total vmfaults
338 uint64_t ru_majflt
; //!< page faults
339 uint64_t ru_nswap
; //!< swaps
340 uint64_t ru_inblock
; //!< block input operations
341 uint64_t ru_oublock
; //!< block output operations
342 uint64_t ru_msgsnd
; //!< messages sent
343 uint64_t ru_msgrcv
; //!< messages received
344 uint64_t ru_nsignals
; //!< signals received
345 uint64_t ru_nvcsw
; //!< voluntary context switches
346 uint64_t ru_nivcsw
; //!< involuntary "
351 int64_t sc_onstack
; //!< sigstack state to restore
352 int64_t sc_mask
; //!< signal mask to restore
353 int64_t sc_pc
; //!< pc at time of signal
354 int64_t sc_ps
; //!< psl to retore
355 int64_t sc_regs
[32]; //!< processor regs 0 to 31
356 int64_t sc_ownedfp
; //!< fp has been used
357 int64_t sc_fpregs
[32]; //!< fp regs 0 to 31
358 uint64_t sc_fpcr
; //!< floating point control reg
359 uint64_t sc_fp_control
; //!< software fpcr
360 int64_t sc_reserved1
; //!< reserved for kernel
361 uint32_t sc_kreserved1
; //!< reserved for kernel
362 uint32_t sc_kreserved2
; //!< reserved for kernel
363 size_t sc_ssize
; //!< stack size
364 caddr_t sc_sbase
; //!< stack start
365 uint64_t sc_traparg_a0
; //!< a0 argument to trap on exc
366 uint64_t sc_traparg_a1
; //!< a1 argument to trap on exc
367 uint64_t sc_traparg_a2
; //!< a2 argument to trap on exc
368 uint64_t sc_fp_trap_pc
; //!< imprecise pc
369 uint64_t sc_fp_trigger_sum
; //!< Exception summary at trigg
370 uint64_t sc_fp_trigger_inst
; //!< Instruction at trigger pc
375 static const int TBL_SYSINFO
= 12;
379 uint64_t si_user
; //!< User time
380 uint64_t si_nice
; //!< Nice time
381 uint64_t si_sys
; //!< System time
382 uint64_t si_idle
; //!< Idle time
383 uint64_t si_hz
; //!< hz
384 uint64_t si_phz
; //!< phz
385 uint64_t si_boottime
; //!< Boot time in seconds
386 uint64_t wait
; //!< Wait time
387 uint32_t si_max_procs
; //!< rpb->rpb_numprocs
388 uint32_t pad
; //!< padding
392 /// For stack_create.
395 Addr address
; //!< address hint
396 size_t rsize
; //!< red zone size
397 size_t ysize
; //!< yellow zone size
398 size_t gsize
; //!< green zone size
399 size_t swap
; //!< amount of swap to reserve
400 size_t incr
; //!< growth increment
401 uint64_t align
; //!< address alignment
402 uint64_t flags
; //!< MAP_FIXED etc.
403 // was struct memalloc_attr *
404 Addr attr
; //!< allocation policy
405 uint64_t reserved
; //!< reserved
408 /// Return values for nxm calls.
410 KERN_NOT_RECEIVER
= 7,
414 /// For nxm_task_init.
415 static const int NXM_TASK_INIT_VP
= 2; //!< initial thread is VP
417 /// Task attribute structure.
418 struct nxm_task_attr
{
419 int64_t nxm_callback
; //!< nxm_callback
420 unsigned int nxm_version
; //!< nxm_version
421 unsigned short nxm_uniq_offset
; //!< nxm_uniq_offset
422 unsigned short flags
; //!< flags
423 int nxm_quantum
; //!< nxm_quantum
425 int64_t pad2
; //!< pad2
429 typedef uint64_t sigset_t
;
431 /// Thread state shared between user & kernel.
432 struct ushared_state
{
433 sigset_t sigmask
; //!< thread signal mask
434 sigset_t sig
; //!< thread pending mask
435 // struct nxm_pth_state *
436 Addr pth_id
; //!< out-of-line state
437 int flags
; //!< shared flags
438 #define US_SIGSTACK 0x1 // thread called sigaltstack
439 #define US_ONSTACK 0x2 // thread is running on altstack
440 #define US_PROFILE 0x4 // thread called profil
441 #define US_SYSCALL 0x8 // thread in syscall
442 #define US_TRAP 0x10 // thread has trapped
443 #define US_YELLOW 0x20 // thread has mellowed yellow
444 #define US_YZONE 0x40 // thread has zoned out
445 #define US_FP_OWNED 0x80 // thread used floating point
447 int cancel_state
; //!< thread's cancelation state
448 #define US_CANCEL 0x1 // cancel pending
449 #define US_NOCANCEL 0X2 // synch cancel disabled
450 #define US_SYS_NOCANCEL 0x4 // syscall cancel disabled
451 #define US_ASYNC_NOCANCEL 0x8 // asynch cancel disabled
452 #define US_CANCEL_BITS (US_NOCANCEL|US_SYS_NOCANCEL|US_ASYNC_NOCANCEL)
453 #define US_CANCEL_MASK (US_CANCEL|US_NOCANCEL|US_SYS_NOCANCEL| \
456 // These are semi-shared. They are always visible to
457 // the kernel but are never context-switched by the library.
459 int nxm_ssig
; //!< scheduler's synchronous signals
460 int reserved1
; //!< reserved1
461 int64_t nxm_active
; //!< scheduler active
462 int64_t reserved2
; //!< reserved2
465 struct nxm_sched_state
{
466 struct ushared_state nxm_u
; //!< state own by user thread
467 unsigned int nxm_bits
; //!< scheduler state / slot
468 int nxm_quantum
; //!< quantum count-down value
469 int nxm_set_quantum
; //!< quantum reset value
470 int nxm_sysevent
; //!< syscall state
471 // struct nxm_upcall *
472 Addr nxm_uc_ret
; //!< stack ptr of null thread
474 Addr nxm_tid
; //!< scheduler's thread id
475 int64_t nxm_va
; //!< page fault address
476 // struct nxm_pth_state *
477 Addr nxm_pthid
; //!< id of null thread
478 uint64_t nxm_bound_pcs_count
; //!< bound PCS thread count
479 int64_t pad
[2]; //!< pad
484 int64_t nxm_callback
; //!< address of upcall routine
485 unsigned int nxm_version
; //!< version number
486 unsigned short nxm_uniq_offset
; //!< correction factor for TEB
487 unsigned short pad1
; //!< pad1
488 int64_t space
[2]; //!< future growth
489 struct nxm_sched_state nxm_ss
[1]; //!< array of shared areas
492 /// nxm_slot_state_t.
493 enum nxm_slot_state_t
{
501 struct nxm_config_info
{
502 int nxm_nslots_per_rad
; //!< max number of VP slots per RAD
503 int nxm_nrads
; //!< max number of RADs
504 // nxm_slot_state_t *
505 Addr nxm_slot_state
; //!< per-VP slot state
506 // struct nxm_shared *
507 Addr nxm_rad
[1]; //!< per-RAD shared areas
510 /// For nxm_thread_create.
511 enum nxm_thread_type
{
517 /// Thread attributes.
518 struct nxm_thread_attr
{
519 int version
; //!< version
521 int cancel_flags
; //!< cancel_flags
522 int priority
; //!< priority
523 int policy
; //!< policy
524 int signal_type
; //!< signal_type
526 Addr pthid
; //!< pthid
527 sigset_t sigmask
; //!< sigmask
528 /// Initial register values.
534 uint64_t pad2
[2]; //!< pad2
537 /// Helper function to convert a host stat buffer to a target stat
538 /// buffer. Also copies the target buffer out to the simulated
539 /// memory space. Used by stat(), fstat(), and lstat().
542 copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
, global_stat
*host
)
544 TypedBufferArg
<T
> tgt(addr
);
546 tgt
->st_dev
= htog(host
->st_dev
);
547 tgt
->st_ino
= htog(host
->st_ino
);
548 tgt
->st_mode
= htog(host
->st_mode
);
549 tgt
->st_nlink
= htog(host
->st_nlink
);
550 tgt
->st_uid
= htog(host
->st_uid
);
551 tgt
->st_gid
= htog(host
->st_gid
);
552 tgt
->st_rdev
= htog(host
->st_rdev
);
553 tgt
->st_size
= htog(host
->st_size
);
554 tgt
->st_atimeX
= htog(host
->st_atime
);
555 tgt
->st_mtimeX
= htog(host
->st_mtime
);
556 tgt
->st_ctimeX
= htog(host
->st_ctime
);
557 tgt
->st_blksize
= htog(host
->st_blksize
);
558 tgt
->st_blocks
= htog(host
->st_blocks
);
563 /// Helper function to convert a host statfs buffer to a target statfs
564 /// buffer. Also copies the target buffer out to the simulated
565 /// memory space. Used by statfs() and fstatfs().
568 copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
, global_statfs
*host
)
570 TypedBufferArg
<T
> tgt(addr
);
572 #if defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD__)
575 tgt
->f_type
= htog(host
->f_type
);
577 tgt
->f_bsize
= htog(host
->f_bsize
);
578 tgt
->f_blocks
= htog(host
->f_blocks
);
579 tgt
->f_bfree
= htog(host
->f_bfree
);
580 tgt
->f_bavail
= htog(host
->f_bavail
);
581 tgt
->f_files
= htog(host
->f_files
);
582 tgt
->f_ffree
= htog(host
->f_ffree
);
584 // Is this as string normally?
585 memcpy(&tgt
->f_fsid
, &host
->f_fsid
, sizeof(host
->f_fsid
));
592 static void copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
,
595 Tru64::copyOutStatBuf
<Tru64::F64_stat
>(mem
, addr
, host
);
598 static void copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
,
601 Tru64::copyOutStatfsBuf
<Tru64::F64_statfs
>(mem
, addr
, host
);
607 static void copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
,
610 Tru64::copyOutStatBuf
<Tru64::pre_F64_stat
>(mem
, addr
, host
);
613 static void copyOutStatfsBuf(FunctionalMemory
*mem
, Addr addr
,
616 Tru64::copyOutStatfsBuf
<Tru64::pre_F64_statfs
>(mem
, addr
, host
);
620 /// Helper function to convert a host stat buffer to an old pre-F64
621 /// (4.x) target stat buffer. Also copies the target buffer out to
622 /// the simulated memory space. Used by pre_F64_stat(),
623 /// pre_F64_fstat(), and pre_F64_lstat().
625 copyOutPreF64StatBuf(FunctionalMemory
*mem
, Addr addr
, struct stat
*host
)
627 TypedBufferArg
<Tru64::pre_F64_stat
> tgt(addr
);
629 tgt
->st_dev
= htog(host
->st_dev
);
630 tgt
->st_ino
= htog(host
->st_ino
);
631 tgt
->st_mode
= htog(host
->st_mode
);
632 tgt
->st_nlink
= htog(host
->st_nlink
);
633 tgt
->st_uid
= htog(host
->st_uid
);
634 tgt
->st_gid
= htog(host
->st_gid
);
635 tgt
->st_rdev
= htog(host
->st_rdev
);
636 tgt
->st_size
= htog(host
->st_size
);
637 tgt
->st_atimeX
= htog(host
->st_atime
);
638 tgt
->st_mtimeX
= htog(host
->st_mtime
);
639 tgt
->st_ctimeX
= htog(host
->st_ctime
);
640 tgt
->st_blksize
= htog(host
->st_blksize
);
641 tgt
->st_blocks
= htog(host
->st_blocks
);
647 /// The target system's hostname.
648 static const char *hostname
;
650 /// Target uname() handler.
652 unameFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
655 TypedBufferArg
<Tru64::utsname
> name(xc
->getSyscallArg(0));
657 strcpy(name
->sysname
, "OSF1");
658 strcpy(name
->nodename
, hostname
);
659 strcpy(name
->release
, "V5.1");
660 strcpy(name
->version
, "732");
661 strcpy(name
->machine
, "alpha");
663 name
.copyOut(xc
->mem
);
668 /// Target getsysyinfo() handler.
670 getsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
673 unsigned op
= xc
->getSyscallArg(0);
674 unsigned nbytes
= xc
->getSyscallArg(2);
678 case Tru64::GSI_MAX_CPU
: {
679 TypedBufferArg
<uint32_t> max_cpu(xc
->getSyscallArg(1));
680 *max_cpu
= htog((uint32_t)process
->numCpus());
681 max_cpu
.copyOut(xc
->mem
);
685 case Tru64::GSI_CPUS_IN_BOX
: {
686 TypedBufferArg
<uint32_t> cpus_in_box(xc
->getSyscallArg(1));
687 *cpus_in_box
= htog((uint32_t)process
->numCpus());
688 cpus_in_box
.copyOut(xc
->mem
);
692 case Tru64::GSI_PHYSMEM
: {
693 TypedBufferArg
<uint64_t> physmem(xc
->getSyscallArg(1));
694 *physmem
= htog((uint64_t)1024 * 1024); // physical memory in KB
695 physmem
.copyOut(xc
->mem
);
699 case Tru64::GSI_CPU_INFO
: {
700 TypedBufferArg
<Tru64::cpu_info
> infop(xc
->getSyscallArg(1));
702 infop
->current_cpu
= htog(0);
703 infop
->cpus_in_box
= htog(process
->numCpus());
704 infop
->cpu_type
= htog(57);
705 infop
->ncpus
= htog(process
->numCpus());
706 uint64_t cpumask
= (1 << process
->numCpus()) - 1;
707 infop
->cpus_present
= infop
->cpus_running
= htog(cpumask
);
708 infop
->cpu_binding
= htog(0);
709 infop
->cpu_ex_binding
= htog(0);
710 infop
->mhz
= htog(667);
712 infop
.copyOut(xc
->mem
);
716 case Tru64::GSI_PROC_TYPE
: {
717 TypedBufferArg
<uint64_t> proc_type(xc
->getSyscallArg(1));
718 *proc_type
= htog((uint64_t)11);
719 proc_type
.copyOut(xc
->mem
);
723 case Tru64::GSI_PLATFORM_NAME
: {
724 BufferArg
bufArg(xc
->getSyscallArg(1), nbytes
);
725 strncpy((char *)bufArg
.bufferPtr(),
726 "COMPAQ Professional Workstation XP1000",
728 bufArg
.copyOut(xc
->mem
);
732 case Tru64::GSI_CLK_TCK
: {
733 TypedBufferArg
<uint64_t> clk_hz(xc
->getSyscallArg(1));
734 *clk_hz
= htog((uint64_t)1024);
735 clk_hz
.copyOut(xc
->mem
);
740 warn("getsysinfo: unknown op %d\n", op
);
747 /// Target setsysyinfo() handler.
749 setsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
752 unsigned op
= xc
->getSyscallArg(0);
755 case SSI_IEEE_FP_CONTROL
:
756 warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n",
757 xc
->getSyscallArg(1));
761 warn("setsysinfo: unknown op %d\n", op
);
768 /// Target fnctl() handler.
770 fcntlFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
773 int fd
= xc
->getSyscallArg(0);
775 if (fd
< 0 || process
->sim_fd(fd
) < 0)
778 int cmd
= xc
->getSyscallArg(1);
781 // if we really wanted to support this, we'd need to do it
782 // in the target fd space.
783 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd
);
786 case 1: // F_GETFD (get close-on-exec flag)
787 case 2: // F_SETFD (set close-on-exec flag)
790 case 3: // F_GETFL (get file flags)
791 case 4: // F_SETFL (set file flags)
792 // not sure if this is totally valid, but we'll pass it through
793 // to the underlying OS
794 warn("fcntl(%d, %d) passed through to host\n", fd
, cmd
);
795 return fcntl(process
->sim_fd(fd
), cmd
);
798 case 7: // F_GETLK (get lock)
799 case 8: // F_SETLK (set lock)
800 case 9: // F_SETLKW (set lock and wait)
801 // don't mess with file locking... just act like it's OK
802 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd
, cmd
);
806 warn("Unknown fcntl command %d\n", cmd
);
812 /// Target getdirentries() handler.
814 getdirentriesFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
818 panic("getdirent not implemented on cygwin!");
820 int fd
= process
->sim_fd(xc
->getSyscallArg(0));
821 Addr tgt_buf
= xc
->getSyscallArg(1);
822 int tgt_nbytes
= xc
->getSyscallArg(2);
823 Addr tgt_basep
= xc
->getSyscallArg(3);
825 char * const host_buf
= new char[tgt_nbytes
];
827 // just pass basep through uninterpreted.
828 TypedBufferArg
<int64_t> basep(tgt_basep
);
829 basep
.copyIn(xc
->mem
);
830 long host_basep
= (off_t
)htog((int64_t)*basep
);
831 int host_result
= getdirentries(fd
, host_buf
, tgt_nbytes
, &host_basep
);
834 if (host_result
< 0) {
839 // no error: copy results back to target space
840 Addr tgt_buf_ptr
= tgt_buf
;
841 char *host_buf_ptr
= host_buf
;
842 char *host_buf_end
= host_buf
+ host_result
;
843 while (host_buf_ptr
< host_buf_end
) {
844 global_dirent
*host_dp
= (global_dirent
*)host_buf_ptr
;
845 int namelen
= strlen(host_dp
->d_name
);
847 // Actual size includes padded string rounded up for alignment.
848 // Subtract 256 for dummy char array in Tru64::dirent definition.
849 // Add 1 to namelen for terminating null char.
850 int tgt_bufsize
= sizeof(Tru64::dirent
) - 256 + roundUp(namelen
+1, 8);
851 TypedBufferArg
<Tru64::dirent
> tgt_dp(tgt_buf_ptr
, tgt_bufsize
);
852 tgt_dp
->d_ino
= host_dp
->d_ino
;
853 tgt_dp
->d_reclen
= tgt_bufsize
;
854 tgt_dp
->d_namlen
= namelen
;
855 strcpy(tgt_dp
->d_name
, host_dp
->d_name
);
856 tgt_dp
.copyOut(xc
->mem
);
858 tgt_buf_ptr
+= tgt_bufsize
;
859 host_buf_ptr
+= host_dp
->d_reclen
;
864 *basep
= htog((int64_t)host_basep
);
865 basep
.copyOut(xc
->mem
);
867 return tgt_buf_ptr
- tgt_buf
;
871 /// Target sigreturn() handler.
873 sigreturnFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
876 RegFile
*regs
= &xc
->regs
;
877 TypedBufferArg
<Tru64::sigcontext
> sc(xc
->getSyscallArg(0));
881 // Restore state from sigcontext structure.
882 // Note that we'll advance PC <- NPC before the end of the cycle,
883 // so we need to restore the desired PC into NPC.
884 // The current regs->pc will get clobbered.
885 regs
->npc
= htog(sc
->sc_pc
);
887 for (int i
= 0; i
< 31; ++i
) {
888 regs
->intRegFile
[i
] = htog(sc
->sc_regs
[i
]);
889 regs
->floatRegFile
.q
[i
] = htog(sc
->sc_fpregs
[i
]);
892 regs
->miscRegs
.fpcr
= htog(sc
->sc_fpcr
);
897 /// Target table() handler.
899 tableFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
902 int id
= xc
->getSyscallArg(0); // table ID
903 int index
= xc
->getSyscallArg(1); // index into table
904 // arg 2 is buffer pointer; type depends on table ID
905 int nel
= xc
->getSyscallArg(3); // number of elements
906 int lel
= xc
->getSyscallArg(4); // expected element size
909 case Tru64::TBL_SYSINFO
: {
910 if (index
!= 0 || nel
!= 1 || lel
!= sizeof(Tru64::tbl_sysinfo
))
912 TypedBufferArg
<Tru64::tbl_sysinfo
> elp(xc
->getSyscallArg(2));
914 const int clk_hz
= one_million
;
915 elp
->si_user
= htog(curTick
/ (Clock::Frequency
/ clk_hz
));
916 elp
->si_nice
= htog(0);
917 elp
->si_sys
= htog(0);
918 elp
->si_idle
= htog(0);
920 elp
->si_hz
= htog(clk_hz
);
921 elp
->si_phz
= htog(clk_hz
);
922 elp
->si_boottime
= htog(seconds_since_epoch
); // seconds since epoch?
923 elp
->si_max_procs
= htog(process
->numCpus());
924 elp
.copyOut(xc
->mem
);
929 cerr
<< "table(): id " << id
<< " unknown." << endl
;
934 /// Array of syscall descriptors, indexed by call number.
935 static SyscallDesc syscallDescs
[];
937 /// Number of syscalls in syscallDescs[].
938 static const int Num_Syscall_Descs
;
940 /// Max supported syscall number.
941 static const int Max_Syscall_Desc
;
944 // Mach syscalls -- identified by negated syscall numbers
947 /// Create a stack region for a thread.
949 stack_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
952 TypedBufferArg
<Tru64::vm_stack
> argp(xc
->getSyscallArg(0));
954 argp
.copyIn(xc
->mem
);
956 // if the user chose an address, just let them have it. Otherwise
957 // pick one for them.
958 if (htog(argp
->address
) == 0) {
959 argp
->address
= htog(process
->next_thread_stack_base
);
960 int stack_size
= (htog(argp
->rsize
) + htog(argp
->ysize
) +
962 process
->next_thread_stack_base
-= stack_size
;
963 argp
.copyOut(xc
->mem
);
969 /// NXM library version stamp.
971 const int NXM_LIB_VERSION
= 301003;
973 /// This call sets up the interface between the user and kernel
974 /// schedulers by creating a shared-memory region. The shared memory
975 /// region has several structs, some global, some per-RAD, some per-VP.
977 nxm_task_initFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
980 TypedBufferArg
<Tru64::nxm_task_attr
> attrp(xc
->getSyscallArg(0));
981 TypedBufferArg
<Addr
> configptr_ptr(xc
->getSyscallArg(1));
983 attrp
.copyIn(xc
->mem
);
985 if (gtoh(attrp
->nxm_version
) != NXM_LIB_VERSION
) {
986 cerr
<< "nxm_task_init: thread library version mismatch! "
987 << "got " << attrp
->nxm_version
988 << ", expected " << NXM_LIB_VERSION
<< endl
;
992 if (gtoh(attrp
->flags
) != Tru64::NXM_TASK_INIT_VP
) {
993 cerr
<< "nxm_task_init: bad flag value " << attrp
->flags
994 << " (expected " << Tru64::NXM_TASK_INIT_VP
<< ")" << endl
;
998 const Addr base_addr
= 0x12000; // was 0x3f0000000LL;
999 Addr cur_addr
= base_addr
; // next addresses to use
1000 // first comes the config_info struct
1001 Addr config_addr
= cur_addr
;
1002 cur_addr
+= sizeof(Tru64::nxm_config_info
);
1003 // next comes the per-cpu state vector
1004 Addr slot_state_addr
= cur_addr
;
1005 int slot_state_size
=
1006 process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
1007 cur_addr
+= slot_state_size
;
1008 // now the per-RAD state struct (we only support one RAD)
1009 cur_addr
= 0x14000; // bump up addr for alignment
1010 Addr rad_state_addr
= cur_addr
;
1011 int rad_state_size
=
1012 (sizeof(Tru64::nxm_shared
)
1013 + (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
1014 cur_addr
+= rad_state_size
;
1016 // now initialize a config_info struct and copy it out to user space
1017 TypedBufferArg
<Tru64::nxm_config_info
> config(config_addr
);
1019 config
->nxm_nslots_per_rad
= htog(process
->numCpus());
1020 config
->nxm_nrads
= htog(1); // only one RAD in our system!
1021 config
->nxm_slot_state
= htog(slot_state_addr
);
1022 config
->nxm_rad
[0] = htog(rad_state_addr
);
1024 config
.copyOut(xc
->mem
);
1026 // initialize the slot_state array and copy it out
1027 TypedBufferArg
<Tru64::nxm_slot_state_t
> slot_state(slot_state_addr
,
1029 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1030 // CPU 0 is bound to the calling process; all others are available
1031 // XXX this code should have an endian conversion, but I don't think
1034 (i
== 0) ? Tru64::NXM_SLOT_BOUND
: Tru64::NXM_SLOT_AVAIL
;
1037 slot_state
.copyOut(xc
->mem
);
1039 // same for the per-RAD "shared" struct. Note that we need to
1040 // allocate extra bytes for the per-VP array which is embedded at
1042 TypedBufferArg
<Tru64::nxm_shared
> rad_state(rad_state_addr
,
1045 rad_state
->nxm_callback
= attrp
->nxm_callback
;
1046 rad_state
->nxm_version
= attrp
->nxm_version
;
1047 rad_state
->nxm_uniq_offset
= attrp
->nxm_uniq_offset
;
1048 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1049 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[i
];
1050 ssp
->nxm_u
.sigmask
= htog(0);
1051 ssp
->nxm_u
.sig
= htog(0);
1052 ssp
->nxm_u
.flags
= htog(0);
1053 ssp
->nxm_u
.cancel_state
= htog(0);
1054 ssp
->nxm_u
.nxm_ssig
= 0;
1055 ssp
->nxm_bits
= htog(0);
1056 ssp
->nxm_quantum
= attrp
->nxm_quantum
;
1057 ssp
->nxm_set_quantum
= attrp
->nxm_quantum
;
1058 ssp
->nxm_sysevent
= htog(0);
1061 uint64_t uniq
= xc
->regs
.miscRegs
.uniq
;
1062 ssp
->nxm_u
.pth_id
= htog(uniq
+ gtoh(attrp
->nxm_uniq_offset
));
1063 ssp
->nxm_u
.nxm_active
= htog(uniq
| 1);
1066 ssp
->nxm_u
.pth_id
= htog(0);
1067 ssp
->nxm_u
.nxm_active
= htog(0);
1071 rad_state
.copyOut(xc
->mem
);
1074 // copy pointer to shared config area out to user
1076 *configptr_ptr
= htog(config_addr
);
1077 configptr_ptr
.copyOut(xc
->mem
);
1079 // Register this as a valid address range with the process
1080 process
->nxm_start
= base_addr
;
1081 process
->nxm_end
= cur_addr
;
1086 /// Initialize execution context.
1088 init_exec_context(ExecContext
*ec
,
1089 Tru64::nxm_thread_attr
*attrp
, uint64_t uniq_val
)
1091 memset(&ec
->regs
, 0, sizeof(ec
->regs
));
1093 ec
->regs
.intRegFile
[ArgumentReg0
] = gtoh(attrp
->registers
.a0
);
1094 ec
->regs
.intRegFile
[27/*t12*/] = gtoh(attrp
->registers
.pc
);
1095 ec
->regs
.intRegFile
[StackPointerReg
] = gtoh(attrp
->registers
.sp
);
1096 ec
->regs
.miscRegs
.uniq
= uniq_val
;
1098 ec
->regs
.pc
= gtoh(attrp
->registers
.pc
);
1099 ec
->regs
.npc
= gtoh(attrp
->registers
.pc
) + sizeof(MachInst
);
1105 static SyscallReturn
1106 nxm_thread_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1109 TypedBufferArg
<Tru64::nxm_thread_attr
> attrp(xc
->getSyscallArg(0));
1110 TypedBufferArg
<uint64_t> kidp(xc
->getSyscallArg(1));
1111 int thread_index
= xc
->getSyscallArg(2);
1113 // get attribute args
1114 attrp
.copyIn(xc
->mem
);
1116 if (gtoh(attrp
->version
) != NXM_LIB_VERSION
) {
1117 cerr
<< "nxm_thread_create: thread library version mismatch! "
1118 << "got " << attrp
->version
1119 << ", expected " << NXM_LIB_VERSION
<< endl
;
1123 if (thread_index
< 0 | thread_index
> process
->numCpus()) {
1124 cerr
<< "nxm_thread_create: bad thread index " << thread_index
1129 // On a real machine, the per-RAD shared structure is in
1130 // shared memory, so both the user and kernel can get at it.
1131 // We don't have that luxury, so we just copy it in and then
1133 int rad_state_size
=
1134 (sizeof(Tru64::nxm_shared
) +
1135 (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
1137 TypedBufferArg
<Tru64::nxm_shared
> rad_state(0x14000,
1139 rad_state
.copyIn(xc
->mem
);
1141 uint64_t uniq_val
= gtoh(attrp
->pthid
) - gtoh(rad_state
->nxm_uniq_offset
);
1143 if (gtoh(attrp
->type
) == Tru64::NXM_TYPE_MANAGER
) {
1144 // DEC pthreads seems to always create one of these (in
1145 // addition to N application threads), but we don't use it,
1146 // so don't bother creating it.
1148 // This is supposed to be a port number. Make something up.
1150 kidp
.copyOut(xc
->mem
);
1153 } else if (gtoh(attrp
->type
) == Tru64::NXM_TYPE_VP
) {
1154 // A real "virtual processor" kernel thread. Need to fork
1155 // this thread on another CPU.
1156 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[thread_index
];
1158 if (gtoh(ssp
->nxm_u
.nxm_active
) != 0)
1159 return (int) Tru64::KERN_NOT_RECEIVER
;
1161 ssp
->nxm_u
.pth_id
= attrp
->pthid
;
1162 ssp
->nxm_u
.nxm_active
= htog(uniq_val
| 1);
1164 rad_state
.copyOut(xc
->mem
);
1166 Addr slot_state_addr
= 0x12000 + sizeof(Tru64::nxm_config_info
);
1167 int slot_state_size
=
1168 process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
1170 TypedBufferArg
<Tru64::nxm_slot_state_t
>
1171 slot_state(slot_state_addr
,
1174 slot_state
.copyIn(xc
->mem
);
1176 if (slot_state
[thread_index
] != Tru64::NXM_SLOT_AVAIL
) {
1177 cerr
<< "nxm_thread_createFunc: requested VP slot "
1178 << thread_index
<< " not available!" << endl
;
1182 // XXX This should have an endian conversion but I think this code
1183 // doesn't work anyway
1184 slot_state
[thread_index
] = Tru64::NXM_SLOT_BOUND
;
1186 slot_state
.copyOut(xc
->mem
);
1188 // Find a free simulator execution context.
1189 for (int i
= 0; i
< process
->numCpus(); ++i
) {
1190 ExecContext
*xc
= process
->execContexts
[i
];
1192 if (xc
->status() == ExecContext::Unallocated
) {
1193 // inactive context... grab it
1194 init_exec_context(xc
, attrp
, uniq_val
);
1196 // This is supposed to be a port number, but we'll try
1197 // and get away with just sticking the thread index
1199 *kidp
= htog(thread_index
);
1200 kidp
.copyOut(xc
->mem
);
1206 // fell out of loop... no available inactive context
1207 cerr
<< "nxm_thread_create: no idle contexts available." << endl
;
1210 cerr
<< "nxm_thread_create: can't handle thread type "
1211 << attrp
->type
<< endl
;
1218 /// Thread idle call (like yield()).
1219 static SyscallReturn
1220 nxm_idleFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1227 static SyscallReturn
1228 nxm_thread_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1231 uint64_t tid
= xc
->getSyscallArg(0);
1232 uint64_t secs
= xc
->getSyscallArg(1);
1233 uint64_t flags
= xc
->getSyscallArg(2);
1234 uint64_t action
= xc
->getSyscallArg(3);
1235 uint64_t usecs
= xc
->getSyscallArg(4);
1237 cout
<< xc
->cpu
->name() << ": nxm_thread_block " << tid
<< " " << secs
1238 << " " << flags
<< " " << action
<< " " << usecs
<< endl
;
1244 static SyscallReturn
1245 nxm_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1248 Addr uaddr
= xc
->getSyscallArg(0);
1249 uint64_t val
= xc
->getSyscallArg(1);
1250 uint64_t secs
= xc
->getSyscallArg(2);
1251 uint64_t usecs
= xc
->getSyscallArg(3);
1252 uint64_t flags
= xc
->getSyscallArg(4);
1254 BaseCPU
*cpu
= xc
->cpu
;
1256 cout
<< cpu
->name() << ": nxm_block "
1257 << hex
<< uaddr
<< dec
<< " " << val
1258 << " " << secs
<< " " << usecs
1259 << " " << flags
<< endl
;
1265 static SyscallReturn
1266 nxm_unblockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1269 Addr uaddr
= xc
->getSyscallArg(0);
1271 cout
<< xc
->cpu
->name() << ": nxm_unblock "
1272 << hex
<< uaddr
<< dec
<< endl
;
1277 /// Switch thread priority.
1278 static SyscallReturn
1279 swtch_priFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1282 // Attempts to switch to another runnable thread (if there is
1283 // one). Returns false if there are no other threads to run
1284 // (i.e., the thread can reasonably spin-wait) or true if there
1285 // are other threads.
1287 // Since we assume at most one "kernel" thread per CPU, it's
1288 // always safe to return false here.
1293 /// Activate exec context waiting on a channel. Just activate one
1296 activate_waiting_context(Addr uaddr
, Process
*process
,
1297 bool activate_all
= false)
1299 int num_activated
= 0;
1301 list
<Process::WaitRec
>::iterator i
= process
->waitList
.begin();
1302 list
<Process::WaitRec
>::iterator end
= process
->waitList
.end();
1304 while (i
!= end
&& (num_activated
== 0 || activate_all
)) {
1305 if (i
->waitChan
== uaddr
) {
1306 // found waiting process: make it active
1307 ExecContext
*newCtx
= i
->waitingContext
;
1308 assert(newCtx
->status() == ExecContext::Suspended
);
1311 // get rid of this record
1312 i
= process
->waitList
.erase(i
);
1320 return num_activated
;
1323 /// M5 hacked-up lock acquire.
1325 m5_lock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1327 TypedBufferArg
<uint64_t> lockp(uaddr
);
1329 lockp
.copyIn(xc
->mem
);
1331 if (gtoh(*lockp
) == 0) {
1332 // lock is free: grab it
1334 lockp
.copyOut(xc
->mem
);
1336 // lock is busy: disable until free
1337 process
->waitList
.push_back(Process::WaitRec(uaddr
, xc
));
1344 m5_unlock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1346 TypedBufferArg
<uint64_t> lockp(uaddr
);
1348 lockp
.copyIn(xc
->mem
);
1349 assert(*lockp
!= 0);
1351 // Check for a process waiting on the lock.
1352 int num_waiting
= activate_waiting_context(uaddr
, process
);
1354 // clear lock field if no waiting context is taking over the lock
1355 if (num_waiting
== 0) {
1357 lockp
.copyOut(xc
->mem
);
1361 /// Lock acquire syscall handler.
1362 static SyscallReturn
1363 m5_mutex_lockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1366 Addr uaddr
= xc
->getSyscallArg(0);
1368 m5_lock_mutex(uaddr
, process
, xc
);
1370 // Return 0 since we will always return to the user with the lock
1371 // acquired. We will just keep the context inactive until that is
1376 /// Try lock (non-blocking).
1377 static SyscallReturn
1378 m5_mutex_trylockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1381 Addr uaddr
= xc
->getSyscallArg(0);
1382 TypedBufferArg
<uint64_t> lockp(uaddr
);
1384 lockp
.copyIn(xc
->mem
);
1386 if (gtoh(*lockp
) == 0) {
1387 // lock is free: grab it
1389 lockp
.copyOut(xc
->mem
);
1396 /// Unlock syscall handler.
1397 static SyscallReturn
1398 m5_mutex_unlockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1401 Addr uaddr
= xc
->getSyscallArg(0);
1403 m5_unlock_mutex(uaddr
, process
, xc
);
1408 /// Signal ocndition.
1409 static SyscallReturn
1410 m5_cond_signalFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1413 Addr cond_addr
= xc
->getSyscallArg(0);
1415 // Wake up one process waiting on the condition variable.
1416 activate_waiting_context(cond_addr
, process
);
1421 /// Wake up all processes waiting on the condition variable.
1422 static SyscallReturn
1423 m5_cond_broadcastFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1426 Addr cond_addr
= xc
->getSyscallArg(0);
1428 activate_waiting_context(cond_addr
, process
, true);
1433 /// Wait on a condition.
1434 static SyscallReturn
1435 m5_cond_waitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1438 Addr cond_addr
= xc
->getSyscallArg(0);
1439 Addr lock_addr
= xc
->getSyscallArg(1);
1440 TypedBufferArg
<uint64_t> condp(cond_addr
);
1441 TypedBufferArg
<uint64_t> lockp(lock_addr
);
1443 // user is supposed to acquire lock before entering
1444 lockp
.copyIn(xc
->mem
);
1445 assert(gtoh(*lockp
) != 0);
1447 m5_unlock_mutex(lock_addr
, process
, xc
);
1449 process
->waitList
.push_back(Process::WaitRec(cond_addr
, xc
));
1456 static SyscallReturn
1457 m5_thread_exitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1460 assert(xc
->status() == ExecContext::Active
);
1466 /// Array of syscall descriptors for Mach syscalls, indexed by
1467 /// (negated) call number.
1468 static SyscallDesc machSyscallDescs
[];
1470 /// Number of syscalls in machSyscallDescs[].
1471 static const int Num_Mach_Syscall_Descs
;
1473 /// Max supported Mach syscall number.
1474 static const int Max_Mach_Syscall_Desc
;
1476 /// Since negated values are used to identify Mach syscalls, the
1477 /// minimum (signed) valid syscall number is the negated max Mach
1479 static const int Min_Syscall_Desc
;
1481 /// Do the specified syscall. Just looks the call number up in
1482 /// the table and invokes the appropriate handler.
1484 doSyscall(int callnum
, Process
*process
, ExecContext
*xc
)
1486 if (callnum
< Min_Syscall_Desc
|| callnum
> Max_Syscall_Desc
) {
1487 fatal("Syscall %d out of range\n", callnum
);
1492 &machSyscallDescs
[-callnum
] : &syscallDescs
[callnum
];
1494 desc
->doSyscall(callnum
, process
, xc
);
1497 /// Indirect syscall invocation (call #0).
1498 static SyscallReturn
1499 indirectSyscallFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1502 int new_callnum
= xc
->getSyscallArg(0);
1504 for (int i
= 0; i
< 5; ++i
)
1505 xc
->setSyscallArg(i
, xc
->getSyscallArg(i
+1));
1507 doSyscall(new_callnum
, process
, xc
);
1515 // open(2) flags translation table
1516 OpenFlagTransTable
Tru64::openFlagTable
[] = {
1518 { Tru64::TGT_O_RDONLY
, _O_RDONLY
},
1519 { Tru64::TGT_O_WRONLY
, _O_WRONLY
},
1520 { Tru64::TGT_O_RDWR
, _O_RDWR
},
1521 { Tru64::TGT_O_APPEND
, _O_APPEND
},
1522 { Tru64::TGT_O_CREAT
, _O_CREAT
},
1523 { Tru64::TGT_O_TRUNC
, _O_TRUNC
},
1524 { Tru64::TGT_O_EXCL
, _O_EXCL
},
1526 { Tru64::TGT_O_NONBLOCK
, _O_NONBLOCK
},
1529 { Tru64::TGT_O_NOCTTY
, _O_NOCTTY
},
1532 { Tru64::TGT_O_SYNC
, _O_SYNC
},
1534 #else /* !_MSC_VER */
1535 { Tru64::TGT_O_RDONLY
, O_RDONLY
},
1536 { Tru64::TGT_O_WRONLY
, O_WRONLY
},
1537 { Tru64::TGT_O_RDWR
, O_RDWR
},
1538 { Tru64::TGT_O_APPEND
, O_APPEND
},
1539 { Tru64::TGT_O_CREAT
, O_CREAT
},
1540 { Tru64::TGT_O_TRUNC
, O_TRUNC
},
1541 { Tru64::TGT_O_EXCL
, O_EXCL
},
1542 { Tru64::TGT_O_NONBLOCK
, O_NONBLOCK
},
1543 { Tru64::TGT_O_NOCTTY
, O_NOCTTY
},
1545 { Tru64::TGT_O_SYNC
, O_SYNC
},
1547 #endif /* _MSC_VER */
1550 const int Tru64::NUM_OPEN_FLAGS
= (sizeof(Tru64::openFlagTable
)/sizeof(Tru64::openFlagTable
[0]));
1552 const char *Tru64::hostname
= "m5.eecs.umich.edu";
1554 SyscallDesc
Tru64::syscallDescs
[] = {
1555 /* 0 */ SyscallDesc("syscall (#0)", indirectSyscallFunc
,
1556 SyscallDesc::SuppressReturnValue
),
1557 /* 1 */ SyscallDesc("exit", exitFunc
),
1558 /* 2 */ SyscallDesc("fork", unimplementedFunc
),
1559 /* 3 */ SyscallDesc("read", readFunc
),
1560 /* 4 */ SyscallDesc("write", writeFunc
),
1561 /* 5 */ SyscallDesc("old_open", unimplementedFunc
),
1562 /* 6 */ SyscallDesc("close", closeFunc
),
1563 /* 7 */ SyscallDesc("wait4", unimplementedFunc
),
1564 /* 8 */ SyscallDesc("old_creat", unimplementedFunc
),
1565 /* 9 */ SyscallDesc("link", unimplementedFunc
),
1566 /* 10 */ SyscallDesc("unlink", unlinkFunc
),
1567 /* 11 */ SyscallDesc("execv", unimplementedFunc
),
1568 /* 12 */ SyscallDesc("chdir", unimplementedFunc
),
1569 /* 13 */ SyscallDesc("fchdir", unimplementedFunc
),
1570 /* 14 */ SyscallDesc("mknod", unimplementedFunc
),
1571 /* 15 */ SyscallDesc("chmod", unimplementedFunc
),
1572 /* 16 */ SyscallDesc("chown", unimplementedFunc
),
1573 /* 17 */ SyscallDesc("obreak", obreakFunc
),
1574 /* 18 */ SyscallDesc("pre_F64_getfsstat", unimplementedFunc
),
1575 /* 19 */ SyscallDesc("lseek", lseekFunc
),
1576 /* 20 */ SyscallDesc("getpid", getpidFunc
),
1577 /* 21 */ SyscallDesc("mount", unimplementedFunc
),
1578 /* 22 */ SyscallDesc("unmount", unimplementedFunc
),
1579 /* 23 */ SyscallDesc("setuid", setuidFunc
),
1580 /* 24 */ SyscallDesc("getuid", getuidFunc
),
1581 /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc
),
1582 /* 26 */ SyscallDesc("ptrace", unimplementedFunc
),
1583 /* 27 */ SyscallDesc("recvmsg", unimplementedFunc
),
1584 /* 28 */ SyscallDesc("sendmsg", unimplementedFunc
),
1585 /* 29 */ SyscallDesc("recvfrom", unimplementedFunc
),
1586 /* 30 */ SyscallDesc("accept", unimplementedFunc
),
1587 /* 31 */ SyscallDesc("getpeername", unimplementedFunc
),
1588 /* 32 */ SyscallDesc("getsockname", unimplementedFunc
),
1589 /* 33 */ SyscallDesc("access", unimplementedFunc
),
1590 /* 34 */ SyscallDesc("chflags", unimplementedFunc
),
1591 /* 35 */ SyscallDesc("fchflags", unimplementedFunc
),
1592 /* 36 */ SyscallDesc("sync", unimplementedFunc
),
1593 /* 37 */ SyscallDesc("kill", unimplementedFunc
),
1594 /* 38 */ SyscallDesc("old_stat", unimplementedFunc
),
1595 /* 39 */ SyscallDesc("setpgid", unimplementedFunc
),
1596 /* 40 */ SyscallDesc("old_lstat", unimplementedFunc
),
1597 /* 41 */ SyscallDesc("dup", unimplementedFunc
),
1598 /* 42 */ SyscallDesc("pipe", unimplementedFunc
),
1599 /* 43 */ SyscallDesc("set_program_attributes", unimplementedFunc
),
1600 /* 44 */ SyscallDesc("profil", unimplementedFunc
),
1601 /* 45 */ SyscallDesc("open", openFunc
<Tru64
>),
1602 /* 46 */ SyscallDesc("obsolete osigaction", unimplementedFunc
),
1603 /* 47 */ SyscallDesc("getgid", getgidFunc
),
1604 /* 48 */ SyscallDesc("sigprocmask", ignoreFunc
),
1605 /* 49 */ SyscallDesc("getlogin", unimplementedFunc
),
1606 /* 50 */ SyscallDesc("setlogin", unimplementedFunc
),
1607 /* 51 */ SyscallDesc("acct", unimplementedFunc
),
1608 /* 52 */ SyscallDesc("sigpending", unimplementedFunc
),
1609 /* 53 */ SyscallDesc("classcntl", unimplementedFunc
),
1610 /* 54 */ SyscallDesc("ioctl", ioctlFunc
<Tru64
>),
1611 /* 55 */ SyscallDesc("reboot", unimplementedFunc
),
1612 /* 56 */ SyscallDesc("revoke", unimplementedFunc
),
1613 /* 57 */ SyscallDesc("symlink", unimplementedFunc
),
1614 /* 58 */ SyscallDesc("readlink", unimplementedFunc
),
1615 /* 59 */ SyscallDesc("execve", unimplementedFunc
),
1616 /* 60 */ SyscallDesc("umask", unimplementedFunc
),
1617 /* 61 */ SyscallDesc("chroot", unimplementedFunc
),
1618 /* 62 */ SyscallDesc("old_fstat", unimplementedFunc
),
1619 /* 63 */ SyscallDesc("getpgrp", unimplementedFunc
),
1620 /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc
),
1621 /* 65 */ SyscallDesc("mremap", unimplementedFunc
),
1622 /* 66 */ SyscallDesc("vfork", unimplementedFunc
),
1623 /* 67 */ SyscallDesc("pre_F64_stat", statFunc
<Tru64::PreF64
>),
1624 /* 68 */ SyscallDesc("pre_F64_lstat", lstatFunc
<Tru64::PreF64
>),
1625 /* 69 */ SyscallDesc("sbrk", unimplementedFunc
),
1626 /* 70 */ SyscallDesc("sstk", unimplementedFunc
),
1627 /* 71 */ SyscallDesc("mmap", mmapFunc
<Tru64
>),
1628 /* 72 */ SyscallDesc("ovadvise", unimplementedFunc
),
1629 /* 73 */ SyscallDesc("munmap", munmapFunc
),
1630 /* 74 */ SyscallDesc("mprotect", ignoreFunc
),
1631 /* 75 */ SyscallDesc("madvise", unimplementedFunc
),
1632 /* 76 */ SyscallDesc("old_vhangup", unimplementedFunc
),
1633 /* 77 */ SyscallDesc("kmodcall", unimplementedFunc
),
1634 /* 78 */ SyscallDesc("mincore", unimplementedFunc
),
1635 /* 79 */ SyscallDesc("getgroups", unimplementedFunc
),
1636 /* 80 */ SyscallDesc("setgroups", unimplementedFunc
),
1637 /* 81 */ SyscallDesc("old_getpgrp", unimplementedFunc
),
1638 /* 82 */ SyscallDesc("setpgrp", unimplementedFunc
),
1639 /* 83 */ SyscallDesc("setitimer", unimplementedFunc
),
1640 /* 84 */ SyscallDesc("old_wait", unimplementedFunc
),
1641 /* 85 */ SyscallDesc("table", tableFunc
),
1642 /* 86 */ SyscallDesc("getitimer", unimplementedFunc
),
1643 /* 87 */ SyscallDesc("gethostname", gethostnameFunc
),
1644 /* 88 */ SyscallDesc("sethostname", unimplementedFunc
),
1645 /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc
),
1646 /* 90 */ SyscallDesc("dup2", unimplementedFunc
),
1647 /* 91 */ SyscallDesc("pre_F64_fstat", fstatFunc
<Tru64::PreF64
>),
1648 /* 92 */ SyscallDesc("fcntl", fcntlFunc
),
1649 /* 93 */ SyscallDesc("select", unimplementedFunc
),
1650 /* 94 */ SyscallDesc("poll", unimplementedFunc
),
1651 /* 95 */ SyscallDesc("fsync", unimplementedFunc
),
1652 /* 96 */ SyscallDesc("setpriority", unimplementedFunc
),
1653 /* 97 */ SyscallDesc("socket", unimplementedFunc
),
1654 /* 98 */ SyscallDesc("connect", unimplementedFunc
),
1655 /* 99 */ SyscallDesc("old_accept", unimplementedFunc
),
1656 /* 100 */ SyscallDesc("getpriority", unimplementedFunc
),
1657 /* 101 */ SyscallDesc("old_send", unimplementedFunc
),
1658 /* 102 */ SyscallDesc("old_recv", unimplementedFunc
),
1659 /* 103 */ SyscallDesc("sigreturn", sigreturnFunc
,
1660 SyscallDesc::SuppressReturnValue
),
1661 /* 104 */ SyscallDesc("bind", unimplementedFunc
),
1662 /* 105 */ SyscallDesc("setsockopt", unimplementedFunc
),
1663 /* 106 */ SyscallDesc("listen", unimplementedFunc
),
1664 /* 107 */ SyscallDesc("plock", unimplementedFunc
),
1665 /* 108 */ SyscallDesc("old_sigvec", unimplementedFunc
),
1666 /* 109 */ SyscallDesc("old_sigblock", unimplementedFunc
),
1667 /* 110 */ SyscallDesc("old_sigsetmask", unimplementedFunc
),
1668 /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc
),
1669 /* 112 */ SyscallDesc("sigstack", ignoreFunc
),
1670 /* 113 */ SyscallDesc("old_recvmsg", unimplementedFunc
),
1671 /* 114 */ SyscallDesc("old_sendmsg", unimplementedFunc
),
1672 /* 115 */ SyscallDesc("obsolete vtrace", unimplementedFunc
),
1673 /* 116 */ SyscallDesc("gettimeofday", gettimeofdayFunc
<Tru64
>),
1674 /* 117 */ SyscallDesc("getrusage", getrusageFunc
<Tru64
>),
1675 /* 118 */ SyscallDesc("getsockopt", unimplementedFunc
),
1676 /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc
),
1677 /* 120 */ SyscallDesc("readv", unimplementedFunc
),
1678 /* 121 */ SyscallDesc("writev", unimplementedFunc
),
1679 /* 122 */ SyscallDesc("settimeofday", unimplementedFunc
),
1680 /* 123 */ SyscallDesc("fchown", unimplementedFunc
),
1681 /* 124 */ SyscallDesc("fchmod", unimplementedFunc
),
1682 /* 125 */ SyscallDesc("old_recvfrom", unimplementedFunc
),
1683 /* 126 */ SyscallDesc("setreuid", unimplementedFunc
),
1684 /* 127 */ SyscallDesc("setregid", unimplementedFunc
),
1685 /* 128 */ SyscallDesc("rename", renameFunc
),
1686 /* 129 */ SyscallDesc("truncate", truncateFunc
),
1687 /* 130 */ SyscallDesc("ftruncate", ftruncateFunc
),
1688 /* 131 */ SyscallDesc("flock", unimplementedFunc
),
1689 /* 132 */ SyscallDesc("setgid", unimplementedFunc
),
1690 /* 133 */ SyscallDesc("sendto", unimplementedFunc
),
1691 /* 134 */ SyscallDesc("shutdown", unimplementedFunc
),
1692 /* 135 */ SyscallDesc("socketpair", unimplementedFunc
),
1693 /* 136 */ SyscallDesc("mkdir", unimplementedFunc
),
1694 /* 137 */ SyscallDesc("rmdir", unimplementedFunc
),
1695 /* 138 */ SyscallDesc("utimes", unimplementedFunc
),
1696 /* 139 */ SyscallDesc("obsolete 4.2 sigreturn", unimplementedFunc
),
1697 /* 140 */ SyscallDesc("adjtime", unimplementedFunc
),
1698 /* 141 */ SyscallDesc("old_getpeername", unimplementedFunc
),
1699 /* 142 */ SyscallDesc("gethostid", unimplementedFunc
),
1700 /* 143 */ SyscallDesc("sethostid", unimplementedFunc
),
1701 /* 144 */ SyscallDesc("getrlimit", getrlimitFunc
<Tru64
>),
1702 /* 145 */ SyscallDesc("setrlimit", ignoreFunc
),
1703 /* 146 */ SyscallDesc("old_killpg", unimplementedFunc
),
1704 /* 147 */ SyscallDesc("setsid", unimplementedFunc
),
1705 /* 148 */ SyscallDesc("quotactl", unimplementedFunc
),
1706 /* 149 */ SyscallDesc("oldquota", unimplementedFunc
),
1707 /* 150 */ SyscallDesc("old_getsockname", unimplementedFunc
),
1708 /* 151 */ SyscallDesc("pread", unimplementedFunc
),
1709 /* 152 */ SyscallDesc("pwrite", unimplementedFunc
),
1710 /* 153 */ SyscallDesc("pid_block", unimplementedFunc
),
1711 /* 154 */ SyscallDesc("pid_unblock", unimplementedFunc
),
1712 /* 155 */ SyscallDesc("signal_urti", unimplementedFunc
),
1713 /* 156 */ SyscallDesc("sigaction", ignoreFunc
),
1714 /* 157 */ SyscallDesc("sigwaitprim", unimplementedFunc
),
1715 /* 158 */ SyscallDesc("nfssvc", unimplementedFunc
),
1716 /* 159 */ SyscallDesc("getdirentries", getdirentriesFunc
),
1717 /* 160 */ SyscallDesc("pre_F64_statfs", statfsFunc
<Tru64::PreF64
>),
1718 /* 161 */ SyscallDesc("pre_F64_fstatfs", fstatfsFunc
<Tru64::PreF64
>),
1719 /* 162 */ SyscallDesc("unknown #162", unimplementedFunc
),
1720 /* 163 */ SyscallDesc("async_daemon", unimplementedFunc
),
1721 /* 164 */ SyscallDesc("getfh", unimplementedFunc
),
1722 /* 165 */ SyscallDesc("getdomainname", unimplementedFunc
),
1723 /* 166 */ SyscallDesc("setdomainname", unimplementedFunc
),
1724 /* 167 */ SyscallDesc("unknown #167", unimplementedFunc
),
1725 /* 168 */ SyscallDesc("unknown #168", unimplementedFunc
),
1726 /* 169 */ SyscallDesc("exportfs", unimplementedFunc
),
1727 /* 170 */ SyscallDesc("unknown #170", unimplementedFunc
),
1728 /* 171 */ SyscallDesc("unknown #171", unimplementedFunc
),
1729 /* 172 */ SyscallDesc("unknown #172", unimplementedFunc
),
1730 /* 173 */ SyscallDesc("unknown #173", unimplementedFunc
),
1731 /* 174 */ SyscallDesc("unknown #174", unimplementedFunc
),
1732 /* 175 */ SyscallDesc("unknown #175", unimplementedFunc
),
1733 /* 176 */ SyscallDesc("unknown #176", unimplementedFunc
),
1734 /* 177 */ SyscallDesc("unknown #177", unimplementedFunc
),
1735 /* 178 */ SyscallDesc("unknown #178", unimplementedFunc
),
1736 /* 179 */ SyscallDesc("unknown #179", unimplementedFunc
),
1737 /* 180 */ SyscallDesc("unknown #180", unimplementedFunc
),
1738 /* 181 */ SyscallDesc("alt_plock", unimplementedFunc
),
1739 /* 182 */ SyscallDesc("unknown #182", unimplementedFunc
),
1740 /* 183 */ SyscallDesc("unknown #183", unimplementedFunc
),
1741 /* 184 */ SyscallDesc("getmnt", unimplementedFunc
),
1742 /* 185 */ SyscallDesc("unknown #185", unimplementedFunc
),
1743 /* 186 */ SyscallDesc("unknown #186", unimplementedFunc
),
1744 /* 187 */ SyscallDesc("alt_sigpending", unimplementedFunc
),
1745 /* 188 */ SyscallDesc("alt_setsid", unimplementedFunc
),
1746 /* 189 */ SyscallDesc("unknown #189", unimplementedFunc
),
1747 /* 190 */ SyscallDesc("unknown #190", unimplementedFunc
),
1748 /* 191 */ SyscallDesc("unknown #191", unimplementedFunc
),
1749 /* 192 */ SyscallDesc("unknown #192", unimplementedFunc
),
1750 /* 193 */ SyscallDesc("unknown #193", unimplementedFunc
),
1751 /* 194 */ SyscallDesc("unknown #194", unimplementedFunc
),
1752 /* 195 */ SyscallDesc("unknown #195", unimplementedFunc
),
1753 /* 196 */ SyscallDesc("unknown #196", unimplementedFunc
),
1754 /* 197 */ SyscallDesc("unknown #197", unimplementedFunc
),
1755 /* 198 */ SyscallDesc("unknown #198", unimplementedFunc
),
1756 /* 199 */ SyscallDesc("swapon", unimplementedFunc
),
1757 /* 200 */ SyscallDesc("msgctl", unimplementedFunc
),
1758 /* 201 */ SyscallDesc("msgget", unimplementedFunc
),
1759 /* 202 */ SyscallDesc("msgrcv", unimplementedFunc
),
1760 /* 203 */ SyscallDesc("msgsnd", unimplementedFunc
),
1761 /* 204 */ SyscallDesc("semctl", unimplementedFunc
),
1762 /* 205 */ SyscallDesc("semget", unimplementedFunc
),
1763 /* 206 */ SyscallDesc("semop", unimplementedFunc
),
1764 /* 207 */ SyscallDesc("uname", unameFunc
),
1765 /* 208 */ SyscallDesc("lchown", unimplementedFunc
),
1766 /* 209 */ SyscallDesc("shmat", unimplementedFunc
),
1767 /* 210 */ SyscallDesc("shmctl", unimplementedFunc
),
1768 /* 211 */ SyscallDesc("shmdt", unimplementedFunc
),
1769 /* 212 */ SyscallDesc("shmget", unimplementedFunc
),
1770 /* 213 */ SyscallDesc("mvalid", unimplementedFunc
),
1771 /* 214 */ SyscallDesc("getaddressconf", unimplementedFunc
),
1772 /* 215 */ SyscallDesc("msleep", unimplementedFunc
),
1773 /* 216 */ SyscallDesc("mwakeup", unimplementedFunc
),
1774 /* 217 */ SyscallDesc("msync", unimplementedFunc
),
1775 /* 218 */ SyscallDesc("signal", unimplementedFunc
),
1776 /* 219 */ SyscallDesc("utc_gettime", unimplementedFunc
),
1777 /* 220 */ SyscallDesc("utc_adjtime", unimplementedFunc
),
1778 /* 221 */ SyscallDesc("unknown #221", unimplementedFunc
),
1779 /* 222 */ SyscallDesc("security", unimplementedFunc
),
1780 /* 223 */ SyscallDesc("kloadcall", unimplementedFunc
),
1781 /* 224 */ SyscallDesc("stat", statFunc
<Tru64::F64
>),
1782 /* 225 */ SyscallDesc("lstat", lstatFunc
<Tru64::F64
>),
1783 /* 226 */ SyscallDesc("fstat", fstatFunc
<Tru64::F64
>),
1784 /* 227 */ SyscallDesc("statfs", statfsFunc
<Tru64::F64
>),
1785 /* 228 */ SyscallDesc("fstatfs", fstatfsFunc
<Tru64::F64
>),
1786 /* 229 */ SyscallDesc("getfsstat", unimplementedFunc
),
1787 /* 230 */ SyscallDesc("gettimeofday64", unimplementedFunc
),
1788 /* 231 */ SyscallDesc("settimeofday64", unimplementedFunc
),
1789 /* 232 */ SyscallDesc("unknown #232", unimplementedFunc
),
1790 /* 233 */ SyscallDesc("getpgid", unimplementedFunc
),
1791 /* 234 */ SyscallDesc("getsid", unimplementedFunc
),
1792 /* 235 */ SyscallDesc("sigaltstack", ignoreFunc
),
1793 /* 236 */ SyscallDesc("waitid", unimplementedFunc
),
1794 /* 237 */ SyscallDesc("priocntlset", unimplementedFunc
),
1795 /* 238 */ SyscallDesc("sigsendset", unimplementedFunc
),
1796 /* 239 */ SyscallDesc("set_speculative", unimplementedFunc
),
1797 /* 240 */ SyscallDesc("msfs_syscall", unimplementedFunc
),
1798 /* 241 */ SyscallDesc("sysinfo", unimplementedFunc
),
1799 /* 242 */ SyscallDesc("uadmin", unimplementedFunc
),
1800 /* 243 */ SyscallDesc("fuser", unimplementedFunc
),
1801 /* 244 */ SyscallDesc("proplist_syscall", unimplementedFunc
),
1802 /* 245 */ SyscallDesc("ntp_adjtime", unimplementedFunc
),
1803 /* 246 */ SyscallDesc("ntp_gettime", unimplementedFunc
),
1804 /* 247 */ SyscallDesc("pathconf", unimplementedFunc
),
1805 /* 248 */ SyscallDesc("fpathconf", unimplementedFunc
),
1806 /* 249 */ SyscallDesc("sync2", unimplementedFunc
),
1807 /* 250 */ SyscallDesc("uswitch", unimplementedFunc
),
1808 /* 251 */ SyscallDesc("usleep_thread", unimplementedFunc
),
1809 /* 252 */ SyscallDesc("audcntl", unimplementedFunc
),
1810 /* 253 */ SyscallDesc("audgen", unimplementedFunc
),
1811 /* 254 */ SyscallDesc("sysfs", unimplementedFunc
),
1812 /* 255 */ SyscallDesc("subsys_info", unimplementedFunc
),
1813 /* 256 */ SyscallDesc("getsysinfo", getsysinfoFunc
),
1814 /* 257 */ SyscallDesc("setsysinfo", setsysinfoFunc
),
1815 /* 258 */ SyscallDesc("afs_syscall", unimplementedFunc
),
1816 /* 259 */ SyscallDesc("swapctl", unimplementedFunc
),
1817 /* 260 */ SyscallDesc("memcntl", unimplementedFunc
),
1818 /* 261 */ SyscallDesc("fdatasync", unimplementedFunc
),
1819 /* 262 */ SyscallDesc("oflock", unimplementedFunc
),
1820 /* 263 */ SyscallDesc("F64_readv", unimplementedFunc
),
1821 /* 264 */ SyscallDesc("F64_writev", unimplementedFunc
),
1822 /* 265 */ SyscallDesc("cdslxlate", unimplementedFunc
),
1823 /* 266 */ SyscallDesc("sendfile", unimplementedFunc
),
1826 const int Tru64::Num_Syscall_Descs
=
1827 sizeof(Tru64::syscallDescs
) / sizeof(SyscallDesc
);
1829 const int Tru64::Max_Syscall_Desc
= Tru64::Num_Syscall_Descs
- 1;
1831 SyscallDesc
Tru64::machSyscallDescs
[] = {
1832 /* 0 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1833 /* 1 */ SyscallDesc("m5_mutex_lock", m5_mutex_lockFunc
),
1834 /* 2 */ SyscallDesc("m5_mutex_trylock", m5_mutex_trylockFunc
),
1835 /* 3 */ SyscallDesc("m5_mutex_unlock", m5_mutex_unlockFunc
),
1836 /* 4 */ SyscallDesc("m5_cond_signal", m5_cond_signalFunc
),
1837 /* 5 */ SyscallDesc("m5_cond_broadcast", m5_cond_broadcastFunc
),
1838 /* 6 */ SyscallDesc("m5_cond_wait", m5_cond_waitFunc
),
1839 /* 7 */ SyscallDesc("m5_thread_exit", m5_thread_exitFunc
),
1840 /* 8 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1841 /* 9 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1842 /* 10 */ SyscallDesc("task_self", unimplementedFunc
),
1843 /* 11 */ SyscallDesc("thread_reply", unimplementedFunc
),
1844 /* 12 */ SyscallDesc("task_notify", unimplementedFunc
),
1845 /* 13 */ SyscallDesc("thread_self", unimplementedFunc
),
1846 /* 14 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1847 /* 15 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1848 /* 16 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1849 /* 17 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1850 /* 18 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1851 /* 19 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1852 /* 20 */ SyscallDesc("msg_send_trap", unimplementedFunc
),
1853 /* 21 */ SyscallDesc("msg_receive_trap", unimplementedFunc
),
1854 /* 22 */ SyscallDesc("msg_rpc_trap", unimplementedFunc
),
1855 /* 23 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1856 /* 24 */ SyscallDesc("nxm_block", nxm_blockFunc
),
1857 /* 25 */ SyscallDesc("nxm_unblock", nxm_unblockFunc
),
1858 /* 26 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1859 /* 27 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1860 /* 28 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1861 /* 29 */ SyscallDesc("nxm_thread_destroy", unimplementedFunc
),
1862 /* 30 */ SyscallDesc("lw_wire", unimplementedFunc
),
1863 /* 31 */ SyscallDesc("lw_unwire", unimplementedFunc
),
1864 /* 32 */ SyscallDesc("nxm_thread_create", nxm_thread_createFunc
),
1865 /* 33 */ SyscallDesc("nxm_task_init", nxm_task_initFunc
),
1866 /* 34 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1867 /* 35 */ SyscallDesc("nxm_idle", nxm_idleFunc
),
1868 /* 36 */ SyscallDesc("nxm_wakeup_idle", unimplementedFunc
),
1869 /* 37 */ SyscallDesc("nxm_set_pthid", unimplementedFunc
),
1870 /* 38 */ SyscallDesc("nxm_thread_kill", unimplementedFunc
),
1871 /* 39 */ SyscallDesc("nxm_thread_block", nxm_thread_blockFunc
),
1872 /* 40 */ SyscallDesc("nxm_thread_wakeup", unimplementedFunc
),
1873 /* 41 */ SyscallDesc("init_process", unimplementedFunc
),
1874 /* 42 */ SyscallDesc("nxm_get_binding", unimplementedFunc
),
1875 /* 43 */ SyscallDesc("map_fd", unimplementedFunc
),
1876 /* 44 */ SyscallDesc("nxm_resched", unimplementedFunc
),
1877 /* 45 */ SyscallDesc("nxm_set_cancel", unimplementedFunc
),
1878 /* 46 */ SyscallDesc("nxm_set_binding", unimplementedFunc
),
1879 /* 47 */ SyscallDesc("stack_create", stack_createFunc
),
1880 /* 48 */ SyscallDesc("nxm_get_state", unimplementedFunc
),
1881 /* 49 */ SyscallDesc("nxm_thread_suspend", unimplementedFunc
),
1882 /* 50 */ SyscallDesc("nxm_thread_resume", unimplementedFunc
),
1883 /* 51 */ SyscallDesc("nxm_signal_check", unimplementedFunc
),
1884 /* 52 */ SyscallDesc("htg_unix_syscall", unimplementedFunc
),
1885 /* 53 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1886 /* 54 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1887 /* 55 */ SyscallDesc("host_self", unimplementedFunc
),
1888 /* 56 */ SyscallDesc("host_priv_self", unimplementedFunc
),
1889 /* 57 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1890 /* 58 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1891 /* 59 */ SyscallDesc("swtch_pri", swtch_priFunc
),
1892 /* 60 */ SyscallDesc("swtch", unimplementedFunc
),
1893 /* 61 */ SyscallDesc("thread_switch", unimplementedFunc
),
1894 /* 62 */ SyscallDesc("semop_fast", unimplementedFunc
),
1895 /* 63 */ SyscallDesc("nxm_pshared_init", unimplementedFunc
),
1896 /* 64 */ SyscallDesc("nxm_pshared_block", unimplementedFunc
),
1897 /* 65 */ SyscallDesc("nxm_pshared_unblock", unimplementedFunc
),
1898 /* 66 */ SyscallDesc("nxm_pshared_destroy", unimplementedFunc
),
1899 /* 67 */ SyscallDesc("nxm_swtch_pri", swtch_priFunc
),
1900 /* 68 */ SyscallDesc("lw_syscall", unimplementedFunc
),
1901 /* 69 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1902 /* 70 */ SyscallDesc("mach_sctimes_0", unimplementedFunc
),
1903 /* 71 */ SyscallDesc("mach_sctimes_1", unimplementedFunc
),
1904 /* 72 */ SyscallDesc("mach_sctimes_2", unimplementedFunc
),
1905 /* 73 */ SyscallDesc("mach_sctimes_3", unimplementedFunc
),
1906 /* 74 */ SyscallDesc("mach_sctimes_4", unimplementedFunc
),
1907 /* 75 */ SyscallDesc("mach_sctimes_5", unimplementedFunc
),
1908 /* 76 */ SyscallDesc("mach_sctimes_6", unimplementedFunc
),
1909 /* 77 */ SyscallDesc("mach_sctimes_7", unimplementedFunc
),
1910 /* 78 */ SyscallDesc("mach_sctimes_8", unimplementedFunc
),
1911 /* 79 */ SyscallDesc("mach_sctimes_9", unimplementedFunc
),
1912 /* 80 */ SyscallDesc("mach_sctimes_10", unimplementedFunc
),
1913 /* 81 */ SyscallDesc("mach_sctimes_11", unimplementedFunc
),
1914 /* 82 */ SyscallDesc("mach_sctimes_port_alloc_dealloc", unimplementedFunc
)
1917 const int Tru64::Num_Mach_Syscall_Descs
=
1918 sizeof(Tru64::machSyscallDescs
) / sizeof(SyscallDesc
);
1919 const int Tru64::Max_Mach_Syscall_Desc
= Tru64::Num_Mach_Syscall_Descs
- 1;
1920 const int Tru64::Min_Syscall_Desc
= -Tru64::Max_Mach_Syscall_Desc
;
1924 AlphaTru64Process::syscall(ExecContext
*xc
)
1928 int64_t callnum
= xc
->regs
.intRegFile
[ReturnValueReg
];
1930 Tru64::doSyscall(callnum
, this, xc
);
1934 AlphaTru64Process::AlphaTru64Process(const std::string
&name
,
1935 ObjectFile
*objFile
,
1939 std::vector
<std::string
> &argv
,
1940 std::vector
<std::string
> &envp
)
1941 : LiveProcess(name
, objFile
, stdin_fd
, stdout_fd
, stderr_fd
, argv
, envp
)