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