linux.hh revision 3113
112953Sgabeblack@google.com/*
212953Sgabeblack@google.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
312953Sgabeblack@google.com * All rights reserved.
412953Sgabeblack@google.com *
512953Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612953Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712953Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812953Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912953Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012953Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112953Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212953Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312953Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412953Sgabeblack@google.com * this software without specific prior written permission.
1512953Sgabeblack@google.com *
1612953Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712953Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812953Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912953Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012953Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112953Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212953Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312953Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412953Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512953Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612953Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712953Sgabeblack@google.com *
2812953Sgabeblack@google.com * Authors: Ali Saidi
2912953Sgabeblack@google.com */
3012953Sgabeblack@google.com
3112953Sgabeblack@google.com#ifndef __LINUX_HH__
3212953Sgabeblack@google.com#define __LINUX_HH__
3313063Sgabeblack@google.com#include "config/full_system.hh"
3413063Sgabeblack@google.com
3513063Sgabeblack@google.com#if FULL_SYSTEM
3612957Sgabeblack@google.com
3712957Sgabeblack@google.comclass Linux {};
3812961Sgabeblack@google.com
3913063Sgabeblack@google.com#else //!FULL_SYSTEM
4012954Sgabeblack@google.com
4112954Sgabeblack@google.com#include <inttypes.h>
4212953Sgabeblack@google.com
4312953Sgabeblack@google.com#include "kern/operatingsystem.hh"
4413063Sgabeblack@google.com
4512953Sgabeblack@google.com///
4612961Sgabeblack@google.com/// This class encapsulates the types, structures, constants,
4712961Sgabeblack@google.com/// functions, and syscall-number mappings specific to the Alpha Linux
4812953Sgabeblack@google.com/// syscall interface.
4912953Sgabeblack@google.com///
5012953Sgabeblack@google.comclass Linux : public OperatingSystem
5113245Sgabeblack@google.com{
5213245Sgabeblack@google.com
5312953Sgabeblack@google.com  public:
5412954Sgabeblack@google.com
5512954Sgabeblack@google.com    //@{
5612954Sgabeblack@google.com    /// Basic Linux types.
5712954Sgabeblack@google.com/*    typedef uint64_t size_t;
5812954Sgabeblack@google.com    typedef uint64_t off_t;
5912954Sgabeblack@google.com    typedef int64_t time_t;
6012954Sgabeblack@google.com    typedef uint32_t uid_t;
6112954Sgabeblack@google.com    typedef uint32_t gid_t;*/
6212954Sgabeblack@google.com    //@}
6312954Sgabeblack@google.com
6412954Sgabeblack@google.com    /// Stat buffer.  Note that we can't call it 'stat' since that
6512954Sgabeblack@google.com    /// gets #defined to something else on some systems. This type
6612954Sgabeblack@google.com    /// can be specialized by architecture specific "Linux" classes
6712954Sgabeblack@google.com    typedef struct {
6812954Sgabeblack@google.com        uint32_t	st_dev;		//!< device
6912954Sgabeblack@google.com        uint32_t	st_ino;		//!< inode
7012954Sgabeblack@google.com        uint32_t	st_mode;	//!< mode
7112954Sgabeblack@google.com        uint32_t	st_nlink;	//!< link count
7212954Sgabeblack@google.com        uint32_t	st_uid;		//!< owner's user ID
7312957Sgabeblack@google.com        uint32_t	st_gid;		//!< owner's group ID
7412954Sgabeblack@google.com        uint32_t	st_rdev;	//!< device number
7512954Sgabeblack@google.com        int32_t		_pad1;		//!< for alignment
7612954Sgabeblack@google.com        int64_t		st_size;	//!< file size in bytes
7712954Sgabeblack@google.com        uint64_t	st_atimeX;	//!< time of last access
7812954Sgabeblack@google.com        uint64_t	st_mtimeX;	//!< time of last modification
7912954Sgabeblack@google.com        uint64_t	st_ctimeX;	//!< time of last status change
8012954Sgabeblack@google.com        uint32_t	st_blksize;	//!< optimal I/O block size
8112954Sgabeblack@google.com        int32_t		st_blocks;	//!< number of blocks allocated
8212954Sgabeblack@google.com        uint32_t	st_flags;	//!< flags
8312954Sgabeblack@google.com        uint32_t	st_gen;		//!< unknown
8412954Sgabeblack@google.com    } tgt_stat;
8512954Sgabeblack@google.com
8612954Sgabeblack@google.com    // same for stat64
8712954Sgabeblack@google.com    typedef struct {
8812954Sgabeblack@google.com        uint64_t	st_dev;
8912954Sgabeblack@google.com        uint64_t	st_ino;
9012954Sgabeblack@google.com        uint64_t	st_rdev;
9113063Sgabeblack@google.com        int64_t		st_size;
9212954Sgabeblack@google.com        uint64_t	st_blocks;
9312954Sgabeblack@google.com
9412954Sgabeblack@google.com        uint32_t	st_mode;
9512954Sgabeblack@google.com        uint32_t	st_uid;
9612954Sgabeblack@google.com        uint32_t	st_gid;
9712954Sgabeblack@google.com        uint32_t	st_blksize;
9812954Sgabeblack@google.com        uint32_t	st_nlink;
9912954Sgabeblack@google.com        uint32_t	__pad0;
10012954Sgabeblack@google.com
10113063Sgabeblack@google.com        uint64_t	st_atimeX;
10213063Sgabeblack@google.com        uint64_t 	st_atime_nsec;
10312954Sgabeblack@google.com        uint64_t	st_mtimeX;
10412954Sgabeblack@google.com        uint64_t	st_mtime_nsec;
10513063Sgabeblack@google.com        uint64_t	st_ctimeX;
10613063Sgabeblack@google.com        uint64_t	st_ctime_nsec;
10712954Sgabeblack@google.com        int64_t		___unused[3];
10812954Sgabeblack@google.com    } tgt_stat64;
10912954Sgabeblack@google.com
11012954Sgabeblack@google.com    /// Length of strings in struct utsname (plus 1 for null char).
11113063Sgabeblack@google.com    static const int _SYS_NMLN = 65;
11213063Sgabeblack@google.com
11313063Sgabeblack@google.com    /// Interface struct for uname().
11413063Sgabeblack@google.com    struct utsname {
11513063Sgabeblack@google.com        char sysname[_SYS_NMLN];	//!< System name.
11612961Sgabeblack@google.com        char nodename[_SYS_NMLN];	//!< Node name.
11712961Sgabeblack@google.com        char release[_SYS_NMLN];	//!< OS release.
11812961Sgabeblack@google.com        char version[_SYS_NMLN];	//!< OS version.
11912961Sgabeblack@google.com        char machine[_SYS_NMLN];	//!< Machine type.
12012961Sgabeblack@google.com    };
12112961Sgabeblack@google.com
12212961Sgabeblack@google.com    /// Limit struct for getrlimit/setrlimit.
12312961Sgabeblack@google.com    struct rlimit {
12412961Sgabeblack@google.com        uint64_t  rlim_cur;	//!< soft limit
12512961Sgabeblack@google.com        uint64_t  rlim_max;	//!< hard limit
12612961Sgabeblack@google.com    };
12712961Sgabeblack@google.com
12812961Sgabeblack@google.com    /// For gettimeofday().
12912961Sgabeblack@google.com    struct timeval {
13012961Sgabeblack@google.com        int64_t tv_sec;		//!< seconds
13112961Sgabeblack@google.com        int64_t tv_usec;	//!< microseconds
13212961Sgabeblack@google.com    };
13312961Sgabeblack@google.com
13412961Sgabeblack@google.com    // For writev/readv
13512961Sgabeblack@google.com    struct tgt_iovec {
13612961Sgabeblack@google.com        uint64_t iov_base; // void *
13713058Sgabeblack@google.com        uint64_t iov_len;
13813058Sgabeblack@google.com    };
13913058Sgabeblack@google.com
14013058Sgabeblack@google.com
14113058Sgabeblack@google.com    /// For getrusage().
14213058Sgabeblack@google.com    struct rusage {
14313058Sgabeblack@google.com        struct timeval ru_utime;	//!< user time used
14413058Sgabeblack@google.com        struct timeval ru_stime;	//!< system time used
14512954Sgabeblack@google.com        int64_t ru_maxrss;		//!< max rss
14612953Sgabeblack@google.com        int64_t ru_ixrss;		//!< integral shared memory size
14712953Sgabeblack@google.com        int64_t ru_idrss;		//!< integral unshared data "
14812953Sgabeblack@google.com        int64_t ru_isrss;		//!< integral unshared stack "
14912953Sgabeblack@google.com        int64_t ru_minflt;		//!< page reclaims - total vmfaults
15013144Sgabeblack@google.com        int64_t ru_majflt;		//!< page faults
15113063Sgabeblack@google.com        int64_t ru_nswap;		//!< swaps
15213063Sgabeblack@google.com        int64_t ru_inblock;		//!< block input operations
15313063Sgabeblack@google.com        int64_t ru_oublock;		//!< block output operations
15413063Sgabeblack@google.com        int64_t ru_msgsnd;		//!< messages sent
15513063Sgabeblack@google.com        int64_t ru_msgrcv;		//!< messages received
15613063Sgabeblack@google.com        int64_t ru_nsignals;		//!< signals received
15713063Sgabeblack@google.com        int64_t ru_nvcsw;		//!< voluntary context switches
15813063Sgabeblack@google.com        int64_t ru_nivcsw;		//!< involuntary "
15913063Sgabeblack@google.com    };
16013063Sgabeblack@google.com
16113063Sgabeblack@google.com};  // class Linux
16213063Sgabeblack@google.com
16312953Sgabeblack@google.com
16413072Sgabeblack@google.com#endif // FULL_SYSTEM
16512953Sgabeblack@google.com
16613076Sgabeblack@google.com#endif // __LINUX_HH__
16713076Sgabeblack@google.com