linux.hh revision 9141
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
402553SN/A    /// This table maps the target open() flags to the corresponding
412553SN/A    /// host open() flags.
422553SN/A    static OpenFlagTransTable openFlagTable[];
432553SN/A
442553SN/A    /// Number of entries in openFlagTable[].
452553SN/A    static const int NUM_OPEN_FLAGS;
462553SN/A
472553SN/A    //@{
482553SN/A    /// open(2) flag values.
495543Ssaidi@eecs.umich.edu    static const int TGT_O_RDONLY       = 0x00000000;   //!< O_RDONLY
505543Ssaidi@eecs.umich.edu    static const int TGT_O_WRONLY       = 0x00000001;   //!< O_WRONLY
515543Ssaidi@eecs.umich.edu    static const int TGT_O_RDWR         = 0x00000002;   //!< O_RDWR
525543Ssaidi@eecs.umich.edu    static const int TGT_O_NONBLOCK     = 0x00000080;   //!< O_NONBLOCK
535543Ssaidi@eecs.umich.edu    static const int TGT_O_APPEND       = 0x00000008;   //!< O_APPEND
545543Ssaidi@eecs.umich.edu    static const int TGT_O_CREAT        = 0x00000100;   //!< O_CREAT
555543Ssaidi@eecs.umich.edu    static const int TGT_O_TRUNC        = 0x00000200;   //!< O_TRUNC
565543Ssaidi@eecs.umich.edu    static const int TGT_O_EXCL         = 0x00000400;   //!< O_EXCL
575543Ssaidi@eecs.umich.edu    static const int TGT_O_NOCTTY       = 0x00000800;   //!< O_NOCTTY
585543Ssaidi@eecs.umich.edu    static const int TGT_O_SYNC         = 0x00000010;   //!< O_SYNC
595543Ssaidi@eecs.umich.edu    static const int TGT_O_DRD          = 0x00010000;   //!< O_DRD
605543Ssaidi@eecs.umich.edu    static const int TGT_O_DIRECTIO     = 0x00020000;   //!< O_DIRECTIO
615543Ssaidi@eecs.umich.edu    static const int TGT_O_CACHE        = 0x00002000;   //!< O_CACHE
625543Ssaidi@eecs.umich.edu    static const int TGT_O_DSYNC        = 0x00008000;   //!< O_DSYNC
635543Ssaidi@eecs.umich.edu    static const int TGT_O_RSYNC        = 0x00040000;   //!< O_RSYNC
642553SN/A    //@}
652553SN/A
662553SN/A    /// For mmap().
672555SN/A    static const unsigned TGT_MAP_ANONYMOUS = 0x800;
688600Ssteve.reinhardt@amd.com    static const unsigned TGT_MAP_FIXED     = 0x10;
692553SN/A
702553SN/A    //@{
712553SN/A    /// For getsysinfo().
726378Sgblack@eecs.umich.edu    static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
736378Sgblack@eecs.umich.edu    static const unsigned GSI_CPU_INFO = 59;       //!< CPU information
746378Sgblack@eecs.umich.edu    static const unsigned GSI_PROC_TYPE = 60;      //!< get proc_type
756378Sgblack@eecs.umich.edu    static const unsigned GSI_MAX_CPU = 30;        //!< max # cpu's on this machine
766378Sgblack@eecs.umich.edu    static const unsigned GSI_CPUS_IN_BOX = 55;    //!< number of CPUs in system
776378Sgblack@eecs.umich.edu    static const unsigned GSI_PHYSMEM = 19;        //!< Physical memory in KB
786378Sgblack@eecs.umich.edu    static const unsigned GSI_CLK_TCK = 42;        //!< clock freq in Hz
792553SN/A    //@}
802553SN/A
812553SN/A    //@{
822553SN/A    /// For getrusage().
832553SN/A    static const int TGT_RUSAGE_SELF = 0;
842553SN/A    static const int TGT_RUSAGE_CHILDREN = -1;
852553SN/A    static const int TGT_RUSAGE_BOTH = -2;
862553SN/A    //@}
872553SN/A
882553SN/A    //@{
892553SN/A    /// For setsysinfo().
902553SN/A    static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
912553SN/A    //@}
922553SN/A
932553SN/A    //@{
942553SN/A    /// ioctl() command codes.
959141Smarc.orr@gmail.com    static const unsigned TGT_TCGETA     = 0x5401;
969141Smarc.orr@gmail.com    static const unsigned TGT_TCSETAW    = 0x5403;
979141Smarc.orr@gmail.com    static const unsigned TGT_TCGETS     = 0x540d;
989141Smarc.orr@gmail.com    static const unsigned TGT_FIONREAD   = 0x467f;
999141Smarc.orr@gmail.com    static const unsigned TGT_TIOCGETP   = 0x7408;
1009141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETP   = 0x7409;
1019141Smarc.orr@gmail.com    static const unsigned TGT_TIOCSETN   = 0x740a;
1022553SN/A    //@}
1032553SN/A
1049141Smarc.orr@gmail.com    static bool
1059141Smarc.orr@gmail.com    isTtyReq(unsigned req)
1069141Smarc.orr@gmail.com    {
1079141Smarc.orr@gmail.com        switch (req) {
1089141Smarc.orr@gmail.com          case TGT_TIOCGETP:
1099141Smarc.orr@gmail.com          case TGT_TIOCSETP:
1109141Smarc.orr@gmail.com          case TGT_TIOCSETN:
1119141Smarc.orr@gmail.com          case TGT_FIONREAD:
1129141Smarc.orr@gmail.com          case TGT_TCGETS:
1139141Smarc.orr@gmail.com          case TGT_TCGETA:
1149141Smarc.orr@gmail.com          case TGT_TCSETAW:
1159141Smarc.orr@gmail.com            return true;
1169141Smarc.orr@gmail.com          default:
1179141Smarc.orr@gmail.com            return false;
1189141Smarc.orr@gmail.com        }
1199141Smarc.orr@gmail.com    }
1209141Smarc.orr@gmail.com
1212553SN/A    /// For table().
1222553SN/A    static const int TBL_SYSINFO = 12;
1232555SN/A
1244661Sksewell@umich.edu    /// Resource enumeration for getrlimit()/setrlimit().
1252555SN/A    enum rlimit_resources {
1262555SN/A        TGT_RLIMIT_CPU = 0,
1272555SN/A        TGT_RLIMIT_FSIZE = 1,
1282555SN/A        TGT_RLIMIT_DATA = 2,
1292555SN/A        TGT_RLIMIT_STACK = 3,
1302555SN/A        TGT_RLIMIT_CORE = 4,
1312555SN/A        TGT_RLIMIT_NOFILE = 5,
1322555SN/A        TGT_RLIMIT_AS = 6,
1332555SN/A        TGT_RLIMIT_RSS = 7,
1342555SN/A        TGT_RLIMIT_VMEM = 7,
1352555SN/A        TGT_RLIMIT_NPROC = 8,
1362555SN/A        TGT_RLIMIT_MEMLOCK = 9,
1374661Sksewell@umich.edu        TGT_RLIMIT_LOCKS = 10,
1384661Sksewell@umich.edu        NUM_RLIMIT_RESOURCES
1392555SN/A    };
1402555SN/A
1414661Sksewell@umich.edu    /// Offset used to make sure that processes don't
1424661Sksewell@umich.edu    /// assign themselves to process IDs reserved for
1434661Sksewell@umich.edu    /// the root users.
1444661Sksewell@umich.edu    static const int NUM_ROOT_PROCS = 2;
1456640Svince@csl.cornell.edu
1466640Svince@csl.cornell.edu    typedef struct {
1476640Svince@csl.cornell.edu       int32_t  uptime;    /* Seconds since boot */
1486640Svince@csl.cornell.edu       uint32_t loads[3];  /* 1, 5, and 15 minute load averages */
1496640Svince@csl.cornell.edu       uint32_t totalram;  /* Total usable main memory size */
1506640Svince@csl.cornell.edu       uint32_t freeram;   /* Available memory size */
1516640Svince@csl.cornell.edu       uint32_t sharedram; /* Amount of shared memory */
1526640Svince@csl.cornell.edu       uint32_t bufferram; /* Memory used by buffers */
1536640Svince@csl.cornell.edu       uint32_t totalswap; /* Total swap space size */
1546640Svince@csl.cornell.edu       uint32_t freeswap;  /* swap space still available */
1556640Svince@csl.cornell.edu       uint16_t procs;     /* Number of current processes */
1566640Svince@csl.cornell.edu       uint32_t totalhigh; /* Total high memory size */
1576640Svince@csl.cornell.edu       uint32_t freehigh;  /* Available high memory size */
1586640Svince@csl.cornell.edu       uint32_t mem_unit;  /* Memory unit size in bytes */
1596640Svince@csl.cornell.edu    } tgt_sysinfo;
1606640Svince@csl.cornell.edu
1612553SN/A};
1622553SN/A
1632553SN/A#endif
164