Subversion Repositories shark

Rev

Rev 11 | Rev 390 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 1999 Massimiliano Giorgi
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 */
37
 
38
/*
385 giacomo 39
 * CVS :        $Id: printk.c,v 1.3 2004-01-08 20:14:08 giacomo Exp $
2 pj 40
 *
41
 * File:        $File$
385 giacomo 42
 * Revision:    $Revision: 1.3 $
43
 * Last update: $Date: 2004-01-08 20:14:08 $
2 pj 44
 */
45
 
46
#include <ll/i386/cons.h>
47
#include <ll/stdarg.h>
48
#include <ll/string.h>
49
#include <ll/stdio.h>
50
#include <kernel/log.h>
51
#include <kernel/func.h>
52
 
53
static int printklevel=0;
54
 
385 giacomo 55
#define NO_LEVEL 100
56
 
2 pj 57
static char *levelname[]={
58
  "emerg ",
59
  "alert ",
60
  "crit  ",
61
  "err   ",
62
  "warn  ",
63
  "notice",
64
  "info  ",
65
  "debug "
66
};
67
 
68
static int vprintk(int flag, char *fmt, va_list ap)
69
{
385 giacomo 70
  static char buf[2048]; /* DANGER !!!!! */
2 pj 71
  SYS_FLAGS f;
72
  int level;
73
 
385 giacomo 74
  level = NO_LEVEL;
75
  if (*fmt == '<' && *(fmt+2) == '>')
76
    level = *(fmt+1) - '0';
77
  if (level != NO_LEVEL) {
2 pj 78
    if (level<LOG_EMERG||level>LOG_DEBUG) level=LOG_INFO;
79
    fmt+=3;
80
  }
385 giacomo 81
 
2 pj 82
  if (level<=printklevel) return 0;
83
 
84
  vsprintf(buf,(char*)fmt,ap);
85
 
86
  f=kern_fsave();
385 giacomo 87
  if (level != NO_LEVEL)
88
    cprintf("[%s] %s",levelname[level],buf);
89
  else
90
    cprintf("%s",buf);
2 pj 91
  kern_frestore(f);
92
 
93
  return 0;
94
}
95
 
96
int printk(const char *fmt, ...)
97
{
98
  va_list ap;
99
  int res;
100
 
101
  va_start(ap, fmt);
102
  res=vprintk(0,(char *)fmt, ap);
103
  va_end(ap);
104
  return res;
105
}
106
 
107
int printkboot(const char *fmt, ...)
108
{
109
  va_list ap;
110
  int res;
111
 
112
  va_start(ap, fmt);
113
  res=vprintk(1,(char *)fmt, ap);
114
  va_end(ap);
115
  return res;
116
}