1/* 2 * Copyright (c) 2012-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 63 unchanged lines hidden (view full) --- 72#include "base/types.hh" 73#include "config/the_isa.hh" 74#include "cpu/base.hh" 75#include "cpu/thread_context.hh" 76#include "debug/SyscallVerbose.hh" 77#include "mem/page_table.hh" 78#include "mem/se_translating_port_proxy.hh" 79#include "sim/byteswap.hh" |
80#include "sim/emul_driver.hh" |
81#include "sim/process.hh" 82#include "sim/syscallreturn.hh" 83#include "sim/system.hh" 84 85/// 86/// System call descriptor. 87/// 88class SyscallDesc { --- 511 unchanged lines hidden (view full) --- 600 ThreadContext *tc) 601{ 602 int index = 0; 603 int fd = process->getSyscallArg(tc, index); 604 unsigned req = process->getSyscallArg(tc, index); 605 606 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req); 607 |
608 Process::FdMap *fdObj = process->sim_fd_obj(fd); 609 610 if (fdObj == NULL) { |
611 // doesn't map to any simulator fd: not a valid target fd 612 return -EBADF; 613 } 614 |
615 if (fdObj->driver != NULL) { 616 return fdObj->driver->ioctl(process, tc, req); 617 } 618 |
619 if (OS::isTtyReq(req)) { 620 return -ENOTTY; 621 } 622 623 warn("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n", 624 fd, req, tc->pcState()); 625 return -ENOTTY; 626} --- 4 unchanged lines hidden (view full) --- 631 ThreadContext *tc, int index) 632{ 633 std::string path; 634 635 if (!tc->getMemProxy().tryReadString(path, 636 process->getSyscallArg(tc, index))) 637 return -EFAULT; 638 |
639 int tgtFlags = process->getSyscallArg(tc, index); 640 int mode = process->getSyscallArg(tc, index); 641 int hostFlags = 0; 642 643 // translate open flags 644 for (int i = 0; i < OS::NUM_OPEN_FLAGS; i++) { 645 if (tgtFlags & OS::openFlagTable[i].tgtFlag) { 646 tgtFlags &= ~OS::openFlagTable[i].tgtFlag; --- 9 unchanged lines hidden (view full) --- 656 hostFlags |= O_BINARY; 657#endif 658 659 // Adjust path for current working directory 660 path = process->fullPath(path); 661 662 DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str()); 663 |
664 if (startswith(path, "/dev/")) { 665 std::string filename = path.substr(strlen("/dev/")); 666 if (filename == "sysdev0") { 667 // This is a memory-mapped high-resolution timer device on Alpha. 668 // We don't support it, so just punt. 669 warn("Ignoring open(%s, ...)\n", path); 670 return -ENOENT; 671 } 672 673 EmulatedDriver *drv = process->findDriver(filename); 674 if (drv != NULL) { 675 // the driver's open method will allocate a fd from the 676 // process if necessary. 677 return drv->open(process, tc, mode, hostFlags); 678 } 679 680 // fall through here for pass through to host devices, such as 681 // /dev/zero 682 } 683 |
684 int fd; 685 int local_errno; 686 if (startswith(path, "/proc/") || startswith(path, "/system/") || 687 startswith(path, "/platform/") || startswith(path, "/sys/")) { 688 // It's a proc/sys entry and requires special handling 689 fd = OS::openSpecialFile(path, process, tc); 690 local_errno = ENOENT; 691 } else { --- 801 unchanged lines hidden --- |