xref: /illumos-gate/usr/src/uts/intel/sys/pmem.h (revision cdd3e9a818787b4def17c9f707f435885ce0ed31)
1ae115bc7Smrj /*
2ae115bc7Smrj  * CDDL HEADER START
3ae115bc7Smrj  *
4ae115bc7Smrj  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License, Version 1.0 only
6ae115bc7Smrj  * (the "License").  You may not use this file except in compliance
7ae115bc7Smrj  * with the License.
8ae115bc7Smrj  *
9ae115bc7Smrj  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10ae115bc7Smrj  * or http://www.opensolaris.org/os/licensing.
11ae115bc7Smrj  * See the License for the specific language governing permissions
12ae115bc7Smrj  * and limitations under the License.
13ae115bc7Smrj  *
14ae115bc7Smrj  * When distributing Covered Code, include this CDDL HEADER in each
15ae115bc7Smrj  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16ae115bc7Smrj  * If applicable, add the following below this CDDL HEADER, with the
17ae115bc7Smrj  * fields enclosed by brackets "[]" replaced with your own identifying
18ae115bc7Smrj  * information: Portions Copyright [yyyy] [name of copyright owner]
19ae115bc7Smrj  *
20ae115bc7Smrj  * CDDL HEADER END
21ae115bc7Smrj  */
22ae115bc7Smrj /*
23ae115bc7Smrj  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24ae115bc7Smrj  * Use is subject to license terms.
25ae115bc7Smrj  */
26ae115bc7Smrj 
27ae115bc7Smrj #ifndef	_SYS_PMEM_H
28ae115bc7Smrj #define	_SYS_PMEM_H
29ae115bc7Smrj 
30ae115bc7Smrj #ifdef	__cplusplus
31ae115bc7Smrj extern "C" {
32ae115bc7Smrj #endif
33ae115bc7Smrj 
34ae115bc7Smrj /*
35ae115bc7Smrj  * PMEM - Direct mapping physical memory pages to userland process
36ae115bc7Smrj  *
37ae115bc7Smrj  * Provide consolidation private functions used for directly (w/o occupying
38ae115bc7Smrj  * kernel virtual address space) allocating and exporting physical memory pages
39ae115bc7Smrj  * to userland.
40ae115bc7Smrj  */
41ae115bc7Smrj 
42ae115bc7Smrj /*
43ae115bc7Smrj  * Flags to pass to pmem_alloc
44ae115bc7Smrj  */
45ae115bc7Smrj #define	PMEM_SLEEP	0x1
46ae115bc7Smrj #define	PMEM_NOSLEEP	0x2
47ae115bc7Smrj 
48ae115bc7Smrj /*
49ae115bc7Smrj  * Called by driver devmap routine to pass physical memory mapping info to
50ae115bc7Smrj  * seg_dev framework, used only for physical memory allocated from
51ae115bc7Smrj  * devmap_pmem_alloc().
52ae115bc7Smrj  */
53ae115bc7Smrj int	devmap_pmem_setup(devmap_cookie_t, dev_info_t *dip,
54ae115bc7Smrj     struct devmap_callback_ctl *, devmap_pmem_cookie_t, offset_t,
55*cdd3e9a8SRobert Mustacchi     size_t, uint_t, uint_t, const ddi_device_acc_attr_t *);
56ae115bc7Smrj 
57ae115bc7Smrj /*
58ae115bc7Smrj  * Replace existing mapping using a new cookie, mainly gets called when doing
59ae115bc7Smrj  * fork(). Should be called in pertinent devmap_dup(9E).
60ae115bc7Smrj  */
61ae115bc7Smrj int	devmap_pmem_remap(devmap_cookie_t, dev_info_t *dip,
62ae115bc7Smrj     devmap_pmem_cookie_t, offset_t, size_t, uint_t, uint_t,
63*cdd3e9a8SRobert Mustacchi     const ddi_device_acc_attr_t *);
64ae115bc7Smrj 
65ae115bc7Smrj /*
66ae115bc7Smrj  * Directly (i.e., without occupying kernel virtual address space) allocate
67ae115bc7Smrj  * 'npages' physical memory pages for exporting to user land. The allocated
68ae115bc7Smrj  * page_t pointer will be recorded in cookie.
69ae115bc7Smrj  */
70ae115bc7Smrj int	devmap_pmem_alloc(size_t, uint_t, devmap_pmem_cookie_t *);
71ae115bc7Smrj 
72ae115bc7Smrj void	devmap_pmem_free(devmap_pmem_cookie_t);
73ae115bc7Smrj 
74ae115bc7Smrj int	devmap_pmem_getpfns(devmap_pmem_cookie_t, uint_t, pgcnt_t, pfn_t *);
75ae115bc7Smrj 
76ae115bc7Smrj void    pmem_init();
77ae115bc7Smrj 
78ae115bc7Smrj #ifdef	__cplusplus
79ae115bc7Smrj }
80ae115bc7Smrj #endif
81ae115bc7Smrj 
82ae115bc7Smrj #endif	/* _SYS_PMEM_H */
83