1 | /* $Revision: 26433 $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Ring-0 Memory Objects.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | *
|
---|
26 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | * additional information or have any questions.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___internal_memobj_h
|
---|
32 | #define ___internal_memobj_h
|
---|
33 |
|
---|
34 | #include <iprt/memobj.h>
|
---|
35 | #include <iprt/assert.h>
|
---|
36 | #include "internal/magics.h"
|
---|
37 |
|
---|
38 | RT_C_DECLS_BEGIN
|
---|
39 |
|
---|
40 | /** @defgroup grp_rt_memobj_int Internals.
|
---|
41 | * @ingroup grp_rt_memobj
|
---|
42 | * @internal
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Ring-0 memory object type.
|
---|
48 | */
|
---|
49 | typedef enum RTR0MEMOBJTYPE
|
---|
50 | {
|
---|
51 | /** The traditional invalid value. */
|
---|
52 | RTR0MEMOBJTYPE_INVALID = 0,
|
---|
53 |
|
---|
54 | /** @name Primary types (parents)
|
---|
55 | * @{ */
|
---|
56 | /** RTR0MemObjAllocPage.
|
---|
57 | * This memory is page aligned and fixed. */
|
---|
58 | RTR0MEMOBJTYPE_PAGE,
|
---|
59 | /** RTR0MemObjAllocLow.
|
---|
60 | * This memory is page aligned, fixed and is backed by physical memory below 4GB. */
|
---|
61 | RTR0MEMOBJTYPE_LOW,
|
---|
62 | /** RTR0MemObjAllocCont.
|
---|
63 | * This memory is page aligned, fixed and is backed by contiguous physical memory below 4GB. */
|
---|
64 | RTR0MEMOBJTYPE_CONT,
|
---|
65 | /** RTR0MemObjLockKernel, RTR0MemObjLockUser.
|
---|
66 | * This memory is page aligned and fixed. It was locked/pinned/wired down by the API call. */
|
---|
67 | RTR0MEMOBJTYPE_LOCK,
|
---|
68 | /** RTR0MemObjAllocPhys, RTR0MemObjEnterPhys.
|
---|
69 | * This memory is physical memory, page aligned, contiguous and doesn't need to have a mapping. */
|
---|
70 | RTR0MEMOBJTYPE_PHYS,
|
---|
71 | /** RTR0MemObjAllocPhysNC.
|
---|
72 | * This memory is physical memory, page aligned and doesn't need to have a mapping. */
|
---|
73 | RTR0MEMOBJTYPE_PHYS_NC,
|
---|
74 | /** RTR0MemObjReserveKernel, RTR0MemObjReserveUser.
|
---|
75 | * This memory is page aligned and has no backing. */
|
---|
76 | RTR0MEMOBJTYPE_RES_VIRT,
|
---|
77 | /** @} */
|
---|
78 |
|
---|
79 | /** @name Secondary types (children)
|
---|
80 | * @{
|
---|
81 | */
|
---|
82 | /** RTR0MemObjMapUser, RTR0MemObjMapKernel.
|
---|
83 | * This is a user or kernel context mapping of another ring-0 memory object. */
|
---|
84 | RTR0MEMOBJTYPE_MAPPING,
|
---|
85 | /** @} */
|
---|
86 |
|
---|
87 | /** The end of the valid types. Used for sanity checking. */
|
---|
88 | RTR0MEMOBJTYPE_END
|
---|
89 | } RTR0MEMOBJTYPE;
|
---|
90 |
|
---|
91 |
|
---|
92 | /** @name RTR0MEMOBJINTERNAL::fFlags
|
---|
93 | * @{ */
|
---|
94 | /** Page level protection was changed. */
|
---|
95 | #define RTR0MEMOBJ_FLAGS_PROT_CHANGED RT_BIT_32(0)
|
---|
96 | /** @} */
|
---|
97 |
|
---|
98 |
|
---|
99 | typedef struct RTR0MEMOBJINTERNAL *PRTR0MEMOBJINTERNAL;
|
---|
100 | typedef struct RTR0MEMOBJINTERNAL **PPRTR0MEMOBJINTERNAL;
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Ring-0 memory object.
|
---|
104 | *
|
---|
105 | * When using the PRTR0MEMOBJINTERNAL and PPRTR0MEMOBJINTERNAL types
|
---|
106 | * we get pMem and ppMem variable names.
|
---|
107 | *
|
---|
108 | * When using the RTR0MEMOBJ and PRTR0MEMOBJ types we get MemObj and
|
---|
109 | * pMemObj variable names. We never dereference variables of the RTR0MEMOBJ
|
---|
110 | * type, we always convert it to a PRTR0MEMOBJECTINTERNAL variable first.
|
---|
111 | */
|
---|
112 | typedef struct RTR0MEMOBJINTERNAL
|
---|
113 | {
|
---|
114 | /** Magic number (RTR0MEM_MAGIC). */
|
---|
115 | uint32_t u32Magic;
|
---|
116 | /** The size of this structure. */
|
---|
117 | uint32_t cbSelf;
|
---|
118 | /** The type of allocation. */
|
---|
119 | RTR0MEMOBJTYPE enmType;
|
---|
120 | /** Flags, RTR0MEMOBJ_FLAGS_*. */
|
---|
121 | uint32_t fFlags;
|
---|
122 | /** The size of the memory allocated, pinned down, or mapped. */
|
---|
123 | size_t cb;
|
---|
124 | /** The memory address.
|
---|
125 | * What this really is varies with the type.
|
---|
126 | * For PAGE, CONT, LOW, RES_VIRT/R0, LOCK/R0 and MAP/R0 it's the ring-0 mapping.
|
---|
127 | * For LOCK/R3, RES_VIRT/R3 and MAP/R3 it is the ring-3 mapping.
|
---|
128 | * For PHYS this might actually be NULL if there isn't any mapping.
|
---|
129 | */
|
---|
130 | void *pv;
|
---|
131 |
|
---|
132 | /** Object relations. */
|
---|
133 | union
|
---|
134 | {
|
---|
135 | /** This is for tracking child memory handles mapping the
|
---|
136 | * memory described by the primary handle. */
|
---|
137 | struct
|
---|
138 | {
|
---|
139 | /** Number of mappings. */
|
---|
140 | uint32_t cMappingsAllocated;
|
---|
141 | /** Number of mappings in the array. */
|
---|
142 | uint32_t cMappings;
|
---|
143 | /** Pointers to child handles mapping this memory. */
|
---|
144 | PPRTR0MEMOBJINTERNAL papMappings;
|
---|
145 | } Parent;
|
---|
146 |
|
---|
147 | /** Pointer to the primary handle. */
|
---|
148 | struct
|
---|
149 | {
|
---|
150 | /** Pointer to the parent. */
|
---|
151 | PRTR0MEMOBJINTERNAL pParent;
|
---|
152 | } Child;
|
---|
153 | } uRel;
|
---|
154 |
|
---|
155 | /** Type specific data for the memory types that requires that. */
|
---|
156 | union
|
---|
157 | {
|
---|
158 | /** RTR0MEMTYPE_PAGE. */
|
---|
159 | struct
|
---|
160 | {
|
---|
161 | unsigned iDummy;
|
---|
162 | } Page;
|
---|
163 |
|
---|
164 | /** RTR0MEMTYPE_LOW. */
|
---|
165 | struct
|
---|
166 | {
|
---|
167 | unsigned iDummy;
|
---|
168 | } Low;
|
---|
169 |
|
---|
170 | /** RTR0MEMTYPE_CONT. */
|
---|
171 | struct
|
---|
172 | {
|
---|
173 | /** The physical address of the first page. */
|
---|
174 | RTHCPHYS Phys;
|
---|
175 | } Cont;
|
---|
176 |
|
---|
177 | /** RTR0MEMTYPE_LOCK_USER. */
|
---|
178 | struct
|
---|
179 | {
|
---|
180 | /** The process that owns the locked memory.
|
---|
181 | * This is NIL_RTR0PROCESS if it's kernel memory. */
|
---|
182 | RTR0PROCESS R0Process;
|
---|
183 | } Lock;
|
---|
184 |
|
---|
185 | /** RTR0MEMTYPE_PHYS. */
|
---|
186 | struct
|
---|
187 | {
|
---|
188 | /** The base address of the physical memory. */
|
---|
189 | RTHCPHYS PhysBase;
|
---|
190 | /** If set this object was created by RTR0MemPhysAlloc, otherwise it was
|
---|
191 | * created by RTR0MemPhysEnter. */
|
---|
192 | bool fAllocated;
|
---|
193 | } Phys;
|
---|
194 |
|
---|
195 | /** RTR0MEMTYPE_PHYS_NC. */
|
---|
196 | struct
|
---|
197 | {
|
---|
198 | unsigned iDummy;
|
---|
199 | } PhysNC;
|
---|
200 |
|
---|
201 | /** RTR0MEMOBJTYPE_RES_VIRT */
|
---|
202 | struct
|
---|
203 | {
|
---|
204 | /** The process that owns the reserved memory.
|
---|
205 | * This is NIL_RTR0PROCESS if it's kernel memory. */
|
---|
206 | RTR0PROCESS R0Process;
|
---|
207 | } ResVirt;
|
---|
208 |
|
---|
209 | /** RTR0MEMOBJTYPE_MAPPING */
|
---|
210 | struct
|
---|
211 | {
|
---|
212 | /** The process that owns the reserved memory.
|
---|
213 | * This is NIL_RTR0PROCESS if it's kernel memory. */
|
---|
214 | RTR0PROCESS R0Process;
|
---|
215 | } Mapping;
|
---|
216 | } u;
|
---|
217 |
|
---|
218 | } RTR0MEMOBJINTERNAL;
|
---|
219 |
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Checks if this is mapping or not.
|
---|
223 | *
|
---|
224 | * @returns true if it's a mapping, otherwise false.
|
---|
225 | * @param pMem The ring-0 memory object handle.
|
---|
226 | * @see RTR0MemObjIsMapping
|
---|
227 | */
|
---|
228 | DECLINLINE(bool) rtR0MemObjIsMapping(PRTR0MEMOBJINTERNAL pMem)
|
---|
229 | {
|
---|
230 | switch (pMem->enmType)
|
---|
231 | {
|
---|
232 | case RTR0MEMOBJTYPE_MAPPING:
|
---|
233 | return true;
|
---|
234 |
|
---|
235 | default:
|
---|
236 | return false;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * Checks page level protection can be changed on this object.
|
---|
243 | *
|
---|
244 | * @returns true / false.
|
---|
245 | * @param pMem The ring-0 memory object handle.
|
---|
246 | */
|
---|
247 | DECLINLINE(bool) rtR0MemObjIsProtectable(PRTR0MEMOBJINTERNAL pMem)
|
---|
248 | {
|
---|
249 | switch (pMem->enmType)
|
---|
250 | {
|
---|
251 | case RTR0MEMOBJTYPE_MAPPING:
|
---|
252 | case RTR0MEMOBJTYPE_PAGE:
|
---|
253 | case RTR0MEMOBJTYPE_LOW:
|
---|
254 | case RTR0MEMOBJTYPE_CONT:
|
---|
255 | return true;
|
---|
256 |
|
---|
257 | default:
|
---|
258 | return false;
|
---|
259 | }
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Checks if RTR0MEMOBJ::pv is a ring-3 pointer or not.
|
---|
265 | *
|
---|
266 | * @returns true if it's a object with a ring-3 address, otherwise false.
|
---|
267 | * @param pMem The ring-0 memory object handle.
|
---|
268 | */
|
---|
269 | DECLINLINE(bool) rtR0MemObjIsRing3(PRTR0MEMOBJINTERNAL pMem)
|
---|
270 | {
|
---|
271 | switch (pMem->enmType)
|
---|
272 | {
|
---|
273 | case RTR0MEMOBJTYPE_RES_VIRT:
|
---|
274 | return pMem->u.ResVirt.R0Process != NIL_RTR0PROCESS;
|
---|
275 | case RTR0MEMOBJTYPE_LOCK:
|
---|
276 | return pMem->u.Lock.R0Process != NIL_RTR0PROCESS;
|
---|
277 | case RTR0MEMOBJTYPE_MAPPING:
|
---|
278 | return pMem->u.Mapping.R0Process != NIL_RTR0PROCESS;
|
---|
279 | default:
|
---|
280 | return false;
|
---|
281 | }
|
---|
282 | }
|
---|
283 |
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * Frees the memory object (but not the handle).
|
---|
287 | * Any OS specific handle resources will be freed by this call.
|
---|
288 | *
|
---|
289 | * @returns IPRT status code. On failure it is assumed that the object remains valid.
|
---|
290 | * @param pMem The ring-0 memory object handle to the memory which should be freed.
|
---|
291 | */
|
---|
292 | int rtR0MemObjNativeFree(PRTR0MEMOBJINTERNAL pMem);
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Allocates page aligned virtual kernel memory.
|
---|
296 | *
|
---|
297 | * The memory is taken from a non paged (= fixed physical memory backing) pool.
|
---|
298 | *
|
---|
299 | * @returns IPRT status code.
|
---|
300 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
301 | * @param cb Number of bytes to allocate, page aligned.
|
---|
302 | * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
|
---|
303 | */
|
---|
304 | int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Allocates page aligned virtual kernel memory with physical backing below 4GB.
|
---|
308 | *
|
---|
309 | * The physical memory backing the allocation is fixed.
|
---|
310 | *
|
---|
311 | * @returns IPRT status code.
|
---|
312 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
313 | * @param cb Number of bytes to allocate, page aligned.
|
---|
314 | * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
|
---|
315 | */
|
---|
316 | int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
|
---|
320 | *
|
---|
321 | * The physical memory backing the allocation is fixed.
|
---|
322 | *
|
---|
323 | * @returns IPRT status code.
|
---|
324 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
325 | * @param cb Number of bytes to allocate, page aligned.
|
---|
326 | * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object.
|
---|
327 | */
|
---|
328 | int rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable);
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Locks a range of user virtual memory.
|
---|
332 | *
|
---|
333 | * @returns IPRT status code.
|
---|
334 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
335 | * @param R3Ptr User virtual address, page aligned.
|
---|
336 | * @param cb Number of bytes to lock, page aligned.
|
---|
337 | * @param fAccess The desired access, a combination of RTMEM_PROT_READ
|
---|
338 | * and RTMEM_PROT_WRITE.
|
---|
339 | * @param R0Process The process to lock pages in.
|
---|
340 | */
|
---|
341 | int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process);
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * Locks a range of kernel virtual memory.
|
---|
345 | *
|
---|
346 | * @returns IPRT status code.
|
---|
347 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
348 | * @param pv Kernel virtual address, page aligned.
|
---|
349 | * @param cb Number of bytes to lock, page aligned.
|
---|
350 | * @param fAccess The desired access, a combination of RTMEM_PROT_READ
|
---|
351 | * and RTMEM_PROT_WRITE.
|
---|
352 | */
|
---|
353 | int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess);
|
---|
354 |
|
---|
355 | /**
|
---|
356 | * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
|
---|
357 | *
|
---|
358 | * @returns IPRT status code.
|
---|
359 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
360 | * @param cb Number of bytes to allocate, page aligned.
|
---|
361 | * @param PhysHighest The highest permittable address (inclusive).
|
---|
362 | * NIL_RTHCPHYS if any address is acceptable.
|
---|
363 | * @param uAlignment The alignment of the reserved memory.
|
---|
364 | * Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
|
---|
365 | */
|
---|
366 | int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment);
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
|
---|
370 | *
|
---|
371 | * @returns IPRT status code.
|
---|
372 | * @retval VERR_NOT_SUPPORTED if it's not possible to allocated unmapped
|
---|
373 | * physical memory on this platform.
|
---|
374 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
375 | * @param cb Number of bytes to allocate, page aligned.
|
---|
376 | * @param PhysHighest The highest permittable address (inclusive).
|
---|
377 | * NIL_RTHCPHYS if any address is acceptable.
|
---|
378 | */
|
---|
379 | int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest);
|
---|
380 |
|
---|
381 | /**
|
---|
382 | * Creates a page aligned, contiguous, physical memory object.
|
---|
383 | *
|
---|
384 | * @returns IPRT status code.
|
---|
385 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
386 | * @param Phys The physical address to start at, page aligned.
|
---|
387 | * @param cb The size of the object in bytes, page aligned.
|
---|
388 | */
|
---|
389 | int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb);
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Reserves kernel virtual address space.
|
---|
393 | *
|
---|
394 | * @returns IPRT status code.
|
---|
395 | * Return VERR_NOT_SUPPORTED to indicate that the user should employ fallback strategies.
|
---|
396 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
397 | * @param pvFixed Requested address. (void *)-1 means any address. This matches uAlignment if specified.
|
---|
398 | * @param cb The number of bytes to reserve, page aligned.
|
---|
399 | * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
|
---|
400 | */
|
---|
401 | int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment);
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Reserves user virtual address space in the current process.
|
---|
405 | *
|
---|
406 | * @returns IPRT status code.
|
---|
407 | * @param ppMem Where to store the ring-0 memory object handle.
|
---|
408 | * @param R3PtrFixed Requested address. (RTR3PTR)-1 means any address. This matches uAlignment if specified.
|
---|
409 | * @param cb The number of bytes to reserve, page aligned.
|
---|
410 | * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
|
---|
411 | * @param R0Process The process to reserve the memory in.
|
---|
412 | */
|
---|
413 | int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Maps a memory object into user virtual address space in the current process.
|
---|
417 | *
|
---|
418 | * @returns IPRT status code.
|
---|
419 | * @retval VERR_NOT_SUPPORTED see RTR0MemObjMapKernelEx.
|
---|
420 | *
|
---|
421 | * @param ppMem Where to store the ring-0 memory object handle of the mapping object.
|
---|
422 | * @param pMemToMap The object to be map.
|
---|
423 | * @param pvFixed Requested address. (void *)-1 means any address. This matches uAlignment if specified.
|
---|
424 | * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
|
---|
425 | * @param fProt Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
|
---|
426 | * @param offSub Where in the object to start mapping. If non-zero
|
---|
427 | * the value must be page aligned and cbSub must be
|
---|
428 | * non-zero as well.
|
---|
429 | * @param cbSub The size of the part of the object to be mapped. If
|
---|
430 | * zero the entire object is mapped. The value must be
|
---|
431 | * page aligned.
|
---|
432 | */
|
---|
433 | int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
|
---|
434 | unsigned fProt, size_t offSub, size_t cbSub);
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Maps a memory object into user virtual address space in the current process.
|
---|
438 | *
|
---|
439 | * @returns IPRT status code.
|
---|
440 | * @param ppMem Where to store the ring-0 memory object handle of the mapping object.
|
---|
441 | * @param pMemToMap The object to be map.
|
---|
442 | * @param R3PtrFixed Requested address. (RTR3PTR)-1 means any address. This matches uAlignment if specified.
|
---|
443 | * @param uAlignment The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
|
---|
444 | * @param fProt Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
|
---|
445 | * @param R0Process The process to map the memory into.
|
---|
446 | */
|
---|
447 | int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
|
---|
448 |
|
---|
449 | /**
|
---|
450 | * Change the page level protection of one or more pages in a memory object.
|
---|
451 | *
|
---|
452 | * @returns IPRT status code.
|
---|
453 | * @retval VERR_NOT_SUPPORTED see RTR0MemObjProtect.
|
---|
454 | *
|
---|
455 | * @param pMem The memory object.
|
---|
456 | * @param offSub Offset into the memory object. Page aligned.
|
---|
457 | * @param cbSub Number of bytes to change the protection of. Page
|
---|
458 | * aligned.
|
---|
459 | * @param fProt Combination of RTMEM_PROT_* flags.
|
---|
460 | */
|
---|
461 | int rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt);
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * Get the physical address of an page in the memory object.
|
---|
465 | *
|
---|
466 | * @returns The physical address.
|
---|
467 | * @returns NIL_RTHCPHYS if the object doesn't contain fixed physical pages.
|
---|
468 | * @returns NIL_RTHCPHYS if the iPage is out of range.
|
---|
469 | * @returns NIL_RTHCPHYS if the object handle isn't valid.
|
---|
470 | * @param pMem The ring-0 memory object handle.
|
---|
471 | * @param iPage The page number within the object (valid).
|
---|
472 | */
|
---|
473 | RTHCPHYS rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage);
|
---|
474 |
|
---|
475 | PRTR0MEMOBJINTERNAL rtR0MemObjNew(size_t cbSelf, RTR0MEMOBJTYPE enmType, void *pv, size_t cb);
|
---|
476 | void rtR0MemObjDelete(PRTR0MEMOBJINTERNAL pMem);
|
---|
477 |
|
---|
478 | /** @} */
|
---|
479 |
|
---|
480 | RT_C_DECLS_END
|
---|
481 |
|
---|
482 | #endif
|
---|
483 |
|
---|