VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.h@ 40966

Last change on this file since 40966 was 40966, checked in by vboxsync, 13 years ago

Runtime/r0drv/solaris: Dissolve VBI into IPRT.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: memobj-r0drv-solaris.h 40966 2012-04-17 16:43:28Z vboxsync $ */
2/** @file
3 * IPRT - Ring-0 Memory Objects - Segment driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2012 Oracle Corporation
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
27
28#ifndef ___r0drv_solaris_memobj_r0drv_solaris_h
29#define ___r0drv_solaris_memobj_r0drv_solaris_h
30
31/*******************************************************************************
32* Header Files *
33*******************************************************************************/
34#include "../the-solaris-kernel.h"
35
36
37/*******************************************************************************
38* Structures and Typedefs *
39*******************************************************************************/
40typedef struct SEGVBOX_CRARGS
41{
42 uint64_t *paPhysAddrs;
43 uint_t fPageAccess;
44} SEGVBOX_CRARGS;
45typedef SEGVBOX_CRARGS *PSEGVBOX_CRARGS;
46
47typedef struct SEGVBOX_DATA
48{
49 uint_t fPageAccess;
50} SEGVBOX_DATA;
51typedef SEGVBOX_DATA *PSEGVBOX_DATA;
52
53static struct seg_ops s_SegVBoxOps;
54static vnode_t s_segVBoxVnode;
55
56
57DECLINLINE(int) rtR0SegVBoxSolCreate(seg_t *pSeg, void *pvArgs)
58{
59 struct as *pAddrSpace = pSeg->s_as;
60 PSEGVBOX_CRARGS pArgs = pvArgs;
61 PSEGVBOX_DATA pData = kmem_zalloc(sizeof(*pData), KM_SLEEP);
62
63 AssertPtr(pAddrSpace);
64 AssertPtr(pArgs);
65 AssertPtr(pData);
66
67 hat_map(pAddrSpace->a_hat, pSeg->s_base, pSeg->s_size, HAT_MAP);
68 pData->fPageAccess = pArgs->fPageAccess | PROT_USER;
69
70 pSeg->s_ops = &s_SegVBoxOps;
71 pSeg->s_data = pData;
72
73 /*
74 * Now load the locked mappings to the pages.
75 */
76 caddr_t virtAddr = pSeg->s_base;
77 pgcnt_t cPages = (pSeg->s_size + PAGESIZE - 1) >> PAGESHIFT;
78 for (pgcnt_t iPage = 0; iPage < cPages; ++iPage, virtAddr += PAGESIZE)
79 {
80 hat_devload(pAddrSpace->a_hat, virtAddr, PAGESIZE, pArgs->paPhysAddrs[iPage] >> PAGESHIFT,
81 pData->fPageAccess | HAT_UNORDERED_OK, HAT_LOAD | HAT_LOAD_LOCK);
82 }
83
84 return 0;
85}
86
87
88static int rtR0SegVBoxSolDup(seg_t *pSrcSeg, seg_t *pDstSeg)
89{
90 /*
91 * Duplicate a segment and return the new segment in 'pDstSeg'.
92 */
93 PSEGVBOX_DATA pSrcData = pSrcSeg->s_data;
94 PSEGVBOX_DATA pDstData = kmem_zalloc(sizeof(*pDstData), KM_SLEEP);
95
96 AssertPtr(pDstData);
97 AssertPtr(pSrcData);
98
99 pDstData->fPageAccess = pSrcData->fPageAccess;
100 pDstSeg->s_ops = &s_SegVBoxOps;
101 pDstSeg->s_data = pDstData;
102
103 return 0;
104}
105
106
107static int rtR0SegVBoxSolUnmap(seg_t *pSeg, caddr_t virtAddr, size_t cb)
108{
109 /** @todo make these into release assertions. */
110 if ( virtAddr < pSeg->s_base
111 || virtAddr + cb > pSeg->s_base + pSeg->s_size
112 || (cb & PAGEOFFSET) || ((uintptr_t)virtAddr & PAGEOFFSET))
113 {
114 panic("rtRt0SegVBoxSolUnmap");
115 }
116
117 if (virtAddr != pSeg->s_base || cb != pSeg->s_size)
118 return ENOTSUP;
119
120 hat_unload(pSeg->s_as->a_hat, virtAddr, cb, HAT_UNLOAD_UNMAP | HAT_UNLOAD_UNLOCK);
121
122 seg_free(pSeg);
123 return 0;
124}
125
126
127static void rtR0SegVBoxSolFree(seg_t *pSeg)
128{
129 PSEGVBOX_DATA pData = pSeg->s_data;
130 kmem_free(pData, sizeof(*pData));
131}
132
133
134static int rtR0SegVBoxSolFault(struct hat *pHat, seg_t *pSeg, caddr_t virtAddr, size_t cb, enum fault_type FaultType,
135 enum seg_rw ReadWrite)
136{
137 /*
138 * We would demand fault if the (u)read() path would SEGOP_FAULT() on buffers mapped in via our
139 * segment driver i.e. prefaults before DMA. Don't fail in such case where we're called directly,
140 * see #5047.
141 */
142 return 0;
143}
144
145
146static int rtR0SegVBoxSolFaultA(seg_t *pSeg, caddr_t virtAddr)
147{
148 return 0;
149}
150
151
152static int rtR0SegVBoxSolSetProt(seg_t *pSeg, caddr_t virtAddr, size_t cb, uint_t fPageAccess)
153{
154 return EACCES;
155}
156
157
158static int rtR0SegVBoxSolCheckProt(seg_t *pSeg, caddr_t virtAddr, size_t cb, uint_t fPageAccess)
159{
160 return EINVAL;
161}
162
163
164static int rtR0SegVBoxSolKluster(seg_t *pSeg, caddr_t virtAddr, ssize_t Delta)
165{
166 return -1;
167}
168
169
170static int rtR0SegVBoxSolSync(seg_t *pSeg, caddr_t virtAddr, size_t cb, int Attr, uint_t fFlags)
171{
172 return 0;
173}
174
175
176static size_t rtR0SegVBoxSolInCore(seg_t *pSeg, caddr_t virtAddr, size_t cb, char *pVec)
177{
178 size_t cbLen = (cb + PAGEOFFSET) & PAGEMASK;
179 for (virtAddr = 0; cbLen != 0; cbLen -= PAGESIZE, virtAddr += PAGESIZE)
180 *pVec++ = 1;
181 return cbLen;
182}
183
184
185static int rtR0SegVBoxSolLockOp(seg_t *pSeg, caddr_t virtAddr, size_t cb, int Attr, int Op, ulong_t *pLockMap, size_t off)
186{
187 return 0;
188}
189
190
191static int rtR0SegVBoxSolGetProt(seg_t *pSeg, caddr_t virtAddr, size_t cb, uint_t *pafPageAccess)
192{
193 PSEGVBOX_DATA pData = pSeg->s_data;
194 size_t iPage = seg_page(pSeg, virtAddr + cb) - seg_page(pSeg, virtAddr) + 1;
195 if (iPage)
196 {
197 do
198 {
199 iPage--;
200 pafPageAccess[iPage] = pData->fPageAccess;
201 } while (iPage);
202 }
203 return 0;
204}
205
206
207static u_offset_t rtR0SegVBoxSolGetOffset(seg_t *pSeg, caddr_t virtAddr)
208{
209 return ((uintptr_t)virtAddr - (uintptr_t)pSeg->s_base);
210}
211
212
213static int rtR0SegVBoxSolGetType(seg_t *pSeg, caddr_t virtAddr)
214{
215 return MAP_SHARED;
216}
217
218
219static int rtR0SegVBoxSolGetVp(seg_t *pSeg, caddr_t virtAddr, vnode_t **ppVnode)
220{
221 *ppVnode = &s_segVBoxVnode;
222 return 0;
223}
224
225
226static int rtR0SegVBoxSolAdvise(seg_t *pSeg, caddr_t virtAddr, size_t cb, uint_t Behav /* wut? */)
227{
228 return 0;
229}
230
231
232static void rtR0SegVBoxSolDump(seg_t *pSeg)
233{
234 /* Nothing to do. */
235}
236
237
238static int rtR0SegVBoxSolPageLock(seg_t *pSeg, caddr_t virtAddr, size_t cb, page_t ***pppPage, enum lock_type LockType, enum seg_rw ReadWrite)
239{
240 return ENOTSUP;
241}
242
243
244static int rtR0SegVBoxSolSetPageSize(seg_t *pSeg, caddr_t virtAddr, size_t cb, uint_t SizeCode)
245{
246 return ENOTSUP;
247}
248
249
250static int rtR0SegVBoxSolGetMemId(seg_t *pSeg, caddr_t virtAddr, memid_t *pMemId)
251{
252 return ENODEV;
253}
254
255
256static lgrp_mem_policy_info_t *rtR0SegVBoxSolGetPolicy(seg_t *pSeg, caddr_t virtAddr)
257{
258 return NULL;
259}
260
261
262static int rtR0SegVBoxSolCapable(seg_t *pSeg, segcapability_t Capab)
263{
264 return 0;
265}
266
267
268static struct seg_ops s_SegVBoxOps =
269{
270 rtR0SegVBoxSolDup,
271 rtR0SegVBoxSolUnmap,
272 rtR0SegVBoxSolFree,
273 rtR0SegVBoxSolFault,
274 rtR0SegVBoxSolFaultA,
275 rtR0SegVBoxSolSetProt,
276 rtR0SegVBoxSolCheckProt,
277 rtR0SegVBoxSolKluster,
278 NULL, /* swapout */
279 rtR0SegVBoxSolSync,
280 rtR0SegVBoxSolInCore,
281 rtR0SegVBoxSolLockOp,
282 rtR0SegVBoxSolGetProt,
283 rtR0SegVBoxSolGetOffset,
284 rtR0SegVBoxSolGetType,
285 rtR0SegVBoxSolGetVp,
286 rtR0SegVBoxSolAdvise,
287 rtR0SegVBoxSolDump,
288 rtR0SegVBoxSolPageLock,
289 rtR0SegVBoxSolSetPageSize,
290 rtR0SegVBoxSolGetMemId,
291 rtR0SegVBoxSolGetPolicy,
292 rtR0SegVBoxSolCapable
293};
294
295#endif /* ___r0drv_solaris_memobj_r0drv_solaris_h */
296
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette