Deleted Added
sdiff udiff text old ( 3079:13d9c24a7bba ) new ( 3113:a6811aaea654 )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

41/// This file defines objects used to emulate syscalls from the target
42/// application on the host machine.
43
44#include <errno.h>
45#include <string>
46#ifdef __CYGWIN32__
47#include <sys/fcntl.h> // for O_BINARY
48#endif
49#include <sys/uio.h>
50
51#include "arch/isa_traits.hh" // for Addr
52#include "base/chunk_generator.hh"
53#include "base/intmath.hh" // for RoundUp
54#include "base/misc.hh"
55#include "base/trace.hh"
56#include "cpu/base.hh"
57#include "cpu/thread_context.hh"
58#include "mem/translating_port.hh"
59#include "mem/page_table.hh"

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

300SyscallReturn getuidPseudoFunc(SyscallDesc *desc, int num,
301 Process *p, ThreadContext *tc);
302
303/// Target getgidPseudo() handler.
304SyscallReturn getgidPseudoFunc(SyscallDesc *desc, int num,
305 Process *p, ThreadContext *tc);
306
307
308/// This struct is used to build an target-OS-dependent table that
309/// maps the target's open() flags to the host open() flags.
310struct OpenFlagTransTable {
311 int tgtFlag; //!< Target system flag value.
312 int hostFlag; //!< Corresponding host system flag value.
313};
314
315
316
317/// A readable name for 1,000,000, for converting microseconds to seconds.
318const int one_million = 1000000;
319
320/// Approximate seconds since the epoch (1/1/1970). About a billion,
321/// by my reckoning. We want to keep this a constant (not use the
322/// real-world time) to keep simulations repeatable.
323const unsigned seconds_since_epoch = 1000000000;
324

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

335
336//////////////////////////////////////////////////////////////////////
337//
338// The following emulation functions are generic, but need to be
339// templated to account for differences in types, constants, etc.
340//
341//////////////////////////////////////////////////////////////////////
342
343/// Target ioctl() handler. For the most part, programs call ioctl()
344/// only to find out if their stdout is a tty, to determine whether to
345/// do line or block buffering.
346template <class OS>
347SyscallReturn
348ioctlFunc(SyscallDesc *desc, int callnum, Process *process,
349 ThreadContext *tc)
350{

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

487 return -EFAULT;
488
489 struct stat hostBuf;
490 int result = stat(path.c_str(), &hostBuf);
491
492 if (result < 0)
493 return -errno;
494
495 OS::copyOutStatBuf(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
496
497 return 0;
498}
499
500
501/// Target fstat64() handler.
502template <class OS>
503SyscallReturn

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

516#else
517 struct stat64 hostBuf;
518 int result = fstat64(process->sim_fd(fd), &hostBuf);
519#endif
520
521 if (result < 0)
522 return -errno;
523
524 OS::copyOutStat64Buf(tc->getMemPort(), fd, tc->getSyscallArg(1), &hostBuf);
525
526 return 0;
527}
528
529
530/// Target lstat() handler.
531template <class OS>
532SyscallReturn

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

539 return -EFAULT;
540
541 struct stat hostBuf;
542 int result = lstat(path.c_str(), &hostBuf);
543
544 if (result < 0)
545 return -errno;
546
547 OS::copyOutStatBuf(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
548
549 return 0;
550}
551
552/// Target lstat64() handler.
553template <class OS>
554SyscallReturn
555lstat64Func(SyscallDesc *desc, int callnum, Process *process,

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

566#else
567 struct stat64 hostBuf;
568 int result = lstat64(path.c_str(), &hostBuf);
569#endif
570
571 if (result < 0)
572 return -errno;
573
574 OS::copyOutStat64Buf(tc->getMemPort(), -1, tc->getSyscallArg(1), &hostBuf);
575
576 return 0;
577}
578
579/// Target fstat() handler.
580template <class OS>
581SyscallReturn
582fstatFunc(SyscallDesc *desc, int callnum, Process *process,

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

590 return -EBADF;
591
592 struct stat hostBuf;
593 int result = fstat(fd, &hostBuf);
594
595 if (result < 0)
596 return -errno;
597
598 OS::copyOutStatBuf(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
599
600 return 0;
601}
602
603
604/// Target statfs() handler.
605template <class OS>
606SyscallReturn

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

613 return -EFAULT;
614
615 struct statfs hostBuf;
616 int result = statfs(path.c_str(), &hostBuf);
617
618 if (result < 0)
619 return -errno;
620
621 OS::copyOutStatfsBuf(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
622
623 return 0;
624}
625
626
627/// Target fstatfs() handler.
628template <class OS>
629SyscallReturn

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

636 return -EBADF;
637
638 struct statfs hostBuf;
639 int result = fstatfs(fd, &hostBuf);
640
641 if (result < 0)
642 return -errno;
643
644 OS::copyOutStatfsBuf(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
645
646 return 0;
647}
648
649
650/// Target writev() handler.
651template <class OS>
652SyscallReturn

--- 208 unchanged lines hidden ---