diff --git a/src/arch/alpha/linux/linux.hh b/src/arch/alpha/linux/linux.hh --- a/src/arch/alpha/linux/linux.hh +++ b/src/arch/alpha/linux/linux.hh @@ -97,16 +97,16 @@ //@{ /// ioctl() command codes. - static const unsigned TIOCGETP_ = 0x40067408; - static const unsigned TIOCSETP_ = 0x80067409; - static const unsigned TIOCSETN_ = 0x8006740a; - static const unsigned TIOCSETC_ = 0x80067411; - static const unsigned TIOCGETC_ = 0x40067412; - static const unsigned FIONREAD_ = 0x4004667f; - static const unsigned TIOCISATTY_ = 0x2000745e; - static const unsigned TIOCGETS_ = 0x402c7413; - static const unsigned TIOCGETA_ = 0x40127417; - static const unsigned TCSETAW_ = 0x80147419; // 2.6.15 kernel + static const unsigned TGT_TIOCGETP = 0x40067408; + static const unsigned TGT_TIOCSETP = 0x80067409; + static const unsigned TGT_TIOCSETN = 0x8006740a; + static const unsigned TGT_TIOCSETC = 0x80067411; + static const unsigned TGT_TIOCGETC = 0x40067412; + static const unsigned TGT_FIONREAD = 0x4004667f; + static const unsigned TGT_TIOCISATTY = 0x2000745e; + static const unsigned TGT_TCGETS = 0x402c7413; + static const unsigned TGT_TCGETA = 0x40127417; + static const unsigned TGT_TCSETAW = 0x80147419; // 2.6.15 kernel //@} /// For table(). diff --git a/src/arch/alpha/tru64/tru64.hh b/src/arch/alpha/tru64/tru64.hh --- a/src/arch/alpha/tru64/tru64.hh +++ b/src/arch/alpha/tru64/tru64.hh @@ -91,16 +91,16 @@ //@{ /// ioctl() command codes. - static const unsigned TIOCGETP_ = 0x40067408; - static const unsigned TIOCSETP_ = 0x80067409; - static const unsigned TIOCSETN_ = 0x8006740a; - static const unsigned TIOCSETC_ = 0x80067411; - static const unsigned TIOCGETC_ = 0x40067412; - static const unsigned FIONREAD_ = 0x4004667f; - static const unsigned TIOCISATTY_ = 0x2000745e; - static const unsigned TIOCGETS_ = 0x402c7413; - static const unsigned TIOCGETA_ = 0x40127417; - static const unsigned TCSETAW_ = 0x80147419; + static const unsigned TGT_TIOCGETP = 0x40067408; + static const unsigned TGT_TIOCSETP = 0x80067409; + static const unsigned TGT_TIOCSETN = 0x8006740a; + static const unsigned TGT_TIOCSETC = 0x80067411; + static const unsigned TGT_TIOCGETC = 0x40067412; + static const unsigned TGT_FIONREAD = 0x4004667f; + static const unsigned TGT_TIOCISATTY = 0x2000745e; + static const unsigned TGT_TCGETS = 0x402c7413; + static const unsigned TGT_TCGETA = 0x40127417; + static const unsigned TGT_TCSETAW = 0x80147419; // 2.6.15 kernel //@} //@{ diff --git a/src/arch/arm/linux/linux.hh b/src/arch/arm/linux/linux.hh --- a/src/arch/arm/linux/linux.hh +++ b/src/arch/arm/linux/linux.hh @@ -100,20 +100,6 @@ static const int TGT_RUSAGE_BOTH = -2; //@} - //@{ - /// ioctl() command codes. - static const unsigned TIOCGETP_ = 0x5401; - static const unsigned TIOCSETP_ = 0x80067409; - static const unsigned TIOCSETN_ = 0x8006740a; - static const unsigned TIOCSETC_ = 0x80067411; - static const unsigned TIOCGETC_ = 0x40067412; - static const unsigned FIONREAD_ = 0x4004667f; - static const unsigned TIOCISATTY_ = 0x2000745e; - static const unsigned TIOCGETS_ = 0x402c7413; - static const unsigned TIOCGETA_ = 0x5405; - static const unsigned TCSETAW_ = 0x5407; // 2.6.15 kernel - //@} - /// For table(). static const int TBL_SYSINFO = 12; diff --git a/src/arch/mips/linux/linux.hh b/src/arch/mips/linux/linux.hh --- a/src/arch/mips/linux/linux.hh +++ b/src/arch/mips/linux/linux.hh @@ -92,16 +92,13 @@ //@{ /// ioctl() command codes. - static const unsigned TIOCGETP_ = 0x7408; - static const unsigned TIOCSETP_ = 0x7409; - static const unsigned TIOCSETN_ = 0x740a; - static const unsigned TIOCSETC_ = 0x7411; - static const unsigned TIOCGETC_ = 0x7412; - static const unsigned FIONREAD_ = 0x467f; - static const unsigned TIOCISATTY_ = 0x5480; - static const unsigned TIOCGETS_ = 0x540d; - static const unsigned TIOCGETA_ = 0x7417; - static const unsigned TCSETAW_ = 0x5403; // 2.6.15 kernel + static const unsigned TGT_TIOCGETP = 0x7408; + static const unsigned TGT_TIOCSETP = 0x7409; + static const unsigned TGT_TIOCSETN = 0x740a; + static const unsigned TGT_FIONREAD = 0x467f; + static const unsigned TGT_TCGETS = 0x540d; + static const unsigned TGT_TCGETA = 0x5401; + static const unsigned TGT_TCSETAW = 0x5403; // 2.6.15 kernel //@} /// For table(). diff --git a/src/arch/power/linux/linux.hh b/src/arch/power/linux/linux.hh --- a/src/arch/power/linux/linux.hh +++ b/src/arch/power/linux/linux.hh @@ -131,18 +131,16 @@ //@{ /// ioctl() command codes. - /// These are for the 2.6.15 kernel. Some have changed for - /// later versions. - static const unsigned TIOCGETP_ = 0x40067408; - static const unsigned TIOCSETP_ = 0x80067409; - static const unsigned TIOCSETN_ = 0x8006740a; - static const unsigned TIOCSETC_ = 0x80067411; - static const unsigned TIOCGETC_ = 0x40067412; - static const unsigned FIONREAD_ = 0x4004667f; - static const unsigned TIOCISATTY_ = 0x2000745e; - static const unsigned TIOCGETS_ = 0x402c7413; - static const unsigned TIOCGETA_ = 0x40147417; - static const unsigned TCSETAW_ = 0x80147419; + static const unsigned TGT_TIOCGETP = 0x40067408; + static const unsigned TGT_TIOCSETP = 0x80067409; + static const unsigned TGT_TIOCSETN = 0x8006740a; + static const unsigned TGT_TIOCSETC = 0x80067411; + static const unsigned TGT_TIOCGETC = 0x40067412; + static const unsigned TGT_FIONREAD = 0x4004667f; + static const unsigned TGT_TIOCISATTY = 0x2000745e; + static const unsigned TGT_TCGETS = 0x402c7413; + static const unsigned TGT_TCGETA = 0x40127417; + static const unsigned TGT_TCSETAW = 0x80147419; // 2.6.15 kernel //@} }; diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh --- a/src/arch/x86/linux/linux.hh +++ b/src/arch/x86/linux/linux.hh @@ -111,7 +111,6 @@ uint64_t freehigh; /* Available high memory size */ uint64_t mem_unit; /* Memory unit size in bytes */ } tgt_sysinfo; - }; class X86Linux32 : public Linux diff --git a/src/arch/x86/linux/syscalls.cc b/src/arch/x86/linux/syscalls.cc --- a/src/arch/x86/linux/syscalls.cc +++ b/src/arch/x86/linux/syscalls.cc @@ -229,7 +229,7 @@ /* 13 */ SyscallDesc("rt_sigaction", ignoreFunc), /* 14 */ SyscallDesc("rt_sigprocmask", ignoreFunc), /* 15 */ SyscallDesc("rt_sigreturn", unimplementedFunc), - /* 16 */ SyscallDesc("ioctl", unimplementedFunc), + /* 16 */ SyscallDesc("ioctl", ioctlFunc), /* 17 */ SyscallDesc("pread64", unimplementedFunc), /* 18 */ SyscallDesc("pwrite64", unimplementedFunc), /* 19 */ SyscallDesc("readv", unimplementedFunc), @@ -546,7 +546,7 @@ /* 51 */ SyscallDesc("acct", unimplementedFunc), /* 52 */ SyscallDesc("umount2", unimplementedFunc), /* 53 */ SyscallDesc("lock", unimplementedFunc), - /* 54 */ SyscallDesc("ioctl", unimplementedFunc), + /* 54 */ SyscallDesc("ioctl", ioctlFunc), /* 55 */ SyscallDesc("fcntl", unimplementedFunc), /* 56 */ SyscallDesc("mpx", unimplementedFunc), /* 57 */ SyscallDesc("setpgid", unimplementedFunc), diff --git a/src/kern/linux/linux.hh b/src/kern/linux/linux.hh --- a/src/kern/linux/linux.hh +++ b/src/kern/linux/linux.hh @@ -147,6 +147,14 @@ uint64_t iov_len; }; + //@{ + /// ioctl() command codes. + static const unsigned TGT_FIONREAD = 0x541B; + static const unsigned TGT_TCSETAW = 0x5407; + static const unsigned TGT_TCGETS = 0x5401; + static const unsigned TGT_TCGETA = 0x5405; + //@} + /// For getrusage(). struct rusage { diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -52,6 +52,8 @@ #include #include +#include "arch/mips/linux/linux.hh" +#include "arch/x86/linux/linux.hh" #include "base/chunk_generator.hh" #include "base/intmath.hh" // for RoundUp #include "base/misc.hh" @@ -484,6 +486,72 @@ tgt.copyOut(mem); } +template +bool +isttyReq(unsigned req) +{ + switch (req) { + case OS::TGT_TIOCISATTY: + case OS::TGT_TIOCGETP: + case OS::TGT_TIOCSETP: + case OS::TGT_TIOCSETN: + case OS::TGT_TIOCSETC: + case OS::TGT_TIOCGETC: + case OS::TGT_TIOCGETS: + case OS::TGT_TIOCGETA: + case OS::TGT_TCSETAW: + return true; + default: + return false; + } +} + +template +bool +isttyLinux(unsigned req) +{ + switch (req) { + case OS::TGT_FIONREAD: + case OS::TGT_TCSETAW: + case OS::TGT_TCGETS: + case OS::TGT_TCGETA: + return true; + default: + return false; + } +} + +template <> inline +bool +isttyReq(unsigned req) +{ + return isttyLinux(req); +} + +template <> inline +bool +isttyReq(unsigned req) +{ + return isttyLinux(req); +} + +template <> inline +bool +isttyReq(unsigned req) +{ + switch (req) { + case MipsLinux::TGT_TIOCGETP: + case MipsLinux::TGT_TIOCSETP: + case MipsLinux::TGT_TIOCSETN: + case MipsLinux::TGT_TCGETS: + case MipsLinux::TGT_TCGETA: + case MipsLinux::TGT_TCSETAW: + return true; + default: + return false; + } +} + /// Target ioctl() handler. For the most part, programs call ioctl() /// only to find out if their stdout is a tty, to determine whether to /// do line or block buffering. @@ -503,22 +571,12 @@ return -EBADF; } - switch (req) { - case OS::TIOCISATTY_: - case OS::TIOCGETP_: - case OS::TIOCSETP_: - case OS::TIOCSETN_: - case OS::TIOCSETC_: - case OS::TIOCGETC_: - case OS::TIOCGETS_: - case OS::TIOCGETA_: - case OS::TCSETAW_: + + if(isttyReq(req)) { return -ENOTTY; - - default: - fatal("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n", - fd, req, tc->pcState()); } + fatal("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ \n", + fd, req, tc->pcState()); } /// Target open() handler.