xref: /titanic_51/usr/src/lib/fm/libldom/sparc/ldom.h (revision c3a558e7c77127215b010652905be7916ec5a080)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LDOM_H
27 #define	_LDOM_H
28 
29 #include <stdlib.h>
30 #include <libnvpair.h>
31 #include <sys/types.h>
32 #include <umem.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct ldom_hdl ldom_hdl_t;
39 
40 extern ldom_hdl_t *ldom_init(void *(*allocp)(size_t size),
41 			    void (*freep)(void *addr, size_t size));
42 extern void ldom_fini(ldom_hdl_t *lhp);
43 
44 extern int ldom_fmri_status(ldom_hdl_t *lhp, nvlist_t *nvl_fmri);
45 extern int ldom_fmri_retire(ldom_hdl_t *lhp, nvlist_t *nvl_fmri);
46 extern int ldom_fmri_unretire(ldom_hdl_t *lhp, nvlist_t *nvl_fmri);
47 extern int ldom_fmri_blacklist(ldom_hdl_t *lhp, nvlist_t *nvl_fmri);
48 extern int ldom_fmri_unblacklist(ldom_hdl_t *lhp, nvlist_t *nvl_fmri);
49 
50 extern ssize_t ldom_get_core_md(ldom_hdl_t *lhp, uint64_t **buf);
51 extern ssize_t ldom_get_local_md(ldom_hdl_t *lhp, uint64_t **buf);
52 
53 /*
54  * domain type
55  */
56 #define	LDOM_TYPE_LEGACY	0x1
57 #define	LDOM_TYPE_CONTROL	0x2
58 #define	LDOM_TYPE_ROOT		0x4
59 #define	LDOM_TYPE_IO		0x8
60 #define	LDOM_TYPE_ALL \
61 	(LDOM_TYPE_LEGACY | LDOM_TYPE_CONTROL | LDOM_TYPE_ROOT | LDOM_TYPE_IO)
62 #define	VALID_LDOM_TYPE(t)	((t) & LDOM_TYPE_ALL)
63 
64 extern int ldom_get_type(ldom_hdl_t *lhp, uint32_t *type_mask);
65 
66 /*
67  * Resource map
68  */
69 typedef enum ldom_rsrc {
70 	LDOM_RSRC_PCI,
71 	LDOM_RSRC_NIU,
72 	LDOM_RSRC_MAX
73 } ldom_rsrc_t;
74 
75 extern int
76 ldom_find_id(ldom_hdl_t *lhp, uint64_t addr, ldom_rsrc_t type,
77     uint64_t *virt_addr, char *name, int name_size, uint64_t *id);
78 
79 /*
80  * event notification
81  */
82 typedef enum ldom_event {
83 	LDOM_EVENT_UNKNOWN,
84 	LDOM_EVENT_ADD,
85 	LDOM_EVENT_REMOVE,
86 	LDOM_EVENT_BIND,
87 	LDOM_EVENT_UNBIND,
88 	LDOM_EVENT_START,
89 	LDOM_EVENT_STOP,
90 	LDOM_EVENT_RESET,
91 	LDOM_EVENT_PANIC,
92 	LDOM_EVENT_MAX
93 } ldom_event_t;
94 #define	VALID_LDOM_EVENT(e)	((e) > LDOM_EVENT_UNKNOWN && \
95 				(e) < LDOM_EVENT_MAX)
96 #define	MAX_LDOM_NAME		256
97 
98 typedef void *ldom_cb_arg_t;
99 typedef void (*ldom_reg_cb_t)(char *ldom_name, ldom_event_t event,
100 				ldom_cb_arg_t data);
101 extern int ldom_register_event(ldom_hdl_t *lhp, ldom_reg_cb_t cb,
102 				ldom_cb_arg_t data);
103 extern int ldom_unregister_event(ldom_hdl_t *lhp);
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif	/* _LDOM_H */
110