|
|
1.1 ! root 1: /* ! 2: * Linux kernel print routine. ! 3: * Copyright (C) 1995 Shantanu Goel. ! 4: * ! 5: * This program is free software; you can redistribute it and/or modify ! 6: * it under the terms of the GNU General Public License as published by ! 7: * the Free Software Foundation; either version 2, or (at your option) ! 8: * any later version. ! 9: * ! 10: * This program is distributed in the hope that it will be useful, ! 11: * but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 13: * GNU General Public License for more details. ! 14: * ! 15: * You should have received a copy of the GNU General Public License ! 16: * along with this program; if not, write to the Free Software ! 17: * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ! 18: */ ! 19: ! 20: /* ! 21: * linux/kernel/printk.c ! 22: * ! 23: * Copyright (C) 1991, 1992 Linus Torvalds ! 24: */ ! 25: ! 26: #define MACH_INCLUDE ! 27: #include <stdarg.h> ! 28: #include <asm/system.h> ! 29: ! 30: static char buf[2048]; ! 31: ! 32: #define DEFAULT_MESSAGE_LOGLEVEL 4 ! 33: #define DEFAULT_CONSOLE_LOGLEVEL 7 ! 34: ! 35: int console_loglevel = DEFAULT_CONSOLE_LOGLEVEL; ! 36: ! 37: int ! 38: printk (char *fmt, ...) ! 39: { ! 40: va_list args; ! 41: int n, flags; ! 42: extern void cnputc (); ! 43: extern int linux_vsprintf (char *buf, char *fmt,...); ! 44: char *p, *msg, *buf_end; ! 45: static int msg_level = -1; ! 46: ! 47: save_flags (flags); ! 48: cli (); ! 49: va_start (args, fmt); ! 50: n = linux_vsprintf (buf + 3, fmt, args); ! 51: buf_end = buf + 3 + n; ! 52: va_end (args); ! 53: for (p = buf + 3; p < buf_end; p++) ! 54: { ! 55: msg = p; ! 56: if (msg_level < 0) ! 57: { ! 58: if (p[0] != '<' || p[1] < '0' || p[1] > '7' || p[2] != '>') ! 59: { ! 60: p -= 3; ! 61: p[0] = '<'; ! 62: p[1] = DEFAULT_MESSAGE_LOGLEVEL + '0'; ! 63: p[2] = '>'; ! 64: } ! 65: else ! 66: msg += 3; ! 67: msg_level = p[1] - '0'; ! 68: } ! 69: for (; p < buf_end; p++) ! 70: if (*p == '\n') ! 71: break; ! 72: if (msg_level < console_loglevel) ! 73: while (msg <= p) ! 74: cnputc (*msg++); ! 75: if (*p == '\n') ! 76: msg_level = -1; ! 77: } ! 78: restore_flags (flags); ! 79: return n; ! 80: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.