Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | 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
/*
39
 * CVS :        $Id: printk.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $
40
 *
41
 * File:        $File$
42
 * Revision:    $Revision: 1.1.1.1 $
43
 * Last update: $Date: 2002-03-29 14:12:52 $
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
 
55
static char *levelname[]={
56
  "emerg ",
57
  "alert ",
58
  "crit  ",
59
  "err   ",
60
  "warn  ",
61
  "notice",
62
  "info  ",
63
  "debug "
64
};
65
 
66
static int vprintk(int flag, char *fmt, va_list ap)
67
{
68
  static char buf[1024]; /* DANGER !!!!! */
69
  SYS_FLAGS f;
70
  int level;
71
  int result;
72
 
73
  result=sscanf(fmt,"<%i>",&level);
74
  if (result==1) {
75
    if (level<LOG_EMERG||level>LOG_DEBUG) level=LOG_INFO;
76
    fmt+=3;
77
  } else {
78
    level=LOG_INFO;
79
  }
80
  if (level<=printklevel) return 0;
81
 
82
  vsprintf(buf,(char*)fmt,ap);
83
  result=(strchr(fmt,'\n')!=NULL);
84
 
85
  f=kern_fsave();
86
  cprintf("[%s] %s",levelname[level],buf);
87
  if ((!flag)&&(!result)) cprintf("\n");
88
  kern_frestore(f);
89
 
90
  return 0;
91
}
92
 
93
int printk(const char *fmt, ...)
94
{
95
  va_list ap;
96
  int res;
97
 
98
  va_start(ap, fmt);
99
  res=vprintk(0,(char *)fmt, ap);
100
  va_end(ap);
101
  return res;
102
}
103
 
104
int printkboot(const char *fmt, ...)
105
{
106
  va_list ap;
107
  int res;
108
 
109
  va_start(ap, fmt);
110
  res=vprintk(1,(char *)fmt, ap);
111
  va_end(ap);
112
  return res;
113
}