VirtualBox

source: vbox/trunk/include/iprt/param.h@ 104730

Last change on this file since 104730 was 104730, checked in by vboxsync, 6 months ago

Config.kmk,include/iprt/param.h: Allow bolting the linux.arm64 builds to a particular host size by using VBOX_WITH_16K_PAGE_SIZE_ON_LINUX_ARM64,VBOX_WITH_4K_PAGE_SIZE_ON_LINUX_ARM64 or VBOX_WITH_64K_PAGE_SIZE_ON_LINUX_ARM64 (to not having to deal with variable page sizes at this stage), bugref:10391

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/** @file
2 * IPRT - Parameter Definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_param_h
37#define IPRT_INCLUDED_param_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/cdefs.h>
43
44/** @todo Much of the PAGE_* stuff here is obsolete and highly risky to have around.
45 * As for component configs (MM_*), either we gather all in here or we move those bits away! */
46
47/** @defgroup grp_rt_param System Parameter Definitions
48 * @ingroup grp_rt_cdefs
49 * @{
50 */
51
52/* Undefine PAGE_SIZE and PAGE_SHIFT to avoid unnecessary noice when clashing
53 * with system headers. Include system headers before / after iprt depending
54 * on which you wish to take precedence. */
55#undef PAGE_SIZE
56#undef PAGE_SHIFT
57
58/* Undefine PAGE_OFFSET_MASK to avoid the conflict with the-linux-kernel.h */
59#undef PAGE_OFFSET_MASK
60
61/**
62 * i386 Page size.
63 */
64#if defined(RT_ARCH_SPARC64)
65# define PAGE_SIZE 8192
66#elif defined(RT_ARCH_ARM64)
67# if defined(RT_OS_DARWIN)
68# define PAGE_SIZE 16384
69# elif defined(RT_OS_LINUX)
70# ifdef IN_RING0
71# define PAGE_SIZE (1 << CONFIG_ARM64_PAGE_SHIFT)
72# elif defined(IPRT_STATIC_ARM64_PAGE_SHIFT)
73# define PAGE_SIZE (1 << IPRT_STATIC_ARM64_PAGE_SHIFT)
74# else
75# define PAGE_SIZE RT_DONT_USE_PAGE_SIZE_ON_LINUX_ARM64_IN_USERSPACE_DUE_TO_VARIABLE_PAGE_SIZE
76# endif
77# elif defined(RT_OS_WINDOWS)
78# define PAGE_SIZE 4096
79# else
80# error "This needs porting"
81# endif
82#else
83# define PAGE_SIZE 4096
84#endif
85
86/**
87 * i386 Page shift.
88 * This is used to convert between size (in bytes) and page count.
89 */
90#if defined(RT_ARCH_SPARC64)
91# define PAGE_SHIFT 13
92#elif defined(RT_ARCH_ARM64)
93# if defined(RT_OS_DARWIN)
94# define PAGE_SHIFT 14
95# elif defined(RT_OS_LINUX)
96# ifdef IN_RING0
97# define PAGE_SHIFT CONFIG_ARM64_PAGE_SHIFT
98# elif defined(IPRT_STATIC_ARM64_PAGE_SHIFT)
99# define PAGE_SHIFT IPRT_STATIC_ARM64_PAGE_SHIFT
100# else
101# define PAGE_SHIFT RT_DONT_USE_PAGE_SHIFT_ON_LINUX_ARM64_IN_USERSPACE_DUE_TO_VARIABLE_PAGE_SIZE
102# endif
103# elif defined(RT_OS_WINDOWS)
104# define PAGE_SHIFT 12
105# else
106# error "This needs porting"
107# endif
108#else
109# define PAGE_SHIFT 12
110#endif
111
112/**
113 * i386 Page offset mask.
114 *
115 * @note If you do one-complement this, always insert a target type case after
116 * the operator! Otherwise you may end up with weird results.
117 */
118#if defined(RT_ARCH_SPARC64)
119# define PAGE_OFFSET_MASK 0x1fff
120#elif defined(RT_ARCH_ARM64)
121# if defined(RT_OS_DARWIN)
122# define PAGE_OFFSET_MASK 0x3fff
123# elif defined(RT_OS_LINUX)
124# ifdef IN_RING0
125# define PAGE_OFFSET_MASK (PAGE_SIZE - 1)
126# elif defined(IPRT_STATIC_ARM64_PAGE_SHIFT)
127# define PAGE_OFFSET_MASK ((1 << IPRT_STATIC_ARM64_PAGE_SHIFT) - 1)
128# else
129# define PAGE_OFFSET_MASK RT_DONT_USE_PAGE_OFFSET_MASK_ON_LINUX_ARM64_IN_USERSPACE_DUE_TO_VARIABLE_PAGE_SIZE
130# endif
131# elif defined(RT_OS_WINDOWS)
132# define PAGE_OFFSET_MASK 0xfff
133# else
134# error "This needs porting"
135# endif
136#else
137# define PAGE_OFFSET_MASK 0xfff
138#endif
139
140/**
141 * Page address mask for the uintptr_t sized pointers.
142 *
143 * Be careful when using this since it may be a size too big!
144 * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
145 */
146#define PAGE_BASE_MASK (~(uintptr_t)PAGE_OFFSET_MASK)
147
148/**
149 * Get the page aligned address of a POINTER in the CURRENT context.
150 *
151 * @returns Page aligned address (it's an uintptr_t).
152 * @param pv The virtual address to align.
153 *
154 * @remarks Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
155 * @remarks This only works with POINTERS in the current context.
156 * Do NOT use on guest address or physical address!
157 */
158#define PAGE_ADDRESS(pv) ((uintptr_t)(pv) & ~(uintptr_t)PAGE_OFFSET_MASK)
159
160/**
161 * Get the page aligned address of a physical address
162 *
163 * @returns Page aligned address (it's an RTHCPHYS or RTGCPHYS).
164 * @param Phys The physical address to align.
165 */
166#define PHYS_PAGE_ADDRESS(Phys) ((Phys) & X86_PTE_PAE_PG_MASK)
167
168/**
169 * Host max path (the reasonable value).
170 * @remarks defined both by iprt/param.h and iprt/path.h.
171 */
172#if !defined(IPRT_INCLUDED_path_h) || defined(DOXYGEN_RUNNING)
173# define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
174#endif
175
176/** @} */
177
178#endif /* !IPRT_INCLUDED_param_h */
179
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