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 2005 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 #define LOG_NUMCONS 1024 /* up to 1024 /dev/conslog clones */ 51 52 #define LOG_MID 44 /* module ID */ 53 #define LOG_MINPS 0 /* min packet size */ 54 #define LOG_MAXPS 1024 /* max packet size */ 55 #define LOG_LOWAT 2048 /* threshold for backenable */ 56 #define LOG_HIWAT 1048576 /* threshold for tossing messages */ 57 58 #define LOG_MAGIC 0xf00d4109U /* "food for log" - unsent msg magic */ 59 #define LOG_RECENTSIZE 8192 /* queue of most recent messages */ 60 #define LOG_MINFREE 4096 /* message cache low water mark */ 61 #define LOG_MAXFREE 8192 /* message cache high water mark */ 62 63 typedef struct log log_t; 64 typedef int (log_filter_t)(log_t *, log_ctl_t *); 65 66 struct log { 67 queue_t *log_q; /* message queue */ 68 log_filter_t *log_wanted; /* message filter */ 69 mblk_t *log_data; /* parameters for filter */ 70 uint16_t log_flags; /* message type (e.g. SL_CONSOLE) */ 71 short log_inuse; /* is this log device open? */ 72 int log_overflow; /* messages lost due to QFULL */ 73 zoneid_t log_zoneid; /* zone id of log */ 74 major_t log_major; /* major number of associated device */ 75 minor_t log_minor; /* minor number of associated device */ 76 }; 77 78 /* Array of /dev/log minor devices */ 79 typedef struct log_zone { 80 log_t lz_clones[LOG_NUMCLONES]; 81 uint16_t lz_active; /* active types (OR of all log_flags fields) */ 82 } log_zone_t; 83 84 #define LOG_MSGSIZE 200 85 86 typedef struct log_dump { 87 uint32_t ld_magic; /* LOG_MAGIC */ 88 uint32_t ld_msgsize; /* MBLKL(mp->b_cont) */ 89 uint32_t ld_csum; /* checksum32(log_ctl) */ 90 uint32_t ld_msum; /* checksum32(message text) */ 91 /* 92 * log_ctl and message text follow here -- see dump_messages() 93 */ 94 } log_dump_t; 95 96 #ifdef _KERNEL 97 98 /* global zone variables */ 99 extern log_zone_t log_global; 100 extern queue_t *log_consq; /* primary console reader queue */ 101 extern queue_t *log_backlogq; /* console backlog queue */ 102 extern queue_t *log_intrq; /* pending high-level interrupt message queue */ 103 104 extern log_filter_t log_error; 105 extern log_filter_t log_trace; 106 extern log_filter_t log_console; 107 108 extern void log_init(void); 109 extern void log_enter(void); 110 extern void log_exit(void); 111 extern void log_update(log_t *, queue_t *, short, log_filter_t); 112 extern mblk_t *log_makemsg(int, int, int, int, int, void *, size_t, int); 113 extern void log_freemsg(mblk_t *); 114 extern void log_sendmsg(mblk_t *, zoneid_t); 115 extern void log_flushq(queue_t *); 116 extern void log_printq(queue_t *); 117 extern log_t *log_alloc(minor_t); 118 extern void log_free(log_t *); 119 120 #endif /* _KERNEL */ 121 122 #ifdef __cplusplus 123 } 124 #endif 125 126 #endif /* _SYS_LOG_H */ 127