1/* $NetBSD: linux_mmap.h,v 1.22 2021/09/23 06:56:27 ryo Exp $ */ 2 3/*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Frank van der Linden and Eric Haszlakiewicz. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _LINUX_MMAP_H 33#define _LINUX_MMAP_H 34 35#define LINUX_PROT_NONE 0x00 36#define LINUX_PROT_READ 0x01 37#define LINUX_PROT_WRITE 0x02 38#define LINUX_PROT_EXEC 0x04 39#define LINUX_PROT_GROWSDOWN 0x01000000 40#define LINUX_PROT_GROWSUP 0x02000000 41 42#define LINUX_MAP_SHARED 0x0001 43#define LINUX_MAP_PRIVATE 0x0002 44 45#if defined(__i386__) 46#include <compat/linux/arch/i386/linux_mmap.h> 47#elif defined(__m68k__) 48#include <compat/linux/arch/m68k/linux_mmap.h> 49#elif defined(__alpha__) 50#include <compat/linux/arch/alpha/linux_mmap.h> 51#elif defined(__powerpc__) 52#include <compat/linux/arch/powerpc/linux_mmap.h> 53#elif defined(__mips__) 54#include <compat/linux/arch/mips/linux_mmap.h> 55#elif defined(__aarch64__) 56#include <compat/linux/arch/aarch64/linux_mmap.h> 57#elif defined(__arm__) 58#include <compat/linux/arch/arm/linux_mmap.h> 59#elif defined(__amd64__) 60#include <compat/linux/arch/amd64/linux_mmap.h> 61/* 62 * XXX ERH: All below here are guesses. The header 63 * XXX ERH: files are correct but the defined(*) 64 * XXX ERH: probably aren't 65 * 66 * XXX ERH: Can probably drop some of these headers: linux 67 * XXX ERH: is stupid about compat stuff. It doesn't really 68 * XXX ERH: use all the defines, but I don't want to go looking 69 * XXX ERH: through all the kernel sources right now. 70 */ 71#elif defined(__sparc__) 72#include <compat/linux/arch/sparc/linux_mmap.h> 73#else 74#error Undefined linux_mmap.h machine type. 75#endif 76 77/* 78 * Ensure the linux_sys_mmap syscall appears to exist: 79 */ 80struct linux_sys_mmap_args; 81struct linux_sys_mmap_args { 82 syscallarg(unsigned long) addr; 83 syscallarg(size_t) len; 84 syscallarg(int) prot; 85 syscallarg(int) flags; 86 syscallarg(int) fd; 87 syscallarg(linux_off_t) offset; 88}; 89 90/* 91 * Same arguments, but different meaning for "offset". 92 * See linux_misc.c:linux_sys_mmap2(). 93 */ 94#define linux_sys_mmap2_args linux_sys_mmap_args 95 96#ifdef _KERNEL 97__BEGIN_DECLS 98int linux_sys_mmap(struct lwp *p, const struct linux_sys_mmap_args *v, register_t *retval); 99int linux_sys_mmap2(struct lwp *p, const struct linux_sys_mmap2_args *v, register_t *retval); 100 101__END_DECLS 102#endif /* !_KERNEL */ 103 104#endif /* !_LINUX_MMAP_H */ 105