linux.hh revision 9141:593fe25c86a6
12972Sgblack@eecs.umich.edu/*
22972Sgblack@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan
32972Sgblack@eecs.umich.edu * All rights reserved.
42972Sgblack@eecs.umich.edu *
52972Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
62972Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
72972Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
82972Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
92972Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
102972Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
112972Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
122972Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
132972Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
142972Sgblack@eecs.umich.edu * this software without specific prior written permission.
152972Sgblack@eecs.umich.edu *
162972Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172972Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182972Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192972Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202972Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212972Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222972Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232972Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242972Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252972Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262972Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272972Sgblack@eecs.umich.edu *
282972Sgblack@eecs.umich.edu * Authors: Korey Sewell
292972Sgblack@eecs.umich.edu */
302972Sgblack@eecs.umich.edu
312972Sgblack@eecs.umich.edu#ifndef __ARCH_MIPS_LINUX_LINUX_HH__
322972Sgblack@eecs.umich.edu#define __ARCH_MIPS_LINUX_LINUX_HH__
332972Sgblack@eecs.umich.edu
344040Ssaidi@eecs.umich.edu#include "kern/linux/linux.hh"
356215Snate@binkert.org
362972Sgblack@eecs.umich.educlass MipsLinux : public Linux
372972Sgblack@eecs.umich.edu{
382972Sgblack@eecs.umich.edu  public:
392972Sgblack@eecs.umich.edu
402972Sgblack@eecs.umich.edu    /// This table maps the target open() flags to the corresponding
412972Sgblack@eecs.umich.edu    /// host open() flags.
422972Sgblack@eecs.umich.edu    static OpenFlagTransTable openFlagTable[];
434040Ssaidi@eecs.umich.edu
442972Sgblack@eecs.umich.edu    /// Number of entries in openFlagTable[].
452972Sgblack@eecs.umich.edu    static const int NUM_OPEN_FLAGS;
462972Sgblack@eecs.umich.edu
472972Sgblack@eecs.umich.edu    //@{
482972Sgblack@eecs.umich.edu    /// open(2) flag values.
492972Sgblack@eecs.umich.edu    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
502972Sgblack@eecs.umich.edu    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
512972Sgblack@eecs.umich.edu    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
522972Sgblack@eecs.umich.edu    static const int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
532972Sgblack@eecs.umich.edu    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
544635Sgblack@eecs.umich.edu    static const int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
555251Sksewell@umich.edu    static const int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
565251Sksewell@umich.edu    static const int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
575251Sksewell@umich.edu    static const int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
585251Sksewell@umich.edu    static const int TGT_O_SYNC         = 0x00000010;   //!< O_SYNC
592972Sgblack@eecs.umich.edu    static const int TGT_O_DRD          = 0x00010000;   //!< O_DRD
602972Sgblack@eecs.umich.edu    static const int TGT_O_DIRECTIO     = 0x00020000;   //!< O_DIRECTIO
612972Sgblack@eecs.umich.edu    static const int TGT_O_CACHE        = 0x00002000;   //!< O_CACHE
62    static const int TGT_O_DSYNC        = 0x00008000;   //!< O_DSYNC
63    static const int TGT_O_RSYNC        = 0x00040000;   //!< O_RSYNC
64    //@}
65
66    /// For mmap().
67    static const unsigned TGT_MAP_ANONYMOUS = 0x800;
68    static const unsigned TGT_MAP_FIXED     = 0x10;
69
70    //@{
71    /// For getsysinfo().
72    static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
73    static const unsigned GSI_CPU_INFO = 59;       //!< CPU information
74    static const unsigned GSI_PROC_TYPE = 60;      //!< get proc_type
75    static const unsigned GSI_MAX_CPU = 30;        //!< max # cpu's on this machine
76    static const unsigned GSI_CPUS_IN_BOX = 55;    //!< number of CPUs in system
77    static const unsigned GSI_PHYSMEM = 19;        //!< Physical memory in KB
78    static const unsigned GSI_CLK_TCK = 42;        //!< clock freq in Hz
79    //@}
80
81    //@{
82    /// For getrusage().
83    static const int TGT_RUSAGE_SELF = 0;
84    static const int TGT_RUSAGE_CHILDREN = -1;
85    static const int TGT_RUSAGE_BOTH = -2;
86    //@}
87
88    //@{
89    /// For setsysinfo().
90    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
91    //@}
92
93    //@{
94    /// ioctl() command codes.
95    static const unsigned TGT_TCGETA     = 0x5401;
96    static const unsigned TGT_TCSETAW    = 0x5403;
97    static const unsigned TGT_TCGETS     = 0x540d;
98    static const unsigned TGT_FIONREAD   = 0x467f;
99    static const unsigned TGT_TIOCGETP   = 0x7408;
100    static const unsigned TGT_TIOCSETP   = 0x7409;
101    static const unsigned TGT_TIOCSETN   = 0x740a;
102    //@}
103
104    static bool
105    isTtyReq(unsigned req)
106    {
107        switch (req) {
108          case TGT_TIOCGETP:
109          case TGT_TIOCSETP:
110          case TGT_TIOCSETN:
111          case TGT_FIONREAD:
112          case TGT_TCGETS:
113          case TGT_TCGETA:
114          case TGT_TCSETAW:
115            return true;
116          default:
117            return false;
118        }
119    }
120
121    /// For table().
122    static const int TBL_SYSINFO = 12;
123
124    /// Resource enumeration for getrlimit()/setrlimit().
125    enum rlimit_resources {
126        TGT_RLIMIT_CPU = 0,
127        TGT_RLIMIT_FSIZE = 1,
128        TGT_RLIMIT_DATA = 2,
129        TGT_RLIMIT_STACK = 3,
130        TGT_RLIMIT_CORE = 4,
131        TGT_RLIMIT_NOFILE = 5,
132        TGT_RLIMIT_AS = 6,
133        TGT_RLIMIT_RSS = 7,
134        TGT_RLIMIT_VMEM = 7,
135        TGT_RLIMIT_NPROC = 8,
136        TGT_RLIMIT_MEMLOCK = 9,
137        TGT_RLIMIT_LOCKS = 10,
138        NUM_RLIMIT_RESOURCES
139    };
140
141    /// Offset used to make sure that processes don't
142    /// assign themselves to process IDs reserved for
143    /// the root users.
144    static const int NUM_ROOT_PROCS = 2;
145
146    typedef struct {
147       int32_t  uptime;    /* Seconds since boot */
148       uint32_t loads[3];  /* 1, 5, and 15 minute load averages */
149       uint32_t totalram;  /* Total usable main memory size */
150       uint32_t freeram;   /* Available memory size */
151       uint32_t sharedram; /* Amount of shared memory */
152       uint32_t bufferram; /* Memory used by buffers */
153       uint32_t totalswap; /* Total swap space size */
154       uint32_t freeswap;  /* swap space still available */
155       uint16_t procs;     /* Number of current processes */
156       uint32_t totalhigh; /* Total high memory size */
157       uint32_t freehigh;  /* Available high memory size */
158       uint32_t mem_unit;  /* Memory unit size in bytes */
159    } tgt_sysinfo;
160
161};
162
163#endif
164