1/*
| 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 *
|
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * Copyright (c) 2007-2008 The Florida State University 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 *
| 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 *
|
29 * Authors: Stephen Hines
| 41 * Authors: Ali Saidi 42 * Stephen Hines
|
30 */ 31 32#ifndef __ARCH_ARM_LINUX_LINUX_HH__ 33#define __ARCH_ARM_LINUX_LINUX_HH__ 34 35#include "kern/linux/linux.hh" 36 37class ArmLinux : public Linux 38{ 39 public: 40 41 /// This table maps the target open() flags to the corresponding 42 /// host open() flags. 43 static OpenFlagTransTable openFlagTable[]; 44 45 /// Number of entries in openFlagTable[]. 46 static const int NUM_OPEN_FLAGS; 47 48 //@{
| 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 //@{
|
49 /// open(2) flag values. 50 static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY 51 static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY 52 static const int TGT_O_RDWR = 00000002; //!< O_RDWR 53 static const int TGT_O_CREAT = 00000100; //!< O_CREAT 54 static const int TGT_O_EXCL = 00000200; //!< O_EXCL 55 static const int TGT_O_NOCTTY = 00000400; //!< O_NOCTTY 56 static const int TGT_O_TRUNC = 00001000; //!< O_TRUNC 57 static const int TGT_O_APPEND = 00002000; //!< O_APPEND 58 static const int TGT_O_NONBLOCK = 00004000; //!< O_NONBLOCK 59 static const int TGT_O_SYNC = 00010000; //!< O_SYNC 60 static const int TGT_FASYNC = 00020000; //!< FASYNC 61 static const int TGT_O_DIRECTORY = 00040000; //!< O_DIRECTORY 62 static const int TGT_O_NOFOLLOW = 00100000; //!< O_NOFOLLOW 63 static const int TGT_O_DIRECT = 00200000; //!< O_DIRECT 64 static const int TGT_O_LARGEFILE = 00400000; //!< O_LARGEFILE 65 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME 66 //@} 67 68 /// For mmap(). 69 static const unsigned TGT_MAP_ANONYMOUS = 0x20; 70 71 //@{ 72 /// For getrusage(). 73 static const int TGT_RUSAGE_SELF = 0; 74 static const int TGT_RUSAGE_CHILDREN = -1; 75 static const int TGT_RUSAGE_BOTH = -2; 76 //@} 77 78 //@{ 79 /// ioctl() command codes. 80 static const unsigned TIOCGETP_ = 0x5401; 81 static const unsigned TIOCSETP_ = 0x80067409; 82 static const unsigned TIOCSETN_ = 0x8006740a; 83 static const unsigned TIOCSETC_ = 0x80067411; 84 static const unsigned TIOCGETC_ = 0x40067412; 85 static const unsigned FIONREAD_ = 0x4004667f; 86 static const unsigned TIOCISATTY_ = 0x2000745e; 87 static const unsigned TIOCGETS_ = 0x402c7413; 88 static const unsigned TIOCGETA_ = 0x40127417; 89 static const unsigned TCSETAW_ = 0x5407; // 2.6.15 kernel 90 //@} 91 92 /// For table(). 93 static const int TBL_SYSINFO = 12; 94 95 /// Resource enumeration for getrlimit(). 96 enum rlimit_resources { 97 TGT_RLIMIT_CPU = 0, 98 TGT_RLIMIT_FSIZE = 1, 99 TGT_RLIMIT_DATA = 2, 100 TGT_RLIMIT_STACK = 3, 101 TGT_RLIMIT_CORE = 4, 102 TGT_RLIMIT_RSS = 5, 103 TGT_RLIMIT_NPROC = 6, 104 TGT_RLIMIT_NOFILE = 7, 105 TGT_RLIMIT_MEMLOCK = 8, 106 TGT_RLIMIT_AS = 9, 107 TGT_RLIMIT_LOCKS = 10 108 }; 109
| 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_DIRECTORY = 00040000; //!< O_DIRECTORY 83 static const int TGT_O_NOFOLLOW = 00100000; //!< O_NOFOLLOW 84 static const int TGT_O_DIRECT = 00200000; //!< O_DIRECT 85 static const int TGT_O_LARGEFILE = 00400000; //!< O_LARGEFILE 86 static const int TGT_O_NOATIME = 01000000; //!< O_NOATIME 87 //@} 88 89 /// For mmap(). 90 static const unsigned TGT_MAP_ANONYMOUS = 0x20; 91 92 //@{ 93 /// For getrusage(). 94 static const int TGT_RUSAGE_SELF = 0; 95 static const int TGT_RUSAGE_CHILDREN = -1; 96 static const int TGT_RUSAGE_BOTH = -2; 97 //@} 98 99 //@{ 100 /// ioctl() command codes. 101 static const unsigned TIOCGETP_ = 0x5401; 102 static const unsigned TIOCSETP_ = 0x80067409; 103 static const unsigned TIOCSETN_ = 0x8006740a; 104 static const unsigned TIOCSETC_ = 0x80067411; 105 static const unsigned TIOCGETC_ = 0x40067412; 106 static const unsigned FIONREAD_ = 0x4004667f; 107 static const unsigned TIOCISATTY_ = 0x2000745e; 108 static const unsigned TIOCGETS_ = 0x402c7413; 109 static const unsigned TIOCGETA_ = 0x40127417; 110 static const unsigned TCSETAW_ = 0x5407; // 2.6.15 kernel 111 //@} 112 113 /// For table(). 114 static const int TBL_SYSINFO = 12; 115 116 /// Resource enumeration for getrlimit(). 117 enum rlimit_resources { 118 TGT_RLIMIT_CPU = 0, 119 TGT_RLIMIT_FSIZE = 1, 120 TGT_RLIMIT_DATA = 2, 121 TGT_RLIMIT_STACK = 3, 122 TGT_RLIMIT_CORE = 4, 123 TGT_RLIMIT_RSS = 5, 124 TGT_RLIMIT_NPROC = 6, 125 TGT_RLIMIT_NOFILE = 7, 126 TGT_RLIMIT_MEMLOCK = 8, 127 TGT_RLIMIT_AS = 9, 128 TGT_RLIMIT_LOCKS = 10 129 }; 130
|
| 131 /// Limit struct for getrlimit/setrlimit. 132 struct rlimit { 133 uint32_t rlim_cur; //!< soft limit 134 uint32_t rlim_max; //!< hard limit 135 }; 136 137 /// For gettimeofday(). 138 struct timeval { 139 int32_t tv_sec; //!< seconds 140 int32_t tv_usec; //!< microseconds 141 }; 142 143 // For writev/readv 144 struct tgt_iovec { 145 uint32_t iov_base; // void * 146 uint32_t iov_len; 147 }; 148 149
|
110 typedef struct { 111 uint32_t st_dev; 112 uint32_t st_ino; 113 uint16_t st_mode; 114 uint16_t st_nlink; 115 uint16_t st_uid; 116 uint16_t st_gid; 117 uint32_t st_rdev; 118 uint32_t st_size; 119 uint32_t st_blksize; 120 uint32_t st_blocks; 121 uint32_t st_atimeX; 122 uint32_t st_atime_nsec; 123 uint32_t st_mtimeX; 124 uint32_t st_mtime_nsec; 125 uint32_t st_ctimeX; 126 uint32_t st_ctime_nsec; 127 } tgt_stat; 128 129 typedef struct { 130 uint64_t st_dev; 131 uint8_t __pad0[4]; 132 uint32_t __st_ino; 133 uint32_t st_mode; 134 uint32_t st_nlink; 135 uint32_t st_uid; 136 uint32_t st_gid; 137 uint64_t st_rdev; 138 uint8_t __pad3[4]; 139 int64_t __attribute__ ((aligned (8))) st_size; 140 uint32_t st_blksize; 141 uint64_t __attribute__ ((aligned (8))) st_blocks; 142 uint32_t st_atimeX; 143 uint32_t st_atime_nsec; 144 uint32_t st_mtimeX; 145 uint32_t st_mtime_nsec; 146 uint32_t st_ctimeX; 147 uint32_t st_ctime_nsec; 148 uint64_t st_ino; 149 } tgt_stat64; 150 151 typedef struct { 152 int32_t uptime; /* Seconds since boot */ 153 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */ 154 uint32_t totalram; /* Total usable main memory size */ 155 uint32_t freeram; /* Available memory size */ 156 uint32_t sharedram; /* Amount of shared memory */ 157 uint32_t bufferram; /* Memory used by buffers */ 158 uint32_t totalswap; /* Total swap space size */ 159 uint32_t freeswap; /* swap space still available */ 160 uint16_t procs; /* Number of current processes */ 161 uint32_t totalhigh; /* Total high memory size */ 162 uint32_t freehigh; /* Available high memory size */ 163 uint32_t mem_unit; /* Memory unit size in bytes */ 164 } tgt_sysinfo; 165
| 150 typedef struct { 151 uint32_t st_dev; 152 uint32_t st_ino; 153 uint16_t st_mode; 154 uint16_t st_nlink; 155 uint16_t st_uid; 156 uint16_t st_gid; 157 uint32_t st_rdev; 158 uint32_t st_size; 159 uint32_t st_blksize; 160 uint32_t st_blocks; 161 uint32_t st_atimeX; 162 uint32_t st_atime_nsec; 163 uint32_t st_mtimeX; 164 uint32_t st_mtime_nsec; 165 uint32_t st_ctimeX; 166 uint32_t st_ctime_nsec; 167 } tgt_stat; 168 169 typedef struct { 170 uint64_t st_dev; 171 uint8_t __pad0[4]; 172 uint32_t __st_ino; 173 uint32_t st_mode; 174 uint32_t st_nlink; 175 uint32_t st_uid; 176 uint32_t st_gid; 177 uint64_t st_rdev; 178 uint8_t __pad3[4]; 179 int64_t __attribute__ ((aligned (8))) st_size; 180 uint32_t st_blksize; 181 uint64_t __attribute__ ((aligned (8))) st_blocks; 182 uint32_t st_atimeX; 183 uint32_t st_atime_nsec; 184 uint32_t st_mtimeX; 185 uint32_t st_mtime_nsec; 186 uint32_t st_ctimeX; 187 uint32_t st_ctime_nsec; 188 uint64_t st_ino; 189 } tgt_stat64; 190 191 typedef struct { 192 int32_t uptime; /* Seconds since boot */ 193 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */ 194 uint32_t totalram; /* Total usable main memory size */ 195 uint32_t freeram; /* Available memory size */ 196 uint32_t sharedram; /* Amount of shared memory */ 197 uint32_t bufferram; /* Memory used by buffers */ 198 uint32_t totalswap; /* Total swap space size */ 199 uint32_t freeswap; /* swap space still available */ 200 uint16_t procs; /* Number of current processes */ 201 uint32_t totalhigh; /* Total high memory size */ 202 uint32_t freehigh; /* Available high memory size */ 203 uint32_t mem_unit; /* Memory unit size in bytes */ 204 } tgt_sysinfo; 205
|
| 206 /// For getrusage(). 207 struct rusage { 208 struct timeval ru_utime; //!< user time used 209 struct timeval ru_stime; //!< system time used 210 int32_t ru_maxrss; //!< max rss 211 int32_t ru_ixrss; //!< integral shared memory size 212 int32_t ru_idrss; //!< integral unshared data " 213 int32_t ru_isrss; //!< integral unshared stack " 214 int32_t ru_minflt; //!< page reclaims - total vmfaults 215 int32_t ru_majflt; //!< page faults 216 int32_t ru_nswap; //!< swaps 217 int32_t ru_inblock; //!< block input operations 218 int32_t ru_oublock; //!< block output operations 219 int32_t ru_msgsnd; //!< messages sent 220 int32_t ru_msgrcv; //!< messages received 221 int32_t ru_nsignals; //!< signals received 222 int32_t ru_nvcsw; //!< voluntary context switches 223 int32_t ru_nivcsw; //!< involuntary " 224 };
|
166
| 225
|
| 226 /// For times(). 227 struct tms { 228 int32_t tms_utime; //!< user time 229 int32_t tms_stime; //!< system time 230 int32_t tms_cutime; //!< user time of children 231 int32_t tms_cstime; //!< system time of children 232 }; 233 234
|
167}; 168 169#endif
| 235}; 236 237#endif
|