VirtualBox

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

Last change on this file since 5605 was 5265, checked in by vboxsync, 17 years ago

Be careful with PAGE_ADDRESS, it only works for pointers in the current context!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/** @file
2 * innotek Portable Runtime - Parameter Definitions.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___iprt_param_h
18#define ___iprt_param_h
19
20/** @todo Much of the PAGE_* stuff here is obsolete and highly risky to have around.
21 * As for component configs (MM_*), either we gather all in here or we move those bits away! */
22
23/** @defgroup grp_rt_param System Parameter Definitions
24 * @ingroup grp_rt_cdefs
25 * @{
26 */
27
28/* Undefine PAGE_SIZE and PAGE_SHIFT to avoid unnecessary noice when clashing
29 with system headers. Include system headers before / after iprt depending
30 on which you wish to take precedence. */
31#undef PAGE_SIZE
32#undef PAGE_SHIFT
33
34/**
35 * i386 Page size.
36 */
37#define PAGE_SIZE 4096
38
39/**
40 * i386 Page shift.
41 * This is used to convert between size (in bytes) and page count.
42 */
43#define PAGE_SHIFT 12
44
45/**
46 * i386 Page offset mask.
47 *
48 * Do NOT one-complement this for whatever purpose. You may get a 32-bit const when you want a 64-bit one.
49 * Use PAGE_BASE_MASK, PAGE_BASE_GC_MASK, PAGE_BASE_HC_MASK, PAGE_ADDRESS() or X86_PTE_PAE_PG_MASK.
50 */
51#define PAGE_OFFSET_MASK 0xfff
52
53/**
54 * Page address mask for the guest context POINTERS.
55 * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
56 */
57#define PAGE_BASE_GC_MASK (~(RTGCUINTPTR)0xfff)
58
59/**
60 * Page address mask for the host context POINTERS.
61 * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
62 */
63#define PAGE_BASE_HC_MASK (~(RTHCUINTPTR)0xfff)
64
65/**
66 * Page address mask for the both context POINTERS.
67 *
68 * Be careful when using this since it may be a size too big!
69 * @remark Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
70 */
71#define PAGE_BASE_MASK (~(RTUINTPTR)0xfff)
72
73/**
74 * Get the page aligned address of a POINTER in the CURRENT context.
75 *
76 * @returns Page aligned address (it's an uintptr_t).
77 * @param pv The address to align.
78 *
79 * @remarks Physical addresses are always masked using X86_PTE_PAE_PG_MASK!
80 * @remarks This only works with POINTERS in the current context.
81 * Do NOT use on guest address or physical address!
82 */
83#define PAGE_ADDRESS(pv) ((uintptr_t)(pv) & ~(uintptr_t)0xfff)
84
85#if 1 /** @todo remove this! Use X86_PAGE_* defines. */
86/**
87 * i386 Page directory shift.
88 * This is used to convert between PDR index and virtual address.
89 * @deprecated Use X86_*.
90 */
91#define PGDIR_SHIFT 22
92
93/**
94 * i386 Page table mask.
95 * This is used together with PAGE_SHIFT to get the page table
96 * index from a virtual address.
97 * @deprecated Use X86_*.
98 */
99#define PTE_MASK 0x3ff
100
101/**
102 * i386 Page table and page directory entry count for the default
103 * paging mode.
104 * @deprecated Use X86_*.
105 */
106#define PAGE_ENTRIES 1024
107
108/**
109 * i386 4MB Page offset mask.
110 * @deprecated Use X86_*.
111 */
112#define PAGE_OFFSET_MASK_BIG 0x3fffff
113#endif /* obsolete */
114
115/**
116 * Host max path (the reasonable value).
117 */
118#define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
119
120/** @} */
121
122
123/** @} */
124
125#endif
126
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