linux.hh revision 11382:654272b82e94
1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are 16 * met: redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer; 18 * redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution; 21 * neither the name of the copyright holders nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: Gabe Black 38 */ 39 40#ifndef __ARCH_X86_LINUX_LINUX_HH__ 41#define __ARCH_X86_LINUX_LINUX_HH__ 42 43#include "kern/linux/linux.hh" 44 45class X86Linux64 : public Linux 46{ 47 public: 48 49 typedef struct { 50 uint64_t st_dev; 51 uint64_t st_ino; 52 uint64_t st_nlink; 53 uint32_t st_mode; 54 uint32_t st_uid; 55 uint32_t st_gid; 56 uint32_t __pad0; 57 uint64_t st_rdev; 58 int64_t st_size; 59 int64_t st_blksize; 60 int64_t st_blocks; 61 uint64_t st_atimeX; 62 uint64_t st_atime_nsec; 63 uint64_t st_mtimeX; 64 uint64_t st_mtime_nsec; 65 uint64_t st_ctimeX; 66 uint64_t st_ctime_nsec; 67 int64_t unused0[3]; 68 } tgt_stat64; 69 70 static const int TGT_SIGHUP = 0x000001; 71 static const int TGT_SIGINT = 0x000002; 72 static const int TGT_SIGQUIT = 0x000003; 73 static const int TGT_SIGILL = 0x000004; 74 static const int TGT_SIGTRAP = 0x000005; 75 static const int TGT_SIGABRT = 0x000006; 76 static const int TGT_SIGIOT = 0x000006; 77 static const int TGT_SIGBUS = 0x000007; 78 static const int TGT_SIGFPE = 0x000008; 79 static const int TGT_SIGKILL = 0x000009; 80 static const int TGT_SIGUSR1 = 0x00000a; 81 static const int TGT_SIGSEGV = 0x00000b; 82 static const int TGT_SIGUSR2 = 0x00000c; 83 static const int TGT_SIGPIPE = 0x00000d; 84 static const int TGT_SIGALRM = 0x00000e; 85 static const int TGT_SIGTERM = 0x00000f; 86 static const int TGT_SIGSTKFLT = 0x000010; 87 static const int TGT_SIGCHLD = 0x000011; 88 static const int TGT_SIGCONT = 0x000012; 89 static const int TGT_SIGSTOP = 0x000013; 90 static const int TGT_SIGTSTP = 0x000014; 91 static const int TGT_SIGTTIN = 0x000015; 92 static const int TGT_SIGTTOU = 0x000016; 93 static const int TGT_SIGURG = 0x000017; 94 static const int TGT_SIGXCPU = 0x000018; 95 static const int TGT_SIGXFSZ = 0x000019; 96 static const int TGT_SIGVTALRM = 0x00001a; 97 static const int TGT_SIGPROF = 0x00001b; 98 static const int TGT_SIGWINCH = 0x00001c; 99 static const int TGT_SIGIO = 0x00001d; 100 static const int TGT_SIGPOLL = 0x00001d; 101 static const int TGT_SIGPWR = 0x00001e; 102 static const int TGT_SIGSYS = 0x00001f; 103 static const int TGT_SIGUNUSED = 0x00001f; 104 105 static SyscallFlagTransTable openFlagTable[]; 106 107 static const int TGT_O_RDONLY = 000000000; //!< O_RDONLY 108 static const int TGT_O_WRONLY = 000000001; //!< O_WRONLY 109 static const int TGT_O_RDWR = 000000002; //!< O_RDWR 110 static const int TGT_O_CREAT = 000000100; //!< O_CREAT 111 static const int TGT_O_EXCL = 000000200; //!< O_EXCL 112 static const int TGT_O_NOCTTY = 000000400; //!< O_NOCTTY 113 static const int TGT_O_TRUNC = 000001000; //!< O_TRUNC 114 static const int TGT_O_APPEND = 000002000; //!< O_APPEND 115 static const int TGT_O_NONBLOCK = 000004000; //!< O_NONBLOCK 116 static const int TGT_O_DSYNC = 000010000; 117 static const int TGT_FASYNC = 000020000; 118 static const int TGT_O_DIRECT = 000040000; //!< O_DIRECTIO 119 static const int TGT_O_LARGEFILE = 000100000; 120 static const int TGT_O_DIRECTORY = 000200000; 121 static const int TGT_O_NOFOLLOW = 000400000; 122 static const int TGT_O_NOATIME = 001000000; 123 static const int TGT_O_CLOEXEC = 002000000; 124 static const int TGT_O_SYNC = 004010000; //!< O_SYNC 125 static const int TGT_O_PATH = 010000000; 126 127 static const int NUM_OPEN_FLAGS; 128 129 static const unsigned TGT_MAP_ANONYMOUS = 0x20; 130 static const unsigned TGT_MAP_FIXED = 0x10; 131 132 typedef struct { 133 uint64_t iov_base; // void * 134 uint64_t iov_len; // size_t 135 } tgt_iovec; 136 137 typedef struct { 138 int64_t uptime; /* Seconds since boot */ 139 uint64_t loads[3]; /* 1, 5, and 15 minute load averages */ 140 uint64_t totalram; /* Total usable main memory size */ 141 uint64_t freeram; /* Available memory size */ 142 uint64_t sharedram; /* Amount of shared memory */ 143 uint64_t bufferram; /* Memory used by buffers */ 144 uint64_t totalswap; /* Total swap space size */ 145 uint64_t freeswap; /* swap space still available */ 146 uint16_t procs; /* Number of current processes */ 147 uint64_t totalhigh; /* Total high memory size */ 148 uint64_t freehigh; /* Available high memory size */ 149 uint64_t mem_unit; /* Memory unit size in bytes */ 150 } tgt_sysinfo; 151 152}; 153 154class X86Linux32 : public Linux 155{ 156 public: 157 158 typedef struct { 159 uint64_t st_dev; 160 uint8_t __pad0[4]; 161 uint32_t __st_ino; 162 uint32_t st_mode; 163 uint32_t st_nlink; 164 uint32_t st_uid; 165 uint32_t st_gid; 166 uint64_t st_rdev; 167 uint8_t __pad3[4]; 168 int64_t st_size; 169 uint32_t st_blksize; 170 uint64_t st_blocks; 171 uint32_t st_atimeX; 172 uint32_t st_atime_nsec; 173 uint32_t st_mtimeX; 174 uint32_t st_mtime_nsec; 175 uint32_t st_ctimeX; 176 uint32_t st_ctime_nsec; 177 uint64_t st_ino; 178 } __attribute__((__packed__)) tgt_stat64; 179 180 static const int TGT_SIGHUP = 0x000001; 181 static const int TGT_SIGINT = 0x000002; 182 static const int TGT_SIGQUIT = 0x000003; 183 static const int TGT_SIGILL = 0x000004; 184 static const int TGT_SIGTRAP = 0x000005; 185 static const int TGT_SIGABRT = 0x000006; 186 static const int TGT_SIGIOT = 0x000006; 187 static const int TGT_SIGBUS = 0x000007; 188 static const int TGT_SIGFPE = 0x000008; 189 static const int TGT_SIGKILL = 0x000009; 190 static const int TGT_SIGUSR1 = 0x00000a; 191 static const int TGT_SIGSEGV = 0x00000b; 192 static const int TGT_SIGUSR2 = 0x00000c; 193 static const int TGT_SIGPIPE = 0x00000d; 194 static const int TGT_SIGALRM = 0x00000e; 195 static const int TGT_SIGTERM = 0x00000f; 196 static const int TGT_SIGSTKFLT = 0x000010; 197 static const int TGT_SIGCHLD = 0x000011; 198 static const int TGT_SIGCONT = 0x000012; 199 static const int TGT_SIGSTOP = 0x000013; 200 static const int TGT_SIGTSTP = 0x000014; 201 static const int TGT_SIGTTIN = 0x000015; 202 static const int TGT_SIGTTOU = 0x000016; 203 static const int TGT_SIGURG = 0x000017; 204 static const int TGT_SIGXCPU = 0x000018; 205 static const int TGT_SIGXFSZ = 0x000019; 206 static const int TGT_SIGVTALRM = 0x00001a; 207 static const int TGT_SIGPROF = 0x00001b; 208 static const int TGT_SIGWINCH = 0x00001c; 209 static const int TGT_SIGIO = 0x00001d; 210 static const int TGT_SIGPOLL = 0x00001d; 211 static const int TGT_SIGPWR = 0x00001e; 212 static const int TGT_SIGSYS = 0x00001f; 213 static const int TGT_SIGUNUSED = 0x00001f; 214 215 static SyscallFlagTransTable openFlagTable[]; 216 217 static const int TGT_O_RDONLY = 000000000; //!< O_RDONLY 218 static const int TGT_O_WRONLY = 000000001; //!< O_WRONLY 219 static const int TGT_O_RDWR = 000000002; //!< O_RDWR 220 static const int TGT_O_CREAT = 000000100; //!< O_CREAT 221 static const int TGT_O_EXCL = 000000200; //!< O_EXCL 222 static const int TGT_O_NOCTTY = 000000400; //!< O_NOCTTY 223 static const int TGT_O_TRUNC = 000001000; //!< O_TRUNC 224 static const int TGT_O_APPEND = 000002000; //!< O_APPEND 225 static const int TGT_O_NONBLOCK = 000004000; //!< O_NONBLOCK 226 static const int TGT_O_DSYNC = 000010000; //!< O_DSYNC 227 static const int TGT_FASYNC = 000020000; 228 static const int TGT_O_DIRECT = 000040000; //!< O_DIRECTIO 229 static const int TGT_O_LARGEFILE = 000100000; 230 static const int TGT_O_DIRECTORY = 000200000; 231 static const int TGT_O_NOFOLLOW = 000400000; 232 static const int TGT_O_NOATIME = 001000000; 233 static const int TGT_O_CLOEXEC = 002000000; 234 static const int TGT_O_SYNC = 004010000; //!< O_SYNC 235 static const int TGT_O_PATH = 010000000; 236 237 static const int NUM_OPEN_FLAGS; 238 239 static const unsigned TGT_MAP_ANONYMOUS = 0x20; 240 static const unsigned TGT_MAP_FIXED = 0x10; 241 242 typedef struct { 243 int32_t uptime; /* Seconds since boot */ 244 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */ 245 uint32_t totalram; /* Total usable main memory size */ 246 uint32_t freeram; /* Available memory size */ 247 uint32_t sharedram; /* Amount of shared memory */ 248 uint32_t bufferram; /* Memory used by buffers */ 249 uint32_t totalswap; /* Total swap space size */ 250 uint32_t freeswap; /* swap space still available */ 251 uint16_t procs; /* Number of current processes */ 252 uint32_t totalhigh; /* Total high memory size */ 253 uint32_t freehigh; /* Available high memory size */ 254 uint32_t mem_unit; /* Memory unit size in bytes */ 255 } tgt_sysinfo; 256 257 static bool mmapGrowsDown() { return true; } 258}; 259 260#endif 261