xref: /titanic_44/usr/src/uts/common/sys/mem.h (revision f6acbf7c6543dc0aab58cae1df419f0147c46d77)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_MEM_H
27 #define	_SYS_MEM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <sys/uio.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 #if defined(_SYSCALL32)
59 typedef struct mem_vtop32 {
60 	uint32_t	m_as;
61 	uint32_t	m_va;
62 	uint32_t	m_pfn;
63 } mem_vtop32_t;
64 #endif
65 
66 /*
67  * Private ioctls for fmd(1M).  These interfaces are Sun Private.  Applications
68  * and drivers should not make use of these interfaces: they can change without
69  * notice and programs that consume them will fail to run on future releases.
70  */
71 #define	MEM_NAME		(('M' << 8) | 0x04)
72 #define	MEM_INFO		(('M' << 8) | 0x05)
73 
74 #define	MEM_PAGE_RETIRE		(('M' << 8) | 0x02)
75 #define	MEM_PAGE_ISRETIRED	(('M' << 8) | 0x03)
76 #define	MEM_PAGE_UNRETIRE	(('M' << 8) | 0x06)
77 #define	MEM_PAGE_GETERRORS	(('M' << 8) | 0x07)
78 #define	MEM_PAGE_RETIRE_MCE	(('M' << 8) | 0x08)
79 #define	MEM_PAGE_RETIRE_UE	(('M' << 8) | 0x09)
80 #define	MEM_PAGE_RETIRE_TEST	(('M' << 8) | 0x0A)
81 
82 #define	MEM_SID			(('M' << 8) | 0x0B)
83 #define	MEM_PAGE_FMRI_RETIRE	(('M' << 8) | 0x0C)
84 #define	MEM_PAGE_FMRI_ISRETIRED	(('M' << 8) | 0x0D)
85 
86 /*
87  * Bits returned from MEM_PAGE_GETERRORS ioctl for use by fmd(1M).
88  */
89 #define	MEM_PAGE_ERR_NONE	0x0
90 #define	MEM_PAGE_ERR_MULTI_CE	0x1
91 #define	MEM_PAGE_ERR_UE		0x2
92 #define	MEM_PAGE_ERR_FMA_REQ	0x8
93 
94 #define	MEM_FMRI_MAX_BUFSIZE	8192	/* maximum allowed packed FMRI size */
95 
96 typedef struct mem_page {
97 	caddr_t		m_fmri;		/* buffer containing packed FMRI */
98 	size_t		m_fmrisz;	/* size of packed FMRI */
99 } mem_page_t;
100 
101 #if	defined(_SYSCALL32)
102 typedef struct mem_page32 {
103 	caddr32_t	m_fmri;
104 	size32_t	m_fmrisz;
105 } mem_page32_t;
106 #endif	/* _SYSCALL32 */
107 
108 typedef struct mem_name {
109 	uint64_t	m_addr;		/* memory address */
110 	uint64_t	m_synd;		/* architecture-specific syndrome */
111 	uint64_t	m_type[2];	/* architecture-specific type */
112 	caddr_t		m_name;		/* memory name buffer */
113 	size_t		m_namelen;	/* memory name buffer length */
114 	caddr_t		m_sid;		/* memory serial id buffer */
115 	size_t		m_sidlen;	/* memory serial id buffer length */
116 } mem_name_t;
117 
118 #if	defined(_SYSCALL32)
119 typedef struct mem_name32 {
120 	uint64_t	m_addr;
121 	uint64_t	m_synd;
122 	uint64_t	m_type[2];
123 	caddr32_t	m_name;
124 	size32_t	m_namelen;
125 	caddr32_t	m_sid;
126 	size32_t	m_sidlen;
127 } mem_name32_t;
128 #endif	/* _SYSCALL32 */
129 
130 typedef struct mem_info {
131 	uint64_t	m_addr;		/* memory address */
132 	uint64_t	m_synd;		/* architecture-specific syndrome */
133 	uint64_t	m_mem_size;	/* total memory size */
134 	uint64_t	m_seg_size;	/* segment size */
135 	uint64_t	m_bank_size;	/* bank size */
136 	int		m_segments;	/* # of segments */
137 	int		m_banks;	/* # of banks in segment */
138 	int		m_mcid;		/* associated memory controller id */
139 } mem_info_t;
140 
141 #ifdef	_KERNEL
142 
143 extern pfn_t impl_obmem_pfnum(pfn_t);
144 
145 extern int plat_mem_do_mmio(struct uio *, enum uio_rw);
146 
147 #endif	/* _KERNEL */
148 
149 #ifdef	__cplusplus
150 }
151 #endif
152 
153 #endif	/* _SYS_MEM_H */
154