Ticket #13665: vivek-gsoc2017-drm-squash.diff

File vivek-gsoc2017-drm-squash.diff, 235.0 KB (added by kallisti5, 7 years ago)

Vivek's drm branch

  • new file headers/compatibility/freebsd/machine/atomic.h

    diff --git a/headers/compatibility/freebsd/machine/atomic.h b/headers/compatibility/freebsd/machine/atomic.h
    new file mode 100644
    index 0000000000..d02f8ff148
    - +  
     1/*
     2 * Copyright 2007, Hugo Santos. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_ATOMIC_H_
     6#define _FBSD_COMPAT_MACHINE_ATOMIC_H_
     7
     8
     9#include <KernelExport.h>
     10
     11
     12#define atomic_add_int(ptr, value) \
     13    atomic_add((int32 *)(ptr), value)
     14
     15#define atomic_subtract_int(ptr, value) \
     16    atomic_add((int32 *)(ptr), -value)
     17
     18#define atomic_set_acq_32(ptr, value) \
     19    atomic_set_int(ptr, value)
     20
     21#define atomic_set_int(ptr, value) \
     22    atomic_or((int32 *)(ptr), value)
     23
     24#define atomic_readandclear_int(ptr) \
     25    atomic_set((int32 *)(ptr), 0)
     26
     27#endif  /* _FBSD_COMPAT_MACHINE_ATOMIC_H_ */
  • new file headers/compatibility/freebsd/machine/cpufunc.h

    diff --git a/headers/compatibility/freebsd/machine/cpufunc.h b/headers/compatibility/freebsd/machine/cpufunc.h
    new file mode 100644
    index 0000000000..8e1575b1dd
    - +  
     1/*-
     2 * Copyright (c) 1993 The Regents of the University of California.
     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
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 4. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _FBSD_COMPAT_MACHINE_CPUFUNC_H_
     32#define _FBSD_COMPAT_MACHINE_CPUFUNC_H_
     33
     34
     35static __inline void
     36outsb(u_int port, const void *addr, size_t cnt)
     37{
     38    __asm __volatile("cld; rep; outsb"
     39             : "+S" (addr), "+c" (cnt)
     40             : "d" (port));
     41}
     42
     43#endif /* _FBSD_COMPAT_MACHINE_CPUFUNC_H_ */
  • new file headers/compatibility/freebsd/machine/endian.h

    diff --git a/headers/compatibility/freebsd/machine/endian.h b/headers/compatibility/freebsd/machine/endian.h
    new file mode 100644
    index 0000000000..6d6e68c768
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_ENDIAN_H_
     6#define _FBSD_COMPAT_MACHINE_ENDIAN_H_
     7
     8
     9#include <freebsd/sys/cdefs.h>
     10#include <freebsd/sys/_types.h>
     11
     12#endif
  • new file headers/compatibility/freebsd/sys/_mutex.h

    diff --git a/headers/compatibility/freebsd/sys/_mutex.h b/headers/compatibility/freebsd/sys/_mutex.h
    new file mode 100644
    index 0000000000..7d8e757c53
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS__MUTEX_H_
     7#define _FBSD_COMPAT_SYS__MUTEX_H_
     8
     9
     10#include <lock.h>
     11
     12
     13struct mtx {
     14    int                     type;
     15    union {
     16        struct {
     17            mutex           lock;
     18            thread_id       owner;
     19        }                   mutex;
     20        int32               spinlock;
     21        recursive_lock      recursive;
     22    } u;
     23};
     24
     25
     26#endif /* _FBSD_COMPAT_SYS__MUTEX_H_ */
  • new file headers/compatibility/freebsd/sys/_timeval.h

    diff --git a/headers/compatibility/freebsd/sys/_timeval.h b/headers/compatibility/freebsd/sys/_timeval.h
    new file mode 100644
    index 0000000000..f447fca94b
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS__TIMEVAL_H_
     6#define _FBSD_COMPAT_SYS__TIMEVAL_H_
     7
     8
     9#include <freebsd/sys/_types.h>
     10
     11#endif /* _FBSD_COMPAT_SYS__TIMEVAL_H_ */
  • new file headers/compatibility/freebsd/sys/_types.h

    diff --git a/headers/compatibility/freebsd/sys/_types.h b/headers/compatibility/freebsd/sys/_types.h
    new file mode 100644
    index 0000000000..790e013860
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS__TYPES_H_
     6#define _FBSD_COMPAT_SYS__TYPES_H_
     7
     8
     9#ifdef __GNUCLIKE_BUILTIN_VARARGS
     10typedef __builtin_va_list   __va_list;  /* internally known to gcc */
     11#else
     12typedef char *          __va_list;
     13#endif /* __GNUCLIKE_BUILTIN_VARARGS */
     14#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
     15    && !defined(__NO_GNUC_VA_LIST)
     16#define __GNUC_VA_LIST
     17typedef __va_list       __gnuc_va_list; /* compatibility w/GNU headers*/
     18#endif
     19
     20#endif /* _FBSD_COMPAT_SYS__TYPES_H_ */
  • new file headers/compatibility/freebsd/sys/cdefs.h

    diff --git a/headers/compatibility/freebsd/sys/cdefs.h b/headers/compatibility/freebsd/sys/cdefs.h
    new file mode 100644
    index 0000000000..f971269f4c
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * This code is derived from software contributed to Berkeley by
     6 * Berkeley Software Design, Inc.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice, this list of conditions and the following disclaimer.
     13 * 2. Redistributions in binary form must reproduce the above copyright
     14 *    notice, this list of conditions and the following disclaimer in the
     15 *    documentation and/or other materials provided with the distribution.
     16 * 4. Neither the name of the University nor the names of its contributors
     17 *    may be used to endorse or promote products derived from this software
     18 *    without specific prior written permission.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30 * SUCH DAMAGE.
     31 *
     32 *  @(#)cdefs.h 8.8 (Berkeley) 1/9/95
     33 * $FreeBSD$
     34 */
     35#ifndef _FBSD_COMPAT_SYS_CDEFS_H_
     36#define _FBSD_COMPAT_SYS_CDEFS_H_
     37
     38
     39#include <posix/sys/cdefs.h>
     40
     41
     42#define __FBSDID(str)   static const char __fbsdid[] = str
     43
     44/*
     45 * This code has been put in place to help reduce the addition of
     46 * compiler specific defines in FreeBSD code.  It helps to aid in
     47 * having a compiler-agnostic source tree.
     48 */
     49
     50#if defined(__GNUC__) || defined(__INTEL_COMPILER)
     51
     52#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
     53#define __GNUCLIKE_ASM 3
     54#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
     55#else
     56#define __GNUCLIKE_ASM 2
     57#endif
     58#define __GNUCLIKE___TYPEOF 1
     59#define __GNUCLIKE___OFFSETOF 1
     60#define __GNUCLIKE___SECTION 1
     61
     62#define __GNUCLIKE_ATTRIBUTE_MODE_DI 1
     63
     64#ifndef __INTEL_COMPILER
     65# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
     66#endif
     67
     68#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
     69# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
     70    && __INTEL_COMPILER < 800
     71#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
     72# endif
     73
     74#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
     75# define __GNUCLIKE_BUILTIN_VARARGS 1
     76# define __GNUCLIKE_BUILTIN_STDARG 1
     77# define __GNUCLIKE_BUILTIN_VAALIST 1
     78#endif
     79
     80#if defined(__GNUC__)
     81# define __GNUC_VA_LIST_COMPATIBILITY 1
     82#endif
     83
     84#ifndef __INTEL_COMPILER
     85# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
     86# define __GNUCLIKE_MATH_BUILTIN_RELOPS
     87#endif
     88
     89#define __GNUCLIKE_BUILTIN_MEMCPY 1
     90
     91/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
     92#define __CC_SUPPORTS_INLINE 1
     93#define __CC_SUPPORTS___INLINE 1
     94#define __CC_SUPPORTS___INLINE__ 1
     95
     96#define __CC_SUPPORTS___FUNC__ 1
     97#define __CC_SUPPORTS_WARNING 1
     98
     99#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
     100
     101#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
     102
     103#endif /* __GNUC__ || __INTEL_COMPILER */
     104
     105
     106/*
     107 * Macro to test if we're using a specific version of gcc or later.
     108 */
     109#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
     110#define __GNUC_PREREQ__(ma, mi) \
     111    (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
     112#else
     113#define __GNUC_PREREQ__(ma, mi) 0
     114#endif
     115
     116/*
     117 * GNU C version 2.96 adds explicit branch prediction so that
     118 * the CPU back-end can hint the processor and also so that
     119 * code blocks can be reordered such that the predicted path
     120 * sees a more linear flow, thus improving cache behavior, etc.
     121 *
     122 * The following two macros provide us with a way to utilize this
     123 * compiler feature.  Use __predict_true() if you expect the expression
     124 * to evaluate to true, and __predict_false() if you expect the
     125 * expression to evaluate to false.
     126 *
     127 * A few notes about usage:
     128 *
     129 *  * Generally, __predict_false() error condition checks (unless
     130 *    you have some _strong_ reason to do otherwise, in which case
     131 *    document it), and/or __predict_true() `no-error' condition
     132 *    checks, assuming you want to optimize for the no-error case.
     133 *
     134 *  * Other than that, if you don't know the likelihood of a test
     135 *    succeeding from empirical or other `hard' evidence, don't
     136 *    make predictions.
     137 *
     138 *  * These are meant to be used in places that are run `a lot'.
     139 *    It is wasteful to make predictions in code that is run
     140 *    seldomly (e.g. at subsystem initialization time) as the
     141 *    basic block reordering that this affects can often generate
     142 *    larger code.
     143 */
     144#if __GNUC_PREREQ__(2, 96)
     145#define __predict_true(exp)     __builtin_expect((exp), 1)
     146#define __predict_false(exp)    __builtin_expect((exp), 0)
     147#else
     148#define __predict_true(exp)     (exp)
     149#define __predict_false(exp)    (exp)
     150#endif
     151
     152/*
     153 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
     154 * require it.
     155 */
     156#if __GNUC_PREREQ__(4, 1)
     157#define __offsetof(type, field)  __builtin_offsetof(type, field)
     158#else
     159#ifndef __cplusplus
     160#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
     161#else
     162#define __offsetof(type, field)                 \
     163  (__offsetof__ (reinterpret_cast <size_t>          \
     164                 (&reinterpret_cast <const volatile char &> \
     165                  (static_cast<type *> (0)->field))))
     166#endif
     167#endif
     168#define __rangeof(type, start, end) \
     169    (__offsetof(type, end) - __offsetof(type, start))
     170
     171/*
     172 * Compiler-dependent macros to help declare dead (non-returning) and
     173 * pure (no side effects) functions, and unused variables.  They are
     174 * null except for versions of gcc that are known to support the features
     175 * properly (old versions of gcc-2 supported the dead and pure features
     176 * in a different (wrong) way).  If we do not provide an implementation
     177 * for a given compiler, let the compile fail if it is told to use
     178 * a feature that we cannot live without.
     179 */
     180#ifdef lint
     181#define __pure2
     182#define __unused
     183#define __packed
     184#define __aligned(x)
     185#define __section(x)
     186#else
     187#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
     188#define __pure2
     189#define __unused
     190#endif
     191#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
     192#define __pure2     __attribute__((__const__))
     193#define __unused
     194/* XXX Find out what to do for __packed, __aligned and __section */
     195#endif
     196#if __GNUC_PREREQ__(2, 7)
     197#define __pure2     __attribute__((__const__))
     198#define __unused    __attribute__((__unused__))
     199#define __packed    __attribute__((__packed__))
     200#define __aligned(x)    __attribute__((__aligned__(x)))
     201#define __section(x)    __attribute__((__section__(x)))
     202#endif
     203
     204#if __GNUC_PREREQ__(3, 1)
     205#define __used      __attribute__((__used__))
     206#else
     207#if __GNUC_PREREQ__(2, 7)
     208#define __used
     209#endif
     210#endif
     211
     212#if defined(__INTEL_COMPILER)
     213#define __pure2     __attribute__((__const__))
     214#define __unused    __attribute__((__unused__))
     215#define __used      __attribute__((__used__))
     216#define __packed    __attribute__((__packed__))
     217#define __aligned(x)    __attribute__((__aligned__(x)))
     218#define __section(x)    __attribute__((__section__(x)))
     219#endif
     220#endif
     221
     222/*
     223 * Compiler-dependent macros to declare that functions take printf-like
     224 * or scanf-like arguments.  They are null except for versions of gcc
     225 * that are known to support the features properly (old versions of gcc-2
     226 * didn't permit keeping the keywords out of the application namespace).
     227 */
     228#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
     229#define __printflike(fmtarg, firstvararg)
     230#define __scanflike(fmtarg, firstvararg)
     231#define __format_arg(fmtarg)
     232#else
     233#define __printflike(fmtarg, firstvararg) \
     234        __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
     235#define __scanflike(fmtarg, firstvararg) \
     236        __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
     237#define __format_arg(fmtarg)    __attribute__((__format_arg__ (fmtarg)))
     238#endif
     239
     240#if __GNUC_PREREQ__(3, 1)
     241#define __noinline  __attribute__ ((__noinline__))
     242#else
     243#define __noinline
     244#endif
     245
     246#if __GNUC_PREREQ__(3, 3)
     247#define __nonnull(x)    __attribute__((__nonnull__(x)))
     248#else
     249#define __nonnull(x)
     250#endif
     251
     252/*
     253 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
     254 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
     255 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
     256 * mode -- there must be no spaces between its arguments, and for nested
     257 * __CONCAT's, all the __CONCAT's must be at the left.  __CONCAT can also
     258 * concatenate double-quoted strings produced by the __STRING macro, but
     259 * this only works with ANSI C.
     260 *
     261 * __XSTRING is like __STRING, but it expands any macros in its argument
     262 * first.  It is only available with ANSI C.
     263 */
     264#if defined(__STDC__) || defined(__cplusplus)
     265#define __XSTRING(x)    __STRING(x) /* expand x, then stringify */
     266
     267#define __const     const       /* define reserved names to standard */
     268#define __signed    signed
     269#define __volatile  volatile
     270#if defined(__cplusplus)
     271#define __inline    inline      /* convert to C++ keyword */
     272#else
     273#if !(defined(__CC_SUPPORTS___INLINE))
     274#define __inline            /* delete GCC keyword */
     275#endif /* ! __CC_SUPPORTS___INLINE */
     276#endif /* !__cplusplus */
     277
     278#else   /* !(__STDC__ || __cplusplus) */
     279
     280#if !defined(__CC_SUPPORTS___INLINE)
     281#define __const             /* delete pseudo-ANSI C keywords */
     282#define __inline
     283#define __signed
     284#define __volatile
     285/*
     286 * In non-ANSI C environments, new programs will want ANSI-only C keywords
     287 * deleted from the program and old programs will want them left alone.
     288 * When using a compiler other than gcc, programs using the ANSI C keywords
     289 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
     290 * When using "gcc -traditional", we assume that this is the intent; if
     291 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
     292 */
     293#ifndef NO_ANSI_KEYWORDS
     294#define const               /* delete ANSI C keywords */
     295#define inline
     296#define signed
     297#define volatile
     298#endif  /* !NO_ANSI_KEYWORDS */
     299#endif  /* !__CC_SUPPORTS___INLINE */
     300#endif  /* !(__STDC__ || __cplusplus) */
     301
     302#ifndef __DECONST
     303#define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
     304#endif
     305
     306#ifndef __UNCONST
     307#define __UNCONST(var)  ((void*)(uintptr_t)(const void *)(var))
     308#endif
     309
     310#endif
  • new file headers/compatibility/freebsd/sys/libkern.h

    diff --git a/headers/compatibility/freebsd/sys/libkern.h b/headers/compatibility/freebsd/sys/libkern.h
    new file mode 100644
    index 0000000000..ad98f4d4eb
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_LIBKERN_H_
     6#define _FBSD_COMPAT_SYS_LIBKERN_H_
     7
     8
     9#include <freebsd/sys/cdefs.h>
     10#include <freebsd/sys/types.h>
     11
     12#ifdef __cplusplus
     13extern "C" {
     14#endif
     15
     16extern int random(void);
     17uint32_t arc4random(void);
     18
     19static __inline int imax(int a, int b) { return (a > b ? a : b); }
     20
     21extern int abs(int a);
     22
     23#ifdef __cplusplus
     24}
     25#endif
     26
     27#endif /* _FBSD_COMPAT_SYS_LIBKERN_H_ */
  • new file headers/compatibility/freebsd/sys/queue.h

    diff --git a/headers/compatibility/freebsd/sys/queue.h b/headers/compatibility/freebsd/sys/queue.h
    new file mode 100644
    index 0000000000..a6c6ba197b
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  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
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 4. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
     28 *
     29 *  @(#)queue.h 8.5 (Berkeley) 8/20/94
     30 * $FreeBSD: src/sys/sys/queue.h,v 1.60.2.1 2005/08/16 22:41:39 phk Exp $
     31 */
     32#ifndef _SYS_QUEUE_H_
     33#define _SYS_QUEUE_H_
     34
     35#include <freebsd/sys/cdefs.h>
     36
     37/*
     38 * This file defines four types of data structures: singly-linked lists,
     39 * singly-linked tail queues, lists and tail queues.
     40 *
     41 * A singly-linked list is headed by a single forward pointer. The elements
     42 * are singly linked for minimum space and pointer manipulation overhead at
     43 * the expense of O(n) removal for arbitrary elements. New elements can be
     44 * added to the list after an existing element or at the head of the list.
     45 * Elements being removed from the head of the list should use the explicit
     46 * macro for this purpose for optimum efficiency. A singly-linked list may
     47 * only be traversed in the forward direction.  Singly-linked lists are ideal
     48 * for applications with large datasets and few or no removals or for
     49 * implementing a LIFO queue.
     50 *
     51 * A singly-linked tail queue is headed by a pair of pointers, one to the
     52 * head of the list and the other to the tail of the list. The elements are
     53 * singly linked for minimum space and pointer manipulation overhead at the
     54 * expense of O(n) removal for arbitrary elements. New elements can be added
     55 * to the list after an existing element, at the head of the list, or at the
     56 * end of the list. Elements being removed from the head of the tail queue
     57 * should use the explicit macro for this purpose for optimum efficiency.
     58 * A singly-linked tail queue may only be traversed in the forward direction.
     59 * Singly-linked tail queues are ideal for applications with large datasets
     60 * and few or no removals or for implementing a FIFO queue.
     61 *
     62 * A list is headed by a single forward pointer (or an array of forward
     63 * pointers for a hash table header). The elements are doubly linked
     64 * so that an arbitrary element can be removed without a need to
     65 * traverse the list. New elements can be added to the list before
     66 * or after an existing element or at the head of the list. A list
     67 * may only be traversed in the forward direction.
     68 *
     69 * A tail queue is headed by a pair of pointers, one to the head of the
     70 * list and the other to the tail of the list. The elements are doubly
     71 * linked so that an arbitrary element can be removed without a need to
     72 * traverse the list. New elements can be added to the list before or
     73 * after an existing element, at the head of the list, or at the end of
     74 * the list. A tail queue may be traversed in either direction.
     75 *
     76 * For details on the use of these macros, see the queue(3) manual page.
     77 *
     78 *
     79 *              SLIST   LIST    STAILQ  TAILQ
     80 * _HEAD            +   +   +   +
     81 * _HEAD_INITIALIZER        +   +   +   +
     82 * _ENTRY           +   +   +   +
     83 * _INIT            +   +   +   +
     84 * _EMPTY           +   +   +   +
     85 * _FIRST           +   +   +   +
     86 * _NEXT            +   +   +   +
     87 * _PREV            -   -   -   +
     88 * _LAST            -   -   +   +
     89 * _FOREACH         +   +   +   +
     90 * _FOREACH_SAFE        +   +   +   +
     91 * _FOREACH_REVERSE     -   -   -   +
     92 * _FOREACH_REVERSE_SAFE    -   -   -   +
     93 * _INSERT_HEAD         +   +   +   +
     94 * _INSERT_BEFORE       -   +   -   +
     95 * _INSERT_AFTER        +   +   +   +
     96 * _INSERT_TAIL         -   -   +   +
     97 * _CONCAT          -   -   +   +
     98 * _REMOVE_HEAD         +   -   +   -
     99 * _REMOVE          +   +   +   +
     100 *
     101 */
     102#define QUEUE_MACRO_DEBUG 0
     103#if QUEUE_MACRO_DEBUG
     104/* Store the last 2 places the queue element or head was altered */
     105struct qm_trace {
     106    char * lastfile;
     107    int lastline;
     108    char * prevfile;
     109    int prevline;
     110};
     111
     112#define TRACEBUF    struct qm_trace trace;
     113#define TRASHIT(x)  do {(x) = (void *)-1;} while (0)
     114
     115#define QMD_TRACE_HEAD(head) do {                   \
     116    (head)->trace.prevline = (head)->trace.lastline;        \
     117    (head)->trace.prevfile = (head)->trace.lastfile;        \
     118    (head)->trace.lastline = __LINE__;              \
     119    (head)->trace.lastfile = __FILE__;              \
     120} while (0)
     121
     122#define QMD_TRACE_ELEM(elem) do {                   \
     123    (elem)->trace.prevline = (elem)->trace.lastline;        \
     124    (elem)->trace.prevfile = (elem)->trace.lastfile;        \
     125    (elem)->trace.lastline = __LINE__;              \
     126    (elem)->trace.lastfile = __FILE__;              \
     127} while (0)
     128
     129#else
     130#define QMD_TRACE_ELEM(elem)
     131#define QMD_TRACE_HEAD(head)
     132#define TRACEBUF
     133#define TRASHIT(x)
     134#endif  /* QUEUE_MACRO_DEBUG */
     135
     136/*
     137 * Singly-linked List declarations.
     138 */
     139#define SLIST_HEAD(name, type)                      \
     140struct name {                               \
     141    struct type *slh_first; /* first element */         \
     142}
     143
     144#define SLIST_HEAD_INITIALIZER(head)                    \
     145    { NULL }
     146
     147#define SLIST_ENTRY(type)                       \
     148struct {                                \
     149    struct type *sle_next;  /* next element */          \
     150}
     151
     152/*
     153 * Singly-linked List functions.
     154 */
     155#define SLIST_EMPTY(head)   ((head)->slh_first == NULL)
     156
     157#define SLIST_FIRST(head)   ((head)->slh_first)
     158
     159#define SLIST_FOREACH(var, head, field)                 \
     160    for ((var) = SLIST_FIRST((head));               \
     161        (var);                          \
     162        (var) = SLIST_NEXT((var), field))
     163
     164#define SLIST_FOREACH_SAFE(var, head, field, tvar)          \
     165    for ((var) = SLIST_FIRST((head));               \
     166        (var) && ((tvar) = SLIST_NEXT((var), field), 1);        \
     167        (var) = (tvar))
     168
     169#define SLIST_FOREACH_PREVPTR(var, varp, head, field)           \
     170    for ((varp) = &SLIST_FIRST((head));             \
     171        ((var) = *(varp)) != NULL;                  \
     172        (varp) = &SLIST_NEXT((var), field))
     173
     174#define SLIST_INIT(head) do {                       \
     175    SLIST_FIRST((head)) = NULL;                 \
     176} while (0)
     177
     178#define SLIST_INSERT_AFTER(slistelm, elm, field) do {           \
     179    SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);   \
     180    SLIST_NEXT((slistelm), field) = (elm);              \
     181} while (0)
     182
     183#define SLIST_INSERT_HEAD(head, elm, field) do {            \
     184    SLIST_NEXT((elm), field) = SLIST_FIRST((head));         \
     185    SLIST_FIRST((head)) = (elm);                    \
     186} while (0)
     187
     188#define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
     189
     190#define SLIST_REMOVE(head, elm, type, field) do {           \
     191    if (SLIST_FIRST((head)) == (elm)) {             \
     192        SLIST_REMOVE_HEAD((head), field);           \
     193    }                               \
     194    else {                              \
     195        struct type *curelm = SLIST_FIRST((head));      \
     196        while (SLIST_NEXT(curelm, field) != (elm))      \
     197            curelm = SLIST_NEXT(curelm, field);     \
     198        SLIST_NEXT(curelm, field) =             \
     199            SLIST_NEXT(SLIST_NEXT(curelm, field), field);   \
     200    }                               \
     201} while (0)
     202
     203#define SLIST_REMOVE_HEAD(head, field) do {             \
     204    SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
     205} while (0)
     206
     207/*
     208 * Singly-linked Tail queue declarations.
     209 */
     210#define STAILQ_HEAD(name, type)                     \
     211struct name {                               \
     212    struct type *stqh_first;/* first element */         \
     213    struct type **stqh_last;/* addr of last next element */     \
     214}
     215
     216#define STAILQ_HEAD_INITIALIZER(head)                   \
     217    { NULL, &(head).stqh_first }
     218
     219#define STAILQ_ENTRY(type)                      \
     220struct {                                \
     221    struct type *stqe_next; /* next element */          \
     222}
     223
     224/*
     225 * Singly-linked Tail queue functions.
     226 */
     227#define STAILQ_CONCAT(head1, head2) do {                \
     228    if (!STAILQ_EMPTY((head2))) {                   \
     229        *(head1)->stqh_last = (head2)->stqh_first;      \
     230        (head1)->stqh_last = (head2)->stqh_last;        \
     231        STAILQ_INIT((head2));                   \
     232    }                               \
     233} while (0)
     234
     235#define STAILQ_EMPTY(head)  ((head)->stqh_first == NULL)
     236
     237#define STAILQ_FIRST(head)  ((head)->stqh_first)
     238
     239#define STAILQ_FOREACH(var, head, field)                \
     240    for((var) = STAILQ_FIRST((head));               \
     241       (var);                           \
     242       (var) = STAILQ_NEXT((var), field))
     243
     244
     245#define STAILQ_FOREACH_SAFE(var, head, field, tvar)         \
     246    for ((var) = STAILQ_FIRST((head));              \
     247        (var) && ((tvar) = STAILQ_NEXT((var), field), 1);       \
     248        (var) = (tvar))
     249
     250#define STAILQ_INIT(head) do {                      \
     251    STAILQ_FIRST((head)) = NULL;                    \
     252    (head)->stqh_last = &STAILQ_FIRST((head));          \
     253} while (0)
     254
     255#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {       \
     256    if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
     257        (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
     258    STAILQ_NEXT((tqelm), field) = (elm);                \
     259} while (0)
     260
     261#define STAILQ_INSERT_HEAD(head, elm, field) do {           \
     262    if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
     263        (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
     264    STAILQ_FIRST((head)) = (elm);                   \
     265} while (0)
     266
     267#define STAILQ_INSERT_TAIL(head, elm, field) do {           \
     268    STAILQ_NEXT((elm), field) = NULL;               \
     269    *(head)->stqh_last = (elm);                 \
     270    (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
     271} while (0)
     272
     273#define STAILQ_LAST(head, type, field)                  \
     274    (STAILQ_EMPTY((head)) ?                     \
     275        NULL :                          \
     276            ((struct type *)                    \
     277        ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
     278
     279#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
     280
     281#define STAILQ_REMOVE(head, elm, type, field) do {          \
     282    if (STAILQ_FIRST((head)) == (elm)) {                \
     283        STAILQ_REMOVE_HEAD((head), field);          \
     284    }                               \
     285    else {                              \
     286        struct type *curelm = STAILQ_FIRST((head));     \
     287        while (STAILQ_NEXT(curelm, field) != (elm))     \
     288            curelm = STAILQ_NEXT(curelm, field);        \
     289        if ((STAILQ_NEXT(curelm, field) =           \
     290             STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
     291            (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
     292    }                               \
     293} while (0)
     294
     295#define STAILQ_REMOVE_HEAD(head, field) do {                \
     296    if ((STAILQ_FIRST((head)) =                 \
     297         STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)     \
     298        (head)->stqh_last = &STAILQ_FIRST((head));      \
     299} while (0)
     300
     301#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {         \
     302    if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
     303        (head)->stqh_last = &STAILQ_FIRST((head));      \
     304} while (0)
     305
     306/*
     307 * List declarations.
     308 */
     309#define LIST_HEAD(name, type)                       \
     310struct name {                               \
     311    struct type *lh_first;  /* first element */         \
     312}
     313
     314#define LIST_HEAD_INITIALIZER(head)                 \
     315    { NULL }
     316
     317#define LIST_ENTRY(type)                        \
     318struct {                                \
     319    struct type *le_next;   /* next element */          \
     320    struct type **le_prev;  /* address of previous next element */  \
     321}
     322
     323/*
     324 * List functions.
     325 */
     326
     327#define LIST_EMPTY(head)    ((head)->lh_first == NULL)
     328
     329#define LIST_FIRST(head)    ((head)->lh_first)
     330
     331#define LIST_FOREACH(var, head, field)                  \
     332    for ((var) = LIST_FIRST((head));                \
     333        (var);                          \
     334        (var) = LIST_NEXT((var), field))
     335
     336#define LIST_FOREACH_SAFE(var, head, field, tvar)           \
     337    for ((var) = LIST_FIRST((head));                \
     338        (var) && ((tvar) = LIST_NEXT((var), field), 1);     \
     339        (var) = (tvar))
     340
     341#define LIST_INIT(head) do {                        \
     342    LIST_FIRST((head)) = NULL;                  \
     343} while (0)
     344
     345#define LIST_INSERT_AFTER(listelm, elm, field) do {         \
     346    if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
     347        LIST_NEXT((listelm), field)->field.le_prev =        \
     348            &LIST_NEXT((elm), field);               \
     349    LIST_NEXT((listelm), field) = (elm);                \
     350    (elm)->field.le_prev = &LIST_NEXT((listelm), field);        \
     351} while (0)
     352
     353#define LIST_INSERT_BEFORE(listelm, elm, field) do {            \
     354    (elm)->field.le_prev = (listelm)->field.le_prev;        \
     355    LIST_NEXT((elm), field) = (listelm);                \
     356    *(listelm)->field.le_prev = (elm);              \
     357    (listelm)->field.le_prev = &LIST_NEXT((elm), field);        \
     358} while (0)
     359
     360#define LIST_INSERT_HEAD(head, elm, field) do {             \
     361    if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
     362        LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
     363    LIST_FIRST((head)) = (elm);                 \
     364    (elm)->field.le_prev = &LIST_FIRST((head));         \
     365} while (0)
     366
     367#define LIST_NEXT(elm, field)   ((elm)->field.le_next)
     368
     369#define LIST_REMOVE(elm, field) do {                    \
     370    if (LIST_NEXT((elm), field) != NULL)                \
     371        LIST_NEXT((elm), field)->field.le_prev =        \
     372            (elm)->field.le_prev;               \
     373    *(elm)->field.le_prev = LIST_NEXT((elm), field);        \
     374} while (0)
     375
     376/*
     377 * Tail queue declarations.
     378 */
     379#define TAILQ_HEAD(name, type)                      \
     380struct name {                               \
     381    struct type *tqh_first; /* first element */         \
     382    struct type **tqh_last; /* addr of last next element */     \
     383    TRACEBUF                            \
     384}
     385
     386#define TAILQ_HEAD_INITIALIZER(head)                    \
     387    { NULL, &(head).tqh_first }
     388
     389#define TAILQ_ENTRY(type)                       \
     390struct {                                \
     391    struct type *tqe_next;  /* next element */          \
     392    struct type **tqe_prev; /* address of previous next element */  \
     393    TRACEBUF                            \
     394}
     395
     396/*
     397 * Tail queue functions.
     398 */
     399#define TAILQ_CONCAT(head1, head2, field) do {              \
     400    if (!TAILQ_EMPTY(head2)) {                  \
     401        *(head1)->tqh_last = (head2)->tqh_first;        \
     402        (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
     403        (head1)->tqh_last = (head2)->tqh_last;          \
     404        TAILQ_INIT((head2));                    \
     405        QMD_TRACE_HEAD(head1);                  \
     406        QMD_TRACE_HEAD(head2);                  \
     407    }                               \
     408} while (0)
     409
     410#define TAILQ_EMPTY(head)   ((head)->tqh_first == NULL)
     411
     412#define TAILQ_FIRST(head)   ((head)->tqh_first)
     413
     414#define TAILQ_FOREACH(var, head, field)                 \
     415    for ((var) = TAILQ_FIRST((head));               \
     416        (var);                          \
     417        (var) = TAILQ_NEXT((var), field))
     418
     419#define TAILQ_FOREACH_SAFE(var, head, field, tvar)          \
     420    for ((var) = TAILQ_FIRST((head));               \
     421        (var) && ((tvar) = TAILQ_NEXT((var), field), 1);        \
     422        (var) = (tvar))
     423
     424#define TAILQ_FOREACH_REVERSE(var, head, headname, field)       \
     425    for ((var) = TAILQ_LAST((head), headname);          \
     426        (var);                          \
     427        (var) = TAILQ_PREV((var), headname, field))
     428
     429#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
     430    for ((var) = TAILQ_LAST((head), headname);          \
     431        (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
     432        (var) = (tvar))
     433
     434#define TAILQ_INIT(head) do {                       \
     435    TAILQ_FIRST((head)) = NULL;                 \
     436    (head)->tqh_last = &TAILQ_FIRST((head));            \
     437    QMD_TRACE_HEAD(head);                       \
     438} while (0)
     439
     440#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {      \
     441    if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
     442        TAILQ_NEXT((elm), field)->field.tqe_prev =      \
     443            &TAILQ_NEXT((elm), field);              \
     444    else {                              \
     445        (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
     446        QMD_TRACE_HEAD(head);                   \
     447    }                               \
     448    TAILQ_NEXT((listelm), field) = (elm);               \
     449    (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);      \
     450    QMD_TRACE_ELEM(&(elm)->field);                  \
     451    QMD_TRACE_ELEM(&listelm->field);                \
     452} while (0)
     453
     454#define TAILQ_INSERT_BEFORE(listelm, elm, field) do {           \
     455    (elm)->field.tqe_prev = (listelm)->field.tqe_prev;      \
     456    TAILQ_NEXT((elm), field) = (listelm);               \
     457    *(listelm)->field.tqe_prev = (elm);             \
     458    (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);      \
     459    QMD_TRACE_ELEM(&(elm)->field);                  \
     460    QMD_TRACE_ELEM(&listelm->field);                \
     461} while (0)
     462
     463#define TAILQ_INSERT_HEAD(head, elm, field) do {            \
     464    if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
     465        TAILQ_FIRST((head))->field.tqe_prev =           \
     466            &TAILQ_NEXT((elm), field);              \
     467    else                                \
     468        (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
     469    TAILQ_FIRST((head)) = (elm);                    \
     470    (elm)->field.tqe_prev = &TAILQ_FIRST((head));           \
     471    QMD_TRACE_HEAD(head);                       \
     472    QMD_TRACE_ELEM(&(elm)->field);                  \
     473} while (0)
     474
     475#define TAILQ_INSERT_TAIL(head, elm, field) do {            \
     476    TAILQ_NEXT((elm), field) = NULL;                \
     477    (elm)->field.tqe_prev = (head)->tqh_last;           \
     478    *(head)->tqh_last = (elm);                  \
     479    (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
     480    QMD_TRACE_HEAD(head);                       \
     481    QMD_TRACE_ELEM(&(elm)->field);                  \
     482} while (0)
     483
     484#define TAILQ_LAST(head, headname)                  \
     485    (*(((struct headname *)((head)->tqh_last))->tqh_last))
     486
     487#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
     488
     489#define TAILQ_PREV(elm, headname, field)                \
     490    (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
     491
     492#define TAILQ_REMOVE(head, elm, field) do {             \
     493    if ((TAILQ_NEXT((elm), field)) != NULL)             \
     494        TAILQ_NEXT((elm), field)->field.tqe_prev =      \
     495            (elm)->field.tqe_prev;              \
     496    else {                              \
     497        (head)->tqh_last = (elm)->field.tqe_prev;       \
     498        QMD_TRACE_HEAD(head);                   \
     499    }                               \
     500    *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);      \
     501    TRASHIT((elm)->field.tqe_next);                 \
     502    TRASHIT((elm)->field.tqe_prev);                 \
     503    QMD_TRACE_ELEM(&(elm)->field);                  \
     504} while (0)
     505
     506
     507#ifdef _KERNEL
     508
     509/*
     510 * XXX insque() and remque() are an old way of handling certain queues.
     511 * They bogusly assumes that all queue heads look alike.
     512 */
     513
     514struct quehead {
     515    struct quehead *qh_link;
     516    struct quehead *qh_rlink;
     517};
     518
     519#ifdef __CC_SUPPORTS___INLINE
     520
     521static __inline void
     522insque(void *a, void *b)
     523{
     524    struct quehead *element = (struct quehead *)a,
     525         *head = (struct quehead *)b;
     526
     527    element->qh_link = head->qh_link;
     528    element->qh_rlink = head;
     529    head->qh_link = element;
     530    element->qh_link->qh_rlink = element;
     531}
     532
     533static __inline void
     534remque(void *a)
     535{
     536    struct quehead *element = (struct quehead *)a;
     537
     538    element->qh_link->qh_rlink = element->qh_rlink;
     539    element->qh_rlink->qh_link = element->qh_link;
     540    element->qh_rlink = 0;
     541}
     542
     543#else /* !__CC_SUPPORTS___INLINE */
     544
     545void    insque(void *a, void *b);
     546void    remque(void *a);
     547
     548#endif /* __CC_SUPPORTS___INLINE */
     549
     550#endif /* _KERNEL */
     551
     552#endif /* !_SYS_QUEUE_H_ */
  • new file headers/compatibility/freebsd/sys/systm.h

    diff --git a/headers/compatibility/freebsd/sys/systm.h b/headers/compatibility/freebsd/sys/systm.h
    new file mode 100644
    index 0000000000..ebd70b1ccf
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_SYSTM_H_
     7#define _FBSD_COMPAT_SYS_SYSTM_H_
     8
     9
     10#include <stdint.h>
     11#include <stdio.h>
     12#include <string.h>
     13#include <strings.h>
     14
     15#include <freebsd/machine/atomic.h>
     16#include <freebsd/machine/cpufunc.h>
     17
     18//#include <freebsd/sys/callout.h>
     19#include <freebsd/sys/cdefs.h>
     20#include <freebsd/sys/_mutex.h>
     21#include <freebsd/sys/queue.h>
     22
     23#include <freebsd/sys/libkern.h>
     24
     25
     26#ifdef __cplusplus
     27extern "C" {
     28#endif
     29
     30#define printf freebsd_printf
     31int printf(const char *format, ...) __printflike(1, 2);
     32
     33
     34#define ovbcopy(f, t, l) bcopy((f), (t), (l))
     35
     36#define bootverbose 1
     37
     38#ifdef INVARIANTS
     39#define KASSERT(cond,msg) do {  \
     40    if (!(cond))                \
     41        panic msg;              \
     42} while (0)
     43#else
     44#define KASSERT(exp,msg) do { \
     45} while (0)
     46#endif
     47
     48#define DELAY(n) \
     49    do {                \
     50        if (n < 1000)   \
     51            spin(n);    \
     52        else            \
     53            snooze(n);  \
     54    } while (0)
     55
     56void wakeup(void *);
     57
     58#ifndef CTASSERT /* Allow lint to override */
     59#define CTASSERT(x)         _CTASSERT(x, __LINE__)
     60#define _CTASSERT(x, y)     __CTASSERT(x, y)
     61#define __CTASSERT(x, y)    typedef char __assert ## y[(x) ? 1 : -1]
     62#endif
     63
     64
     65static inline int
     66copyin(const void * __restrict udaddr, void * __restrict kaddr,
     67    size_t len)
     68{
     69    return user_memcpy(kaddr, udaddr, len);
     70}
     71
     72
     73static inline int
     74copyout(const void * __restrict kaddr, void * __restrict udaddr,
     75    size_t len)
     76{
     77    return user_memcpy(udaddr, kaddr, len);
     78}
     79
     80
     81static inline void log(int level, const char *fmt, ...) { }
     82
     83
     84int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
     85extern int sprintf(char *buf, const char *, ...);
     86
     87extern void driver_vprintf(const char *format, va_list vl);
     88#define vprintf(fmt, vl) driver_vprintf(fmt, vl)
     89
     90extern int vsnprintf(char *, size_t, const char *, __va_list)
     91    __printflike(3, 0);
     92
     93int msleep(void *, struct mtx *, int, const char *, int);
     94int _pause(const char *, int);
     95#define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
     96#define tsleep(channel, priority, waitMessage, timeout) \
     97    msleep((channel), NULL, (priority), (waitMessage), (timeout))
     98
     99struct unrhdr;
     100struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
     101void delete_unrhdr(struct unrhdr *);
     102int alloc_unr(struct unrhdr *);
     103void free_unr(struct unrhdr *, u_int);
     104
     105extern char *getenv(const char *name);
     106extern void    freeenv(char *env);
     107
     108#ifdef __cplusplus
     109}
     110#endif
     111
     112#endif  /* _FBSD_COMPAT_SYS_SYSTM_H_ */
  • new file headers/compatibility/freebsd/sys/time.h

    diff --git a/headers/compatibility/freebsd/sys/time.h b/headers/compatibility/freebsd/sys/time.h
    new file mode 100644
    index 0000000000..0c8428587d
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_TIME_H_
     6#define _FBSD_COMPAT_SYS_TIME_H_
     7
     8
     9#include <posix/sys/time.h>
     10
     11#include <freebsd/sys/_timeval.h>
     12#include <sys/types.h>
     13
     14
     15#define time_uptime (system_time() / 1000000)
     16
     17
     18int ppsratecheck(struct timeval*, int*, int);
     19
     20#endif /* _FBSD_COMPAT_SYS_TIME_H_ */
  • new file headers/compatibility/freebsd/sys/types.h

    diff --git a/headers/compatibility/freebsd/sys/types.h b/headers/compatibility/freebsd/sys/types.h
    new file mode 100644
    index 0000000000..2823689b4a
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_TYPES_H_
     6#define _FBSD_COMPAT_SYS_TYPES_H_
     7
     8
     9#include <posix/stdint.h>
     10#include <posix/sys/types.h>
     11
     12#include <freebsd/sys/cdefs.h>
     13
     14#include <freebsd/machine/endian.h>
     15#include <freebsd/sys/_types.h>
     16
     17
     18typedef int boolean_t;
     19typedef __const char* c_caddr_t;
     20typedef uint64_t u_quad_t;
     21
     22#ifdef B_HAIKU_64_BIT
     23
     24typedef uint64_t segsz_t;
     25
     26#else
     27
     28typedef uint32_t segsz_t;
     29
     30#endif
     31
     32#endif
  • new file headers/compatibility/freebsd/vm/_vm_radix.h

    diff --git a/headers/compatibility/freebsd/vm/_vm_radix.h b/headers/compatibility/freebsd/vm/_vm_radix.h
    new file mode 100644
    index 0000000000..e5a0bb2a24
    - +  
     1/*
     2 * Copyright (c) 2013 EMC Corp.
     3 * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org>
     4 * Copyright (c) 2008 Mayur Shardul <mayur.shardul@gmail.com>
     5 * All rights reserved.
     6 *
     7 * Redistribution and use in source and binary forms, with or without
     8 * modification, are permitted provided that the following conditions
     9 * are met:
     10 * 1. Redistributions of source code must retain the above copyright
     11 *    notice, this list of conditions and the following disclaimer.
     12 * 2. Redistributions in binary form must reproduce the above copyright
     13 *    notice, this list of conditions and the following disclaimer in the
     14 *    documentation and/or other materials provided with the distribution.
     15 *
     16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26 * SUCH DAMAGE.
     27 *
     28 * $FreeBSD$
     29 */
     30
     31#ifndef _FBSD_COMPAT_VM_VM_RADIX_H_
     32#define _FBSD_COMPAT_VM_VM_RADIX_H_
     33
     34#include <freebsd/sys/types.h>
     35
     36/*
     37 * Radix tree root.
     38 */
     39struct vm_radix {
     40    uintptr_t   rt_root;
     41};
     42
     43#ifdef _KERNEL
     44
     45static __inline boolean_t
     46vm_radix_is_empty(struct vm_radix *rtree)
     47{
     48
     49    return (rtree->rt_root == 0);
     50}
     51
     52#endif /* _KERNEL */
     53#endif /* !_FBSD_COMPAT_VM_VM_RADIX_H_ */
  • new file headers/compatibility/freebsd/vm/vm.h

    diff --git a/headers/compatibility/freebsd/vm/vm.h b/headers/compatibility/freebsd/vm/vm.h
    new file mode 100644
    index 0000000000..8e41b01bb5
    - +  
     1/*
     2 * Copyright 2007, Hugo Santos. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_VM_VM_H_
     6#define _FBSD_COMPAT_VM_VM_H_
     7
     8
     9#include <stdint.h>
     10#include <KernelExport.h>
     11#include <vm/vm_types.h>
     12
     13#ifdef B_HAIKU_64_BIT
     14
     15typedef uint64_t vm_size_t;
     16
     17#else
     18
     19typedef uint32_t vm_size_t;
     20
     21#endif
     22
     23typedef char vm_inherit_t;  /* inheritance codes */
     24
     25#define VM_INHERIT_SHARE    ((vm_inherit_t) 0)
     26#define VM_INHERIT_COPY     ((vm_inherit_t) 1)
     27#define VM_INHERIT_NONE     ((vm_inherit_t) 2)
     28#define VM_INHERIT_ZERO     ((vm_inherit_t) 3)
     29#define VM_INHERIT_DEFAULT  VM_INHERIT_COPY
     30
     31typedef u_char vm_prot_t;   /* protection codes */
     32
     33#define VM_PROT_NONE        ((vm_prot_t) 0x00)
     34#define VM_PROT_READ        ((vm_prot_t) 0x01)
     35#define VM_PROT_WRITE       ((vm_prot_t) 0x02)
     36#define VM_PROT_EXECUTE     ((vm_prot_t) 0x04)
     37#define VM_PROT_COPY        ((vm_prot_t) 0x08)  /* copy-on-read */
     38
     39#define VM_PROT_ALL     (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
     40#define VM_PROT_RW      (VM_PROT_READ|VM_PROT_WRITE)
     41#define VM_PROT_DEFAULT     VM_PROT_ALL
     42
     43typedef page_num_t vm_pindex_t;
     44typedef page_num_t pfn_t;
     45typedef void *pmap_t;
     46typedef addr_t vm_offset_t;
     47typedef phys_addr_t vm_paddr_t;
     48typedef char vm_memattr_t;
     49typedef u_char objtype_t;
     50typedef uint64_t vm_ooffset_t;
     51
     52struct vm_object;
     53typedef struct vm_object *vm_object_t;
     54
     55struct vm_map_entry;
     56typedef struct vm_map_entry *vm_map_entry_t;
     57
     58struct vm_map;
     59typedef struct vm_map *vm_map_t;
     60
     61typedef struct vm_page *vm_page_t;
     62
     63#define vmspace_pmap(...)   NULL
     64#define pmap_extract(...)   NULL
     65
     66
     67vm_paddr_t pmap_kextract(vm_offset_t virtualAddress);
     68
     69#define vtophys(virtualAddress) pmap_kextract((vm_offset_t)(virtualAddress))
     70
     71#endif  /* _FBSD_COMPAT_VM_VM_H_ */
  • new file headers/compatibility/freebsd/vm/vm_map.h

    diff --git a/headers/compatibility/freebsd/vm/vm_map.h b/headers/compatibility/freebsd/vm/vm_map.h
    new file mode 100644
    index 0000000000..e95869249c
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * This code is derived from software contributed to Berkeley by
     6 * The Mach Operating System project at Carnegie-Mellon University.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice, this list of conditions and the following disclaimer.
     13 * 2. Redistributions in binary form must reproduce the above copyright
     14 *    notice, this list of conditions and the following disclaimer in the
     15 *    documentation and/or other materials provided with the distribution.
     16 * 3. Neither the name of the University nor the names of its contributors
     17 *    may be used to endorse or promote products derived from this software
     18 *    without specific prior written permission.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30 * SUCH DAMAGE.
     31 *
     32 *  @(#)vm_map.h    8.9 (Berkeley) 5/17/95
     33 *
     34 *
     35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     36 * All rights reserved.
     37 *
     38 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
     39 *
     40 * Permission to use, copy, modify and distribute this software and
     41 * its documentation is hereby granted, provided that both the copyright
     42 * notice and this permission notice appear in all copies of the
     43 * software, derivative works or modified versions, and any portions
     44 * thereof, and that both notices appear in supporting documentation.
     45 *
     46 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     47 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     48 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     49 *
     50 * Carnegie Mellon requests users of this software to return to
     51 *
     52 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
     53 *  School of Computer Science
     54 *  Carnegie Mellon University
     55 *  Pittsburgh PA 15213-3890
     56 *
     57 * any improvements or extensions that they make and grant Carnegie the
     58 * rights to redistribute these changes.
     59 *
     60 * $FreeBSD$
     61 */
     62
     63/*
     64 *  Virtual memory map module definitions.
     65 */
     66#ifndef _FBSD_COMPAT_VM_MAP_
     67#define _FBSD_COMPAT_VM_MAP_
     68
     69// #include <sys/lock.h>
     70// #include <sys/sx.h>
     71// #include <sys/_mutex.h>
     72#include <freebsd/sys/types.h>
     73#include <freebsd/sys/_mutex.h>
     74#include <freebsd/vm/vm.h>
     75
     76#include <lock.h>
     77
     78/*
     79 *  Types defined:
     80 *
     81 *  vm_map_t        the high-level address map data structure.
     82 *  vm_map_entry_t      an entry in an address map.
     83 */
     84
     85typedef u_char vm_flags_t;
     86typedef u_int vm_eflags_t;
     87
     88/*
     89 *  Objects which live in maps may be either VM objects, or
     90 *  another map (called a "sharing map") which denotes read-write
     91 *  sharing with other maps.
     92 */
     93union vm_map_object {
     94    struct vm_object *vm_object;    /* object object */
     95    struct vm_map *sub_map;     /* belongs to another map */
     96};
     97
     98/*
     99 *  Address map entries consist of start and end addresses,
     100 *  a VM object (or sharing map) and offset into that object,
     101 *  and user-exported inheritance and protection information.
     102 *  Also included is control information for virtual copy operations.
     103 */
     104struct vm_map_entry {
     105    struct vm_map_entry *prev;  /* previous entry */
     106    struct vm_map_entry *next;  /* next entry */
     107    struct vm_map_entry *left;  /* left child in binary search tree */
     108    struct vm_map_entry *right; /* right child in binary search tree */
     109    vm_offset_t start;      /* start address */
     110    vm_offset_t end;        /* end address */
     111    vm_offset_t avail_ssize;    /* amt can grow if this is a stack */
     112    vm_offset_t next_read;      /* vaddr of the next sequential read */
     113    vm_size_t adj_free;     /* amount of adjacent free space */
     114    vm_size_t max_free;     /* max free space in subtree */
     115    union vm_map_object object; /* object I point to */
     116    vm_ooffset_t offset;        /* offset into object */
     117    vm_eflags_t eflags;     /* map entry flags */
     118    vm_prot_t protection;       /* protection code */
     119    vm_prot_t max_protection;   /* maximum protection */
     120    vm_inherit_t inheritance;   /* inheritance */
     121    uint8_t read_ahead;     /* pages in the read-ahead window */
     122    int wired_count;        /* can be paged if = 0 */
     123    struct ucred *cred;     /* tmp storage for creator ref */
     124    struct thread *wiring_thread;
     125};
     126
     127#define MAP_ENTRY_NOSYNC        0x0001
     128#define MAP_ENTRY_IS_SUB_MAP        0x0002
     129#define MAP_ENTRY_COW           0x0004
     130#define MAP_ENTRY_NEEDS_COPY        0x0008
     131#define MAP_ENTRY_NOFAULT       0x0010
     132#define MAP_ENTRY_USER_WIRED        0x0020
     133
     134#define MAP_ENTRY_BEHAV_NORMAL      0x0000  /* default behavior */
     135#define MAP_ENTRY_BEHAV_SEQUENTIAL  0x0040  /* expect sequential access */
     136#define MAP_ENTRY_BEHAV_RANDOM      0x0080  /* expect random access */
     137#define MAP_ENTRY_BEHAV_RESERVED    0x00C0  /* future use */
     138
     139#define MAP_ENTRY_BEHAV_MASK        0x00C0
     140
     141#define MAP_ENTRY_IN_TRANSITION     0x0100  /* entry being changed */
     142#define MAP_ENTRY_NEEDS_WAKEUP      0x0200  /* waiters in transition */
     143#define MAP_ENTRY_NOCOREDUMP        0x0400  /* don't include in a core */
     144
     145#define MAP_ENTRY_GROWS_DOWN        0x1000  /* Top-down stacks */
     146#define MAP_ENTRY_GROWS_UP      0x2000  /* Bottom-up stacks */
     147
     148#define MAP_ENTRY_WIRE_SKIPPED      0x4000
     149#define MAP_ENTRY_VN_WRITECNT       0x8000  /* writeable vnode mapping */
     150
     151// #ifdef   _KERNEL
     152static __inline u_char
     153vm_map_entry_behavior(vm_map_entry_t entry)
     154{
     155    return (entry->eflags & MAP_ENTRY_BEHAV_MASK);
     156}
     157
     158static __inline int
     159vm_map_entry_user_wired_count(vm_map_entry_t entry)
     160{
     161    if (entry->eflags & MAP_ENTRY_USER_WIRED)
     162        return (1);
     163    return (0);
     164}
     165
     166static __inline int
     167vm_map_entry_system_wired_count(vm_map_entry_t entry)
     168{
     169    return (entry->wired_count - vm_map_entry_user_wired_count(entry));
     170}
     171// #endif   /* _KERNEL */
     172
     173/*
     174 *  A map is a set of map entries.  These map entries are
     175 *  organized both as a binary search tree and as a doubly-linked
     176 *  list.  Both structures are ordered based upon the start and
     177 *  end addresses contained within each map entry.  Sleator and
     178 *  Tarjan's top-down splay algorithm is employed to control
     179 *  height imbalance in the binary search tree.
     180 *
     181 * List of locks
     182 *  (c) const until freed
     183 */
     184struct vm_map {
     185    struct vm_map_entry header; /* List of entries */
     186    mutex lock;         /* Lock for map data */
     187    struct mtx system_mtx;
     188    int nentries;           /* Number of entries */
     189    vm_size_t size;         /* virtual size */
     190    u_int timestamp;        /* Version number */
     191    u_char needs_wakeup;
     192    u_char system_map;      /* (c) Am I a system map? */
     193    vm_flags_t flags;       /* flags for this vm_map */
     194    vm_map_entry_t root;        /* Root of a binary search tree */
     195    pmap_t pmap;            /* (c) Physical map */
     196#define min_offset  header.start    /* (c) */
     197#define max_offset  header.end  /* (c) */
     198    int busy;
     199};
     200
     201/*
     202 * vm_flags_t values
     203 */
     204#define MAP_WIREFUTURE      0x01    /* wire all future pages */
     205#define MAP_BUSY_WAKEUP     0x02
     206
     207// #ifdef   _KERNEL
     208static __inline vm_offset_t
     209vm_map_max(const struct vm_map *map)
     210{
     211    return (map->max_offset);
     212}
     213
     214static __inline vm_offset_t
     215vm_map_min(const struct vm_map *map)
     216{
     217    return (map->min_offset);
     218}
     219
     220static __inline pmap_t
     221vm_map_pmap(vm_map_t map)
     222{
     223    return (map->pmap);
     224}
     225
     226static __inline void
     227vm_map_modflags(vm_map_t map, vm_flags_t set, vm_flags_t clear)
     228{
     229    map->flags = (map->flags | set) & ~clear;
     230}
     231// #endif   /* _KERNEL */
     232
     233/*
     234 * Shareable process virtual address space.
     235 *
     236 * List of locks
     237 *  (c) const until freed
     238 */
     239struct vmspace {
     240    struct vm_map vm_map;   /* VM address map */
     241    struct shmmap_state *vm_shm;    /* SYS5 shared memory private data XXX */
     242    segsz_t vm_swrss;   /* resident set size before last swap */
     243    segsz_t vm_tsize;   /* text size (pages) XXX */
     244    segsz_t vm_dsize;   /* data size (pages) XXX */
     245    segsz_t vm_ssize;   /* stack size (pages) */
     246    caddr_t vm_taddr;   /* (c) user virtual address of text */
     247    caddr_t vm_daddr;   /* (c) user virtual address of data */
     248    caddr_t vm_maxsaddr;    /* user VA at max stack growth */
     249    volatile int vm_refcnt; /* number of references */
     250};
     251
     252// #endif   /* _KERNEL */
     253
     254// #ifdef   _KERNEL
     255/*
     256 *  Macros:     vm_map_lock, etc.
     257 *  Function:
     258 *      Perform locking on the data portion of a map.  Note that
     259 *      these macros mimic procedure calls returning void.  The
     260 *      semicolon is supplied by the user of these macros, not
     261 *      by the macros themselves.  The macros can safely be used
     262 *      as unbraced elements in a higher level statement.
     263 */
     264
     265void _vm_map_lock(vm_map_t map, const char *file, int line);
     266void _vm_map_unlock(vm_map_t map, const char *file, int line);
     267int _vm_map_unlock_and_wait(vm_map_t map, int timo, const char *file, int line);
     268void _vm_map_lock_read(vm_map_t map, const char *file, int line);
     269void _vm_map_unlock_read(vm_map_t map, const char *file, int line);
     270int _vm_map_trylock(vm_map_t map, const char *file, int line);
     271int _vm_map_trylock_read(vm_map_t map, const char *file, int line);
     272int _vm_map_lock_upgrade(vm_map_t map, const char *file, int line);
     273void _vm_map_lock_downgrade(vm_map_t map, const char *file, int line);
     274int vm_map_locked(vm_map_t map);
     275void vm_map_wakeup(vm_map_t map);
     276void vm_map_busy(vm_map_t map);
     277void vm_map_unbusy(vm_map_t map);
     278void vm_map_wait_busy(vm_map_t map);
     279
     280#define vm_map_lock(map)    _vm_map_lock(map, LOCK_FILE, LOCK_LINE)
     281#define vm_map_unlock(map)  _vm_map_unlock(map, LOCK_FILE, LOCK_LINE)
     282#define vm_map_unlock_and_wait(map, timo)   \
     283            _vm_map_unlock_and_wait(map, timo, LOCK_FILE, LOCK_LINE)
     284#define vm_map_lock_read(map)   _vm_map_lock_read(map, LOCK_FILE, LOCK_LINE)
     285#define vm_map_unlock_read(map) _vm_map_unlock_read(map, LOCK_FILE, LOCK_LINE)
     286#define vm_map_trylock(map) _vm_map_trylock(map, LOCK_FILE, LOCK_LINE)
     287#define vm_map_trylock_read(map)    \
     288            _vm_map_trylock_read(map, LOCK_FILE, LOCK_LINE)
     289#define vm_map_lock_upgrade(map)    \
     290            _vm_map_lock_upgrade(map, LOCK_FILE, LOCK_LINE)
     291#define vm_map_lock_downgrade(map)  \
     292            _vm_map_lock_downgrade(map, LOCK_FILE, LOCK_LINE)
     293
     294long vmspace_resident_count(struct vmspace *vmspace);
     295// #endif   /* _KERNEL */
     296
     297
     298/* XXX: number of kernel maps to statically allocate */
     299#define MAX_KMAP    10
     300
     301/*
     302 * Copy-on-write flags for vm_map operations
     303 */
     304#define MAP_INHERIT_SHARE   0x0001
     305#define MAP_COPY_ON_WRITE   0x0002
     306#define MAP_NOFAULT     0x0004
     307#define MAP_PREFAULT        0x0008
     308#define MAP_PREFAULT_PARTIAL    0x0010
     309#define MAP_DISABLE_SYNCER  0x0020
     310#define MAP_CHECK_EXCL      0x0040
     311#define MAP_DISABLE_COREDUMP    0x0100
     312#define MAP_PREFAULT_MADVISE    0x0200  /* from (user) madvise request */
     313#define MAP_VN_WRITECOUNT   0x0400
     314#define MAP_STACK_GROWS_DOWN    0x1000
     315#define MAP_STACK_GROWS_UP  0x2000
     316#define MAP_ACC_CHARGED     0x4000
     317#define MAP_ACC_NO_CHARGE   0x8000
     318
     319/*
     320 * vm_fault option flags
     321 */
     322#define VM_FAULT_NORMAL 0       /* Nothing special */
     323#define VM_FAULT_WIRE   1       /* Wire the mapped page */
     324#define VM_FAULT_DIRTY  2       /* Dirty the page; use w/VM_PROT_COPY */
     325
     326/*
     327 * Initially, mappings are slightly sequential.  The maximum window size must
     328 * account for the map entry's "read_ahead" field being defined as an uint8_t.
     329 */
     330#define VM_FAULT_READ_AHEAD_MIN     7
     331#define VM_FAULT_READ_AHEAD_INIT    15
     332#define VM_FAULT_READ_AHEAD_MAX     min(atop(MAXPHYS) - 1, UINT8_MAX)
     333
     334/*
     335 * The following "find_space" options are supported by vm_map_find().
     336 *
     337 * For VMFS_ALIGNED_SPACE, the desired alignment is specified to
     338 * the macro argument as log base 2 of the desired alignment.
     339 */
     340#define VMFS_NO_SPACE       0   /* don't find; use the given range */
     341#define VMFS_ANY_SPACE      1   /* find a range with any alignment */
     342#define VMFS_OPTIMAL_SPACE  2   /* find a range with optimal alignment*/
     343#define VMFS_SUPER_SPACE    3   /* find a superpage-aligned range */
     344#define VMFS_ALIGNED_SPACE(x)   ((x) << 8) /* find a range with fixed alignment */
     345
     346/*
     347 * vm_map_wire and vm_map_unwire option flags
     348 */
     349#define VM_MAP_WIRE_SYSTEM  0   /* wiring in a kernel map */
     350#define VM_MAP_WIRE_USER    1   /* wiring in a user map */
     351
     352#define VM_MAP_WIRE_NOHOLES 0   /* region must not have holes */
     353#define VM_MAP_WIRE_HOLESOK 2   /* region may have holes */
     354
     355#define VM_MAP_WIRE_WRITE   4   /* Validate writable. */
     356
     357// #ifdef _KERNEL
     358boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t);
     359vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t);
     360int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t);
     361int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t,
     362    vm_offset_t, int, vm_prot_t, vm_prot_t, int);
     363int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t,
     364    vm_prot_t, vm_prot_t, int);
     365int vm_map_findspace (vm_map_t, vm_offset_t, vm_size_t, vm_offset_t *);
     366int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);
     367void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t);
     368int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int);
     369int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
     370    vm_pindex_t *, vm_prot_t *, boolean_t *);
     371int vm_map_lookup_locked(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
     372    vm_pindex_t *, vm_prot_t *, boolean_t *);
     373void vm_map_lookup_done (vm_map_t, vm_map_entry_t);
     374boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *);
     375int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t);
     376int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t);
     377void vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry);
     378void vm_map_startup (void);
     379int vm_map_submap (vm_map_t, vm_offset_t, vm_offset_t, vm_map_t);
     380int vm_map_sync(vm_map_t, vm_offset_t, vm_offset_t, boolean_t, boolean_t);
     381int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t, int);
     382int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int);
     383int vm_map_growstack (struct proc *p, vm_offset_t addr);
     384int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
     385    int flags);
     386int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
     387    int flags);
     388long vmspace_swap_count(struct vmspace *vmspace);
     389// #endif               /* _KERNEL */
     390#endif              /* _FBSD_COMPAT_VM_MAP_ */
  • new file headers/compatibility/freebsd/vm/vm_object.h

    diff --git a/headers/compatibility/freebsd/vm/vm_object.h b/headers/compatibility/freebsd/vm/vm_object.h
    new file mode 100644
    index 0000000000..f63a894a03
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * This code is derived from software contributed to Berkeley by
     6 * The Mach Operating System project at Carnegie-Mellon University.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice, this list of conditions and the following disclaimer.
     13 * 2. Redistributions in binary form must reproduce the above copyright
     14 *    notice, this list of conditions and the following disclaimer in the
     15 *    documentation and/or other materials provided with the distribution.
     16 * 3. Neither the name of the University nor the names of its contributors
     17 *    may be used to endorse or promote products derived from this software
     18 *    without specific prior written permission.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30 * SUCH DAMAGE.
     31 *
     32 *  from: @(#)vm_object.h   8.3 (Berkeley) 1/12/94
     33 *
     34 *
     35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     36 * All rights reserved.
     37 *
     38 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
     39 *
     40 * Permission to use, copy, modify and distribute this software and
     41 * its documentation is hereby granted, provided that both the copyright
     42 * notice and this permission notice appear in all copies of the
     43 * software, derivative works or modified versions, and any portions
     44 * thereof, and that both notices appear in supporting documentation.
     45 *
     46 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     47 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     48 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     49 *
     50 * Carnegie Mellon requests users of this software to return to
     51 *
     52 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
     53 *  School of Computer Science
     54 *  Carnegie Mellon University
     55 *  Pittsburgh PA 15213-3890
     56 *
     57 * any improvements or extensions that they make and grant Carnegie the
     58 * rights to redistribute these changes.
     59 *
     60 * $FreeBSD$
     61 */
     62
     63/*
     64 *  Virtual memory object module definitions.
     65 */
     66
     67#ifndef _FBSD_COMPAT_VM_VM_OBJECT_
     68#define _FBSD_COMPAT_VM_VM_OBJECT_
     69
     70// #include <sys/queue.h>
     71// #include <sys/_lock.h>
     72// #include <sys/_mutex.h>
     73// #include <sys/_rwlock.h>
     74
     75// #include <vm/_vm_radix.h>
     76
     77#include <lock.h>
     78#include <freebsd/sys/queue.h>
     79#include <freebsd/sys/types.h>
     80#include <freebsd/vm/vm.h>
     81#include <freebsd/vm/_vm_radix.h>
     82
     83/*
     84 *  Types defined:
     85 *
     86 *  vm_object_t     Virtual memory object.
     87 *
     88 * List of locks
     89 *  (c) const until freed
     90 *  (o) per-object lock
     91 *  (f) free pages queue mutex
     92 *
     93 */
     94
     95struct vm_object {
     96    rw_lock lock;
     97    TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
     98    LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
     99    LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
     100    TAILQ_HEAD(respgs, vm_page) memq; /* list of resident pages */
     101    struct vm_radix rtree;      /* root of the resident page radix trie*/
     102    vm_pindex_t size;       /* Object size */
     103    int generation;         /* generation ID */
     104    int ref_count;          /* How many refs?? */
     105    int shadow_count;       /* how many objects that this is a shadow for */
     106    vm_memattr_t memattr;       /* default memory attribute for pages */
     107    objtype_t type;         /* type of pager */
     108    u_short flags;          /* see below */
     109    u_short pg_color;       /* (c) color of first page in obj */
     110    u_int paging_in_progress;   /* Paging (in or out) so don't collapse or destroy */
     111    int resident_page_count;    /* number of resident pages */
     112    struct vm_object *backing_object; /* object that I'm a shadow of */
     113    vm_ooffset_t backing_object_offset;/* Offset in backing object */
     114    TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of this pager type */
     115    LIST_HEAD(, vm_reserv) rvq; /* list of reservations */
     116    void *handle;
     117    union {
     118        /*
     119         * VNode pager
     120         *
     121         *  vnp_size - current size of file
     122         */
     123        struct {
     124            off_t vnp_size;
     125            vm_ooffset_t writemappings;
     126        } vnp;
     127
     128        /*
     129         * Device pager
     130         *
     131         *  devp_pglist - list of allocated pages
     132         */
     133        struct {
     134            TAILQ_HEAD(, vm_page) devp_pglist;
     135            struct cdev_pager_ops *ops;
     136            struct cdev *dev;
     137        } devp;
     138
     139        /*
     140         * SG pager
     141         *
     142         *  sgp_pglist - list of allocated pages
     143         */
     144        struct {
     145            TAILQ_HEAD(, vm_page) sgp_pglist;
     146        } sgp;
     147
     148        /*
     149         * Swap pager
     150         *
     151         *  swp_tmpfs - back-pointer to the tmpfs vnode,
     152         *           if any, which uses the vm object
     153         *           as backing store.  The handle
     154         *           cannot be reused for linking,
     155         *           because the vnode can be
     156         *           reclaimed and recreated, making
     157         *           the handle changed and hash-chain
     158         *           invalid.
     159         *
     160         *  swp_bcount - number of swap 'swblock' metablocks, each
     161         *           contains up to 16 swapblk assignments.
     162         *           see vm/swap_pager.h
     163         */
     164        struct {
     165            void *swp_tmpfs;
     166            int swp_bcount;
     167        } swp;
     168    } un_pager;
     169    struct ucred *cred;
     170    vm_ooffset_t charge;
     171    void *umtx_data;
     172};
     173
     174/*
     175 * Flags
     176 */
     177#define OBJ_FICTITIOUS  0x0001      /* (c) contains fictitious pages */
     178#define OBJ_UNMANAGED   0x0002      /* (c) contains unmanaged pages */
     179#define OBJ_POPULATE    0x0004      /* pager implements populate() */
     180#define OBJ_DEAD    0x0008      /* dead objects (during rundown) */
     181#define OBJ_NOSPLIT 0x0010      /* dont split this object */
     182#define OBJ_UMTXDEAD    0x0020      /* umtx pshared was terminated */
     183#define OBJ_PIPWNT  0x0040      /* paging in progress wanted */
     184#define OBJ_MIGHTBEDIRTY 0x0100     /* object might be dirty, only for vnode */
     185#define OBJ_TMPFS_NODE  0x0200      /* object belongs to tmpfs VREG node */
     186#define OBJ_TMPFS_DIRTY 0x0400      /* dirty tmpfs obj */
     187#define OBJ_COLORED 0x1000      /* pg_color is defined */
     188#define OBJ_ONEMAPPING  0x2000      /* One USE (a single, non-forked) mapping flag */
     189#define OBJ_DISCONNECTWNT 0x4000    /* disconnect from vnode wanted */
     190#define OBJ_TMPFS   0x8000      /* has tmpfs vnode allocated */
     191
     192/*
     193 * Helpers to perform conversion between vm_object page indexes and offsets.
     194 * IDX_TO_OFF() converts an index into an offset.
     195 * OFF_TO_IDX() converts an offset into an index.  Since offsets are signed
     196 *   by default, the sign propagation in OFF_TO_IDX(), when applied to
     197 *   negative offsets, is intentional and returns a vm_object page index
     198 *   that cannot be created by a userspace mapping.
     199 * UOFF_TO_IDX() treats the offset as an unsigned value and converts it
     200 *   into an index accordingly.  Use it only when the full range of offset
     201 *   values are allowed.  Currently, this only applies to device mappings.
     202 * OBJ_MAX_SIZE specifies the maximum page index corresponding to the
     203 *   maximum unsigned offset.
     204 */
     205#define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
     206#define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
     207#define UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT)
     208#define OBJ_MAX_SIZE    (UOFF_TO_IDX(UINT64_MAX) + 1)
     209
     210#ifdef  _KERNEL
     211
     212#define OBJPC_SYNC  0x1         /* sync I/O */
     213#define OBJPC_INVAL 0x2         /* invalidate */
     214#define OBJPC_NOSYNC    0x4         /* skip if VPO_NOSYNC */
     215
     216/*
     217 * The following options are supported by vm_object_page_remove().
     218 */
     219#define OBJPR_CLEANONLY 0x1     /* Don't remove dirty pages. */
     220#define OBJPR_NOTMAPPED 0x2     /* Don't unmap pages. */
     221
     222TAILQ_HEAD(object_q, vm_object);
     223
     224extern struct object_q vm_object_list;  /* list of allocated objects */
     225extern struct mtx vm_object_list_mtx;   /* lock for object list and count */
     226
     227extern struct vm_object kernel_object_store;
     228extern struct vm_object kmem_object_store;
     229
     230#define kernel_object   (&kernel_object_store)
     231#define kmem_object (&kmem_object_store)
     232
     233#define VM_OBJECT_ASSERT_LOCKED(object)                 \
     234    rw_assert(&(object)->lock, RA_LOCKED)
     235#define VM_OBJECT_ASSERT_RLOCKED(object)                \
     236    rw_assert(&(object)->lock, RA_RLOCKED)
     237#define VM_OBJECT_ASSERT_WLOCKED(object)                \
     238    rw_assert(&(object)->lock, RA_WLOCKED)
     239#define VM_OBJECT_ASSERT_UNLOCKED(object)               \
     240    rw_assert(&(object)->lock, RA_UNLOCKED)
     241#define VM_OBJECT_LOCK_DOWNGRADE(object)                \
     242    rw_downgrade(&(object)->lock)
     243#define VM_OBJECT_RLOCK(object)                     \
     244    rw_rlock(&(object)->lock)
     245#define VM_OBJECT_RUNLOCK(object)                   \
     246    rw_runlock(&(object)->lock)
     247#define VM_OBJECT_SLEEP(object, wchan, pri, wmesg, timo)        \
     248    rw_sleep((wchan), &(object)->lock, (pri), (wmesg), (timo))
     249#define VM_OBJECT_TRYRLOCK(object)                  \
     250    rw_try_rlock(&(object)->lock)
     251#define VM_OBJECT_TRYWLOCK(object)                  \
     252    rw_try_wlock(&(object)->lock)
     253#define VM_OBJECT_TRYUPGRADE(object)                    \
     254    rw_try_upgrade(&(object)->lock)
     255#define VM_OBJECT_WLOCK(object)                     \
     256    rw_wlock(&(object)->lock)
     257#define VM_OBJECT_WOWNED(object)                    \
     258    rw_wowned(&(object)->lock)
     259#define VM_OBJECT_WUNLOCK(object)                   \
     260    rw_wunlock(&(object)->lock)
     261
     262/*
     263 *  The object must be locked or thread private.
     264 */
     265static __inline void
     266vm_object_set_flag(vm_object_t object, u_short bits)
     267{
     268
     269    object->flags |= bits;
     270}
     271
     272/*
     273 *  Conditionally set the object's color, which (1) enables the allocation
     274 *  of physical memory reservations for anonymous objects and larger-than-
     275 *  superpage-sized named objects and (2) determines the first page offset
     276 *  within the object at which a reservation may be allocated.  In other
     277 *  words, the color determines the alignment of the object with respect
     278 *  to the largest superpage boundary.  When mapping named objects, like
     279 *  files or POSIX shared memory objects, the color should be set to zero
     280 *  before a virtual address is selected for the mapping.  In contrast,
     281 *  for anonymous objects, the color may be set after the virtual address
     282 *  is selected.
     283 *
     284 *  The object must be locked.
     285 */
     286static __inline void
     287vm_object_color(vm_object_t object, u_short color)
     288{
     289
     290    if ((object->flags & OBJ_COLORED) == 0) {
     291        object->pg_color = color;
     292        object->flags |= OBJ_COLORED;
     293    }
     294}
     295
     296void vm_object_clear_flag(vm_object_t object, u_short bits);
     297void vm_object_pip_add(vm_object_t object, short i);
     298void vm_object_pip_subtract(vm_object_t object, short i);
     299void vm_object_pip_wakeup(vm_object_t object);
     300void vm_object_pip_wakeupn(vm_object_t object, short i);
     301void vm_object_pip_wait(vm_object_t object, char *waitid);
     302
     303void umtx_shm_object_init(vm_object_t object);
     304void umtx_shm_object_terminated(vm_object_t object);
     305extern int umtx_shm_vnobj_persistent;
     306
     307vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
     308boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t,
     309   boolean_t);
     310void vm_object_collapse (vm_object_t);
     311void vm_object_deallocate (vm_object_t);
     312void vm_object_destroy (vm_object_t);
     313void vm_object_terminate (vm_object_t);
     314void vm_object_set_writeable_dirty (vm_object_t);
     315void vm_object_init (void);
     316void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
     317boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
     318    vm_ooffset_t end, int flags);
     319void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
     320    vm_pindex_t end);
     321void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
     322    vm_pindex_t end, int options);
     323boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);
     324void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
     325void vm_object_reference (vm_object_t);
     326void vm_object_reference_locked(vm_object_t);
     327int  vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr);
     328void vm_object_shadow (vm_object_t *, vm_ooffset_t *, vm_size_t);
     329void vm_object_split(vm_map_entry_t);
     330boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t,
     331    boolean_t);
     332void vm_object_unwire(vm_object_t object, vm_ooffset_t offset,
     333    vm_size_t length, uint8_t queue);
     334struct vnode *vm_object_vnode(vm_object_t object);
     335#endif              /* _KERNEL */
     336
     337#endif              /* _FBSD_COMPAT_VM_VM_OBJECT_ */
     338/*-
     339 * Copyright (c) 1991, 1993
     340 *  The Regents of the University of California.  All rights reserved.
     341 *
     342 * This code is derived from software contributed to Berkeley by
     343 * The Mach Operating System project at Carnegie-Mellon University.
     344 *
     345 * Redistribution and use in source and binary forms, with or without
     346 * modification, are permitted provided that the following conditions
     347 * are met:
     348 * 1. Redistributions of source code must retain the above copyright
     349 *    notice, this list of conditions and the following disclaimer.
     350 * 2. Redistributions in binary form must reproduce the above copyright
     351 *    notice, this list of conditions and the following disclaimer in the
     352 *    documentation and/or other materials provided with the distribution.
     353 * 3. Neither the name of the University nor the names of its contributors
     354 *    may be used to endorse or promote products derived from this software
     355 *    without specific prior written permission.
     356 *
     357 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     358 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     359 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     360 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     361 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     362 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     363 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     364 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     365 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     366 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     367 * SUCH DAMAGE.
     368 *
     369 *  from: @(#)vm_object.h   8.3 (Berkeley) 1/12/94
     370 *
     371 *
     372 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     373 * All rights reserved.
     374 *
     375 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
     376 *
     377 * Permission to use, copy, modify and distribute this software and
     378 * its documentation is hereby granted, provided that both the copyright
     379 * notice and this permission notice appear in all copies of the
     380 * software, derivative works or modified versions, and any portions
     381 * thereof, and that both notices appear in supporting documentation.
     382 *
     383 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     384 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     385 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     386 *
     387 * Carnegie Mellon requests users of this software to return to
     388 *
     389 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
     390 *  School of Computer Science
     391 *  Carnegie Mellon University
     392 *  Pittsburgh PA 15213-3890
     393 *
     394 * any improvements or extensions that they make and grant Carnegie the
     395 * rights to redistribute these changes.
     396 *
     397 * $FreeBSD$
     398 */
     399
     400/*
     401 *  Virtual memory object module definitions.
     402 */
     403
     404#ifndef _FBSD_COMPAT_VM_VM_OBJECT_
     405#define _FBSD_COMPAT_VM_VM_OBJECT_
     406
     407// #include <sys/queue.h>
     408// #include <sys/_lock.h>
     409// #include <sys/_mutex.h>
     410// #include <sys/_rwlock.h>
     411
     412// #include <vm/_vm_radix.h>
     413
     414/*
     415 *  Types defined:
     416 *
     417 *  vm_object_t     Virtual memory object.
     418 *
     419 * List of locks
     420 *  (c) const until freed
     421 *  (o) per-object lock
     422 *  (f) free pages queue mutex
     423 *
     424 */
     425
     426struct vm_object {
     427    struct rwlock lock;
     428    TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
     429    LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
     430    LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
     431    TAILQ_HEAD(respgs, vm_page) memq; /* list of resident pages */
     432    struct vm_radix rtree;      /* root of the resident page radix trie*/
     433    vm_pindex_t size;       /* Object size */
     434    int generation;         /* generation ID */
     435    int ref_count;          /* How many refs?? */
     436    int shadow_count;       /* how many objects that this is a shadow for */
     437    vm_memattr_t memattr;       /* default memory attribute for pages */
     438    objtype_t type;         /* type of pager */
     439    u_short flags;          /* see below */
     440    u_short pg_color;       /* (c) color of first page in obj */
     441    u_int paging_in_progress;   /* Paging (in or out) so don't collapse or destroy */
     442    int resident_page_count;    /* number of resident pages */
     443    struct vm_object *backing_object; /* object that I'm a shadow of */
     444    vm_ooffset_t backing_object_offset;/* Offset in backing object */
     445    TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of this pager type */
     446    LIST_HEAD(, vm_reserv) rvq; /* list of reservations */
     447    void *handle;
     448    union {
     449        /*
     450         * VNode pager
     451         *
     452         *  vnp_size - current size of file
     453         */
     454        struct {
     455            off_t vnp_size;
     456            vm_ooffset_t writemappings;
     457        } vnp;
     458
     459        /*
     460         * Device pager
     461         *
     462         *  devp_pglist - list of allocated pages
     463         */
     464        struct {
     465            TAILQ_HEAD(, vm_page) devp_pglist;
     466            struct cdev_pager_ops *ops;
     467            struct cdev *dev;
     468        } devp;
     469
     470        /*
     471         * SG pager
     472         *
     473         *  sgp_pglist - list of allocated pages
     474         */
     475        struct {
     476            TAILQ_HEAD(, vm_page) sgp_pglist;
     477        } sgp;
     478
     479        /*
     480         * Swap pager
     481         *
     482         *  swp_tmpfs - back-pointer to the tmpfs vnode,
     483         *           if any, which uses the vm object
     484         *           as backing store.  The handle
     485         *           cannot be reused for linking,
     486         *           because the vnode can be
     487         *           reclaimed and recreated, making
     488         *           the handle changed and hash-chain
     489         *           invalid.
     490         *
     491         *  swp_bcount - number of swap 'swblock' metablocks, each
     492         *           contains up to 16 swapblk assignments.
     493         *           see vm/swap_pager.h
     494         */
     495        struct {
     496            void *swp_tmpfs;
     497            int swp_bcount;
     498        } swp;
     499    } un_pager;
     500    struct ucred *cred;
     501    vm_ooffset_t charge;
     502    void *umtx_data;
     503};
     504
     505/*
     506 * Flags
     507 */
     508#define OBJ_FICTITIOUS  0x0001      /* (c) contains fictitious pages */
     509#define OBJ_UNMANAGED   0x0002      /* (c) contains unmanaged pages */
     510#define OBJ_POPULATE    0x0004      /* pager implements populate() */
     511#define OBJ_DEAD    0x0008      /* dead objects (during rundown) */
     512#define OBJ_NOSPLIT 0x0010      /* dont split this object */
     513#define OBJ_UMTXDEAD    0x0020      /* umtx pshared was terminated */
     514#define OBJ_PIPWNT  0x0040      /* paging in progress wanted */
     515#define OBJ_MIGHTBEDIRTY 0x0100     /* object might be dirty, only for vnode */
     516#define OBJ_TMPFS_NODE  0x0200      /* object belongs to tmpfs VREG node */
     517#define OBJ_TMPFS_DIRTY 0x0400      /* dirty tmpfs obj */
     518#define OBJ_COLORED 0x1000      /* pg_color is defined */
     519#define OBJ_ONEMAPPING  0x2000      /* One USE (a single, non-forked) mapping flag */
     520#define OBJ_DISCONNECTWNT 0x4000    /* disconnect from vnode wanted */
     521#define OBJ_TMPFS   0x8000      /* has tmpfs vnode allocated */
     522
     523/*
     524 * Helpers to perform conversion between vm_object page indexes and offsets.
     525 * IDX_TO_OFF() converts an index into an offset.
     526 * OFF_TO_IDX() converts an offset into an index.  Since offsets are signed
     527 *   by default, the sign propagation in OFF_TO_IDX(), when applied to
     528 *   negative offsets, is intentional and returns a vm_object page index
     529 *   that cannot be created by a userspace mapping.
     530 * UOFF_TO_IDX() treats the offset as an unsigned value and converts it
     531 *   into an index accordingly.  Use it only when the full range of offset
     532 *   values are allowed.  Currently, this only applies to device mappings.
     533 * OBJ_MAX_SIZE specifies the maximum page index corresponding to the
     534 *   maximum unsigned offset.
     535 */
     536#define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
     537#define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
     538#define UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT)
     539#define OBJ_MAX_SIZE    (UOFF_TO_IDX(UINT64_MAX) + 1)
     540
     541#ifdef  _KERNEL
     542
     543#define OBJPC_SYNC  0x1         /* sync I/O */
     544#define OBJPC_INVAL 0x2         /* invalidate */
     545#define OBJPC_NOSYNC    0x4         /* skip if VPO_NOSYNC */
     546
     547/*
     548 * The following options are supported by vm_object_page_remove().
     549 */
     550#define OBJPR_CLEANONLY 0x1     /* Don't remove dirty pages. */
     551#define OBJPR_NOTMAPPED 0x2     /* Don't unmap pages. */
     552
     553TAILQ_HEAD(object_q, vm_object);
     554
     555extern struct object_q vm_object_list;  /* list of allocated objects */
     556extern struct mtx vm_object_list_mtx;   /* lock for object list and count */
     557
     558extern struct vm_object kernel_object_store;
     559extern struct vm_object kmem_object_store;
     560
     561#define kernel_object   (&kernel_object_store)
     562#define kmem_object (&kmem_object_store)
     563
     564#define VM_OBJECT_ASSERT_LOCKED(object)                 \
     565    rw_assert(&(object)->lock, RA_LOCKED)
     566#define VM_OBJECT_ASSERT_RLOCKED(object)                \
     567    rw_assert(&(object)->lock, RA_RLOCKED)
     568#define VM_OBJECT_ASSERT_WLOCKED(object)                \
     569    rw_assert(&(object)->lock, RA_WLOCKED)
     570#define VM_OBJECT_ASSERT_UNLOCKED(object)               \
     571    rw_assert(&(object)->lock, RA_UNLOCKED)
     572#define VM_OBJECT_LOCK_DOWNGRADE(object)                \
     573    rw_downgrade(&(object)->lock)
     574#define VM_OBJECT_RLOCK(object)                     \
     575    rw_rlock(&(object)->lock)
     576#define VM_OBJECT_RUNLOCK(object)                   \
     577    rw_runlock(&(object)->lock)
     578#define VM_OBJECT_SLEEP(object, wchan, pri, wmesg, timo)        \
     579    rw_sleep((wchan), &(object)->lock, (pri), (wmesg), (timo))
     580#define VM_OBJECT_TRYRLOCK(object)                  \
     581    rw_try_rlock(&(object)->lock)
     582#define VM_OBJECT_TRYWLOCK(object)                  \
     583    rw_try_wlock(&(object)->lock)
     584#define VM_OBJECT_TRYUPGRADE(object)                    \
     585    rw_try_upgrade(&(object)->lock)
     586#define VM_OBJECT_WLOCK(object)                     \
     587    rw_wlock(&(object)->lock)
     588#define VM_OBJECT_WOWNED(object)                    \
     589    rw_wowned(&(object)->lock)
     590#define VM_OBJECT_WUNLOCK(object)                   \
     591    rw_wunlock(&(object)->lock)
     592
     593/*
     594 *  The object must be locked or thread private.
     595 */
     596static __inline void
     597vm_object_set_flag(vm_object_t object, u_short bits)
     598{
     599
     600    object->flags |= bits;
     601}
     602
     603/*
     604 *  Conditionally set the object's color, which (1) enables the allocation
     605 *  of physical memory reservations for anonymous objects and larger-than-
     606 *  superpage-sized named objects and (2) determines the first page offset
     607 *  within the object at which a reservation may be allocated.  In other
     608 *  words, the color determines the alignment of the object with respect
     609 *  to the largest superpage boundary.  When mapping named objects, like
     610 *  files or POSIX shared memory objects, the color should be set to zero
     611 *  before a virtual address is selected for the mapping.  In contrast,
     612 *  for anonymous objects, the color may be set after the virtual address
     613 *  is selected.
     614 *
     615 *  The object must be locked.
     616 */
     617static __inline void
     618vm_object_color(vm_object_t object, u_short color)
     619{
     620
     621    if ((object->flags & OBJ_COLORED) == 0) {
     622        object->pg_color = color;
     623        object->flags |= OBJ_COLORED;
     624    }
     625}
     626
     627void vm_object_clear_flag(vm_object_t object, u_short bits);
     628void vm_object_pip_add(vm_object_t object, short i);
     629void vm_object_pip_subtract(vm_object_t object, short i);
     630void vm_object_pip_wakeup(vm_object_t object);
     631void vm_object_pip_wakeupn(vm_object_t object, short i);
     632void vm_object_pip_wait(vm_object_t object, char *waitid);
     633
     634void umtx_shm_object_init(vm_object_t object);
     635void umtx_shm_object_terminated(vm_object_t object);
     636extern int umtx_shm_vnobj_persistent;
     637
     638vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
     639boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t,
     640   boolean_t);
     641void vm_object_collapse (vm_object_t);
     642void vm_object_deallocate (vm_object_t);
     643void vm_object_destroy (vm_object_t);
     644void vm_object_terminate (vm_object_t);
     645void vm_object_set_writeable_dirty (vm_object_t);
     646void vm_object_init (void);
     647void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
     648boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
     649    vm_ooffset_t end, int flags);
     650void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
     651    vm_pindex_t end);
     652void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
     653    vm_pindex_t end, int options);
     654boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);
     655void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
     656void vm_object_reference (vm_object_t);
     657void vm_object_reference_locked(vm_object_t);
     658int  vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr);
     659void vm_object_shadow (vm_object_t *, vm_ooffset_t *, vm_size_t);
     660void vm_object_split(vm_map_entry_t);
     661boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t,
     662    boolean_t);
     663void vm_object_unwire(vm_object_t object, vm_ooffset_t offset,
     664    vm_size_t length, uint8_t queue);
     665struct vnode *vm_object_vnode(vm_object_t object);
     666#endif              /* _KERNEL */
     667
     668#endif              /* _FBSD_COMPAT_VM_VM_OBJECT_ */
  • new file headers/compatibility/freebsd/vm/vm_page.h

    diff --git a/headers/compatibility/freebsd/vm/vm_page.h b/headers/compatibility/freebsd/vm/vm_page.h
    new file mode 100644
    index 0000000000..a76697cef5
    - +  
     1#include <freebsd/vm/vm.h>
     2
     3#define PQ_ACTIVE 0x00
     4#define PQ_NONE 0x01
     5
     6#define VM_PAGE_TO_PHYS(p) ((p)->physical_page_number)
     7
     8extern void vm_page_dirty(vm_page_t m);
     9extern void vm_page_reference(vm_page_t m);
     10extern void vm_page_lock(vm_page_t m);
     11extern void vm_page_unlock(vm_page_t m);
     12extern void vm_page_hold(vm_page_t m);
     13extern void vm_page_unhold(vm_page_t m);
     14extern void vm_page_wire(vm_page_t m);
     15extern boolean_t vm_page_unwire(vm_page_t m, uint8_t queue);
     16
     17extern vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t paddr);
  • new file headers/compatibility/linux/agp_backend.h

    diff --git a/headers/compatibility/linux/agp_backend.h b/headers/compatibility/linux/agp_backend.h
    new file mode 100644
    index 0000000000..afb0436cf0
    - +  
     1/*
     2 * AGPGART backend specific includes. Not for userspace consumption.
     3 *
     4 * Copyright (C) 2004 Silicon Graphics, Inc.
     5 * Copyright (C) 2002-2003 Dave Jones
     6 * Copyright (C) 1999 Jeff Hartmann
     7 * Copyright (C) 1999 Precision Insight, Inc.
     8 * Copyright (C) 1999 Xi Graphics, Inc.
     9 *
     10 * Permission is hereby granted, free of charge, to any person obtaining a
     11 * copy of this software and associated documentation files (the "Software"),
     12 * to deal in the Software without restriction, including without limitation
     13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     14 * and/or sell copies of the Software, and to permit persons to whom the
     15 * Software is furnished to do so, subject to the following conditions:
     16 *
     17 * The above copyright notice and this permission notice shall be included
     18 * in all copies or substantial portions of the Software.
     19 *
     20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     23 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
     24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
     26 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     27 *
     28 */
     29
     30#ifndef _LINUX_AGP_BACKEND__H
     31#define _LINUX_AGP_BACKEND_H_
     32
     33#include <linux/list.h>
     34#include <linuxkpi/linux/types.h>
     35
     36enum chipset_type {
     37    NOT_SUPPORTED,
     38    SUPPORTED,
     39};
     40
     41struct agp_version {
     42    u16 major;
     43    u16 minor;
     44};
     45
     46struct agp_kern_info {
     47    struct agp_version version;
     48    struct pci_dev *device;
     49    enum chipset_type chipset;
     50    unsigned long mode;
     51    unsigned long aper_base;
     52    size_t aper_size;
     53    int max_memory;     /* In pages */
     54    int current_memory;
     55    bool cant_use_aperture;
     56    unsigned long page_mask;
     57    const struct vm_operations_struct *vm_ops;
     58};
     59
     60/*
     61 * The agp_memory structure has information about the block of agp memory
     62 * allocated.  A caller may manipulate the next and prev pointers to link
     63 * each allocated item into a list.  These pointers are ignored by the backend.
     64 * Everything else should never be written to, but the caller may read any of
     65 * the items to determine the status of this block of agp memory.
     66 */
     67
     68struct agp_bridge_data;
     69
     70struct agp_memory {
     71    struct agp_memory *next;
     72    struct agp_memory *prev;
     73    struct agp_bridge_data *bridge;
     74    struct page **pages;
     75    size_t page_count;
     76    int key;
     77    int num_scratch_pages;
     78    off_t pg_start;
     79    u32 type;
     80    u32 physical;
     81    bool is_bound;
     82    bool is_flushed;
     83    /* list of agp_memory mapped to the aperture */
     84    struct list_head mapped_list;
     85    /* DMA-mapped addresses */
     86    struct scatterlist *sg_list;
     87    int num_sg;
     88};
     89
     90#define AGP_NORMAL_MEMORY 0
     91
     92#define AGP_USER_TYPES (1 << 16)
     93#define AGP_USER_MEMORY (AGP_USER_TYPES)
     94#define AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)
     95
     96extern struct agp_bridge_data *agp_bridge;
     97extern struct list_head agp_bridges;
     98
     99extern struct agp_bridge_data *(*agp_find_bridge)(struct pci_dev *);
     100
     101extern void agp_free_memory(struct agp_memory *);
     102extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t, u32);
     103extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
     104extern int agp_bind_memory(struct agp_memory *, off_t);
     105extern int agp_unbind_memory(struct agp_memory *);
     106extern void agp_enable(struct agp_bridge_data *, u32);
     107extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
     108extern void agp_backend_release(struct agp_bridge_data *);
     109
     110#endif              /* _LINUX_AGP_BACKEND_H_ */
  • new file headers/compatibility/linux/list.h

    diff --git a/headers/compatibility/linux/list.h b/headers/compatibility/linux/list.h
    new file mode 100644
    index 0000000000..48a720c81b
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_LIST_H_
     32#define _LINUX_LIST_H_
     33
     34/*
     35 * Since LIST_HEAD conflicts with the linux definition we must include any
     36 * FreeBSD header which requires it here so it is resolved with the correct
     37 * definition prior to the undef.
     38 */
     39
     40#include <linuxkpi/linux/compiler.h>
     41#include <stddef.h>
     42
     43#define prefetch(x)
     44
     45#define LINUX_LIST_HEAD_INIT(name) { &(name), &(name) }
     46
     47#define LINUX_LIST_HEAD(name) \
     48    struct list_head name = LINUX_LIST_HEAD_INIT(name)
     49
     50#ifndef LIST_HEAD_DEF
     51#define LIST_HEAD_DEF
     52struct list_head {
     53    struct list_head *next;
     54    struct list_head *prev;
     55};
     56#endif
     57
     58static inline void
     59INIT_LIST_HEAD(struct list_head *list)
     60{
     61
     62    list->next = list->prev = list;
     63}
     64 
     65static inline int
     66list_empty(const struct list_head *head)
     67{
     68
     69    return (head->next == head);
     70}
     71
     72static inline int
     73list_empty_careful(const struct list_head *head)
     74{
     75    struct list_head *next = head->next;
     76
     77    return ((next == head) && (next == head->prev));
     78}
     79
     80static inline void
     81__list_del(struct list_head *prev, struct list_head *next)
     82{
     83    next->prev = prev;
     84    WRITE_ONCE(prev->next, next);
     85}
     86
     87static inline void
     88list_del(struct list_head *entry)
     89{
     90
     91    __list_del(entry->prev, entry->next);
     92}
     93
     94static inline void
     95list_replace(struct list_head *old, struct list_head *new)
     96{
     97    new->next = old->next;
     98    new->next->prev = new;
     99    new->prev = old->prev;
     100    new->prev->next = new;
     101}
     102
     103static inline void
     104list_replace_init(struct list_head *old, struct list_head *new)
     105{
     106    list_replace(old, new);
     107    INIT_LIST_HEAD(old);
     108}
     109
     110static inline void
     111linux_list_add(struct list_head *new, struct list_head *prev,
     112    struct list_head *next)
     113{
     114
     115    next->prev = new;
     116    new->next = next;
     117    new->prev = prev;
     118    prev->next = new;
     119}
     120
     121static inline void
     122list_del_init(struct list_head *entry)
     123{   
     124
     125    list_del(entry);
     126    INIT_LIST_HEAD(entry);
     127}
     128
     129#define list_entry(ptr, type, field)    container_of(ptr, type, field)
     130
     131#define list_first_entry(ptr, type, member) \
     132        list_entry((ptr)->next, type, member)
     133
     134#define list_last_entry(ptr, type, member)  \
     135    list_entry((ptr)->prev, type, member)
     136
     137#define list_first_entry_or_null(ptr, type, member) \
     138    (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
     139
     140#define list_next_entry(ptr, member)                    \
     141    list_entry(((ptr)->member.next), typeof(*(ptr)), member)
     142
     143#define list_prev_entry(ptr, member)                    \
     144    list_entry(((ptr)->member.prev), typeof(*(ptr)), member)
     145
     146#define list_for_each(p, head)                      \
     147    for (p = (head)->next; p != (head); p = (p)->next)
     148
     149#define list_for_each_safe(p, n, head)                  \
     150    for (p = (head)->next, n = (p)->next; p != (head); p = n, n = (p)->next)
     151
     152#define list_for_each_entry(p, h, field)                \
     153    for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \
     154        p = list_entry((p)->field.next, typeof(*p), field))
     155
     156#define list_for_each_entry_safe(p, n, h, field)            \
     157    for (p = list_entry((h)->next, typeof(*p), field),      \
     158        n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\
     159        p = n, n = list_entry(n->field.next, typeof(*n), field))
     160
     161#define list_for_each_entry_from(p, h, field) \
     162    for ( ; &(p)->field != (h); \
     163        p = list_entry((p)->field.next, typeof(*p), field))
     164
     165#define list_for_each_entry_continue(p, h, field)           \
     166    for (p = list_next_entry((p), field); &(p)->field != (h);   \
     167        p = list_next_entry((p), field))
     168
     169#define list_for_each_entry_safe_from(pos, n, head, member)             \
     170    for (n = list_entry((pos)->member.next, typeof(*pos), member);      \
     171         &(pos)->member != (head);                      \
     172         pos = n, n = list_entry(n->member.next, typeof(*n), member))
     173
     174#define list_for_each_entry_reverse(p, h, field)            \
     175    for (p = list_entry((h)->prev, typeof(*p), field); &(p)->field != (h); \
     176        p = list_entry((p)->field.prev, typeof(*p), field))
     177
     178#define list_for_each_entry_safe_reverse(p, n, h, field)        \
     179    for (p = list_entry((h)->prev, typeof(*p), field),      \
     180        n = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
     181        p = n, n = list_entry(n->field.prev, typeof(*n), field))
     182
     183#define list_for_each_entry_continue_reverse(p, h, field) \
     184    for (p = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
     185        p = list_entry((p)->field.prev, typeof(*p), field))
     186
     187#define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = (p)->prev)
     188
     189static inline void
     190list_add(struct list_head *new, struct list_head *head)
     191{
     192
     193    linux_list_add(new, head, head->next);
     194}
     195
     196static inline void
     197list_add_tail(struct list_head *new, struct list_head *head)
     198{
     199
     200    linux_list_add(new, head->prev, head);
     201}
     202
     203static inline void
     204list_move(struct list_head *list, struct list_head *head)
     205{
     206
     207    list_del(list);
     208    list_add(list, head);
     209}
     210
     211static inline void
     212list_move_tail(struct list_head *entry, struct list_head *head)
     213{
     214
     215    list_del(entry);
     216    list_add_tail(entry, head);
     217}
     218
     219static inline void
     220linux_list_splice(const struct list_head *list, struct list_head *prev, 
     221    struct list_head *next)
     222{
     223    struct list_head *first;
     224    struct list_head *last;
     225
     226    if (list_empty(list))
     227        return;
     228    first = list->next;
     229    last = list->prev;
     230    first->prev = prev;
     231    prev->next = first;
     232    last->next = next;
     233    next->prev = last;
     234}
     235
     236static inline void
     237list_splice(const struct list_head *list, struct list_head *head)
     238{
     239
     240    linux_list_splice(list, head, head->next);
     241}
     242
     243static inline void
     244list_splice_tail(struct list_head *list, struct list_head *head)
     245{
     246
     247    linux_list_splice(list, head->prev, head);
     248}
     249 
     250static inline void
     251list_splice_init(struct list_head *list, struct list_head *head)
     252{
     253
     254    linux_list_splice(list, head, head->next);
     255    INIT_LIST_HEAD(list);   
     256}
     257 
     258static inline void
     259list_splice_tail_init(struct list_head *list, struct list_head *head)
     260{
     261
     262    linux_list_splice(list, head->prev, head);
     263    INIT_LIST_HEAD(list);
     264}
     265
     266#undef LIST_HEAD
     267#define LIST_HEAD(name) struct list_head name = { &(name), &(name) }
     268
     269
     270struct hlist_head {
     271    struct hlist_node *first;
     272};
     273
     274struct hlist_node {
     275    struct hlist_node *next, **pprev;
     276};
     277
     278#define HLIST_HEAD_INIT { }
     279#define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT
     280#define INIT_HLIST_HEAD(head) (head)->first = NULL
     281#define INIT_HLIST_NODE(node)                       \
     282do {                                    \
     283    (node)->next = NULL;                        \
     284    (node)->pprev = NULL;                       \
     285} while (0)
     286
     287static inline int
     288hlist_unhashed(const struct hlist_node *h)
     289{
     290
     291    return !h->pprev;
     292}
     293
     294static inline int
     295hlist_empty(const struct hlist_head *h)
     296{
     297
     298    return !h->first;
     299}
     300
     301static inline void
     302hlist_del(struct hlist_node *n)
     303{
     304
     305        if (n->next)
     306                n->next->pprev = n->pprev;
     307        *n->pprev = n->next;
     308}
     309
     310static inline void
     311hlist_del_init(struct hlist_node *n)
     312{
     313
     314    if (hlist_unhashed(n))
     315        return;
     316    hlist_del(n);
     317    INIT_HLIST_NODE(n);
     318}
     319
     320static inline void
     321hlist_add_head(struct hlist_node *n, struct hlist_head *h)
     322{
     323
     324    n->next = h->first;
     325    if (h->first)
     326        h->first->pprev = &n->next;
     327    h->first = n;
     328    n->pprev = &h->first;
     329}
     330
     331static inline void
     332hlist_add_before(struct hlist_node *n, struct hlist_node *next)
     333{
     334
     335    n->pprev = next->pprev;
     336    n->next = next;
     337    next->pprev = &n->next;
     338    *(n->pprev) = n;
     339}
     340 
     341static inline void
     342hlist_add_after(struct hlist_node *n, struct hlist_node *next)
     343{
     344
     345    next->next = n->next;
     346    n->next = next;
     347    next->pprev = &n->next;
     348    if (next->next)
     349        next->next->pprev = &next->next;
     350}
     351 
     352static inline void
     353hlist_move_list(struct hlist_head *old, struct hlist_head *new)
     354{
     355
     356    new->first = old->first;
     357    if (new->first)
     358        new->first->pprev = &new->first;
     359    old->first = NULL;
     360}
     361
     362/**
     363 * list_is_singular - tests whether a list has just one entry.
     364 * @head: the list to test.
     365 */
     366static inline int list_is_singular(const struct list_head *head)
     367{
     368    return !list_empty(head) && (head->next == head->prev);
     369}
     370
     371static inline void __list_cut_position(struct list_head *list,
     372        struct list_head *head, struct list_head *entry)
     373{
     374    struct list_head *new_first = entry->next;
     375    list->next = head->next;
     376    list->next->prev = list;
     377    list->prev = entry;
     378    entry->next = list;
     379    head->next = new_first;
     380    new_first->prev = head;
     381}
     382
     383/**
     384 * list_cut_position - cut a list into two
     385 * @list: a new list to add all removed entries
     386 * @head: a list with entries
     387 * @entry: an entry within head, could be the head itself
     388 *  and if so we won't cut the list
     389 *
     390 * This helper moves the initial part of @head, up to and
     391 * including @entry, from @head to @list. You should
     392 * pass on @entry an element you know is on @head. @list
     393 * should be an empty list or a list you do not care about
     394 * losing its data.
     395 *
     396 */
     397static inline void list_cut_position(struct list_head *list,
     398        struct list_head *head, struct list_head *entry)
     399{
     400    if (list_empty(head))
     401        return;
     402    if (list_is_singular(head) &&
     403        (head->next != entry && head != entry))
     404        return;
     405    if (entry == head)
     406        INIT_LIST_HEAD(list);
     407    else
     408        __list_cut_position(list, head, entry);
     409}
     410
     411/**
     412 *  list_is_last - tests whether @list is the last entry in list @head
     413 *   @list: the entry to test
     414 *    @head: the head of the list
     415 */
     416static inline int list_is_last(const struct list_head *list,
     417                                const struct list_head *head)
     418{
     419        return list->next == head;
     420}
     421 
     422#define hlist_entry(ptr, type, field)   container_of(ptr, type, field)
     423
     424#define hlist_for_each(p, head)                     \
     425    for (p = (head)->first; p; p = (p)->next)
     426
     427#define hlist_for_each_safe(p, n, head)                 \
     428    for (p = (head)->first; p && ({ n = (p)->next; 1; }); p = n)
     429
     430#define hlist_entry_safe(ptr, type, member) \
     431    ((ptr) ? hlist_entry(ptr, type, member) : NULL)
     432
     433#define hlist_for_each_entry(pos, head, member)             \
     434    for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
     435         pos;                           \
     436         pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
     437
     438#define hlist_for_each_entry_continue(pos, member)          \
     439    for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member); \
     440         (pos);                         \
     441         pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
     442
     443#define hlist_for_each_entry_from(pos, member)              \
     444    for (; (pos);                               \
     445         pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
     446
     447#define hlist_for_each_entry_safe(pos, n, head, member)         \
     448    for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
     449         (pos) && ({ n = (pos)->member.next; 1; });         \
     450         pos = hlist_entry_safe(n, typeof(*(pos)), member))
     451
     452extern void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv,
     453    struct list_head *a, struct list_head *b));
     454
     455#endif /* _LINUX_LIST_H_ */
  • new file headers/compatibility/linuxkpi/asm/atomic.h

    diff --git a/headers/compatibility/linuxkpi/asm/atomic.h b/headers/compatibility/linuxkpi/asm/atomic.h
    new file mode 100644
    index 0000000000..ee8837bda1
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31
     32#ifndef _ASM_ATOMIC_H_
     33#define _ASM_ATOMIC_H_
     34
     35#include <stdint.h>
     36#include <SupportDefs.h>
     37#include <linux/compiler.h>
     38
     39#define ATOMIC_INIT(x)  { .counter = (x) }
     40#ifndef __DECONST
     41#define __DECONST(type, var) ((type)(uintptr_t)(const void*)(var))
     42#endif
     43
     44typedef struct {
     45    volatile int counter;
     46} atomic_t;
     47
     48/*------------------------------------------------------------------------*
     49 *  32-bit atomic operations
     50 *------------------------------------------------------------------------*/
     51
     52#define linux_atomic_add(i, v)      atomic_add_return((i), (v))
     53#define linux_atomic_sub(i, v)      atomic_sub_return((i), (v))
     54#define linux_atomic_inc_return(v)      atomic_add_return(1, (v))
     55#define linux_atomic_add_negative(i, v) (atomic_add_return((i), (v)) < 0)
     56#define linux_atomic_add_and_test(i, v) (atomic_add_return((i), (v)) == 0)
     57#define linux_atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
     58#define linux_atomic_dec_and_test(v)        (atomic_sub_return(1, (v)) == 0)
     59#define linux_atomic_inc_and_test(v)        (atomic_add_return(1, (v)) == 0)
     60#define linux_atomic_dec_return(v)      atomic_sub_return(1, (v))
     61#define linux_atomic_inc_not_zero(v)        atomic_add_unless((v), 1, 0)
     62
     63#define atomic_cmpset_int(p, old, new)      \
     64    atomic_test_and_set((int32*)(p), (new), (old))
     65
     66#define atomic_load_acq_int(p)      \
     67    atomic_get((int32*)(p))
     68
     69#define atomic_clear_int(p, v)  \
     70    atomic_and((int32*)(p), (~(v)))
     71
     72#define atomic_swap_int(p, v)       \
     73    atomic_get_and_set((int32*)(p), (v))
     74
     75static __inline__ int
     76atomic_add_return(int i, atomic_t *v)
     77{
     78    return atomic_add((int32*)(&v->counter), i);
     79}
     80
     81static __inline__ int
     82atomic_sub_return(int i, atomic_t *v)
     83{
     84    return atomic_add((int32*)(&v->counter), -i);
     85}
     86
     87static __inline__ void
     88linux_atomic_set(atomic_t *v, int i)
     89{
     90    atomic_set((int32*)(&v->counter), i);
     91}
     92
     93static __inline__ void
     94atomic_set_release(atomic_t *v, int i)
     95{
     96    atomic_set((int32*)(&v->counter), i);
     97}
     98
     99static __inline__ void
     100atomic_set_mask(unsigned int mask, atomic_t *v)
     101{
     102    atomic_or((int32*)(&v->counter), (mask));
     103}
     104
     105static __inline__ int
     106atomic_read(const atomic_t *v)
     107{
     108    return atomic_get((int32*)(&v->counter));
     109}
     110
     111static __inline__ int
     112atomic_inc(atomic_t *v)
     113{
     114    return atomic_add((int32*)(&v->counter), 1);
     115}
     116
     117static __inline__ int
     118atomic_dec(atomic_t *v)
     119{
     120    return atomic_add((int32*)(&v->counter), -1);
     121}
     122
     123static __inline__ int
     124atomic_add_unless(atomic_t *v, int a, int u)
     125{
     126    int c;
     127
     128    for (;;) {
     129        c = atomic_read(v);
     130        if (unlikely(c == u))
     131            break;
     132        if (likely(atomic_cmpset_int(&v->counter, c, c + a)))
     133            break;
     134    }
     135    return (c != u);
     136}
     137
     138static __inline__ void
     139atomic_clear_mask(unsigned int mask, atomic_t *v)
     140{
     141    atomic_clear_int(&v->counter, mask);
     142}
     143
     144static __inline__ int
     145atomic_xchg(atomic_t *v, int i)
     146{
     147#if defined(__i386__) || defined(__amd64__) || \
     148    defined(__arm__) || defined(__aarch64__)
     149    return (atomic_swap_int(&v->counter, i));
     150#else
     151    int ret;
     152    for (;;) {
     153        ret = atomic_load_acq_int(&v->counter);
     154        if (atomic_cmpset_int(&v->counter, ret, i))
     155            break;
     156    }
     157    return (ret);
     158#endif
     159}
     160
     161static __inline__ int
     162atomic_cmpxchg(atomic_t *v, int old, int new)
     163{
     164    int ret = old;
     165
     166    for (;;) {
     167        if (atomic_cmpset_int(&v->counter, old, new))
     168            break;
     169        ret = atomic_load_acq_int(&v->counter);
     170        if (ret != old)
     171            break;
     172    }
     173    return (ret);
     174}
     175
     176#define cmpxchg(ptr, old, new) ({               \
     177    __typeof(*(ptr)) __ret;                 \
     178                                \
     179    CTASSERT(sizeof(__ret) == 1 || sizeof(__ret) == 2 ||    \
     180        sizeof(__ret) == 4 || sizeof(__ret) == 8);      \
     181                                \
     182    __ret = (old);                      \
     183    switch (sizeof(__ret)) {                \
     184    case 1:                         \
     185        while (!atomic_fcmpset_8((volatile int8_t *)(ptr), \
     186            (int8_t *)&__ret, (new)) && __ret == (old)) \
     187            ;                   \
     188        break;                      \
     189    case 2:                         \
     190        while (!atomic_fcmpset_16((volatile int16_t *)(ptr), \
     191            (int16_t *)&__ret, (new)) && __ret == (old)) \
     192            ;                   \
     193        break;                      \
     194    case 4:                         \
     195        while (!atomic_fcmpset_32((volatile int32_t *)(ptr), \
     196            (int32_t *)&__ret, (new)) && __ret == (old)) \
     197            ;                   \
     198        break;                      \
     199    case 8:                         \
     200        while (!atomic_fcmpset_64((volatile int64_t *)(ptr), \
     201            (int64_t *)&__ret, (new)) && __ret == (old)) \
     202            ;                   \
     203        break;                      \
     204    }                           \
     205    __ret;                          \
     206})
     207
     208#define cmpxchg_relaxed(...)    cmpxchg(__VA_ARGS__)
     209
     210#define xchg(ptr, v) ({                     \
     211    __typeof(*(ptr)) __ret;                 \
     212                                \
     213    __ret = *(ptr);                     \
     214    *(ptr) = v;                     \
     215    __ret;                          \
     216})
     217
     218#define LINUX_ATOMIC_OP(op, c_op)               \
     219static __inline__ void linux_atomic_##op(int i, atomic_t *v)        \
     220{                               \
     221    int c, old;                     \
     222                                \
     223    c = v->counter;                     \
     224    while ((old = atomic_cmpxchg(v, c, c c_op i)) != c) \
     225        c = old;                    \
     226}
     227
     228#define LINUX_ATOMIC_FETCH_OP(op, c_op)             \
     229static __inline__ int linux_atomic_fetch_##op(int i, atomic_t *v)       \
     230{                               \
     231    int c, old;                     \
     232                                \
     233    c = v->counter;                     \
     234    while ((old = atomic_cmpxchg(v, c, c c_op i)) != c) \
     235        c = old;                    \
     236                                \
     237    return (c);                     \
     238}
     239
     240LINUX_ATOMIC_OP(or, |)
     241LINUX_ATOMIC_OP(and, &)
     242LINUX_ATOMIC_OP(andnot, &~)
     243LINUX_ATOMIC_OP(xor, ^)
     244
     245LINUX_ATOMIC_FETCH_OP(or, |)
     246LINUX_ATOMIC_FETCH_OP(and, &)
     247LINUX_ATOMIC_FETCH_OP(andnot, &~)
     248LINUX_ATOMIC_FETCH_OP(xor, ^)
     249
     250#endif                  /* _ASM_ATOMIC_H_ */
  • new file headers/compatibility/linuxkpi/asm/pgtable.h

    diff --git a/headers/compatibility/linuxkpi/asm/pgtable.h b/headers/compatibility/linuxkpi/asm/pgtable.h
    new file mode 100644
    index 0000000000..1df1030603
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _ASM_PGTABLE_H_
     32#define _ASM_PGTABLE_H_
     33
     34#include <linux/page.h>
     35
     36typedef unsigned long   pteval_t;
     37typedef unsigned long   pmdval_t;
     38typedef unsigned long   pudval_t;
     39typedef unsigned long   pgdval_t;
     40typedef unsigned long   pgprotval_t;
     41typedef struct page *pgtable_t;
     42
     43#endif  /* _ASM_PGTABLE_H_ */
  • new file headers/compatibility/linuxkpi/asm/types.h

    diff --git a/headers/compatibility/linuxkpi/asm/types.h b/headers/compatibility/linuxkpi/asm/types.h
    new file mode 100644
    index 0000000000..b32f5a9bc4
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _ASM_TYPES_H_
     32#define _ASM_TYPES_H_
     33
     34#include <sys/types.h>
     35#include <SupportDefs.h>
     36
     37typedef uint8_t u8;
     38typedef uint8_t __u8;
     39typedef uint16_t u16;
     40typedef uint16_t __u16;
     41typedef uint32_t u32;
     42typedef uint32_t __u32;
     43typedef uint64_t u64;
     44typedef uint64_t __u64;
     45
     46typedef int8_t s8;
     47typedef int8_t __s8;
     48typedef int16_t s16;
     49typedef int16_t __s16;
     50typedef int32_t s32;
     51typedef int32_t __s32;
     52typedef int64_t s64;
     53typedef int64_t __s64;
     54
     55typedef phys_addr_t vm_paddr_t;
     56
     57/* DMA addresses come in generic and 64-bit flavours.  */
     58typedef vm_paddr_t dma_addr_t;
     59typedef vm_paddr_t dma64_addr_t;
     60
     61// typedef unsigned short umode_t;
     62
     63#endif  /* _ASM_TYPES_H_ */
  • new file headers/compatibility/linuxkpi/linux/cdev.h

    diff --git a/headers/compatibility/linuxkpi/linux/cdev.h b/headers/compatibility/linuxkpi/linux/cdev.h
    new file mode 100644
    index 0000000000..917695a19d
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_CDEV_H_
     32#define _LINUX_CDEV_H_
     33
     34#include <linux/kdev_t.h>
     35
     36struct file_operations;
     37struct inode;
     38struct module;
     39
     40extern struct cdevsw linuxcdevsw;
     41extern const struct kobj_type linux_cdev_ktype;
     42extern const struct kobj_type linux_cdev_static_ktype;
     43
     44struct linux_cdev {
     45};
     46
     47static inline void
     48cdev_init(struct linux_cdev *cdev, const struct file_operations *ops)
     49{
     50}
     51
     52static inline struct linux_cdev *
     53cdev_alloc(void)
     54{
     55    return NULL;
     56}
     57
     58static inline void
     59cdev_put(struct linux_cdev *p)
     60{
     61}
     62
     63static inline int
     64cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned count)
     65{
     66    return (0);
     67}
     68
     69static inline int
     70cdev_add_ext(struct linux_cdev *cdev, dev_t dev, uid_t uid, gid_t gid, int mode)
     71{
     72    return (0);
     73}
     74
     75static inline void
     76cdev_del(struct linux_cdev *cdev)
     77{
     78}
     79
     80struct linux_cdev *linux_find_cdev(const char *name, unsigned major, unsigned minor);
     81
     82#define cdev    linux_cdev
     83
     84#endif  /* _LINUX_CDEV_H_ */
  • new file headers/compatibility/linuxkpi/linux/compiler.h

    diff --git a/headers/compatibility/linuxkpi/linux/compiler.h b/headers/compatibility/linuxkpi/linux/compiler.h
    new file mode 100644
    index 0000000000..389fdd76b3
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * Copyright (c) 2015 François Tigeot
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions
     11 * are met:
     12 * 1. Redistributions of source code must retain the above copyright
     13 *    notice unmodified, this list of conditions, and the following
     14 *    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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 *
     30 * $FreeBSD$
     31 */
     32#ifndef _LINUX_COMPILER_H_
     33#define _LINUX_COMPILER_H_
     34
     35#define __user
     36#define __kernel
     37#define __safe
     38#define __force
     39#define __nocast
     40#define __iomem
     41#define __chk_user_ptr(x)       0
     42#define __chk_io_ptr(x)         0
     43#define __builtin_warning(x, y...)  (1)
     44#define __acquires(x)
     45#define __releases(x)
     46#define __acquire(x)            0
     47#define __release(x)            0
     48#define __cond_lock(x,c)        (c)
     49#define __bitwise
     50#define __devinitdata
     51#define __deprecated
     52#define __init
     53#define __devinit
     54#define __devexit
     55#define __exit
     56#define __rcu
     57#define __malloc
     58#define ___stringify(...)       #__VA_ARGS__
     59#define __stringify(...)        ___stringify(__VA_ARGS__)
     60#define __attribute_const__     __attribute__((__const__))
     61#undef __always_inline
     62#define __always_inline         inline
     63#define ____cacheline_aligned       __aligned(CACHE_LINE_SIZE)
     64
     65#define likely(x)           __builtin_expect(!!(x), 1)
     66#define unlikely(x)         __builtin_expect(!!(x), 0)
     67#define typeof(x)           __typeof(x)
     68
     69#define uninitialized_var(x)        x = x
     70#define __always_unused         __unused
     71#define __must_check            __result_use_check
     72
     73#define __printf(a,b)           __printflike(a,b)
     74
     75#define barrier()           __asm__ __volatile__("": : :"memory")
     76
     77#define ___PASTE(a,b) a##b
     78#define __PASTE(a,b) ___PASTE(a,b)
     79
     80#define ACCESS_ONCE(x)          (*(volatile __typeof(x) *)&(x))
     81 
     82#define WRITE_ONCE(x,v) do {        \
     83    barrier();          \
     84    ACCESS_ONCE(x) = (v);       \
     85    barrier();          \
     86} while (0)
     87
     88#define READ_ONCE(x) ({         \
     89    __typeof(x) __var = ({      \
     90        barrier();      \
     91        ACCESS_ONCE(x);     \
     92    });             \
     93    barrier();          \
     94    __var;              \
     95})
     96
     97#define lockless_dereference(p) READ_ONCE(p)
     98
     99#define _AT(T,X)    ((T)(X))
     100
     101#endif  /* _LINUX_COMPILER_H_ */
  • new file headers/compatibility/linuxkpi/linux/device.h

    diff --git a/headers/compatibility/linuxkpi/linux/device.h b/headers/compatibility/linuxkpi/linux/device.h
    new file mode 100644
    index 0000000000..12432553f0
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_DEVICE_H_
     32#define _LINUX_DEVICE_H_
     33
     34struct device;
     35
     36#endif  /* _LINUX_DEVICE_H_ */
  • new file headers/compatibility/linuxkpi/linux/dma-attrs.h

    diff --git a/headers/compatibility/linuxkpi/linux/dma-attrs.h b/headers/compatibility/linuxkpi/linux/dma-attrs.h
    new file mode 100644
    index 0000000000..fda22822dc
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_DMA_ATTR_H_
     32#define _LINUX_DMA_ATTR_H_
     33
     34enum dma_attr { DMA_ATTR_WRITE_BARRIER, DMA_ATTR_WEAK_ORDERING, DMA_ATTR_MAX, };
     35
     36#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX)
     37
     38struct dma_attrs {
     39    unsigned long flags;
     40};
     41 
     42#define DEFINE_DMA_ATTRS(x) struct dma_attrs x = { }
     43
     44static inline void
     45init_dma_attrs(struct dma_attrs *attrs)
     46{
     47    attrs->flags = 0;
     48}
     49
     50#endif  /* _LINUX_DMA_ATTR_H_ */
  • new file headers/compatibility/linuxkpi/linux/gfp.h

    diff --git a/headers/compatibility/linuxkpi/linux/gfp.h b/headers/compatibility/linuxkpi/linux/gfp.h
    new file mode 100644
    index 0000000000..96eac510b9
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_GFP_H_
     32#define _LINUX_GFP_H_
     33
     34#define M_WAITOK    0x01u
     35#define M_NOWAIT    0x02u
     36#define M_USE_RESERVE   0x04u
     37#define M_ZERO  __GFP_ZERO
     38
     39#define __GFP_NOWARN    0
     40#define __GFP_HIGHMEM   0
     41#define __GFP_ZERO  0x08u
     42#define __GFP_NORETRY   0
     43#define __GFP_RECLAIM   0
     44#define __GFP_RECLAIMABLE   0
     45
     46#define __GFP_IO    0
     47#define __GFP_NO_KSWAPD 0
     48#define __GFP_WAIT  M_WAITOK
     49#define __GFP_DMA32 0x10u
     50
     51#define GFP_NOWAIT  M_NOWAIT
     52#define GFP_ATOMIC  (M_NOWAIT | M_USE_RESERVE)
     53#define GFP_KERNEL  M_WAITOK
     54#define GFP_USER    M_WAITOK
     55#define GFP_HIGHUSER    M_WAITOK
     56#define GFP_HIGHUSER_MOVABLE    M_WAITOK
     57#define GFP_IOFS    M_NOWAIT
     58#define GFP_NOIO    M_NOWAIT
     59#define GFP_DMA32   __GFP_DMA32
     60#define GFP_TEMPORARY   M_NOWAIT
     61#define GFP_NATIVE_MASK (M_NOWAIT | M_WAITOK | M_USE_RESERVE | M_ZERO)
     62
     63
     64#endif  /* _LINUX_GFP_H_ */
  • new file headers/compatibility/linuxkpi/linux/kdev_t.h

    diff --git a/headers/compatibility/linuxkpi/linux/kdev_t.h b/headers/compatibility/linuxkpi/linux/kdev_t.h
    new file mode 100644
    index 0000000000..6f1b9a10de
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_KDEV_T_H_
     32#define _LINUX_KDEV_T_H_
     33
     34#include <linux/types.h>
     35
     36#define MAJOR(dev)      major((dev))
     37#define MINOR(dev)      minor((dev))
     38#define MKDEV(ma, mi)   makedev((ma), (mi))
     39
     40static inline uint16_t
     41old_encode_dev(dev_t dev)
     42{
     43    return ((MAJOR(dev) << 8) | MINOR(dev));
     44}
     45
     46#endif  /* _LINUX_KDEV_T_H_ */
  • new file headers/compatibility/linuxkpi/linux/kernel.h

    diff --git a/headers/compatibility/linuxkpi/linux/kernel.h b/headers/compatibility/linuxkpi/linux/kernel.h
    new file mode 100644
    index 0000000000..59d1063171
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * Copyright (c) 2014-2015 François Tigeot
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions
     11 * are met:
     12 * 1. Redistributions of source code must retain the above copyright
     13 *    notice unmodified, this list of conditions, and the following
     14 *    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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 *
     30 * $FreeBSD$
     31 */
     32#ifndef _LINUX_KERNEL_H_
     33#define _LINUX_KERNEL_H_
     34
     35#include <linux/types.h>
     36#include <stdarg.h>
     37#include <stdio.h>
     38#include <stdlib.h>
     39#include <freebsd/sys/time.h>
     40
     41#define KERN_CONT       ""
     42#define KERN_EMERG  "<0>"
     43#define KERN_ALERT  "<1>"
     44#define KERN_CRIT   "<2>"
     45#define KERN_ERR    "<3>"
     46#define KERN_WARNING    "<4>"
     47#define KERN_NOTICE "<5>"
     48#define KERN_INFO   "<6>"
     49#define KERN_DEBUG  "<7>"
     50
     51#define U8_MAX      ((u8)~0U)
     52#define S8_MAX      ((s8)(U8_MAX >> 1))
     53#define S8_MIN      ((s8)(-S8_MAX - 1))
     54#define U16_MAX     ((u16)~0U)
     55#define S16_MAX     ((s16)(U16_MAX >> 1))
     56#define S16_MIN     ((s16)(-S16_MAX - 1))
     57#define U32_MAX     ((u32)~0U)
     58#define S32_MAX     ((s32)(U32_MAX >> 1))
     59#define S32_MIN     ((s32)(-S32_MAX - 1))
     60#define U64_MAX     ((u64)~0ULL)
     61#define S64_MAX     ((s64)(U64_MAX >> 1))
     62#define S64_MIN     ((s64)(-S64_MAX - 1))
     63
     64#define S8_C(x)  x
     65#define U8_C(x)  x ## U
     66#define S16_C(x) x
     67#define U16_C(x) x ## U
     68#define S32_C(x) x
     69#define U32_C(x) x ## U
     70#define S64_C(x) x ## LL
     71#define U64_C(x) x ## ULL
     72
     73#define BUILD_BUG_ON(x)         CTASSERT(!(x))
     74#define BUILD_BUG_ON_MSG(x, msg)    BUILD_BUG_ON(x)
     75#define BUILD_BUG_ON_NOT_POWER_OF_2(x)  BUILD_BUG_ON(!powerof2(x))
     76
     77#define BUG()           panic("BUG at %s:%d", __FILE__, __LINE__)
     78#define BUG_ON(cond)        do {                \
     79    if (cond) {                     \
     80        panic("BUG ON %s failed at %s:%d",      \
     81            __stringify(cond), __FILE__, __LINE__); \
     82    }                           \
     83} while (0)
     84
     85#define WARN_ON(cond) ({                    \
     86      bool __ret = (cond);                  \
     87      if (__ret) {                      \
     88        printf("WARNING %s failed at %s:%d\n",      \
     89            __stringify(cond), __FILE__, __LINE__); \
     90      }                             \
     91      unlikely(__ret);                      \
     92})
     93
     94#define WARN_ON_SMP(cond)   WARN_ON(cond)
     95
     96#define WARN_ON_ONCE(cond) ({                   \
     97      static bool __warn_on_once;               \
     98      bool __ret = (cond);                  \
     99      if (__ret && !__warn_on_once) {               \
     100        __warn_on_once = 1;             \
     101        printf("WARNING %s failed at %s:%d\n",      \
     102            __stringify(cond), __FILE__, __LINE__); \
     103      }                             \
     104      unlikely(__ret);                      \
     105})
     106
     107#define oops_in_progress    SCHEDULER_STOPPED()
     108
     109#undef  ALIGN
     110#define ALIGN(x, y)     roundup2((x), (y))
     111#undef PTR_ALIGN
     112#define PTR_ALIGN(p, a)     ((__typeof(p))ALIGN((uintptr_t)(p), (a)))
     113#define DIV_ROUND_UP(x, n)  howmany(x, n)
     114#define DIV_ROUND_UP_ULL(x, n)  DIV_ROUND_UP((unsigned long long)(x), (n))
     115#define FIELD_SIZEOF(t, f)  sizeof(((t *)0)->f)
     116
     117#define printk(...)     printf(__VA_ARGS__)
     118#define vprintk(f, a)       vprintf(f, a)
     119
     120struct va_format {
     121    const char *fmt;
     122    va_list *va;
     123};
     124
     125static inline int
     126vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
     127{
     128    ssize_t ssize = size;
     129    int i;
     130
     131    i = vsnprintf(buf, size, fmt, args);
     132
     133    return ((i >= ssize) ? (ssize - 1) : i);
     134}
     135
     136static inline int
     137scnprintf(char *buf, size_t size, const char *fmt, ...)
     138{
     139    va_list args;
     140    int i;
     141
     142    va_start(args, fmt);
     143    i = vscnprintf(buf, size, fmt, args);
     144    va_end(args);
     145
     146    return (i);
     147}
     148
     149/*
     150 * The "pr_debug()" and "pr_devel()" macros should produce zero code
     151 * unless DEBUG is defined:
     152 */
     153#ifdef DEBUG
     154#define pr_debug(fmt, ...) \
     155        log(LOG_DEBUG, fmt, ##__VA_ARGS__)
     156#define pr_devel(fmt, ...) \
     157    log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
     158#else
     159#define pr_debug(fmt, ...) \
     160        ({ if (0) log(LOG_DEBUG, fmt, ##__VA_ARGS__); 0; })
     161#define pr_devel(fmt, ...) \
     162    ({ if (0) log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); 0; })
     163#endif
     164
     165#ifndef pr_fmt
     166#define pr_fmt(fmt) fmt
     167#endif
     168
     169/*
     170 * Print a one-time message (analogous to WARN_ONCE() et al):
     171 */
     172#define printk_once(...) do {           \
     173    static bool __print_once;       \
     174                        \
     175    if (!__print_once) {            \
     176        __print_once = true;        \
     177        printk(__VA_ARGS__);        \
     178    }                   \
     179} while (0)
     180
     181/*
     182 * Log a one-time message (analogous to WARN_ONCE() et al):
     183 */
     184#define log_once(level,...) do {        \
     185    static bool __log_once;         \
     186                        \
     187    if (unlikely(!__log_once)) {        \
     188        __log_once = true;      \
     189        log(level, __VA_ARGS__);    \
     190    }                   \
     191} while (0)
     192
     193#define pr_emerg(fmt, ...) \
     194    log(LOG_EMERG, pr_fmt(fmt), ##__VA_ARGS__)
     195#define pr_alert(fmt, ...) \
     196    log(LOG_ALERT, pr_fmt(fmt), ##__VA_ARGS__)
     197#define pr_crit(fmt, ...) \
     198    log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__)
     199#define pr_err(fmt, ...) \
     200    log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
     201#define pr_warning(fmt, ...) \
     202    log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
     203#define pr_warn(...) \
     204    pr_warning(__VA_ARGS__)
     205#define pr_warn_once(fmt, ...) \
     206    log_once(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
     207#define pr_notice(fmt, ...) \
     208    log(LOG_NOTICE, pr_fmt(fmt), ##__VA_ARGS__)
     209#define pr_info(fmt, ...) \
     210    log(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
     211#define pr_info_once(fmt, ...) \
     212    log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
     213#define pr_cont(fmt, ...) \
     214    printk(KERN_CONT fmt, ##__VA_ARGS__)
     215#define pr_warn_ratelimited(...) do {       \
     216    static linux_ratelimit_t __ratelimited; \
     217    if (linux_ratelimited(&__ratelimited))  \
     218        pr_warning(__VA_ARGS__);    \
     219} while (0)
     220
     221#ifndef WARN
     222#define WARN(condition, ...) ({         \
     223        bool __ret_warn_on = (condition);   \
     224        if (unlikely(__ret_warn_on))        \
     225                pr_warning(__VA_ARGS__);    \
     226        unlikely(__ret_warn_on);        \
     227})
     228#endif
     229
     230#ifndef WARN_ONCE
     231#define WARN_ONCE(condition, ...) ({        \
     232        bool __ret_warn_on = (condition);   \
     233        if (unlikely(__ret_warn_on))        \
     234                pr_warn_once(__VA_ARGS__);  \
     235        unlikely(__ret_warn_on);        \
     236})
     237#endif
     238
     239#define container_of(ptr, type, member)             \
     240({                              \
     241    const __typeof(((type *)0)->member) *__p = (ptr);   \
     242    (type *)((uintptr_t)__p - offsetof(type, member));  \
     243})
     244 
     245#define ARRAY_SIZE(x)   (sizeof(x) / sizeof((x)[0]))
     246
     247#define strtoq strtoll
     248#define strtouq strtoull
     249
     250static inline unsigned long long
     251simple_strtoull(const char *cp, char **endp, unsigned int base)
     252{
     253    return (strtouq(cp, endp, base));
     254}
     255
     256static inline long long
     257simple_strtoll(const char *cp, char **endp, unsigned int base)
     258{
     259    return (strtoq(cp, endp, base));
     260}
     261
     262static inline unsigned long
     263simple_strtoul(const char *cp, char **endp, unsigned int base)
     264{
     265    return (strtoul(cp, endp, base));
     266}
     267
     268static inline long
     269simple_strtol(const char *cp, char **endp, unsigned int base)
     270{
     271    return (strtol(cp, endp, base));
     272}
     273
     274static inline int
     275kstrtoul(const char *cp, unsigned int base, unsigned long *res)
     276{
     277    char *end;
     278
     279    *res = strtoul(cp, &end, base);
     280
     281    if (*cp == 0 || *end != 0)
     282        return (-EINVAL);
     283    return (0);
     284}
     285
     286static inline int
     287kstrtol(const char *cp, unsigned int base, long *res)
     288{
     289    char *end;
     290
     291    *res = strtol(cp, &end, base);
     292
     293    if (*cp == 0 || *end != 0)
     294        return (-EINVAL);
     295    return (0);
     296}
     297
     298static inline int
     299kstrtoint(const char *cp, unsigned int base, int *res)
     300{
     301    char *end;
     302    long temp;
     303
     304    *res = temp = strtol(cp, &end, base);
     305
     306    if (*cp == 0 || *end != 0)
     307        return (-EINVAL);
     308    if (temp != (int)temp)
     309        return (-ERANGE);
     310    return (0);
     311}
     312
     313static inline int
     314kstrtouint(const char *cp, unsigned int base, unsigned int *res)
     315{
     316    char *end;
     317    unsigned long temp;
     318
     319    *res = temp = strtoul(cp, &end, base);
     320
     321    if (*cp == 0 || *end != 0)
     322        return (-EINVAL);
     323    if (temp != (unsigned int)temp)
     324        return (-ERANGE);
     325    return (0);
     326}
     327
     328static inline int
     329kstrtou32(const char *cp, unsigned int base, u32 *res)
     330{
     331    char *end;
     332    unsigned long temp;
     333
     334    *res = temp = strtoul(cp, &end, base);
     335
     336    if (*cp == 0 || *end != 0)
     337        return (-EINVAL);
     338    if (temp != (u32)temp)
     339        return (-ERANGE);
     340    return (0);
     341}
     342
     343#ifndef min
     344#define min(x, y)   ((x) < (y) ? (x) : (y))
     345#endif
     346
     347#ifndef max
     348#define max(x, y)   ((x) > (y) ? (x) : (y))
     349#endif
     350
     351#define min3(a, b, c)   min(a, min(b,c))
     352#define max3(a, b, c)   max(a, max(b,c))
     353
     354#define min_t(type, x, y) ({            \
     355    type __min1 = (x);          \
     356    type __min2 = (y);          \
     357    __min1 < __min2 ? __min1 : __min2; })
     358
     359#define max_t(type, x, y) ({            \
     360    type __max1 = (x);          \
     361    type __max2 = (y);          \
     362    __max1 > __max2 ? __max1 : __max2; })
     363
     364#define clamp_t(type, _x, min, max) min_t(type, max_t(type, _x, min), max)
     365#define clamp(x, lo, hi)        min( max(x,lo), hi)
     366#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
     367
     368/*
     369 * This looks more complex than it should be. But we need to
     370 * get the type for the ~ right in round_down (it needs to be
     371 * as wide as the result!), and we want to evaluate the macro
     372 * arguments just once each.
     373 */
     374#define __round_mask(x, y) ((__typeof__(x))((y)-1))
     375#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
     376#define round_down(x, y) ((x) & ~__round_mask(x, y))
     377
     378#define smp_processor_id()  PCPU_GET(cpuid)
     379#define num_possible_cpus() mp_ncpus
     380#define num_online_cpus()   mp_ncpus
     381
     382#if defined(__i386__) || defined(__amd64__)
     383extern bool linux_cpu_has_clflush;
     384#define cpu_has_clflush     linux_cpu_has_clflush
     385#endif
     386
     387typedef struct pm_message {
     388        int event;
     389} pm_message_t;
     390
     391/* Swap values of a and b */
     392#define swap(a, b) do {         \
     393    typeof(a) _swap_tmp = a;    \
     394    a = b;              \
     395    b = _swap_tmp;          \
     396} while (0)
     397
     398#define DIV_ROUND_CLOSEST(x, divisor)   (((x) + ((divisor) / 2)) / (divisor))
     399
     400#define DIV_ROUND_CLOSEST_ULL(x, divisor) ({        \
     401    __typeof(divisor) __d = (divisor);      \
     402    unsigned long long __ret = (x) + (__d) / 2; \
     403    __ret /= __d;                   \
     404    __ret;                      \
     405})
     406
     407static inline uintmax_t
     408mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor)
     409{
     410    uintmax_t q = (x / divisor);
     411    uintmax_t r = (x % divisor);
     412
     413    return ((q * multiplier) + ((r * multiplier) / divisor));
     414}
     415
     416static inline int64_t
     417abs64(int64_t x)
     418{
     419    return (x < 0 ? -x : x);
     420}
     421
     422typedef struct linux_ratelimit {
     423    struct timeval lasttime;
     424    int counter;
     425} linux_ratelimit_t;
     426
     427static inline bool
     428linux_ratelimited(linux_ratelimit_t *rl)
     429{
     430    return (ppsratecheck(&rl->lasttime, &rl->counter, 1));
     431}
     432
     433#endif  /* _LINUX_KERNEL_H_ */
  • new file headers/compatibility/linuxkpi/linux/kobject.h

    diff --git a/headers/compatibility/linuxkpi/linux/kobject.h b/headers/compatibility/linuxkpi/linux/kobject.h
    new file mode 100644
    index 0000000000..90a884af98
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_KOBJECT_H_
     32#define _LINUX_KOBJECT_H_
     33
     34#include <linux/kernel.h>
     35#include <linux/kref.h>
     36#include <linux/list.h>
     37#include <linux/slab.h>
     38
     39struct kobject;
     40struct sysctl_oid;
     41
     42struct kobj_type {
     43    void (*release)(struct kobject *kobj);
     44    const struct sysfs_ops *sysfs_ops;
     45    struct attribute **default_attrs;
     46};
     47
     48extern const struct kobj_type linux_kfree_type;
     49
     50struct kobject {
     51    struct kobject      *parent;
     52    char            *name;
     53    struct kref     kref;
     54    const struct kobj_type  *ktype;
     55    struct list_head    entry;
     56    struct sysctl_oid   *oidp;
     57};
     58
     59extern struct kobject *mm_kobj;
     60
     61struct attribute {
     62    const char  *name;
     63    struct module   *owner;
     64    mode_t      mode;
     65};
     66
     67struct kobj_attribute {
     68        struct attribute attr;
     69        ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
     70                        char *buf);
     71        ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
     72                         const char *buf, size_t count);
     73};
     74
     75static inline void
     76kobject_init(struct kobject *kobj, const struct kobj_type *ktype)
     77{
     78
     79    kref_init(&kobj->kref);
     80    INIT_LIST_HEAD(&kobj->entry);
     81    kobj->ktype = ktype;
     82    kobj->oidp = NULL;
     83}
     84
     85void linux_kobject_release(struct kref *kref);
     86
     87static inline void
     88kobject_put(struct kobject *kobj)
     89{
     90
     91    if (kobj)
     92        kref_put(&kobj->kref, linux_kobject_release);
     93}
     94
     95static inline struct kobject *
     96kobject_get(struct kobject *kobj)
     97{
     98
     99    if (kobj)
     100        kref_get(&kobj->kref);
     101    return kobj;
     102}
     103
     104int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
     105int kobject_add(struct kobject *kobj, struct kobject *parent,
     106        const char *fmt, ...);
     107
     108static inline struct kobject *
     109kobject_create(void)
     110{
     111    struct kobject *kobj;
     112
     113    kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
     114
     115    if (kobj == (NULL))
     116        return (NULL);
     117    kobject_init(kobj, &linux_kfree_type);
     118
     119    return (kobj);
     120}
     121
     122static inline struct kobject *
     123kobject_create_and_add(const char *name, struct kobject *parent)
     124{
     125    struct kobject *kobj;
     126
     127    kobj = kobject_create();
     128    if (kobj == NULL)
     129        return (NULL);
     130    if (kobject_add(kobj, parent, "%s", name) == 0)
     131        return (kobj);
     132    kobject_put(kobj);
     133
     134    return (NULL);
     135}
     136
     137static inline char *
     138kobject_name(const struct kobject *kobj)
     139{
     140
     141    return kobj->name;
     142}
     143
     144int kobject_set_name(struct kobject *kobj, const char *fmt, ...);
     145int kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
     146        struct kobject *parent, const char *fmt, ...);
     147
     148#endif /* _LINUX_KOBJECT_H_ */
  • new file headers/compatibility/linuxkpi/linux/kref.h

    diff --git a/headers/compatibility/linuxkpi/linux/kref.h b/headers/compatibility/linuxkpi/linux/kref.h
    new file mode 100644
    index 0000000000..bbb43f4753
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
     6 * Copyright (c) 2013 François Tigeot
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions
     11 * are met:
     12 * 1. Redistributions of source code must retain the above copyright
     13 *    notice unmodified, this list of conditions, and the following
     14 *    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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 *
     30 * $FreeBSD$
     31 */
     32#ifndef _LINUX_KREF_H_
     33#define _LINUX_KREF_H_
     34
     35#include <linux/refcount.h>
     36#include <linux/mutex.h>
     37
     38#include <asm/atomic.h>
     39
     40#ifndef WARN_ON
     41#define WARN_ON(cond) ({                    \
     42    bool __ret = (cond);                    \
     43    if (__ret) {                        \
     44        printf("WARNING %s failed at %s:%d\n",      \
     45            __stringify(cond), __FILE__, __LINE__); \
     46    }                               \
     47    unlikely(__ret);                        \
     48})
     49#endif /* WARN_ON */
     50
     51struct kref {
     52    atomic_t refcount;
     53};
     54
     55static __inline void
     56kref_init(struct kref *kref)
     57{
     58
     59    refcount_init(&kref->refcount.counter, 1);
     60}
     61
     62static __inline void
     63kref_get(struct kref *kref)
     64{
     65
     66    refcount_acquire(&kref->refcount.counter);
     67}
     68
     69static __inline int
     70kref_put(struct kref *kref, void (*rel)(struct kref *kref))
     71{
     72
     73    if (refcount_release(&kref->refcount.counter)) {
     74        rel(kref);
     75        return 1;
     76    }
     77    return 0;
     78}
     79
     80static __inline int
     81kref_sub(struct kref *kref, unsigned int count,
     82    void (*rel)(struct kref *kref))
     83{
     84
     85    while (count--) {
     86        if (refcount_release(&kref->refcount.counter)) {
     87            rel(kref);
     88            return 1;
     89        }
     90    }
     91    return 0;
     92}
     93
     94static __inline int
     95kref_get_unless_zero(struct kref *kref)
     96{
     97    return atomic_add_unless(&kref->refcount, 1, 0);
     98}
     99
     100static __inline int kref_put_mutex(struct kref *kref,
     101    void (*release)(struct kref *kref), struct mutex *lock)
     102{
     103    WARN_ON(release == NULL);
     104    if (unlikely(!atomic_add_unless(&kref->refcount, -1, 1))) {
     105        mutex_lock(lock);
     106        if (unlikely(!linux_atomic_dec_and_test(&kref->refcount))) {
     107            mutex_unlock(lock);
     108            return 0;
     109        }
     110        release(kref);
     111        return 1;
     112    }
     113    return 0;
     114}
     115
     116#endif /* _LINUX_KREF_H_ */
  • new file headers/compatibility/linuxkpi/linux/mm.h

    diff --git a/headers/compatibility/linuxkpi/linux/mm.h b/headers/compatibility/linuxkpi/linux/mm.h
    new file mode 100644
    index 0000000000..b4a50af0c9
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
     6 * Copyright (c) 2015 François Tigeot
     7 * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
     8 * All rights reserved.
     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 unmodified, this list of conditions, and the following
     15 *    disclaimer.
     16 * 2. Redistributions in binary form must reproduce the above copyright
     17 *    notice, this list of conditions and the following disclaimer in the
     18 *    documentation and/or other materials provided with the distribution.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * $FreeBSD$
     32 */
     33#ifndef _LINUX_MM_H_
     34#define _LINUX_MM_H_
     35
     36#include <linux/page.h>
     37// #include <linux/spinlock.h>
     38// #include <linux/gfp.h>
     39// #include <linux/kernel.h>
     40// #include <linux/mm_types.h>
     41// #include <linux/pfn.h>
     42// #include <linux/list.h>
     43
     44#include <asm/pgtable.h>
     45#include <freebsd/vm/vm_map.h>
     46#include <freebsd/vm/vm_page.h>
     47#include <freebsd/vm/vm_object.h>
     48
     49#include <arch_vm.h>
     50
     51#define VM_READ         VM_PROT_READ
     52#define VM_WRITE        VM_PROT_WRITE
     53#define VM_EXEC         VM_PROT_EXECUTE
     54
     55#define VM_PFNINTERNAL      (1 << 8)    /* FreeBSD private flag to vm_insert_pfn() */
     56#define VM_MIXEDMAP     (1 << 9)
     57#define VM_NORESERVE        (1 << 10)
     58#define VM_PFNMAP       (1 << 11)
     59#define VM_IO           (1 << 12)
     60#define VM_MAYWRITE     (1 << 13)
     61#define VM_DONTCOPY     (1 << 14)
     62#define VM_DONTEXPAND       (1 << 15)
     63#define VM_DONTDUMP     (1 << 16)
     64
     65#define VMA_MAX_PREFAULT_RECORD 1
     66
     67#define FOLL_WRITE      (1 << 0)
     68#define FOLL_FORCE      (1 << 1)
     69
     70#define VM_FAULT_OOM        (1 << 0)
     71#define VM_FAULT_SIGBUS     (1 << 1)
     72#define VM_FAULT_MAJOR      (1 << 2)
     73#define VM_FAULT_WRITE      (1 << 3)
     74#define VM_FAULT_HWPOISON   (1 << 4)
     75#define VM_FAULT_HWPOISON_LARGE (1 << 5)
     76#define VM_FAULT_SIGSEGV    (1 << 6)
     77#define VM_FAULT_NOPAGE     (1 << 7)
     78#define VM_FAULT_LOCKED     (1 << 8)
     79#define VM_FAULT_RETRY      (1 << 9)
     80#define VM_FAULT_FALLBACK   (1 << 10)
     81
     82#define FAULT_FLAG_WRITE    (1 << 0)
     83#define FAULT_FLAG_MKWRITE  (1 << 1)
     84#define FAULT_FLAG_ALLOW_RETRY  (1 << 2)
     85#define FAULT_FLAG_RETRY_NOWAIT (1 << 3)
     86#define FAULT_FLAG_KILLABLE (1 << 4)
     87#define FAULT_FLAG_TRIED    (1 << 5)
     88#define FAULT_FLAG_USER     (1 << 6)
     89#define FAULT_FLAG_REMOTE   (1 << 7)
     90#define FAULT_FLAG_INSTRUCTION  (1 << 8)
     91
     92typedef int (*pte_fn_t)(linux_pte_t *, pgtable_t, unsigned long addr, void *data);
     93
     94struct vm_area_struct {
     95    vm_offset_t vm_start;
     96    vm_offset_t vm_end;
     97    vm_offset_t vm_pgoff;
     98    pgprot_t vm_page_prot;
     99    unsigned long vm_flags;
     100    struct mm_struct *vm_mm;
     101    void   *vm_private_data;
     102    const struct vm_operations_struct *vm_ops;
     103    struct linux_file *vm_file;
     104
     105    /* internal operation */
     106    vm_paddr_t vm_pfn;      /* PFN for memory map */
     107    vm_size_t vm_len;       /* length for memory map */
     108    vm_pindex_t vm_pfn_first;
     109    int vm_pfn_count;
     110    int    *vm_pfn_pcount;
     111    vm_object_t vm_obj;
     112    vm_map_t vm_cached_map;
     113    TAILQ_ENTRY(vm_area_struct) vm_entry;
     114};
     115
     116struct vm_fault {
     117    unsigned int flags;
     118    pgoff_t pgoff;
     119    void   *virtual_address;    /* user-space address */
     120    struct page *page;
     121};
     122
     123struct vm_operations_struct {
     124    void    (*open) (struct vm_area_struct *);
     125    void    (*close) (struct vm_area_struct *);
     126    int     (*fault) (struct vm_area_struct *, struct vm_fault *);
     127};
     128
     129/*
     130 * Compute log2 of the power of two rounded up count of pages
     131 * needed for size bytes.
     132 */
     133static inline int
     134get_order(unsigned long size)
     135{
     136    int order;
     137
     138    size = (size - 1) >> PAGE_SHIFT;
     139    order = 0;
     140    while (size) {
     141        order++;
     142        size >>= 1;
     143    }
     144    return (order);
     145}
     146
     147static inline void *
     148lowmem_page_address(struct page *page)
     149{
     150    return (page_address(page));
     151}
     152
     153/*
     154 * This only works via memory map operations.
     155 */
     156static inline int
     157io_remap_pfn_range(struct vm_area_struct *vma,
     158    unsigned long addr, unsigned long pfn, unsigned long size,
     159    vm_memattr_t prot)
     160{
     161    vma->vm_page_prot = prot;
     162    vma->vm_pfn = pfn;
     163    vma->vm_len = size;
     164
     165    return (0);
     166}
     167
     168static inline int
     169apply_to_page_range(struct mm_struct *mm, unsigned long address,
     170    unsigned long size, pte_fn_t fn, void *data)
     171{
     172    return (-ENOTSUP);
     173}
     174
     175static inline int
     176zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
     177    unsigned long size)
     178{
     179    return (-ENOTSUP);
     180}
     181
     182static inline int
     183remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
     184    unsigned long pfn, unsigned long size, pgprot_t prot)
     185{
     186    return (-ENOTSUP);
     187}
     188
     189static inline unsigned long
     190vma_pages(struct vm_area_struct *vma)
     191{
     192    return ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT);
     193}
     194
     195#define offset_in_page(off) ((off) & (PAGE_SIZE - 1))
     196
     197static inline void
     198set_page_dirty(struct vm_page *page)
     199{
     200    vm_page_dirty(page);
     201}
     202
     203static inline void
     204set_page_dirty_lock(struct vm_page *page)
     205{
     206    vm_page_lock(page);
     207    vm_page_dirty(page);
     208    vm_page_unlock(page);
     209}
     210
     211static inline void
     212mark_page_accessed(struct vm_page *page)
     213{
     214    vm_page_reference(page);
     215}
     216
     217static inline void
     218get_page(struct vm_page *page)
     219{
     220    vm_page_lock(page);
     221    vm_page_hold(page);
     222    vm_page_wire(page);
     223    vm_page_unlock(page);
     224}
     225
     226extern long
     227get_user_pages(unsigned long start, unsigned long nr_pages,
     228    int gup_flags, struct page **,
     229    struct vm_area_struct **);
     230
     231extern int
     232__get_user_pages_fast(unsigned long start, int nr_pages, int write,
     233    struct page **);
     234
     235extern long
     236get_user_pages_remote(struct task_struct *, struct mm_struct *,
     237    unsigned long start, unsigned long nr_pages,
     238    int gup_flags, struct page **,
     239    struct vm_area_struct **);
     240
     241static inline void
     242put_page(struct vm_page *page)
     243{
     244    vm_page_lock(page);
     245    vm_page_unwire(page, PQ_ACTIVE);
     246    vm_page_unhold(page);
     247    vm_page_unlock(page);
     248}
     249
     250#define copy_highpage(to, from) pmap_copy_page(from, to)
     251
     252static inline pgprot_t
     253vm_get_page_prot(unsigned long vm_flags)
     254{
     255    return (vm_flags & VM_PROT_ALL);
     256}
     257
     258extern int vm_insert_mixed(struct vm_area_struct *, unsigned long addr, pfn_t pfn);
     259
     260extern int
     261vm_insert_pfn(struct vm_area_struct *, unsigned long addr,
     262    unsigned long pfn);
     263
     264extern int
     265vm_insert_pfn_prot(struct vm_area_struct *, unsigned long addr,
     266    unsigned long pfn, pgprot_t pgprot);
     267
     268static inline vm_page_t
     269vmalloc_to_page(const void *addr)
     270{
     271    vm_paddr_t paddr;
     272
     273    paddr = pmap_kextract((vm_offset_t)addr);
     274    return (PHYS_TO_VM_PAGE(paddr));
     275}
     276
     277extern int is_vmalloc_addr(const void *addr);
     278
     279#endif                  /* _LINUX_MM_H_ */
  • new file headers/compatibility/linuxkpi/linux/mutex.h

    diff --git a/headers/compatibility/linuxkpi/linux/mutex.h b/headers/compatibility/linuxkpi/linux/mutex.h
    new file mode 100644
    index 0000000000..3a9f822e29
    - +  
     1#ifndef _LINUX_MUTEX_H_
     2#define _LINUX_MUTEX_H_
     3
     4#include <lock.h>
     5
     6typedef mutex mutex_t;
     7
     8#define mutex_lock_nested(_m, _s)   mutex_lock((_m))
     9#define mutex_lock_nest_lock(_m, _s)    mutex_lock((_m))
     10
     11#define mutex_init(_m) \
     12    mutex_init((_m), mutex_name(#_m))
     13
     14#define linux_mutex_init(m, name, flags)        \
     15    mutex_init_etc((m), (name), (flags))
     16
     17
     18#define linux_mutex_destroy(m)      \
     19    mutex_destroy((m))
     20
     21#endif                  /* _LINUX_MUTEX_H_ */
  • new file headers/compatibility/linuxkpi/linux/page.h

    diff --git a/headers/compatibility/linuxkpi/linux/page.h b/headers/compatibility/linuxkpi/linux/page.h
    new file mode 100644
    index 0000000000..0ac2824337
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_PAGE_H_
     32#define _LINUX_PAGE_H_
     33
     34#include <linux/types.h>
     35#include <linux/gfp.h>
     36
     37#include <freebsd/vm/vm.h>
     38
     39#include <KernelExport.h>
     40
     41#ifdef __cplusplus
     42extern "C" {
     43#endif
     44
     45#ifndef PAGE_SIZE
     46#include <kernel.h>
     47#define PAGE_SIZE B_PAGE_SIZE
     48#endif
     49
     50#define vm_memattr_t        uint32
     51#define VM_MEMATTR_DEFAULT  B_MTR_WB
     52typedef unsigned long linux_pte_t;
     53typedef unsigned long linux_pmd_t;
     54typedef unsigned long linux_pgd_t;
     55typedef unsigned long pgprot_t;
     56
     57#define page    vm_page
     58
     59#define LINUXKPI_PROT_VALID (1 << 4)
     60#define LINUXKPI_CACHE_MODE_SHIFT 3
     61
     62static inline pgprot_t
     63cachemode2protval(vm_memattr_t attr)
     64{
     65    return ((attr | LINUXKPI_PROT_VALID) << LINUXKPI_CACHE_MODE_SHIFT);
     66}
     67
     68static inline vm_memattr_t
     69pgprot2cachemode(pgprot_t prot)
     70{
     71    int val;
     72
     73    val = prot >> LINUXKPI_CACHE_MODE_SHIFT;
     74
     75    if (val & LINUXKPI_PROT_VALID)
     76        return (val & ~LINUXKPI_PROT_VALID);
     77    else
     78        return (VM_MEMATTR_DEFAULT);
     79}
     80
     81#define virt_to_page(x)     PHYS_TO_VM_PAGE(vtophys((x)))
     82#define page_to_pfn(pp)     (VM_PAGE_TO_PHYS((pp)) >> PAGE_SHIFT)
     83#define pfn_to_page(pfn)    (PHYS_TO_VM_PAGE((pfn) << PAGE_SHIFT))
     84#define nth_page(page,n)    pfn_to_page(page_to_pfn((page)) + (n))
     85
     86#define clear_page(page)        memset((page), 0, PAGE_SIZE)
     87#define pgprot_noncached(prot)      ((pgprot_t)VM_MEMATTR_UNCACHEABLE)
     88#define pgprot_writecombine(prot)   ((pgprot_t)VM_MEMATTR_WRITE_COMBINING)
     89
     90#undef  PAGE_MASK
     91#define PAGE_MASK   (~(PAGE_SIZE-1))
     92/*
     93 * Modifying PAGE_MASK in the above way breaks trunc_page, round_page,
     94 * and btoc macros. Therefore, redefine them in a way that makes sense
     95 * so the LinuxKPI consumers don't get totally broken behavior.
     96 */
     97#undef  btoc
     98#define btoc(x) (((vm_offset_t)(x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
     99#undef  round_page
     100#define round_page(x)   ((((uintptr_t)(x)) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
     101#undef  trunc_page
     102#define trunc_page(x)   ((uintptr_t)(x) & ~(PAGE_SIZE - 1))
     103
     104/*
     105 * Resolve a page into a virtual address:
     106 *
     107 * NOTE: This function only works for pages allocated by the kernel.
     108 */
     109extern void *linux_page_address(struct page *);
     110
     111#define page_address(page) linux_page_address(page)
     112
     113/*
     114 * Page management for unmapped pages:
     115 */
     116extern vm_page_t linux_alloc_pages(gfp_t flags, unsigned int order);
     117extern void linux_free_pages(vm_page_t page, unsigned int order);
     118
     119static inline struct page *
     120alloc_page(gfp_t flags)
     121{
     122
     123    return (linux_alloc_pages(flags, 0));
     124}
     125
     126static inline struct page *
     127alloc_pages(gfp_t flags, unsigned int order)
     128{
     129
     130    return (linux_alloc_pages(flags, order));
     131}
     132
     133static inline struct page *
     134alloc_pages_node(int node_id, gfp_t flags, unsigned int order)
     135{
     136
     137    return (linux_alloc_pages(flags, order));
     138}
     139
     140static inline void
     141__free_pages(struct page *page, unsigned int order)
     142{
     143
     144    linux_free_pages(page, order);
     145}
     146
     147static inline void
     148__free_page(struct page *page)
     149{
     150
     151    linux_free_pages(page, 0);
     152}
     153
     154/*
     155 * Page management for mapped pages:
     156 */
     157extern vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
     158extern void linux_free_kmem(vm_offset_t, unsigned int order);
     159
     160static inline vm_offset_t
     161get_zeroed_page(gfp_t flags)
     162{
     163
     164    return (linux_alloc_kmem(flags | __GFP_ZERO, 0));
     165}
     166
     167static inline vm_offset_t
     168__get_free_page(gfp_t flags)
     169{
     170
     171    return (linux_alloc_kmem(flags, 0));
     172}
     173
     174static inline vm_offset_t
     175__get_free_pages(gfp_t flags, unsigned int order)
     176{
     177
     178    return (linux_alloc_kmem(flags, order));
     179}
     180
     181static inline void
     182free_pages(uintptr_t addr, unsigned int order)
     183{
     184    if (addr == 0)
     185        return;
     186
     187    linux_free_kmem(addr, order);
     188}
     189
     190static inline void
     191free_page(uintptr_t addr)
     192{
     193    if (addr == 0)
     194        return;
     195
     196    linux_free_kmem(addr, 0);
     197}
     198
     199static inline bool
     200gfpflags_allow_blocking(const gfp_t gfp_flags)
     201{
     202    return ((gfp_flags & (M_WAITOK | M_NOWAIT)) == M_WAITOK);
     203}
     204
     205#define SetPageReserved(page)   do { } while (0)    /* NOP */
     206#define ClearPageReserved(page) do { } while (0)    /* NOP */
     207
     208#ifdef __cplusplus
     209}
     210#endif
     211
     212#endif  /* _LINUX_PAGE_H_ */
  • new file headers/compatibility/linuxkpi/linux/refcount.h

    diff --git a/headers/compatibility/linuxkpi/linux/refcount.h b/headers/compatibility/linuxkpi/linux/refcount.h
    new file mode 100644
    index 0000000000..f6cf619a19
    - +  
     1/*-
     2 * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
     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
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24 * SUCH DAMAGE.
     25 *
     26 * $FreeBSD$
     27 */
     28
     29#ifndef __SYS_REFCOUNT_H__
     30#define __SYS_REFCOUNT_H__
     31
     32// #include <sys/limits.h>
     33// #include <freebsd/machine/atomic.h>
     34#include <sys/types.h>
     35#include <limits.h>
     36
     37#ifdef _KERNEL
     38#include <freebsd/sys/systm.h>
     39#else
     40#define KASSERT(exp, msg)   /* */
     41#endif
     42
     43#define atomic_add_acq_int(value, addValue) __atomic_fetch_add((value), (addValue), __ATOMIC_ACQUIRE)
     44#define atomic_fetchadd_int(value, addValue) __atomic_fetch_add((value), (addValue), __ATOMIC_ACQUIRE)
     45
     46static __inline void
     47refcount_init(volatile int *count, int value)
     48{
     49
     50    *count = value;
     51}
     52
     53static __inline void
     54refcount_acquire(volatile int *count)
     55{
     56
     57    KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
     58    atomic_add_acq_int(count, 1);   
     59}
     60
     61static __inline int
     62refcount_release(volatile int *count)
     63{
     64    int old;
     65
     66    /* XXX: Should this have a rel membar? */
     67    old = atomic_fetchadd_int(count, -1);
     68    KASSERT(old > 0, ("negative refcount %p", count));
     69    return (old == 1);
     70}
     71
     72#endif  /* ! __SYS_REFCOUNT_H__ */
  • new file headers/compatibility/linuxkpi/linux/scatterlist.h

    diff --git a/headers/compatibility/linuxkpi/linux/scatterlist.h b/headers/compatibility/linuxkpi/linux/scatterlist.h
    new file mode 100644
    index 0000000000..86529b9ee4
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
     6 * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions
     11 * are met:
     12 * 1. Redistributions of source code must retain the above copyright
     13 *    notice unmodified, this list of conditions, and the following
     14 *    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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 *
     30 * $FreeBSD$
     31 */
     32#ifndef _LINUX_SCATTERLIST_H_
     33#define _LINUX_SCATTERLIST_H_
     34
     35#include <freebsd/sys/systm.h>
     36#include <linux/page.h>
     37#include <linux/slab.h>
     38#include <linux/mm.h>
     39
     40#ifdef __cplusplus
     41extern "C" {
     42#endif
     43
     44#ifndef min
     45#define min(a, b) ((a) < (b)) ? (a) : (b)
     46#endif
     47
     48struct scatterlist {
     49    unsigned long page_link;
     50#define SG_PAGE_LINK_CHAIN  0x1UL
     51#define SG_PAGE_LINK_LAST   0x2UL
     52#define SG_PAGE_LINK_MASK   0x3UL
     53    unsigned int offset;
     54    unsigned int length;
     55    dma_addr_t address;
     56};
     57
     58CTASSERT((sizeof(struct scatterlist) & SG_PAGE_LINK_MASK) == 0);
     59
     60struct sg_table {
     61    struct scatterlist *sgl;
     62    unsigned int nents;
     63    unsigned int orig_nents;
     64};
     65
     66struct sg_page_iter {
     67    struct scatterlist *sg;
     68    unsigned int sg_pgoffset;
     69    unsigned int maxents;
     70    struct {
     71        unsigned int nents;
     72        int pg_advance;
     73    } internal;
     74};
     75
     76#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
     77
     78#define SG_MAGIC        0x87654321UL
     79
     80#define sg_is_chain(sg)     ((sg)->page_link & SG_PAGE_LINK_CHAIN)
     81#define sg_is_last(sg)      ((sg)->page_link & SG_PAGE_LINK_LAST)
     82#define sg_chain_ptr(sg)    \
     83    ((struct scatterlist *) ((sg)->page_link & ~SG_PAGE_LINK_MASK))
     84
     85#define sg_dma_address(sg)  (sg)->address
     86#define sg_dma_len(sg)      (sg)->length
     87
     88#define for_each_sg_page(sgl, iter, nents, pgoffset)            \
     89    for (_sg_iter_init(sgl, iter, nents, pgoffset);         \
     90         (iter)->sg; _sg_iter_next(iter))
     91
     92#define for_each_sg(sglist, sg, sgmax, iter)                \
     93    for (iter = 0, sg = (sglist); iter < (sgmax); iter++, sg = sg_next(sg))
     94
     95typedef struct scatterlist *(sg_alloc_fn) (unsigned int, gfp_t);
     96typedef void (sg_free_fn) (struct scatterlist *, unsigned int);
     97
     98static inline void
     99sg_assign_page(struct scatterlist *sg, struct page *page)
     100{
     101    unsigned long page_link = sg->page_link & SG_PAGE_LINK_MASK;
     102
     103    sg->page_link = page_link | (unsigned long)page;
     104}
     105
     106static inline void
     107sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len,
     108    unsigned int offset)
     109{
     110    sg_assign_page(sg, page);
     111    sg->offset = offset;
     112    sg->length = len;
     113}
     114
     115static inline struct page *
     116sg_page(struct scatterlist *sg)
     117{
     118    return ((struct page *)((sg)->page_link & ~SG_PAGE_LINK_MASK));
     119}
     120
     121static inline void
     122sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen)
     123{
     124    sg_set_page(sg, virt_to_page(buf), buflen,
     125        ((uintptr_t)buf) & (PAGE_SIZE - 1));
     126}
     127
     128static inline struct scatterlist *
     129sg_next(struct scatterlist *sg)
     130{
     131    if (sg_is_last(sg))
     132        return (NULL);
     133    sg++;
     134    if (sg_is_chain(sg))
     135        sg = sg_chain_ptr(sg);
     136    return (sg);
     137}
     138
     139static inline vm_paddr_t
     140sg_phys(struct scatterlist *sg)
     141{
     142    return (VM_PAGE_TO_PHYS(sg_page(sg)) + sg->offset);
     143}
     144
     145static inline void
     146sg_chain(struct scatterlist *prv, unsigned int prv_nents,
     147    struct scatterlist *sgl)
     148{
     149    struct scatterlist *sg = &prv[prv_nents - 1];
     150
     151    sg->offset = 0;
     152    sg->length = 0;
     153    sg->page_link = ((unsigned long)sgl |
     154        SG_PAGE_LINK_CHAIN) & ~SG_PAGE_LINK_LAST;
     155}
     156
     157static inline void
     158sg_mark_end(struct scatterlist *sg)
     159{
     160    sg->page_link |= SG_PAGE_LINK_LAST;
     161    sg->page_link &= ~SG_PAGE_LINK_CHAIN;
     162}
     163
     164static inline void
     165sg_init_table(struct scatterlist *sg, unsigned int nents)
     166{
     167    bzero(sg, sizeof(*sg) * nents);
     168    sg_mark_end(&sg[nents - 1]);
     169}
     170
     171static struct scatterlist *
     172sg_kmalloc(unsigned int nents, gfp_t gfp_mask)
     173{
     174    if (nents == SG_MAX_SINGLE_ALLOC) {
     175        return ((scatterlist *)__get_free_page(gfp_mask));
     176    } else
     177        return (scatterlist *)(kmalloc(nents * sizeof(struct scatterlist), gfp_mask));
     178}
     179
     180static inline void
     181sg_kfree(struct scatterlist *sg, unsigned int nents)
     182{
     183    if (nents == SG_MAX_SINGLE_ALLOC) {
     184        free_page((unsigned long)sg);
     185    } else
     186        kfree(sg);
     187}
     188
     189static inline void
     190__sg_free_table(struct sg_table *table, unsigned int max_ents,
     191    bool skip_first_chunk, sg_free_fn * free_fn)
     192{
     193    struct scatterlist *sgl, *next;
     194
     195    if (unlikely(!table->sgl))
     196        return;
     197
     198    sgl = table->sgl;
     199    while (table->orig_nents) {
     200        unsigned int alloc_size = table->orig_nents;
     201        unsigned int sg_size;
     202
     203        if (alloc_size > max_ents) {
     204            next = sg_chain_ptr(&sgl[max_ents - 1]);
     205            alloc_size = max_ents;
     206            sg_size = alloc_size - 1;
     207        } else {
     208            sg_size = alloc_size;
     209            next = NULL;
     210        }
     211
     212        table->orig_nents -= sg_size;
     213        if (skip_first_chunk)
     214            skip_first_chunk = 0;
     215        else
     216            free_fn(sgl, alloc_size);
     217        sgl = next;
     218    }
     219
     220    table->sgl = NULL;
     221}
     222
     223static inline void
     224sg_free_table(struct sg_table *table)
     225{
     226    __sg_free_table(table, SG_MAX_SINGLE_ALLOC, 0, sg_kfree);
     227}
     228
     229static inline int
     230__sg_alloc_table(struct sg_table *table, unsigned int nents,
     231    unsigned int max_ents, struct scatterlist *first_chunk,
     232    gfp_t gfp_mask, sg_alloc_fn *alloc_fn)
     233{
     234    struct scatterlist *sg, *prv;
     235    unsigned int left;
     236
     237    memset(table, 0, sizeof(*table));
     238
     239    if (nents == 0)
     240        return (-EINVAL);
     241    left = nents;
     242    prv = NULL;
     243    do {
     244        unsigned int sg_size;
     245        unsigned int alloc_size = left;
     246
     247        if (alloc_size > max_ents) {
     248            alloc_size = max_ents;
     249            sg_size = alloc_size - 1;
     250        } else
     251            sg_size = alloc_size;
     252
     253        left -= sg_size;
     254
     255        if (first_chunk) {
     256            sg = first_chunk;
     257            first_chunk = NULL;
     258        } else {
     259            sg = alloc_fn(alloc_size, gfp_mask);
     260        }
     261        if (unlikely(!sg)) {
     262            if (prv)
     263                table->nents = ++table->orig_nents;
     264            return (ENOMEM);
     265        }
     266        sg_init_table(sg, alloc_size);
     267        table->nents = table->orig_nents += sg_size;
     268
     269        if (prv)
     270            sg_chain(prv, max_ents, sg);
     271        else
     272            table->sgl = sg;
     273
     274        if (!left)
     275            sg_mark_end(&sg[sg_size - 1]);
     276
     277        prv = sg;
     278    } while (left);
     279
     280    return (0);
     281}
     282
     283static inline int
     284sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
     285{
     286    int ret;
     287
     288    ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC,
     289        NULL, gfp_mask, sg_kmalloc);
     290    if (unlikely(ret))
     291        __sg_free_table(table, SG_MAX_SINGLE_ALLOC, 0, sg_kfree);
     292
     293    return (ret);
     294}
     295
     296static inline int
     297sg_alloc_table_from_pages(struct sg_table *sgt,
     298    struct page **pages, unsigned int count,
     299    unsigned long off, unsigned long size,
     300    gfp_t gfp_mask)
     301{
     302    unsigned int i, segs, cur;
     303    int rc;
     304    struct scatterlist *s;
     305
     306    for (segs = i = 1; i < count; ++i) {
     307        if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
     308            ++segs;
     309    }
     310    if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask))))
     311        return (rc);
     312
     313    cur = 0;
     314    for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
     315        unsigned long seg_size;
     316        unsigned int j;
     317
     318        for (j = cur + 1; j < count; ++j)
     319            if (page_to_pfn(pages[j]) !=
     320                page_to_pfn(pages[j - 1]) + 1)
     321                break;
     322
     323        seg_size = ((j - cur) << PAGE_SHIFT) - off;
     324        sg_set_page(s, pages[cur], min(size, seg_size), off);
     325        size -= seg_size;
     326        off = 0;
     327        cur = j;
     328    }
     329    return (0);
     330}
     331
     332
     333static inline int
     334sg_nents(struct scatterlist *sg)
     335{
     336    int nents;
     337
     338    for (nents = 0; sg; sg = sg_next(sg))
     339        nents++;
     340    return (nents);
     341}
     342
     343static inline void
     344__sg_page_iter_start(struct sg_page_iter *piter,
     345    struct scatterlist *sglist, unsigned int nents,
     346    unsigned long pgoffset)
     347{
     348    piter->internal.pg_advance = 0;
     349    piter->internal.nents = nents;
     350
     351    piter->sg = sglist;
     352    piter->sg_pgoffset = pgoffset;
     353}
     354
     355static inline void
     356_sg_iter_next(struct sg_page_iter *iter)
     357{
     358    struct scatterlist *sg;
     359    unsigned int pgcount;
     360
     361    sg = iter->sg;
     362    pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
     363
     364    ++iter->sg_pgoffset;
     365    while (iter->sg_pgoffset >= pgcount) {
     366        iter->sg_pgoffset -= pgcount;
     367        sg = sg_next(sg);
     368        --iter->maxents;
     369        if (sg == NULL || iter->maxents == 0)
     370            break;
     371        pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
     372    }
     373    iter->sg = sg;
     374}
     375
     376static inline int
     377sg_page_count(struct scatterlist *sg)
     378{
     379    return (PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT);
     380}
     381
     382static inline bool
     383__sg_page_iter_next(struct sg_page_iter *piter)
     384{
     385    if (piter->internal.nents == 0)
     386        return (0);
     387    if (piter->sg == NULL)
     388        return (0);
     389
     390    piter->sg_pgoffset += piter->internal.pg_advance;
     391    piter->internal.pg_advance = 1;
     392
     393    while (piter->sg_pgoffset >= (unsigned int)sg_page_count(piter->sg)) {
     394        piter->sg_pgoffset -= sg_page_count(piter->sg);
     395        piter->sg = sg_next(piter->sg);
     396        if (--piter->internal.nents == 0)
     397            return (0);
     398        if (piter->sg == NULL)
     399            return (0);
     400    }
     401    return (1);
     402}
     403
     404static inline void
     405_sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
     406    unsigned int nents, unsigned long pgoffset)
     407{
     408    if (nents) {
     409        iter->sg = sgl;
     410        iter->sg_pgoffset = pgoffset - 1;
     411        iter->maxents = nents;
     412        _sg_iter_next(iter);
     413    } else {
     414        iter->sg = NULL;
     415        iter->sg_pgoffset = 0;
     416        iter->maxents = 0;
     417    }
     418}
     419
     420static inline dma_addr_t
     421sg_page_iter_dma_address(struct sg_page_iter *spi)
     422{
     423    return (spi->sg->address + (spi->sg_pgoffset << PAGE_SHIFT));
     424}
     425
     426static inline struct page *
     427sg_page_iter_page(struct sg_page_iter *piter)
     428{
     429    return (nth_page(sg_page(piter->sg), piter->sg_pgoffset));
     430}
     431
     432#ifdef __cplusplus
     433}
     434#endif
     435
     436#endif                  /* _LINUX_SCATTERLIST_H_ */
  • new file headers/compatibility/linuxkpi/linux/slab.h

    diff --git a/headers/compatibility/linuxkpi/linux/slab.h b/headers/compatibility/linuxkpi/linux/slab.h
    new file mode 100644
    index 0000000000..3bc11420dd
    - +  
     1#ifndef _LINUX_SLAB_H_
     2#define _LINUX_SLAB_H_
     3
     4#include <linux/gfp.h>
     5#include <linux/types.h>
     6
     7#include <malloc.h>
     8
     9#define kvmalloc(size)          kmalloc(size, GFP_KERNEL)
     10#define kzalloc(size, flags)        kmalloc(size, (flags) | __GFP_ZERO)
     11#define kzalloc_node(size, flags, node) kmalloc(size, (flags) | __GFP_ZERO)
     12#define kfree_const(ptr)        kfree(ptr)
     13#define kcalloc(n, size, flags)     kmalloc((n) * (size), (flags) | __GFP_ZERO)
     14#define vzalloc(size)           __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0)
     15#define vfree(arg)          kfree(arg)
     16#define kvfree(arg)         kfree(arg)
     17#define vmalloc_node(size, node)        __vmalloc(size, GFP_KERNEL, 0)
     18#define vmalloc_user(size)              __vmalloc(size, GFP_KERNEL | __GFP_ZERO, 0)
     19#define vmalloc(size)                   __vmalloc(size, GFP_KERNEL, 0)
     20#define __kmalloc(...)          kmalloc(__VA_ARGS__)
     21#define kmalloc_node(chunk, flags, n)   kmalloc(chunk, flags)
     22
     23extern void *kmalloc(size_t size, int flags);
     24extern void *krealloc(void *ptr, size_t size, int flags);
     25extern void kfree(const void *ptr);
     26
     27static inline void *
     28__vmalloc(size_t size, int flags, int other)
     29{
     30    return (malloc(size));
     31}
     32
     33static inline void *
     34vmalloc_32(size_t size)
     35{
     36    return (malloc(size));
     37}
     38
     39static inline void *
     40kmalloc_array(size_t n, size_t size, int flags)
     41{
     42    return (kmalloc(n * size, flags));
     43}
     44
     45#endif  /* _LINUX_SLAB_H_ */
  • new file headers/compatibility/linuxkpi/linux/types.h

    diff --git a/headers/compatibility/linuxkpi/linux/types.h b/headers/compatibility/linuxkpi/linux/types.h
    new file mode 100644
    index 0000000000..3cdd1c19bd
    - +  
     1/*-
     2 * Copyright (c) 2010 Isilon Systems, Inc.
     3 * Copyright (c) 2010 iX Systems, Inc.
     4 * Copyright (c) 2010 Panasas, Inc.
     5 * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
     6 * All rights reserved.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice unmodified, this list of conditions, and the following
     13 *    disclaimer.
     14 * 2. Redistributions in binary form must reproduce the above copyright
     15 *    notice, this list of conditions and the following disclaimer in the
     16 *    documentation and/or other materials provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _LINUX_TYPES_H_
     32#define _LINUX_TYPES_H_
     33
     34#include <linux/compiler.h>
     35#include <asm/types.h>
     36#include <freebsd/sys/cdefs.h>
     37
     38#ifndef __bitwise__
     39#ifdef __CHECKER__
     40#define __bitwise__ __attribute__((bitwise))
     41#else
     42#define __bitwise__
     43#endif
     44#endif
     45
     46#define major(x)    0
     47#define minor(x)    0
     48#define makedev(x,y)    0
     49
     50typedef uint16_t __le16;
     51typedef uint16_t __be16;
     52typedef uint32_t __le32;
     53typedef uint32_t __be32;
     54typedef uint64_t __le64;
     55typedef uint64_t __be64;
     56
     57typedef unsigned int    uint;
     58typedef unsigned gfp_t;
     59typedef uint64_t loff_t;
     60typedef vm_paddr_t resource_size_t;
     61typedef uint16_t __bitwise__ __sum16;
     62typedef unsigned long pgoff_t;
     63
     64typedef u64 phys_addr_t;
     65
     66#define DECLARE_BITMAP(n, bits)                     \
     67    unsigned long n[howmany(bits, sizeof(long) * 8)]
     68
     69typedef unsigned long irq_hw_number_t;
     70
     71struct rcu_head {
     72    void *raw[2];
     73} __aligned(sizeof(void *));
     74
     75typedef void (*rcu_callback_t)(struct rcu_head *head);
     76typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
     77typedef int linux_task_fn_t(void *data);
     78
     79#endif  /* _LINUX_TYPES_H_ */
     80   
     81 No newline at end of file
  • src/add-ons/kernel/drivers/graphics/Jamfile

    diff --git a/headers/private/graphics/3dfx/DriverInterface.h b/headers/private/graphics/non-drm/3dfx/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/3dfx/DriverInterface.h
    rename to headers/private/graphics/non-drm/3dfx/DriverInterface.h
    diff --git a/headers/private/graphics/AGP.h b/headers/private/graphics/non-drm/AGP.h
    similarity index 100%
    rename from headers/private/graphics/AGP.h
    rename to headers/private/graphics/non-drm/AGP.h
    diff --git a/headers/private/graphics/ati/DriverInterface.h b/headers/private/graphics/non-drm/ati/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/ati/DriverInterface.h
    rename to headers/private/graphics/non-drm/ati/DriverInterface.h
    diff --git a/headers/private/graphics/common/benaphore.h b/headers/private/graphics/non-drm/common/benaphore.h
    similarity index 100%
    rename from headers/private/graphics/common/benaphore.h
    rename to headers/private/graphics/non-drm/common/benaphore.h
    diff --git a/headers/private/graphics/common/bendian_bitfield.h b/headers/private/graphics/non-drm/common/bendian_bitfield.h
    similarity index 100%
    rename from headers/private/graphics/common/bendian_bitfield.h
    rename to headers/private/graphics/non-drm/common/bendian_bitfield.h
    diff --git a/headers/private/graphics/common/compute_display_timing.h b/headers/private/graphics/non-drm/common/compute_display_timing.h
    similarity index 100%
    rename from headers/private/graphics/common/compute_display_timing.h
    rename to headers/private/graphics/non-drm/common/compute_display_timing.h
    diff --git a/headers/private/graphics/common/create_display_modes.h b/headers/private/graphics/non-drm/common/create_display_modes.h
    similarity index 100%
    rename from headers/private/graphics/common/create_display_modes.h
    rename to headers/private/graphics/non-drm/common/create_display_modes.h
    diff --git a/headers/private/graphics/common/ddc.h b/headers/private/graphics/non-drm/common/ddc.h
    similarity index 100%
    rename from headers/private/graphics/common/ddc.h
    rename to headers/private/graphics/non-drm/common/ddc.h
    diff --git a/headers/private/graphics/common/debug_ext.h b/headers/private/graphics/non-drm/common/debug_ext.h
    similarity index 100%
    rename from headers/private/graphics/common/debug_ext.h
    rename to headers/private/graphics/non-drm/common/debug_ext.h
    diff --git a/headers/private/graphics/common/dp.h b/headers/private/graphics/non-drm/common/dp.h
    similarity index 100%
    rename from headers/private/graphics/common/dp.h
    rename to headers/private/graphics/non-drm/common/dp.h
    diff --git a/headers/private/graphics/common/dp_raw.h b/headers/private/graphics/non-drm/common/dp_raw.h
    similarity index 100%
    rename from headers/private/graphics/common/dp_raw.h
    rename to headers/private/graphics/non-drm/common/dp_raw.h
    diff --git a/headers/private/graphics/common/edid.h b/headers/private/graphics/non-drm/common/edid.h
    similarity index 100%
    rename from headers/private/graphics/common/edid.h
    rename to headers/private/graphics/non-drm/common/edid.h
    diff --git a/headers/private/graphics/common/edid_raw.h b/headers/private/graphics/non-drm/common/edid_raw.h
    similarity index 100%
    rename from headers/private/graphics/common/edid_raw.h
    rename to headers/private/graphics/non-drm/common/edid_raw.h
    diff --git a/headers/private/graphics/common/i2c.h b/headers/private/graphics/non-drm/common/i2c.h
    similarity index 100%
    rename from headers/private/graphics/common/i2c.h
    rename to headers/private/graphics/non-drm/common/i2c.h
    diff --git a/headers/private/graphics/common/lendian_bitfield.h b/headers/private/graphics/non-drm/common/lendian_bitfield.h
    similarity index 100%
    rename from headers/private/graphics/common/lendian_bitfield.h
    rename to headers/private/graphics/non-drm/common/lendian_bitfield.h
    diff --git a/headers/private/graphics/common/log_coll.h b/headers/private/graphics/non-drm/common/log_coll.h
    similarity index 100%
    rename from headers/private/graphics/common/log_coll.h
    rename to headers/private/graphics/non-drm/common/log_coll.h
    diff --git a/headers/private/graphics/common/memory_manager.h b/headers/private/graphics/non-drm/common/memory_manager.h
    similarity index 100%
    rename from headers/private/graphics/common/memory_manager.h
    rename to headers/private/graphics/non-drm/common/memory_manager.h
    diff --git a/headers/private/graphics/common/validate_display_mode.h b/headers/private/graphics/non-drm/common/validate_display_mode.h
    similarity index 100%
    rename from headers/private/graphics/common/validate_display_mode.h
    rename to headers/private/graphics/non-drm/common/validate_display_mode.h
    diff --git a/headers/private/graphics/common/video_configuration.h b/headers/private/graphics/non-drm/common/video_configuration.h
    similarity index 100%
    rename from headers/private/graphics/common/video_configuration.h
    rename to headers/private/graphics/non-drm/common/video_configuration.h
    diff --git a/headers/private/graphics/et6x00/DriverInterface.h b/headers/private/graphics/non-drm/et6x00/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/et6x00/DriverInterface.h
    rename to headers/private/graphics/non-drm/et6x00/DriverInterface.h
    diff --git a/headers/private/graphics/intel_810/DriverInterface.h b/headers/private/graphics/non-drm/intel_810/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/intel_810/DriverInterface.h
    rename to headers/private/graphics/non-drm/intel_810/DriverInterface.h
    diff --git a/headers/private/graphics/intel_extreme/AreaKeeper.h b/headers/private/graphics/non-drm/intel_extreme/AreaKeeper.h
    similarity index 100%
    rename from headers/private/graphics/intel_extreme/AreaKeeper.h
    rename to headers/private/graphics/non-drm/intel_extreme/AreaKeeper.h
    diff --git a/headers/private/graphics/intel_extreme/intel_extreme.h b/headers/private/graphics/non-drm/intel_extreme/intel_extreme.h
    similarity index 100%
    rename from headers/private/graphics/intel_extreme/intel_extreme.h
    rename to headers/private/graphics/non-drm/intel_extreme/intel_extreme.h
    diff --git a/headers/private/graphics/intel_extreme/lock.h b/headers/private/graphics/non-drm/intel_extreme/lock.h
    similarity index 100%
    rename from headers/private/graphics/intel_extreme/lock.h
    rename to headers/private/graphics/non-drm/intel_extreme/lock.h
    diff --git a/headers/private/graphics/intel_extreme/utility.h b/headers/private/graphics/non-drm/intel_extreme/utility.h
    similarity index 100%
    rename from headers/private/graphics/intel_extreme/utility.h
    rename to headers/private/graphics/non-drm/intel_extreme/utility.h
    diff --git a/headers/private/graphics/matrox/DriverInterface.h b/headers/private/graphics/non-drm/matrox/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/matrox/DriverInterface.h
    rename to headers/private/graphics/non-drm/matrox/DriverInterface.h
    diff --git a/headers/private/graphics/matrox/mga_macros.h b/headers/private/graphics/non-drm/matrox/mga_macros.h
    similarity index 100%
    rename from headers/private/graphics/matrox/mga_macros.h
    rename to headers/private/graphics/non-drm/matrox/mga_macros.h
    diff --git a/headers/private/graphics/neomagic/DriverInterface.h b/headers/private/graphics/non-drm/neomagic/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/neomagic/DriverInterface.h
    rename to headers/private/graphics/non-drm/neomagic/DriverInterface.h
    diff --git a/headers/private/graphics/neomagic/nm_macros.h b/headers/private/graphics/non-drm/neomagic/nm_macros.h
    similarity index 100%
    rename from headers/private/graphics/neomagic/nm_macros.h
    rename to headers/private/graphics/non-drm/neomagic/nm_macros.h
    diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/non-drm/nvidia/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/nvidia/DriverInterface.h
    rename to headers/private/graphics/non-drm/nvidia/DriverInterface.h
    diff --git a/headers/private/graphics/nvidia/nv_acc.h b/headers/private/graphics/non-drm/nvidia/nv_acc.h
    similarity index 100%
    rename from headers/private/graphics/nvidia/nv_acc.h
    rename to headers/private/graphics/non-drm/nvidia/nv_acc.h
    diff --git a/headers/private/graphics/nvidia/nv_macros.h b/headers/private/graphics/non-drm/nvidia/nv_macros.h
    similarity index 100%
    rename from headers/private/graphics/nvidia/nv_macros.h
    rename to headers/private/graphics/non-drm/nvidia/nv_macros.h
    diff --git a/headers/private/graphics/nvidia_gpgpu/DriverInterface.h b/headers/private/graphics/non-drm/nvidia_gpgpu/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/nvidia_gpgpu/DriverInterface.h
    rename to headers/private/graphics/non-drm/nvidia_gpgpu/DriverInterface.h
    diff --git a/headers/private/graphics/nvidia_gpgpu/nv_acc.h b/headers/private/graphics/non-drm/nvidia_gpgpu/nv_acc.h
    similarity index 100%
    rename from headers/private/graphics/nvidia_gpgpu/nv_acc.h
    rename to headers/private/graphics/non-drm/nvidia_gpgpu/nv_acc.h
    diff --git a/headers/private/graphics/nvidia_gpgpu/nv_macros.h b/headers/private/graphics/non-drm/nvidia_gpgpu/nv_macros.h
    similarity index 100%
    rename from headers/private/graphics/nvidia_gpgpu/nv_macros.h
    rename to headers/private/graphics/non-drm/nvidia_gpgpu/nv_macros.h
    diff --git a/headers/private/graphics/omap/omap3_regs.h b/headers/private/graphics/non-drm/omap/omap3_regs.h
    similarity index 100%
    rename from headers/private/graphics/omap/omap3_regs.h
    rename to headers/private/graphics/non-drm/omap/omap3_regs.h
    diff --git a/headers/private/graphics/radeon/2d_regs.h b/headers/private/graphics/non-drm/radeon/2d_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/2d_regs.h
    rename to headers/private/graphics/non-drm/radeon/2d_regs.h
    diff --git a/headers/private/graphics/radeon/3d_regs.h b/headers/private/graphics/non-drm/radeon/3d_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/3d_regs.h
    rename to headers/private/graphics/non-drm/radeon/3d_regs.h
    diff --git a/headers/private/graphics/radeon/accelerant_ext.h b/headers/private/graphics/non-drm/radeon/accelerant_ext.h
    similarity index 100%
    rename from headers/private/graphics/radeon/accelerant_ext.h
    rename to headers/private/graphics/non-drm/radeon/accelerant_ext.h
    diff --git a/headers/private/graphics/radeon/bios_regs.h b/headers/private/graphics/non-drm/radeon/bios_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/bios_regs.h
    rename to headers/private/graphics/non-drm/radeon/bios_regs.h
    diff --git a/headers/private/graphics/radeon/buscntrl_regs.h b/headers/private/graphics/non-drm/radeon/buscntrl_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/buscntrl_regs.h
    rename to headers/private/graphics/non-drm/radeon/buscntrl_regs.h
    diff --git a/headers/private/graphics/radeon/capture_regs.h b/headers/private/graphics/non-drm/radeon/capture_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/capture_regs.h
    rename to headers/private/graphics/non-drm/radeon/capture_regs.h
    diff --git a/headers/private/graphics/radeon/config_regs.h b/headers/private/graphics/non-drm/radeon/config_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/config_regs.h
    rename to headers/private/graphics/non-drm/radeon/config_regs.h
    diff --git a/headers/private/graphics/radeon/cp_regs.h b/headers/private/graphics/non-drm/radeon/cp_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/cp_regs.h
    rename to headers/private/graphics/non-drm/radeon/cp_regs.h
    diff --git a/headers/private/graphics/radeon/crtc_regs.h b/headers/private/graphics/non-drm/radeon/crtc_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/crtc_regs.h
    rename to headers/private/graphics/non-drm/radeon/crtc_regs.h
    diff --git a/headers/private/graphics/radeon/dac_regs.h b/headers/private/graphics/non-drm/radeon/dac_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/dac_regs.h
    rename to headers/private/graphics/non-drm/radeon/dac_regs.h
    diff --git a/headers/private/graphics/radeon/ddc_regs.h b/headers/private/graphics/non-drm/radeon/ddc_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/ddc_regs.h
    rename to headers/private/graphics/non-drm/radeon/ddc_regs.h
    diff --git a/headers/private/graphics/radeon/dma_regs.h b/headers/private/graphics/non-drm/radeon/dma_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/dma_regs.h
    rename to headers/private/graphics/non-drm/radeon/dma_regs.h
    diff --git a/headers/private/graphics/radeon/fp_regs.h b/headers/private/graphics/non-drm/radeon/fp_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/fp_regs.h
    rename to headers/private/graphics/non-drm/radeon/fp_regs.h
    diff --git a/headers/private/graphics/radeon/gpiopad_regs.h b/headers/private/graphics/non-drm/radeon/gpiopad_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/gpiopad_regs.h
    rename to headers/private/graphics/non-drm/radeon/gpiopad_regs.h
    diff --git a/headers/private/graphics/radeon/log_enum.h b/headers/private/graphics/non-drm/radeon/log_enum.h
    similarity index 100%
    rename from headers/private/graphics/radeon/log_enum.h
    rename to headers/private/graphics/non-drm/radeon/log_enum.h
    diff --git a/headers/private/graphics/radeon/log_names.h b/headers/private/graphics/non-drm/radeon/log_names.h
    similarity index 100%
    rename from headers/private/graphics/radeon/log_names.h
    rename to headers/private/graphics/non-drm/radeon/log_names.h
    diff --git a/headers/private/graphics/radeon/memcntrl_regs.h b/headers/private/graphics/non-drm/radeon/memcntrl_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/memcntrl_regs.h
    rename to headers/private/graphics/non-drm/radeon/memcntrl_regs.h
    diff --git a/headers/private/graphics/radeon/mmio.h b/headers/private/graphics/non-drm/radeon/mmio.h
    similarity index 100%
    rename from headers/private/graphics/radeon/mmio.h
    rename to headers/private/graphics/non-drm/radeon/mmio.h
    diff --git a/headers/private/graphics/radeon/multimon.h b/headers/private/graphics/non-drm/radeon/multimon.h
    similarity index 100%
    rename from headers/private/graphics/radeon/multimon.h
    rename to headers/private/graphics/non-drm/radeon/multimon.h
    diff --git a/headers/private/graphics/radeon/overlay_regs.h b/headers/private/graphics/non-drm/radeon/overlay_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/overlay_regs.h
    rename to headers/private/graphics/non-drm/radeon/overlay_regs.h
    diff --git a/headers/private/graphics/radeon/pll_access.h b/headers/private/graphics/non-drm/radeon/pll_access.h
    similarity index 100%
    rename from headers/private/graphics/radeon/pll_access.h
    rename to headers/private/graphics/non-drm/radeon/pll_access.h
    diff --git a/headers/private/graphics/radeon/pll_regs.h b/headers/private/graphics/non-drm/radeon/pll_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/pll_regs.h
    rename to headers/private/graphics/non-drm/radeon/pll_regs.h
    diff --git a/headers/private/graphics/radeon/radeon_bios.h b/headers/private/graphics/non-drm/radeon/radeon_bios.h
    similarity index 100%
    rename from headers/private/graphics/radeon/radeon_bios.h
    rename to headers/private/graphics/non-drm/radeon/radeon_bios.h
    diff --git a/headers/private/graphics/radeon/radeon_interface.h b/headers/private/graphics/non-drm/radeon/radeon_interface.h
    similarity index 100%
    rename from headers/private/graphics/radeon/radeon_interface.h
    rename to headers/private/graphics/non-drm/radeon/radeon_interface.h
    diff --git a/headers/private/graphics/radeon/radeon_regs.h b/headers/private/graphics/non-drm/radeon/radeon_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/radeon_regs.h
    rename to headers/private/graphics/non-drm/radeon/radeon_regs.h
    diff --git a/headers/private/graphics/radeon/rbbm_regs.h b/headers/private/graphics/non-drm/radeon/rbbm_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/rbbm_regs.h
    rename to headers/private/graphics/non-drm/radeon/rbbm_regs.h
    diff --git a/headers/private/graphics/radeon/theatre_regs.h b/headers/private/graphics/non-drm/radeon/theatre_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/theatre_regs.h
    rename to headers/private/graphics/non-drm/radeon/theatre_regs.h
    diff --git a/headers/private/graphics/radeon/tv_out_regs.h b/headers/private/graphics/non-drm/radeon/tv_out_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/tv_out_regs.h
    rename to headers/private/graphics/non-drm/radeon/tv_out_regs.h
    diff --git a/headers/private/graphics/radeon/utils.h b/headers/private/graphics/non-drm/radeon/utils.h
    similarity index 100%
    rename from headers/private/graphics/radeon/utils.h
    rename to headers/private/graphics/non-drm/radeon/utils.h
    diff --git a/headers/private/graphics/radeon/version.h b/headers/private/graphics/non-drm/radeon/version.h
    similarity index 100%
    rename from headers/private/graphics/radeon/version.h
    rename to headers/private/graphics/non-drm/radeon/version.h
    diff --git a/headers/private/graphics/radeon/vip_regs.h b/headers/private/graphics/non-drm/radeon/vip_regs.h
    similarity index 100%
    rename from headers/private/graphics/radeon/vip_regs.h
    rename to headers/private/graphics/non-drm/radeon/vip_regs.h
    diff --git a/headers/private/graphics/radeon_hd/AreaKeeper.h b/headers/private/graphics/non-drm/radeon_hd/AreaKeeper.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/AreaKeeper.h
    rename to headers/private/graphics/non-drm/radeon_hd/AreaKeeper.h
    diff --git a/headers/private/graphics/radeon_hd/avivo_reg.h b/headers/private/graphics/non-drm/radeon_hd/avivo_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/avivo_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/avivo_reg.h
    diff --git a/headers/private/graphics/radeon_hd/car_reg.h b/headers/private/graphics/non-drm/radeon_hd/car_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/car_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/car_reg.h
    diff --git a/headers/private/graphics/radeon_hd/evergreen_reg.h b/headers/private/graphics/non-drm/radeon_hd/evergreen_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/evergreen_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/evergreen_reg.h
    diff --git a/headers/private/graphics/radeon_hd/lock.h b/headers/private/graphics/non-drm/radeon_hd/lock.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/lock.h
    rename to headers/private/graphics/non-drm/radeon_hd/lock.h
    diff --git a/headers/private/graphics/radeon_hd/ni_reg.h b/headers/private/graphics/non-drm/radeon_hd/ni_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/ni_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/ni_reg.h
    diff --git a/headers/private/graphics/radeon_hd/r500_reg.h b/headers/private/graphics/non-drm/radeon_hd/r500_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/r500_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/r500_reg.h
    diff --git a/headers/private/graphics/radeon_hd/r600_reg.h b/headers/private/graphics/non-drm/radeon_hd/r600_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/r600_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/r600_reg.h
    diff --git a/headers/private/graphics/radeon_hd/r700_reg.h b/headers/private/graphics/non-drm/radeon_hd/r700_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/r700_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/r700_reg.h
    diff --git a/headers/private/graphics/radeon_hd/radeon_hd.h b/headers/private/graphics/non-drm/radeon_hd/radeon_hd.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/radeon_hd.h
    rename to headers/private/graphics/non-drm/radeon_hd/radeon_hd.h
    diff --git a/headers/private/graphics/radeon_hd/radeon_reg.h b/headers/private/graphics/non-drm/radeon_hd/radeon_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/radeon_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/radeon_reg.h
    diff --git a/headers/private/graphics/radeon_hd/sea_reg.h b/headers/private/graphics/non-drm/radeon_hd/sea_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/sea_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/sea_reg.h
    diff --git a/headers/private/graphics/radeon_hd/si_reg.h b/headers/private/graphics/non-drm/radeon_hd/si_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/si_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/si_reg.h
    diff --git a/headers/private/graphics/radeon_hd/utility.h b/headers/private/graphics/non-drm/radeon_hd/utility.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/utility.h
    rename to headers/private/graphics/non-drm/radeon_hd/utility.h
    diff --git a/headers/private/graphics/radeon_hd/vol_reg.h b/headers/private/graphics/non-drm/radeon_hd/vol_reg.h
    similarity index 100%
    rename from headers/private/graphics/radeon_hd/vol_reg.h
    rename to headers/private/graphics/non-drm/radeon_hd/vol_reg.h
    diff --git a/headers/private/graphics/s3/DriverInterface.h b/headers/private/graphics/non-drm/s3/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/s3/DriverInterface.h
    rename to headers/private/graphics/non-drm/s3/DriverInterface.h
    diff --git a/headers/private/graphics/skeleton/DriverInterface.h b/headers/private/graphics/non-drm/skeleton/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/skeleton/DriverInterface.h
    rename to headers/private/graphics/non-drm/skeleton/DriverInterface.h
    diff --git a/headers/private/graphics/skeleton/macros.h b/headers/private/graphics/non-drm/skeleton/macros.h
    similarity index 100%
    rename from headers/private/graphics/skeleton/macros.h
    rename to headers/private/graphics/non-drm/skeleton/macros.h
    diff --git a/headers/private/graphics/vesa/utility.h b/headers/private/graphics/non-drm/vesa/utility.h
    similarity index 100%
    rename from headers/private/graphics/vesa/utility.h
    rename to headers/private/graphics/non-drm/vesa/utility.h
    diff --git a/headers/private/graphics/vesa/vesa.h b/headers/private/graphics/non-drm/vesa/vesa.h
    similarity index 100%
    rename from headers/private/graphics/vesa/vesa.h
    rename to headers/private/graphics/non-drm/vesa/vesa.h
    diff --git a/headers/private/graphics/vesa/vesa_info.h b/headers/private/graphics/non-drm/vesa/vesa_info.h
    similarity index 100%
    rename from headers/private/graphics/vesa/vesa_info.h
    rename to headers/private/graphics/non-drm/vesa/vesa_info.h
    diff --git a/headers/private/graphics/vesa/vga.h b/headers/private/graphics/non-drm/vesa/vga.h
    similarity index 100%
    rename from headers/private/graphics/vesa/vga.h
    rename to headers/private/graphics/non-drm/vesa/vga.h
    diff --git a/headers/private/graphics/via/DriverInterface.h b/headers/private/graphics/non-drm/via/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/via/DriverInterface.h
    rename to headers/private/graphics/non-drm/via/DriverInterface.h
    diff --git a/headers/private/graphics/via/macros.h b/headers/private/graphics/non-drm/via/macros.h
    similarity index 100%
    rename from headers/private/graphics/via/macros.h
    rename to headers/private/graphics/non-drm/via/macros.h
    diff --git a/headers/private/graphics/video_overlay.h b/headers/private/graphics/non-drm/video_overlay.h
    similarity index 100%
    rename from headers/private/graphics/video_overlay.h
    rename to headers/private/graphics/non-drm/video_overlay.h
    diff --git a/headers/private/graphics/vmware/DriverInterface.h b/headers/private/graphics/non-drm/vmware/DriverInterface.h
    similarity index 100%
    rename from headers/private/graphics/vmware/DriverInterface.h
    rename to headers/private/graphics/non-drm/vmware/DriverInterface.h
    diff --git a/headers/private/graphics/vmware/svga_reg.h b/headers/private/graphics/non-drm/vmware/svga_reg.h
    similarity index 100%
    rename from headers/private/graphics/vmware/svga_reg.h
    rename to headers/private/graphics/non-drm/vmware/svga_reg.h
    diff --git a/headers/private/graphics/vmware/vm_device_version.h b/headers/private/graphics/non-drm/vmware/vm_device_version.h
    similarity index 100%
    rename from headers/private/graphics/vmware/vm_device_version.h
    rename to headers/private/graphics/non-drm/vmware/vm_device_version.h
    diff --git a/src/add-ons/kernel/drivers/graphics/Jamfile b/src/add-ons/kernel/drivers/graphics/Jamfile
    index f8881e30a6..703890f279 100644
    a b  
    11SubDir HAIKU_TOP src add-ons kernel drivers graphics ;
    22
    3 SubInclude HAIKU_TOP src add-ons kernel drivers graphics 3dfx ;
    4 SubInclude HAIKU_TOP src add-ons kernel drivers graphics ati ;
    5 SubInclude HAIKU_TOP src add-ons kernel drivers graphics common ;
    6 SubInclude HAIKU_TOP src add-ons kernel drivers graphics et6x00 ;
    7 SubInclude HAIKU_TOP src add-ons kernel drivers graphics framebuffer ;
    8 SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_810 ;
    9 SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_extreme ;
    10 SubInclude HAIKU_TOP src add-ons kernel drivers graphics matrox ;
    11 SubInclude HAIKU_TOP src add-ons kernel drivers graphics neomagic ;
    12 SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia ;
    13 SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia_gpgpu ;
    14 SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon ;
    15 SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon_hd ;
    16 SubInclude HAIKU_TOP src add-ons kernel drivers graphics s3 ;
    17 SubInclude HAIKU_TOP src add-ons kernel drivers graphics skeleton ;
    18 SubInclude HAIKU_TOP src add-ons kernel drivers graphics vesa ;
    19 SubInclude HAIKU_TOP src add-ons kernel drivers graphics via ;
     3SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm ;
     4SubInclude HAIKU_TOP src add-ons kernel drivers graphics drm ;
  • new file src/add-ons/kernel/drivers/graphics/drm/Jamfile

    diff --git a/src/add-ons/kernel/drivers/graphics/drm/Jamfile b/src/add-ons/kernel/drivers/graphics/drm/Jamfile
    new file mode 100644
    index 0000000000..dbaf197ddc
    - +  
     1SubDir HAIKU_TOP src add-ons kernel drivers graphics drm ;
     2
     3UsePrivateHeaders [ FDirName graphics drm ] ;
     4UsePrivateHeaders [ FDirName graphics drm uapi ] ;
     5UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility ] : true ;
     6UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility linuxkpi ] : true ;
     7
     8UsePrivateKernelHeaders ;
     9UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ;
     10
     11SubDirCcFlags [ FDefines _KERNEL=1 B_USE_POSITIVE_POSIX_ERRORS=1 __KERNEL__=1 ] ;
     12
     13KernelAddon drm :
     14    test.c
     15     # drm_auth.c           # NOT Complete
     16     # drm_bufs.c           # NOT Complete
     17     # drm_cache.c          # NOT Complete
     18     # drm_context.c        # NOT Complete
     19     # drm_dma.c            # NOT Complete
     20     # drm_fops.c           # NOT Complete
     21     # drm_gem.c            # NOT Complete
     22     # drm_ioctl.c          # NOT Complete
     23     # drm_irq.c            # NOT Complete
     24     # drm_lock.c           # NOT Complete
     25     # drm_memory.c         # NOT Complete
     26     # drm_drv.c            # NOT Complete
     27     # drm_scatter.c        # NOT Complete
     28     # drm_pci.c            # NOT Complete
     29     # drm_platform.c       # NOT Complete
     30     # drm_sysfs.c          # NOT Complete
     31     # drm_hashtab.c        # NOT Complete
     32     # drm_mm.c             # NOT Complete
     33     # drm_crtc.c           # NOT Complete
     34     # drm_fourcc.c         # NOT Complete
     35     # drm_modes.c          # NOT Complete
     36     # drm_edid.c           # NOT Complete
     37     # drm_info.c           # NOT Complete
     38     # drm_encoder_slave.c  # NOT Complete
     39     # drm_trace_points.c   # NOT Complete
     40     # drm_global.c         # NOT Complete
     41     # drm_prime.c          # NOT Complete
     42     # drm_rect.c           # NOT Complete
     43     # drm_vma_manager.c    # NOT Complete
     44     # drm_flip_work.c      # NOT Complete
     45     # drm_modeset_lock.c   # NOT Complete
     46     # drm_atomic.c         # NOT Complete
     47     # drm_bridge.c         # NOT Complete
     48     # drm_framebuffer.c    # NOT Complete
     49     # drm_connector.c      # NOT Complete
     50     # drm_blend.c          # NOT Complete
     51     # drm_encoder.c        # NOT Complete
     52     # drm_mode_object.c    # NOT Complete
     53     # drm_property.c       # NOT Complete
     54     # drm_plane.c          # NOT Complete
     55     # drm_color_mgmt.c     # NOT Complete
     56     # drm_print.c          # NOT Complete
     57     # drm_dumb_buffers.c   # NOT Complete
     58     # drm_mode_config.c    # NOT Complete
     59;
  • new file src/add-ons/kernel/drivers/graphics/non-drm/Jamfile

    diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/3dfx/Jamfile
    similarity index 100%
    rename from src/add-ons/kernel/drivers/graphics/3dfx/Jamfile
    rename to src/add-ons/kernel/drivers/graphics/non-drm/3dfx/Jamfile
    diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/3dfx/driver.cpp
    similarity index 100%
    rename from src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp
    rename to src/add-ons/kernel/drivers/graphics/non-drm/3dfx/driver.cpp
    diff --git a/src/add-ons/kernel/drivers/graphics/non-drm/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/Jamfile
    new file mode 100644
    index 0000000000..15c4a18239
    - +  
     1SubDir HAIKU_TOP src add-ons kernel drivers graphics non-drm ;
     2
     3SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm 3dfx ;
     4SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm ati ;
     5SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm common ;
     6SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm et6x00 ;
     7SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm framebuffer ;
     8SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm intel_810 ;
     9SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm intel_extreme ;
     10SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm matrox ;
     11SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm neomagic ;
     12SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm nvidia ;
     13SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm nvidia_gpgpu ;
     14SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm radeon ;
     15SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm radeon_hd ;
     16SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm s3 ;
     17SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm skeleton ;
     18SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm vesa ;
     19SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm via ;