17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23b4203d7Marcel Telka/*	  All Rights Reserved	*/
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate/*
277c478bdstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
287c478bdstevel@tonic-gate * Use is subject to license terms.
297c478bdstevel@tonic-gate */
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#ifndef _SYS_STRLOG_H
327c478bdstevel@tonic-gate#define	_SYS_STRLOG_H
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gate#include <sys/types.h>
357c478bdstevel@tonic-gate#include <sys/types32.h>
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gate#ifdef	__cplusplus
387c478bdstevel@tonic-gateextern "C" {
397c478bdstevel@tonic-gate#endif
407c478bdstevel@tonic-gate
417c478bdstevel@tonic-gate/*
427c478bdstevel@tonic-gate * Streams Log Driver Interface Definitions
437c478bdstevel@tonic-gate */
447c478bdstevel@tonic-gate
457c478bdstevel@tonic-gate/*
467c478bdstevel@tonic-gate * structure of control portion of log message
477c478bdstevel@tonic-gate */
487c478bdstevel@tonic-gatetypedef struct log_ctl {
497c478bdstevel@tonic-gate	short	mid;
507c478bdstevel@tonic-gate	short	sid;
517c478bdstevel@tonic-gate	char 	level;		/* level of message for tracing */
527c478bdstevel@tonic-gate	short	flags;		/* message disposition */
537c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
547c478bdstevel@tonic-gate	clock32_t ltime;	/* time in machine ticks since boot */
557c478bdstevel@tonic-gate	time32_t ttime;		/* time in seconds since 1970 */
567c478bdstevel@tonic-gate#else
577c478bdstevel@tonic-gate	clock_t	ltime;
587c478bdstevel@tonic-gate	time_t	ttime;
597c478bdstevel@tonic-gate#endif
607c478bdstevel@tonic-gate	int	seq_no;		/* sequence number */
617c478bdstevel@tonic-gate	int	pri;		/* priority = (facility|level) */
627c478bdstevel@tonic-gate} log_ctl_t;
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gate/*
657c478bdstevel@tonic-gate * Public flags for log messages
667c478bdstevel@tonic-gate */
677c478bdstevel@tonic-gate#define	SL_FATAL	0x01	/* indicates fatal error */
687c478bdstevel@tonic-gate#define	SL_NOTIFY	0x02	/* logger must notify administrator */
697c478bdstevel@tonic-gate#define	SL_ERROR	0x04	/* include on the error log */
707c478bdstevel@tonic-gate#define	SL_TRACE	0x08	/* include on the trace log */
717c478bdstevel@tonic-gate#define	SL_CONSOLE	0x10	/* include on the console log */
727c478bdstevel@tonic-gate#define	SL_WARN		0x20	/* warning message */
737c478bdstevel@tonic-gate#define	SL_NOTE		0x40	/* notice message */
747c478bdstevel@tonic-gate
757c478bdstevel@tonic-gate/*
767c478bdstevel@tonic-gate * Private flags for log messages -- used by internal implementation only
777c478bdstevel@tonic-gate */
787c478bdstevel@tonic-gate#define	SL_CONSONLY	0x1000	/* send message only to /dev/console */
797c478bdstevel@tonic-gate#define	SL_LOGONLY	0x2000	/* send message only to /var/adm/messages */
807c478bdstevel@tonic-gate#define	SL_USER		0x4000	/* send message to user's terminal */
817c478bdstevel@tonic-gate#define	SL_PANICMSG	0x8000	/* message was created while panicking */
827c478bdstevel@tonic-gate
837c478bdstevel@tonic-gate/*
847c478bdstevel@tonic-gate * Structure defining ids and levels desired by the tracer (I_TRCLOG).
857c478bdstevel@tonic-gate */
867c478bdstevel@tonic-gatetypedef struct trace_ids {
877c478bdstevel@tonic-gate	short	ti_mid;
887c478bdstevel@tonic-gate	short	ti_sid;
897c478bdstevel@tonic-gate	int8_t	ti_level;
907c478bdstevel@tonic-gate} trace_ids_t;
917c478bdstevel@tonic-gate
927c478bdstevel@tonic-gate/*
937c478bdstevel@tonic-gate * Log Driver I_STR ioctl commands
947c478bdstevel@tonic-gate */
957c478bdstevel@tonic-gate
967c478bdstevel@tonic-gate#define	LOGCTL		(('L')<<8)
977c478bdstevel@tonic-gate#define	I_TRCLOG	(LOGCTL|1)	/* process is tracer */
987c478bdstevel@tonic-gate#define	I_ERRLOG	(LOGCTL|2)	/* process is error logger */
997c478bdstevel@tonic-gate#define	I_CONSLOG	(LOGCTL|3)	/* process is console logger */
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gate#define	STRLOG_MAKE_MSGID(fmt, msgid)					\
1027c478bdstevel@tonic-gate{									\
1037c478bdstevel@tonic-gate	uchar_t *__cp = (uchar_t *)fmt;					\
1047c478bdstevel@tonic-gate	uchar_t __c;							\
1057c478bdstevel@tonic-gate	uint32_t __id = 0;						\
1067c478bdstevel@tonic-gate	while ((__c = *__cp++) != '\0')					\
1077c478bdstevel@tonic-gate		if (__c >= ' ')						\
1087c478bdstevel@tonic-gate			__id = (__id >> 5) + (__id << 27) + __c;	\
1097c478bdstevel@tonic-gate	msgid = (__id % 899981) + 100000;				\
1107c478bdstevel@tonic-gate}
1117c478bdstevel@tonic-gate
1127c478bdstevel@tonic-gate#ifdef _KERNEL
1137c478bdstevel@tonic-gate
1147c478bdstevel@tonic-gate#ifndef _ASM
1157c478bdstevel@tonic-gate#include <sys/va_list.h>
1167c478bdstevel@tonic-gate#endif
1177c478bdstevel@tonic-gate
1187c478bdstevel@tonic-gate/*PRINTFLIKE5*/
1197c478bdstevel@tonic-gateextern int strlog(short, short, char, unsigned short, char *, ...)
1207c478bdstevel@tonic-gate	__KPRINTFLIKE(5);
1217c478bdstevel@tonic-gateextern int vstrlog(short, short, char, unsigned short, char *, __va_list)
1227c478bdstevel@tonic-gate	__KVPRINTFLIKE(5);
1237c478bdstevel@tonic-gate
1247c478bdstevel@tonic-gate/*
1257c478bdstevel@tonic-gate * STRLOG(mid,sid,level,flags,fmt,args) should be used for those trace
1267c478bdstevel@tonic-gate * calls that are only to be made during debugging.
1277c478bdstevel@tonic-gate */
1287c478bdstevel@tonic-gate#if defined(DEBUG) || defined(__lint)
1297c478bdstevel@tonic-gate#define	STRLOG	strlog
1307c478bdstevel@tonic-gate#else
1317c478bdstevel@tonic-gate#define	STRLOG	0 && strlog
1327c478bdstevel@tonic-gate#endif	/* DEBUG || __lint */
1337c478bdstevel@tonic-gate
1347c478bdstevel@tonic-gate#endif	/* _KERNEL */
1357c478bdstevel@tonic-gate
1367c478bdstevel@tonic-gate#ifdef	__cplusplus
1377c478bdstevel@tonic-gate}
1387c478bdstevel@tonic-gate#endif
1397c478bdstevel@tonic-gate
1407c478bdstevel@tonic-gate#endif	/* _SYS_STRLOG_H */
141