xref: /titanic_52/usr/src/uts/sun4v/sys/drctl.h (revision 1d4b38e0077763e7c9b20768eacb841957e787bc)
1*1d4b38e0Srsmaeda /*
2*1d4b38e0Srsmaeda  * CDDL HEADER START
3*1d4b38e0Srsmaeda  *
4*1d4b38e0Srsmaeda  * The contents of this file are subject to the terms of the
5*1d4b38e0Srsmaeda  * Common Development and Distribution License (the "License").
6*1d4b38e0Srsmaeda  * You may not use this file except in compliance with the License.
7*1d4b38e0Srsmaeda  *
8*1d4b38e0Srsmaeda  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1d4b38e0Srsmaeda  * or http://www.opensolaris.org/os/licensing.
10*1d4b38e0Srsmaeda  * See the License for the specific language governing permissions
11*1d4b38e0Srsmaeda  * and limitations under the License.
12*1d4b38e0Srsmaeda  *
13*1d4b38e0Srsmaeda  * When distributing Covered Code, include this CDDL HEADER in each
14*1d4b38e0Srsmaeda  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1d4b38e0Srsmaeda  * If applicable, add the following below this CDDL HEADER, with the
16*1d4b38e0Srsmaeda  * fields enclosed by brackets "[]" replaced with your own identifying
17*1d4b38e0Srsmaeda  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1d4b38e0Srsmaeda  *
19*1d4b38e0Srsmaeda  * CDDL HEADER END
20*1d4b38e0Srsmaeda  */
21*1d4b38e0Srsmaeda 
22*1d4b38e0Srsmaeda /*
23*1d4b38e0Srsmaeda  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*1d4b38e0Srsmaeda  * Use is subject to license terms.
25*1d4b38e0Srsmaeda  */
26*1d4b38e0Srsmaeda 
27*1d4b38e0Srsmaeda #ifndef _SYS_DRCTL_H
28*1d4b38e0Srsmaeda #define	_SYS_DRCTL_H
29*1d4b38e0Srsmaeda 
30*1d4b38e0Srsmaeda #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1d4b38e0Srsmaeda 
32*1d4b38e0Srsmaeda #ifdef	__cplusplus
33*1d4b38e0Srsmaeda extern "C" {
34*1d4b38e0Srsmaeda #endif
35*1d4b38e0Srsmaeda 
36*1d4b38e0Srsmaeda 
37*1d4b38e0Srsmaeda #define	DRCTL_DEV "/devices/pseudo/drctl@0:drctl"
38*1d4b38e0Srsmaeda 
39*1d4b38e0Srsmaeda typedef enum {
40*1d4b38e0Srsmaeda 	DRCTL_CPU_CONFIG_REQUEST = 1,
41*1d4b38e0Srsmaeda 	DRCTL_CPU_CONFIG_NOTIFY,
42*1d4b38e0Srsmaeda 	DRCTL_CPU_UNCONFIG_REQUEST,
43*1d4b38e0Srsmaeda 	DRCTL_CPU_UNCONFIG_NOTIFY,
44*1d4b38e0Srsmaeda 	DRCTL_MEM_CONFIG_REQUEST,
45*1d4b38e0Srsmaeda 	DRCTL_MEM_CONFIG_NOTIFY,
46*1d4b38e0Srsmaeda 	DRCTL_MEM_UNCONFIG_REQUEST,
47*1d4b38e0Srsmaeda 	DRCTL_MEM_UNCONFIG_NOTIFY,
48*1d4b38e0Srsmaeda 	DRCTL_IO_CONFIG_REQUEST,
49*1d4b38e0Srsmaeda 	DRCTL_IO_CONFIG_NOTIFY,
50*1d4b38e0Srsmaeda 	DRCTL_IO_UNCONFIG_REQUEST,
51*1d4b38e0Srsmaeda 	DRCTL_IO_UNCONFIG_NOTIFY
52*1d4b38e0Srsmaeda } drctl_cmds_t;
53*1d4b38e0Srsmaeda 
54*1d4b38e0Srsmaeda /*
55*1d4b38e0Srsmaeda  * Responses to/from the daemon for a reconfig request.
56*1d4b38e0Srsmaeda  */
57*1d4b38e0Srsmaeda typedef enum {
58*1d4b38e0Srsmaeda 	DRCTL_STATUS_INIT,		/* to daemon */
59*1d4b38e0Srsmaeda 	DRCTL_STATUS_ALLOW,		/* from daemon */
60*1d4b38e0Srsmaeda 	DRCTL_STATUS_DENY,		/* from daemon */
61*1d4b38e0Srsmaeda 	DRCTL_STATUS_CONFIG_SUCCESS,	/* to daemon */
62*1d4b38e0Srsmaeda 	DRCTL_STATUS_CONFIG_FAILURE	/* to daemon */
63*1d4b38e0Srsmaeda } drctl_status_t;
64*1d4b38e0Srsmaeda 
65*1d4b38e0Srsmaeda /*
66*1d4b38e0Srsmaeda  * Each resource descriptor consists of a common header
67*1d4b38e0Srsmaeda  * followed by a resource-specific structure.
68*1d4b38e0Srsmaeda  */
69*1d4b38e0Srsmaeda 
70*1d4b38e0Srsmaeda typedef struct drctl_rsrc_cpu {
71*1d4b38e0Srsmaeda 	int		id;
72*1d4b38e0Srsmaeda } drctl_rsrc_cpu_t;
73*1d4b38e0Srsmaeda 
74*1d4b38e0Srsmaeda typedef struct drctl_rsrc_memory {
75*1d4b38e0Srsmaeda 	uint64_t	size;
76*1d4b38e0Srsmaeda 	uint64_t	addr;
77*1d4b38e0Srsmaeda } drctl_rsrc_mem_t;
78*1d4b38e0Srsmaeda 
79*1d4b38e0Srsmaeda typedef struct drctl_rsrc_dev {
80*1d4b38e0Srsmaeda 	char		path[1];
81*1d4b38e0Srsmaeda } drctl_rsrc_dev_t;
82*1d4b38e0Srsmaeda 
83*1d4b38e0Srsmaeda typedef struct drctl_rsrc {
84*1d4b38e0Srsmaeda 	drctl_status_t	status;
85*1d4b38e0Srsmaeda 	uint64_t	offset;
86*1d4b38e0Srsmaeda 	union {
87*1d4b38e0Srsmaeda 		drctl_rsrc_cpu_t cpu;
88*1d4b38e0Srsmaeda 		drctl_rsrc_mem_t mem;
89*1d4b38e0Srsmaeda 		drctl_rsrc_dev_t dev;
90*1d4b38e0Srsmaeda 	} un;
91*1d4b38e0Srsmaeda } drctl_rsrc_t;
92*1d4b38e0Srsmaeda 
93*1d4b38e0Srsmaeda #define	res_cpu_id	un.cpu.id
94*1d4b38e0Srsmaeda #define	res_mem_size	un.mem.size
95*1d4b38e0Srsmaeda #define	res_mem_addr	un.mem.addr
96*1d4b38e0Srsmaeda #define	res_dev_path	un.dev.path
97*1d4b38e0Srsmaeda 
98*1d4b38e0Srsmaeda /*
99*1d4b38e0Srsmaeda  * Message sent to DR daemon
100*1d4b38e0Srsmaeda  */
101*1d4b38e0Srsmaeda typedef struct drd_msg {
102*1d4b38e0Srsmaeda 	uint_t		cmd;
103*1d4b38e0Srsmaeda 	uint_t		count;
104*1d4b38e0Srsmaeda 	int		flags;
105*1d4b38e0Srsmaeda 	drctl_rsrc_t	data[1];
106*1d4b38e0Srsmaeda } drd_msg_t;
107*1d4b38e0Srsmaeda 
108*1d4b38e0Srsmaeda typedef void *drctl_cookie_t;
109*1d4b38e0Srsmaeda 
110*1d4b38e0Srsmaeda /*
111*1d4b38e0Srsmaeda  * DR RSMs (resource-specific modules) call these functions to
112*1d4b38e0Srsmaeda  * initialize or finalize a DR request.  A request may include
113*1d4b38e0Srsmaeda  * multiple resources of the same type.  The _init call returns
114*1d4b38e0Srsmaeda  * a cookie which must be supplied on by the corresponding
115*1d4b38e0Srsmaeda  * _fini call.
116*1d4b38e0Srsmaeda  */
117*1d4b38e0Srsmaeda extern int drctl_config_init(int, int,
118*1d4b38e0Srsmaeda     drctl_rsrc_t *, int, drctl_rsrc_t **, size_t *, drctl_cookie_t);
119*1d4b38e0Srsmaeda extern int drctl_config_fini(drctl_cookie_t, drctl_rsrc_t *, int);
120*1d4b38e0Srsmaeda 
121*1d4b38e0Srsmaeda /*
122*1d4b38e0Srsmaeda  * Values for the 2nd arg (flags) of drctl_config_init
123*1d4b38e0Srsmaeda  */
124*1d4b38e0Srsmaeda #define	DRCTL_FLAG_FORCE 1
125*1d4b38e0Srsmaeda 
126*1d4b38e0Srsmaeda 
127*1d4b38e0Srsmaeda #ifdef	__cplusplus
128*1d4b38e0Srsmaeda }
129*1d4b38e0Srsmaeda #endif
130*1d4b38e0Srsmaeda 
131*1d4b38e0Srsmaeda #endif	/* _SYS_DRCTL_H */
132