linux.hh revision 3113
1451SN/A/* 21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 3451SN/A * All rights reserved. 4451SN/A * 5451SN/A * Redistribution and use in source and binary forms, with or without 6451SN/A * modification, are permitted provided that the following conditions are 7451SN/A * met: redistributions of source code must retain the above copyright 8451SN/A * notice, this list of conditions and the following disclaimer; 9451SN/A * redistributions in binary form must reproduce the above copyright 10451SN/A * notice, this list of conditions and the following disclaimer in the 11451SN/A * documentation and/or other materials provided with the distribution; 12451SN/A * neither the name of the copyright holders nor the names of its 13451SN/A * contributors may be used to endorse or promote products derived from 14451SN/A * this software without specific prior written permission. 15451SN/A * 16451SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17451SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18451SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19451SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20451SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21451SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22451SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23451SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24451SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25451SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26451SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 29451SN/A */ 30451SN/A 31451SN/A#ifndef __LINUX_HH__ 32451SN/A#define __LINUX_HH__ 332093SN/A#include "config/full_system.hh" 342093SN/A 352093SN/A#if FULL_SYSTEM 36451SN/A 37451SN/Aclass Linux {}; 38451SN/A 392093SN/A#else //!FULL_SYSTEM 402093SN/A 413113Sgblack@eecs.umich.edu#include <inttypes.h> 422093SN/A 433113Sgblack@eecs.umich.edu#include "kern/operatingsystem.hh" 442423SN/A 452093SN/A/// 462093SN/A/// This class encapsulates the types, structures, constants, 472093SN/A/// functions, and syscall-number mappings specific to the Alpha Linux 482093SN/A/// syscall interface. 492093SN/A/// 503113Sgblack@eecs.umich.educlass Linux : public OperatingSystem 513113Sgblack@eecs.umich.edu{ 522093SN/A 532093SN/A public: 542093SN/A 552093SN/A //@{ 562093SN/A /// Basic Linux types. 573113Sgblack@eecs.umich.edu/* typedef uint64_t size_t; 582093SN/A typedef uint64_t off_t; 592093SN/A typedef int64_t time_t; 602093SN/A typedef uint32_t uid_t; 613113Sgblack@eecs.umich.edu typedef uint32_t gid_t;*/ 622093SN/A //@} 632093SN/A 642093SN/A /// Stat buffer. Note that we can't call it 'stat' since that 653113Sgblack@eecs.umich.edu /// gets #defined to something else on some systems. This type 663113Sgblack@eecs.umich.edu /// can be specialized by architecture specific "Linux" classes 673113Sgblack@eecs.umich.edu typedef struct { 682093SN/A uint32_t st_dev; //!< device 692093SN/A uint32_t st_ino; //!< inode 702093SN/A uint32_t st_mode; //!< mode 712093SN/A uint32_t st_nlink; //!< link count 722093SN/A uint32_t st_uid; //!< owner's user ID 732093SN/A uint32_t st_gid; //!< owner's group ID 742093SN/A uint32_t st_rdev; //!< device number 752093SN/A int32_t _pad1; //!< for alignment 762093SN/A int64_t st_size; //!< file size in bytes 772093SN/A uint64_t st_atimeX; //!< time of last access 782093SN/A uint64_t st_mtimeX; //!< time of last modification 792093SN/A uint64_t st_ctimeX; //!< time of last status change 802093SN/A uint32_t st_blksize; //!< optimal I/O block size 812093SN/A int32_t st_blocks; //!< number of blocks allocated 822093SN/A uint32_t st_flags; //!< flags 832093SN/A uint32_t st_gen; //!< unknown 843113Sgblack@eecs.umich.edu } tgt_stat; 852093SN/A 862093SN/A // same for stat64 873113Sgblack@eecs.umich.edu typedef struct { 882093SN/A uint64_t st_dev; 892093SN/A uint64_t st_ino; 902093SN/A uint64_t st_rdev; 912093SN/A int64_t st_size; 922093SN/A uint64_t st_blocks; 932093SN/A 942093SN/A uint32_t st_mode; 952093SN/A uint32_t st_uid; 962093SN/A uint32_t st_gid; 972093SN/A uint32_t st_blksize; 982093SN/A uint32_t st_nlink; 992093SN/A uint32_t __pad0; 1002093SN/A 1013113Sgblack@eecs.umich.edu uint64_t st_atimeX; 1022093SN/A uint64_t st_atime_nsec; 1033113Sgblack@eecs.umich.edu uint64_t st_mtimeX; 1042093SN/A uint64_t st_mtime_nsec; 1053113Sgblack@eecs.umich.edu uint64_t st_ctimeX; 1062093SN/A uint64_t st_ctime_nsec; 1072093SN/A int64_t ___unused[3]; 1083113Sgblack@eecs.umich.edu } tgt_stat64; 1092093SN/A 1102093SN/A /// Length of strings in struct utsname (plus 1 for null char). 1112093SN/A static const int _SYS_NMLN = 65; 1122093SN/A 1132093SN/A /// Interface struct for uname(). 1142093SN/A struct utsname { 1152093SN/A char sysname[_SYS_NMLN]; //!< System name. 1162093SN/A char nodename[_SYS_NMLN]; //!< Node name. 1172093SN/A char release[_SYS_NMLN]; //!< OS release. 1182093SN/A char version[_SYS_NMLN]; //!< OS version. 1192093SN/A char machine[_SYS_NMLN]; //!< Machine type. 1202093SN/A }; 1212093SN/A 1222093SN/A /// Limit struct for getrlimit/setrlimit. 1232093SN/A struct rlimit { 1242093SN/A uint64_t rlim_cur; //!< soft limit 1252093SN/A uint64_t rlim_max; //!< hard limit 1262093SN/A }; 1272093SN/A 1282093SN/A /// For gettimeofday(). 1292093SN/A struct timeval { 1302093SN/A int64_t tv_sec; //!< seconds 1312093SN/A int64_t tv_usec; //!< microseconds 1322093SN/A }; 1332093SN/A 1342093SN/A // For writev/readv 1352093SN/A struct tgt_iovec { 1362093SN/A uint64_t iov_base; // void * 1372093SN/A uint64_t iov_len; 1382093SN/A }; 1392093SN/A 1402093SN/A 1412093SN/A /// For getrusage(). 1422093SN/A struct rusage { 1432093SN/A struct timeval ru_utime; //!< user time used 1442093SN/A struct timeval ru_stime; //!< system time used 1452093SN/A int64_t ru_maxrss; //!< max rss 1462093SN/A int64_t ru_ixrss; //!< integral shared memory size 1472093SN/A int64_t ru_idrss; //!< integral unshared data " 1482093SN/A int64_t ru_isrss; //!< integral unshared stack " 1492093SN/A int64_t ru_minflt; //!< page reclaims - total vmfaults 1502093SN/A int64_t ru_majflt; //!< page faults 1512093SN/A int64_t ru_nswap; //!< swaps 1522093SN/A int64_t ru_inblock; //!< block input operations 1532093SN/A int64_t ru_oublock; //!< block output operations 1542093SN/A int64_t ru_msgsnd; //!< messages sent 1552093SN/A int64_t ru_msgrcv; //!< messages received 1562093SN/A int64_t ru_nsignals; //!< signals received 1572093SN/A int64_t ru_nvcsw; //!< voluntary context switches 1582093SN/A int64_t ru_nivcsw; //!< involuntary " 1592093SN/A }; 1602093SN/A 1612093SN/A}; // class Linux 1622093SN/A 1632093SN/A 1642093SN/A#endif // FULL_SYSTEM 1652093SN/A 166451SN/A#endif // __LINUX_HH__ 167