xref: /titanic_50/usr/src/uts/common/sys/mem_config.h (revision d73ae94e59c019f5cc3221ee0a0012d02091b40e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_MEM_CONFIG_H
28 #define	_SYS_MEM_CONFIG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Memory add/delete interfaces.
34  */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #ifdef _KERNEL
41 
42 /*
43  * Memory add/delete client interface.
44  */
45 
46 extern int kphysm_add_memory_dynamic(pfn_t base, pgcnt_t npgs);
47 
48 typedef void *memhandle_t;
49 
50 /*
51  * Managed pages have associated page structures ('page_t's).
52  * The difference between phys_pages and managed is accounted for by
53  * boot time memory allocation for the kernel text and data, and also
54  * for page structures.
55  */
56 typedef struct {
57 	pgcnt_t	phys_pages;	/* total physical pages */
58 	pgcnt_t	managed;	/* providing this many managed pages */
59 	pgcnt_t	nonrelocatable;	/* of which this many non-relocatable */
60 	pfn_t	first_nonrelocatable;
61 	pfn_t	last_nonrelocatable;
62 } memquery_t;
63 
64 typedef struct {
65 	pgcnt_t	phys_pages;	/* total physical pages */
66 	pgcnt_t	managed;	/* providing this many managed pages */
67 	pgcnt_t	collected; 	/* done when == managed */
68 } memdelstat_t;
69 
70 extern int kphysm_del_gethandle(memhandle_t *);
71 
72 extern int kphysm_del_span(memhandle_t, pfn_t base, pgcnt_t npgs);
73 
74 extern int kphysm_del_span_query(pfn_t base, pgcnt_t npgs, memquery_t *);
75 
76 extern int kphysm_del_start(memhandle_t,
77 	void (*complete)(void *, int error), void *arg);
78 
79 extern int kphysm_del_release(memhandle_t);
80 
81 extern int kphysm_del_cancel(memhandle_t);
82 
83 extern int kphysm_del_status(memhandle_t, memdelstat_t *);
84 
85 /*
86  * Error returns.
87  */
88 
89 #define	KPHYSM_OK		0	/* Success */
90 #define	KPHYSM_ESPAN		1	/* Memory already in use (add) */
91 #define	KPHYSM_EFAULT		2	/* Memory access test failed (add) */
92 #define	KPHYSM_ERESOURCE	3	/* Some resource was not available */
93 #define	KPHYSM_ENOTSUP		4	/* Operation not supported */
94 #define	KPHYSM_ENOHANDLES	5	/* Cannot allocate any more handles */
95 #define	KPHYSM_ENONRELOC	6	/* Non-relocatable pages in span */
96 #define	KPHYSM_EHANDLE		7	/* Bad handle supplied */
97 #define	KPHYSM_EBUSY		8	/* Memory in span is being deleted */
98 #define	KPHYSM_ENOTVIABLE	9	/* VM viability test failed */
99 #define	KPHYSM_ESEQUENCE	10	/* Function called out of sequence */
100 #define	KPHYSM_ENOWORK		11	/* No pages to delete */
101 #define	KPHYSM_ECANCELLED	12	/* kphysm_del_cancel (for complete) */
102 #define	KPHYSM_EREFUSED		13	/* kphysm_pre_del fail (for complete) */
103 #define	KPHYSM_ENOTFINISHED	14	/* Thread not finished */
104 #define	KPHYSM_ENOTRUNNING	15	/* Thread not running */
105 #define	KPHYSM_EDUP		16	/* Memory span duplicate (delete) */
106 
107 /*
108  * Memory system change call-back interface.
109  */
110 
111 #define	KPHYSM_SETUP_VECTOR_VERSION	1
112 typedef struct {
113 	uint_t		version;
114 	void		(*post_add)(void *arg, pgcnt_t delta_pages);
115 	int		(*pre_del)(void *arg, pgcnt_t delta_pages);
116 	void		(*post_del)(void *arg, pgcnt_t delta_pages,
117 			    int cancelled);
118 } kphysm_setup_vector_t;
119 
120 /*
121  * The register function returns 0 if the vector/arg pair is recorded
122  * successfully.
123  * The error returns are:
124  *	EEXIST	if the vector/arg pair is already registered.
125  *	EINVAL	if the vector version is not supported.
126  *	ENOMEM	if the registration could not be stored.
127  *
128  * A return of EEXIST should be considered a program logic error by
129  * the caller.
130  */
131 extern int kphysm_setup_func_register(kphysm_setup_vector_t *, void *arg);
132 
133 extern void kphysm_setup_func_unregister(kphysm_setup_vector_t *, void *arg);
134 
135 
136 /*
137  * Memory add/delete architecture (lower) interfaces.
138  * These interfaces should not be used by drivers.
139  */
140 
141 extern int arch_kphysm_del_span_ok(pfn_t, pgcnt_t);
142 extern int arch_kphysm_relocate(pfn_t, pgcnt_t);
143 extern int arch_kphysm_del_supported(void);
144 
145 extern int pfn_is_being_deleted(pfn_t);
146 
147 extern void memsegs_lock(int);
148 extern void memsegs_unlock(int);
149 
150 #endif /* _KERNEL */
151 
152 #ifdef	__cplusplus
153 }
154 #endif
155 
156 #endif	/* _SYS_MEM_CONFIG_H */
157