linux.hh revision 11382
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().
1052555SN/A    static const unsigned TGT_MAP_ANONYMOUS = 0x800;
1068600Ssteve.reinhardt@amd.com    static const unsigned TGT_MAP_FIXED     = 0x10;
1072553SN/A
1082553SN/A    //@{
1092553SN/A    /// For getsysinfo().
1106378Sgblack@eecs.umich.edu    static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
1116378Sgblack@eecs.umich.edu    static const unsigned GSI_CPU_INFO = 59;       //!< CPU information
1126378Sgblack@eecs.umich.edu    static const unsigned GSI_PROC_TYPE = 60;      //!< get proc_type
1136378Sgblack@eecs.umich.edu    static const unsigned GSI_MAX_CPU = 30;        //!< max # cpu's on this machine
1146378Sgblack@eecs.umich.edu    static const unsigned GSI_CPUS_IN_BOX = 55;    //!< number of CPUs in system
1156378Sgblack@eecs.umich.edu    static const unsigned GSI_PHYSMEM = 19;        //!< Physical memory in KB
1166378Sgblack@eecs.umich.edu    static const unsigned GSI_CLK_TCK = 42;        //!< clock freq in Hz
1172553SN/A    //@}
1182553SN/A
1192553SN/A    //@{
1202553SN/A    /// For setsysinfo().
1212553SN/A    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
1222553SN/A    //@}
1232553SN/A
1242553SN/A    //@{
1252553SN/A    /// ioctl() command codes.
1269141Smarc.orr@gmail.com    static const unsigned TGT_TCGETA     = 0x5401;
1279141Smarc.orr@gmail.com    static const unsigned TGT_TCSETAW    = 0x5403;
1289141Smarc.orr@gmail.com    static const unsigned TGT_TCGETS     = 0x540d;
1299141Smarc.orr@gmail.com    static const unsigned TGT_FIONREAD   = 0x467f;
1309141Smarc.orr@gmail.com    static const unsigned TGT_TIOCGETP   = 0x7408;
1319141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETP   = 0x7409;
1329141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETN   = 0x740a;
1332553SN/A    //@}
1342553SN/A
1359141Smarc.orr@gmail.com    static bool
1369141Smarc.orr@gmail.com    isTtyReq(unsigned req)
1379141Smarc.orr@gmail.com    {
1389141Smarc.orr@gmail.com        switch (req) {
1399141Smarc.orr@gmail.com          case TGT_TIOCGETP:
1409141Smarc.orr@gmail.com          case TGT_TIOCSETP:
1419141Smarc.orr@gmail.com          case TGT_TIOCSETN:
1429141Smarc.orr@gmail.com          case TGT_FIONREAD:
1439141Smarc.orr@gmail.com          case TGT_TCGETS:
1449141Smarc.orr@gmail.com          case TGT_TCGETA:
1459141Smarc.orr@gmail.com          case TGT_TCSETAW:
1469141Smarc.orr@gmail.com            return true;
1479141Smarc.orr@gmail.com          default:
1489141Smarc.orr@gmail.com            return false;
1499141Smarc.orr@gmail.com        }
1509141Smarc.orr@gmail.com    }
1519141Smarc.orr@gmail.com
1522553SN/A    /// For table().
1532553SN/A    static const int TBL_SYSINFO = 12;
1542555SN/A
1559146Smarc.orr@gmail.com    /// Resource constants for getrlimit() (overide some generics).
1569146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_NPROC = 8;
1579146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_AS = 6;
15810290Smitch.hayenga@arm.com    static const unsigned TGT_RLIMIT_RSS = 7;
1599146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_NOFILE = 5;
1609146Smarc.orr@gmail.com    static const unsigned TGT_RLIMIT_MEMLOCK = 9;
1612555SN/A
1624661Sksewell@umich.edu    /// Offset used to make sure that processes don't
1634661Sksewell@umich.edu    /// assign themselves to process IDs reserved for
1644661Sksewell@umich.edu    /// the root users.
1654661Sksewell@umich.edu    static const int NUM_ROOT_PROCS = 2;
16611320Ssteve.reinhardt@amd.com
1676640Svince@csl.cornell.edu    typedef struct {
1686640Svince@csl.cornell.edu       int32_t  uptime;    /* Seconds since boot */
1696640Svince@csl.cornell.edu       uint32_t loads[3];  /* 1, 5, and 15 minute load averages */
1706640Svince@csl.cornell.edu       uint32_t totalram;  /* Total usable main memory size */
1716640Svince@csl.cornell.edu       uint32_t freeram;   /* Available memory size */
1726640Svince@csl.cornell.edu       uint32_t sharedram; /* Amount of shared memory */
1736640Svince@csl.cornell.edu       uint32_t bufferram; /* Memory used by buffers */
1746640Svince@csl.cornell.edu       uint32_t totalswap; /* Total swap space size */
1756640Svince@csl.cornell.edu       uint32_t freeswap;  /* swap space still available */
1766640Svince@csl.cornell.edu       uint16_t procs;     /* Number of current processes */
1776640Svince@csl.cornell.edu       uint32_t totalhigh; /* Total high memory size */
1786640Svince@csl.cornell.edu       uint32_t freehigh;  /* Available high memory size */
1796640Svince@csl.cornell.edu       uint32_t mem_unit;  /* Memory unit size in bytes */
1806640Svince@csl.cornell.edu    } tgt_sysinfo;
18111320Ssteve.reinhardt@amd.com
1822553SN/A};
1832553SN/A
1842553SN/A#endif
185