linux.hh revision 13536
112855Sgabeblack@google.com/*
212855Sgabeblack@google.com * Copyright (c) 2010, 2011-2012, 2015 ARM Limited
312855Sgabeblack@google.com * All rights reserved
412855Sgabeblack@google.com *
512855Sgabeblack@google.com * The license below extends only to copyright in the software and shall
612855Sgabeblack@google.com * not be construed as granting a license to any other intellectual
712855Sgabeblack@google.com * property including but not limited to intellectual property relating
812855Sgabeblack@google.com * to a hardware implementation of the functionality of the software
912855Sgabeblack@google.com * licensed hereunder.  You may use the software subject to the license
1012855Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated
1112855Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software,
1212855Sgabeblack@google.com * modified or unmodified, in source code or in binary form.
1312855Sgabeblack@google.com *
1412855Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
1512855Sgabeblack@google.com * Copyright (c) 2007-2008 The Florida State University
1612855Sgabeblack@google.com * All rights reserved.
1712855Sgabeblack@google.com *
1812855Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
1912855Sgabeblack@google.com * modification, are permitted provided that the following conditions are
2012855Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
2112855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
2212855Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
2312855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
2412855Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
2512855Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
2612855Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
2712855Sgabeblack@google.com * this software without specific prior written permission.
2812855Sgabeblack@google.com *
2912855Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3012855Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3112855Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3212855Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3312855Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3412855Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3512855Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3612855Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3712855Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3812855Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3912855Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4012855Sgabeblack@google.com *
4112855Sgabeblack@google.com * Authors: Ali Saidi
4212855Sgabeblack@google.com *          Stephen Hines
4312855Sgabeblack@google.com */
4412855Sgabeblack@google.com
4512855Sgabeblack@google.com#ifndef __ARCH_ARM_LINUX_LINUX_HH__
4612855Sgabeblack@google.com#define __ARCH_ARM_LINUX_LINUX_HH__
4712855Sgabeblack@google.com
4812855Sgabeblack@google.com#include "arch/arm/utility.hh"
4912855Sgabeblack@google.com#include "kern/linux/linux.hh"
5012855Sgabeblack@google.com
5112855Sgabeblack@google.comclass ArmLinux : public Linux
5212855Sgabeblack@google.com{
5312855Sgabeblack@google.com  public:
5412855Sgabeblack@google.com    static void
5512855Sgabeblack@google.com    archClone(uint64_t flags,
5612855Sgabeblack@google.com              Process *pp, Process *cp,
5712855Sgabeblack@google.com              ThreadContext *ptc, ThreadContext *ctc,
5812855Sgabeblack@google.com              uint64_t stack, uint64_t tls)
5912855Sgabeblack@google.com    {
6012855Sgabeblack@google.com        ArmISA::copyRegs(ptc, ctc);
6112855Sgabeblack@google.com
6212855Sgabeblack@google.com        if (stack)
6312855Sgabeblack@google.com            ctc->setIntReg(TheISA::StackPointerReg, stack);
6412855Sgabeblack@google.com    }
6512855Sgabeblack@google.com};
6612855Sgabeblack@google.com
6712855Sgabeblack@google.comclass ArmLinux32 : public ArmLinux
6812855Sgabeblack@google.com{
6912855Sgabeblack@google.com  public:
7012855Sgabeblack@google.com
7112855Sgabeblack@google.com    static const int TGT_SIGHUP         = 0x000001;
7212855Sgabeblack@google.com    static const int TGT_SIGINT         = 0x000002;
7312855Sgabeblack@google.com    static const int TGT_SIGQUIT        = 0x000003;
7412855Sgabeblack@google.com    static const int TGT_SIGILL         = 0x000004;
7512855Sgabeblack@google.com    static const int TGT_SIGTRAP        = 0x000005;
7612855Sgabeblack@google.com    static const int TGT_SIGABRT        = 0x000006;
7712855Sgabeblack@google.com    static const int TGT_SIGIOT         = 0x000006;
7812855Sgabeblack@google.com    static const int TGT_SIGBUS         = 0x000007;
7912855Sgabeblack@google.com    static const int TGT_SIGFPE         = 0x000008;
8012855Sgabeblack@google.com    static const int TGT_SIGKILL        = 0x000009;
8112855Sgabeblack@google.com    static const int TGT_SIGUSR1        = 0x00000a;
8212855Sgabeblack@google.com    static const int TGT_SIGSEGV        = 0x00000b;
8312855Sgabeblack@google.com    static const int TGT_SIGUSR2        = 0x00000c;
8412855Sgabeblack@google.com    static const int TGT_SIGPIPE        = 0x00000d;
8512855Sgabeblack@google.com    static const int TGT_SIGALRM        = 0x00000e;
8612855Sgabeblack@google.com    static const int TGT_SIGTERM        = 0x00000f;
8712855Sgabeblack@google.com    static const int TGT_SIGSTKFLT      = 0x000010;
8812855Sgabeblack@google.com    static const int TGT_SIGCHLD        = 0x000011;
8912855Sgabeblack@google.com    static const int TGT_SIGCONT        = 0x000012;
9012855Sgabeblack@google.com    static const int TGT_SIGSTOP        = 0x000013;
9112855Sgabeblack@google.com    static const int TGT_SIGTSTP        = 0x000014;
9212855Sgabeblack@google.com    static const int TGT_SIGTTIN        = 0x000015;
9312855Sgabeblack@google.com    static const int TGT_SIGTTOU        = 0x000016;
9412855Sgabeblack@google.com    static const int TGT_SIGURG         = 0x000017;
9512855Sgabeblack@google.com    static const int TGT_SIGXCPU        = 0x000018;
9612855Sgabeblack@google.com    static const int TGT_SIGXFSZ        = 0x000019;
9712855Sgabeblack@google.com    static const int TGT_SIGVTALRM      = 0x00001a;
9812855Sgabeblack@google.com    static const int TGT_SIGPROF        = 0x00001b;
9912855Sgabeblack@google.com    static const int TGT_SIGWINCH       = 0x00001c;
10012855Sgabeblack@google.com    static const int TGT_SIGIO          = 0x00001d;
10112855Sgabeblack@google.com    static const int TGT_SIGPOLL        = 0x00001d;
10212855Sgabeblack@google.com    static const int TGT_SIGPWR         = 0x00001e;
10312855Sgabeblack@google.com    static const int TGT_SIGSYS         = 0x00001f;
10412855Sgabeblack@google.com    static const int TGT_SIGUNUSED      = 0x00001f;
10512855Sgabeblack@google.com
10612855Sgabeblack@google.com    /// This table maps the target open() flags to the corresponding
10712855Sgabeblack@google.com    /// host open() flags.
10812855Sgabeblack@google.com    static SyscallFlagTransTable openFlagTable[];
10912855Sgabeblack@google.com
11012855Sgabeblack@google.com    /// Number of entries in openFlagTable[].
11112855Sgabeblack@google.com    static const int NUM_OPEN_FLAGS;
11212855Sgabeblack@google.com
11312855Sgabeblack@google.com    //@{
11412855Sgabeblack@google.com    /// Basic ARM Linux types
11512855Sgabeblack@google.com    typedef uint32_t size_t;
11612855Sgabeblack@google.com    typedef uint32_t off_t;
11712855Sgabeblack@google.com    typedef int32_t time_t;
11812855Sgabeblack@google.com    typedef int32_t clock_t;
11912855Sgabeblack@google.com    //@}
12012855Sgabeblack@google.com
12112855Sgabeblack@google.com    //@{
12212855Sgabeblack@google.com    /// open(2) flag values.
12312855Sgabeblack@google.com    static const int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
12412855Sgabeblack@google.com    static const int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
12512855Sgabeblack@google.com    static const int TGT_O_RDWR      = 000000002; //!< O_RDWR
12612855Sgabeblack@google.com    static const int TGT_O_CREAT     = 000000100; //!< O_CREAT
12712855Sgabeblack@google.com    static const int TGT_O_EXCL      = 000000200; //!< O_EXCL
12812855Sgabeblack@google.com    static const int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
12912855Sgabeblack@google.com    static const int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
13012855Sgabeblack@google.com    static const int TGT_O_APPEND    = 000002000; //!< O_APPEND
13112855Sgabeblack@google.com    static const int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
13212855Sgabeblack@google.com    static const int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
13312855Sgabeblack@google.com    static const int TGT_FASYNC      = 000020000; //!< FASYNC
13412855Sgabeblack@google.com    static const int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
13512855Sgabeblack@google.com    static const int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
13612855Sgabeblack@google.com    static const int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
13712855Sgabeblack@google.com    static const int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
13812855Sgabeblack@google.com    static const int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
13912855Sgabeblack@google.com    static const int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
14012855Sgabeblack@google.com    static const int TGT_O_SYNC      = 004010000; //!< O_SYNC
14112855Sgabeblack@google.com    static const int TGT_O_PATH      = 010000000; //!< O_PATH
14212855Sgabeblack@google.com    //@}
14312855Sgabeblack@google.com
14412855Sgabeblack@google.com    static const unsigned TGT_MAP_SHARED        = 0x00001;
14512855Sgabeblack@google.com    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
14612855Sgabeblack@google.com    static const unsigned TGT_MAP_ANON          = 0x00020;
14712855Sgabeblack@google.com    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
14812855Sgabeblack@google.com    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
14912855Sgabeblack@google.com    static const unsigned TGT_MAP_FILE          = 0x00000;
15012855Sgabeblack@google.com    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
15112855Sgabeblack@google.com    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
15212855Sgabeblack@google.com    static const unsigned TGT_MAP_LOCKED        = 0x02000;
15312855Sgabeblack@google.com    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
15412855Sgabeblack@google.com    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
15512855Sgabeblack@google.com    static const unsigned TGT_MAP_POPULATE      = 0x08000;
15612855Sgabeblack@google.com    static const unsigned TGT_MAP_STACK         = 0x20000;
15712855Sgabeblack@google.com    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
15812855Sgabeblack@google.com    static const unsigned TGT_MAP_FIXED         = 0x00010;
15912855Sgabeblack@google.com
16012855Sgabeblack@google.com    static const unsigned NUM_MMAP_FLAGS;
16112855Sgabeblack@google.com
16212855Sgabeblack@google.com    /// For table().
16312855Sgabeblack@google.com    static const int TBL_SYSINFO = 12;
16412855Sgabeblack@google.com
16512855Sgabeblack@google.com    /// Limit struct for getrlimit/setrlimit.
16612855Sgabeblack@google.com    struct rlimit {
16712855Sgabeblack@google.com        uint32_t  rlim_cur;     //!< soft limit
16812855Sgabeblack@google.com        uint32_t  rlim_max;     //!< hard limit
16912855Sgabeblack@google.com    };
17012855Sgabeblack@google.com
17112855Sgabeblack@google.com    /// For gettimeofday().
17212855Sgabeblack@google.com    struct timeval {
17312855Sgabeblack@google.com        int32_t tv_sec;         //!< seconds
17412855Sgabeblack@google.com        int32_t tv_usec;        //!< microseconds
17512855Sgabeblack@google.com    };
17612855Sgabeblack@google.com
177    struct timespec {
178        int32_t tv_sec;   //!< seconds
179        int32_t tv_nsec;  //!< nanoseconds
180    };
181
182    // For writev/readv
183    struct tgt_iovec {
184        uint32_t iov_base; // void *
185        uint32_t iov_len;
186    };
187
188
189    typedef struct {
190        uint32_t st_dev;
191        uint32_t st_ino;
192        uint16_t st_mode;
193        uint16_t st_nlink;
194        uint16_t st_uid;
195        uint16_t st_gid;
196        uint32_t st_rdev;
197        uint32_t __pad1;
198        uint32_t st_size;
199        uint32_t st_blksize;
200        uint32_t __pad2;
201        uint32_t st_blocks;
202        uint32_t st_atimeX;
203        uint32_t st_atime_nsec;
204        uint32_t st_mtimeX;
205        uint32_t st_mtime_nsec;
206        uint32_t st_ctimeX;
207        uint32_t st_ctime_nsec;
208    } tgt_stat;
209
210    typedef struct {
211        uint64_t  st_dev;
212        uint8_t   __pad0[4];
213        uint32_t  __st_ino;
214        uint32_t  st_mode;
215        uint32_t  st_nlink;
216        uint32_t  st_uid;
217        uint32_t  st_gid;
218        uint64_t  st_rdev;
219        uint8_t   __pad3[4];
220        int64_t   __attribute__ ((aligned (8))) st_size;
221        uint32_t  st_blksize;
222        uint64_t  __attribute__ ((aligned (8))) st_blocks;
223        uint32_t  st_atimeX;
224        uint32_t  st_atime_nsec;
225        uint32_t  st_mtimeX;
226        uint32_t  st_mtime_nsec;
227        uint32_t  st_ctimeX;
228        uint32_t  st_ctime_nsec;
229        uint64_t  st_ino;
230    } tgt_stat64;
231
232    typedef struct {
233        int32_t  uptime;    /* Seconds since boot */
234        uint32_t loads[3];  /* 1, 5, and 15 minute load averages */
235        uint32_t totalram;  /* Total usable main memory size */
236        uint32_t freeram;   /* Available memory size */
237        uint32_t sharedram; /* Amount of shared memory */
238        uint32_t bufferram; /* Memory used by buffers */
239        uint32_t totalswap; /* Total swap space size */
240        uint32_t freeswap;  /* swap space still available */
241        uint16_t procs;     /* Number of current processes */
242        uint32_t totalhigh; /* Total high memory size */
243        uint32_t freehigh;  /* Available high memory size */
244        uint32_t mem_unit;  /* Memory unit size in bytes */
245    } tgt_sysinfo;
246
247    /// For getrusage().
248    struct rusage {
249        struct timeval ru_utime;        //!< user time used
250        struct timeval ru_stime;        //!< system time used
251        int32_t ru_maxrss;              //!< max rss
252        int32_t ru_ixrss;               //!< integral shared memory size
253        int32_t ru_idrss;               //!< integral unshared data "
254        int32_t ru_isrss;               //!< integral unshared stack "
255        int32_t ru_minflt;              //!< page reclaims - total vmfaults
256        int32_t ru_majflt;              //!< page faults
257        int32_t ru_nswap;               //!< swaps
258        int32_t ru_inblock;             //!< block input operations
259        int32_t ru_oublock;             //!< block output operations
260        int32_t ru_msgsnd;              //!< messages sent
261        int32_t ru_msgrcv;              //!< messages received
262        int32_t ru_nsignals;            //!< signals received
263        int32_t ru_nvcsw;               //!< voluntary context switches
264        int32_t ru_nivcsw;              //!< involuntary "
265    };
266
267    /// For times().
268    struct tms {
269        int32_t tms_utime;      //!< user time
270        int32_t tms_stime;      //!< system time
271        int32_t tms_cutime;     //!< user time of children
272        int32_t tms_cstime;     //!< system time of children
273    };
274};
275
276class ArmLinux64 : public ArmLinux
277{
278  public:
279
280    static const int TGT_SIGHUP         = 0x000001;
281    static const int TGT_SIGINT         = 0x000002;
282    static const int TGT_SIGQUIT        = 0x000003;
283    static const int TGT_SIGILL         = 0x000004;
284    static const int TGT_SIGTRAP        = 0x000005;
285    static const int TGT_SIGABRT        = 0x000006;
286    static const int TGT_SIGIOT         = 0x000006;
287    static const int TGT_SIGBUS         = 0x000007;
288    static const int TGT_SIGFPE         = 0x000008;
289    static const int TGT_SIGKILL        = 0x000009;
290    static const int TGT_SIGUSR1        = 0x00000a;
291    static const int TGT_SIGSEGV        = 0x00000b;
292    static const int TGT_SIGUSR2        = 0x00000c;
293    static const int TGT_SIGPIPE        = 0x00000d;
294    static const int TGT_SIGALRM        = 0x00000e;
295    static const int TGT_SIGTERM        = 0x00000f;
296    static const int TGT_SIGSTKFLT      = 0x000010;
297    static const int TGT_SIGCHLD        = 0x000011;
298    static const int TGT_SIGCONT        = 0x000012;
299    static const int TGT_SIGSTOP        = 0x000013;
300    static const int TGT_SIGTSTP        = 0x000014;
301    static const int TGT_SIGTTIN        = 0x000015;
302    static const int TGT_SIGTTOU        = 0x000016;
303    static const int TGT_SIGURG         = 0x000017;
304    static const int TGT_SIGXCPU        = 0x000018;
305    static const int TGT_SIGXFSZ        = 0x000019;
306    static const int TGT_SIGVTALRM      = 0x00001a;
307    static const int TGT_SIGPROF        = 0x00001b;
308    static const int TGT_SIGWINCH       = 0x00001c;
309    static const int TGT_SIGIO          = 0x00001d;
310    static const int TGT_SIGPOLL        = 0x00001d;
311    static const int TGT_SIGPWR         = 0x00001e;
312    static const int TGT_SIGSYS         = 0x00001f;
313    static const int TGT_SIGUNUSED      = 0x00001f;
314
315    /// This table maps the target open() flags to the corresponding
316    /// host open() flags.
317    static SyscallFlagTransTable openFlagTable[];
318
319    /// Number of entries in openFlagTable[].
320    static const int NUM_OPEN_FLAGS;
321
322    //@{
323    /// Basic ARM Linux types
324    typedef uint64_t size_t;
325    typedef uint64_t off_t;
326    typedef int64_t time_t;
327    typedef int64_t clock_t;
328    //@}
329
330    //@{
331    /// open(2) flag values.
332    static const int TGT_O_RDONLY    = 000000000; //!< O_RDONLY
333    static const int TGT_O_WRONLY    = 000000001; //!< O_WRONLY
334    static const int TGT_O_RDWR      = 000000002; //!< O_RDWR
335    static const int TGT_O_CREAT     = 000000100; //!< O_CREAT
336    static const int TGT_O_EXCL      = 000000200; //!< O_EXCL
337    static const int TGT_O_NOCTTY    = 000000400; //!< O_NOCTTY
338    static const int TGT_O_TRUNC     = 000001000; //!< O_TRUNC
339    static const int TGT_O_APPEND    = 000002000; //!< O_APPEND
340    static const int TGT_O_NONBLOCK  = 000004000; //!< O_NONBLOCK
341    static const int TGT_O_DSYNC     = 000010000; //!< O_DSYNC
342    static const int TGT_FASYNC      = 000020000; //!< FASYNC
343    static const int TGT_O_DIRECT    = 000200000; //!< O_DIRECT
344    static const int TGT_O_LARGEFILE = 000400000; //!< O_LARGEFILE
345    static const int TGT_O_DIRECTORY = 000040000; //!< O_DIRECTORY
346    static const int TGT_O_NOFOLLOW  = 000100000; //!< O_NOFOLLOW
347    static const int TGT_O_NOATIME   = 001000000; //!< O_NOATIME
348    static const int TGT_O_CLOEXEC   = 002000000; //!< O_NOATIME
349    static const int TGT_O_SYNC      = 004010000; //!< O_SYNC
350    static const int TGT_O_PATH      = 010000000; //!< O_PATH
351    //@}
352
353    /// For mmap().
354    static SyscallFlagTransTable mmapFlagTable[];
355
356    static const unsigned TGT_MAP_SHARED        = 0x00001;
357    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
358    static const unsigned TGT_MAP_ANON          = 0x00020;
359    static const unsigned TGT_MAP_DENYWRITE     = 0x00800;
360    static const unsigned TGT_MAP_EXECUTABLE    = 0x01000;
361    static const unsigned TGT_MAP_FILE          = 0x00000;
362    static const unsigned TGT_MAP_GROWSDOWN     = 0x00100;
363    static const unsigned TGT_MAP_HUGETLB       = 0x40000;
364    static const unsigned TGT_MAP_LOCKED        = 0x02000;
365    static const unsigned TGT_MAP_NONBLOCK      = 0x10000;
366    static const unsigned TGT_MAP_NORESERVE     = 0x04000;
367    static const unsigned TGT_MAP_POPULATE      = 0x08000;
368    static const unsigned TGT_MAP_STACK         = 0x20000;
369    static const unsigned TGT_MAP_ANONYMOUS     = 0x00020;
370    static const unsigned TGT_MAP_FIXED         = 0x00010;
371
372    static const unsigned NUM_MMAP_FLAGS;
373
374    //@{
375    /// For getrusage().
376    static const int TGT_RUSAGE_SELF = 0;
377    static const int TGT_RUSAGE_CHILDREN = -1;
378    static const int TGT_RUSAGE_BOTH = -2;
379    //@}
380
381    //@{
382    /// ioctl() command codes.
383    static const unsigned TIOCGETP_   = 0x5401;
384    static const unsigned TIOCSETP_   = 0x80067409;
385    static const unsigned TIOCSETN_   = 0x8006740a;
386    static const unsigned TIOCSETC_   = 0x80067411;
387    static const unsigned TIOCGETC_   = 0x40067412;
388    static const unsigned FIONREAD_   = 0x4004667f;
389    static const unsigned TIOCISATTY_ = 0x2000745e;
390    static const unsigned TIOCGETS_   = 0x402c7413;
391    static const unsigned TIOCGETA_   = 0x5405;
392    static const unsigned TCSETAW_    = 0x5407;     // 2.6.15 kernel
393    //@}
394
395    /// For table().
396    static const int TBL_SYSINFO = 12;
397
398    /// Resource enumeration for getrlimit().
399    enum rlimit_resources {
400        TGT_RLIMIT_CPU = 0,
401        TGT_RLIMIT_FSIZE = 1,
402        TGT_RLIMIT_DATA = 2,
403        TGT_RLIMIT_STACK = 3,
404        TGT_RLIMIT_CORE = 4,
405        TGT_RLIMIT_RSS = 5,
406        TGT_RLIMIT_NPROC = 6,
407        TGT_RLIMIT_NOFILE = 7,
408        TGT_RLIMIT_MEMLOCK = 8,
409        TGT_RLIMIT_AS = 9,
410        TGT_RLIMIT_LOCKS = 10
411    };
412
413    /// Limit struct for getrlimit/setrlimit.
414    struct rlimit {
415        uint64_t  rlim_cur;     //!< soft limit
416        uint64_t  rlim_max;     //!< hard limit
417    };
418
419    /// For gettimeofday().
420    struct timeval {
421        int64_t tv_sec;         //!< seconds
422        int64_t tv_usec;        //!< microseconds
423    };
424
425    struct timespec {
426        int64_t tv_sec;   //!< seconds
427        int64_t tv_nsec;  //!< nanoseconds
428    };
429
430    // For writev/readv
431    struct tgt_iovec {
432        uint64_t iov_base; // void *
433        uint64_t iov_len;
434    };
435
436    typedef struct {
437        uint64_t st_dev;
438        uint64_t st_ino;
439        uint64_t st_nlink;
440        uint32_t st_mode;
441        uint32_t st_uid;
442        uint32_t st_gid;
443        uint32_t __pad0;
444        uint64_t st_rdev;
445        uint64_t st_size;
446        uint64_t st_blksize;
447        uint64_t st_blocks;
448        uint64_t st_atimeX;
449        uint64_t st_atime_nsec;
450        uint64_t st_mtimeX;
451        uint64_t st_mtime_nsec;
452        uint64_t st_ctimeX;
453        uint64_t st_ctime_nsec;
454    } tgt_stat;
455
456    typedef struct {
457        uint64_t st_dev;
458        uint64_t st_ino;
459        uint32_t st_mode;
460        uint32_t st_nlink;
461        uint32_t st_uid;
462        uint32_t st_gid;
463        uint32_t __pad0;
464        uint64_t st_rdev;
465        uint64_t st_size;
466        uint64_t st_blksize;
467        uint64_t st_blocks;
468        uint64_t st_atimeX;
469        uint64_t st_atime_nsec;
470        uint64_t st_mtimeX;
471        uint64_t st_mtime_nsec;
472        uint64_t st_ctimeX;
473        uint64_t st_ctime_nsec;
474    } tgt_stat64;
475
476    typedef struct {
477        int64_t  uptime;    /* Seconds since boot */
478        uint64_t loads[3];  /* 1, 5, and 15 minute load averages */
479        uint64_t totalram;  /* Total usable main memory size */
480        uint64_t freeram;   /* Available memory size */
481        uint64_t sharedram; /* Amount of shared memory */
482        uint64_t bufferram; /* Memory used by buffers */
483        uint64_t totalswap; /* Total swap space size */
484        uint64_t freeswap;  /* swap space still available */
485        uint16_t procs;     /* Number of current processes */
486        uint16_t pad;
487        uint64_t totalhigh; /* Total high memory size */
488        uint64_t freehigh;  /* Available high memory size */
489        uint32_t mem_unit;  /* Memory unit size in bytes */
490    } tgt_sysinfo;
491
492    /// For getrusage().
493    struct rusage {
494        struct timeval ru_utime;        //!< user time used
495        struct timeval ru_stime;        //!< system time used
496        int64_t ru_maxrss;              //!< max rss
497        int64_t ru_ixrss;               //!< integral shared memory size
498        int64_t ru_idrss;               //!< integral unshared data "
499        int64_t ru_isrss;               //!< integral unshared stack "
500        int64_t ru_minflt;              //!< page reclaims - total vmfaults
501        int64_t ru_majflt;              //!< page faults
502        int64_t ru_nswap;               //!< swaps
503        int64_t ru_inblock;             //!< block input operations
504        int64_t ru_oublock;             //!< block output operations
505        int64_t ru_msgsnd;              //!< messages sent
506        int64_t ru_msgrcv;              //!< messages received
507        int64_t ru_nsignals;            //!< signals received
508        int64_t ru_nvcsw;               //!< voluntary context switches
509        int64_t ru_nivcsw;              //!< involuntary "
510    };
511
512    /// For times().
513    struct tms {
514        int64_t tms_utime;      //!< user time
515        int64_t tms_stime;      //!< system time
516        int64_t tms_cutime;     //!< user time of children
517        int64_t tms_cstime;     //!< system time of children
518    };
519};
520
521#endif
522