syscall_emul.hh (9112:6e854ea87bab) syscall_emul.hh (9141:593fe25c86a6)
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;

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

562 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
563 tgt_stat_buf tgt(addr);
564 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
565 tgt.copyOut(mem);
566}
567
568/// Target ioctl() handler. For the most part, programs call ioctl()
569/// only to find out if their stdout is a tty, to determine whether to
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;

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

562 typedef TypedBufferArg<typename OS::tgt_stat64> tgt_stat_buf;
563 tgt_stat_buf tgt(addr);
564 convertStat64Buf<tgt_stat_buf, hst_stat64>(tgt, host, fakeTTY);
565 tgt.copyOut(mem);
566}
567
568/// Target ioctl() handler. For the most part, programs call ioctl()
569/// only to find out if their stdout is a tty, to determine whether to
570/// do line or block buffering.
570/// do line or block buffering. We always claim that output fds are
571/// not TTYs to provide repeatable results.
571template <class OS>
572SyscallReturn
573ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
574 ThreadContext *tc)
575{
576 int index = 0;
577 int fd = process->getSyscallArg(tc, index);
578 unsigned req = process->getSyscallArg(tc, index);
579
580 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req);
581
582 if (fd < 0 || process->sim_fd(fd) < 0) {
583 // doesn't map to any simulator fd: not a valid target fd
584 return -EBADF;
585 }
586
572template <class OS>
573SyscallReturn
574ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
575 ThreadContext *tc)
576{
577 int index = 0;
578 int fd = process->getSyscallArg(tc, index);
579 unsigned req = process->getSyscallArg(tc, index);
580
581 DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req);
582
583 if (fd < 0 || process->sim_fd(fd) < 0) {
584 // doesn't map to any simulator fd: not a valid target fd
585 return -EBADF;
586 }
587
587 switch (req) {
588 case OS::TIOCISATTY_:
589 case OS::TIOCGETP_:
590 case OS::TIOCSETP_:
591 case OS::TIOCSETN_:
592 case OS::TIOCSETC_:
593 case OS::TIOCGETC_:
594 case OS::TIOCGETS_:
595 case OS::TIOCGETA_:
596 case OS::TCSETAW_:
588 if (OS::isTtyReq(req)) {
597 return -ENOTTY;
589 return -ENOTTY;
598
599 default:
600 fatal("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n",
601 fd, req, tc->pcState());
602 }
590 }
591
592 warn("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n",
593 fd, req, tc->pcState());
594 return -ENOTTY;
603}
604
605/// Target open() handler.
606template <class OS>
607SyscallReturn
608openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
609 ThreadContext *tc)
610{

--- 739 unchanged lines hidden ---
595}
596
597/// Target open() handler.
598template <class OS>
599SyscallReturn
600openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
601 ThreadContext *tc)
602{

--- 739 unchanged lines hidden ---