linux.hh revision 11728:f099627c6750
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Korey Sewell 29 */ 30 31#ifndef __ARCH_RISCV_LINUX_LINUX_HH__ 32#define __ARCH_RISCV_LINUX_LINUX_HH__ 33 34#include "kern/linux/linux.hh" 35 36class RiscvLinux : public Linux 37{ 38 public: 39 static const int TGT_SIGHUP = 1; 40 static const int TGT_SIGINT = 2; 41 static const int TGT_SIGQUIT = 3; 42 static const int TGT_SIGILL = 4; 43 static const int TGT_SIGTRAP = 5; 44 static const int TGT_SIGABRT = 6; 45 static const int TGT_SIGIOT = 6; 46 static const int TGT_SIGEMT = 7; 47 static const int TGT_SIGFPE = 8; 48 static const int TGT_SIGKILL = 9; 49 static const int TGT_SIGBUS = 10; 50 static const int TGT_SIGSEGV = 11; 51 static const int TGT_SIGSYS = 12; 52 static const int TGT_SIGPIPE = 13; 53 static const int TGT_SIGALRM = 14; 54 static const int TGT_SIGTERM = 15; 55 static const int TGT_SIGURG = 16; 56 static const int TGT_SIGSTOP = 17; 57 static const int TGT_SIGTSTP = 18; 58 static const int TGT_SIGCONT = 19; 59 static const int TGT_SIGCHLD = 20; 60 static const int TGT_SIGCLD = 20; 61 static const int TGT_SIGTTIN = 21; 62 static const int TGT_SIGTTOU = 22; 63 static const int TGT_SIGPOLL = 23; 64 static const int TGT_SIGIO = 23; 65 static const int TGT_SIGXCPU = 24; 66 static const int TGT_SIGXFSZ = 25; 67 static const int TGT_SIGVTALRM = 26; 68 static const int TGT_SIGPROF = 27; 69 static const int TGT_SIGWINCH = 28; 70 static const int TGT_SIGLOST = 29; 71 static const int TGT_SIGPWR = 29; 72 static const int TGT_SIGUSR1 = 30; 73 static const int TGT_SIGUSR2 = 31; 74 75 /// This table maps the target open() flags to the corresponding 76 /// host open() flags. 77 static SyscallFlagTransTable openFlagTable[]; 78 79 /// Number of entries in openFlagTable[]. 80 static const int NUM_OPEN_FLAGS; 81 82 //@{ 83 /// open(2) flag values. 84 static const int TGT_O_RDONLY = 0x000000; //!< O_RDONLY 85 static const int TGT_O_WRONLY = 0x000001; //!< O_WRONLY 86 static const int TGT_O_RDWR = 0x000002; //!< O_RDWR 87 static const int TGT_O_CREAT = 0x000040; //!< O_CREAT 88 static const int TGT_O_EXCL = 0x000080; //!< O_EXCL 89 static const int TGT_O_NOCTTY = 0x000100; //!< O_NOCTTY 90 static const int TGT_O_TRUNC = 0x000200; //!< O_TRUNC 91 static const int TGT_O_APPEND = 0x000400; //!< O_APPEND 92 static const int TGT_O_NONBLOCK = 0x000800; //!< O_NONBLOCK 93 static const int TGT_O_SYNC = 0x001000; //!< O_SYNC 94 static const int TGT_FSYNC = 0x001000; //!< FSYNC 95 static const int TGT_FASYNC = 0x008000; //!< FASYNC 96 // The following are not present in riscv64-unknown-elf <fcntl.h> 97 static const int TGT_O_DSYNC = 0x010000; //!< O_DSYNC 98 static const int TGT_O_CLOEXEC = 0x040000; //!< O_CLOEXEC 99 static const int TGT_O_NOINHERIT = 0x040000; //!< O_NOINHERIT 100 static const int TGT_O_DIRECT = 0x080000; //!< O_DIRECT 101 static const int TGT_O_NOFOLLOW = 0x100000; //!< O_NOFOLLOW 102 static const int TGT_O_DIRECTORY = 0x200000; //!< O_DIRECTORY 103 // The following are not defined by riscv64-unknown-elf 104 static const int TGT_O_LARGEFILE = 0x020000; //!< O_LARGEFILE 105 static const int TGT_O_NOATIME = 0x800000; //!< O_NOATIME 106 static const int TGT_O_PATH = 0x400000; //!< O_PATH 107 //@} 108 109 // Only defined in riscv-unknown-elf for proxy kernel and not linux kernel 110 static const unsigned TGT_MAP_SHARED = 0x0001; 111 static const unsigned TGT_MAP_PRIVATE = 0x0002; 112 static const unsigned TGT_MAP_FIXED = 0x0010; 113 static const unsigned TGT_MAP_ANONYMOUS = 0x0020; 114 static const unsigned TGT_MAP_POPULATE = 0x1000; 115 static const unsigned TGT_MREMAP_FIXED = 0x0020; 116 117 static const unsigned NUM_MMAP_FLAGS; 118 119 typedef int64_t time_t; 120 typedef uint64_t dev_t; 121 typedef uint64_t ino_t; 122 typedef uint32_t mode_t; 123 typedef uint32_t nlink_t; 124 typedef uint32_t uid_t; 125 typedef uint32_t gid_t; 126 typedef int64_t off_t; 127 typedef uint64_t blksize_t; 128 typedef uint64_t blkcnt_t; 129 130 struct timespec { 131 time_t tv_sec; 132 int64_t tv_nsec; 133 }; 134 135 typedef struct { 136 dev_t st_dev; 137 ino_t st_ino; 138 mode_t st_mode; 139 nlink_t st_nlink; 140 uid_t st_uid; 141 gid_t st_gid; 142 dev_t st_rdev; 143 dev_t __pad1; 144 off_t st_size; 145 blksize_t st_blksize; 146 blkcnt_t st_blocks; 147 uint64_t st_atimeX; 148 uint64_t st_atime_nsec; 149 uint64_t st_mtimeX; 150 uint64_t st_mtime_nsec; 151 uint64_t st_ctimeX; 152 uint64_t st_ctime_nsec; 153 int32_t ___glibc_reserved[2]; 154 } tgt_stat64; 155}; 156 157#endif 158