xref: /titanic_51/usr/src/uts/sun4v/sys/drctl.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DRCTL_H
28 #define	_SYS_DRCTL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
38 
39 typedef enum {
40 	DRCTL_CPU_CONFIG_REQUEST = 1,
41 	DRCTL_CPU_CONFIG_NOTIFY,
42 	DRCTL_CPU_UNCONFIG_REQUEST,
43 	DRCTL_CPU_UNCONFIG_NOTIFY,
44 	DRCTL_MEM_CONFIG_REQUEST,
45 	DRCTL_MEM_CONFIG_NOTIFY,
46 	DRCTL_MEM_UNCONFIG_REQUEST,
47 	DRCTL_MEM_UNCONFIG_NOTIFY,
48 	DRCTL_IO_CONFIG_REQUEST,
49 	DRCTL_IO_CONFIG_NOTIFY,
50 	DRCTL_IO_UNCONFIG_REQUEST,
51 	DRCTL_IO_UNCONFIG_NOTIFY
52 } drctl_cmds_t;
53 
54 /*
55  * Responses to/from the daemon for a reconfig request.
56  */
57 typedef enum {
58 	DRCTL_STATUS_INIT,		/* to daemon */
59 	DRCTL_STATUS_ALLOW,		/* from daemon */
60 	DRCTL_STATUS_DENY,		/* from daemon */
61 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
62 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
63 } drctl_status_t;
64 
65 /*
66  * Each resource descriptor consists of a common header
67  * followed by a resource-specific structure.
68  */
69 
70 typedef struct drctl_rsrc_cpu {
71 	int		id;
72 } drctl_rsrc_cpu_t;
73 
74 typedef struct drctl_rsrc_memory {
75 	uint64_t	size;
76 	uint64_t	addr;
77 } drctl_rsrc_mem_t;
78 
79 typedef struct drctl_rsrc_dev {
80 	char		path[1];
81 } drctl_rsrc_dev_t;
82 
83 typedef struct drctl_rsrc {
84 	drctl_status_t	status;
85 	uint64_t	offset;
86 	union {
87 		drctl_rsrc_cpu_t cpu;
88 		drctl_rsrc_mem_t mem;
89 		drctl_rsrc_dev_t dev;
90 	} un;
91 } drctl_rsrc_t;
92 
93 #define	res_cpu_id	un.cpu.id
94 #define	res_mem_size	un.mem.size
95 #define	res_mem_addr	un.mem.addr
96 #define	res_dev_path	un.dev.path
97 
98 /*
99  * Message sent to DR daemon
100  */
101 typedef struct drd_msg {
102 	uint_t		cmd;
103 	uint_t		count;
104 	int		flags;
105 	drctl_rsrc_t	data[1];
106 } drd_msg_t;
107 
108 typedef void *drctl_cookie_t;
109 
110 /*
111  * DR RSMs (resource-specific modules) call these functions to
112  * initialize or finalize a DR request.  A request may include
113  * multiple resources of the same type.  The _init call returns
114  * a cookie which must be supplied on by the corresponding
115  * _fini call.
116  */
117 extern int drctl_config_init(int, int,
118     drctl_rsrc_t *, int, drctl_rsrc_t **, size_t *, drctl_cookie_t);
119 extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
120 
121 /*
122  * Values for the 2nd arg (flags) of drctl_config_init
123  */
124 #define	DRCTL_FLAG_FORCE 1
125 
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif	/* _SYS_DRCTL_H */
132