xref: /titanic_50/usr/src/uts/intel/sys/pmem.h (revision 8d4e547db823a866b8f73efc0acdc423e2963caf)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PMEM_H
28 #define	_SYS_PMEM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * PMEM - Direct mapping physical memory pages to userland process
38  *
39  * Provide consolidation private functions used for directly (w/o occupying
40  * kernel virtual address space) allocating and exporting physical memory pages
41  * to userland.
42  */
43 
44 /*
45  * Flags to pass to pmem_alloc
46  */
47 #define	PMEM_SLEEP	0x1
48 #define	PMEM_NOSLEEP	0x2
49 
50 /*
51  * Called by driver devmap routine to pass physical memory mapping info to
52  * seg_dev framework, used only for physical memory allocated from
53  * devmap_pmem_alloc().
54  */
55 int	devmap_pmem_setup(devmap_cookie_t, dev_info_t *dip,
56     struct devmap_callback_ctl *, devmap_pmem_cookie_t, offset_t,
57     size_t, uint_t, uint_t, ddi_device_acc_attr_t *);
58 
59 /*
60  * Replace existing mapping using a new cookie, mainly gets called when doing
61  * fork(). Should be called in pertinent devmap_dup(9E).
62  */
63 int	devmap_pmem_remap(devmap_cookie_t, dev_info_t *dip,
64     devmap_pmem_cookie_t, offset_t, size_t, uint_t, uint_t,
65     ddi_device_acc_attr_t *);
66 
67 /*
68  * Directly (i.e., without occupying kernel virtual address space) allocate
69  * 'npages' physical memory pages for exporting to user land. The allocated
70  * page_t pointer will be recorded in cookie.
71  */
72 int	devmap_pmem_alloc(size_t, uint_t, devmap_pmem_cookie_t *);
73 
74 void	devmap_pmem_free(devmap_pmem_cookie_t);
75 
76 int	devmap_pmem_getpfns(devmap_pmem_cookie_t, uint_t, pgcnt_t, pfn_t *);
77 
78 void    pmem_init();
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif	/* _SYS_PMEM_H */
85