linux.hh revision 11383
12553SN/A/*
25254Sksewell@umich.edu * Copyright (c) 2006 The Regents of The University of Michigan
35254Sksewell@umich.edu * All rights reserved.
42553SN/A *
55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are
75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
145254Sksewell@umich.edu * this software without specific prior written permission.
152553SN/A *
165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272632Sstever@eecs.umich.edu *
285254Sksewell@umich.edu * Authors: Korey Sewell
292553SN/A */
302553SN/A
312599SN/A#ifndef __ARCH_MIPS_LINUX_LINUX_HH__
322599SN/A#define __ARCH_MIPS_LINUX_LINUX_HH__
332553SN/A
342553SN/A#include "kern/linux/linux.hh"
352553SN/A
362553SN/Aclass MipsLinux : public Linux
372553SN/A{
382553SN/A  public:
392553SN/A
4011382Sbrandon.potter@amd.com    static const int TGT_SIGHUP         = 0x000001;
4111382Sbrandon.potter@amd.com    static const int TGT_SIGINT         = 0x000002;
4211382Sbrandon.potter@amd.com    static const int TGT_SIGQUIT        = 0x000003;
4311382Sbrandon.potter@amd.com    static const int TGT_SIGILL         = 0x000004;
4411382Sbrandon.potter@amd.com    static const int TGT_SIGTRAP        = 0x000005;
4511382Sbrandon.potter@amd.com    static const int TGT_SIGIOT         = 0x000006;
4611382Sbrandon.potter@amd.com    static const int TGT_SIGABRT        = 0x000006;
4711382Sbrandon.potter@amd.com    static const int TGT_SIGEMT         = 0x000007;
4811382Sbrandon.potter@amd.com    static const int TGT_SIGFPE         = 0x000008;
4911382Sbrandon.potter@amd.com    static const int TGT_SIGKILL        = 0x000009;
5011382Sbrandon.potter@amd.com    static const int TGT_SIGBUS         = 0x00000a;
5111382Sbrandon.potter@amd.com    static const int TGT_SIGSEGV        = 0x00000b;
5211382Sbrandon.potter@amd.com    static const int TGT_SIGSYS         = 0x00000c;
5311382Sbrandon.potter@amd.com    static const int TGT_SIGPIPE        = 0x00000d;
5411382Sbrandon.potter@amd.com    static const int TGT_SIGALRM        = 0x00000e;
5511382Sbrandon.potter@amd.com    static const int TGT_SIGTERM        = 0x00000f;
5611382Sbrandon.potter@amd.com    static const int TGT_SIGUSR1        = 0x000010;
5711382Sbrandon.potter@amd.com    static const int TGT_SIGUSR2        = 0x000011;
5811382Sbrandon.potter@amd.com    static const int TGT_SIGCHLD        = 0x000012;
5911382Sbrandon.potter@amd.com    static const int TGT_SIGCLD         = 0x000012;
6011382Sbrandon.potter@amd.com    static const int TGT_SIGPWR         = 0x000013;
6111382Sbrandon.potter@amd.com    static const int TGT_SIGWINCH       = 0x000014;
6211382Sbrandon.potter@amd.com    static const int TGT_SIGURG         = 0x000015;
6311382Sbrandon.potter@amd.com    static const int TGT_SIGIO          = 0x000016;
6411382Sbrandon.potter@amd.com    static const int TGT_SIGPOLL        = 0x000016;
6511382Sbrandon.potter@amd.com    static const int TGT_SIGSTOP        = 0x000017;
6611382Sbrandon.potter@amd.com    static const int TGT_SIGTSTP        = 0x000018;
6711382Sbrandon.potter@amd.com    static const int TGT_SIGCONT        = 0x000019;
6811382Sbrandon.potter@amd.com    static const int TGT_SIGTTIN        = 0x00001a;
6911382Sbrandon.potter@amd.com    static const int TGT_SIGTTOU        = 0x00001b;
7011382Sbrandon.potter@amd.com    static const int TGT_SIGVTALRM      = 0x00001c;
7111382Sbrandon.potter@amd.com    static const int TGT_SIGPROF        = 0x00001d;
7211382Sbrandon.potter@amd.com    static const int TGT_SIGXCPU        = 0x00001e;
7311382Sbrandon.potter@amd.com    static const int TGT_SIGXFSZ        = 0x00001f;
7411382Sbrandon.potter@amd.com
752553SN/A    /// This table maps the target open() flags to the corresponding
762553SN/A    /// host open() flags.
7711381Sbrandon.potter@amd.com    static SyscallFlagTransTable openFlagTable[];
782553SN/A
792553SN/A    /// Number of entries in openFlagTable[].
802553SN/A    static const int NUM_OPEN_FLAGS;
812553SN/A
822553SN/A    //@{
832553SN/A    /// open(2) flag values.
845543Ssaidi@eecs.umich.edu    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
855543Ssaidi@eecs.umich.edu    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
865543Ssaidi@eecs.umich.edu    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
875543Ssaidi@eecs.umich.edu    static const int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
885543Ssaidi@eecs.umich.edu    static const int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
895543Ssaidi@eecs.umich.edu    static const int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
9011382Sbrandon.potter@amd.com    static const int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
9111382Sbrandon.potter@amd.com    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
9211382Sbrandon.potter@amd.com    static const int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
9311382Sbrandon.potter@amd.com    static const int TGT_O_DSYNC        = 0x00000010;   //!< O_DSYNC
9411382Sbrandon.potter@amd.com    static const int TGT_O_DIRECT       = 0x00008000;   //!< O_DIRECT
9511382Sbrandon.potter@amd.com    static const int TGT_O_LARGEFILE    = 0x00002000;   //!< O_LARGEFILE
9611382Sbrandon.potter@amd.com    static const int TGT_O_DIRECTORY    = 0x00010000;   //!< O_DIRECTORY
9711382Sbrandon.potter@amd.com    static const int TGT_O_NOFOLLOW     = 0x00020000;   //!< O_NOFOLLOW
9811382Sbrandon.potter@amd.com    static const int TGT_O_NOATIME      = 0x00040000;   //!< O_NOATIME
9911382Sbrandon.potter@amd.com    static const int TGT_O_CLOEXEC      = 0x00080000;   //!< O_CLOEXEC
10011382Sbrandon.potter@amd.com    static const int TGT_O_SYNC         = 0x00004010;   //!< O_SYNC
10111382Sbrandon.potter@amd.com    static const int TGT_O_PATH         = 0x00200000;   //!< O_PATH
1022553SN/A    //@}
1032553SN/A
1042553SN/A    /// For mmap().
10511383Sbrandon.potter@amd.com    static SyscallFlagTransTable mmapFlagTable[];
10611383Sbrandon.potter@amd.com
10711383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_SHARED        = 0x00001;
10811383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_PRIVATE       = 0x00002;
10911383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_ANON          = 0x00800;
11011383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_DENYWRITE     = 0x02000;
11111383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_EXECUTABLE    = 0x04000;
11211383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_FILE          = 0x00000;
11311383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_GROWSDOWN     = 0x01000;
11411383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_HUGETLB       = 0x80000;
11511383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_LOCKED        = 0x08000;
11611383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_NONBLOCK      = 0x20000;
11711383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_NORESERVE     = 0x00400;
11811383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_POPULATE      = 0x10000;
11911383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_STACK         = 0x40000;
12011383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_ANONYMOUS     = 0x00800;
12111383Sbrandon.potter@amd.com    static const unsigned TGT_MAP_FIXED         = 0x00010;
12211383Sbrandon.potter@amd.com
12311383Sbrandon.potter@amd.com    static const unsigned NUM_MMAP_FLAGS;
1242553SN/A
1252553SN/A    //@{
1262553SN/A    /// For getsysinfo().
1276378Sgblack@eecs.umich.edu    static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
1286378Sgblack@eecs.umich.edu    static const unsigned GSI_CPU_INFO = 59;       //!< CPU information
1296378Sgblack@eecs.umich.edu    static const unsigned GSI_PROC_TYPE = 60;      //!< get proc_type
1306378Sgblack@eecs.umich.edu    static const unsigned GSI_MAX_CPU = 30;        //!< max # cpu's on this machine
1316378Sgblack@eecs.umich.edu    static const unsigned GSI_CPUS_IN_BOX = 55;    //!< number of CPUs in system
1326378Sgblack@eecs.umich.edu    static const unsigned GSI_PHYSMEM = 19;        //!< Physical memory in KB
1336378Sgblack@eecs.umich.edu    static const unsigned GSI_CLK_TCK = 42;        //!< clock freq in Hz
1342553SN/A    //@}
1352553SN/A
1362553SN/A    //@{
1372553SN/A    /// For setsysinfo().
1382553SN/A    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
1392553SN/A    //@}
1402553SN/A
1412553SN/A    //@{
1422553SN/A    /// ioctl() command codes.
1439141Smarc.orr@gmail.com    static const unsigned TGT_TCGETA     = 0x5401;
1449141Smarc.orr@gmail.com    static const unsigned TGT_TCSETAW    = 0x5403;
1459141Smarc.orr@gmail.com    static const unsigned TGT_TCGETS     = 0x540d;
1469141Smarc.orr@gmail.com    static const unsigned TGT_FIONREAD   = 0x467f;
1479141Smarc.orr@gmail.com    static const unsigned TGT_TIOCGETP   = 0x7408;
1489141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETP   = 0x7409;
1499141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETN   = 0x740a;
1502553SN/A    //@}
1512553SN/A
1529141Smarc.orr@gmail.com    static bool
1539141Smarc.orr@gmail.com    isTtyReq(unsigned req)
1549141Smarc.orr@gmail.com    {
1559141Smarc.orr@gmail.com        switch (req) {
1569141Smarc.orr@gmail.com          case TGT_TIOCGETP:
1579141Smarc.orr@gmail.com          case TGT_TIOCSETP:
1589141Smarc.orr@gmail.com          case TGT_TIOCSETN:
1599141Smarc.orr@gmail.com          case TGT_FIONREAD:
1609141Smarc.orr@gmail.com          case TGT_TCGETS:
1619141Smarc.orr@gmail.com          case TGT_TCGETA:
1629141Smarc.orr@gmail.com          case TGT_TCSETAW:
1639141Smarc.orr@gmail.com            return true;
1649141Smarc.orr@gmail.com          default:
1659141Smarc.orr@gmail.com            return false;
1669141Smarc.orr@gmail.com        }
1679141Smarc.orr@gmail.com    }
1689141Smarc.orr@gmail.com
1692553SN/A    /// For table().
1702553SN/A    static const int TBL_SYSINFO = 12;
1712555SN/A
1729146Smarc.orr@gmail.com    /// Resource constants for getrlimit() (overide some generics).
1739146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_NPROC = 8;
1749146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_AS = 6;
17510290Smitch.hayenga@arm.com    static const unsigned TGT_RLIMIT_RSS = 7;
1769146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_NOFILE = 5;
1779146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_MEMLOCK = 9;
1782555SN/A
1794661Sksewell@umich.edu    /// Offset used to make sure that processes don't
1804661Sksewell@umich.edu    /// assign themselves to process IDs reserved for
1814661Sksewell@umich.edu    /// the root users.
1824661Sksewell@umich.edu    static const int NUM_ROOT_PROCS = 2;
18311320Ssteve.reinhardt@amd.com
1846640Svince@csl.cornell.edu    typedef struct {
1856640Svince@csl.cornell.edu       int32_t  uptime;    /* Seconds since boot */
1866640Svince@csl.cornell.edu       uint32_t loads[3];  /* 1, 5, and 15 minute load averages */
1876640Svince@csl.cornell.edu       uint32_t totalram;  /* Total usable main memory size */
1886640Svince@csl.cornell.edu       uint32_t freeram;   /* Available memory size */
1896640Svince@csl.cornell.edu       uint32_t sharedram; /* Amount of shared memory */
1906640Svince@csl.cornell.edu       uint32_t bufferram; /* Memory used by buffers */
1916640Svince@csl.cornell.edu       uint32_t totalswap; /* Total swap space size */
1926640Svince@csl.cornell.edu       uint32_t freeswap;  /* swap space still available */
1936640Svince@csl.cornell.edu       uint16_t procs;     /* Number of current processes */
1946640Svince@csl.cornell.edu       uint32_t totalhigh; /* Total high memory size */
1956640Svince@csl.cornell.edu       uint32_t freehigh;  /* Available high memory size */
1966640Svince@csl.cornell.edu       uint32_t mem_unit;  /* Memory unit size in bytes */
1976640Svince@csl.cornell.edu    } tgt_sysinfo;
19811320Ssteve.reinhardt@amd.com
1992553SN/A};
2002553SN/A
2012553SN/A#endif
202