linux.hh (9141:593fe25c86a6) linux.hh (9146:a61fdbbc1d45)
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * Copyright (c) 2007-2008 The Florida State University
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Ali Saidi
42 * Stephen Hines
43 */
44
45#ifndef __ARCH_ARM_LINUX_LINUX_HH__
46#define __ARCH_ARM_LINUX_LINUX_HH__
47
48#include "kern/linux/linux.hh"
49
50class ArmLinux : public Linux
51{
52 public:
53
54 /// This table maps the target open() flags to the corresponding
55 /// host open() flags.
56 static OpenFlagTransTable openFlagTable[];
57
58 /// Number of entries in openFlagTable[].
59 static const int NUM_OPEN_FLAGS;
60
61 //@{
62 /// Basic ARM Linux types
63 typedef uint32_t size_t;
64 typedef uint32_t off_t;
65 typedef int32_t time_t;
66 typedef int32_t clock_t;
67 //@}
68
69 //@{
70 /// open(2) flag values.
71 static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
72 static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
73 static const int TGT_O_RDWR = 00000002; //!< O_RDWR
74 static const int TGT_O_CREAT = 00000100; //!< O_CREAT
75 static const int TGT_O_EXCL = 00000200; //!< O_EXCL
76 static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
77 static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
78 static const int TGT_O_APPEND = 00002000; //!< O_APPEND
79 static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
80 static const int TGT_O_SYNC = 00010000; //!< O_SYNC
81 static const int TGT_FASYNC = 00020000; //!< FASYNC
82 static const int TGT_O_DIRECT = 00040000; //!< O_DIRECT
83 static const int TGT_O_LARGEFILE = 00100000; //!< O_LARGEFILE
84 static const int TGT_O_DIRECTORY = 00200000; //!< O_DIRECTORY
85 static const int TGT_O_NOFOLLOW = 00400000; //!< O_NOFOLLOW
86 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME
87 static const int TGT_O_CLOEXEC = 02000000; //!< O_NOATIME
88
89
90 //@}
91
92 /// For mmap().
93 static const unsigned TGT_MAP_ANONYMOUS = 0x20;
94 static const unsigned TGT_MAP_FIXED = 0x10;
95
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * Copyright (c) 2007-2008 The Florida State University
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Ali Saidi
42 * Stephen Hines
43 */
44
45#ifndef __ARCH_ARM_LINUX_LINUX_HH__
46#define __ARCH_ARM_LINUX_LINUX_HH__
47
48#include "kern/linux/linux.hh"
49
50class ArmLinux : public Linux
51{
52 public:
53
54 /// This table maps the target open() flags to the corresponding
55 /// host open() flags.
56 static OpenFlagTransTable openFlagTable[];
57
58 /// Number of entries in openFlagTable[].
59 static const int NUM_OPEN_FLAGS;
60
61 //@{
62 /// Basic ARM Linux types
63 typedef uint32_t size_t;
64 typedef uint32_t off_t;
65 typedef int32_t time_t;
66 typedef int32_t clock_t;
67 //@}
68
69 //@{
70 /// open(2) flag values.
71 static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
72 static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
73 static const int TGT_O_RDWR = 00000002; //!< O_RDWR
74 static const int TGT_O_CREAT = 00000100; //!< O_CREAT
75 static const int TGT_O_EXCL = 00000200; //!< O_EXCL
76 static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY
77 static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC
78 static const int TGT_O_APPEND = 00002000; //!< O_APPEND
79 static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK
80 static const int TGT_O_SYNC = 00010000; //!< O_SYNC
81 static const int TGT_FASYNC = 00020000; //!< FASYNC
82 static const int TGT_O_DIRECT = 00040000; //!< O_DIRECT
83 static const int TGT_O_LARGEFILE = 00100000; //!< O_LARGEFILE
84 static const int TGT_O_DIRECTORY = 00200000; //!< O_DIRECTORY
85 static const int TGT_O_NOFOLLOW = 00400000; //!< O_NOFOLLOW
86 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME
87 static const int TGT_O_CLOEXEC = 02000000; //!< O_NOATIME
88
89
90 //@}
91
92 /// For mmap().
93 static const unsigned TGT_MAP_ANONYMOUS = 0x20;
94 static const unsigned TGT_MAP_FIXED = 0x10;
95
96 //@{
97 /// For getrusage().
98 static const int TGT_RUSAGE_SELF = 0;
99 static const int TGT_RUSAGE_CHILDREN = -1;
100 static const int TGT_RUSAGE_BOTH = -2;
101 //@}
102
103 /// For table().
104 static const int TBL_SYSINFO = 12;
105
96 /// For table().
97 static const int TBL_SYSINFO = 12;
98
106 /// Resource enumeration for getrlimit().
107 enum rlimit_resources {
108 TGT_RLIMIT_CPU = 0,
109 TGT_RLIMIT_FSIZE = 1,
110 TGT_RLIMIT_DATA = 2,
111 TGT_RLIMIT_STACK = 3,
112 TGT_RLIMIT_CORE = 4,
113 TGT_RLIMIT_RSS = 5,
114 TGT_RLIMIT_NPROC = 6,
115 TGT_RLIMIT_NOFILE = 7,
116 TGT_RLIMIT_MEMLOCK = 8,
117 TGT_RLIMIT_AS = 9,
118 TGT_RLIMIT_LOCKS = 10
119 };
120
121 /// Limit struct for getrlimit/setrlimit.
122 struct rlimit {
123 uint32_t rlim_cur; //!< soft limit
124 uint32_t rlim_max; //!< hard limit
125 };
126
127 /// For gettimeofday().
128 struct timeval {
129 int32_t tv_sec; //!< seconds
130 int32_t tv_usec; //!< microseconds
131 };
132
133 // For writev/readv
134 struct tgt_iovec {
135 uint32_t iov_base; // void *
136 uint32_t iov_len;
137 };
138
139
140 typedef struct {
141 uint32_t st_dev;
142 uint32_t st_ino;
143 uint16_t st_mode;
144 uint16_t st_nlink;
145 uint16_t st_uid;
146 uint16_t st_gid;
147 uint32_t st_rdev;
148 uint32_t st_size;
149 uint32_t st_blksize;
150 uint32_t st_blocks;
151 uint32_t st_atimeX;
152 uint32_t st_atime_nsec;
153 uint32_t st_mtimeX;
154 uint32_t st_mtime_nsec;
155 uint32_t st_ctimeX;
156 uint32_t st_ctime_nsec;
157 } tgt_stat;
158
159 typedef struct {
160 uint64_t st_dev;
161 uint8_t __pad0[4];
162 uint32_t __st_ino;
163 uint32_t st_mode;
164 uint32_t st_nlink;
165 uint32_t st_uid;
166 uint32_t st_gid;
167 uint64_t st_rdev;
168 uint8_t __pad3[4];
169 int64_t __attribute__ ((aligned (8))) st_size;
170 uint32_t st_blksize;
171 uint64_t __attribute__ ((aligned (8))) st_blocks;
172 uint32_t st_atimeX;
173 uint32_t st_atime_nsec;
174 uint32_t st_mtimeX;
175 uint32_t st_mtime_nsec;
176 uint32_t st_ctimeX;
177 uint32_t st_ctime_nsec;
178 uint64_t st_ino;
179 } tgt_stat64;
180
181 typedef struct {
182 int32_t uptime; /* Seconds since boot */
183 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
184 uint32_t totalram; /* Total usable main memory size */
185 uint32_t freeram; /* Available memory size */
186 uint32_t sharedram; /* Amount of shared memory */
187 uint32_t bufferram; /* Memory used by buffers */
188 uint32_t totalswap; /* Total swap space size */
189 uint32_t freeswap; /* swap space still available */
190 uint16_t procs; /* Number of current processes */
191 uint32_t totalhigh; /* Total high memory size */
192 uint32_t freehigh; /* Available high memory size */
193 uint32_t mem_unit; /* Memory unit size in bytes */
194 } tgt_sysinfo;
195
196 /// For getrusage().
197 struct rusage {
198 struct timeval ru_utime; //!< user time used
199 struct timeval ru_stime; //!< system time used
200 int32_t ru_maxrss; //!< max rss
201 int32_t ru_ixrss; //!< integral shared memory size
202 int32_t ru_idrss; //!< integral unshared data "
203 int32_t ru_isrss; //!< integral unshared stack "
204 int32_t ru_minflt; //!< page reclaims - total vmfaults
205 int32_t ru_majflt; //!< page faults
206 int32_t ru_nswap; //!< swaps
207 int32_t ru_inblock; //!< block input operations
208 int32_t ru_oublock; //!< block output operations
209 int32_t ru_msgsnd; //!< messages sent
210 int32_t ru_msgrcv; //!< messages received
211 int32_t ru_nsignals; //!< signals received
212 int32_t ru_nvcsw; //!< voluntary context switches
213 int32_t ru_nivcsw; //!< involuntary "
214 };
215
216 /// For times().
217 struct tms {
218 int32_t tms_utime; //!< user time
219 int32_t tms_stime; //!< system time
220 int32_t tms_cutime; //!< user time of children
221 int32_t tms_cstime; //!< system time of children
222 };
223
224
225};
226
227#endif
99 /// Limit struct for getrlimit/setrlimit.
100 struct rlimit {
101 uint32_t rlim_cur; //!< soft limit
102 uint32_t rlim_max; //!< hard limit
103 };
104
105 /// For gettimeofday().
106 struct timeval {
107 int32_t tv_sec; //!< seconds
108 int32_t tv_usec; //!< microseconds
109 };
110
111 // For writev/readv
112 struct tgt_iovec {
113 uint32_t iov_base; // void *
114 uint32_t iov_len;
115 };
116
117
118 typedef struct {
119 uint32_t st_dev;
120 uint32_t st_ino;
121 uint16_t st_mode;
122 uint16_t st_nlink;
123 uint16_t st_uid;
124 uint16_t st_gid;
125 uint32_t st_rdev;
126 uint32_t st_size;
127 uint32_t st_blksize;
128 uint32_t st_blocks;
129 uint32_t st_atimeX;
130 uint32_t st_atime_nsec;
131 uint32_t st_mtimeX;
132 uint32_t st_mtime_nsec;
133 uint32_t st_ctimeX;
134 uint32_t st_ctime_nsec;
135 } tgt_stat;
136
137 typedef struct {
138 uint64_t st_dev;
139 uint8_t __pad0[4];
140 uint32_t __st_ino;
141 uint32_t st_mode;
142 uint32_t st_nlink;
143 uint32_t st_uid;
144 uint32_t st_gid;
145 uint64_t st_rdev;
146 uint8_t __pad3[4];
147 int64_t __attribute__ ((aligned (8))) st_size;
148 uint32_t st_blksize;
149 uint64_t __attribute__ ((aligned (8))) st_blocks;
150 uint32_t st_atimeX;
151 uint32_t st_atime_nsec;
152 uint32_t st_mtimeX;
153 uint32_t st_mtime_nsec;
154 uint32_t st_ctimeX;
155 uint32_t st_ctime_nsec;
156 uint64_t st_ino;
157 } tgt_stat64;
158
159 typedef struct {
160 int32_t uptime; /* Seconds since boot */
161 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
162 uint32_t totalram; /* Total usable main memory size */
163 uint32_t freeram; /* Available memory size */
164 uint32_t sharedram; /* Amount of shared memory */
165 uint32_t bufferram; /* Memory used by buffers */
166 uint32_t totalswap; /* Total swap space size */
167 uint32_t freeswap; /* swap space still available */
168 uint16_t procs; /* Number of current processes */
169 uint32_t totalhigh; /* Total high memory size */
170 uint32_t freehigh; /* Available high memory size */
171 uint32_t mem_unit; /* Memory unit size in bytes */
172 } tgt_sysinfo;
173
174 /// For getrusage().
175 struct rusage {
176 struct timeval ru_utime; //!< user time used
177 struct timeval ru_stime; //!< system time used
178 int32_t ru_maxrss; //!< max rss
179 int32_t ru_ixrss; //!< integral shared memory size
180 int32_t ru_idrss; //!< integral unshared data "
181 int32_t ru_isrss; //!< integral unshared stack "
182 int32_t ru_minflt; //!< page reclaims - total vmfaults
183 int32_t ru_majflt; //!< page faults
184 int32_t ru_nswap; //!< swaps
185 int32_t ru_inblock; //!< block input operations
186 int32_t ru_oublock; //!< block output operations
187 int32_t ru_msgsnd; //!< messages sent
188 int32_t ru_msgrcv; //!< messages received
189 int32_t ru_nsignals; //!< signals received
190 int32_t ru_nvcsw; //!< voluntary context switches
191 int32_t ru_nivcsw; //!< involuntary "
192 };
193
194 /// For times().
195 struct tms {
196 int32_t tms_utime; //!< user time
197 int32_t tms_stime; //!< system time
198 int32_t tms_cutime; //!< user time of children
199 int32_t tms_cstime; //!< system time of children
200 };
201
202
203};
204
205#endif