xref: /titanic_41/usr/src/uts/sun4u/ngdr/sys/dr_util.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_DR_UTIL_H_
28 #define	_SYS_DR_UTIL_H_
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/memlist.h>
34 #include <sys/sbd_ioctl.h>
35 #include <sys/varargs.h>
36 #include <sys/kmem.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	GETSTRUCT(t, n) \
43 		((t *)kmem_zalloc((size_t)(n) * sizeof (t), KM_SLEEP))
44 #define	FREESTRUCT(p, t, n) \
45 		(kmem_free((caddr_t)(p), sizeof (t) * (size_t)(n)))
46 
47 #define	DRERR_SET_C(epps, eppn)		\
48 	if (*(epps) == NULL)		\
49 		*(epps) = *(eppn);	\
50 	else				\
51 		sbd_err_clear(eppn)
52 
53 #ifdef DEBUG
54 #define	MEMLIST_DUMP(ml) memlist_dump(ml)
55 #else
56 #define	MEMLIST_DUMP(ml)
57 #endif
58 
59 extern sbd_error_t	*sbd_err_new(int e_code, char *fmt, va_list args);
60 extern void		sbd_err_log(sbd_error_t *ep, int ce);
61 extern void		sbd_err_clear(sbd_error_t **ep);
62 extern void		sbd_err_set_c(sbd_error_t **ep, int ce,
63 				int e_code, char *fmt, ...);
64 extern void		sbd_err_set(sbd_error_t **ep, int ce,
65 				int e_code, char *fmt, ...);
66 
67 extern sbd_error_t	*drerr_new(int log, int e_code, char *fmt, ...);
68 extern sbd_error_t	*drerr_new_v(int e_code, char *fmt, va_list args);
69 extern void		drerr_set_c(int log, sbd_error_t **ep,
70 				int e_code, char *fmt, ...);
71 
72 extern void		memlist_delete(struct memlist *mlist);
73 extern void		memlist_dump(struct memlist *mlist);
74 extern int		memlist_intersect(struct memlist *al,
75 				struct memlist *bl);
76 extern void		memlist_coalesce(struct memlist *mlist);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* _SYS_DR_UTIL_H_ */
83