linux.hh (8600:b0d7c64ada19) linux.hh (9141:593fe25c86a6)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2009 The University of Edinburgh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Timothy M. Jones
30 */
31
32#ifndef __ARCH_POWER_LINUX_LINUX_HH__
33#define __ARCH_POWER_LINUX_LINUX_HH__
34
35#include "kern/linux/linux.hh"
36
37/*
38 * This works for a 2.6.15 kernel.
39 */
40
41class PowerLinux : public Linux
42{
43 public:
44
45 typedef int32_t time_t;
46
47 typedef struct {
48 uint64_t st_dev;
49 uint32_t __pad1;
50 uint32_t st_ino;
51 uint32_t st_mode;
52 uint32_t st_nlink;
53 uint32_t st_uid;
54 uint32_t st_gid;
55 uint64_t st_rdev;
56 uint32_t __pad2;
57 uint32_t st_size;
58 uint32_t st_blksize;
59 uint32_t st_blocks;
60 uint32_t st_atimeX;
61 uint32_t st_atime_nsec;
62 uint32_t st_mtimeX;
63 uint32_t st_mtime_nsec;
64 uint32_t st_ctimeX;
65 uint32_t st_ctime_nsec;
66 uint32_t __unused4;
67 uint32_t __unused5;
68 } tgt_stat;
69
70 typedef struct {
71 uint64_t st_dev;
72 uint64_t st_ino;
73 uint32_t st_mode;
74 uint32_t st_nlink;
75 uint32_t st_uid;
76 uint32_t st_gid;
77 uint64_t st_rdev;
78 uint64_t __pad2;
79 uint64_t st_size;
80 uint32_t st_blksize;
81 uint32_t __blksize_pad;
82 uint64_t st_blocks;
83 uint32_t st_atimeX;
84 uint32_t st_atime_nsec;
85 uint32_t st_mtimeX;
86 uint32_t st_mtime_nsec;
87 uint32_t st_ctimeX;
88 uint32_t st_ctime_nsec;
89 uint32_t __unused4;
90 uint32_t __unused5;
91 } tgt_stat64;
92
93 /// For times().
94 struct tms {
95 int32_t tms_utime; //!< user time
96 int32_t tms_stime; //!< system time
97 int32_t tms_cutime; //!< user time of children
98 int32_t tms_cstime; //!< system time of children
99 };
100
101 /// This table maps the target open() flags to the corresponding
102 /// host open() flags.
103 static OpenFlagTransTable openFlagTable[];
104
105 /// Number of entries in openFlagTable[].
106 static const int NUM_OPEN_FLAGS;
107
108 //@{
109 /// open(2) flag values.
110 static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
111 static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
112 static const int TGT_O_RDWR = 00000002; //!< O_RDWR
113 static const int TGT_O_CREAT = 00000100; //!< O_CREAT
114 static const int TGT_O_EXCL = 00000200; //!< O_EXCL
115 static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
116 static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
117 static const int TGT_O_APPEND = 00002000; //!< O_APPEND
118 static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
119 static const int TGT_O_SYNC = 00010000; //!< O_SYNC
120 static const int TGT_FASYNC = 00020000; //!< FASYNC
121 static const int TGT_O_DIRECTORY = 00040000; //!< O_DIRECTORY
122 static const int TGT_O_NOFOLLOW = 00100000; //!< O_NOFOLLOW
123 static const int TGT_O_LARGEFILE = 00200000; //!< O_LARGEFILE
124 static const int TGT_O_DIRECT = 00400000; //!< O_DIRECT
125 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME
126 //@}
127
128 /// For mmap().
129 static const unsigned TGT_MAP_ANONYMOUS = 0x20;
130 static const unsigned TGT_MAP_FIXED = 0x10;
131
132 //@{
133 /// ioctl() command codes.
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2009 The University of Edinburgh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Timothy M. Jones
30 */
31
32#ifndef __ARCH_POWER_LINUX_LINUX_HH__
33#define __ARCH_POWER_LINUX_LINUX_HH__
34
35#include "kern/linux/linux.hh"
36
37/*
38 * This works for a 2.6.15 kernel.
39 */
40
41class PowerLinux : public Linux
42{
43 public:
44
45 typedef int32_t time_t;
46
47 typedef struct {
48 uint64_t st_dev;
49 uint32_t __pad1;
50 uint32_t st_ino;
51 uint32_t st_mode;
52 uint32_t st_nlink;
53 uint32_t st_uid;
54 uint32_t st_gid;
55 uint64_t st_rdev;
56 uint32_t __pad2;
57 uint32_t st_size;
58 uint32_t st_blksize;
59 uint32_t st_blocks;
60 uint32_t st_atimeX;
61 uint32_t st_atime_nsec;
62 uint32_t st_mtimeX;
63 uint32_t st_mtime_nsec;
64 uint32_t st_ctimeX;
65 uint32_t st_ctime_nsec;
66 uint32_t __unused4;
67 uint32_t __unused5;
68 } tgt_stat;
69
70 typedef struct {
71 uint64_t st_dev;
72 uint64_t st_ino;
73 uint32_t st_mode;
74 uint32_t st_nlink;
75 uint32_t st_uid;
76 uint32_t st_gid;
77 uint64_t st_rdev;
78 uint64_t __pad2;
79 uint64_t st_size;
80 uint32_t st_blksize;
81 uint32_t __blksize_pad;
82 uint64_t st_blocks;
83 uint32_t st_atimeX;
84 uint32_t st_atime_nsec;
85 uint32_t st_mtimeX;
86 uint32_t st_mtime_nsec;
87 uint32_t st_ctimeX;
88 uint32_t st_ctime_nsec;
89 uint32_t __unused4;
90 uint32_t __unused5;
91 } tgt_stat64;
92
93 /// For times().
94 struct tms {
95 int32_t tms_utime; //!< user time
96 int32_t tms_stime; //!< system time
97 int32_t tms_cutime; //!< user time of children
98 int32_t tms_cstime; //!< system time of children
99 };
100
101 /// This table maps the target open() flags to the corresponding
102 /// host open() flags.
103 static OpenFlagTransTable openFlagTable[];
104
105 /// Number of entries in openFlagTable[].
106 static const int NUM_OPEN_FLAGS;
107
108 //@{
109 /// open(2) flag values.
110 static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
111 static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
112 static const int TGT_O_RDWR = 00000002; //!< O_RDWR
113 static const int TGT_O_CREAT = 00000100; //!< O_CREAT
114 static const int TGT_O_EXCL = 00000200; //!< O_EXCL
115 static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
116 static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
117 static const int TGT_O_APPEND = 00002000; //!< O_APPEND
118 static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
119 static const int TGT_O_SYNC = 00010000; //!< O_SYNC
120 static const int TGT_FASYNC = 00020000; //!< FASYNC
121 static const int TGT_O_DIRECTORY = 00040000; //!< O_DIRECTORY
122 static const int TGT_O_NOFOLLOW = 00100000; //!< O_NOFOLLOW
123 static const int TGT_O_LARGEFILE = 00200000; //!< O_LARGEFILE
124 static const int TGT_O_DIRECT = 00400000; //!< O_DIRECT
125 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME
126 //@}
127
128 /// For mmap().
129 static const unsigned TGT_MAP_ANONYMOUS = 0x20;
130 static const unsigned TGT_MAP_FIXED = 0x10;
131
132 //@{
133 /// ioctl() command codes.
134 /// These are for the 2.6.15 kernel. Some have changed for
135 /// later versions.
136 static const unsigned TIOCGETP_ = 0x40067408;
137 static const unsigned TIOCSETP_ = 0x80067409;
138 static const unsigned TIOCSETN_ = 0x8006740a;
139 static const unsigned TIOCSETC_ = 0x80067411;
140 static const unsigned TIOCGETC_ = 0x40067412;
141 static const unsigned FIONREAD_ = 0x4004667f;
142 static const unsigned TIOCISATTY_ = 0x2000745e;
143 static const unsigned TIOCGETS_ = 0x402c7413;
144 static const unsigned TIOCGETA_ = 0x40147417;
145 static const unsigned TCSETAW_ = 0x80147419;
134 static const unsigned TGT_TIOCGETP = 0x40067408;
135 static const unsigned TGT_TIOCSETP = 0x80067409;
136 static const unsigned TGT_TIOCSETN = 0x8006740a;
137 static const unsigned TGT_TIOCSETC = 0x80067411;
138 static const unsigned TGT_TIOCGETC = 0x40067412;
139 static const unsigned TGT_FIONREAD = 0x4004667f;
140 static const unsigned TGT_TCGETS = 0x402c7413;
141 static const unsigned TGT_TCGETA = 0x40127417;
142 static const unsigned TGT_TCSETAW = 0x80147419; // 2.6.15 kernel
146 //@}
143 //@}
144
145 static bool
146 isTtyReq(unsigned req)
147 {
148 switch (req) {
149 case TGT_TIOCGETP:
150 case TGT_TIOCSETP:
151 case TGT_TIOCSETN:
152 case TGT_TIOCSETC:
153 case TGT_TIOCGETC:
154 case TGT_TCGETS:
155 case TGT_TCGETA:
156 case TGT_TCSETAW:
157 return true;
158 default:
159 return false;
160 }
161 }
147};
148
149#endif // __ARCH_POWER_LINUX_LINUX_HH__
162};
163
164#endif // __ARCH_POWER_LINUX_LINUX_HH__