xref: /titanic_41/usr/src/uts/sun4v/sys/dr_mem.h (revision 82629e3015252bf18319ba3815c773df23e21436)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _DR_MEM_H
28 #define	_DR_MEM_H
29 
30 /*
31  * Memory DR Control Protocol
32  */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Memory DR Message Header
40  */
41 typedef struct {
42 	uint32_t	msg_type;	/* message type */
43 	uint32_t	msg_arg;	/* messages argument */
44 	uint64_t	req_num;	/* request number */
45 } dr_mem_hdr_t;
46 
47 /*
48  * Memory command and response messages
49  */
50 
51 #define	DR_MEM_DS_ID		"dr-mem"
52 
53 #define	DR_MEM_CONFIGURE	(0x4d43)	/* 'MC' configure mem */
54 #define	DR_MEM_UNCONFIGURE	(0x4d55)	/* 'MU' unconfigure  mem */
55 #define	DR_MEM_UNCONF_STATUS	(0x4d53)	/* 'MS' get mem unconf status */
56 #define	DR_MEM_UNCONF_CANCEL	(0x4d4e)	/* 'MN' cancel mem unconf */
57 #define	DR_MEM_QUERY		(0x4d51)	/* 'MQ' query mem info */
58 
59 #define	DR_MEM_OK		('o')
60 #define	DR_MEM_ERROR		('e')
61 
62 typedef struct {
63 	uint64_t	addr;		/* mblk base address */
64 	uint64_t	size;		/* mblk size */
65 } dr_mem_blk_t;
66 
67 /*
68  * Response Message
69  */
70 typedef struct {
71 	uint64_t	addr;		/* mblk base address */
72 	uint64_t	size;		/* mblk size */
73 	uint32_t	result;		/* result of the operation */
74 	uint32_t	status;		/* status of the mblk */
75 	uint32_t	string_off;	/* informational string offset */
76 	uint32_t	reserved;	/* padding */
77 } dr_mem_stat_t;
78 
79 typedef struct {
80 	uint64_t	addr;		/* query address */
81 	memquery_t	mq;		/* query results */
82 } dr_mem_query_t;
83 
84 /*
85  * Result Codes
86  */
87 #define	DR_MEM_RES_OK			0x0	/* operation succeeded */
88 #define	DR_MEM_RES_FAILURE		0x1	/* operation failed */
89 #define	DR_MEM_RES_BLOCKED		0x2	/* operation was blocked */
90 #define	DR_MEM_RES_NOT_IN_MD		0x3	/* memory not defined in MD */
91 #define	DR_MEM_RES_ESPAN		0x4	/* memory already in use */
92 #define	DR_MEM_RES_EFAULT		0x5	/* memory access test failed */
93 #define	DR_MEM_RES_ERESOURCE		0x6	/* resource not available */
94 #define	DR_MEM_RES_PERM			0x7	/* permanent pages in span */
95 #define	DR_MEM_RES_EBUSY		0x8	/* memory span busy */
96 #define	DR_MEM_RES_ENOTVIABLE		0x9	/* VM viability test failed */
97 #define	DR_MEM_RES_ENOWORK		0xA	/* no pages to unconfigure */
98 #define	DR_MEM_RES_ECANCELLED		0xB	/* operation cancelled */
99 #define	DR_MEM_RES_EREFUSED		0xC	/* operation refused */
100 #define	DR_MEM_RES_EDUP			0xD	/* memory span duplicate */
101 #define	DR_MEM_RES_EINVAL		0xE	/* invalid argument */
102 
103 /*
104  * Status Codes
105  */
106 #define	DR_MEM_STAT_NOT_PRESENT		0x0	/* mblk ID not in MD */
107 #define	DR_MEM_STAT_UNCONFIGURED	0x1	/* mblk unconfigured */
108 #define	DR_MEM_STAT_CONFIGURED		0x2	/* mblk configured */
109 
110 /*
111  * Macros to access arrays that follow message header
112  */
113 #define	DR_MEM_HDR(h)		((dr_mem_hdr_t *)(h))
114 #define	DR_MEM_CMD_MBLKS(h)	((dr_mem_blk_t *)((DR_MEM_HDR(h)) + 1))
115 #define	DR_MEM_RESP_STATS(h)	((dr_mem_stat_t *)((DR_MEM_HDR(h)) + 1))
116 #define	DR_MEM_RESP_DEL_STAT(h)	((memdelstat_t *)(DR_MEM_HDR(h) + 1))
117 #define	DR_MEM_RESP_QUERY(h)	((dr_mem_query_t *)(DR_MEM_HDR(h) + 1))
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif /* _DR_MEM_H */
124