syscall_emul.hh (8795:0909f8ed7aa0) | syscall_emul.hh (8799:dac1e33e07b0) |
---|---|
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; --- 48 unchanged lines hidden (view full) --- 57#include "base/misc.hh" 58#include "base/trace.hh" 59#include "base/types.hh" 60#include "config/the_isa.hh" 61#include "cpu/base.hh" 62#include "cpu/thread_context.hh" 63#include "debug/SyscallVerbose.hh" 64#include "mem/page_table.hh" | 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; --- 48 unchanged lines hidden (view full) --- 57#include "base/misc.hh" 58#include "base/trace.hh" 59#include "base/types.hh" 60#include "config/the_isa.hh" 61#include "cpu/base.hh" 62#include "cpu/thread_context.hh" 63#include "debug/SyscallVerbose.hh" 64#include "mem/page_table.hh" |
65#include "mem/translating_port.hh" | 65#include "mem/se_translating_port_proxy.hh" |
66#include "sim/byteswap.hh" 67#include "sim/process.hh" 68#include "sim/syscallreturn.hh" 69#include "sim/system.hh" 70 71/// 72/// System call descriptor. 73/// --- 42 unchanged lines hidden (view full) --- 116 memset(bufPtr, 0, size); 117 } 118 119 virtual ~BaseBufferArg() { delete [] bufPtr; } 120 121 // 122 // copy data into simulator space (read from target memory) 123 // | 66#include "sim/byteswap.hh" 67#include "sim/process.hh" 68#include "sim/syscallreturn.hh" 69#include "sim/system.hh" 70 71/// 72/// System call descriptor. 73/// --- 42 unchanged lines hidden (view full) --- 116 memset(bufPtr, 0, size); 117 } 118 119 virtual ~BaseBufferArg() { delete [] bufPtr; } 120 121 // 122 // copy data into simulator space (read from target memory) 123 // |
124 virtual bool copyIn(TranslatingPort *memport) | 124 virtual bool copyIn(SETranslatingPortProxy* memproxy) |
125 { | 125 { |
126 memport->readBlob(addr, bufPtr, size); | 126 memproxy->readBlob(addr, bufPtr, size); |
127 return true; // no EFAULT detection for now 128 } 129 130 // 131 // copy data out of simulator space (write to target memory) 132 // | 127 return true; // no EFAULT detection for now 128 } 129 130 // 131 // copy data out of simulator space (write to target memory) 132 // |
133 virtual bool copyOut(TranslatingPort *memport) | 133 virtual bool copyOut(SETranslatingPortProxy* memproxy) |
134 { | 134 { |
135 memport->writeBlob(addr, bufPtr, size); | 135 memproxy->writeBlob(addr, bufPtr, size); |
136 return true; // no EFAULT detection for now 137 } 138 139 protected: 140 Addr addr; 141 int size; 142 uint8_t *bufPtr; 143}; --- 315 unchanged lines hidden (view full) --- 459 tgt->st_mtime_nsec = 0; 460 tgt->st_ctime_nsec = 0; 461#endif 462} 463 464//Here are a couple convenience functions 465template<class OS> 466static void | 136 return true; // no EFAULT detection for now 137 } 138 139 protected: 140 Addr addr; 141 int size; 142 uint8_t *bufPtr; 143}; --- 315 unchanged lines hidden (view full) --- 459 tgt->st_mtime_nsec = 0; 460 tgt->st_ctime_nsec = 0; 461#endif 462} 463 464//Here are a couple convenience functions 465template<class OS> 466static void |
467copyOutStatBuf(TranslatingPort * mem, Addr addr, | 467copyOutStatBuf(SETranslatingPortProxy* mem, Addr addr, |
468 hst_stat *host, bool fakeTTY = false) 469{ 470 typedef TypedBufferArg<typename OS::tgt_stat> tgt_stat_buf; 471 tgt_stat_buf tgt(addr); 472 convertStatBuf<tgt_stat_buf, hst_stat>(tgt, host, fakeTTY); 473 tgt.copyOut(mem); 474} 475 476template<class OS> 477static void | 468 hst_stat *host, bool fakeTTY = false) 469{ 470 typedef TypedBufferArg<typename OS::tgt_stat> tgt_stat_buf; 471 tgt_stat_buf tgt(addr); 472 convertStatBuf<tgt_stat_buf, hst_stat>(tgt, host, fakeTTY); 473 tgt.copyOut(mem); 474} 475 476template<class OS> 477static void |
478copyOutStat64Buf(TranslatingPort * mem, Addr addr, | 478copyOutStat64Buf(SETranslatingPortProxy* mem, Addr addr, |
479 hst_stat64 *host, bool fakeTTY = false) 480{ 481 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf; 482 tgt_stat_buf tgt(addr); 483 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY); 484 tgt.copyOut(mem); 485} 486 --- 38 unchanged lines hidden (view full) --- 525template <class OS> 526SyscallReturn 527openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 528 ThreadContext *tc) 529{ 530 std::string path; 531 532 int index = 0; | 479 hst_stat64 *host, bool fakeTTY = false) 480{ 481 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf; 482 tgt_stat_buf tgt(addr); 483 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY); 484 tgt.copyOut(mem); 485} 486 --- 38 unchanged lines hidden (view full) --- 525template <class OS> 526SyscallReturn 527openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 528 ThreadContext *tc) 529{ 530 std::string path; 531 532 int index = 0; |
533 if (!tc->getMemPort()->tryReadString(path, | 533 if (!tc->getMemProxy()->tryReadString(path, |
534 process->getSyscallArg(tc, index))) 535 return -EFAULT; 536 537 if (path == "/dev/sysdev0") { 538 // This is a memory-mapped high-resolution timer device on Alpha. 539 // We don't support it, so just punt. 540 warn("Ignoring open(%s, ...)\n", path); 541 return -ENOENT; --- 47 unchanged lines hidden (view full) --- 589 590 int index = 0; 591 TypedBufferArg<typename OS::tgt_sysinfo> 592 sysinfo(process->getSyscallArg(tc, index)); 593 594 sysinfo->uptime=seconds_since_epoch; 595 sysinfo->totalram=process->system->memSize(); 596 | 534 process->getSyscallArg(tc, index))) 535 return -EFAULT; 536 537 if (path == "/dev/sysdev0") { 538 // This is a memory-mapped high-resolution timer device on Alpha. 539 // We don't support it, so just punt. 540 warn("Ignoring open(%s, ...)\n", path); 541 return -ENOENT; --- 47 unchanged lines hidden (view full) --- 589 590 int index = 0; 591 TypedBufferArg<typename OS::tgt_sysinfo> 592 sysinfo(process->getSyscallArg(tc, index)); 593 594 sysinfo->uptime=seconds_since_epoch; 595 sysinfo->totalram=process->system->memSize(); 596 |
597 sysinfo.copyOut(tc->getMemPort()); | 597 sysinfo.copyOut(tc->getMemProxy()); |
598 599 return 0; 600} 601 602/// Target chmod() handler. 603template <class OS> 604SyscallReturn 605chmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 606 ThreadContext *tc) 607{ 608 std::string path; 609 610 int index = 0; | 598 599 return 0; 600} 601 602/// Target chmod() handler. 603template <class OS> 604SyscallReturn 605chmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 606 ThreadContext *tc) 607{ 608 std::string path; 609 610 int index = 0; |
611 if (!tc->getMemPort()->tryReadString(path, | 611 if (!tc->getMemProxy()->tryReadString(path, |
612 process->getSyscallArg(tc, index))) { 613 return -EFAULT; 614 } 615 616 uint32_t mode = process->getSyscallArg(tc, index); 617 mode_t hostMode = 0; 618 619 // XXX translate mode flags via OS::something??? --- 89 unchanged lines hidden (view full) --- 709template <class OS> 710SyscallReturn 711statFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 712 ThreadContext *tc) 713{ 714 std::string path; 715 716 int index = 0; | 612 process->getSyscallArg(tc, index))) { 613 return -EFAULT; 614 } 615 616 uint32_t mode = process->getSyscallArg(tc, index); 617 mode_t hostMode = 0; 618 619 // XXX translate mode flags via OS::something??? --- 89 unchanged lines hidden (view full) --- 709template <class OS> 710SyscallReturn 711statFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 712 ThreadContext *tc) 713{ 714 std::string path; 715 716 int index = 0; |
717 if (!tc->getMemPort()->tryReadString(path, | 717 if (!tc->getMemProxy()->tryReadString(path, |
718 process->getSyscallArg(tc, index))) { 719 return -EFAULT; 720 } 721 Addr bufPtr = process->getSyscallArg(tc, index); 722 723 // Adjust path for current working directory 724 path = process->fullPath(path); 725 726 struct stat hostBuf; 727 int result = stat(path.c_str(), &hostBuf); 728 729 if (result < 0) 730 return -errno; 731 | 718 process->getSyscallArg(tc, index))) { 719 return -EFAULT; 720 } 721 Addr bufPtr = process->getSyscallArg(tc, index); 722 723 // Adjust path for current working directory 724 path = process->fullPath(path); 725 726 struct stat hostBuf; 727 int result = stat(path.c_str(), &hostBuf); 728 729 if (result < 0) 730 return -errno; 731 |
732 copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf); | 732 copyOutStatBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf); |
733 734 return 0; 735} 736 737 738/// Target stat64() handler. 739template <class OS> 740SyscallReturn 741stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, 742 ThreadContext *tc) 743{ 744 std::string path; 745 746 int index = 0; | 733 734 return 0; 735} 736 737 738/// Target stat64() handler. 739template <class OS> 740SyscallReturn 741stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, 742 ThreadContext *tc) 743{ 744 std::string path; 745 746 int index = 0; |
747 if (!tc->getMemPort()->tryReadString(path, | 747 if (!tc->getMemProxy()->tryReadString(path, |
748 process->getSyscallArg(tc, index))) 749 return -EFAULT; 750 Addr bufPtr = process->getSyscallArg(tc, index); 751 752 // Adjust path for current working directory 753 path = process->fullPath(path); 754 755#if NO_STAT64 756 struct stat hostBuf; 757 int result = stat(path.c_str(), &hostBuf); 758#else 759 struct stat64 hostBuf; 760 int result = stat64(path.c_str(), &hostBuf); 761#endif 762 763 if (result < 0) 764 return -errno; 765 | 748 process->getSyscallArg(tc, index))) 749 return -EFAULT; 750 Addr bufPtr = process->getSyscallArg(tc, index); 751 752 // Adjust path for current working directory 753 path = process->fullPath(path); 754 755#if NO_STAT64 756 struct stat hostBuf; 757 int result = stat(path.c_str(), &hostBuf); 758#else 759 struct stat64 hostBuf; 760 int result = stat64(path.c_str(), &hostBuf); 761#endif 762 763 if (result < 0) 764 return -errno; 765 |
766 copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf); | 766 copyOutStat64Buf<OS>(tc->getMemProxy(), bufPtr, &hostBuf); |
767 768 return 0; 769} 770 771 772/// Target fstat64() handler. 773template <class OS> 774SyscallReturn --- 14 unchanged lines hidden (view full) --- 789#else 790 struct stat64 hostBuf; 791 int result = fstat64(process->sim_fd(fd), &hostBuf); 792#endif 793 794 if (result < 0) 795 return -errno; 796 | 767 768 return 0; 769} 770 771 772/// Target fstat64() handler. 773template <class OS> 774SyscallReturn --- 14 unchanged lines hidden (view full) --- 789#else 790 struct stat64 hostBuf; 791 int result = fstat64(process->sim_fd(fd), &hostBuf); 792#endif 793 794 if (result < 0) 795 return -errno; 796 |
797 copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf, (fd == 1)); | 797 copyOutStat64Buf<OS>(tc->getMemProxy(), bufPtr, &hostBuf, (fd == 1)); |
798 799 return 0; 800} 801 802 803/// Target lstat() handler. 804template <class OS> 805SyscallReturn 806lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 807 ThreadContext *tc) 808{ 809 std::string path; 810 811 int index = 0; | 798 799 return 0; 800} 801 802 803/// Target lstat() handler. 804template <class OS> 805SyscallReturn 806lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 807 ThreadContext *tc) 808{ 809 std::string path; 810 811 int index = 0; |
812 if (!tc->getMemPort()->tryReadString(path, | 812 if (!tc->getMemProxy()->tryReadString(path, |
813 process->getSyscallArg(tc, index))) { 814 return -EFAULT; 815 } 816 Addr bufPtr = process->getSyscallArg(tc, index); 817 818 // Adjust path for current working directory 819 path = process->fullPath(path); 820 821 struct stat hostBuf; 822 int result = lstat(path.c_str(), &hostBuf); 823 824 if (result < 0) 825 return -errno; 826 | 813 process->getSyscallArg(tc, index))) { 814 return -EFAULT; 815 } 816 Addr bufPtr = process->getSyscallArg(tc, index); 817 818 // Adjust path for current working directory 819 path = process->fullPath(path); 820 821 struct stat hostBuf; 822 int result = lstat(path.c_str(), &hostBuf); 823 824 if (result < 0) 825 return -errno; 826 |
827 copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf); | 827 copyOutStatBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf); |
828 829 return 0; 830} 831 832/// Target lstat64() handler. 833template <class OS> 834SyscallReturn 835lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, 836 ThreadContext *tc) 837{ 838 std::string path; 839 840 int index = 0; | 828 829 return 0; 830} 831 832/// Target lstat64() handler. 833template <class OS> 834SyscallReturn 835lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process, 836 ThreadContext *tc) 837{ 838 std::string path; 839 840 int index = 0; |
841 if (!tc->getMemPort()->tryReadString(path, | 841 if (!tc->getMemProxy()->tryReadString(path, |
842 process->getSyscallArg(tc, index))) { 843 return -EFAULT; 844 } 845 Addr bufPtr = process->getSyscallArg(tc, index); 846 847 // Adjust path for current working directory 848 path = process->fullPath(path); 849 850#if NO_STAT64 851 struct stat hostBuf; 852 int result = lstat(path.c_str(), &hostBuf); 853#else 854 struct stat64 hostBuf; 855 int result = lstat64(path.c_str(), &hostBuf); 856#endif 857 858 if (result < 0) 859 return -errno; 860 | 842 process->getSyscallArg(tc, index))) { 843 return -EFAULT; 844 } 845 Addr bufPtr = process->getSyscallArg(tc, index); 846 847 // Adjust path for current working directory 848 path = process->fullPath(path); 849 850#if NO_STAT64 851 struct stat hostBuf; 852 int result = lstat(path.c_str(), &hostBuf); 853#else 854 struct stat64 hostBuf; 855 int result = lstat64(path.c_str(), &hostBuf); 856#endif 857 858 if (result < 0) 859 return -errno; 860 |
861 copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf); | 861 copyOutStat64Buf<OS>(tc->getMemProxy(), bufPtr, &hostBuf); |
862 863 return 0; 864} 865 866/// Target fstat() handler. 867template <class OS> 868SyscallReturn 869fstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, --- 9 unchanged lines hidden (view full) --- 879 return -EBADF; 880 881 struct stat hostBuf; 882 int result = fstat(fd, &hostBuf); 883 884 if (result < 0) 885 return -errno; 886 | 862 863 return 0; 864} 865 866/// Target fstat() handler. 867template <class OS> 868SyscallReturn 869fstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, --- 9 unchanged lines hidden (view full) --- 879 return -EBADF; 880 881 struct stat hostBuf; 882 int result = fstat(fd, &hostBuf); 883 884 if (result < 0) 885 return -errno; 886 |
887 copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf, (fd == 1)); | 887 copyOutStatBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf, (fd == 1)); |
888 889 return 0; 890} 891 892 893/// Target statfs() handler. 894template <class OS> 895SyscallReturn 896statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 897 ThreadContext *tc) 898{ 899 std::string path; 900 901 int index = 0; | 888 889 return 0; 890} 891 892 893/// Target statfs() handler. 894template <class OS> 895SyscallReturn 896statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 897 ThreadContext *tc) 898{ 899 std::string path; 900 901 int index = 0; |
902 if (!tc->getMemPort()->tryReadString(path, | 902 if (!tc->getMemProxy()->tryReadString(path, |
903 process->getSyscallArg(tc, index))) { 904 return -EFAULT; 905 } 906 Addr bufPtr = process->getSyscallArg(tc, index); 907 908 // Adjust path for current working directory 909 path = process->fullPath(path); 910 911 struct statfs hostBuf; 912 int result = statfs(path.c_str(), &hostBuf); 913 914 if (result < 0) 915 return -errno; 916 | 903 process->getSyscallArg(tc, index))) { 904 return -EFAULT; 905 } 906 Addr bufPtr = process->getSyscallArg(tc, index); 907 908 // Adjust path for current working directory 909 path = process->fullPath(path); 910 911 struct statfs hostBuf; 912 int result = statfs(path.c_str(), &hostBuf); 913 914 if (result < 0) 915 return -errno; 916 |
917 OS::copyOutStatfsBuf(tc->getMemPort(), bufPtr, &hostBuf); | 917 OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf); |
918 919 return 0; 920} 921 922 923/// Target fstatfs() handler. 924template <class OS> 925SyscallReturn --- 8 unchanged lines hidden (view full) --- 934 return -EBADF; 935 936 struct statfs hostBuf; 937 int result = fstatfs(fd, &hostBuf); 938 939 if (result < 0) 940 return -errno; 941 | 918 919 return 0; 920} 921 922 923/// Target fstatfs() handler. 924template <class OS> 925SyscallReturn --- 8 unchanged lines hidden (view full) --- 934 return -EBADF; 935 936 struct statfs hostBuf; 937 int result = fstatfs(fd, &hostBuf); 938 939 if (result < 0) 940 return -errno; 941 |
942 OS::copyOutStatfsBuf(tc->getMemPort(), bufPtr, &hostBuf); | 942 OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf); |
943 944 return 0; 945} 946 947 948/// Target writev() handler. 949template <class OS> 950SyscallReturn 951writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 952 ThreadContext *tc) 953{ 954 int index = 0; 955 int fd = process->getSyscallArg(tc, index); 956 if (fd < 0 || process->sim_fd(fd) < 0) { 957 // doesn't map to any simulator fd: not a valid target fd 958 return -EBADF; 959 } 960 | 943 944 return 0; 945} 946 947 948/// Target writev() handler. 949template <class OS> 950SyscallReturn 951writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 952 ThreadContext *tc) 953{ 954 int index = 0; 955 int fd = process->getSyscallArg(tc, index); 956 if (fd < 0 || process->sim_fd(fd) < 0) { 957 // doesn't map to any simulator fd: not a valid target fd 958 return -EBADF; 959 } 960 |
961 TranslatingPort *p = tc->getMemPort(); | 961 SETranslatingPortProxy *p = tc->getMemProxy(); |
962 uint64_t tiov_base = process->getSyscallArg(tc, index); 963 size_t count = process->getSyscallArg(tc, index); 964 struct iovec hiov[count]; 965 for (size_t i = 0; i < count; ++i) { 966 typename OS::tgt_iovec tiov; 967 968 p->readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), 969 (uint8_t*)&tiov, sizeof(typename OS::tgt_iovec)); --- 128 unchanged lines hidden (view full) --- 1098 1099 default: 1100 std::cerr << "getrlimitFunc: unimplemented resource " << resource 1101 << std::endl; 1102 abort(); 1103 break; 1104 } 1105 | 962 uint64_t tiov_base = process->getSyscallArg(tc, index); 963 size_t count = process->getSyscallArg(tc, index); 964 struct iovec hiov[count]; 965 for (size_t i = 0; i < count; ++i) { 966 typename OS::tgt_iovec tiov; 967 968 p->readBlob(tiov_base + i*sizeof(typename OS::tgt_iovec), 969 (uint8_t*)&tiov, sizeof(typename OS::tgt_iovec)); --- 128 unchanged lines hidden (view full) --- 1098 1099 default: 1100 std::cerr << "getrlimitFunc: unimplemented resource " << resource 1101 << std::endl; 1102 abort(); 1103 break; 1104 } 1105 |
1106 rlp.copyOut(tc->getMemPort()); | 1106 rlp.copyOut(tc->getMemProxy()); |
1107 return 0; 1108} 1109 1110/// Target gettimeofday() handler. 1111template <class OS> 1112SyscallReturn 1113gettimeofdayFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 1114 ThreadContext *tc) 1115{ 1116 int index = 0; 1117 TypedBufferArg<typename OS::timeval> tp(process->getSyscallArg(tc, index)); 1118 1119 getElapsedTime(tp->tv_sec, tp->tv_usec); 1120 tp->tv_sec += seconds_since_epoch; 1121 tp->tv_sec = TheISA::htog(tp->tv_sec); 1122 tp->tv_usec = TheISA::htog(tp->tv_usec); 1123 | 1107 return 0; 1108} 1109 1110/// Target gettimeofday() handler. 1111template <class OS> 1112SyscallReturn 1113gettimeofdayFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 1114 ThreadContext *tc) 1115{ 1116 int index = 0; 1117 TypedBufferArg<typename OS::timeval> tp(process->getSyscallArg(tc, index)); 1118 1119 getElapsedTime(tp->tv_sec, tp->tv_usec); 1120 tp->tv_sec += seconds_since_epoch; 1121 tp->tv_sec = TheISA::htog(tp->tv_sec); 1122 tp->tv_usec = TheISA::htog(tp->tv_usec); 1123 |
1124 tp.copyOut(tc->getMemPort()); | 1124 tp.copyOut(tc->getMemProxy()); |
1125 1126 return 0; 1127} 1128 1129 1130/// Target utimes() handler. 1131template <class OS> 1132SyscallReturn 1133utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 1134 ThreadContext *tc) 1135{ 1136 std::string path; 1137 1138 int index = 0; | 1125 1126 return 0; 1127} 1128 1129 1130/// Target utimes() handler. 1131template <class OS> 1132SyscallReturn 1133utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 1134 ThreadContext *tc) 1135{ 1136 std::string path; 1137 1138 int index = 0; |
1139 if (!tc->getMemPort()->tryReadString(path, | 1139 if (!tc->getMemProxy()->tryReadString(path, |
1140 process->getSyscallArg(tc, index))) { 1141 return -EFAULT; 1142 } 1143 1144 TypedBufferArg<typename OS::timeval [2]> 1145 tp(process->getSyscallArg(tc, index)); | 1140 process->getSyscallArg(tc, index))) { 1141 return -EFAULT; 1142 } 1143 1144 TypedBufferArg<typename OS::timeval [2]> 1145 tp(process->getSyscallArg(tc, index)); |
1146 tp.copyIn(tc->getMemPort()); | 1146 tp.copyIn(tc->getMemProxy()); |
1147 1148 struct timeval hostTimeval[2]; 1149 for (int i = 0; i < 2; ++i) 1150 { 1151 hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec); 1152 hostTimeval[i].tv_usec = gtoh((*tp)[i].tv_usec); 1153 } 1154 --- 49 unchanged lines hidden (view full) --- 1204 1205 default: 1206 // don't really handle THREAD or CHILDREN, but just warn and 1207 // plow ahead 1208 warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.", 1209 who); 1210 } 1211 | 1147 1148 struct timeval hostTimeval[2]; 1149 for (int i = 0; i < 2; ++i) 1150 { 1151 hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec); 1152 hostTimeval[i].tv_usec = gtoh((*tp)[i].tv_usec); 1153 } 1154 --- 49 unchanged lines hidden (view full) --- 1204 1205 default: 1206 // don't really handle THREAD or CHILDREN, but just warn and 1207 // plow ahead 1208 warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.", 1209 who); 1210 } 1211 |
1212 rup.copyOut(tc->getMemPort()); | 1212 rup.copyOut(tc->getMemProxy()); |
1213 1214 return 0; 1215} 1216 1217/// Target times() function. 1218template <class OS> 1219SyscallReturn 1220timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, --- 8 unchanged lines hidden (view full) --- 1229 bufp->tms_stime = 0; 1230 bufp->tms_cutime = 0; 1231 bufp->tms_cstime = 0; 1232 1233 // Convert to host endianness 1234 bufp->tms_utime = htog(bufp->tms_utime); 1235 1236 // Write back | 1213 1214 return 0; 1215} 1216 1217/// Target times() function. 1218template <class OS> 1219SyscallReturn 1220timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process, --- 8 unchanged lines hidden (view full) --- 1229 bufp->tms_stime = 0; 1230 bufp->tms_cutime = 0; 1231 bufp->tms_cstime = 0; 1232 1233 // Convert to host endianness 1234 bufp->tms_utime = htog(bufp->tms_utime); 1235 1236 // Write back |
1237 bufp.copyOut(tc->getMemPort()); | 1237 bufp.copyOut(tc->getMemProxy()); |
1238 1239 // Return clock ticks since system boot 1240 return clocks; 1241} 1242 1243/// Target time() function. 1244template <class OS> 1245SyscallReturn --- 4 unchanged lines hidden (view full) --- 1250 getElapsedTime(sec, usec); 1251 sec += seconds_since_epoch; 1252 1253 int index = 0; 1254 Addr taddr = (Addr)process->getSyscallArg(tc, index); 1255 if(taddr != 0) { 1256 typename OS::time_t t = sec; 1257 t = htog(t); | 1238 1239 // Return clock ticks since system boot 1240 return clocks; 1241} 1242 1243/// Target time() function. 1244template <class OS> 1245SyscallReturn --- 4 unchanged lines hidden (view full) --- 1250 getElapsedTime(sec, usec); 1251 sec += seconds_since_epoch; 1252 1253 int index = 0; 1254 Addr taddr = (Addr)process->getSyscallArg(tc, index); 1255 if(taddr != 0) { 1256 typename OS::time_t t = sec; 1257 t = htog(t); |
1258 TranslatingPort *p = tc->getMemPort(); | 1258 SETranslatingPortProxy *p = tc->getMemProxy(); |
1259 p->writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t)); 1260 } 1261 return sec; 1262} 1263 1264 1265#endif // __SIM_SYSCALL_EMUL_HH__ | 1259 p->writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t)); 1260 } 1261 return sec; 1262} 1263 1264 1265#endif // __SIM_SYSCALL_EMUL_HH__ |