VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.7 KB
Line 
1/* $Id: the-freebsd-kernel.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Ring-0 Driver, The FreeBSD Kernel Headers.
4 */
5
6/*
7 * Contributed by knut st. osmundsen.
8 *
9 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
10 *
11 * This file is part of VirtualBox base platform packages, as
12 * available from https://www.virtualbox.org.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation, in version 3 of the
17 * License.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see <https://www.gnu.org/licenses>.
26 *
27 * The contents of this file may alternatively be used under the terms
28 * of the Common Development and Distribution License Version 1.0
29 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
30 * in the VirtualBox distribution, in which case the provisions of the
31 * CDDL are applicable instead of those of the GPL.
32 *
33 * You may elect to license modified versions of this file under the
34 * terms and conditions of either the GPL or the CDDL or both.
35 *
36 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
37 * --------------------------------------------------------------------
38 *
39 * This code is based on:
40 *
41 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
42 *
43 * Permission is hereby granted, free of charge, to any person
44 * obtaining a copy of this software and associated documentation
45 * files (the "Software"), to deal in the Software without
46 * restriction, including without limitation the rights to use,
47 * copy, modify, merge, publish, distribute, sublicense, and/or sell
48 * copies of the Software, and to permit persons to whom the
49 * Software is furnished to do so, subject to the following
50 * conditions:
51 *
52 * The above copyright notice and this permission notice shall be
53 * included in all copies or substantial portions of the Software.
54 *
55 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
57 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
59 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
60 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
61 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
62 * OTHER DEALINGS IN THE SOFTWARE.
63 */
64
65#ifndef IPRT_INCLUDED_SRC_r0drv_freebsd_the_freebsd_kernel_h
66#define IPRT_INCLUDED_SRC_r0drv_freebsd_the_freebsd_kernel_h
67#ifndef RT_WITHOUT_PRAGMA_ONCE
68# pragma once
69#endif
70
71#include <iprt/types.h>
72
73/* Deal with conflicts first. */
74#include <sys/param.h>
75#undef PVM
76#include <sys/bus.h>
77#include <sys/types.h>
78#include <sys/errno.h>
79#include <sys/kernel.h>
80#include <sys/uio.h>
81#include <sys/libkern.h>
82#include <sys/systm.h>
83#include <sys/malloc.h>
84#include <sys/pcpu.h>
85#include <sys/proc.h>
86#include <sys/limits.h>
87#include <sys/unistd.h>
88#include <sys/kthread.h>
89#include <sys/lock.h>
90#if __FreeBSD_version >= 1000030
91#include <sys/rwlock.h>
92#endif
93#include <sys/mutex.h>
94#include <sys/sched.h>
95#include <sys/callout.h>
96#include <sys/cpu.h>
97#include <sys/smp.h>
98#include <sys/sleepqueue.h>
99#include <sys/sx.h>
100#include <vm/vm.h>
101#include <vm/pmap.h> /* for vtophys */
102#include <vm/vm_map.h>
103#include <vm/vm_object.h>
104#include <vm/vm_kern.h>
105#include <vm/vm_param.h> /* KERN_SUCCESS ++ */
106#include <vm/vm_page.h>
107#include <vm/vm_phys.h> /* vm_phys_alloc_* */
108#include <vm/vm_extern.h> /* kmem_alloc_attr */
109#include <vm/vm_pageout.h> /* vm_contig_grow_cache */
110#include <sys/vmmeter.h> /* cnt */
111#include <sys/resourcevar.h>
112#include <machine/cpu.h>
113
114/**
115 * Wrappers around the sleepq_ KPI.
116 */
117#if __FreeBSD_version >= 800026
118# define SLEEPQ_TIMEDWAIT(EventInt) sleepq_timedwait(EventInt, 0)
119# define SLEEPQ_TIMEDWAIT_SIG(EventInt) sleepq_timedwait_sig(EventInt, 0)
120# define SLEEPQ_WAIT(EventInt) sleepq_wait(EventInt, 0)
121# define SLEEPQ_WAIT_SIG(EventInt) sleepq_wait_sig(EventInt, 0)
122#else
123# define SLEEPQ_TIMEDWAIT(EventInt) sleepq_timedwait(EventInt)
124# define SLEEPQ_TIMEDWAIT_SIG(EventInt) sleepq_timedwait_sig(EventInt)
125# define SLEEPQ_WAIT(EventInt) sleepq_wait(EventInt)
126# define SLEEPQ_WAIT_SIG(EventInt) sleepq_wait_sig(EventInt)
127#endif
128
129/**
130 * Our pmap_enter version
131 */
132#if __FreeBSD_version >= 701105
133# define MY_PMAP_ENTER(pPhysMap, AddrR3, pPage, fProt, fWired) \
134 pmap_enter(pPhysMap, AddrR3, VM_PROT_NONE, pPage, fProt, fWired)
135#else
136# define MY_PMAP_ENTER(pPhysMap, AddrR3, pPage, fProt, fWired) \
137 pmap_enter(pPhysMap, AddrR3, pPage, fProt, fWired)
138#endif
139
140/**
141 * The VM object lock/unlock wrappers for older kernels.
142 */
143#if __FreeBSD_version < 1000030
144# define VM_OBJECT_WLOCK(a_pObject) VM_OBJECT_LOCK((a_pObject))
145# define VM_OBJECT_WUNLOCK(a_pObject) VM_OBJECT_UNLOCK((a_pObject))
146#endif
147
148#if __FreeBSD_version >= 1100077
149# define MY_LIM_MAX_PROC(a_pProc, a_Limit) lim_max_proc((a_pProc), (a_Limit))
150#else
151# define MY_LIM_MAX_PROC(a_pProc, a_Limit) lim_max((a_pProc), (a_Limit))
152#endif
153
154/**
155 * Check whether we can use kmem_alloc_attr for low allocs.
156 */
157#if (__FreeBSD_version >= 900011) \
158 || (__FreeBSD_version < 900000 && __FreeBSD_version >= 800505) \
159 || (__FreeBSD_version < 800000 && __FreeBSD_version >= 703101)
160# define USE_KMEM_ALLOC_ATTR
161#endif
162
163/**
164 * Check whether we can use kmem_alloc_prot.
165 */
166#if 0 /** @todo Not available yet. */
167# define USE_KMEM_ALLOC_PROT
168#endif
169
170#endif /* !IPRT_INCLUDED_SRC_r0drv_freebsd_the_freebsd_kernel_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use