VirtualBox

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

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

VMM,VMMDev,scm,VBox/param.h: Don't use PAGE_BASE_GC_MASK and friends in the VMM. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** @file
2 * IPRT - Parameter Definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2022 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_param_h
27#define IPRT_INCLUDED_param_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33
34/** @todo Much of the PAGE_* stuff here is obsolete and highly risky to have around.
35 * As for component configs (MM_*), either we gather all in here or we move those bits away! */
36
37/** @defgroup grp_rt_param System Parameter Definitions
38 * @ingroup grp_rt_cdefs
39 * @{
40 */
41
42/* Undefine PAGE_SIZE and PAGE_SHIFT to avoid unnecessary noice when clashing
43 * with system headers. Include system headers before / after iprt depending
44 * on which you wish to take precedence. */
45#undef PAGE_SIZE
46#undef PAGE_SHIFT
47
48/* Undefine PAGE_OFFSET_MASK to avoid the conflict with the-linux-kernel.h */
49#undef PAGE_OFFSET_MASK
50
51/**
52 * i386 Page size.
53 */
54#if defined(RT_ARCH_SPARC64)
55# define PAGE_SIZE 8192
56#elif defined(RT_ARCH_ARM64)
57# define PAGE_SIZE 16384
58#else
59# define PAGE_SIZE 4096
60#endif
61
62/**
63 * i386 Page shift.
64 * This is used to convert between size (in bytes) and page count.
65 */
66#if defined(RT_ARCH_SPARC64)
67# define PAGE_SHIFT 13
68#elif defined(RT_ARCH_ARM64)
69# define PAGE_SHIFT 14
70#else
71# define PAGE_SHIFT 12
72#endif
73
74/**
75 * i386 Page offset mask.
76 *
77 * @note If you do one-complement this, always insert a target type case after
78 * the operator! Otherwise you may end up with weird results.
79 */
80#if defined(RT_ARCH_SPARC64)
81# define PAGE_OFFSET_MASK 0x1fff
82#elif defined(RT_ARCH_ARM64)
83# define PAGE_OFFSET_MASK 0x3fff
84#else
85# define PAGE_OFFSET_MASK 0xfff
86#endif
87
88/**
89 * Page address mask for the uintptr_t sized pointers.
90 *
91 * Be careful when using this since it may be a size too big!
92 * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
93 */
94#define PAGE_BASE_MASK (~(uintptr_t)PAGE_OFFSET_MASK)
95
96/**
97 * Get the page aligned address of a POINTER in the CURRENT context.
98 *
99 * @returns Page aligned address (it's an uintptr_t).
100 * @param pv The virtual address to align.
101 *
102 * @remarks Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
103 * @remarks This only works with POINTERS in the current context.
104 * Do NOT use on guest address or physical address!
105 */
106#define PAGE_ADDRESS(pv) ((uintptr_t)(pv) & ~(uintptr_t)PAGE_OFFSET_MASK)
107
108/**
109 * Get the page aligned address of a physical address
110 *
111 * @returns Page aligned address (it's an RTHCPHYS or RTGCPHYS).
112 * @param Phys The physical address to align.
113 */
114#define PHYS_PAGE_ADDRESS(Phys) ((Phys) & X86_PTE_PAE_PG_MASK)
115
116/**
117 * Host max path (the reasonable value).
118 * @remarks defined both by iprt/param.h and iprt/path.h.
119 */
120#if !defined(IPRT_INCLUDED_path_h) || defined(DOXYGEN_RUNNING)
121# define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
122#endif
123
124/** @} */
125
126#endif /* !IPRT_INCLUDED_param_h */
127
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