xref: /titanic_41/usr/src/uts/common/sys/strlog.h (revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f)
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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef _SYS_STRLOG_H
32 #define	_SYS_STRLOG_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/types.h>
37 #include <sys/types32.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Streams Log Driver Interface Definitions
45  */
46 
47 /*
48  * structure of control portion of log message
49  */
50 typedef struct log_ctl {
51 	short	mid;
52 	short	sid;
53 	char 	level;		/* level of message for tracing */
54 	short	flags;		/* message disposition */
55 #if defined(_LP64) || defined(_I32LPx)
56 	clock32_t ltime;	/* time in machine ticks since boot */
57 	time32_t ttime;		/* time in seconds since 1970 */
58 #else
59 	clock_t	ltime;
60 	time_t	ttime;
61 #endif
62 	int	seq_no;		/* sequence number */
63 	int	pri;		/* priority = (facility|level) */
64 } log_ctl_t;
65 
66 /*
67  * Public flags for log messages
68  */
69 #define	SL_FATAL	0x01	/* indicates fatal error */
70 #define	SL_NOTIFY	0x02	/* logger must notify administrator */
71 #define	SL_ERROR	0x04	/* include on the error log */
72 #define	SL_TRACE	0x08	/* include on the trace log */
73 #define	SL_CONSOLE	0x10	/* include on the console log */
74 #define	SL_WARN		0x20	/* warning message */
75 #define	SL_NOTE		0x40	/* notice message */
76 
77 /*
78  * Private flags for log messages -- used by internal implementation only
79  */
80 #define	SL_CONSONLY	0x1000	/* send message only to /dev/console */
81 #define	SL_LOGONLY	0x2000	/* send message only to /var/adm/messages */
82 #define	SL_USER		0x4000	/* send message to user's terminal */
83 #define	SL_PANICMSG	0x8000	/* message was created while panicking */
84 
85 /*
86  * Structure defining ids and levels desired by the tracer (I_TRCLOG).
87  */
88 typedef struct trace_ids {
89 	short	ti_mid;
90 	short	ti_sid;
91 	int8_t	ti_level;
92 } trace_ids_t;
93 
94 /*
95  * Log Driver I_STR ioctl commands
96  */
97 
98 #define	LOGCTL		(('L')<<8)
99 #define	I_TRCLOG	(LOGCTL|1)	/* process is tracer */
100 #define	I_ERRLOG	(LOGCTL|2)	/* process is error logger */
101 #define	I_CONSLOG	(LOGCTL|3)	/* process is console logger */
102 
103 #define	STRLOG_MAKE_MSGID(fmt, msgid)					\
104 {									\
105 	uchar_t *__cp = (uchar_t *)fmt;					\
106 	uchar_t __c;							\
107 	uint32_t __id = 0;						\
108 	while ((__c = *__cp++) != '\0')					\
109 		if (__c >= ' ')						\
110 			__id = (__id >> 5) + (__id << 27) + __c;	\
111 	msgid = (__id % 899981) + 100000;				\
112 }
113 
114 #ifdef _KERNEL
115 
116 #ifndef _ASM
117 #include <sys/va_list.h>
118 #endif
119 
120 /*PRINTFLIKE5*/
121 extern int strlog(short, short, char, unsigned short, char *, ...)
122 	__KPRINTFLIKE(5);
123 extern int vstrlog(short, short, char, unsigned short, char *, __va_list)
124 	__KVPRINTFLIKE(5);
125 
126 /*
127  * STRLOG(mid,sid,level,flags,fmt,args) should be used for those trace
128  * calls that are only to be made during debugging.
129  */
130 #if defined(DEBUG) || defined(__lint)
131 #define	STRLOG	strlog
132 #else
133 #define	STRLOG	0 && strlog
134 #endif	/* DEBUG || __lint */
135 
136 #endif	/* _KERNEL */
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif	/* _SYS_STRLOG_H */
143