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