freebsd.hh revision 11383
12SN/A/* 21762SN/A * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com> 35502Snate@binkert.org * All rights reserved. 42SN/A * 52SN/A * This software was developed by the University of Cambridge Computer 62SN/A * Laboratory as part of the CTSRD Project, with support from the UK Higher 72SN/A * Education Innovation Fund (HEIF). 82SN/A * 92SN/A * Redistribution and use in source and binary forms, with or without 102SN/A * modification, are permitted provided that the following conditions are 112SN/A * met: redistributions of source code must retain the above copyright 122SN/A * notice, this list of conditions and the following disclaimer; 132SN/A * redistributions in binary form must reproduce the above copyright 142SN/A * notice, this list of conditions and the following disclaimer in the 152SN/A * documentation and/or other materials provided with the distribution; 162SN/A * neither the name of the copyright holders nor the names of its 172SN/A * contributors may be used to endorse or promote products derived from 182SN/A * this software without specific prior written permission. 192SN/A * 202SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 212SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 222SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 232SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 242SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 252SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 262SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 272SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 282665Ssaidi@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 292665Ssaidi@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 302665Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 312665Ssaidi@eecs.umich.edu */ 322SN/A 332SN/A#ifndef __ARCH_ARM_FREEBSD_FREEBSD_HH__ 345501Snate@binkert.org#define __ARCH_ARM_FREEBSD_FREEBSD_HH__ 352SN/A 362SN/A#include "kern/freebsd/freebsd.hh" 372SN/A 382SN/Aclass ArmFreebsd32 : public FreeBSD 395502Snate@binkert.org{ 405501Snate@binkert.org public: 415501Snate@binkert.org 421717SN/A /// This table maps the target open() flags to the corresponding 435501Snate@binkert.org /// host open() flags. 4456SN/A static SyscallFlagTransTable openFlagTable[]; 452SN/A 462SN/A /// Number of entries in openFlagTable[]. 472SN/A static const int NUM_OPEN_FLAGS; 482SN/A 492SN/A //@{ 502SN/A /// Basic ARM FreeBSD types 512SN/A typedef uint32_t size_t; 522SN/A typedef uint32_t off_t; 532SN/A typedef int32_t time_t; 545605Snate@binkert.org typedef int32_t clock_t; 552SN/A //@} 564017Sstever@eecs.umich.edu 574016Sstever@eecs.umich.edu //@{ 584017Sstever@eecs.umich.edu /// open(2) flag values. 594016Sstever@eecs.umich.edu static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY 605768Snate@binkert.org static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY 615768Snate@binkert.org static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR 625774Snate@binkert.org static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT 635768Snate@binkert.org static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL 645768Snate@binkert.org static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY 655768Snate@binkert.org static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC 665768Snate@binkert.org static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND 675768Snate@binkert.org static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK 685768Snate@binkert.org static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC 695768Snate@binkert.org static const int TGT_FASYNC = 0x00000040; //!< FASYNC 705768Snate@binkert.org static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT 715768Snate@binkert.org static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY 725768Snate@binkert.org static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW 735768Snate@binkert.org static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC 745768Snate@binkert.org //@} 755768Snate@binkert.org 765602Snate@binkert.org /// For mmap(). 775602Snate@binkert.org static const unsigned TGT_MAP_SHARED = 0x0001; 785502Snate@binkert.org static const unsigned TGT_MAP_PRIVATE = 0x0002; 795503Snate@binkert.org static const unsigned TGT_MAP_ANONYMOUS = 0x1000; 805502Snate@binkert.org static const unsigned TGT_MAP_FIXED = 0x0010; 815502Snate@binkert.org 825502Snate@binkert.org /// Limit struct for getrlimit/setrlimit. 835502Snate@binkert.org struct rlimit { 845502Snate@binkert.org uint32_t rlim_cur; //!< soft limit 855503Snate@binkert.org uint32_t rlim_max; //!< hard limit 865502Snate@binkert.org }; 875502Snate@binkert.org 885502Snate@binkert.org /// For gettimeofday(). 895502Snate@binkert.org struct timeval { 905503Snate@binkert.org int32_t tv_sec; //!< seconds 915503Snate@binkert.org int32_t tv_usec; //!< microseconds 925503Snate@binkert.org }; 935502Snate@binkert.org 945503Snate@binkert.org // For writev/readv 955502Snate@binkert.org struct tgt_iovec { 965502Snate@binkert.org uint32_t iov_base; // void * 972SN/A uint32_t iov_len; 982SN/A }; 992SN/A 1005502Snate@binkert.org /* 1015502Snate@binkert.org * sizeof st 120 1025602Snate@binkert.org * sizeof st_dev 4 1035502Snate@binkert.org * sizeof st_ino 4 1045502Snate@binkert.org * sizeof st_mode 2 1052SN/A * sizeof st_nlink 2 1065502Snate@binkert.org * sizeof st_uid 4 1075502Snate@binkert.org * sizeof st_gid 4 1085503Snate@binkert.org * sizeof st_rdev 4 1095503Snate@binkert.org * sizeof st_atim 16 1105503Snate@binkert.org * sizeof st_size 8 1115503Snate@binkert.org * sizeof st_blocks 8 1125503Snate@binkert.org * sizeof st_blksize 4 1135502Snate@binkert.org * sizeof st_flags 4 1142SN/A * sizeof st_gen 4 1155503Snate@binkert.org * sizeof st_lspare 4 1165503Snate@binkert.org */ 1175602Snate@binkert.org 1185502Snate@binkert.org typedef struct { 1192SN/A uint32_t st_dev; 1205602Snate@binkert.org uint32_t st_ino; 1215602Snate@binkert.org uint16_t st_mode; 1225502Snate@binkert.org uint16_t st_nlink; 1235503Snate@binkert.org uint32_t st_uid; 1245503Snate@binkert.org uint32_t st_gid; 1255502Snate@binkert.org uint32_t st_rdev; 1265503Snate@binkert.org uint64_t st_atimeX; 1275503Snate@binkert.org uint64_t st_atime_nsec; 1285503Snate@binkert.org uint64_t st_mtimeX; 1295503Snate@binkert.org uint64_t st_mtime_nsec; 1305503Snate@binkert.org uint64_t st_ctimeX; 1315503Snate@binkert.org uint64_t st_ctime_nsec; 1325503Snate@binkert.org uint64_t st_size; 1335503Snate@binkert.org uint64_t st_blocks; 1345503Snate@binkert.org uint32_t st_blksize; 1355503Snate@binkert.org uint32_t st_flags; 1365503Snate@binkert.org uint32_t st_gen; 1375503Snate@binkert.org uint32_t st_lspare; 1385503Snate@binkert.org uint64_t st_birthtimX; 1395503Snate@binkert.org uint64_t st_birthtim; 1405502Snate@binkert.org } tgt_stat; 1415502Snate@binkert.org 1425503Snate@binkert.org typedef struct { 1435503Snate@binkert.org uint32_t st_dev; 1442SN/A uint32_t st_ino; 1455502Snate@binkert.org uint16_t st_mode; 1465503Snate@binkert.org uint16_t st_nlink; 1475503Snate@binkert.org uint32_t st_uid; 1485503Snate@binkert.org uint32_t st_gid; 1492SN/A uint32_t st_rdev; 1502SN/A uint64_t st_atimeX; 1512SN/A uint64_t st_atime_nsec; 1522SN/A uint64_t st_mtimeX; 1532SN/A uint64_t st_mtime_nsec; 1542SN/A uint64_t st_ctimeX; 1555502Snate@binkert.org uint64_t st_ctime_nsec; 1562SN/A uint64_t st_size; 1575502Snate@binkert.org uint64_t st_blocks; 1585502Snate@binkert.org uint32_t st_blksize; 1595502Snate@binkert.org uint32_t st_flags; 1605602Snate@binkert.org uint32_t st_gen; 1612SN/A uint32_t st_lspare; 1622SN/A uint64_t st_birthtimX; 1632SN/A uint64_t st_birthtim; 1645502Snate@binkert.org } tgt_stat64; 1652SN/A 1665502Snate@binkert.org /// For getrusage(). 1675502Snate@binkert.org struct rusage { 1682SN/A struct timeval ru_utime; //!< user time used 1695502Snate@binkert.org struct timeval ru_stime; //!< system time used 1702SN/A int32_t ru_maxrss; //!< max rss 1712SN/A int32_t ru_ixrss; //!< integral shared memory size 1725502Snate@binkert.org int32_t ru_idrss; //!< integral unshared data " 1735502Snate@binkert.org int32_t ru_isrss; //!< integral unshared stack " 1745502Snate@binkert.org int32_t ru_minflt; //!< page reclaims - total vmfaults 1755503Snate@binkert.org int32_t ru_majflt; //!< page faults 1765503Snate@binkert.org int32_t ru_nswap; //!< swaps 1775502Snate@binkert.org int32_t ru_inblock; //!< block input operations 1785602Snate@binkert.org int32_t ru_oublock; //!< block output operations 1792SN/A int32_t ru_msgsnd; //!< messages sent 1802SN/A int32_t ru_msgrcv; //!< messages received 1812667Sstever@eecs.umich.edu int32_t ru_nsignals; //!< signals received 1822SN/A int32_t ru_nvcsw; //!< voluntary context switches 1832SN/A int32_t ru_nivcsw; //!< involuntary " 1845503Snate@binkert.org }; 1855503Snate@binkert.org 1865769Snate@binkert.org /// For times(). 1875502Snate@binkert.org struct tms { 1885503Snate@binkert.org int32_t tms_utime; //!< user time 1895503Snate@binkert.org int32_t tms_stime; //!< system time 1905503Snate@binkert.org int32_t tms_cutime; //!< user time of children 1915503Snate@binkert.org int32_t tms_cstime; //!< system time of children 1925503Snate@binkert.org }; 1935503Snate@binkert.org}; 1945503Snate@binkert.org 1955502Snate@binkert.orgclass ArmFreebsd64 : public FreeBSD 1965502Snate@binkert.org{ 1975503Snate@binkert.org public: 1985502Snate@binkert.org 1992SN/A /// This table maps the target open() flags to the corresponding 2002SN/A /// host open() flags. 2012667Sstever@eecs.umich.edu static SyscallFlagTransTable openFlagTable[]; 2022SN/A 2032667Sstever@eecs.umich.edu /// Number of entries in openFlagTable[]. 2045769Snate@binkert.org static const int NUM_OPEN_FLAGS; 2052667Sstever@eecs.umich.edu 2062667Sstever@eecs.umich.edu //@{ 2072667Sstever@eecs.umich.edu /// Basic ARM FreeBSD types 2085769Snate@binkert.org typedef uint64_t size_t; 2092667Sstever@eecs.umich.edu typedef uint64_t off_t; 2102SN/A typedef int64_t time_t; 2115769Snate@binkert.org typedef int64_t clock_t; 2122SN/A //@} 2132667Sstever@eecs.umich.edu 2142667Sstever@eecs.umich.edu //@{ 2152SN/A /// open(2) flag values. 2162SN/A static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY 217224SN/A static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY 218224SN/A static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR 219224SN/A static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT 220224SN/A static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL 221224SN/A static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY 2225769Snate@binkert.org static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC 2235769Snate@binkert.org static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND 224224SN/A static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK 225224SN/A static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC 226224SN/A static const int TGT_FASYNC = 0x00000040; //!< FASYNC 227237SN/A static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT 228224SN/A static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY 2295695Snate@binkert.org static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW 2305695Snate@binkert.org static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC 231224SN/A //@} 232224SN/A 233224SN/A /// For mmap(). 234224SN/A static const unsigned TGT_MAP_SHARED = 0x0001; 235224SN/A static const unsigned TGT_MAP_PRIVATE = 0x0002; 236224SN/A static const unsigned TGT_MAP_ANONYMOUS = 0x1000; 237224SN/A static const unsigned TGT_MAP_FIXED = 0x0010; 2385769Snate@binkert.org 2395769Snate@binkert.org //@{ 2405769Snate@binkert.org /// For getrusage(). 2415769Snate@binkert.org static const int TGT_RUSAGE_SELF = 0; 2425769Snate@binkert.org static const int TGT_RUSAGE_CHILDREN = -1; 2435769Snate@binkert.org static const int TGT_RUSAGE_THREAD = 1; 244224SN/A //@} 245224SN/A 246224SN/A /// Resource enumeration for getrlimit(). 2475695Snate@binkert.org enum rlimit_resources { 248224SN/A TGT_RLIMIT_CPU = 0, 249224SN/A TGT_RLIMIT_FSIZE = 1, 250224SN/A TGT_RLIMIT_DATA = 2, 2512SN/A TGT_RLIMIT_STACK = 3, 252217SN/A TGT_RLIMIT_CORE = 4, 2532SN/A TGT_RLIMIT_RSS = 5, 254265SN/A TGT_RLIMIT_MEMLOCK = 6, 255237SN/A TGT_RLIMIT_NPROC = 7, 256237SN/A TGT_RLIMIT_NOFILE = 8, 2575502Snate@binkert.org TGT_RLIMIT_SBSIZE = 9, 2585502Snate@binkert.org TGT_RLIMIT_VMEM = 10, 2595503Snate@binkert.org TGT_RLIMIT_AS = TGT_RLIMIT_VMEM, 2605502Snate@binkert.org TGT_RLIMIT_NPTS = 11, 2615503Snate@binkert.org TGT_RLIMIT_SWAP = 12, 2625769Snate@binkert.org TGT_RLIMIT_KQUEUES = 13 2635502Snate@binkert.org }; 2645502Snate@binkert.org 2655502Snate@binkert.org /// Limit struct for getrlimit/setrlimit. 2665502Snate@binkert.org struct rlimit { 2675502Snate@binkert.org uint64_t rlim_cur; //!< soft limit 2685503Snate@binkert.org uint64_t rlim_max; //!< hard limit 2695502Snate@binkert.org }; 2705502Snate@binkert.org 2712SN/A /// For gettimeofday(). 272237SN/A struct timeval { 273265SN/A int64_t tv_sec; //!< seconds 274265SN/A int64_t tv_usec; //!< microseconds 2755502Snate@binkert.org }; 276265SN/A 277265SN/A // For writev/readv 278265SN/A struct tgt_iovec { 279265SN/A uint64_t iov_base; // void * 2802SN/A uint64_t iov_len; 2812SN/A }; 282237SN/A 283237SN/A typedef struct { 284237SN/A uint32_t st_dev; 285265SN/A uint32_t st_ino; 286265SN/A uint16_t st_mode; 287265SN/A uint16_t st_nlink; 288270SN/A uint32_t st_uid; 289265SN/A uint32_t st_gid; 290265SN/A uint32_t st_rdev; 291270SN/A uint64_t st_atimeX; 292265SN/A uint64_t st_atime_nsec; 293265SN/A uint64_t st_mtimeX; 294395SN/A uint64_t st_mtime_nsec; 295237SN/A uint64_t st_ctimeX; 296237SN/A uint64_t st_ctime_nsec; 297237SN/A uint64_t st_size; 2982SN/A uint64_t st_blocks; 2995501Snate@binkert.org uint32_t st_blksize; 3002SN/A uint32_t st_flags; 3012SN/A uint32_t st_gen; 3022SN/A uint32_t st_lspare; 3032SN/A uint64_t st_birthtimX; 3042SN/A uint64_t st_birthtim; 3052SN/A } tgt_stat; 3062SN/A 3072SN/A typedef struct { 3085502Snate@binkert.org uint32_t st_dev; 3095502Snate@binkert.org uint32_t st_ino; 3105502Snate@binkert.org uint16_t st_mode; 3115503Snate@binkert.org uint16_t st_nlink; 3125503Snate@binkert.org uint32_t st_uid; 3135502Snate@binkert.org uint32_t st_gid; 3145503Snate@binkert.org uint32_t st_rdev; 3155502Snate@binkert.org uint64_t st_atimeX; 3165502Snate@binkert.org uint64_t st_atime_nsec; 3172SN/A uint64_t st_mtimeX; 3182SN/A uint64_t st_mtime_nsec; 3192SN/A uint64_t st_ctimeX; 3202SN/A uint64_t st_ctime_nsec; 3212SN/A uint64_t st_size; 3222SN/A uint64_t st_blocks; 3235502Snate@binkert.org uint32_t st_blksize; 3245502Snate@binkert.org uint32_t st_flags; 3255502Snate@binkert.org uint32_t st_gen; 3265502Snate@binkert.org uint32_t st_lspare; 3275502Snate@binkert.org uint64_t st_birthtimX; 3285502Snate@binkert.org uint64_t st_birthtim; 3295502Snate@binkert.org } tgt_stat64; 3305502Snate@binkert.org 3315502Snate@binkert.org /// For getrusage(). 3325502Snate@binkert.org struct rusage { 3335503Snate@binkert.org struct timeval ru_utime; //!< user time used 3345503Snate@binkert.org struct timeval ru_stime; //!< system time used 3355502Snate@binkert.org int64_t ru_maxrss; //!< max rss 3365502Snate@binkert.org int64_t ru_ixrss; //!< integral shared memory size 3375502Snate@binkert.org int64_t ru_idrss; //!< integral unshared data " 3385502Snate@binkert.org int64_t ru_isrss; //!< integral unshared stack " 3395502Snate@binkert.org int64_t ru_minflt; //!< page reclaims - total vmfaults 3405502Snate@binkert.org int64_t ru_majflt; //!< page faults 3415502Snate@binkert.org int64_t ru_nswap; //!< swaps 3425502Snate@binkert.org int64_t ru_inblock; //!< block input operations 3435502Snate@binkert.org int64_t ru_oublock; //!< block output operations 3445502Snate@binkert.org int64_t ru_msgsnd; //!< messages sent 3455502Snate@binkert.org int64_t ru_msgrcv; //!< messages received 3465502Snate@binkert.org int64_t ru_nsignals; //!< signals received 3475502Snate@binkert.org int64_t ru_nvcsw; //!< voluntary context switches 3485502Snate@binkert.org int64_t ru_nivcsw; //!< involuntary " 3495502Snate@binkert.org }; 3505502Snate@binkert.org 3515502Snate@binkert.org /// For times(). 3525502Snate@binkert.org struct tms { 3535502Snate@binkert.org int64_t tms_utime; //!< user time 3545502Snate@binkert.org int64_t tms_stime; //!< system time 3555502Snate@binkert.org int64_t tms_cutime; //!< user time of children 3565502Snate@binkert.org int64_t tms_cstime; //!< system time of children 3575503Snate@binkert.org }; 3585502Snate@binkert.org}; 3595502Snate@binkert.org 3605502Snate@binkert.org#endif 3615502Snate@binkert.org