linux.cc revision 10037
11046SN/A/*
21046SN/A * Copyright (c) 2011 ARM Limited
31762SN/A * All rights reserved
41046SN/A *
51046SN/A * The license below extends only to copyright in the software and shall
61046SN/A * not be construed as granting a license to any other intellectual
71046SN/A * property including but not limited to intellectual property relating
81046SN/A * to a hardware implementation of the functionality of the software
91046SN/A * licensed hereunder.  You may use the software subject to the license
101046SN/A * terms below provided that you ensure that this notice is replicated
111046SN/A * unmodified and in its entirety in all distributions of the software,
121046SN/A * modified or unmodified, in source code or in binary form.
131046SN/A *
141046SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
151046SN/A * Copyright (c) 2007-2008 The Florida State University
161046SN/A * All rights reserved.
171046SN/A *
181046SN/A * Redistribution and use in source and binary forms, with or without
191046SN/A * modification, are permitted provided that the following conditions are
201046SN/A * met: redistributions of source code must retain the above copyright
211046SN/A * notice, this list of conditions and the following disclaimer;
221046SN/A * redistributions in binary form must reproduce the above copyright
231046SN/A * notice, this list of conditions and the following disclaimer in the
241046SN/A * documentation and/or other materials provided with the distribution;
251046SN/A * neither the name of the copyright holders nor the names of its
261046SN/A * contributors may be used to endorse or promote products derived from
271046SN/A * this software without specific prior written permission.
282665Ssaidi@eecs.umich.edu *
292665Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
302665Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
311046SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
321530SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
332655Sstever@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
342655Sstever@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
352655Sstever@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362655Sstever@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
372655Sstever@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
381530SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
391530SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
401530SN/A *
412667Sstever@eecs.umich.edu * Authors: Stephen Hines
422667Sstever@eecs.umich.edu */
431046SN/A
442655Sstever@eecs.umich.edu#include <fcntl.h>
452655Sstever@eecs.umich.edu
462655Sstever@eecs.umich.edu#include "arch/arm/linux/linux.hh"
472655Sstever@eecs.umich.edu
482655Sstever@eecs.umich.edu// open(2) flags translation table
491046SN/AOpenFlagTransTable ArmLinux32::openFlagTable[] = {
502655Sstever@eecs.umich.edu#ifdef _MSC_VER
512655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_RDONLY,     _O_RDONLY },
522655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_WRONLY,     _O_WRONLY },
532655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_RDWR,       _O_RDWR },
541046SN/A  { ArmLinux32::TGT_O_APPEND,     _O_APPEND },
552655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_CREAT,      _O_CREAT },
562655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_TRUNC,      _O_TRUNC },
572655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_EXCL,       _O_EXCL },
582667Sstever@eecs.umich.edu#ifdef _O_NONBLOCK
592655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_NONBLOCK,   _O_NONBLOCK },
602655Sstever@eecs.umich.edu#endif
612655Sstever@eecs.umich.edu#ifdef _O_NOCTTY
622655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_NOCTTY,     _O_NOCTTY },
632655Sstever@eecs.umich.edu#endif
642655Sstever@eecs.umich.edu#ifdef _O_SYNC
652655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_SYNC,       _O_SYNC },
662655Sstever@eecs.umich.edu#endif
671046SN/A#else /* !_MSC_VER */
682655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_RDONLY,     O_RDONLY },
692655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_WRONLY,     O_WRONLY },
702667Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_RDWR,       O_RDWR },
711046SN/A  { ArmLinux32::TGT_O_CREAT,      O_CREAT },
722655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_EXCL,       O_EXCL },
731046SN/A  { ArmLinux32::TGT_O_NOCTTY,     O_NOCTTY },
742655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_TRUNC,      O_TRUNC },
752655Sstever@eecs.umich.edu  { ArmLinux32::TGT_O_APPEND,     O_APPEND },
761439SN/A  { ArmLinux32::TGT_O_NONBLOCK,   O_NONBLOCK },
771530SN/A#ifdef O_SYNC
782889Sbinkertn@umich.edu  { ArmLinux32::TGT_O_SYNC,       O_SYNC },
791530SN/A#endif
801439SN/A#ifdef FASYNC
811858SN/A  { ArmLinux32::TGT_FASYNC,       FASYNC },
822667Sstever@eecs.umich.edu#endif
831858SN/A#ifdef O_DIRECT
842889Sbinkertn@umich.edu  { ArmLinux32::TGT_O_DIRECT,     O_DIRECT },
852889Sbinkertn@umich.edu#endif
862889Sbinkertn@umich.edu#ifdef O_LARGEFILE
872889Sbinkertn@umich.edu  { ArmLinux32::TGT_O_LARGEFILE,  O_LARGEFILE },
882889Sbinkertn@umich.edu#endif
892889Sbinkertn@umich.edu#ifdef O_DIRECTORY
902889Sbinkertn@umich.edu  { ArmLinux32::TGT_O_DIRECTORY,  O_DIRECTORY },
912889Sbinkertn@umich.edu#endif
922889Sbinkertn@umich.edu#ifdef O_NOFOLLOW
932889Sbinkertn@umich.edu  { ArmLinux32::TGT_O_NOFOLLOW,   O_NOFOLLOW },
942889Sbinkertn@umich.edu#endif
952655Sstever@eecs.umich.edu#endif /* _MSC_VER */
962655Sstever@eecs.umich.edu};
972667Sstever@eecs.umich.edu
982889Sbinkertn@umich.educonst int ArmLinux32::NUM_OPEN_FLAGS = sizeof(ArmLinux32::openFlagTable) /
992655Sstever@eecs.umich.edu                                       sizeof(ArmLinux32::openFlagTable[0]);
1002655Sstever@eecs.umich.edu
1012763Sstever@eecs.umich.edu// open(2) flags translation table
1022763Sstever@eecs.umich.eduOpenFlagTransTable ArmLinux64::openFlagTable[] = {
1032667Sstever@eecs.umich.edu#ifdef _MSC_VER
1042667Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_RDONLY,     _O_RDONLY },
1052667Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_WRONLY,     _O_WRONLY },
1062763Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_RDWR,       _O_RDWR },
1072667Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_APPEND,     _O_APPEND },
1082655Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_CREAT,      _O_CREAT },
1092655Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_TRUNC,      _O_TRUNC },
1102655Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_EXCL,       _O_EXCL },
1112655Sstever@eecs.umich.edu#ifdef _O_NONBLOCK
1122655Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_NONBLOCK,   _O_NONBLOCK },
1132655Sstever@eecs.umich.edu#endif
1142655Sstever@eecs.umich.edu#ifdef _O_NOCTTY
1152655Sstever@eecs.umich.edu  { ArmLinux64::TGT_O_NOCTTY,     _O_NOCTTY },
1162655Sstever@eecs.umich.edu#endif
1172655Sstever@eecs.umich.edu#ifdef _O_SYNC
118  { ArmLinux64::TGT_O_SYNC,       _O_SYNC },
119#endif
120#else /* !_MSC_VER */
121  { ArmLinux64::TGT_O_RDONLY,     O_RDONLY },
122  { ArmLinux64::TGT_O_WRONLY,     O_WRONLY },
123  { ArmLinux64::TGT_O_RDWR,       O_RDWR },
124  { ArmLinux64::TGT_O_CREAT,      O_CREAT },
125  { ArmLinux64::TGT_O_EXCL,       O_EXCL },
126  { ArmLinux64::TGT_O_NOCTTY,     O_NOCTTY },
127  { ArmLinux64::TGT_O_TRUNC,      O_TRUNC },
128  { ArmLinux64::TGT_O_APPEND,     O_APPEND },
129  { ArmLinux64::TGT_O_NONBLOCK,   O_NONBLOCK },
130#ifdef O_SYNC
131  { ArmLinux64::TGT_O_SYNC,       O_SYNC },
132#endif
133#ifdef FASYNC
134  { ArmLinux64::TGT_FASYNC,       FASYNC },
135#endif
136#ifdef O_DIRECT
137  { ArmLinux64::TGT_O_DIRECT,     O_DIRECT },
138#endif
139#ifdef O_LARGEFILE
140  { ArmLinux64::TGT_O_LARGEFILE,  O_LARGEFILE },
141#endif
142#ifdef O_DIRECTORY
143  { ArmLinux64::TGT_O_DIRECTORY,  O_DIRECTORY },
144#endif
145#ifdef O_NOFOLLOW
146  { ArmLinux64::TGT_O_NOFOLLOW,   O_NOFOLLOW },
147#endif
148#endif /* _MSC_VER */
149};
150
151const int ArmLinux64::NUM_OPEN_FLAGS = sizeof(ArmLinux64::openFlagTable) /
152                                       sizeof(ArmLinux64::openFlagTable[0]);
153
154