10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5630Sjbeck * Common Development and Distribution License, Version 1.0 only 6*5630Sjbeck * (the "License"). You may not use this file except in compliance 7*5630Sjbeck * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*5630Sjbeck * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _SYS_LOG_H 310Sstevel@tonic-gate #define _SYS_LOG_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/types.h> 360Sstevel@tonic-gate #include <sys/strlog.h> 370Sstevel@tonic-gate #include <sys/stream.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define LOG_CONSMIN 0 /* /dev/conslog minor */ 441259Sns92644 #define LOG_LOGMIN 5 /* /dev/log minor */ 450Sstevel@tonic-gate #define LOG_BACKLOG LOG_LOGMIN /* console backlog queue */ 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define LOG_LOGMINIDX 0 /* index of smallest /dev/log clone */ 480Sstevel@tonic-gate #define LOG_LOGMAXIDX 15 /* up to 16 /dev/log clones */ 490Sstevel@tonic-gate #define LOG_NUMCLONES (LOG_LOGMAXIDX - LOG_LOGMINIDX + 1) 500Sstevel@tonic-gate 510Sstevel@tonic-gate #define LOG_MID 44 /* module ID */ 520Sstevel@tonic-gate #define LOG_MINPS 0 /* min packet size */ 530Sstevel@tonic-gate #define LOG_MAXPS 1024 /* max packet size */ 540Sstevel@tonic-gate #define LOG_LOWAT 2048 /* threshold for backenable */ 550Sstevel@tonic-gate #define LOG_HIWAT 1048576 /* threshold for tossing messages */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate #define LOG_MAGIC 0xf00d4109U /* "food for log" - unsent msg magic */ 580Sstevel@tonic-gate #define LOG_RECENTSIZE 8192 /* queue of most recent messages */ 590Sstevel@tonic-gate #define LOG_MINFREE 4096 /* message cache low water mark */ 600Sstevel@tonic-gate #define LOG_MAXFREE 8192 /* message cache high water mark */ 610Sstevel@tonic-gate 620Sstevel@tonic-gate typedef struct log log_t; 630Sstevel@tonic-gate typedef int (log_filter_t)(log_t *, log_ctl_t *); 640Sstevel@tonic-gate 650Sstevel@tonic-gate struct log { 660Sstevel@tonic-gate queue_t *log_q; /* message queue */ 670Sstevel@tonic-gate log_filter_t *log_wanted; /* message filter */ 680Sstevel@tonic-gate mblk_t *log_data; /* parameters for filter */ 690Sstevel@tonic-gate uint16_t log_flags; /* message type (e.g. SL_CONSOLE) */ 700Sstevel@tonic-gate short log_inuse; /* is this log device open? */ 710Sstevel@tonic-gate int log_overflow; /* messages lost due to QFULL */ 720Sstevel@tonic-gate zoneid_t log_zoneid; /* zone id of log */ 731259Sns92644 major_t log_major; /* device type */ 740Sstevel@tonic-gate minor_t log_minor; /* minor number of associated device */ 750Sstevel@tonic-gate }; 760Sstevel@tonic-gate 771259Sns92644 /* Array of /dev/log minor devices */ 780Sstevel@tonic-gate typedef struct log_zone { 790Sstevel@tonic-gate log_t lz_clones[LOG_NUMCLONES]; 800Sstevel@tonic-gate uint16_t lz_active; /* active types (OR of all log_flags fields) */ 810Sstevel@tonic-gate } log_zone_t; 820Sstevel@tonic-gate 830Sstevel@tonic-gate #define LOG_MSGSIZE 200 840Sstevel@tonic-gate 850Sstevel@tonic-gate typedef struct log_dump { 860Sstevel@tonic-gate uint32_t ld_magic; /* LOG_MAGIC */ 870Sstevel@tonic-gate uint32_t ld_msgsize; /* MBLKL(mp->b_cont) */ 880Sstevel@tonic-gate uint32_t ld_csum; /* checksum32(log_ctl) */ 890Sstevel@tonic-gate uint32_t ld_msum; /* checksum32(message text) */ 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * log_ctl and message text follow here -- see dump_messages() 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate } log_dump_t; 940Sstevel@tonic-gate 950Sstevel@tonic-gate #ifdef _KERNEL 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* global zone variables */ 980Sstevel@tonic-gate extern log_zone_t log_global; 990Sstevel@tonic-gate extern queue_t *log_consq; /* primary console reader queue */ 1000Sstevel@tonic-gate extern queue_t *log_backlogq; /* console backlog queue */ 1010Sstevel@tonic-gate extern queue_t *log_intrq; /* pending high-level interrupt message queue */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate extern log_filter_t log_error; 1040Sstevel@tonic-gate extern log_filter_t log_trace; 1050Sstevel@tonic-gate extern log_filter_t log_console; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate extern void log_init(void); 1080Sstevel@tonic-gate extern void log_enter(void); 1090Sstevel@tonic-gate extern void log_exit(void); 1100Sstevel@tonic-gate extern void log_update(log_t *, queue_t *, short, log_filter_t); 1110Sstevel@tonic-gate extern mblk_t *log_makemsg(int, int, int, int, int, void *, size_t, int); 1120Sstevel@tonic-gate extern void log_freemsg(mblk_t *); 1130Sstevel@tonic-gate extern void log_sendmsg(mblk_t *, zoneid_t); 1140Sstevel@tonic-gate extern void log_flushq(queue_t *); 1150Sstevel@tonic-gate extern void log_printq(queue_t *); 1160Sstevel@tonic-gate extern log_t *log_alloc(minor_t); 1171259Sns92644 extern void log_free(log_t *); 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate #endif /* _KERNEL */ 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate #ifdef __cplusplus 1220Sstevel@tonic-gate } 1230Sstevel@tonic-gate #endif 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate #endif /* _SYS_LOG_H */ 126