32
32
/*******************************************************************************
34
34
*******************************************************************************/
35
#include "the-solaris-kernel.h"
35
#include "../the-solaris-kernel.h"
36
#include "internal/iprt.h"
37
37
#include <iprt/memobj.h>
39
#include <iprt/assert.h>
39
40
#include <iprt/err.h>
40
#include <iprt/assert.h>
41
41
#include <iprt/log.h>
42
43
#include <iprt/param.h>
43
44
#include <iprt/process.h>
44
45
#include "internal/memobj.h"
83
86
case RTR0MEMOBJTYPE_LOCK:
84
vbi_unlock_va(pMemSolaris->Core.pv, pMemSolaris->Core.cb, pMemSolaris->handle);
87
vbi_unlock_va(pMemSolaris->Core.pv, pMemSolaris->Core.cb, pMemSolaris->fAccess, pMemSolaris->pvHandle);
87
90
case RTR0MEMOBJTYPE_MAPPING:
88
91
vbi_unmap(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
94
case RTR0MEMOBJTYPE_RES_VIRT:
96
if (pMemSolaris->Core.u.ResVirt.R0Process == NIL_RTR0PROCESS)
97
vmem_xfree(heap_arena, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
92
104
case RTR0MEMOBJTYPE_PHYS:
93
case RTR0MEMOBJTYPE_RES_VIRT:
95
106
AssertMsgFailed(("enmType=%d\n", pMemSolaris->Core.enmType));
96
107
return VERR_INTERNAL_ERROR;
206
int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process)
217
int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
208
219
AssertReturn(R0Process == RTR0ProcHandleSelf(), VERR_INVALID_PARAMETER);
210
222
/* Create the locking object */
211
223
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
212
224
if (!pMemSolaris)
213
225
return VERR_NO_MEMORY;
227
int fPageAccess = S_READ;
228
if (fAccess & RTMEM_PROT_WRITE)
229
fPageAccess = S_WRITE;
230
if (fAccess & RTMEM_PROT_EXEC)
231
fPageAccess = S_EXEC;
232
void *pvPageList = NULL;
217
234
/* Lock down user pages */
218
int rc = vbi_lock_va((caddr_t)R3Ptr, cb, &ppl);
235
int rc = vbi_lock_va((caddr_t)R3Ptr, cb, fPageAccess, &pvPageList);
221
238
cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: vbi_lock_va failed rc=%d\n", rc);
239
rtR0MemObjDelete(&pMemSolaris->Core);
222
240
return VERR_LOCK_FAILED;
225
243
pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)vbi_proc();
226
pMemSolaris->handle = ppl;
244
pMemSolaris->pvHandle = pvPageList;
245
pMemSolaris->fAccess = fPageAccess;
227
246
*ppMem = &pMemSolaris->Core;
228
247
return VINF_SUCCESS;
232
int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
251
int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess)
234
255
PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb);
235
256
if (!pMemSolaris)
236
257
return VERR_NO_MEMORY;
239
int rc = vbi_lock_va((caddr_t)pv, cb, &ppl);
259
int fPageAccess = S_READ;
260
if (fAccess & RTMEM_PROT_WRITE)
261
fPageAccess = S_WRITE;
262
if (fAccess & RTMEM_PROT_EXEC)
263
fPageAccess = S_EXEC;
264
void *pvPageList = NULL;
265
int rc = vbi_lock_va((caddr_t)pv, cb, fPageAccess, &pvPageList);
242
268
cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: vbi_lock_va failed rc=%d\n", rc);
269
rtR0MemObjDelete(&pMemSolaris->Core);
243
270
return VERR_LOCK_FAILED;
246
273
pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;
247
pMemSolaris->handle = ppl;
274
pMemSolaris->pvHandle = pvPageList;
275
pMemSolaris->fAccess = fPageAccess;
248
276
*ppMem = &pMemSolaris->Core;
249
277
return VINF_SUCCESS;
253
281
int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
255
return VERR_NOT_IMPLEMENTED;
283
PRTR0MEMOBJSOLARIS pMemSolaris;
289
pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/,
290
NULL /*minaddr*/, NULL /*maxaddr*/, VM_SLEEP);
292
return VERR_NO_MEMORY;
293
pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
296
vmem_xfree(heap_arena, pv, cb);
297
return VERR_NO_MEMORY;
300
pMemSolaris->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS;
301
*ppMem = &pMemSolaris->Core;
264
311
int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
265
312
unsigned fProt, size_t offSub, size_t cbSub)
267
/* @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */
314
/** @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */
268
315
return VERR_NOT_IMPLEMENTED;
271
319
int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
273
321
AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED);
274
322
AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
275
AssertMsgReturn(uAlignment == 0 || uAlignment == PAGE_SIZE, ("%d\n", uAlignment), VERR_NOT_SUPPORTED);
323
if (uAlignment > PAGE_SIZE)
324
return VERR_NOT_SUPPORTED;
277
326
PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;
278
327
size_t size = pMemToMapSolaris->Core.cb;