coreboot-v2/src/console/printk.c
<<
>>
Prefs
   1/*
   2 *  blantantly copied from linux/kernel/printk.c
   3 *
   4 *  Copyright (C) 1991, 1992  Linus Torvalds
   5 *
   6 */
   7
   8#include <stdarg.h>
   9#include <smp/spinlock.h>
  10#include <console/vtxprintf.h>
  11#include <console/console.h>
  12
  13/* printk's without a loglevel use this.. */
  14#define DEFAULT_MESSAGE_LOGLEVEL 4 /* BIOS_WARNING */
  15
  16/* We show everything that is MORE important than this.. */
  17#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
  18
  19/* Keep together for sysctl support */
  20
  21int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
  22int default_message_loglevel = DEFAULT_MESSAGE_LOGLEVEL;
  23int minimum_console_loglevel = MINIMUM_CONSOLE_LOGLEVEL;
  24int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
  25
  26static spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
  27
  28int do_printk(int msg_level, const char *fmt, ...)
  29{
  30        va_list args;
  31        int i;
  32
  33        if (msg_level > console_loglevel) {
  34                return 0;
  35        }
  36
  37        spin_lock(&console_lock);
  38
  39        va_start(args, fmt);
  40        i = vtxprintf(console_tx_byte, fmt, args);
  41        va_end(args);
  42
  43        console_tx_flush();
  44
  45        spin_unlock(&console_lock);
  46
  47        return i;
  48}
  49
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.