syscall_emul.hh (11758:104a404d426e) syscall_emul.hh (11759:deaf82fd2e7c)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

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

57
58#ifdef __CYGWIN32__
59#include <sys/fcntl.h> // for O_BINARY
60
61#endif
62#include <fcntl.h>
63#include <sys/mman.h>
64#include <sys/stat.h>
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

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

57
58#ifdef __CYGWIN32__
59#include <sys/fcntl.h> // for O_BINARY
60
61#endif
62#include <fcntl.h>
63#include <sys/mman.h>
64#include <sys/stat.h>
65#include <sys/statfs.h>
65#include <sys/time.h>
66#include <sys/uio.h>
67#include <unistd.h>
68
69#include <cerrno>
70#include <string>
71
72#include "base/chunk_generator.hh"

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

446
447//////////////////////////////////////////////////////////////////////
448//
449// The following emulation functions are generic, but need to be
450// templated to account for differences in types, constants, etc.
451//
452//////////////////////////////////////////////////////////////////////
453
66#include <sys/time.h>
67#include <sys/uio.h>
68#include <unistd.h>
69
70#include <cerrno>
71#include <string>
72
73#include "base/chunk_generator.hh"

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

447
448//////////////////////////////////////////////////////////////////////
449//
450// The following emulation functions are generic, but need to be
451// templated to account for differences in types, constants, etc.
452//
453//////////////////////////////////////////////////////////////////////
454
455 typedef struct statfs hst_statfs;
454#if NO_STAT64
455 typedef struct stat hst_stat;
456 typedef struct stat hst_stat64;
457#else
458 typedef struct stat hst_stat;
459 typedef struct stat64 hst_stat64;
460#endif
461

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

551 hst_stat64 *host, bool fakeTTY = false)
552{
553 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
554 tgt_stat_buf tgt(addr);
555 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
556 tgt.copyOut(mem);
557}
558
456#if NO_STAT64
457 typedef struct stat hst_stat;
458 typedef struct stat hst_stat64;
459#else
460 typedef struct stat hst_stat;
461 typedef struct stat64 hst_stat64;
462#endif
463

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

553 hst_stat64 *host, bool fakeTTY = false)
554{
555 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
556 tgt_stat_buf tgt(addr);
557 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
558 tgt.copyOut(mem);
559}
560
561template <class OS>
562static void
563copyOutStatfsBuf(SETranslatingPortProxy &mem, Addr addr,
564 hst_statfs *host)
565{
566 TypedBufferArg<typename OS::tgt_statfs> tgt(addr);
567
568#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD__)
569 tgt->f_type = 0;
570#else
571 tgt->f_type = TheISA::htog(host->f_type);
572#endif
573 tgt->f_bsize = TheISA::htog(host->f_bsize);
574 tgt->f_blocks = TheISA::htog(host->f_blocks);
575 tgt->f_bfree = TheISA::htog(host->f_bfree);
576 tgt->f_bavail = TheISA::htog(host->f_bavail);
577 tgt->f_files = TheISA::htog(host->f_files);
578 tgt->f_ffree = TheISA::htog(host->f_ffree);
579 memcpy(&tgt->f_fsid, &host->f_fsid, sizeof(host->f_fsid));
580 tgt->f_namelen = TheISA::htog(host->f_namelen);
581 tgt->f_frsize = TheISA::htog(host->f_frsize);
582 memcpy(&tgt->f_spare, &host->f_spare, sizeof(host->f_spare));
583
584 tgt.copyOut(mem);
585}
586
559/// Target ioctl() handler. For the most part, programs call ioctl()
560/// only to find out if their stdout is a tty, to determine whether to
561/// do line or block buffering. We always claim that output fds are
562/// not TTYs to provide repeatable results.
563template <class OS>
564SyscallReturn
565ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
566 ThreadContext *tc)

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

1151 path = process->fullPath(path);
1152
1153 struct statfs hostBuf;
1154 int result = statfs(path.c_str(), &hostBuf);
1155
1156 if (result < 0)
1157 return -errno;
1158
587/// Target ioctl() handler. For the most part, programs call ioctl()
588/// only to find out if their stdout is a tty, to determine whether to
589/// do line or block buffering. We always claim that output fds are
590/// not TTYs to provide repeatable results.
591template <class OS>
592SyscallReturn
593ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
594 ThreadContext *tc)

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

1179 path = process->fullPath(path);
1180
1181 struct statfs hostBuf;
1182 int result = statfs(path.c_str(), &hostBuf);
1183
1184 if (result < 0)
1185 return -errno;
1186
1159 OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf);
1187 copyOutStatfsBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf);
1160
1161 return 0;
1162}
1163
1164
1165/// Target fstatfs() handler.
1166template <class OS>
1167SyscallReturn

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

1177 return -EBADF;
1178
1179 struct statfs hostBuf;
1180 int result = fstatfs(sim_fd, &hostBuf);
1181
1182 if (result < 0)
1183 return -errno;
1184
1188
1189 return 0;
1190}
1191
1192
1193/// Target fstatfs() handler.
1194template <class OS>
1195SyscallReturn

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

1205 return -EBADF;
1206
1207 struct statfs hostBuf;
1208 int result = fstatfs(sim_fd, &hostBuf);
1209
1210 if (result < 0)
1211 return -errno;
1212
1185 OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf);
1213 copyOutStatfsBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf);
1186
1187 return 0;
1188}
1189
1190
1191/// Target writev() handler.
1192template <class OS>
1193SyscallReturn

--- 475 unchanged lines hidden ---
1214
1215 return 0;
1216}
1217
1218
1219/// Target writev() handler.
1220template <class OS>
1221SyscallReturn

--- 475 unchanged lines hidden ---