2 * Copyright (c) 2003 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.
31 #include <fcntl.h> // for host open() flags
32 #include <sys/types.h>
34 #include <string.h> // for memset()
37 #include "sim/host.hh"
38 #include "cpu/base_cpu.hh"
39 #include "mem/functional_mem/functional_memory.hh"
40 #include "sim/process.hh"
41 #include "cpu/exec_context.hh"
42 #include "sim/fake_syscall.hh"
44 #include "arch/alpha/alpha_common_syscall_emul.hh"
45 #include "arch/alpha/alpha_tru64_process.hh"
47 #include "sim/syscall_emul.hh"
48 #include "sim/universe.hh" // for curTick & ticksPerSecond
50 #include "base/trace.hh"
62 typedef uint64_t size_t;
63 typedef uint64_t off_t
;
64 typedef uint16_t nlink_t
;
65 typedef int32_t dev_t
;
66 typedef uint32_t uid_t
;
67 typedef uint32_t gid_t
;
68 typedef uint32_t time_t;
69 typedef uint32_t mode_t
;
70 typedef uint32_t ino_t
;
73 static const int TGT_O_RDONLY
= 00000000;
74 static const int TGT_O_WRONLY
= 00000001;
75 static const int TGT_O_RDWR
= 00000002;
76 static const int TGT_O_NONBLOCK
= 00000004;
77 static const int TGT_O_APPEND
= 00000010;
78 static const int TGT_O_CREAT
= 00001000;
79 static const int TGT_O_TRUNC
= 00002000;
80 static const int TGT_O_EXCL
= 00004000;
81 static const int TGT_O_NOCTTY
= 00010000;
82 static const int TGT_O_SYNC
= 00040000;
83 static const int TGT_O_DRD
= 00100000;
84 static const int TGT_O_DIRECTIO
= 00200000;
85 static const int TGT_O_CACHE
= 00400000;
86 static const int TGT_O_DSYNC
= 02000000;
87 static const int TGT_O_RSYNC
= 04000000;
89 static OpenFlagTransTable openFlagTable
[];
90 static const int NUM_OPEN_FLAGS
;
93 // Stat buffer. Note that Tru64 v5.0+ use a new "F64" stat structure,
94 // and a new set of syscall numbers for stat calls. Backwards
95 // compatibility with v4.x should be feasible by implementing another
96 // set of stat functions using the old structure definition and
97 // binding them to the old syscall numbers, but we haven't done that
106 uint16_t st_nlink_reserved
;
122 uint64_t st_spare
[4];
124 int32_t st_ino_reserved
;
126 int32_t st_atime_reserved
;
128 int32_t st_mtime_reserved
;
130 int32_t st_ctime_reserved
;
137 // for getdirentries()
142 ino_t d_ino
; /* file number of entry */
143 uint16_t d_reclen
; /* length of this record */
144 uint16_t d_namlen
; /* length of string in d_name */
145 char d_name
[256]; /* dummy name length */
153 static const int _SYS_NMLN
= 32;
156 char sysname
[_SYS_NMLN
];
157 char nodename
[_SYS_NMLN
];
158 char release
[_SYS_NMLN
];
159 char version
[_SYS_NMLN
];
160 char machine
[_SYS_NMLN
];
168 static const unsigned TIOCGETP
= 0x40067408;
169 static const unsigned TIOCSETP
= 0x80067409;
170 static const unsigned TIOCSETN
= 0x8006740a;
171 static const unsigned TIOCSETC
= 0x80067411;
172 static const unsigned TIOCGETC
= 0x40067412;
173 static const unsigned FIONREAD
= 0x4004667f;
174 static const unsigned TIOCISATTY
= 0x2000745e;
180 enum rlimit_resources
{
193 uint64_t rlim_cur
; // soft limit
194 uint64_t rlim_max
; // hard limit
201 static const unsigned TGT_MAP_ANONYMOUS
= 0x10;
208 static const unsigned GSI_PLATFORM_NAME
= 103; // get platform name as string
209 static const unsigned GSI_CPU_INFO
= 59; // CPU information
210 static const unsigned GSI_PROC_TYPE
= 60; // get proc_type
211 static const unsigned GSI_MAX_CPU
= 30; // max # cpu's on this machine
212 static const unsigned GSI_CPUS_IN_BOX
= 55; // number of processors in system
213 static const unsigned GSI_PHYSMEM
= 19; // Amount of physical memory in KB
214 static const unsigned GSI_CLK_TCK
= 42; // clock freq in Hz
217 uint32_t current_cpu
;
218 uint32_t cpus_in_box
;
221 uint64_t cpus_present
;
222 uint64_t cpus_running
;
223 uint64_t cpu_binding
;
224 uint64_t cpu_ex_binding
;
226 uint32_t unused
[3]; // future expansion
243 static const int RUSAGE_THREAD
= 1;
244 static const int RUSAGE_SELF
= 0;
245 static const int RUSAGE_CHILDREN
= -1;
248 struct timeval ru_utime
; // user time used
249 struct timeval ru_stime
; // system time used
251 uint64_t ru_ixrss
; // integral shared memory size
252 uint64_t ru_idrss
; // integral unshared data "
253 uint64_t ru_isrss
; // integral unshared stack "
254 uint64_t ru_minflt
; // page reclaims - total vmfaults
255 uint64_t ru_majflt
; // page faults
256 uint64_t ru_nswap
; // swaps
257 uint64_t ru_inblock
; // block input operations
258 uint64_t ru_oublock
; // block output operations
259 uint64_t ru_msgsnd
; // messages sent
260 uint64_t ru_msgrcv
; // messages received
261 uint64_t ru_nsignals
; // signals received
262 uint64_t ru_nvcsw
; // voluntary context switches
263 uint64_t ru_nivcsw
; // involuntary "
271 int64_t sc_onstack
; // sigstack state to restore
272 int64_t sc_mask
; // signal mask to restore
273 int64_t sc_pc
; // pc at time of signal
274 int64_t sc_ps
; // psl to retore
275 int64_t sc_regs
[32]; // processor regs 0 to 31
276 int64_t sc_ownedfp
; // fp has been used
277 int64_t sc_fpregs
[32]; // fp regs 0 to 31
278 uint64_t sc_fpcr
; // floating point control reg
279 uint64_t sc_fp_control
; // software fpcr
280 int64_t sc_reserved1
; // reserved for kernel
281 uint32_t sc_kreserved1
; // reserved for kernel
282 uint32_t sc_kreserved2
; // reserved for kernel
283 size_t sc_ssize
; // stack size
284 caddr_t sc_sbase
; // stack start
285 uint64_t sc_traparg_a0
; // a0 argument to trap on exc
286 uint64_t sc_traparg_a1
; // a1 argument to trap on exc
287 uint64_t sc_traparg_a2
; // a2 argument to trap on exc
288 uint64_t sc_fp_trap_pc
; // imprecise pc
289 uint64_t sc_fp_trigger_sum
; // Exception summary at trigg
290 uint64_t sc_fp_trigger_inst
; // Instruction at trigger pc
297 static const int TBL_SYSINFO
= 12;
300 uint64_t si_user
; // User time
301 uint64_t si_nice
; // Nice time
302 uint64_t si_sys
; // System time
303 uint64_t si_idle
; // Idle time
306 uint64_t si_boottime
; // Boot time in seconds
307 uint64_t wait
; // Wait time
308 uint32_t si_max_procs
; // rpb->rpb_numprocs
319 Addr address
; // address hint
320 size_t rsize
; // red zone size
321 size_t ysize
; // yellow zone size
322 size_t gsize
; // green zone size
323 size_t swap
; // amount of swap to reserve
324 size_t incr
; // growth increment
325 uint64_t align
; // address alignment
326 uint64_t flags
; // MAP_FIXED etc.
327 // struct memalloc_attr *
328 Addr attr
; // allocation policy
333 // return values for nxm calls
336 KERN_NOT_RECEIVER
= 7,
344 static const int NXM_TASK_INIT_VP
= 2; // initial thread is VP
346 struct nxm_task_attr
{
347 int64_t nxm_callback
;
348 unsigned int nxm_version
;
349 unsigned short nxm_uniq_offset
;
350 unsigned short flags
;
356 typedef uint64_t sigset_t
;
358 struct ushared_state
{
359 sigset_t sigmask
; // thread signal mask
360 sigset_t sig
; // thread pending mask
361 // struct nxm_pth_state *
362 Addr pth_id
; // out-of-line state
363 int flags
; // shared flags
364 #define US_SIGSTACK 0x1 // thread called sigaltstack
365 #define US_ONSTACK 0x2 // thread is running on altstack
366 #define US_PROFILE 0x4 // thread called profil
367 #define US_SYSCALL 0x8 // thread in syscall
368 #define US_TRAP 0x10 // thread has trapped
369 #define US_YELLOW 0x20 // thread has mellowed yellow
370 #define US_YZONE 0x40 // thread has zoned out
371 #define US_FP_OWNED 0x80 // thread used floating point
373 int cancel_state
; // thread's cancelation state
374 #define US_CANCEL 0x1 // cancel pending
375 #define US_NOCANCEL 0X2 // synch cancel disabled
376 #define US_SYS_NOCANCEL 0x4 // syscall cancel disabled
377 #define US_ASYNC_NOCANCEL 0x8 // asynch cancel disabled
378 #define US_CANCEL_BITS (US_NOCANCEL|US_SYS_NOCANCEL|US_ASYNC_NOCANCEL)
379 #define US_CANCEL_MASK (US_CANCEL|US_NOCANCEL|US_SYS_NOCANCEL| \
382 // These are semi-shared. They are always visible to
383 // the kernel but are never context-switched by the library.
385 int nxm_ssig
; // scheduler's synchronous signals
387 int64_t nxm_active
; // scheduler active
391 struct nxm_sched_state
{
392 struct ushared_state nxm_u
; // state own by user thread
393 unsigned int nxm_bits
; // scheduler state / slot
394 int nxm_quantum
; // quantum count-down value
395 int nxm_set_quantum
; // quantum reset value
396 int nxm_sysevent
; // syscall state
397 // struct nxm_upcall *
398 Addr nxm_uc_ret
; // stack ptr of null thread
400 Addr nxm_tid
; // scheduler's thread id
401 int64_t nxm_va
; // page fault address
402 // struct nxm_pth_state *
403 Addr nxm_pthid
; // id of null thread
404 uint64_t nxm_bound_pcs_count
; // bound PCS thread count
409 int64_t nxm_callback
; // address of upcall routine
410 unsigned int nxm_version
; // version number
411 unsigned short nxm_uniq_offset
; // correction factor for TEB
413 int64_t space
[2]; // future growth
414 struct nxm_sched_state nxm_ss
[1]; // array of shared areas
417 enum nxm_slot_state_t
{
425 struct nxm_config_info
{
426 int nxm_nslots_per_rad
; // max number of VP slots per RAD
427 int nxm_nrads
; // max number of RADs
428 // nxm_slot_state_t *
429 Addr nxm_slot_state
; // per-VP slot state
430 // struct nxm_shared *
431 Addr nxm_rad
[1]; // per-RAD shared areas
435 // for nxm_thread_create
438 enum nxm_thread_type
{
445 struct nxm_thread_attr
{
465 copyOutStatBuf(FunctionalMemory
*mem
, Addr addr
, struct stat
*host
)
467 TypedBufferArg
<Tru64::F64_stat
> tgt(addr
);
469 tgt
->st_dev
= host
->st_dev
;
470 tgt
->st_ino
= host
->st_ino
;
471 tgt
->st_mode
= host
->st_mode
;
472 tgt
->st_nlink
= host
->st_nlink
;
473 tgt
->st_uid
= host
->st_uid
;
474 tgt
->st_gid
= host
->st_gid
;
475 tgt
->st_rdev
= host
->st_rdev
;
476 tgt
->st_size
= host
->st_size
;
477 tgt
->st_atimeX
= host
->st_atime
;
478 tgt
->st_mtimeX
= host
->st_mtime
;
479 tgt
->st_ctimeX
= host
->st_ctime
;
480 tgt
->st_blksize
= host
->st_blksize
;
481 tgt
->st_blocks
= host
->st_blocks
;
486 static const char *hostname
;
490 unameFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
493 TypedBufferArg
<Tru64::utsname
> name(xc
->getSyscallArg(0));
495 strcpy(name
->sysname
, "OSF1");
496 strcpy(name
->nodename
, hostname
);
497 strcpy(name
->release
, "V5.1");
498 strcpy(name
->version
, "732");
499 strcpy(name
->machine
, "alpha");
501 name
.copyOut(xc
->mem
);
508 getsysinfoFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
511 unsigned op
= xc
->getSyscallArg(0);
512 unsigned nbytes
= xc
->getSyscallArg(2);
516 case Tru64::GSI_MAX_CPU
: {
517 TypedBufferArg
<uint32_t> max_cpu(xc
->getSyscallArg(1));
518 *max_cpu
= process
->numCpus();
519 max_cpu
.copyOut(xc
->mem
);
523 case Tru64::GSI_CPUS_IN_BOX
: {
524 TypedBufferArg
<uint32_t> cpus_in_box(xc
->getSyscallArg(1));
525 *cpus_in_box
= process
->numCpus();
526 cpus_in_box
.copyOut(xc
->mem
);
530 case Tru64::GSI_PHYSMEM
: {
531 TypedBufferArg
<uint64_t> physmem(xc
->getSyscallArg(1));
532 *physmem
= 1024 * 1024; // physical memory in KB
533 physmem
.copyOut(xc
->mem
);
537 case Tru64::GSI_CPU_INFO
: {
538 TypedBufferArg
<Tru64::cpu_info
> infop(xc
->getSyscallArg(1));
540 infop
->current_cpu
= 0;
541 infop
->cpus_in_box
= process
->numCpus();
542 infop
->cpu_type
= 57;
543 infop
->ncpus
= process
->numCpus();
544 int cpumask
= (1 << process
->numCpus()) - 1;
545 infop
->cpus_present
= infop
->cpus_running
= cpumask
;
546 infop
->cpu_binding
= 0;
547 infop
->cpu_ex_binding
= 0;
550 infop
.copyOut(xc
->mem
);
554 case Tru64::GSI_PROC_TYPE
: {
555 TypedBufferArg
<uint64_t> proc_type(xc
->getSyscallArg(1));
557 proc_type
.copyOut(xc
->mem
);
561 case Tru64::GSI_PLATFORM_NAME
: {
562 BufferArg
bufArg(xc
->getSyscallArg(1), nbytes
);
563 strncpy((char *)bufArg
.bufferPtr(),
564 "COMPAQ Professional Workstation XP1000",
566 bufArg
.copyOut(xc
->mem
);
570 case Tru64::GSI_CLK_TCK
: {
571 TypedBufferArg
<uint64_t> clk_hz(xc
->getSyscallArg(1));
573 clk_hz
.copyOut(xc
->mem
);
578 cerr
<< "getsysinfo: unknown op " << op
<< endl
;
588 fcntlFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
591 int fd
= xc
->getSyscallArg(0);
593 if (fd
< 0 || process
->sim_fd(fd
) < 0)
596 int cmd
= xc
->getSyscallArg(1);
599 // if we really wanted to support this, we'd need to do it
600 // in the target fd space.
601 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd
);
604 case 1: // F_GETFD (get close-on-exec flag)
605 case 2: // F_SETFD (set close-on-exec flag)
608 case 3: // F_GETFL (get file flags)
609 case 4: // F_SETFL (set file flags)
610 // not sure if this is totally valid, but we'll pass it through
611 // to the underlying OS
612 warn("fcntl(%d, %d) passed through to host\n", fd
, cmd
);
613 return fcntl(process
->sim_fd(fd
), cmd
);
616 case 7: // F_GETLK (get lock)
617 case 8: // F_SETLK (set lock)
618 case 9: // F_SETLKW (set lock and wait)
619 // don't mess with file locking... just act like it's OK
620 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd
, cmd
);
624 warn("Unknown fcntl command %d\n", cmd
);
632 getdirentriesFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
635 int fd
= process
->sim_fd(xc
->getSyscallArg(0));
636 Addr tgt_buf
= xc
->getSyscallArg(1);
637 int tgt_nbytes
= xc
->getSyscallArg(2);
638 Addr tgt_basep
= xc
->getSyscallArg(3);
640 char * const host_buf
= new char[tgt_nbytes
];
642 // just pass basep through uninterpreted.
643 TypedBufferArg
<int64_t> basep(tgt_basep
);
644 basep
.copyIn(xc
->mem
);
645 ::off_t host_basep
= (off_t
)*basep
;
646 int host_result
= getdirentries(fd
, host_buf
, tgt_nbytes
, &host_basep
);
649 if (host_result
< 0) {
654 // no error: copy results back to target space
655 Addr tgt_buf_ptr
= tgt_buf
;
656 char *host_buf_ptr
= host_buf
;
657 char *host_buf_end
= host_buf
+ host_result
;
658 while (host_buf_ptr
< host_buf_end
) {
659 struct dirent
*host_dp
= (struct dirent
*)host_buf_ptr
;
660 int namelen
= strlen(host_dp
->d_name
);
662 // Actual size includes padded string rounded up for alignment.
663 // Subtract 256 for dummy char array in Tru64::dirent definition.
664 // Add 1 to namelen for terminating null char.
665 int tgt_bufsize
= sizeof(Tru64::dirent
) - 256 + RoundUp(namelen
+1, 8);
666 TypedBufferArg
<Tru64::dirent
> tgt_dp(tgt_buf_ptr
, tgt_bufsize
);
667 tgt_dp
->d_ino
= host_dp
->d_ino
;
668 tgt_dp
->d_reclen
= tgt_bufsize
;
669 tgt_dp
->d_namlen
= namelen
;
670 strcpy(tgt_dp
->d_name
, host_dp
->d_name
);
671 tgt_dp
.copyOut(xc
->mem
);
673 tgt_buf_ptr
+= tgt_bufsize
;
674 host_buf_ptr
+= host_dp
->d_reclen
;
680 basep
.copyOut(xc
->mem
);
682 return (tgt_buf_ptr
- tgt_buf
);
688 sigreturnFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
691 RegFile
*regs
= &xc
->regs
;
692 TypedBufferArg
<Tru64::sigcontext
> sc(xc
->getSyscallArg(0));
696 // Restore state from sigcontext structure.
697 // Note that we'll advance PC <- NPC before the end of the cycle,
698 // so we need to restore the desired PC into NPC.
699 // The current regs->pc will get clobbered.
700 regs
->npc
= sc
->sc_pc
;
702 for (int i
= 0; i
< 31; ++i
) {
703 regs
->intRegFile
[i
] = sc
->sc_regs
[i
];
704 regs
->floatRegFile
.q
[i
] = sc
->sc_fpregs
[i
];
707 regs
->miscRegs
.fpcr
= sc
->sc_fpcr
;
714 tableFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
717 int id
= xc
->getSyscallArg(0); // table ID
718 int index
= xc
->getSyscallArg(1); // index into table
719 // arg 2 is buffer pointer; type depends on table ID
720 int nel
= xc
->getSyscallArg(3); // number of elements
721 int lel
= xc
->getSyscallArg(4); // expected element size
724 case Tru64::TBL_SYSINFO
: {
725 if (index
!= 0 || nel
!= 1 || lel
!= sizeof(Tru64::tbl_sysinfo
))
727 TypedBufferArg
<Tru64::tbl_sysinfo
> elp(xc
->getSyscallArg(2));
729 const int clk_hz
= one_million
;
730 elp
->si_user
= curTick
/ (ticksPerSecond
/ clk_hz
);
736 elp
->si_phz
= clk_hz
;
737 elp
->si_boottime
= seconds_since_epoch
; // seconds since epoch?
738 elp
->si_max_procs
= process
->numCpus();
739 elp
.copyOut(xc
->mem
);
744 cerr
<< "table(): id " << id
<< " unknown." << endl
;
749 static SyscallDesc syscallDescs
[];
751 static const int Num_Syscall_Descs
;
752 static const int Max_Syscall_Desc
;
755 // Mach syscalls -- identified by negated syscall numbers
758 // Create a stack region for a thread.
761 stack_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
764 TypedBufferArg
<Tru64::vm_stack
> argp(xc
->getSyscallArg(0));
766 argp
.copyIn(xc
->mem
);
768 // if the user chose an address, just let them have it. Otherwise
769 // pick one for them.
770 if (argp
->address
== 0) {
771 argp
->address
= process
->next_thread_stack_base
;
772 int stack_size
= (argp
->rsize
+ argp
->ysize
+ argp
->gsize
);
773 process
->next_thread_stack_base
-= stack_size
;
774 argp
.copyOut(xc
->mem
);
781 const int NXM_LIB_VERSION
= 301003;
784 // This call sets up the interface between the user and kernel
785 // schedulers by creating a shared-memory region. The shared memory
786 // region has several structs, some global, some per-RAD, some per-VP.
790 nxm_task_initFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
793 TypedBufferArg
<Tru64::nxm_task_attr
> attrp(xc
->getSyscallArg(0));
794 TypedBufferArg
<Addr
> configptr_ptr(xc
->getSyscallArg(1));
796 attrp
.copyIn(xc
->mem
);
798 if (attrp
->nxm_version
!= NXM_LIB_VERSION
) {
799 cerr
<< "nxm_task_init: thread library version mismatch! "
800 << "got " << attrp
->nxm_version
801 << ", expected " << NXM_LIB_VERSION
<< endl
;
805 if (attrp
->flags
!= Tru64::NXM_TASK_INIT_VP
) {
806 cerr
<< "nxm_task_init: bad flag value " << attrp
->flags
807 << " (expected " << Tru64::NXM_TASK_INIT_VP
<< ")" << endl
;
811 const Addr base_addr
= 0x12000; // was 0x3f0000000LL;
812 Addr cur_addr
= base_addr
; // next addresses to use
813 // first comes the config_info struct
814 Addr config_addr
= cur_addr
;
815 cur_addr
+= sizeof(Tru64::nxm_config_info
);
816 // next comes the per-cpu state vector
817 Addr slot_state_addr
= cur_addr
;
818 int slot_state_size
= process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
819 cur_addr
+= slot_state_size
;
820 // now the per-RAD state struct (we only support one RAD)
821 cur_addr
= 0x14000; // bump up addr for alignment
822 Addr rad_state_addr
= cur_addr
;
824 (sizeof(Tru64::nxm_shared
)
825 + (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
826 cur_addr
+= rad_state_size
;
828 // now initialize a config_info struct and copy it out to user space
829 TypedBufferArg
<Tru64::nxm_config_info
> config(config_addr
);
831 config
->nxm_nslots_per_rad
= process
->numCpus();
832 config
->nxm_nrads
= 1; // only one RAD in our system!
833 config
->nxm_slot_state
= slot_state_addr
;
834 config
->nxm_rad
[0] = rad_state_addr
;
836 config
.copyOut(xc
->mem
);
838 // initialize the slot_state array and copy it out
839 TypedBufferArg
<Tru64::nxm_slot_state_t
> slot_state(slot_state_addr
,
841 for (int i
= 0; i
< process
->numCpus(); ++i
) {
842 // CPU 0 is bound to the calling process; all others are available
843 slot_state
[i
] = (i
== 0) ? Tru64::NXM_SLOT_BOUND
: Tru64::NXM_SLOT_AVAIL
;
846 slot_state
.copyOut(xc
->mem
);
848 // same for the per-RAD "shared" struct. Note that we need to
849 // allocate extra bytes for the per-VP array which is embedded at
851 TypedBufferArg
<Tru64::nxm_shared
> rad_state(rad_state_addr
,
854 rad_state
->nxm_callback
= attrp
->nxm_callback
;
855 rad_state
->nxm_version
= attrp
->nxm_version
;
856 rad_state
->nxm_uniq_offset
= attrp
->nxm_uniq_offset
;
857 for (int i
= 0; i
< process
->numCpus(); ++i
) {
858 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[i
];
859 ssp
->nxm_u
.sigmask
= 0;
861 ssp
->nxm_u
.flags
= 0;
862 ssp
->nxm_u
.cancel_state
= 0;
863 ssp
->nxm_u
.nxm_ssig
= 0;
865 ssp
->nxm_quantum
= attrp
->nxm_quantum
;
866 ssp
->nxm_set_quantum
= attrp
->nxm_quantum
;
867 ssp
->nxm_sysevent
= 0;
870 uint64_t uniq
= xc
->regs
.miscRegs
.uniq
;
871 ssp
->nxm_u
.pth_id
= uniq
+ attrp
->nxm_uniq_offset
;
872 ssp
->nxm_u
.nxm_active
= uniq
| 1;
875 ssp
->nxm_u
.pth_id
= 0;
876 ssp
->nxm_u
.nxm_active
= 0;
880 rad_state
.copyOut(xc
->mem
);
883 // copy pointer to shared config area out to user
885 *configptr_ptr
= config_addr
;
886 configptr_ptr
.copyOut(xc
->mem
);
893 init_exec_context(ExecContext
*ec
,
894 Tru64::nxm_thread_attr
*attrp
, uint64_t uniq_val
)
896 memset(&ec
->regs
, 0, sizeof(ec
->regs
));
898 ec
->regs
.intRegFile
[ArgumentReg0
] = attrp
->registers
.a0
;
899 ec
->regs
.intRegFile
[27/*t12*/] = attrp
->registers
.pc
;
900 ec
->regs
.intRegFile
[StackPointerReg
] = attrp
->registers
.sp
;
901 ec
->regs
.miscRegs
.uniq
= uniq_val
;
903 ec
->regs
.pc
= attrp
->registers
.pc
;
904 ec
->regs
.npc
= attrp
->registers
.pc
+ sizeof(MachInst
);
906 ec
->setStatus(ExecContext::Active
);
911 nxm_thread_createFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
914 TypedBufferArg
<Tru64::nxm_thread_attr
> attrp(xc
->getSyscallArg(0));
915 TypedBufferArg
<uint64_t> kidp(xc
->getSyscallArg(1));
916 int thread_index
= xc
->getSyscallArg(2);
918 // get attribute args
919 attrp
.copyIn(xc
->mem
);
921 if (attrp
->version
!= NXM_LIB_VERSION
) {
922 cerr
<< "nxm_thread_create: thread library version mismatch! "
923 << "got " << attrp
->version
924 << ", expected " << NXM_LIB_VERSION
<< endl
;
928 if (thread_index
< 0 | thread_index
> process
->numCpus()) {
929 cerr
<< "nxm_thread_create: bad thread index " << thread_index
934 // On a real machine, the per-RAD shared structure is in
935 // shared memory, so both the user and kernel can get at it.
936 // We don't have that luxury, so we just copy it in and then
939 (sizeof(Tru64::nxm_shared
) +
940 (process
->numCpus()-1) * sizeof(Tru64::nxm_sched_state
));
942 TypedBufferArg
<Tru64::nxm_shared
> rad_state(0x14000,
944 rad_state
.copyIn(xc
->mem
);
946 uint64_t uniq_val
= attrp
->pthid
- rad_state
->nxm_uniq_offset
;
948 if (attrp
->type
== Tru64::NXM_TYPE_MANAGER
) {
949 // DEC pthreads seems to always create one of these (in
950 // addition to N application threads), but we don't use it,
951 // so don't bother creating it.
953 // This is supposed to be a port number. Make something up.
955 kidp
.copyOut(xc
->mem
);
958 } else if (attrp
->type
== Tru64::NXM_TYPE_VP
) {
959 // A real "virtual processor" kernel thread. Need to fork
960 // this thread on another CPU.
961 Tru64::nxm_sched_state
*ssp
= &rad_state
->nxm_ss
[thread_index
];
963 if (ssp
->nxm_u
.nxm_active
!= 0)
964 return Tru64::KERN_NOT_RECEIVER
;
966 ssp
->nxm_u
.pth_id
= attrp
->pthid
;
967 ssp
->nxm_u
.nxm_active
= uniq_val
| 1;
969 rad_state
.copyOut(xc
->mem
);
971 Addr slot_state_addr
= 0x12000 + sizeof(Tru64::nxm_config_info
);
972 int slot_state_size
= process
->numCpus() * sizeof(Tru64::nxm_slot_state_t
);
974 TypedBufferArg
<Tru64::nxm_slot_state_t
> slot_state(slot_state_addr
,
977 slot_state
.copyIn(xc
->mem
);
979 if (slot_state
[thread_index
] != Tru64::NXM_SLOT_AVAIL
) {
980 cerr
<< "nxm_thread_createFunc: requested VP slot "
981 << thread_index
<< " not available!" << endl
;
985 slot_state
[thread_index
] = Tru64::NXM_SLOT_BOUND
;
987 slot_state
.copyOut(xc
->mem
);
989 // Find a free simulator execution context.
990 for (int i
= 0; i
< process
->numCpus(); ++i
) {
991 ExecContext
*xc
= process
->execContexts
[i
];
993 if (xc
->status() == ExecContext::Unallocated
) {
994 // inactive context... grab it
995 init_exec_context(xc
, attrp
, uniq_val
);
997 // This is supposed to be a port number, but we'll try
998 // and get away with just sticking the thread index
1000 *kidp
= thread_index
;
1001 kidp
.copyOut(xc
->mem
);
1007 // fell out of loop... no available inactive context
1008 cerr
<< "nxm_thread_create: no idle contexts available." << endl
;
1011 cerr
<< "nxm_thread_create: can't handle thread type "
1012 << attrp
->type
<< endl
;
1022 nxm_idleFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1030 nxm_thread_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1033 uint64_t tid
= xc
->getSyscallArg(0);
1034 uint64_t secs
= xc
->getSyscallArg(1);
1035 uint64_t flags
= xc
->getSyscallArg(2);
1036 uint64_t action
= xc
->getSyscallArg(3);
1037 uint64_t usecs
= xc
->getSyscallArg(4);
1039 cout
<< xc
->cpu
->name() << ": nxm_thread_block " << tid
<< " " << secs
1040 << " " << flags
<< " " << action
<< " " << usecs
<< endl
;
1048 nxm_blockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1051 Addr uaddr
= xc
->getSyscallArg(0);
1052 uint64_t val
= xc
->getSyscallArg(1);
1053 uint64_t secs
= xc
->getSyscallArg(2);
1054 uint64_t usecs
= xc
->getSyscallArg(3);
1055 uint64_t flags
= xc
->getSyscallArg(4);
1057 BaseCPU
*cpu
= xc
->cpu
;
1059 cout
<< cpu
->name() << ": nxm_block " << hex
<< uaddr
<< dec
<< " " << val
1060 << " " << secs
<< " " << usecs
1061 << " " << flags
<< endl
;
1069 nxm_unblockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1072 Addr uaddr
= xc
->getSyscallArg(0);
1074 cout
<< xc
->cpu
->name() << ": nxm_unblock "
1075 << hex
<< uaddr
<< dec
<< endl
;
1083 swtch_priFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1086 // Attempts to switch to another runnable thread (if there is
1087 // one). Returns false if there are no other threads to run
1088 // (i.e., the thread can reasonably spin-wait) or true if there
1089 // are other threads.
1091 // Since we assume at most one "kernel" thread per CPU, it's
1092 // always safe to return false here.
1097 // just activate one by default
1099 activate_waiting_context(Addr uaddr
, Process
*process
,
1100 bool activate_all
= false)
1102 int num_activated
= 0;
1104 list
<Process::WaitRec
>::iterator i
= process
->waitList
.begin();
1105 list
<Process::WaitRec
>::iterator end
= process
->waitList
.end();
1107 while (i
!= end
&& (num_activated
== 0 || activate_all
)) {
1108 if (i
->waitChan
== uaddr
) {
1109 // found waiting process: make it active
1110 ExecContext
*newCtx
= i
->waitingContext
;
1111 assert(newCtx
->status() == ExecContext::Suspended
);
1112 newCtx
->setStatus(ExecContext::Active
);
1114 // get rid of this record
1115 i
= process
->waitList
.erase(i
);
1123 return num_activated
;
1128 m5_lock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1130 TypedBufferArg
<uint64_t> lockp(uaddr
);
1132 lockp
.copyIn(xc
->mem
);
1135 // lock is free: grab it
1137 lockp
.copyOut(xc
->mem
);
1139 // lock is busy: disable until free
1140 process
->waitList
.push_back(Process::WaitRec(uaddr
, xc
));
1141 xc
->setStatus(ExecContext::Suspended
);
1146 m5_unlock_mutex(Addr uaddr
, Process
*process
, ExecContext
*xc
)
1148 TypedBufferArg
<uint64_t> lockp(uaddr
);
1150 lockp
.copyIn(xc
->mem
);
1151 assert(*lockp
!= 0);
1153 // Check for a process waiting on the lock.
1154 int num_waiting
= activate_waiting_context(uaddr
, process
);
1156 // clear lock field if no waiting context is taking over the lock
1157 if (num_waiting
== 0) {
1159 lockp
.copyOut(xc
->mem
);
1166 m5_mutex_lockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1169 Addr uaddr
= xc
->getSyscallArg(0);
1171 m5_lock_mutex(uaddr
, process
, xc
);
1173 // Return 0 since we will always return to the user with the lock
1174 // acquired. We will just keep the context inactive until that is
1182 m5_mutex_trylockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1185 Addr uaddr
= xc
->getSyscallArg(0);
1186 TypedBufferArg
<uint64_t> lockp(uaddr
);
1188 lockp
.copyIn(xc
->mem
);
1191 // lock is free: grab it
1193 lockp
.copyOut(xc
->mem
);
1203 m5_mutex_unlockFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1206 Addr uaddr
= xc
->getSyscallArg(0);
1208 m5_unlock_mutex(uaddr
, process
, xc
);
1216 m5_cond_signalFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1219 Addr cond_addr
= xc
->getSyscallArg(0);
1221 // Wqake up one process waiting on the condition variable.
1222 activate_waiting_context(cond_addr
, process
);
1230 m5_cond_broadcastFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1233 Addr cond_addr
= xc
->getSyscallArg(0);
1235 // Wake up all processes waiting on the condition variable.
1236 activate_waiting_context(cond_addr
, process
, true);
1244 m5_cond_waitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1247 Addr cond_addr
= xc
->getSyscallArg(0);
1248 Addr lock_addr
= xc
->getSyscallArg(1);
1249 TypedBufferArg
<uint64_t> condp(cond_addr
);
1250 TypedBufferArg
<uint64_t> lockp(lock_addr
);
1252 // user is supposed to acquire lock before entering
1253 lockp
.copyIn(xc
->mem
);
1254 assert(*lockp
!= 0);
1256 m5_unlock_mutex(lock_addr
, process
, xc
);
1258 process
->waitList
.push_back(Process::WaitRec(cond_addr
, xc
));
1259 xc
->setStatus(ExecContext::Suspended
);
1267 m5_thread_exitFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1270 assert(xc
->status() == ExecContext::Active
);
1271 xc
->setStatus(ExecContext::Unallocated
);
1277 static SyscallDesc machSyscallDescs
[];
1279 static const int Num_Mach_Syscall_Descs
;
1280 static const int Max_Mach_Syscall_Desc
;
1282 // Since negated values are used to identify Mach syscalls, the
1283 // minimum (signed) valid syscall number is the negated max Mach
1285 static const int Min_Syscall_Desc
;
1288 // helper function for invoking syscalls
1292 doSyscall(int callnum
, Process
*process
, ExecContext
*xc
)
1294 if (callnum
< Min_Syscall_Desc
|| callnum
> Max_Syscall_Desc
) {
1295 cerr
<< "Syscall " << callnum
<< " out of range" << endl
;
1300 (callnum
< 0) ? &machSyscallDescs
[-callnum
] : &syscallDescs
[callnum
];
1302 desc
->doSyscall(callnum
, process
, xc
);
1306 // Indirect syscall invocation (call #0)
1310 indirectSyscallFunc(SyscallDesc
*desc
, int callnum
, Process
*process
,
1313 int new_callnum
= xc
->getSyscallArg(0);
1315 for (int i
= 0; i
< 5; ++i
)
1316 xc
->setSyscallArg(i
, xc
->getSyscallArg(i
+1));
1318 doSyscall(new_callnum
, process
, xc
);
1327 // open(2) flags translation table
1328 OpenFlagTransTable
Tru64::openFlagTable
[] = {
1329 /* target flag */ /* host flag */
1331 { Tru64::TGT_O_RDONLY
, _O_RDONLY
},
1332 { Tru64::TGT_O_WRONLY
, _O_WRONLY
},
1333 { Tru64::TGT_O_RDWR
, _O_RDWR
},
1334 { Tru64::TGT_O_APPEND
, _O_APPEND
},
1335 { Tru64::TGT_O_CREAT
, _O_CREAT
},
1336 { Tru64::TGT_O_TRUNC
, _O_TRUNC
},
1337 { Tru64::TGT_O_EXCL
, _O_EXCL
},
1339 { Tru64::TGT_O_NONBLOCK
, _O_NONBLOCK
},
1342 { Tru64::TGT_O_NOCTTY
, _O_NOCTTY
},
1345 { Tru64::TGT_O_SYNC
, _O_SYNC
},
1347 #else /* !_MSC_VER */
1348 { Tru64::TGT_O_RDONLY
, O_RDONLY
},
1349 { Tru64::TGT_O_WRONLY
, O_WRONLY
},
1350 { Tru64::TGT_O_RDWR
, O_RDWR
},
1351 { Tru64::TGT_O_APPEND
, O_APPEND
},
1352 { Tru64::TGT_O_CREAT
, O_CREAT
},
1353 { Tru64::TGT_O_TRUNC
, O_TRUNC
},
1354 { Tru64::TGT_O_EXCL
, O_EXCL
},
1355 { Tru64::TGT_O_NONBLOCK
, O_NONBLOCK
},
1356 { Tru64::TGT_O_NOCTTY
, O_NOCTTY
},
1358 { Tru64::TGT_O_SYNC
, O_SYNC
},
1360 #endif /* _MSC_VER */
1363 const int Tru64::NUM_OPEN_FLAGS
= (sizeof(Tru64::openFlagTable
)/sizeof(Tru64::openFlagTable
[0]));
1365 const char *Tru64::hostname
= "m5.eecs.umich.edu";
1367 SyscallDesc
Tru64::syscallDescs
[] = {
1368 /* 0 */ SyscallDesc("syscall (#0)", indirectSyscallFunc
,
1369 SyscallDesc::SuppressReturnValue
),
1370 /* 1 */ SyscallDesc("exit", exitFunc
),
1371 /* 2 */ SyscallDesc("fork", unimplementedFunc
),
1372 /* 3 */ SyscallDesc("read", readFunc
),
1373 /* 4 */ SyscallDesc("write", writeFunc
),
1374 /* 5 */ SyscallDesc("old_open", unimplementedFunc
),
1375 /* 6 */ SyscallDesc("close", closeFunc
),
1376 /* 7 */ SyscallDesc("wait4", unimplementedFunc
),
1377 /* 8 */ SyscallDesc("old_creat", unimplementedFunc
),
1378 /* 9 */ SyscallDesc("link", unimplementedFunc
),
1379 /* 10 */ SyscallDesc("unlink", unimplementedFunc
),
1380 /* 11 */ SyscallDesc("execv", unimplementedFunc
),
1381 /* 12 */ SyscallDesc("chdir", unimplementedFunc
),
1382 /* 13 */ SyscallDesc("fchdir", unimplementedFunc
),
1383 /* 14 */ SyscallDesc("mknod", unimplementedFunc
),
1384 /* 15 */ SyscallDesc("chmod", unimplementedFunc
),
1385 /* 16 */ SyscallDesc("chown", unimplementedFunc
),
1386 /* 17 */ SyscallDesc("obreak", obreakFunc
),
1387 /* 18 */ SyscallDesc("pre_F64_getfsstat", unimplementedFunc
),
1388 /* 19 */ SyscallDesc("lseek", lseekFunc
),
1389 /* 20 */ SyscallDesc("getpid", getpidFunc
),
1390 /* 21 */ SyscallDesc("mount", unimplementedFunc
),
1391 /* 22 */ SyscallDesc("unmount", unimplementedFunc
),
1392 /* 23 */ SyscallDesc("setuid", setuidFunc
),
1393 /* 24 */ SyscallDesc("getuid", getuidFunc
),
1394 /* 25 */ SyscallDesc("exec_with_loader", unimplementedFunc
),
1395 /* 26 */ SyscallDesc("ptrace", unimplementedFunc
),
1396 /* 27 */ SyscallDesc("recvmsg", unimplementedFunc
),
1397 /* 28 */ SyscallDesc("sendmsg", unimplementedFunc
),
1398 /* 29 */ SyscallDesc("recvfrom", unimplementedFunc
),
1399 /* 30 */ SyscallDesc("accept", unimplementedFunc
),
1400 /* 31 */ SyscallDesc("getpeername", unimplementedFunc
),
1401 /* 32 */ SyscallDesc("getsockname", unimplementedFunc
),
1402 /* 33 */ SyscallDesc("access", unimplementedFunc
),
1403 /* 34 */ SyscallDesc("chflags", unimplementedFunc
),
1404 /* 35 */ SyscallDesc("fchflags", unimplementedFunc
),
1405 /* 36 */ SyscallDesc("sync", unimplementedFunc
),
1406 /* 37 */ SyscallDesc("kill", unimplementedFunc
),
1407 /* 38 */ SyscallDesc("old_stat", unimplementedFunc
),
1408 /* 39 */ SyscallDesc("setpgid", unimplementedFunc
),
1409 /* 40 */ SyscallDesc("old_lstat", unimplementedFunc
),
1410 /* 41 */ SyscallDesc("dup", unimplementedFunc
),
1411 /* 42 */ SyscallDesc("pipe", unimplementedFunc
),
1412 /* 43 */ SyscallDesc("set_program_attributes", unimplementedFunc
),
1413 /* 44 */ SyscallDesc("profil", unimplementedFunc
),
1414 /* 45 */ SyscallDesc("open", openFunc
<Tru64
>),
1415 /* 46 */ SyscallDesc("obsolete osigaction", unimplementedFunc
),
1416 /* 47 */ SyscallDesc("getgid", getgidFunc
),
1417 /* 48 */ SyscallDesc("sigprocmask", ignoreFunc
),
1418 /* 49 */ SyscallDesc("getlogin", unimplementedFunc
),
1419 /* 50 */ SyscallDesc("setlogin", unimplementedFunc
),
1420 /* 51 */ SyscallDesc("acct", unimplementedFunc
),
1421 /* 52 */ SyscallDesc("sigpending", unimplementedFunc
),
1422 /* 53 */ SyscallDesc("classcntl", unimplementedFunc
),
1423 /* 54 */ SyscallDesc("ioctl", ioctlFunc
<Tru64
>),
1424 /* 55 */ SyscallDesc("reboot", unimplementedFunc
),
1425 /* 56 */ SyscallDesc("revoke", unimplementedFunc
),
1426 /* 57 */ SyscallDesc("symlink", unimplementedFunc
),
1427 /* 58 */ SyscallDesc("readlink", unimplementedFunc
),
1428 /* 59 */ SyscallDesc("execve", unimplementedFunc
),
1429 /* 60 */ SyscallDesc("umask", unimplementedFunc
),
1430 /* 61 */ SyscallDesc("chroot", unimplementedFunc
),
1431 /* 62 */ SyscallDesc("old_fstat", unimplementedFunc
),
1432 /* 63 */ SyscallDesc("getpgrp", unimplementedFunc
),
1433 /* 64 */ SyscallDesc("getpagesize", getpagesizeFunc
),
1434 /* 65 */ SyscallDesc("mremap", unimplementedFunc
),
1435 /* 66 */ SyscallDesc("vfork", unimplementedFunc
),
1436 /* 67 */ SyscallDesc("pre_F64_stat", unimplementedFunc
),
1437 /* 68 */ SyscallDesc("pre_F64_lstat", unimplementedFunc
),
1438 /* 69 */ SyscallDesc("sbrk", unimplementedFunc
),
1439 /* 70 */ SyscallDesc("sstk", unimplementedFunc
),
1440 /* 71 */ SyscallDesc("mmap", mmapFunc
<Tru64
>),
1441 /* 72 */ SyscallDesc("ovadvise", unimplementedFunc
),
1442 /* 73 */ SyscallDesc("munmap", munmapFunc
),
1443 /* 74 */ SyscallDesc("mprotect", ignoreFunc
),
1444 /* 75 */ SyscallDesc("madvise", unimplementedFunc
),
1445 /* 76 */ SyscallDesc("old_vhangup", unimplementedFunc
),
1446 /* 77 */ SyscallDesc("kmodcall", unimplementedFunc
),
1447 /* 78 */ SyscallDesc("mincore", unimplementedFunc
),
1448 /* 79 */ SyscallDesc("getgroups", unimplementedFunc
),
1449 /* 80 */ SyscallDesc("setgroups", unimplementedFunc
),
1450 /* 81 */ SyscallDesc("old_getpgrp", unimplementedFunc
),
1451 /* 82 */ SyscallDesc("setpgrp", unimplementedFunc
),
1452 /* 83 */ SyscallDesc("setitimer", unimplementedFunc
),
1453 /* 84 */ SyscallDesc("old_wait", unimplementedFunc
),
1454 /* 85 */ SyscallDesc("table", tableFunc
),
1455 /* 86 */ SyscallDesc("getitimer", unimplementedFunc
),
1456 /* 87 */ SyscallDesc("gethostname", gethostnameFunc
),
1457 /* 88 */ SyscallDesc("sethostname", unimplementedFunc
),
1458 /* 89 */ SyscallDesc("getdtablesize", unimplementedFunc
),
1459 /* 90 */ SyscallDesc("dup2", unimplementedFunc
),
1460 /* 91 */ SyscallDesc("pre_F64_fstat", unimplementedFunc
),
1461 /* 92 */ SyscallDesc("fcntl", fcntlFunc
),
1462 /* 93 */ SyscallDesc("select", unimplementedFunc
),
1463 /* 94 */ SyscallDesc("poll", unimplementedFunc
),
1464 /* 95 */ SyscallDesc("fsync", unimplementedFunc
),
1465 /* 96 */ SyscallDesc("setpriority", unimplementedFunc
),
1466 /* 97 */ SyscallDesc("socket", unimplementedFunc
),
1467 /* 98 */ SyscallDesc("connect", unimplementedFunc
),
1468 /* 99 */ SyscallDesc("old_accept", unimplementedFunc
),
1469 /* 100 */ SyscallDesc("getpriority", unimplementedFunc
),
1470 /* 101 */ SyscallDesc("old_send", unimplementedFunc
),
1471 /* 102 */ SyscallDesc("old_recv", unimplementedFunc
),
1472 /* 103 */ SyscallDesc("sigreturn", sigreturnFunc
,
1473 SyscallDesc::SuppressReturnValue
),
1474 /* 104 */ SyscallDesc("bind", unimplementedFunc
),
1475 /* 105 */ SyscallDesc("setsockopt", unimplementedFunc
),
1476 /* 106 */ SyscallDesc("listen", unimplementedFunc
),
1477 /* 107 */ SyscallDesc("plock", unimplementedFunc
),
1478 /* 108 */ SyscallDesc("old_sigvec", unimplementedFunc
),
1479 /* 109 */ SyscallDesc("old_sigblock", unimplementedFunc
),
1480 /* 110 */ SyscallDesc("old_sigsetmask", unimplementedFunc
),
1481 /* 111 */ SyscallDesc("sigsuspend", unimplementedFunc
),
1482 /* 112 */ SyscallDesc("sigstack", ignoreFunc
),
1483 /* 113 */ SyscallDesc("old_recvmsg", unimplementedFunc
),
1484 /* 114 */ SyscallDesc("old_sendmsg", unimplementedFunc
),
1485 /* 115 */ SyscallDesc("obsolete vtrace", unimplementedFunc
),
1486 /* 116 */ SyscallDesc("gettimeofday", gettimeofdayFunc
<Tru64
>),
1487 /* 117 */ SyscallDesc("getrusage", getrusageFunc
<Tru64
>),
1488 /* 118 */ SyscallDesc("getsockopt", unimplementedFunc
),
1489 /* 119 */ SyscallDesc("numa_syscalls", unimplementedFunc
),
1490 /* 120 */ SyscallDesc("readv", unimplementedFunc
),
1491 /* 121 */ SyscallDesc("writev", unimplementedFunc
),
1492 /* 122 */ SyscallDesc("settimeofday", unimplementedFunc
),
1493 /* 123 */ SyscallDesc("fchown", unimplementedFunc
),
1494 /* 124 */ SyscallDesc("fchmod", unimplementedFunc
),
1495 /* 125 */ SyscallDesc("old_recvfrom", unimplementedFunc
),
1496 /* 126 */ SyscallDesc("setreuid", unimplementedFunc
),
1497 /* 127 */ SyscallDesc("setregid", unimplementedFunc
),
1498 /* 128 */ SyscallDesc("rename", unimplementedFunc
),
1499 /* 129 */ SyscallDesc("truncate", unimplementedFunc
),
1500 /* 130 */ SyscallDesc("ftruncate", unimplementedFunc
),
1501 /* 131 */ SyscallDesc("flock", unimplementedFunc
),
1502 /* 132 */ SyscallDesc("setgid", unimplementedFunc
),
1503 /* 133 */ SyscallDesc("sendto", unimplementedFunc
),
1504 /* 134 */ SyscallDesc("shutdown", unimplementedFunc
),
1505 /* 135 */ SyscallDesc("socketpair", unimplementedFunc
),
1506 /* 136 */ SyscallDesc("mkdir", unimplementedFunc
),
1507 /* 137 */ SyscallDesc("rmdir", unimplementedFunc
),
1508 /* 138 */ SyscallDesc("utimes", unimplementedFunc
),
1509 /* 139 */ SyscallDesc("obsolete 4.2 sigreturn", unimplementedFunc
),
1510 /* 140 */ SyscallDesc("adjtime", unimplementedFunc
),
1511 /* 141 */ SyscallDesc("old_getpeername", unimplementedFunc
),
1512 /* 142 */ SyscallDesc("gethostid", unimplementedFunc
),
1513 /* 143 */ SyscallDesc("sethostid", unimplementedFunc
),
1514 /* 144 */ SyscallDesc("getrlimit", getrlimitFunc
<Tru64
>),
1515 /* 145 */ SyscallDesc("setrlimit", unimplementedFunc
),
1516 /* 146 */ SyscallDesc("old_killpg", unimplementedFunc
),
1517 /* 147 */ SyscallDesc("setsid", unimplementedFunc
),
1518 /* 148 */ SyscallDesc("quotactl", unimplementedFunc
),
1519 /* 149 */ SyscallDesc("oldquota", unimplementedFunc
),
1520 /* 150 */ SyscallDesc("old_getsockname", unimplementedFunc
),
1521 /* 151 */ SyscallDesc("pread", unimplementedFunc
),
1522 /* 152 */ SyscallDesc("pwrite", unimplementedFunc
),
1523 /* 153 */ SyscallDesc("pid_block", unimplementedFunc
),
1524 /* 154 */ SyscallDesc("pid_unblock", unimplementedFunc
),
1525 /* 155 */ SyscallDesc("signal_urti", unimplementedFunc
),
1526 /* 156 */ SyscallDesc("sigaction", ignoreFunc
),
1527 /* 157 */ SyscallDesc("sigwaitprim", unimplementedFunc
),
1528 /* 158 */ SyscallDesc("nfssvc", unimplementedFunc
),
1529 /* 159 */ SyscallDesc("getdirentries", getdirentriesFunc
),
1530 /* 160 */ SyscallDesc("pre_F64_statfs", unimplementedFunc
),
1531 /* 161 */ SyscallDesc("pre_F64_fstatfs", unimplementedFunc
),
1532 /* 162 */ SyscallDesc("unknown #162", unimplementedFunc
),
1533 /* 163 */ SyscallDesc("async_daemon", unimplementedFunc
),
1534 /* 164 */ SyscallDesc("getfh", unimplementedFunc
),
1535 /* 165 */ SyscallDesc("getdomainname", unimplementedFunc
),
1536 /* 166 */ SyscallDesc("setdomainname", unimplementedFunc
),
1537 /* 167 */ SyscallDesc("unknown #167", unimplementedFunc
),
1538 /* 168 */ SyscallDesc("unknown #168", unimplementedFunc
),
1539 /* 169 */ SyscallDesc("exportfs", unimplementedFunc
),
1540 /* 170 */ SyscallDesc("unknown #170", unimplementedFunc
),
1541 /* 171 */ SyscallDesc("unknown #171", unimplementedFunc
),
1542 /* 172 */ SyscallDesc("unknown #172", unimplementedFunc
),
1543 /* 173 */ SyscallDesc("unknown #173", unimplementedFunc
),
1544 /* 174 */ SyscallDesc("unknown #174", unimplementedFunc
),
1545 /* 175 */ SyscallDesc("unknown #175", unimplementedFunc
),
1546 /* 176 */ SyscallDesc("unknown #176", unimplementedFunc
),
1547 /* 177 */ SyscallDesc("unknown #177", unimplementedFunc
),
1548 /* 178 */ SyscallDesc("unknown #178", unimplementedFunc
),
1549 /* 179 */ SyscallDesc("unknown #179", unimplementedFunc
),
1550 /* 180 */ SyscallDesc("unknown #180", unimplementedFunc
),
1551 /* 181 */ SyscallDesc("alt_plock", unimplementedFunc
),
1552 /* 182 */ SyscallDesc("unknown #182", unimplementedFunc
),
1553 /* 183 */ SyscallDesc("unknown #183", unimplementedFunc
),
1554 /* 184 */ SyscallDesc("getmnt", unimplementedFunc
),
1555 /* 185 */ SyscallDesc("unknown #185", unimplementedFunc
),
1556 /* 186 */ SyscallDesc("unknown #186", unimplementedFunc
),
1557 /* 187 */ SyscallDesc("alt_sigpending", unimplementedFunc
),
1558 /* 188 */ SyscallDesc("alt_setsid", unimplementedFunc
),
1559 /* 189 */ SyscallDesc("unknown #189", unimplementedFunc
),
1560 /* 190 */ SyscallDesc("unknown #190", unimplementedFunc
),
1561 /* 191 */ SyscallDesc("unknown #191", unimplementedFunc
),
1562 /* 192 */ SyscallDesc("unknown #192", unimplementedFunc
),
1563 /* 193 */ SyscallDesc("unknown #193", unimplementedFunc
),
1564 /* 194 */ SyscallDesc("unknown #194", unimplementedFunc
),
1565 /* 195 */ SyscallDesc("unknown #195", unimplementedFunc
),
1566 /* 196 */ SyscallDesc("unknown #196", unimplementedFunc
),
1567 /* 197 */ SyscallDesc("unknown #197", unimplementedFunc
),
1568 /* 198 */ SyscallDesc("unknown #198", unimplementedFunc
),
1569 /* 199 */ SyscallDesc("swapon", unimplementedFunc
),
1570 /* 200 */ SyscallDesc("msgctl", unimplementedFunc
),
1571 /* 201 */ SyscallDesc("msgget", unimplementedFunc
),
1572 /* 202 */ SyscallDesc("msgrcv", unimplementedFunc
),
1573 /* 203 */ SyscallDesc("msgsnd", unimplementedFunc
),
1574 /* 204 */ SyscallDesc("semctl", unimplementedFunc
),
1575 /* 205 */ SyscallDesc("semget", unimplementedFunc
),
1576 /* 206 */ SyscallDesc("semop", unimplementedFunc
),
1577 /* 207 */ SyscallDesc("uname", unameFunc
),
1578 /* 208 */ SyscallDesc("lchown", unimplementedFunc
),
1579 /* 209 */ SyscallDesc("shmat", unimplementedFunc
),
1580 /* 210 */ SyscallDesc("shmctl", unimplementedFunc
),
1581 /* 211 */ SyscallDesc("shmdt", unimplementedFunc
),
1582 /* 212 */ SyscallDesc("shmget", unimplementedFunc
),
1583 /* 213 */ SyscallDesc("mvalid", unimplementedFunc
),
1584 /* 214 */ SyscallDesc("getaddressconf", unimplementedFunc
),
1585 /* 215 */ SyscallDesc("msleep", unimplementedFunc
),
1586 /* 216 */ SyscallDesc("mwakeup", unimplementedFunc
),
1587 /* 217 */ SyscallDesc("msync", unimplementedFunc
),
1588 /* 218 */ SyscallDesc("signal", unimplementedFunc
),
1589 /* 219 */ SyscallDesc("utc_gettime", unimplementedFunc
),
1590 /* 220 */ SyscallDesc("utc_adjtime", unimplementedFunc
),
1591 /* 221 */ SyscallDesc("unknown #221", unimplementedFunc
),
1592 /* 222 */ SyscallDesc("security", unimplementedFunc
),
1593 /* 223 */ SyscallDesc("kloadcall", unimplementedFunc
),
1594 /* 224 */ SyscallDesc("stat", statFunc
<Tru64
>),
1595 /* 225 */ SyscallDesc("lstat", lstatFunc
<Tru64
>),
1596 /* 226 */ SyscallDesc("fstat", fstatFunc
<Tru64
>),
1597 /* 227 */ SyscallDesc("statfs", unimplementedFunc
),
1598 /* 228 */ SyscallDesc("fstatfs", unimplementedFunc
),
1599 /* 229 */ SyscallDesc("getfsstat", unimplementedFunc
),
1600 /* 230 */ SyscallDesc("gettimeofday64", unimplementedFunc
),
1601 /* 231 */ SyscallDesc("settimeofday64", unimplementedFunc
),
1602 /* 232 */ SyscallDesc("unknown #232", unimplementedFunc
),
1603 /* 233 */ SyscallDesc("getpgid", unimplementedFunc
),
1604 /* 234 */ SyscallDesc("getsid", unimplementedFunc
),
1605 /* 235 */ SyscallDesc("sigaltstack", ignoreFunc
),
1606 /* 236 */ SyscallDesc("waitid", unimplementedFunc
),
1607 /* 237 */ SyscallDesc("priocntlset", unimplementedFunc
),
1608 /* 238 */ SyscallDesc("sigsendset", unimplementedFunc
),
1609 /* 239 */ SyscallDesc("set_speculative", unimplementedFunc
),
1610 /* 240 */ SyscallDesc("msfs_syscall", unimplementedFunc
),
1611 /* 241 */ SyscallDesc("sysinfo", unimplementedFunc
),
1612 /* 242 */ SyscallDesc("uadmin", unimplementedFunc
),
1613 /* 243 */ SyscallDesc("fuser", unimplementedFunc
),
1614 /* 244 */ SyscallDesc("proplist_syscall", unimplementedFunc
),
1615 /* 245 */ SyscallDesc("ntp_adjtime", unimplementedFunc
),
1616 /* 246 */ SyscallDesc("ntp_gettime", unimplementedFunc
),
1617 /* 247 */ SyscallDesc("pathconf", unimplementedFunc
),
1618 /* 248 */ SyscallDesc("fpathconf", unimplementedFunc
),
1619 /* 249 */ SyscallDesc("sync2", unimplementedFunc
),
1620 /* 250 */ SyscallDesc("uswitch", unimplementedFunc
),
1621 /* 251 */ SyscallDesc("usleep_thread", unimplementedFunc
),
1622 /* 252 */ SyscallDesc("audcntl", unimplementedFunc
),
1623 /* 253 */ SyscallDesc("audgen", unimplementedFunc
),
1624 /* 254 */ SyscallDesc("sysfs", unimplementedFunc
),
1625 /* 255 */ SyscallDesc("subsys_info", unimplementedFunc
),
1626 /* 256 */ SyscallDesc("getsysinfo", getsysinfoFunc
),
1627 /* 257 */ SyscallDesc("setsysinfo", unimplementedFunc
),
1628 /* 258 */ SyscallDesc("afs_syscall", unimplementedFunc
),
1629 /* 259 */ SyscallDesc("swapctl", unimplementedFunc
),
1630 /* 260 */ SyscallDesc("memcntl", unimplementedFunc
),
1631 /* 261 */ SyscallDesc("fdatasync", unimplementedFunc
),
1632 /* 262 */ SyscallDesc("oflock", unimplementedFunc
),
1633 /* 263 */ SyscallDesc("F64_readv", unimplementedFunc
),
1634 /* 264 */ SyscallDesc("F64_writev", unimplementedFunc
),
1635 /* 265 */ SyscallDesc("cdslxlate", unimplementedFunc
),
1636 /* 266 */ SyscallDesc("sendfile", unimplementedFunc
),
1639 const int Tru64::Num_Syscall_Descs
=
1640 sizeof(Tru64::syscallDescs
) / sizeof(SyscallDesc
);
1642 const int Tru64::Max_Syscall_Desc
= Tru64::Num_Syscall_Descs
- 1;
1644 SyscallDesc
Tru64::machSyscallDescs
[] = {
1645 /* 0 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1646 /* 1 */ SyscallDesc("m5_mutex_lock", m5_mutex_lockFunc
),
1647 /* 2 */ SyscallDesc("m5_mutex_trylock", m5_mutex_trylockFunc
),
1648 /* 3 */ SyscallDesc("m5_mutex_unlock", m5_mutex_unlockFunc
),
1649 /* 4 */ SyscallDesc("m5_cond_signal", m5_cond_signalFunc
),
1650 /* 5 */ SyscallDesc("m5_cond_broadcast", m5_cond_broadcastFunc
),
1651 /* 6 */ SyscallDesc("m5_cond_wait", m5_cond_waitFunc
),
1652 /* 7 */ SyscallDesc("m5_thread_exit", m5_thread_exitFunc
),
1653 /* 8 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1654 /* 9 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1655 /* 10 */ SyscallDesc("task_self", unimplementedFunc
),
1656 /* 11 */ SyscallDesc("thread_reply", unimplementedFunc
),
1657 /* 12 */ SyscallDesc("task_notify", unimplementedFunc
),
1658 /* 13 */ SyscallDesc("thread_self", unimplementedFunc
),
1659 /* 14 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1660 /* 15 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1661 /* 16 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1662 /* 17 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1663 /* 18 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1664 /* 19 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1665 /* 20 */ SyscallDesc("msg_send_trap", unimplementedFunc
),
1666 /* 21 */ SyscallDesc("msg_receive_trap", unimplementedFunc
),
1667 /* 22 */ SyscallDesc("msg_rpc_trap", unimplementedFunc
),
1668 /* 23 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1669 /* 24 */ SyscallDesc("nxm_block", nxm_blockFunc
),
1670 /* 25 */ SyscallDesc("nxm_unblock", nxm_unblockFunc
),
1671 /* 26 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1672 /* 27 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1673 /* 28 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1674 /* 29 */ SyscallDesc("nxm_thread_destroy", unimplementedFunc
),
1675 /* 30 */ SyscallDesc("lw_wire", unimplementedFunc
),
1676 /* 31 */ SyscallDesc("lw_unwire", unimplementedFunc
),
1677 /* 32 */ SyscallDesc("nxm_thread_create", nxm_thread_createFunc
),
1678 /* 33 */ SyscallDesc("nxm_task_init", nxm_task_initFunc
),
1679 /* 34 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1680 /* 35 */ SyscallDesc("nxm_idle", nxm_idleFunc
),
1681 /* 36 */ SyscallDesc("nxm_wakeup_idle", unimplementedFunc
),
1682 /* 37 */ SyscallDesc("nxm_set_pthid", unimplementedFunc
),
1683 /* 38 */ SyscallDesc("nxm_thread_kill", unimplementedFunc
),
1684 /* 39 */ SyscallDesc("nxm_thread_block", nxm_thread_blockFunc
),
1685 /* 40 */ SyscallDesc("nxm_thread_wakeup", unimplementedFunc
),
1686 /* 41 */ SyscallDesc("init_process", unimplementedFunc
),
1687 /* 42 */ SyscallDesc("nxm_get_binding", unimplementedFunc
),
1688 /* 43 */ SyscallDesc("map_fd", unimplementedFunc
),
1689 /* 44 */ SyscallDesc("nxm_resched", unimplementedFunc
),
1690 /* 45 */ SyscallDesc("nxm_set_cancel", unimplementedFunc
),
1691 /* 46 */ SyscallDesc("nxm_set_binding", unimplementedFunc
),
1692 /* 47 */ SyscallDesc("stack_create", stack_createFunc
),
1693 /* 48 */ SyscallDesc("nxm_get_state", unimplementedFunc
),
1694 /* 49 */ SyscallDesc("nxm_thread_suspend", unimplementedFunc
),
1695 /* 50 */ SyscallDesc("nxm_thread_resume", unimplementedFunc
),
1696 /* 51 */ SyscallDesc("nxm_signal_check", unimplementedFunc
),
1697 /* 52 */ SyscallDesc("htg_unix_syscall", unimplementedFunc
),
1698 /* 53 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1699 /* 54 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1700 /* 55 */ SyscallDesc("host_self", unimplementedFunc
),
1701 /* 56 */ SyscallDesc("host_priv_self", unimplementedFunc
),
1702 /* 57 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1703 /* 58 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1704 /* 59 */ SyscallDesc("swtch_pri", swtch_priFunc
),
1705 /* 60 */ SyscallDesc("swtch", unimplementedFunc
),
1706 /* 61 */ SyscallDesc("thread_switch", unimplementedFunc
),
1707 /* 62 */ SyscallDesc("semop_fast", unimplementedFunc
),
1708 /* 63 */ SyscallDesc("nxm_pshared_init", unimplementedFunc
),
1709 /* 64 */ SyscallDesc("nxm_pshared_block", unimplementedFunc
),
1710 /* 65 */ SyscallDesc("nxm_pshared_unblock", unimplementedFunc
),
1711 /* 66 */ SyscallDesc("nxm_pshared_destroy", unimplementedFunc
),
1712 /* 67 */ SyscallDesc("nxm_swtch_pri", swtch_priFunc
),
1713 /* 68 */ SyscallDesc("lw_syscall", unimplementedFunc
),
1714 /* 69 */ SyscallDesc("kern_invalid", unimplementedFunc
),
1715 /* 70 */ SyscallDesc("mach_sctimes_0", unimplementedFunc
),
1716 /* 71 */ SyscallDesc("mach_sctimes_1", unimplementedFunc
),
1717 /* 72 */ SyscallDesc("mach_sctimes_2", unimplementedFunc
),
1718 /* 73 */ SyscallDesc("mach_sctimes_3", unimplementedFunc
),
1719 /* 74 */ SyscallDesc("mach_sctimes_4", unimplementedFunc
),
1720 /* 75 */ SyscallDesc("mach_sctimes_5", unimplementedFunc
),
1721 /* 76 */ SyscallDesc("mach_sctimes_6", unimplementedFunc
),
1722 /* 77 */ SyscallDesc("mach_sctimes_7", unimplementedFunc
),
1723 /* 78 */ SyscallDesc("mach_sctimes_8", unimplementedFunc
),
1724 /* 79 */ SyscallDesc("mach_sctimes_9", unimplementedFunc
),
1725 /* 80 */ SyscallDesc("mach_sctimes_10", unimplementedFunc
),
1726 /* 81 */ SyscallDesc("mach_sctimes_11", unimplementedFunc
),
1727 /* 82 */ SyscallDesc("mach_sctimes_port_alloc_dealloc", unimplementedFunc
)
1730 const int Tru64::Num_Mach_Syscall_Descs
=
1731 sizeof(Tru64::machSyscallDescs
) / sizeof(SyscallDesc
);
1732 const int Tru64::Max_Mach_Syscall_Desc
= Tru64::Num_Mach_Syscall_Descs
- 1;
1733 const int Tru64::Min_Syscall_Desc
= -Tru64::Max_Mach_Syscall_Desc
;
1737 AlphaTru64Process::syscall(ExecContext
*xc
)
1741 int64_t callnum
= xc
->regs
.intRegFile
[ReturnValueReg
];
1743 Tru64::doSyscall(callnum
, this, xc
);
1747 AlphaTru64Process::AlphaTru64Process(const std::string
&name
,
1748 ObjectFile
*objFile
,
1752 std::vector
<std::string
> &argv
,
1753 std::vector
<std::string
> &envp
)
1754 : LiveProcess(name
, objFile
, stdin_fd
, stdout_fd
, stderr_fd
, argv
, envp
)