linux.hh revision 11382
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 1212579SN/A static const unsigned TGT_MAP_ANONYMOUS = 0x20; 1228600Ssteve.reinhardt@amd.com static const unsigned TGT_MAP_FIXED = 0x10; 12311320Ssteve.reinhardt@amd.com 12411320Ssteve.reinhardt@amd.com typedef struct { 1256640Svince@csl.cornell.edu int64_t uptime; /* Seconds since boot */ 1266640Svince@csl.cornell.edu uint64_t loads[3]; /* 1, 5, and 15 minute load averages */ 1276640Svince@csl.cornell.edu uint64_t totalram; /* Total usable main memory size */ 1286640Svince@csl.cornell.edu uint64_t freeram; /* Available memory size */ 1296640Svince@csl.cornell.edu uint64_t sharedram; /* Amount of shared memory */ 1306640Svince@csl.cornell.edu uint64_t bufferram; /* Memory used by buffers */ 1316640Svince@csl.cornell.edu uint64_t totalswap; /* Total swap space size */ 1326640Svince@csl.cornell.edu uint64_t freeswap; /* swap space still available */ 1336640Svince@csl.cornell.edu uint16_t procs; /* Number of current processes */ 1346640Svince@csl.cornell.edu uint64_t totalhigh; /* Total high memory size */ 1356640Svince@csl.cornell.edu uint64_t freehigh; /* Available high memory size */ 1366640Svince@csl.cornell.edu uint64_t mem_unit; /* Memory unit size in bytes */ 1376640Svince@csl.cornell.edu } tgt_sysinfo; 1386640Svince@csl.cornell.edu 1399141Smarc.orr@gmail.com //@{ 1409141Smarc.orr@gmail.com /// ioctl() command codes. 1419141Smarc.orr@gmail.com /// These were calculated using the SPARC Linux headers on an x86 1429141Smarc.orr@gmail.com /// machine and thus may not be correct. It would be good to 1439141Smarc.orr@gmail.com /// verify/update these values on an actual SPARC Linux machine. 1449141Smarc.orr@gmail.com static const unsigned TGT_TCGETA = 0x40125401; 1459141Smarc.orr@gmail.com static const unsigned TGT_TCSETAW = 0x80125403; 1469141Smarc.orr@gmail.com static const unsigned TGT_TCGETS = 0x40385408; 1479141Smarc.orr@gmail.com static const unsigned TGT_FIONREAD = 0x4004667f; 1489141Smarc.orr@gmail.com static const unsigned TGT_TIOCGETP = 0x40067408; 1499141Smarc.orr@gmail.com static const unsigned TGT_TIOCSETP = 0x80067409; 1509141Smarc.orr@gmail.com static const unsigned TGT_TIOCSETN = 0x8006740a; 1519141Smarc.orr@gmail.com //@} 1529141Smarc.orr@gmail.com 1539141Smarc.orr@gmail.com static bool 1549141Smarc.orr@gmail.com isTtyReq(unsigned req) 1559141Smarc.orr@gmail.com { 1569141Smarc.orr@gmail.com switch (req) { 1579141Smarc.orr@gmail.com case TGT_TIOCGETP: 1589141Smarc.orr@gmail.com case TGT_TIOCSETP: 1599141Smarc.orr@gmail.com case TGT_TIOCSETN: 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 } 1682579SN/A}; 1692579SN/A 1704188Sgblack@eecs.umich.educlass Sparc32Linux : public SparcLinux 1714188Sgblack@eecs.umich.edu{ 1724188Sgblack@eecs.umich.edu public: 1734188Sgblack@eecs.umich.edu 1744188Sgblack@eecs.umich.edu typedef struct { 1754188Sgblack@eecs.umich.edu uint64_t st_dev; 1764188Sgblack@eecs.umich.edu uint64_t st_ino; 1774188Sgblack@eecs.umich.edu uint32_t st_mode; 1784188Sgblack@eecs.umich.edu uint32_t st_nlink; 1794188Sgblack@eecs.umich.edu uint32_t st_uid; 1804188Sgblack@eecs.umich.edu uint32_t st_gid; 1814188Sgblack@eecs.umich.edu uint64_t st_rdev; 1824188Sgblack@eecs.umich.edu uint8_t __pad3[8]; 1834188Sgblack@eecs.umich.edu int64_t st_size; 1844188Sgblack@eecs.umich.edu int32_t st_blksize; 1854188Sgblack@eecs.umich.edu uint8_t __pad4[8]; 1864188Sgblack@eecs.umich.edu int64_t st_blocks; 1874188Sgblack@eecs.umich.edu uint64_t st_atimeX; 1884188Sgblack@eecs.umich.edu uint64_t st_atime_nsec; 1894188Sgblack@eecs.umich.edu uint64_t st_mtimeX; 1904188Sgblack@eecs.umich.edu uint64_t st_mtime_nsec; 1914188Sgblack@eecs.umich.edu uint64_t st_ctimeX; 1924188Sgblack@eecs.umich.edu uint64_t st_ctime_nsec; 1934188Sgblack@eecs.umich.edu uint32_t __unused4; 1944188Sgblack@eecs.umich.edu uint32_t __unused5; 1954188Sgblack@eecs.umich.edu } tgt_stat64; 19611320Ssteve.reinhardt@amd.com 1976640Svince@csl.cornell.edu typedef struct { 1986640Svince@csl.cornell.edu int32_t uptime; /* Seconds since boot */ 1996640Svince@csl.cornell.edu uint32_t loads[3]; /* 1, 5, and 15 minute load averages */ 2006640Svince@csl.cornell.edu uint32_t totalram; /* Total usable main memory size */ 2016640Svince@csl.cornell.edu uint32_t freeram; /* Available memory size */ 2026640Svince@csl.cornell.edu uint32_t sharedram; /* Amount of shared memory */ 2036640Svince@csl.cornell.edu uint32_t bufferram; /* Memory used by buffers */ 2046640Svince@csl.cornell.edu uint32_t totalswap; /* Total swap space size */ 2056640Svince@csl.cornell.edu uint32_t freeswap; /* swap space still available */ 2066640Svince@csl.cornell.edu uint16_t procs; /* Number of current processes */ 2076640Svince@csl.cornell.edu uint32_t totalhigh; /* Total high memory size */ 2086640Svince@csl.cornell.edu uint32_t freehigh; /* Available high memory size */ 2096640Svince@csl.cornell.edu uint32_t mem_unit; /* Memory unit size in bytes */ 21011320Ssteve.reinhardt@amd.com } tgt_sysinfo; 2116640Svince@csl.cornell.edu 2129146Smarc.orr@gmail.com /// Resource constants for getrlimit() (overide some generics). 2139146Smarc.orr@gmail.com static const unsigned TGT_RLIMIT_NPROC = 7; 2149146Smarc.orr@gmail.com static const unsigned TGT_RLIMIT_NOFILE = 6; 2154188Sgblack@eecs.umich.edu}; 2164188Sgblack@eecs.umich.edu 2172579SN/A#endif 218