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 --- 1517 unchanged lines hidden (view full) --- 1526 if (result < 0) 1527 return -errno; 1528 1529 copyOutStatfsBuf<OS>(tc->getMemProxy(), bufPtr, &hostBuf); 1530 1531 return 0; 1532} 1533 |
1534/// Target readv() handler. 1535template <class OS> 1536SyscallReturn 1537readvFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc) 1538{ 1539 int index = 0; 1540 int tgt_fd = p->getSyscallArg(tc, index); |
1541 |
1542 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]); 1543 if (!ffdp) 1544 return -EBADF; 1545 int sim_fd = ffdp->getSimFD(); 1546 1547 SETranslatingPortProxy &prox = tc->getMemProxy(); 1548 uint64_t tiov_base = p->getSyscallArg(tc, index); 1549 size_t count = p->getSyscallArg(tc, index); 1550 typename OS::tgt_iovec tiov[count]; 1551 struct iovec hiov[count]; 1552 for (size_t i = 0; i < count; ++i) { 1553 prox.readBlob(tiov_base + (i * sizeof(typename OS::tgt_iovec)), 1554 (uint8_t*)&tiov[i], sizeof(typename OS::tgt_iovec)); 1555 hiov[i].iov_len = TheISA::gtoh(tiov[i].iov_len); 1556 hiov[i].iov_base = new char [hiov[i].iov_len]; 1557 } 1558 1559 int result = readv(sim_fd, hiov, count); 1560 int local_errno = errno; 1561 1562 for (size_t i = 0; i < count; ++i) { 1563 if (result != -1) { 1564 prox.writeBlob(TheISA::htog(tiov[i].iov_base), 1565 (uint8_t*)hiov[i].iov_base, hiov[i].iov_len); 1566 } 1567 delete [] (char *)hiov[i].iov_base; 1568 } 1569 1570 return (result == -1) ? -local_errno : result; 1571} 1572 |
1573/// Target writev() handler. 1574template <class OS> 1575SyscallReturn 1576writevFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc) 1577{ 1578 int index = 0; 1579 int tgt_fd = p->getSyscallArg(tc, index); 1580 --- 17 unchanged lines hidden (view full) --- 1598 hiov[i].iov_len); 1599 } 1600 1601 int result = writev(sim_fd, hiov, count); 1602 1603 for (size_t i = 0; i < count; ++i) 1604 delete [] (char *)hiov[i].iov_base; 1605 |
1606 return (result == -1) ? -errno : result; |
1607} 1608 1609/// Real mmap handler. 1610template <class OS> 1611SyscallReturn 1612mmapImpl(SyscallDesc *desc, int num, Process *p, ThreadContext *tc, 1613 bool is_mmap2) 1614{ --- 1062 unchanged lines hidden --- |