linux.hh revision 5222:bb733a878f85
1/*
2 * Copyright .AN) 2007 MIPS Technologies, Inc.  All Rights Reserved
3 *
4 * This software is part of the M5 simulator.
5 *
6 * THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
7 * DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
8 * TO THESE TERMS AND CONDITIONS.
9 *
10 * Permission is granted to use, copy, create derivative works and
11 * distribute this software and such derivative works for any purpose,
12 * so long as (1) the copyright notice above, this grant of permission,
13 * and the disclaimer below appear in all copies and derivative works
14 * made, (2) the copyright notice above is augmented as appropriate to
15 * reflect the addition of any new copyrightable work in a derivative
16 * work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3)
17 * the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any
18 * advertising or publicity pertaining to the use or distribution of
19 * this software without specific, written prior authorization.
20 *
21 * THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B  MIPS MAKES NO WARRANTIES AND
22 * DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
23 * OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
25 * NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
26 * IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
27 * INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
28 * ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
29 * THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
30 * IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
31 * STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
32 * POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
33 *
34 * Authors: Korey L. Sewell
35 */
36
37#ifndef __ARCH_MIPS_LINUX_LINUX_HH__
38#define __ARCH_MIPS_LINUX_LINUX_HH__
39
40#include "kern/linux/linux.hh"
41#include <string>
42
43using std::string;
44
45class MipsLinux : public Linux
46{
47  public:
48
49    /// This table maps the target open() flags to the corresponding
50    /// host open() flags.
51    static OpenFlagTransTable openFlagTable[];
52
53    /// Number of entries in openFlagTable[].
54    static const int NUM_OPEN_FLAGS;
55
56    //@{
57    /// open(2) flag values.
58    static const int TGT_O_RDONLY	= 0x00000000;	//!< O_RDONLY
59    static const int TGT_O_WRONLY	= 0x00000001;	//!< O_WRONLY
60    static const int TGT_O_RDWR	        = 0x00000002;	//!< O_RDWR
61    static const int TGT_O_NONBLOCK     = 0x00000080;	//!< O_NONBLOCK
62    static const int TGT_O_APPEND	= 0x00000008;	//!< O_APPEND
63    static const int TGT_O_CREAT	= 0x00000100;	//!< O_CREAT
64    static const int TGT_O_TRUNC	= 0x00000200;	//!< O_TRUNC
65    static const int TGT_O_EXCL	        = 0x00000400;	//!< O_EXCL
66    static const int TGT_O_NOCTTY	= 0x00000800;	//!< O_NOCTTY
67    static const int TGT_O_SYNC	        = 0x00000010;	//!< O_SYNC
68    static const int TGT_O_DRD	        = 0x00010000;	//!< O_DRD
69    static const int TGT_O_DIRECTIO     = 0x00020000;	//!< O_DIRECTIO
70    static const int TGT_O_CACHE	= 0x00002000;	//!< O_CACHE
71    static const int TGT_O_DSYNC	= 0x00008000;	//!< O_DSYNC
72    static const int TGT_O_RSYNC	= 0x00040000;	//!< O_RSYNC
73    //@}
74
75    /// For mmap().
76    static const unsigned TGT_MAP_ANONYMOUS = 0x800;
77
78    //@{
79    /// For getsysinfo().
80    static const unsigned GSI_PLATFORM_NAME = 103;  //!< platform name as string
81    static const unsigned GSI_CPU_INFO = 59;	//!< CPU information
82    static const unsigned GSI_PROC_TYPE = 60;	//!< get proc_type
83    static const unsigned GSI_MAX_CPU = 30;         //!< max # cpu's on this machine
84    static const unsigned GSI_CPUS_IN_BOX = 55;	//!< number of CPUs in system
85    static const unsigned GSI_PHYSMEM = 19;	        //!< Physical memory in KB
86    static const unsigned GSI_CLK_TCK = 42;	        //!< clock freq in Hz
87    //@}
88
89    //@{
90    /// For getrusage().
91    static const int TGT_RUSAGE_SELF = 0;
92    static const int TGT_RUSAGE_CHILDREN = -1;
93    static const int TGT_RUSAGE_BOTH = -2;
94    //@}
95
96    //@{
97    /// For setsysinfo().
98    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
99    //@}
100
101    //@{
102    /// ioctl() command codes.
103    static const unsigned TIOCGETP   = 0x7408;
104    static const unsigned TIOCSETP   = 0x7409;
105    static const unsigned TIOCSETN   = 0x740a;
106    static const unsigned TIOCSETC   = 0x7411;
107    static const unsigned TIOCGETC   = 0x7412;
108    static const unsigned FIONREAD   = 0x467f;
109    static const unsigned TIOCISATTY = 0x5480;
110    static const unsigned TIOCGETS   = 0x540d;
111    static const unsigned TIOCGETA   = 0x7417;
112    //@}
113
114    /// For table().
115    static const int TBL_SYSINFO = 12;
116
117    /// Resource enumeration for getrlimit()/setrlimit().
118    enum rlimit_resources {
119        TGT_RLIMIT_CPU = 0,
120        TGT_RLIMIT_FSIZE = 1,
121        TGT_RLIMIT_DATA = 2,
122        TGT_RLIMIT_STACK = 3,
123        TGT_RLIMIT_CORE = 4,
124        TGT_RLIMIT_NOFILE = 5,
125        TGT_RLIMIT_AS = 6,
126        TGT_RLIMIT_RSS = 7,
127        TGT_RLIMIT_VMEM = 7,
128        TGT_RLIMIT_NPROC = 8,
129        TGT_RLIMIT_MEMLOCK = 9,
130        TGT_RLIMIT_LOCKS = 10,
131        NUM_RLIMIT_RESOURCES
132    };
133
134    /// Offset used to make sure that processes don't
135    /// assign themselves to process IDs reserved for
136    /// the root users.
137    static const int NUM_ROOT_PROCS = 2;
138};
139
140#endif
141