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.
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.
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]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_DR_UTIL_H_
27 #define _SYS_DR_UTIL_H_
28 #include <sys/types.h>
30 #include <sys/memlist.h>
31 #include <sys/varargs.h>
32 #include <sys/sbd_ioctl.h>
38 #define GETSTRUCT(t, n) \
39 ((t *)kmem_zalloc((size_t)(n) * sizeof (t), KM_SLEEP))
40 #define FREESTRUCT(p, t, n) \
41 (kmem_free((caddr_t)(p), sizeof (t) * (size_t)(n)))
43 #define DRERR_SET_C(epps, eppn) \
44 if (*(epps) == NULL) \
50 #define MEMLIST_DUMP(ml) memlist_dump(ml)
52 #define MEMLIST_DUMP(ml)
55 extern sbd_error_t
*sbd_err_new(int e_code
, char *fmt
, va_list args
);
56 extern void sbd_err_log(sbd_error_t
*ep
, int ce
);
57 extern void sbd_err_clear(sbd_error_t
**ep
);
58 extern void sbd_err_set_c(sbd_error_t
**ep
, int ce
,
59 int e_code
, char *fmt
, ...);
60 extern void sbd_err_set(sbd_error_t
**ep
, int ce
,
61 int e_code
, char *fmt
, ...);
63 extern sbd_error_t
*drerr_new(int log
, int e_code
, char *fmt
, ...);
64 extern sbd_error_t
*drerr_new_v(int e_code
, char *fmt
, va_list args
);
65 extern void drerr_set_c(int log
, sbd_error_t
**ep
,
66 int e_code
, char *fmt
, ...);
68 extern void dr_memlist_delete(struct memlist
*mlist
);
69 extern void memlist_dump(struct memlist
*mlist
);
70 extern int dr_memlist_intersect(struct memlist
*al
,
72 extern void dr_memlist_coalesce(struct memlist
*mlist
);
73 extern struct memlist
*dr_memlist_dup(struct memlist
*mlist
);
74 extern struct memlist
*dr_memlist_add_span(struct memlist
*mlist
,
75 uint64_t base
, uint64_t len
);
76 extern struct memlist
*dr_memlist_del_span(struct memlist
*mlist
,
77 uint64_t base
, uint64_t len
);
78 extern struct memlist
*dr_memlist_cat_span(struct memlist
*mlist
,
79 uint64_t base
, uint64_t len
);
82 * These are all utilities internal for DR. There are
83 * similar functions in kernel/os which have similar names.
84 * We rename them to make sure there is no name space
87 #define memlist_delete dr_memlist_delete
88 #define memlist_intersect dr_memlist_intersect
89 #define memlist_coalesce dr_memlist_coalesce
90 #define memlist_dup dr_memlist_dup
91 #define memlist_add_span dr_memlist_add_span
92 #define memlist_del_span dr_memlist_del_span
93 #define memlist_cat_span dr_memlist_cat_span
99 #endif /* _SYS_DR_UTIL_H_ */