xref: /onnv-gate/usr/src/uts/common/sys/mem_config.h (revision 3446:5903aece022d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3446Smrj  * Common Development and Distribution License (the "License").
6*3446Smrj  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*3446Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*3446Smrj  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_MEM_CONFIG_H
270Sstevel@tonic-gate #define	_SYS_MEM_CONFIG_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * Memory add/delete interfaces.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef _KERNEL
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * Memory add/delete client interface.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate extern int kphysm_add_memory_dynamic(pfn_t base, pgcnt_t npgs);
460Sstevel@tonic-gate 
470Sstevel@tonic-gate typedef void *memhandle_t;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * Managed pages have associated page structures ('page_t's).
510Sstevel@tonic-gate  * The difference between phys_pages and managed is accounted for by
520Sstevel@tonic-gate  * boot time memory allocation for the kernel text and data, and also
530Sstevel@tonic-gate  * for page structures.
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate typedef struct {
560Sstevel@tonic-gate 	pgcnt_t	phys_pages;	/* total physical pages */
570Sstevel@tonic-gate 	pgcnt_t	managed;	/* providing this many managed pages */
580Sstevel@tonic-gate 	pgcnt_t	nonrelocatable;	/* of which this many non-relocatable */
590Sstevel@tonic-gate 	pfn_t	first_nonrelocatable;
600Sstevel@tonic-gate 	pfn_t	last_nonrelocatable;
610Sstevel@tonic-gate } memquery_t;
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef struct {
640Sstevel@tonic-gate 	pgcnt_t	phys_pages;	/* total physical pages */
650Sstevel@tonic-gate 	pgcnt_t	managed;	/* providing this many managed pages */
660Sstevel@tonic-gate 	pgcnt_t	collected; 	/* done when == managed */
670Sstevel@tonic-gate } memdelstat_t;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate extern int kphysm_del_gethandle(memhandle_t *);
700Sstevel@tonic-gate 
710Sstevel@tonic-gate extern int kphysm_del_span(memhandle_t, pfn_t base, pgcnt_t npgs);
720Sstevel@tonic-gate 
730Sstevel@tonic-gate extern int kphysm_del_span_query(pfn_t base, pgcnt_t npgs, memquery_t *);
740Sstevel@tonic-gate 
750Sstevel@tonic-gate extern int kphysm_del_start(memhandle_t,
760Sstevel@tonic-gate 	void (*complete)(void *, int error), void *arg);
770Sstevel@tonic-gate 
780Sstevel@tonic-gate extern int kphysm_del_release(memhandle_t);
790Sstevel@tonic-gate 
800Sstevel@tonic-gate extern int kphysm_del_cancel(memhandle_t);
810Sstevel@tonic-gate 
820Sstevel@tonic-gate extern int kphysm_del_status(memhandle_t, memdelstat_t *);
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate  * Error returns.
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #define	KPHYSM_OK		0	/* Success */
890Sstevel@tonic-gate #define	KPHYSM_ESPAN		1	/* Memory already in use (add) */
900Sstevel@tonic-gate #define	KPHYSM_EFAULT		2	/* Memory access test failed (add) */
910Sstevel@tonic-gate #define	KPHYSM_ERESOURCE	3	/* Some resource was not available */
920Sstevel@tonic-gate #define	KPHYSM_ENOTSUP		4	/* Operation not supported */
930Sstevel@tonic-gate #define	KPHYSM_ENOHANDLES	5	/* Cannot allocate any more handles */
940Sstevel@tonic-gate #define	KPHYSM_ENONRELOC	6	/* Non-relocatable pages in span */
950Sstevel@tonic-gate #define	KPHYSM_EHANDLE		7	/* Bad handle supplied */
960Sstevel@tonic-gate #define	KPHYSM_EBUSY		8	/* Memory in span is being deleted */
970Sstevel@tonic-gate #define	KPHYSM_ENOTVIABLE	9	/* VM viability test failed */
980Sstevel@tonic-gate #define	KPHYSM_ESEQUENCE	10	/* Function called out of sequence */
990Sstevel@tonic-gate #define	KPHYSM_ENOWORK		11	/* No pages to delete */
1000Sstevel@tonic-gate #define	KPHYSM_ECANCELLED	12	/* kphysm_del_cancel (for complete) */
1010Sstevel@tonic-gate #define	KPHYSM_EREFUSED		13	/* kphysm_pre_del fail (for complete) */
1020Sstevel@tonic-gate #define	KPHYSM_ENOTFINISHED	14	/* Thread not finished */
1030Sstevel@tonic-gate #define	KPHYSM_ENOTRUNNING	15	/* Thread not running */
1040Sstevel@tonic-gate #define	KPHYSM_EDUP		16	/* Memory span duplicate (delete) */
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * Memory system change call-back interface.
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate #define	KPHYSM_SETUP_VECTOR_VERSION	1
1110Sstevel@tonic-gate typedef struct {
1120Sstevel@tonic-gate 	uint_t		version;
1130Sstevel@tonic-gate 	void		(*post_add)(void *arg, pgcnt_t delta_pages);
1140Sstevel@tonic-gate 	int		(*pre_del)(void *arg, pgcnt_t delta_pages);
1150Sstevel@tonic-gate 	void		(*post_del)(void *arg, pgcnt_t delta_pages,
1160Sstevel@tonic-gate 			    int cancelled);
1170Sstevel@tonic-gate } kphysm_setup_vector_t;
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /*
1200Sstevel@tonic-gate  * The register function returns 0 if the vector/arg pair is recorded
1210Sstevel@tonic-gate  * successfully.
1220Sstevel@tonic-gate  * The error returns are:
1230Sstevel@tonic-gate  *	EEXIST	if the vector/arg pair is already registered.
1240Sstevel@tonic-gate  *	EINVAL	if the vector version is not supported.
1250Sstevel@tonic-gate  *	ENOMEM	if the registration could not be stored.
1260Sstevel@tonic-gate  *
1270Sstevel@tonic-gate  * A return of EEXIST should be considered a program logic error by
1280Sstevel@tonic-gate  * the caller.
1290Sstevel@tonic-gate  */
1300Sstevel@tonic-gate extern int kphysm_setup_func_register(kphysm_setup_vector_t *, void *arg);
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate extern void kphysm_setup_func_unregister(kphysm_setup_vector_t *, void *arg);
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /*
1360Sstevel@tonic-gate  * Memory add/delete architecture (lower) interfaces.
1370Sstevel@tonic-gate  * These interfaces should not be used by drivers.
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate extern int arch_kphysm_del_span_ok(pfn_t, pgcnt_t);
1410Sstevel@tonic-gate extern int arch_kphysm_relocate(pfn_t, pgcnt_t);
1420Sstevel@tonic-gate extern int arch_kphysm_del_supported(void);
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate extern int pfn_is_being_deleted(pfn_t);
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #endif /* _KERNEL */
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate #ifdef	__cplusplus
1490Sstevel@tonic-gate }
1500Sstevel@tonic-gate #endif
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate #endif	/* _SYS_MEM_CONFIG_H */
153