1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _VM_XHAT_H
#define _VM_XHAT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ASM
#include <sys/types.h>
#include <vm/page.h>
#include <sys/kmem.h>
struct xhat;
struct xhat_hme_blk;
struct xhat_ops {
struct xhat *(*xhat_alloc)(void *);
void (*xhat_free)(struct xhat *);
void (*xhat_free_start)(struct xhat *);
void (*xhat_free_end)(struct xhat *);
int (*xhat_dup)(struct xhat *, struct xhat *, caddr_t,
size_t, uint_t);
void (*xhat_swapin)(struct xhat *);
void (*xhat_swapout)(struct xhat *);
void (*xhat_memload)(struct xhat *, caddr_t, struct page *,
uint_t, uint_t);
void (*xhat_memload_array)(struct xhat *, caddr_t, size_t,
struct page **, uint_t, uint_t);
void (*xhat_devload)(struct xhat *, caddr_t, size_t, pfn_t,
uint_t, int);
void (*xhat_unload)(struct xhat *, caddr_t, size_t, uint_t);
void (*xhat_unload_callback)(struct xhat *, caddr_t, size_t,
uint_t, hat_callback_t *);
void (*xhat_setattr)(struct xhat *, caddr_t, size_t, uint_t);
void (*xhat_clrattr)(struct xhat *, caddr_t, size_t, uint_t);
void (*xhat_chgattr)(struct xhat *, caddr_t, size_t, uint_t);
void (*xhat_unshare)(struct xhat *, caddr_t, size_t);
void (*xhat_chgprot)(struct xhat *, caddr_t, size_t, uint_t);
int (*xhat_pageunload)(struct xhat *, struct page *, uint_t,
void *);
};
#define XHAT_POPS(_p) (_p)->xhat_provider_ops
#define XHAT_PROPS(_h) XHAT_POPS(((struct xhat *)(_h))->xhat_provider)
#define XHAT_HOPS(hat, func, args) \
{ \
if (XHAT_PROPS(hat)-> /* */ func) \
XHAT_PROPS(hat)-> /* */ func /* */ args; \
}
#define XHAT_FREE_START(a) \
XHAT_HOPS(a, xhat_free_start, ((struct xhat *)(a)))
#define XHAT_FREE_END(a) \
XHAT_HOPS(a, xhat_free_end, ((struct xhat *)(a)))
#define XHAT_DUP(a, b, c, d, e) \
((XHAT_PROPS(a)->xhat_dup == NULL) ? (0) : \
XHAT_PROPS(a)->xhat_dup((struct xhat *)(a), \
(struct xhat *)(b), c, d, e))
#define XHAT_SWAPIN(a) \
XHAT_HOPS(a, xhat_swapin, ((struct xhat *)(a)))
#define XHAT_SWAPOUT(a) \
XHAT_HOPS(a, xhat_swapout, ((struct xhat *)(a)))
#define XHAT_MEMLOAD(a, b, c, d, e) \
XHAT_HOPS(a, xhat_memload, ((struct xhat *)(a), b, c, d, e))
#define XHAT_MEMLOAD_ARRAY(a, b, c, d, e, f) \
XHAT_HOPS(a, xhat_memload_array, ((struct xhat *)(a), b, c, d, e, f))
#define XHAT_DEVLOAD(a, b, c, d, e, f) \
XHAT_HOPS(a, xhat_devload, ((struct xhat *)(a), b, c, d, e, f))
#define XHAT_UNLOAD(a, b, c, d) \
XHAT_HOPS(a, xhat_unload, ((struct xhat *)(a), b, c, d))
#define XHAT_UNLOAD_CALLBACK(a, b, c, d, e) \
XHAT_HOPS(a, xhat_unload_callback, ((struct xhat *)(a), b, c, d, e))
#define XHAT_SETATTR(a, b, c, d) \
XHAT_HOPS(a, xhat_setattr, ((struct xhat *)(a), b, c, d))
#define XHAT_CLRATTR(a, b, c, d) \
XHAT_HOPS(a, xhat_clrattr, ((struct xhat *)(a), b, c, d))
#define XHAT_CHGATTR(a, b, c, d) \
XHAT_HOPS(a, xhat_chgattr, ((struct xhat *)(a), b, c, d))
#define XHAT_UNSHARE(a, b, c) \
XHAT_HOPS(a, xhat_unshare, ((struct xhat *)(a), b, c))
#define XHAT_CHGPROT(a, b, c, d) \
XHAT_HOPS(a, xhat_chgprot, ((struct xhat *)(a), b, c, d))
#define XHAT_PAGEUNLOAD(a, b, c, d) \
((XHAT_PROPS(a)->xhat_pageunload == NULL) ? (0) : \
XHAT_PROPS(a)->xhat_pageunload((struct xhat *)(a), b, c, d))
#define XHAT_PROVIDER_VERSION 1
/*
* Provider name will be appended with "_cache"
* when initializing kmem cache.
* The resulting sring must be less than
* KMEM_CACHE_NAMELEN
*/
#define XHAT_CACHE_NAMELEN 24
typedef struct xblk_cache {
kmutex_t lock;
kmem_cache_t *cache;
void *free_blks;
void (*reclaim)(void *);
} xblk_cache_t;
typedef struct xhat_provider {
int xhat_provider_version;
int xhat_provider_refcnt;
struct xhat_provider *next;
struct xhat_provider *prev;
char xhat_provider_name[XHAT_CACHE_NAMELEN];
xblk_cache_t *xblkcache;
struct xhat_ops *xhat_provider_ops;
int xhat_provider_blk_size;
} xhat_provider_t;
/*
* The xhat structure is protected by xhat_lock.
* A particular xhat implementation is a extension of the
* xhat structure and may contain its own lock(s) to
* protect those additional fields.
* The xhat structure is never allocated directly.
* Instead its allocation is provided by the hat implementation.
* The xhat provider ops xhat_alloc/xhat_free are used to
* alloc/free a implementation dependant xhat structure.
*/
struct xhat {
xhat_provider_t *xhat_provider;
struct as *xhat_as;
void *arg;
struct xhat *prev;
struct xhat *next;
kmutex_t xhat_lock;
int xhat_refcnt;
kthread_t *holder;
};
/* Error codes */
#define XH_PRVDR (1) /* Provider-specific error */
#define XH_ASBUSY (2) /* Address space is busy */
#define XH_XHHELD (3) /* XHAT is being held */
#define XH_NOTATTCHD (4) /* Provider is not attached to as */
int xhat_provider_register(xhat_provider_t *);
int xhat_provider_unregister(xhat_provider_t *);
void xhat_init(void);
int xhat_attach_xhat(xhat_provider_t *, struct as *, struct xhat **,
void *);
int xhat_detach_xhat(xhat_provider_t *, struct as *);
pfn_t xhat_insert_xhatblk(page_t *, struct xhat *, void **);
int xhat_delete_xhatblk(void *, int);
void xhat_hat_hold(struct xhat *);
void xhat_hat_rele(struct xhat *);
int xhat_hat_holders(struct xhat *);
void xhat_free_start_all(struct as *);
void xhat_free_end_all(struct as *);
int xhat_dup_all(struct as *, struct as *, caddr_t, size_t, uint_t);
void xhat_swapout_all(struct as *);
void xhat_unload_callback_all(struct as *, caddr_t, size_t, uint_t,
hat_callback_t *);
void xhat_setattr_all(struct as *, caddr_t, size_t, uint_t);
void xhat_clrattr_all(struct as *, caddr_t, size_t, uint_t);
void xhat_chgattr_all(struct as *, caddr_t, size_t, uint_t);
void xhat_chgprot_all(struct as *, caddr_t, size_t, uint_t);
void xhat_unshare_all(struct as *, caddr_t, size_t);
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _VM_XHAT_H */
|