xref: /titanic_41/usr/src/uts/common/sys/log.h (revision ba2e4443695ee6a6f420a35cd4fc3d3346d22932)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /*	  All Rights Reserved	*/
29 
30 #ifndef _SYS_LOG_H
31 #define	_SYS_LOG_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <sys/types.h>
36 #include <sys/strlog.h>
37 #include <sys/stream.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #define	LOG_CONSMIN	0		/* /dev/conslog minor */
44 #define	LOG_LOGMIN	5		/* /dev/log minor */
45 #define	LOG_BACKLOG	LOG_LOGMIN	/* console backlog queue */
46 
47 #define	LOG_LOGMINIDX	0		/* index of smallest /dev/log clone */
48 #define	LOG_LOGMAXIDX	15		/* up to 16 /dev/log clones */
49 #define	LOG_NUMCLONES	(LOG_LOGMAXIDX - LOG_LOGMINIDX + 1)
50 
51 #define	LOG_MID		44		/* module ID */
52 #define	LOG_MINPS	0		/* min packet size */
53 #define	LOG_MAXPS	1024		/* max packet size */
54 #define	LOG_LOWAT	2048		/* threshold for backenable */
55 #define	LOG_HIWAT	1048576		/* threshold for tossing messages */
56 
57 #define	LOG_MAGIC	0xf00d4109U	/* "food for log" - unsent msg magic */
58 #define	LOG_RECENTSIZE	8192		/* queue of most recent messages */
59 #define	LOG_MINFREE	4096		/* message cache low water mark */
60 #define	LOG_MAXFREE	8192		/* message cache high water mark */
61 
62 typedef struct log log_t;
63 typedef int (log_filter_t)(log_t *, log_ctl_t *);
64 
65 struct log {
66 	queue_t		*log_q;		/* message queue */
67 	log_filter_t	*log_wanted;	/* message filter */
68 	mblk_t		*log_data;	/* parameters for filter */
69 	uint16_t	log_flags;	/* message type (e.g. SL_CONSOLE) */
70 	short		log_inuse;	/* is this log device open? */
71 	int		log_overflow;	/* messages lost due to QFULL */
72 	zoneid_t	log_zoneid;	/* zone id of log */
73 	major_t		log_major;	/* device type */
74 	minor_t		log_minor;	/* minor number of associated device */
75 };
76 
77 /* Array of /dev/log minor devices */
78 typedef struct log_zone {
79 	log_t lz_clones[LOG_NUMCLONES];
80 	uint16_t lz_active;	/* active types (OR of all log_flags fields) */
81 } log_zone_t;
82 
83 #define	LOG_MSGSIZE	200
84 
85 typedef struct log_dump {
86 	uint32_t	ld_magic;	/* LOG_MAGIC */
87 	uint32_t	ld_msgsize;	/* MBLKL(mp->b_cont) */
88 	uint32_t	ld_csum;	/* checksum32(log_ctl) */
89 	uint32_t	ld_msum;	/* checksum32(message text) */
90 	/*
91 	 * log_ctl and message text follow here -- see dump_messages()
92 	 */
93 } log_dump_t;
94 
95 #ifdef _KERNEL
96 
97 /* global zone variables */
98 extern log_zone_t log_global;
99 extern queue_t *log_consq;	/* primary console reader queue */
100 extern queue_t *log_backlogq;	/* console backlog queue */
101 extern queue_t *log_intrq;	/* pending high-level interrupt message queue */
102 
103 extern log_filter_t log_error;
104 extern log_filter_t log_trace;
105 extern log_filter_t log_console;
106 
107 extern void log_init(void);
108 extern void log_enter(void);
109 extern void log_exit(void);
110 extern void log_update(log_t *, queue_t *, short, log_filter_t);
111 extern mblk_t *log_makemsg(int, int, int, int, int, void *, size_t, int);
112 extern void log_freemsg(mblk_t *);
113 extern void log_sendmsg(mblk_t *, zoneid_t);
114 extern void log_flushq(queue_t *);
115 extern void log_printq(queue_t *);
116 extern log_t *log_alloc(minor_t);
117 extern void log_free(log_t *);
118 
119 #endif	/* _KERNEL */
120 
121 #ifdef	__cplusplus
122 }
123 #endif
124 
125 #endif	/* _SYS_LOG_H */
126