mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2025-02-16 14:40:10 +00:00
Implement 8 loglevels to use with printk: While at it, separate the font in a new "video" directory, which also makes space for a proper video probing implementation. Fill in the font from 32 to 256. Scale the font to render twice as big. Implement dynamic line length detection. Change a few things here and there to follow the linux kernel code style. Add a nice logo. Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <lib/debug.h>
|
|
#include <lib/simplefb.h>
|
|
#include <lib/video/font.h>
|
|
|
|
long int debug_linecount = 0;
|
|
|
|
// Global log level that controls the verbosity
|
|
static int global_loglevel = CONFIG_LOGLEVEL;
|
|
|
|
void printk(int log_level, char *text)
|
|
{
|
|
if (log_level > global_loglevel)
|
|
return;
|
|
|
|
char *prefix;
|
|
switch (log_level) {
|
|
case KERN_EMERG:
|
|
prefix = "[EMERG] ";
|
|
break;
|
|
case KERN_ALERT:
|
|
prefix = "[ALERT] ";
|
|
break;
|
|
case KERN_CRIT:
|
|
prefix = "[CRIT] ";
|
|
break;
|
|
case KERN_ERR:
|
|
prefix = "[ERROR] ";
|
|
break;
|
|
case KERN_WARNING:
|
|
prefix = "[WARN] ";
|
|
break;
|
|
case KERN_NOTICE:
|
|
prefix = "[NOTICE] ";
|
|
break;
|
|
case KERN_INFO:
|
|
prefix = "[INFO] ";
|
|
break;
|
|
case KERN_DEBUG:
|
|
prefix = "[DEBUG] ";
|
|
break;
|
|
default:
|
|
prefix = "[LOG] ";
|
|
break;
|
|
}
|
|
|
|
#ifdef CONFIG_SIMPLE_FB
|
|
// Actually the first line's Y pos. Scales in __simplefb_raw_print
|
|
int y_pos = 5;
|
|
int prefix_width = strlen(prefix) * SCALED_FONTW;
|
|
|
|
__simplefb_raw_print((char*)CONFIG_FRAMEBUFFER_BASE, prefix, 0, y_pos,
|
|
CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
|
__simplefb_raw_print((char*)CONFIG_FRAMEBUFFER_BASE, text, prefix_width, y_pos,
|
|
CONFIG_FRAMEBUFFER_WIDTH, CONFIG_FRAMEBUFFER_STRIDE);
|
|
#endif
|
|
}
|