linux.hh revision 5543
1451SN/A/*
21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
3451SN/A * All rights reserved.
4451SN/A *
5451SN/A * Redistribution and use in source and binary forms, with or without
6451SN/A * modification, are permitted provided that the following conditions are
7451SN/A * met: redistributions of source code must retain the above copyright
8451SN/A * notice, this list of conditions and the following disclaimer;
9451SN/A * redistributions in binary form must reproduce the above copyright
10451SN/A * notice, this list of conditions and the following disclaimer in the
11451SN/A * documentation and/or other materials provided with the distribution;
12451SN/A * neither the name of the copyright holders nor the names of its
13451SN/A * contributors may be used to endorse or promote products derived from
14451SN/A * this software without specific prior written permission.
15451SN/A *
16451SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17451SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18451SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19451SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20451SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21451SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22451SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23451SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24451SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25451SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26451SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Ali Saidi
29451SN/A */
30451SN/A
31451SN/A#ifndef __LINUX_HH__
32451SN/A#define __LINUX_HH__
332093SN/A#include "config/full_system.hh"
342093SN/A
352093SN/A#if FULL_SYSTEM
36451SN/A
37451SN/Aclass Linux {};
38451SN/A
392093SN/A#else //!FULL_SYSTEM
402093SN/A
413113Sgblack@eecs.umich.edu#include <inttypes.h>
422093SN/A
433113Sgblack@eecs.umich.edu#include "kern/operatingsystem.hh"
442423SN/A
452093SN/A///
462093SN/A/// This class encapsulates the types, structures, constants,
472093SN/A/// functions, and syscall-number mappings specific to the Alpha Linux
482093SN/A/// syscall interface.
492093SN/A///
503113Sgblack@eecs.umich.educlass Linux : public OperatingSystem
513113Sgblack@eecs.umich.edu{
522093SN/A
532093SN/A  public:
542093SN/A
552093SN/A    //@{
562093SN/A    /// Basic Linux types.
573122Sgblack@eecs.umich.edu    typedef uint64_t size_t;
582093SN/A    typedef uint64_t off_t;
592093SN/A    typedef int64_t time_t;
602093SN/A    typedef uint32_t uid_t;
613122Sgblack@eecs.umich.edu    typedef uint32_t gid_t;
622093SN/A    //@}
632093SN/A
642093SN/A    /// Stat buffer.  Note that we can't call it 'stat' since that
653113Sgblack@eecs.umich.edu    /// gets #defined to something else on some systems. This type
663113Sgblack@eecs.umich.edu    /// can be specialized by architecture specific "Linux" classes
673113Sgblack@eecs.umich.edu    typedef struct {
685543Ssaidi@eecs.umich.edu        uint32_t        st_dev;         //!< device
695543Ssaidi@eecs.umich.edu        uint32_t        st_ino;         //!< inode
705543Ssaidi@eecs.umich.edu        uint32_t        st_mode;        //!< mode
715543Ssaidi@eecs.umich.edu        uint32_t        st_nlink;       //!< link count
725543Ssaidi@eecs.umich.edu        uint32_t        st_uid;         //!< owner's user ID
735543Ssaidi@eecs.umich.edu        uint32_t        st_gid;         //!< owner's group ID
745543Ssaidi@eecs.umich.edu        uint32_t        st_rdev;        //!< device number
755543Ssaidi@eecs.umich.edu        int32_t         _pad1;          //!< for alignment
765543Ssaidi@eecs.umich.edu        int64_t         st_size;        //!< file size in bytes
775543Ssaidi@eecs.umich.edu        uint64_t        st_atimeX;      //!< time of last access
785543Ssaidi@eecs.umich.edu        uint64_t        st_mtimeX;      //!< time of last modification
795543Ssaidi@eecs.umich.edu        uint64_t        st_ctimeX;      //!< time of last status change
805543Ssaidi@eecs.umich.edu        uint32_t        st_blksize;     //!< optimal I/O block size
815543Ssaidi@eecs.umich.edu        int32_t         st_blocks;      //!< number of blocks allocated
825543Ssaidi@eecs.umich.edu        uint32_t        st_flags;       //!< flags
835543Ssaidi@eecs.umich.edu        uint32_t        st_gen;         //!< unknown
843113Sgblack@eecs.umich.edu    } tgt_stat;
852093SN/A
862093SN/A    // same for stat64
873113Sgblack@eecs.umich.edu    typedef struct {
885543Ssaidi@eecs.umich.edu        uint64_t        st_dev;
895543Ssaidi@eecs.umich.edu        uint64_t        st_ino;
905543Ssaidi@eecs.umich.edu        uint64_t        st_rdev;
915543Ssaidi@eecs.umich.edu        int64_t         st_size;
925543Ssaidi@eecs.umich.edu        uint64_t        st_blocks;
932093SN/A
945543Ssaidi@eecs.umich.edu        uint32_t        st_mode;
955543Ssaidi@eecs.umich.edu        uint32_t        st_uid;
965543Ssaidi@eecs.umich.edu        uint32_t        st_gid;
975543Ssaidi@eecs.umich.edu        uint32_t        st_blksize;
985543Ssaidi@eecs.umich.edu        uint32_t        st_nlink;
995543Ssaidi@eecs.umich.edu        uint32_t        __pad0;
1002093SN/A
1015543Ssaidi@eecs.umich.edu        uint64_t        st_atimeX;
1025543Ssaidi@eecs.umich.edu        uint64_t        st_atime_nsec;
1035543Ssaidi@eecs.umich.edu        uint64_t        st_mtimeX;
1045543Ssaidi@eecs.umich.edu        uint64_t        st_mtime_nsec;
1055543Ssaidi@eecs.umich.edu        uint64_t        st_ctimeX;
1065543Ssaidi@eecs.umich.edu        uint64_t        st_ctime_nsec;
1075543Ssaidi@eecs.umich.edu        int64_t         ___unused[3];
1083113Sgblack@eecs.umich.edu    } tgt_stat64;
1092093SN/A
1102093SN/A    /// Length of strings in struct utsname (plus 1 for null char).
1112093SN/A    static const int _SYS_NMLN = 65;
1122093SN/A
1132093SN/A    /// Interface struct for uname().
1142093SN/A    struct utsname {
1155543Ssaidi@eecs.umich.edu        char sysname[_SYS_NMLN];        //!< System name.
1165543Ssaidi@eecs.umich.edu        char nodename[_SYS_NMLN];       //!< Node name.
1175543Ssaidi@eecs.umich.edu        char release[_SYS_NMLN];        //!< OS release.
1185543Ssaidi@eecs.umich.edu        char version[_SYS_NMLN];        //!< OS version.
1195543Ssaidi@eecs.umich.edu        char machine[_SYS_NMLN];        //!< Machine type.
1202093SN/A    };
1212093SN/A
1222093SN/A    /// Limit struct for getrlimit/setrlimit.
1232093SN/A    struct rlimit {
1245543Ssaidi@eecs.umich.edu        uint64_t  rlim_cur;     //!< soft limit
1255543Ssaidi@eecs.umich.edu        uint64_t  rlim_max;     //!< hard limit
1262093SN/A    };
1272093SN/A
1282093SN/A    /// For gettimeofday().
1292093SN/A    struct timeval {
1305543Ssaidi@eecs.umich.edu        int64_t tv_sec;         //!< seconds
1315543Ssaidi@eecs.umich.edu        int64_t tv_usec;        //!< microseconds
1322093SN/A    };
1332093SN/A
1342093SN/A    // For writev/readv
1352093SN/A    struct tgt_iovec {
1362093SN/A        uint64_t iov_base; // void *
1372093SN/A        uint64_t iov_len;
1382093SN/A    };
1392093SN/A
1402093SN/A
1412093SN/A    /// For getrusage().
1422093SN/A    struct rusage {
1435543Ssaidi@eecs.umich.edu        struct timeval ru_utime;        //!< user time used
1445543Ssaidi@eecs.umich.edu        struct timeval ru_stime;        //!< system time used
1455543Ssaidi@eecs.umich.edu        int64_t ru_maxrss;              //!< max rss
1465543Ssaidi@eecs.umich.edu        int64_t ru_ixrss;               //!< integral shared memory size
1475543Ssaidi@eecs.umich.edu        int64_t ru_idrss;               //!< integral unshared data "
1485543Ssaidi@eecs.umich.edu        int64_t ru_isrss;               //!< integral unshared stack "
1495543Ssaidi@eecs.umich.edu        int64_t ru_minflt;              //!< page reclaims - total vmfaults
1505543Ssaidi@eecs.umich.edu        int64_t ru_majflt;              //!< page faults
1515543Ssaidi@eecs.umich.edu        int64_t ru_nswap;               //!< swaps
1525543Ssaidi@eecs.umich.edu        int64_t ru_inblock;             //!< block input operations
1535543Ssaidi@eecs.umich.edu        int64_t ru_oublock;             //!< block output operations
1545543Ssaidi@eecs.umich.edu        int64_t ru_msgsnd;              //!< messages sent
1555543Ssaidi@eecs.umich.edu        int64_t ru_msgrcv;              //!< messages received
1565543Ssaidi@eecs.umich.edu        int64_t ru_nsignals;            //!< signals received
1575543Ssaidi@eecs.umich.edu        int64_t ru_nvcsw;               //!< voluntary context switches
1585543Ssaidi@eecs.umich.edu        int64_t ru_nivcsw;              //!< involuntary "
1592093SN/A    };
1602093SN/A
1612093SN/A};  // class Linux
1622093SN/A
1632093SN/A
1642093SN/A#endif // FULL_SYSTEM
1652093SN/A
166451SN/A#endif // __LINUX_HH__
167