linux.hh revision 5795
11689SN/A/* 22316SN/A * Copyright (c) 2004-2009 The Regents of The University of Michigan 31689SN/A * All rights reserved. 41689SN/A * 51689SN/A * Redistribution and use in source and binary forms, with or without 61689SN/A * modification, are permitted provided that the following conditions are 71689SN/A * met: redistributions of source code must retain the above copyright 81689SN/A * notice, this list of conditions and the following disclaimer; 91689SN/A * redistributions in binary form must reproduce the above copyright 101689SN/A * notice, this list of conditions and the following disclaimer in the 111689SN/A * documentation and/or other materials provided with the distribution; 121689SN/A * neither the name of the copyright holders nor the names of its 131689SN/A * contributors may be used to endorse or promote products derived from 141689SN/A * this software without specific prior written permission. 151689SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 292965Sksewell@umich.edu */ 301689SN/A 311689SN/A#ifndef __LINUX_HH__ 322733Sktlim@umich.edu#define __LINUX_HH__ 332733Sktlim@umich.edu#include "config/full_system.hh" 342733Sktlim@umich.edu 352292SN/A#if FULL_SYSTEM 362329SN/A 372292SN/Aclass Linux {}; 383577Sgblack@eecs.umich.edu 392292SN/A#else //!FULL_SYSTEM 401060SN/A 412292SN/A#include <inttypes.h> 421717SN/A#include <string> 432292SN/A 442292SN/A#include "kern/operatingsystem.hh" 452790Sktlim@umich.edu 462790Sktlim@umich.educlass ThreadContext; 472790Sktlim@umich.educlass LiveProcess; 482790Sktlim@umich.edu 491061SN/A/// 502292SN/A/// This class encapsulates the types, structures, constants, 512292SN/A/// functions, and syscall-number mappings specific to the Alpha Linux 522292SN/A/// syscall interface. 531060SN/A/// 542292SN/Aclass Linux : public OperatingSystem 551060SN/A{ 561060SN/A 571061SN/A public: 581060SN/A 592292SN/A //@{ 601062SN/A /// Basic Linux types. 612316SN/A typedef uint64_t size_t; 622316SN/A typedef uint64_t off_t; 632292SN/A typedef int64_t time_t; 642292SN/A typedef uint32_t uid_t; 652292SN/A typedef uint32_t gid_t; 662292SN/A //@} 672292SN/A 682292SN/A /// Stat buffer. Note that we can't call it 'stat' since that 692292SN/A /// gets #defined to something else on some systems. This type 702292SN/A /// can be specialized by architecture specific "Linux" classes 712292SN/A typedef struct { 722292SN/A uint32_t st_dev; //!< device 732292SN/A uint32_t st_ino; //!< inode 742292SN/A uint32_t st_mode; //!< mode 752669Sktlim@umich.edu uint32_t st_nlink; //!< link count 762292SN/A uint32_t st_uid; //!< owner's user ID 772292SN/A uint32_t st_gid; //!< owner's group ID 782292SN/A uint32_t st_rdev; //!< device number 792292SN/A int32_t _pad1; //!< for alignment 802292SN/A int64_t st_size; //!< file size in bytes 812292SN/A uint64_t st_atimeX; //!< time of last access 822307SN/A uint64_t st_mtimeX; //!< time of last modification 832843Sktlim@umich.edu uint64_t st_ctimeX; //!< time of last status change 842316SN/A uint32_t st_blksize; //!< optimal I/O block size 852874Sktlim@umich.edu int32_t st_blocks; //!< number of blocks allocated 862292SN/A uint32_t st_flags; //!< flags 872292SN/A uint32_t st_gen; //!< unknown 882292SN/A } tgt_stat; 892980Sgblack@eecs.umich.edu 902292SN/A // same for stat64 912292SN/A typedef struct { 922292SN/A uint64_t st_dev; 932292SN/A uint64_t st_ino; 942292SN/A uint64_t st_rdev; 952292SN/A int64_t st_size; 962292SN/A uint64_t st_blocks; 972292SN/A 982292SN/A uint32_t st_mode; 992292SN/A uint32_t st_uid; 1002292SN/A uint32_t st_gid; 1012292SN/A uint32_t st_blksize; 1022292SN/A uint32_t st_nlink; 1032292SN/A uint32_t __pad0; 1042292SN/A 1052292SN/A uint64_t st_atimeX; 1062292SN/A uint64_t st_atime_nsec; 1072292SN/A uint64_t st_mtimeX; 1082292SN/A uint64_t st_mtime_nsec; 1092292SN/A uint64_t st_ctimeX; 1102292SN/A uint64_t st_ctime_nsec; 1112292SN/A int64_t ___unused[3]; 1122292SN/A } tgt_stat64; 1132292SN/A 1142292SN/A /// Length of strings in struct utsname (plus 1 for null char). 1152292SN/A static const int _SYS_NMLN = 65; 1162292SN/A 1172292SN/A /// Interface struct for uname(). 1182292SN/A struct utsname { 1192292SN/A char sysname[_SYS_NMLN]; //!< System name. 1202292SN/A char nodename[_SYS_NMLN]; //!< Node name. 1212292SN/A char release[_SYS_NMLN]; //!< OS release. 1222680Sktlim@umich.edu char version[_SYS_NMLN]; //!< OS version. 1232935Sksewell@umich.edu char machine[_SYS_NMLN]; //!< Machine type. 1242292SN/A }; 1253640Sktlim@umich.edu 1263640Sktlim@umich.edu /// Limit struct for getrlimit/setrlimit. 1273640Sktlim@umich.edu struct rlimit { 1282292SN/A uint64_t rlim_cur; //!< soft limit 1292292SN/A uint64_t rlim_max; //!< hard limit 1302292SN/A }; 1312292SN/A 1322292SN/A /// For gettimeofday(). 1332292SN/A struct timeval { 1342292SN/A int64_t tv_sec; //!< seconds 1352292SN/A int64_t tv_usec; //!< microseconds 1362292SN/A }; 1372292SN/A 1382292SN/A // For writev/readv 1392292SN/A struct tgt_iovec { 1402132SN/A uint64_t iov_base; // void * 1412301SN/A uint64_t iov_len; 1421062SN/A }; 1431062SN/A 1441062SN/A 1451062SN/A /// For getrusage(). 1461062SN/A struct rusage { 1471062SN/A struct timeval ru_utime; //!< user time used 1481062SN/A struct timeval ru_stime; //!< system time used 1491062SN/A int64_t ru_maxrss; //!< max rss 1501062SN/A int64_t ru_ixrss; //!< integral shared memory size 1511062SN/A int64_t ru_idrss; //!< integral unshared data " 1521062SN/A int64_t ru_isrss; //!< integral unshared stack " 1531062SN/A int64_t ru_minflt; //!< page reclaims - total vmfaults 1541062SN/A int64_t ru_majflt; //!< page faults 1551062SN/A int64_t ru_nswap; //!< swaps 1561062SN/A int64_t ru_inblock; //!< block input operations 1571062SN/A int64_t ru_oublock; //!< block output operations 1581062SN/A int64_t ru_msgsnd; //!< messages sent 1591062SN/A int64_t ru_msgrcv; //!< messages received 1601062SN/A int64_t ru_nsignals; //!< signals received 1611062SN/A int64_t ru_nvcsw; //!< voluntary context switches 1621062SN/A int64_t ru_nivcsw; //!< involuntary " 1632292SN/A }; 1641062SN/A 1651062SN/A static int openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc); 1661062SN/A static std::string procMeminfo(LiveProcess *process, ThreadContext *tc); 1671062SN/A 1681062SN/A}; // class Linux 1692301SN/A 1702316SN/A 1712301SN/A#endif // FULL_SYSTEM 1722301SN/A 1732301SN/A#endif // __LINUX_HH__ 1742301SN/A