xref: /illumos-gate/usr/src/uts/common/sys/mem.h (revision d90554eb1da54eb443177f39ed0e119805d34a46)
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_MEM_H
28 #define	_SYS_MEM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 
38 /*
39  * Memory Device Minor Numbers
40  */
41 #define	M_MEM		0	/* /dev/mem - physical main memory */
42 #define	M_KMEM		1	/* /dev/kmem - virtual kernel memory */
43 #define	M_NULL		2	/* /dev/null - EOF & Rathole */
44 #define	M_ALLKMEM	3	/* /dev/allkmem - virtual kernel memory & I/O */
45 #define	M_ZERO		12	/* /dev/zero - source of private memory */
46 
47 /*
48  * Private ioctl for libkvm: translate virtual address to physical address.
49  */
50 #define	MEM_VTOP		(('M' << 8) | 0x01)
51 
52 typedef struct mem_vtop {
53 	struct as	*m_as;
54 	void		*m_va;
55 	pfn_t		m_pfn;
56 } mem_vtop_t;
57 
58 /*
59  * Private ioctls for fmd(1M).  These interfaces are Sun Private.  Applications
60  * and drivers should not make use of these interfaces: they can change without
61  * notice and programs that consume them will fail to run on future releases.
62  */
63 #define	MEM_NAME		(('M' << 8) | 0x04)
64 #define	MEM_INFO		(('M' << 8) | 0x05)
65 
66 #define	MEM_PAGE_RETIRE		(('M' << 8) | 0x02)
67 #define	MEM_PAGE_ISRETIRED	(('M' << 8) | 0x03)
68 #define	MEM_PAGE_UNRETIRE	(('M' << 8) | 0x06)
69 #define	MEM_PAGE_GETERRORS	(('M' << 8) | 0x07)
70 #define	MEM_PAGE_RETIRE_MCE	(('M' << 8) | 0x08)
71 #define	MEM_PAGE_RETIRE_UE	(('M' << 8) | 0x09)
72 #define	MEM_PAGE_RETIRE_TEST	(('M' << 8) | 0x0A)
73 
74 #define	MEM_SID			(('M' << 8) | 0x0B)
75 #define	MEM_PAGE_FMRI_RETIRE	(('M' << 8) | 0x0C)
76 #define	MEM_PAGE_FMRI_ISRETIRED	(('M' << 8) | 0x0D)
77 
78 /*
79  * Bits returned from MEM_PAGE_GETERRORS ioctl for use by fmd(1M).
80  */
81 #define	MEM_PAGE_ERR_NONE	0x0
82 #define	MEM_PAGE_ERR_MULTI_CE	0x1
83 #define	MEM_PAGE_ERR_UE		0x2
84 #define	MEM_PAGE_ERR_FMA_REQ	0x8
85 
86 #define	MEM_FMRI_MAX_BUFSIZE	8192	/* maximum allowed packed FMRI size */
87 
88 typedef struct mem_page {
89 	caddr_t		m_fmri;		/* buffer containing packed FMRI */
90 	size_t		m_fmrisz;	/* size of packed FMRI */
91 } mem_page_t;
92 
93 #if	defined(_SYSCALL32)
94 typedef struct mem_page32 {
95 	caddr32_t	m_fmri;
96 	size32_t	m_fmrisz;
97 } mem_page32_t;
98 #endif	/* _SYSCALL32 */
99 
100 typedef struct mem_name {
101 	uint64_t	m_addr;		/* memory address */
102 	uint64_t	m_synd;		/* architecture-specific syndrome */
103 	uint64_t	m_type[2];	/* architecture-specific type */
104 	caddr_t		m_name;		/* memory name buffer */
105 	size_t		m_namelen;	/* memory name buffer length */
106 	caddr_t		m_sid;		/* memory serial id buffer */
107 	size_t		m_sidlen;	/* memory serial id buffer length */
108 } mem_name_t;
109 
110 #if	defined(_SYSCALL32)
111 typedef struct mem_name32 {
112 	uint64_t	m_addr;
113 	uint64_t	m_synd;
114 	uint64_t	m_type[2];
115 	caddr32_t	m_name;
116 	size32_t	m_namelen;
117 	caddr32_t	m_sid;
118 	size32_t	m_sidlen;
119 } mem_name32_t;
120 #endif	/* _SYSCALL32 */
121 
122 typedef struct mem_info {
123 	uint64_t	m_addr;		/* memory address */
124 	uint64_t	m_synd;		/* architecture-specific syndrome */
125 	uint64_t	m_mem_size;	/* total memory size */
126 	uint64_t	m_seg_size;	/* segment size */
127 	uint64_t	m_bank_size;	/* bank size */
128 	int		m_segments;	/* # of segments */
129 	int		m_banks;	/* # of banks in segment */
130 	int		m_mcid;		/* associated memory controller id */
131 } mem_info_t;
132 
133 #ifdef	_KERNEL
134 
135 extern pfn_t impl_obmem_pfnum(pfn_t);
136 
137 #endif	/* _KERNEL */
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif	/* _SYS_MEM_H */
144