syscall_emul.hh (10850:e4328e028961) | syscall_emul.hh (10930:ddc3d96d6313) |
---|---|
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 --- 539 unchanged lines hidden (view full) --- 548/// do line or block buffering. We always claim that output fds are 549/// not TTYs to provide repeatable results. 550template <class OS> 551SyscallReturn 552ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 553 ThreadContext *tc) 554{ 555 int index = 0; | 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 --- 539 unchanged lines hidden (view full) --- 548/// do line or block buffering. We always claim that output fds are 549/// not TTYs to provide repeatable results. 550template <class OS> 551SyscallReturn 552ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 553 ThreadContext *tc) 554{ 555 int index = 0; |
556 int fd = process->getSyscallArg(tc, index); | 556 int tgt_fd = process->getSyscallArg(tc, index); |
557 unsigned req = process->getSyscallArg(tc, index); 558 | 557 unsigned req = process->getSyscallArg(tc, index); 558 |
559 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req); | 559 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req); |
560 | 560 |
561 Process::FdMap *fdObj = process->sim_fd_obj(fd); | 561 FDEntry *fde = process->get_fd_entry(tgt_fd); |
562 | 562 |
563 if (fdObj == NULL) { | 563 if (fde == NULL) { |
564 // doesn't map to any simulator fd: not a valid target fd 565 return -EBADF; 566 } 567 | 564 // doesn't map to any simulator fd: not a valid target fd 565 return -EBADF; 566 } 567 |
568 if (fdObj->driver != NULL) { 569 return fdObj->driver->ioctl(process, tc, req); | 568 if (fde->driver != NULL) { 569 return fde->driver->ioctl(process, tc, req); |
570 } 571 572 if (OS::isTtyReq(req)) { 573 return -ENOTTY; 574 } 575 576 warn("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n", | 570 } 571 572 if (OS::isTtyReq(req)) { 573 return -ENOTTY; 574 } 575 576 warn("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n", |
577 fd, req, tc->pcState()); | 577 tgt_fd, req, tc->pcState()); |
578 return -ENOTTY; 579} 580 581template <class OS> 582static SyscallReturn 583openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 584 ThreadContext *tc, int index) 585{ --- 644 unchanged lines hidden (view full) --- 1230 int flags = p->getSyscallArg(tc, index); 1231 int tgt_fd = p->getSyscallArg(tc, index); 1232 int offset = p->getSyscallArg(tc, index); 1233 1234 if (length > 0x100000000ULL) 1235 warn("mmap length argument %#x is unreasonably large.\n", length); 1236 1237 if (!(flags & OS::TGT_MAP_ANONYMOUS)) { | 578 return -ENOTTY; 579} 580 581template <class OS> 582static SyscallReturn 583openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 584 ThreadContext *tc, int index) 585{ --- 644 unchanged lines hidden (view full) --- 1230 int flags = p->getSyscallArg(tc, index); 1231 int tgt_fd = p->getSyscallArg(tc, index); 1232 int offset = p->getSyscallArg(tc, index); 1233 1234 if (length > 0x100000000ULL) 1235 warn("mmap length argument %#x is unreasonably large.\n", length); 1236 1237 if (!(flags & OS::TGT_MAP_ANONYMOUS)) { |
1238 Process::FdMap *fd_map = p->sim_fd_obj(tgt_fd); 1239 if (!fd_map || fd_map->fd < 0) { | 1238 FDEntry *fde = p->get_fd_entry(tgt_fd); 1239 if (!fde || fde->fd < 0) { |
1240 warn("mmap failing: target fd %d is not valid\n", tgt_fd); 1241 return -EBADF; 1242 } 1243 | 1240 warn("mmap failing: target fd %d is not valid\n", tgt_fd); 1241 return -EBADF; 1242 } 1243 |
1244 if (fd_map->filename != "/dev/zero") { | 1244 if (fde->filename != "/dev/zero") { |
1245 // This is very likely broken, but leave a warning here 1246 // (rather than panic) in case /dev/zero is known by 1247 // another name on some platform 1248 warn("allowing mmap of file %s; mmap not supported on files" | 1245 // This is very likely broken, but leave a warning here 1246 // (rather than panic) in case /dev/zero is known by 1247 // another name on some platform 1248 warn("allowing mmap of file %s; mmap not supported on files" |
1249 " other than /dev/zero\n", fd_map->filename); | 1249 " other than /dev/zero\n", fde->filename); |
1250 } 1251 } 1252 1253 length = roundUp(length, TheISA::PageBytes); 1254 1255 if ((start % TheISA::PageBytes) != 0 || 1256 (offset % TheISA::PageBytes) != 0) { 1257 warn("mmap failing: arguments not page-aligned: " --- 256 unchanged lines hidden --- | 1250 } 1251 } 1252 1253 length = roundUp(length, TheISA::PageBytes); 1254 1255 if ((start % TheISA::PageBytes) != 0 || 1256 (offset % TheISA::PageBytes) != 0) { 1257 warn("mmap failing: arguments not page-aligned: " --- 256 unchanged lines hidden --- |