VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette