2 * Copyright (c) 2010 ARM Limited
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.
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.
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.
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.
45 #ifndef __ARCH_ARM_LINUX_LINUX_HH__
46 #define __ARCH_ARM_LINUX_LINUX_HH__
48 #include "kern/linux/linux.hh"
50 class ArmLinux : public Linux
54 /// This table maps the target open() flags to the corresponding
55 /// host open() flags.
56 static OpenFlagTransTable openFlagTable[];
58 /// Number of entries in openFlagTable[].
59 static const int NUM_OPEN_FLAGS;
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;
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
93 static const unsigned TGT_MAP_ANONYMOUS = 0x20;
97 static const int TGT_RUSAGE_SELF = 0;
98 static const int TGT_RUSAGE_CHILDREN = -1;
99 static const int TGT_RUSAGE_BOTH = -2;
103 /// ioctl() command codes.
104 static const unsigned TIOCGETP_ = 0x5401;
105 static const unsigned TIOCSETP_ = 0x80067409;
106 static const unsigned TIOCSETN_ = 0x8006740a;
107 static const unsigned TIOCSETC_ = 0x80067411;
108 static const unsigned TIOCGETC_ = 0x40067412;
109 static const unsigned FIONREAD_ = 0x4004667f;
110 static const unsigned TIOCISATTY_ = 0x2000745e;
111 static const unsigned TIOCGETS_ = 0x402c7413;
112 static const unsigned TIOCGETA_ = 0x5405;
113 static const unsigned TCSETAW_ = 0x5407; // 2.6.15 kernel
117 static const int TBL_SYSINFO = 12;
119 /// Resource enumeration for getrlimit().
120 enum rlimit_resources {
122 TGT_RLIMIT_FSIZE = 1,
124 TGT_RLIMIT_STACK = 3,
127 TGT_RLIMIT_NPROC = 6,
128 TGT_RLIMIT_NOFILE = 7,
129 TGT_RLIMIT_MEMLOCK = 8,
131 TGT_RLIMIT_LOCKS = 10
134 /// Limit struct for getrlimit/setrlimit.
136 uint32_t rlim_cur; //!< soft limit
137 uint32_t rlim_max; //!< hard limit
140 /// For gettimeofday().
142 int32_t tv_sec; //!< seconds
143 int32_t tv_usec; //!< microseconds
148 uint32_t iov_base; // void *
165 uint32_t st_atime_nsec;
167 uint32_t st_mtime_nsec;
169 uint32_t st_ctime_nsec;
182 int64_t __attribute__ ((aligned (8))) st_size;
184 uint64_t __attribute__ ((aligned (8))) st_blocks;
186 uint32_t st_atime_nsec;
188 uint32_t st_mtime_nsec;
190 uint32_t st_ctime_nsec;
195 int32_t uptime; /* Seconds since boot */
196 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
197 uint32_t totalram; /* Total usable main memory size */
198 uint32_t freeram; /* Available memory size */
199 uint32_t sharedram; /* Amount of shared memory */
200 uint32_t bufferram; /* Memory used by buffers */
201 uint32_t totalswap; /* Total swap space size */
202 uint32_t freeswap; /* swap space still available */
203 uint16_t procs; /* Number of current processes */
204 uint32_t totalhigh; /* Total high memory size */
205 uint32_t freehigh; /* Available high memory size */
206 uint32_t mem_unit; /* Memory unit size in bytes */
211 struct timeval ru_utime; //!< user time used
212 struct timeval ru_stime; //!< system time used
213 int32_t ru_maxrss; //!< max rss
214 int32_t ru_ixrss; //!< integral shared memory size
215 int32_t ru_idrss; //!< integral unshared data "
216 int32_t ru_isrss; //!< integral unshared stack "
217 int32_t ru_minflt; //!< page reclaims - total vmfaults
218 int32_t ru_majflt; //!< page faults
219 int32_t ru_nswap; //!< swaps
220 int32_t ru_inblock; //!< block input operations
221 int32_t ru_oublock; //!< block output operations
222 int32_t ru_msgsnd; //!< messages sent
223 int32_t ru_msgrcv; //!< messages received
224 int32_t ru_nsignals; //!< signals received
225 int32_t ru_nvcsw; //!< voluntary context switches
226 int32_t ru_nivcsw; //!< involuntary "
231 int32_t tms_utime; //!< user time
232 int32_t tms_stime; //!< system time
233 int32_t tms_cutime; //!< user time of children
234 int32_t tms_cstime; //!< system time of children