solaris.hh revision 8776:17efd86a39d3
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ali Saidi
29 */
30
31#ifndef __SOLARIS_HH__
32#define __SOLARIS_HH__
33
34#include "base/types.hh"
35#include "config/full_system.hh"
36#include "kern/operatingsystem.hh"
37
38class TranslatingPort;
39
40///
41/// This class encapsulates the types, structures, constants,
42/// functions, and syscall-number mappings specific to the Solaris
43/// syscall interface.
44///
45class Solaris : public OperatingSystem
46{
47
48  public:
49
50    //@{
51    /// Basic Solaris types.
52    typedef uint64_t size_t;
53    typedef uint64_t off_t;
54    typedef int64_t time_t;
55    typedef int32_t uid_t;
56    typedef int32_t gid_t;
57    typedef uint64_t rlim_t;
58    typedef uint64_t ino_t;
59    typedef uint64_t dev_t;
60    typedef uint32_t mode_t;
61    typedef uint32_t nlink_t;
62    //@}
63
64    struct tgt_timespec {
65        int64_t tv_sec;
66        int64_t tv_nsec;
67    };
68
69    /// Stat buffer.  Note that we can't call it 'stat' since that
70    /// gets #defined to something else on some systems.
71    typedef struct {
72        uint64_t        st_dev;         //!< device
73        uint64_t        st_ino;         //!< inode
74        uint32_t        st_mode;        //!< mode
75        uint32_t        st_nlink;       //!< link count
76        int32_t         st_uid;         //!< owner's user ID
77        int32_t         st_gid;         //!< owner's group ID
78        uint64_t        st_rdev;        //!< device number
79        int64_t         st_size;        //!< file size in bytes
80        //struct tgt_timespec   st_atimeX;      //!< time of last access
81        //struct tgt_timespec   st_mtimeX;      //!< time of last modification
82        //struct tgt_timespec   st_ctimeX;      //!< time of last status change
83        int64_t st_atimeX, st_mtimeX, st_ctimeX;
84        int32_t         st_blksize;     //!< optimal I/O block size
85        int64_t         st_blocks;      //!< number of blocks allocated
86        char            st_fstype[16];
87    } tgt_stat;
88
89    // same for stat64
90    typedef struct {
91        uint64_t        st_dev;         //!< device
92        uint64_t        st_ino;         //!< inode
93        uint32_t        st_mode;        //!< mode
94        uint32_t        st_nlink;       //!< link count
95        int32_t         st_uid;         //!< owner's user ID
96        int32_t         st_gid;         //!< owner's group ID
97        uint64_t        st_rdev;        //!< device number
98        int64_t         st_size;        //!< file size in bytes
99        //struct tgt_timespec   st_atimeX;      //!< time of last access
100        //struct tgt_timespec   st_mtimeX;      //!< time of last modification
101        //struct tgt_timespec   st_ctimeX;      //!< time of last status change
102        int64_t st_atimeX, st_mtimeX, st_ctimeX;
103        int32_t         st_blksize;     //!< optimal I/O block size
104        int64_t         st_blocks;      //!< number of blocks allocated
105        char            st_fstype[16];
106    } tgt_stat64;
107
108    /// Length of strings in struct utsname (plus 1 for null char).
109    static const int _SYS_NMLN = 257;
110
111    /// Interface struct for uname().
112    typedef struct utsname {
113        char sysname[_SYS_NMLN];        //!< System name.
114        char nodename[_SYS_NMLN];       //!< Node name.
115        char release[_SYS_NMLN];        //!< OS release.
116        char version[_SYS_NMLN];        //!< OS version.
117        char machine[_SYS_NMLN];        //!< Machine type.
118    } utsname;
119
120};  // class Solaris
121
122#endif // __SOLARIS_HH__
123