[1] | 1 | /** @file
|
---|
[8245] | 2 | * IPRT - Parameter Definitions.
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[76553] | 6 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
[1] | 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
|
---|
[5999] | 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.
|
---|
[1] | 24 | */
|
---|
| 25 |
|
---|
[76557] | 26 | #ifndef IPRT_INCLUDED_param_h
|
---|
| 27 | #define IPRT_INCLUDED_param_h
|
---|
[76507] | 28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 29 | # pragma once
|
---|
| 30 | #endif
|
---|
[1] | 31 |
|
---|
| 32 | /** @todo Much of the PAGE_* stuff here is obsolete and highly risky to have around.
|
---|
| 33 | * As for component configs (MM_*), either we gather all in here or we move those bits away! */
|
---|
| 34 |
|
---|
| 35 | /** @defgroup grp_rt_param System Parameter Definitions
|
---|
| 36 | * @ingroup grp_rt_cdefs
|
---|
| 37 | * @{
|
---|
| 38 | */
|
---|
| 39 |
|
---|
[5265] | 40 | /* Undefine PAGE_SIZE and PAGE_SHIFT to avoid unnecessary noice when clashing
|
---|
[13775] | 41 | * with system headers. Include system headers before / after iprt depending
|
---|
| 42 | * on which you wish to take precedence. */
|
---|
[3161] | 43 | #undef PAGE_SIZE
|
---|
[3600] | 44 | #undef PAGE_SHIFT
|
---|
[3161] | 45 |
|
---|
[13775] | 46 | /* Undefine PAGE_OFFSET_MASK to avoid the conflict with the-linux-kernel.h */
|
---|
| 47 | #undef PAGE_OFFSET_MASK
|
---|
| 48 |
|
---|
[1] | 49 | /**
|
---|
| 50 | * i386 Page size.
|
---|
| 51 | */
|
---|
[29275] | 52 | #if defined(RT_ARCH_SPARC64)
|
---|
| 53 | # define PAGE_SIZE 8192
|
---|
| 54 | #else
|
---|
| 55 | # define PAGE_SIZE 4096
|
---|
| 56 | #endif
|
---|
[1] | 57 |
|
---|
| 58 | /**
|
---|
| 59 | * i386 Page shift.
|
---|
| 60 | * This is used to convert between size (in bytes) and page count.
|
---|
| 61 | */
|
---|
[29275] | 62 | #if defined(RT_ARCH_SPARC64)
|
---|
| 63 | # define PAGE_SHIFT 13
|
---|
| 64 | #else
|
---|
| 65 | # define PAGE_SHIFT 12
|
---|
| 66 | #endif
|
---|
[1] | 67 |
|
---|
| 68 | /**
|
---|
| 69 | * i386 Page offset mask.
|
---|
| 70 | *
|
---|
| 71 | * Do NOT one-complement this for whatever purpose. You may get a 32-bit const when you want a 64-bit one.
|
---|
| 72 | * Use PAGE_BASE_MASK, PAGE_BASE_GC_MASK, PAGE_BASE_HC_MASK, PAGE_ADDRESS() or X86_PTE_PAE_PG_MASK.
|
---|
| 73 | */
|
---|
[29275] | 74 | #if defined(RT_ARCH_SPARC64)
|
---|
| 75 | # define PAGE_OFFSET_MASK 0x1fff
|
---|
| 76 | #else
|
---|
| 77 | # define PAGE_OFFSET_MASK 0xfff
|
---|
| 78 | #endif
|
---|
[1] | 79 |
|
---|
| 80 | /**
|
---|
| 81 | * Page address mask for the guest context POINTERS.
|
---|
| 82 | * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
|
---|
| 83 | */
|
---|
[29275] | 84 | #define PAGE_BASE_GC_MASK (~(RTGCUINTPTR)PAGE_OFFSET_MASK)
|
---|
[1] | 85 |
|
---|
| 86 | /**
|
---|
| 87 | * Page address mask for the host context POINTERS.
|
---|
| 88 | * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
|
---|
| 89 | */
|
---|
[29275] | 90 | #define PAGE_BASE_HC_MASK (~(RTHCUINTPTR)PAGE_OFFSET_MASK)
|
---|
[1] | 91 |
|
---|
| 92 | /**
|
---|
| 93 | * Page address mask for the both context POINTERS.
|
---|
| 94 | *
|
---|
| 95 | * Be careful when using this since it may be a size too big!
|
---|
| 96 | * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
|
---|
| 97 | */
|
---|
[29275] | 98 | #define PAGE_BASE_MASK (~(RTUINTPTR)PAGE_OFFSET_MASK)
|
---|
[1] | 99 |
|
---|
| 100 | /**
|
---|
| 101 | * Get the page aligned address of a POINTER in the CURRENT context.
|
---|
| 102 | *
|
---|
| 103 | * @returns Page aligned address (it's an uintptr_t).
|
---|
[7606] | 104 | * @param pv The virtual address to align.
|
---|
[1] | 105 | *
|
---|
[5265] | 106 | * @remarks Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
|
---|
| 107 | * @remarks This only works with POINTERS in the current context.
|
---|
| 108 | * Do NOT use on guest address or physical address!
|
---|
[1] | 109 | */
|
---|
[29275] | 110 | #define PAGE_ADDRESS(pv) ((uintptr_t)(pv) & ~(uintptr_t)PAGE_OFFSET_MASK)
|
---|
[1] | 111 |
|
---|
| 112 | /**
|
---|
[7598] | 113 | * Get the page aligned address of a physical address
|
---|
| 114 | *
|
---|
| 115 | * @returns Page aligned address (it's an RTHCPHYS or RTGCPHYS).
|
---|
[7606] | 116 | * @param Phys The physical address to align.
|
---|
[7598] | 117 | */
|
---|
[32036] | 118 | #define PHYS_PAGE_ADDRESS(Phys) ((Phys) & X86_PTE_PAE_PG_MASK)
|
---|
[7598] | 119 |
|
---|
| 120 | /**
|
---|
[1] | 121 | * Host max path (the reasonable value).
|
---|
[35218] | 122 | * @remarks defined both by iprt/param.h and iprt/path.h.
|
---|
[1] | 123 | */
|
---|
[76557] | 124 | #if !defined(IPRT_INCLUDED_path_h) || defined(DOXYGEN_RUNNING)
|
---|
[35218] | 125 | # define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
|
---|
| 126 | #endif
|
---|
[1] | 127 |
|
---|
| 128 | /** @} */
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 | /** @} */
|
---|
| 132 |
|
---|
[76585] | 133 | #endif /* !IPRT_INCLUDED_param_h */
|
---|
[1] | 134 |
|
---|