syscall_emul.hh (10931:42d846318962) syscall_emul.hh (10932:cafae9abd4e4)
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

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

553 ThreadContext *tc)
554{
555 int index = 0;
556 int tgt_fd = process->getSyscallArg(tc, index);
557 unsigned req = process->getSyscallArg(tc, index);
558
559 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req);
560
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

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

553 ThreadContext *tc)
554{
555 int index = 0;
556 int tgt_fd = process->getSyscallArg(tc, index);
557 unsigned req = process->getSyscallArg(tc, index);
558
559 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req);
560
561 FDEntry *fde = process->get_fd_entry(tgt_fd);
561 FDEntry *fde = process->getFDEntry(tgt_fd);
562
563 if (fde == NULL) {
564 // doesn't map to any simulator fd: not a valid target fd
565 return -EBADF;
566 }
567
568 if (fde->driver != NULL) {
569 return fde->driver->ioctl(process, tc, req);

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

645 // open the file
646 fd = open(path.c_str(), hostFlags, mode);
647 local_errno = errno;
648 }
649
650 if (fd == -1)
651 return -local_errno;
652
562
563 if (fde == NULL) {
564 // doesn't map to any simulator fd: not a valid target fd
565 return -EBADF;
566 }
567
568 if (fde->driver != NULL) {
569 return fde->driver->ioctl(process, tc, req);

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

645 // open the file
646 fd = open(path.c_str(), hostFlags, mode);
647 local_errno = errno;
648 }
649
650 if (fd == -1)
651 return -local_errno;
652
653 return process->alloc_fd(fd, path.c_str(), hostFlags, mode, false);
653 return process->allocFD(fd, path.c_str(), hostFlags, mode, false);
654}
655
656/// Target open() handler.
657template <class OS>
658SyscallReturn
659openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
660 ThreadContext *tc)
661{

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

807SyscallReturn
808fchmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
809 ThreadContext *tc)
810{
811 int index = 0;
812 int tgt_fd = process->getSyscallArg(tc, index);
813 uint32_t mode = process->getSyscallArg(tc, index);
814
654}
655
656/// Target open() handler.
657template <class OS>
658SyscallReturn
659openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
660 ThreadContext *tc)
661{

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

807SyscallReturn
808fchmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
809 ThreadContext *tc)
810{
811 int index = 0;
812 int tgt_fd = process->getSyscallArg(tc, index);
813 uint32_t mode = process->getSyscallArg(tc, index);
814
815 int sim_fd = process->sim_fd(tgt_fd);
815 int sim_fd = process->getSimFD(tgt_fd);
816 if (sim_fd < 0)
817 return -EBADF;
818
819 mode_t hostMode = 0;
820
821 // XXX translate mode flags via OS::someting???
822 hostMode = mode;
823

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

1001SyscallReturn
1002fstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
1003 ThreadContext *tc)
1004{
1005 int index = 0;
1006 int tgt_fd = process->getSyscallArg(tc, index);
1007 Addr bufPtr = process->getSyscallArg(tc, index);
1008
816 if (sim_fd < 0)
817 return -EBADF;
818
819 mode_t hostMode = 0;
820
821 // XXX translate mode flags via OS::someting???
822 hostMode = mode;
823

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

1001SyscallReturn
1002fstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
1003 ThreadContext *tc)
1004{
1005 int index = 0;
1006 int tgt_fd = process->getSyscallArg(tc, index);
1007 Addr bufPtr = process->getSyscallArg(tc, index);
1008
1009 int sim_fd = process->sim_fd(tgt_fd);
1009 int sim_fd = process->getSimFD(tgt_fd);
1010 if (sim_fd < 0)
1011 return -EBADF;
1012
1013#if NO_STAT64
1014 struct stat hostBuf;
1015 int result = fstat(sim_fd, &hostBuf);
1016#else
1017 struct stat64 hostBuf;

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

1097 ThreadContext *tc)
1098{
1099 int index = 0;
1100 int tgt_fd = process->getSyscallArg(tc, index);
1101 Addr bufPtr = process->getSyscallArg(tc, index);
1102
1103 DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", tgt_fd);
1104
1010 if (sim_fd < 0)
1011 return -EBADF;
1012
1013#if NO_STAT64
1014 struct stat hostBuf;
1015 int result = fstat(sim_fd, &hostBuf);
1016#else
1017 struct stat64 hostBuf;

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

1097 ThreadContext *tc)
1098{
1099 int index = 0;
1100 int tgt_fd = process->getSyscallArg(tc, index);
1101 Addr bufPtr = process->getSyscallArg(tc, index);
1102
1103 DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", tgt_fd);
1104
1105 int sim_fd = process->sim_fd(tgt_fd);
1105 int sim_fd = process->getSimFD(tgt_fd);
1106 if (sim_fd < 0)
1107 return -EBADF;
1108
1109 struct stat hostBuf;
1110 int result = fstat(sim_fd, &hostBuf);
1111
1112 if (result < 0)
1113 return -errno;

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

1153SyscallReturn
1154fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1155 ThreadContext *tc)
1156{
1157 int index = 0;
1158 int tgt_fd = process->getSyscallArg(tc, index);
1159 Addr bufPtr = process->getSyscallArg(tc, index);
1160
1106 if (sim_fd < 0)
1107 return -EBADF;
1108
1109 struct stat hostBuf;
1110 int result = fstat(sim_fd, &hostBuf);
1111
1112 if (result < 0)
1113 return -errno;

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

1153SyscallReturn
1154fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1155 ThreadContext *tc)
1156{
1157 int index = 0;
1158 int tgt_fd = process->getSyscallArg(tc, index);
1159 Addr bufPtr = process->getSyscallArg(tc, index);
1160
1161 int sim_fd = process->sim_fd(tgt_fd);
1161 int sim_fd = process->getSimFD(tgt_fd);
1162 if (sim_fd < 0)
1163 return -EBADF;
1164
1165 struct statfs hostBuf;
1166 int result = fstatfs(sim_fd, &hostBuf);
1167
1168 if (result < 0)
1169 return -errno;

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

1178template <class OS>
1179SyscallReturn
1180writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1181 ThreadContext *tc)
1182{
1183 int index = 0;
1184 int tgt_fd = process->getSyscallArg(tc, index);
1185
1162 if (sim_fd < 0)
1163 return -EBADF;
1164
1165 struct statfs hostBuf;
1166 int result = fstatfs(sim_fd, &hostBuf);
1167
1168 if (result < 0)
1169 return -errno;

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

1178template <class OS>
1179SyscallReturn
1180writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1181 ThreadContext *tc)
1182{
1183 int index = 0;
1184 int tgt_fd = process->getSyscallArg(tc, index);
1185
1186 int sim_fd = process->sim_fd(tgt_fd);
1186 int sim_fd = process->getSimFD(tgt_fd);
1187 if (sim_fd < 0)
1188 return -EBADF;
1189
1190 SETranslatingPortProxy &p = tc->getMemProxy();
1191 uint64_t tiov_base = process->getSyscallArg(tc, index);
1192 size_t count = process->getSyscallArg(tc, index);
1193 struct iovec hiov[count];
1194 for (size_t i = 0; i < count; ++i) {

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

1232 int flags = p->getSyscallArg(tc, index);
1233 int tgt_fd = p->getSyscallArg(tc, index);
1234 int offset = p->getSyscallArg(tc, index);
1235
1236 if (length > 0x100000000ULL)
1237 warn("mmap length argument %#x is unreasonably large.\n", length);
1238
1239 if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
1187 if (sim_fd < 0)
1188 return -EBADF;
1189
1190 SETranslatingPortProxy &p = tc->getMemProxy();
1191 uint64_t tiov_base = process->getSyscallArg(tc, index);
1192 size_t count = process->getSyscallArg(tc, index);
1193 struct iovec hiov[count];
1194 for (size_t i = 0; i < count; ++i) {

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

1232 int flags = p->getSyscallArg(tc, index);
1233 int tgt_fd = p->getSyscallArg(tc, index);
1234 int offset = p->getSyscallArg(tc, index);
1235
1236 if (length > 0x100000000ULL)
1237 warn("mmap length argument %#x is unreasonably large.\n", length);
1238
1239 if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
1240 FDEntry *fde = p->get_fd_entry(tgt_fd);
1240 FDEntry *fde = p->getFDEntry(tgt_fd);
1241 if (!fde || fde->fd < 0) {
1242 warn("mmap failing: target fd %d is not valid\n", tgt_fd);
1243 return -EBADF;
1244 }
1245
1246 if (fde->filename != "/dev/zero") {
1247 // This is very likely broken, but leave a warning here
1248 // (rather than panic) in case /dev/zero is known by

--- 267 unchanged lines hidden ---
1241 if (!fde || fde->fd < 0) {
1242 warn("mmap failing: target fd %d is not valid\n", tgt_fd);
1243 return -EBADF;
1244 }
1245
1246 if (fde->filename != "/dev/zero") {
1247 // This is very likely broken, but leave a warning here
1248 // (rather than panic) in case /dev/zero is known by

--- 267 unchanged lines hidden ---