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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/param.h>
33 #include <sys/systm.h>
40 #include <sys/varargs.h>
42 #include <sys/rsm/rsm.h>
46 extern char *vsprintf_len(size_t, char *, const char *, va_list);
47 extern char *sprintf(char *buf
, const char *fmt
, ...);
50 * From kmdb, read printfs using : *rsmka_dbg/s
52 #define RSMKA_BUFSIZE 0x10000
54 char rsmka_buf
[RSMKA_BUFSIZE
];
55 char *rsmka_dbg
= rsmka_buf
;
56 char *rsmka_buf_end
= rsmka_buf
;
57 char *rsmka_buf_top
= rsmka_buf
+ RSMKA_BUFSIZE
- 256;
58 kmutex_t rsmka_buf_lock
;
60 int rsmdbg_category
= RSM_KERNEL_ALL
;
62 int rsmdbg_level
= RSM_DEBUG_VERBOSE
;
64 int rsmdbg_level
= RSM_NOTICE
;
67 void dbprintf(char *fmt
, ...) {
72 mutex_enter(&rsmka_buf_lock
);
73 (void) vsprintf_len(255, rsmka_buf_end
, fmt
, ap
);
74 rsmka_buf_end
+= strlen(rsmka_buf_end
);
75 if (rsmka_buf_end
> rsmka_buf_top
) {
76 rsmka_buf_end
= rsmka_buf
;
79 mutex_exit(&rsmka_buf_lock
);
83 dbg_printf(int msg_category
, int msg_level
, char *fmt
, ...)
85 if ((msg_category
& rsmdbg_category
) &&
86 (msg_level
<= rsmdbg_level
)) {
89 mutex_enter(&rsmka_buf_lock
);
90 (void) sprintf(rsmka_buf_end
, "%16" PRIx64
":",
93 (void) vsprintf_len(255, rsmka_buf_end
, fmt
, ap
);
94 rsmka_buf_end
+= strlen(rsmka_buf_end
);
95 if (rsmka_buf_end
> rsmka_buf_top
) {
96 rsmka_buf_end
= rsmka_buf
;
98 mutex_exit(&rsmka_buf_lock
);