linux.hh revision 11383
12579SN/A/* 22579SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32579SN/A * All rights reserved. 42579SN/A * 52579SN/A * Redistribution and use in source and binary forms, with or without 62579SN/A * modification, are permitted provided that the following conditions are 72579SN/A * met: redistributions of source code must retain the above copyright 82579SN/A * notice, this list of conditions and the following disclaimer; 92579SN/A * redistributions in binary form must reproduce the above copyright 102579SN/A * notice, this list of conditions and the following disclaimer in the 112579SN/A * documentation and/or other materials provided with the distribution; 122579SN/A * neither the name of the copyright holders nor the names of its 132579SN/A * contributors may be used to endorse or promote products derived from 142579SN/A * this software without specific prior written permission. 152579SN/A * 162579SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172579SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182579SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192579SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202579SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212579SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222579SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232579SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242579SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252579SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262579SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292579SN/A */ 302579SN/A 312599SN/A#ifndef __ARCH_SPARC_LINUX_LINUX_HH__ 322599SN/A#define __ARCH_SPARC_LINUX_LINUX_HH__ 332579SN/A 342579SN/A#include "kern/linux/linux.hh" 352579SN/A 362579SN/Aclass SparcLinux : public Linux 372579SN/A{ 382579SN/A public: 392579SN/A 403113Sgblack@eecs.umich.edu typedef struct { 413113Sgblack@eecs.umich.edu uint32_t st_dev; 423113Sgblack@eecs.umich.edu char __pad1[4]; 433113Sgblack@eecs.umich.edu uint64_t st_ino; 443113Sgblack@eecs.umich.edu uint32_t st_mode; 453113Sgblack@eecs.umich.edu uint16_t st_nlink; 463113Sgblack@eecs.umich.edu uint32_t st_uid; 473113Sgblack@eecs.umich.edu uint32_t st_gid; 483113Sgblack@eecs.umich.edu uint32_t st_rdev; 493113Sgblack@eecs.umich.edu char __pad2[4]; 503113Sgblack@eecs.umich.edu int64_t st_size; 513113Sgblack@eecs.umich.edu int64_t st_atimeX; 523113Sgblack@eecs.umich.edu int64_t st_mtimeX; 533113Sgblack@eecs.umich.edu int64_t st_ctimeX; 543113Sgblack@eecs.umich.edu int64_t st_blksize; 553113Sgblack@eecs.umich.edu int64_t st_blocks; 563113Sgblack@eecs.umich.edu uint64_t __unused4[2]; 573113Sgblack@eecs.umich.edu } tgt_stat; 583113Sgblack@eecs.umich.edu 5911382Sbrandon.potter@amd.com // SPARC receives weird subsignals for several of its signals. If you 6011382Sbrandon.potter@amd.com // find yourself needing to implement these in detail, look at the 6111382Sbrandon.potter@amd.com // Linux source. 6211382Sbrandon.potter@amd.com static const int TGT_SIGHUP = 0x000001; 6311382Sbrandon.potter@amd.com static const int TGT_SIGINT = 0x000002; 6411382Sbrandon.potter@amd.com static const int TGT_SIGQUIT = 0x000003; 6511382Sbrandon.potter@amd.com static const int TGT_SIGILL = 0x000004; 6611382Sbrandon.potter@amd.com static const int TGT_SIGTRAP = 0x000005; 6711382Sbrandon.potter@amd.com static const int TGT_SIGABRT = 0x000006; 6811382Sbrandon.potter@amd.com static const int TGT_SIGIOT = 0x000006; 6911382Sbrandon.potter@amd.com static const int TGT_SIGEMT = 0x000007; 7011382Sbrandon.potter@amd.com static const int TGT_SIGFPE = 0x000008; 7111382Sbrandon.potter@amd.com static const int TGT_SIGKILL = 0x000009; 7211382Sbrandon.potter@amd.com static const int TGT_SIGBUS = 0x00000a; 7311382Sbrandon.potter@amd.com static const int TGT_SIGSEGV = 0x00000b; 7411382Sbrandon.potter@amd.com static const int TGT_SIGSYS = 0x00000c; 7511382Sbrandon.potter@amd.com static const int TGT_SIGPIPE = 0x00000d; 7611382Sbrandon.potter@amd.com static const int TGT_SIGALRM = 0x00000e; 7711382Sbrandon.potter@amd.com static const int TGT_SIGTERM = 0x00000f; 7811382Sbrandon.potter@amd.com static const int TGT_SIGURG = 0x000010; 7911382Sbrandon.potter@amd.com static const int TGT_SIGSTOP = 0x000011; 8011382Sbrandon.potter@amd.com static const int TGT_SIGTSTP = 0x000012; 8111382Sbrandon.potter@amd.com static const int TGT_SIGCONT = 0x000013; 8211382Sbrandon.potter@amd.com static const int TGT_SIGCHLD = 0x000014; 8311382Sbrandon.potter@amd.com static const int TGT_SIGTTIN = 0x000015; 8411382Sbrandon.potter@amd.com static const int TGT_SIGTTOU = 0x000016; 8511382Sbrandon.potter@amd.com static const int TGT_SIGIO = 0x000017; 8611382Sbrandon.potter@amd.com static const int TGT_SIGPOLL = 0x000017; 8711382Sbrandon.potter@amd.com static const int TGT_SIGXCPU = 0x000018; 8811382Sbrandon.potter@amd.com static const int TGT_SIGXFSZ = 0x000019; 8911382Sbrandon.potter@amd.com static const int TGT_SIGVTALRM = 0x00001a; 9011382Sbrandon.potter@amd.com static const int TGT_SIGPROF = 0x00001b; 9111382Sbrandon.potter@amd.com static const int TGT_SIGWINCH = 0x00001c; 9211382Sbrandon.potter@amd.com static const int TGT_SIGLOST = 0x00001d; 9311382Sbrandon.potter@amd.com static const int TGT_SIGPWR = 0x00001d; 9411382Sbrandon.potter@amd.com static const int TGT_SIGUSR1 = 0x00001e; 9511382Sbrandon.potter@amd.com static const int TGT_SIGUSR2 = 0x00001f; 9611382Sbrandon.potter@amd.com 9711381Sbrandon.potter@amd.com static SyscallFlagTransTable openFlagTable[]; 982579SN/A 995543Ssaidi@eecs.umich.edu static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY 1005543Ssaidi@eecs.umich.edu static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY 1015543Ssaidi@eecs.umich.edu static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR 1025543Ssaidi@eecs.umich.edu static const int TGT_O_NONBLOCK = 0x00004000; //!< O_NONBLOCK 1035543Ssaidi@eecs.umich.edu static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND 10411382Sbrandon.potter@amd.com static const int TGT_FASYNC = 0x00000040; //!< FASYNC 1055543Ssaidi@eecs.umich.edu static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT 1065543Ssaidi@eecs.umich.edu static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC 1075543Ssaidi@eecs.umich.edu static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL 1085543Ssaidi@eecs.umich.edu static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY 1095543Ssaidi@eecs.umich.edu static const int TGT_O_SYNC = 0x00002000; //!< O_SYNC 11011382Sbrandon.potter@amd.com static const int TGT_O_LARGEFILE = 0x00040000; //!< O_LARGEFILE 11111382Sbrandon.potter@amd.com static const int TGT_O_DIRECT = 0x00100000; //!< O_DIRECT 11211382Sbrandon.potter@amd.com static const int TGT_O_NOATIME = 0x00200000; //!< O_NOATIME 11311382Sbrandon.potter@amd.com static const int TGT_O_CLOEXEC = 0x00400000; //!< O_CLOEXEC 11411382Sbrandon.potter@amd.com static const int TGT_O_PATH = 0x01000000; //!< O_PATH 11511382Sbrandon.potter@amd.com 11611382Sbrandon.potter@amd.com static const int TGT_O_DIRECTORY = 000200000; //!< O_DIRECTORY 11711382Sbrandon.potter@amd.com static const int TGT_O_NOFOLLOW = 000400000; //!< O_NOFOLLOW 1182579SN/A 1192579SN/A static const int NUM_OPEN_FLAGS; 1202579SN/A 12111383Sbrandon.potter@amd.com /// For mmap(). 12211383Sbrandon.potter@amd.com static SyscallFlagTransTable mmapFlagTable[]; 12311383Sbrandon.potter@amd.com 12411383Sbrandon.potter@amd.com static const unsigned TGT_MAP_SHARED = 0x00001; 12511383Sbrandon.potter@amd.com static const unsigned TGT_MAP_PRIVATE = 0x00002; 12611383Sbrandon.potter@amd.com static const unsigned TGT_MAP_ANON = 0x00020; 12711383Sbrandon.potter@amd.com static const unsigned TGT_MAP_DENYWRITE = 0x00800; 12811383Sbrandon.potter@amd.com static const unsigned TGT_MAP_EXECUTABLE = 0x01000; 12911383Sbrandon.potter@amd.com static const unsigned TGT_MAP_FILE = 0x00000; 13011383Sbrandon.potter@amd.com static const unsigned TGT_MAP_GROWSDOWN = 0x00200; 13111383Sbrandon.potter@amd.com static const unsigned TGT_MAP_HUGETLB = 0x40000; 13211383Sbrandon.potter@amd.com static const unsigned TGT_MAP_LOCKED = 0x00100; 13311383Sbrandon.potter@amd.com static const unsigned TGT_MAP_NONBLOCK = 0x10000; 13411383Sbrandon.potter@amd.com static const unsigned TGT_MAP_NORESERVE = 0x00040; 13511383Sbrandon.potter@amd.com static const unsigned TGT_MAP_POPULATE = 0x08000; 13611383Sbrandon.potter@amd.com static const unsigned TGT_MAP_STACK = 0x20000; 13711383Sbrandon.potter@amd.com static const unsigned TGT_MAP_ANONYMOUS = 0x00020; 13811383Sbrandon.potter@amd.com static const unsigned TGT_MAP_FIXED = 0x00010; 13911383Sbrandon.potter@amd.com static const unsigned TGT_MAP_INHERIT = 0x00080; 14011383Sbrandon.potter@amd.com 14111383Sbrandon.potter@amd.com static const unsigned NUM_MMAP_FLAGS; 14211320Ssteve.reinhardt@amd.com 14311320Ssteve.reinhardt@amd.com typedef struct { 1446640Svince@csl.cornell.edu int64_t uptime; /* Seconds since boot */ 1456640Svince@csl.cornell.edu uint64_t loads[3]; /* 1, 5, and 15 minute load averages */ 1466640Svince@csl.cornell.edu uint64_t totalram; /* Total usable main memory size */ 1476640Svince@csl.cornell.edu uint64_t freeram; /* Available memory size */ 1486640Svince@csl.cornell.edu uint64_t sharedram; /* Amount of shared memory */ 1496640Svince@csl.cornell.edu uint64_t bufferram; /* Memory used by buffers */ 1506640Svince@csl.cornell.edu uint64_t totalswap; /* Total swap space size */ 1516640Svince@csl.cornell.edu uint64_t freeswap; /* swap space still available */ 1526640Svince@csl.cornell.edu uint16_t procs; /* Number of current processes */ 1536640Svince@csl.cornell.edu uint64_t totalhigh; /* Total high memory size */ 1546640Svince@csl.cornell.edu uint64_t freehigh; /* Available high memory size */ 1556640Svince@csl.cornell.edu uint64_t mem_unit; /* Memory unit size in bytes */ 1566640Svince@csl.cornell.edu } tgt_sysinfo; 1576640Svince@csl.cornell.edu 1589141Smarc.orr@gmail.com //@{ 1599141Smarc.orr@gmail.com /// ioctl() command codes. 1609141Smarc.orr@gmail.com /// These were calculated using the SPARC Linux headers on an x86 1619141Smarc.orr@gmail.com /// machine and thus may not be correct. It would be good to 1629141Smarc.orr@gmail.com /// verify/update these values on an actual SPARC Linux machine. 1639141Smarc.orr@gmail.com static const unsigned TGT_TCGETA = 0x40125401; 1649141Smarc.orr@gmail.com static const unsigned TGT_TCSETAW = 0x80125403; 1659141Smarc.orr@gmail.com static const unsigned TGT_TCGETS = 0x40385408; 1669141Smarc.orr@gmail.com static const unsigned TGT_FIONREAD = 0x4004667f; 1679141Smarc.orr@gmail.com static const unsigned TGT_TIOCGETP = 0x40067408; 1689141Smarc.orr@gmail.com static const unsigned TGT_TIOCSETP = 0x80067409; 1699141Smarc.orr@gmail.com static const unsigned TGT_TIOCSETN = 0x8006740a; 1709141Smarc.orr@gmail.com //@} 1719141Smarc.orr@gmail.com 1729141Smarc.orr@gmail.com static bool 1739141Smarc.orr@gmail.com isTtyReq(unsigned req) 1749141Smarc.orr@gmail.com { 1759141Smarc.orr@gmail.com switch (req) { 1769141Smarc.orr@gmail.com case TGT_TIOCGETP: 1779141Smarc.orr@gmail.com case TGT_TIOCSETP: 1789141Smarc.orr@gmail.com case TGT_TIOCSETN: 1799141Smarc.orr@gmail.com case TGT_TCGETS: 1809141Smarc.orr@gmail.com case TGT_TCGETA: 1819141Smarc.orr@gmail.com case TGT_TCSETAW: 1829141Smarc.orr@gmail.com return true; 1839141Smarc.orr@gmail.com default: 1849141Smarc.orr@gmail.com return false; 1859141Smarc.orr@gmail.com } 1869141Smarc.orr@gmail.com } 1872579SN/A}; 1882579SN/A 1894188Sgblack@eecs.umich.educlass Sparc32Linux : public SparcLinux 1904188Sgblack@eecs.umich.edu{ 1914188Sgblack@eecs.umich.edu public: 1924188Sgblack@eecs.umich.edu 1934188Sgblack@eecs.umich.edu typedef struct { 1944188Sgblack@eecs.umich.edu uint64_t st_dev; 1954188Sgblack@eecs.umich.edu uint64_t st_ino; 1964188Sgblack@eecs.umich.edu uint32_t st_mode; 1974188Sgblack@eecs.umich.edu uint32_t st_nlink; 1984188Sgblack@eecs.umich.edu uint32_t st_uid; 1994188Sgblack@eecs.umich.edu uint32_t st_gid; 2004188Sgblack@eecs.umich.edu uint64_t st_rdev; 2014188Sgblack@eecs.umich.edu uint8_t __pad3[8]; 2024188Sgblack@eecs.umich.edu int64_t st_size; 2034188Sgblack@eecs.umich.edu int32_t st_blksize; 2044188Sgblack@eecs.umich.edu uint8_t __pad4[8]; 2054188Sgblack@eecs.umich.edu int64_t st_blocks; 2064188Sgblack@eecs.umich.edu uint64_t st_atimeX; 2074188Sgblack@eecs.umich.edu uint64_t st_atime_nsec; 2084188Sgblack@eecs.umich.edu uint64_t st_mtimeX; 2094188Sgblack@eecs.umich.edu uint64_t st_mtime_nsec; 2104188Sgblack@eecs.umich.edu uint64_t st_ctimeX; 2114188Sgblack@eecs.umich.edu uint64_t st_ctime_nsec; 2124188Sgblack@eecs.umich.edu uint32_t __unused4; 2134188Sgblack@eecs.umich.edu uint32_t __unused5; 2144188Sgblack@eecs.umich.edu } tgt_stat64; 21511320Ssteve.reinhardt@amd.com 2166640Svince@csl.cornell.edu typedef struct { 2176640Svince@csl.cornell.edu int32_t uptime; /* Seconds since boot */ 2186640Svince@csl.cornell.edu uint32_t loads[3]; /* 1, 5, and 15 minute load averages */ 2196640Svince@csl.cornell.edu uint32_t totalram; /* Total usable main memory size */ 2206640Svince@csl.cornell.edu uint32_t freeram; /* Available memory size */ 2216640Svince@csl.cornell.edu uint32_t sharedram; /* Amount of shared memory */ 2226640Svince@csl.cornell.edu uint32_t bufferram; /* Memory used by buffers */ 2236640Svince@csl.cornell.edu uint32_t totalswap; /* Total swap space size */ 2246640Svince@csl.cornell.edu uint32_t freeswap; /* swap space still available */ 2256640Svince@csl.cornell.edu uint16_t procs; /* Number of current processes */ 2266640Svince@csl.cornell.edu uint32_t totalhigh; /* Total high memory size */ 2276640Svince@csl.cornell.edu uint32_t freehigh; /* Available high memory size */ 2286640Svince@csl.cornell.edu uint32_t mem_unit; /* Memory unit size in bytes */ 22911320Ssteve.reinhardt@amd.com } tgt_sysinfo; 2306640Svince@csl.cornell.edu 2319146Smarc.orr@gmail.com /// Resource constants for getrlimit() (overide some generics). 2329146Smarc.orr@gmail.com static const unsigned TGT_RLIMIT_NPROC = 7; 2339146Smarc.orr@gmail.com static const unsigned TGT_RLIMIT_NOFILE = 6; 2344188Sgblack@eecs.umich.edu}; 2354188Sgblack@eecs.umich.edu 2362579SN/A#endif 237