mirror of
https://github.com/tailix/kernel.git
synced 2025-02-17 15:45:37 -05:00
Use <kernaux/console.h>
This commit is contained in:
parent
16b595b68e
commit
d262c6b137
4 changed files with 19 additions and 55 deletions
|
@ -20,7 +20,6 @@ OBJS += info.c.o
|
|||
OBJS += process.c.o
|
||||
|
||||
# Built-in drivers
|
||||
OBJS += console.c.o
|
||||
OBJS += pic.c.o
|
||||
OBJS += timer.c.o
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include "console.h"
|
||||
|
||||
#include <kernaux/arch/x86.h>
|
||||
#include <kernaux/stdlib.h>
|
||||
|
||||
void console_print(const char *const s)
|
||||
{
|
||||
console_write(s, kernaux_strlen(s));
|
||||
}
|
||||
|
||||
void console_putc(const char c) {
|
||||
kernaux_arch_x86_outportb(0x3F8, c);
|
||||
}
|
||||
|
||||
void console_puts(const char *const s)
|
||||
{
|
||||
console_print(s);
|
||||
console_putc('\n');
|
||||
}
|
||||
|
||||
void console_write(const char *const data, const unsigned int size) {
|
||||
for (unsigned int i = 0; i < size; i++) {
|
||||
console_putc(data[i]);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef KERNELMQ_INCLUDED_CONSOLE
|
||||
#define KERNELMQ_INCLUDED_CONSOLE 1
|
||||
|
||||
void console_print(const char *s);
|
||||
void console_putc(char c);
|
||||
void console_puts(const char *s);
|
||||
void console_write(const char *data, unsigned int size);
|
||||
|
||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||
#include "logger.h"
|
||||
|
||||
#include "console.h"
|
||||
|
||||
#include <kernaux/console.h>
|
||||
#include <kernaux/stdlib.h>
|
||||
|
||||
#define LEVELS_COUNT 4
|
||||
|
@ -31,11 +30,11 @@ void logger_log(unsigned char level, const char *const source, const char *forma
|
|||
while ((c = *format++) != 0)
|
||||
{
|
||||
if (c == '\n') {
|
||||
console_putc('\n');
|
||||
kernaux_console_putc('\n');
|
||||
print_prefix(level, source);
|
||||
}
|
||||
else if (c != '%') {
|
||||
console_putc(c);
|
||||
kernaux_console_putc(c);
|
||||
}
|
||||
else {
|
||||
char *p, *p2;
|
||||
|
@ -67,30 +66,30 @@ void logger_log(unsigned char level, const char *const source, const char *forma
|
|||
string:
|
||||
for (p2 = p; *p2; p2++);
|
||||
for (; p2 < p + pad; p2++)
|
||||
console_putc(pad0 ? '0' : ' ');
|
||||
kernaux_console_putc(pad0 ? '0' : ' ');
|
||||
while (*p)
|
||||
console_putc(*p++);
|
||||
kernaux_console_putc(*p++);
|
||||
break;
|
||||
default:
|
||||
console_putc(*((int *) arg++));
|
||||
kernaux_console_putc(*((int *) arg++));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console_putc('\n');
|
||||
kernaux_console_putc('\n');
|
||||
}
|
||||
|
||||
void print_prefix(const unsigned char level, const char *const source)
|
||||
{
|
||||
console_putc('[');
|
||||
console_print(level_text[level]);
|
||||
console_putc(']');
|
||||
console_putc(' ');
|
||||
kernaux_console_putc('[');
|
||||
kernaux_console_print(level_text[level]);
|
||||
kernaux_console_putc(']');
|
||||
kernaux_console_putc(' ');
|
||||
|
||||
if (source) {
|
||||
console_print(source);
|
||||
console_print(": ");
|
||||
kernaux_console_print(source);
|
||||
kernaux_console_print(": ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,11 +104,11 @@ void print(const char *format, ...)
|
|||
{
|
||||
if (c == '\n') {
|
||||
if (*format != 0) {
|
||||
console_putc('\n');
|
||||
kernaux_console_putc('\n');
|
||||
}
|
||||
}
|
||||
else if (c != '%') {
|
||||
console_putc(c);
|
||||
kernaux_console_putc(c);
|
||||
}
|
||||
else {
|
||||
char *p, *p2;
|
||||
|
@ -141,16 +140,16 @@ void print(const char *format, ...)
|
|||
string:
|
||||
for (p2 = p; *p2; p2++);
|
||||
for (; p2 < p + pad; p2++)
|
||||
console_putc(pad0 ? '0' : ' ');
|
||||
kernaux_console_putc(pad0 ? '0' : ' ');
|
||||
while (*p)
|
||||
console_putc(*p++);
|
||||
kernaux_console_putc(*p++);
|
||||
break;
|
||||
default:
|
||||
console_putc(*((int *) arg++));
|
||||
kernaux_console_putc(*((int *) arg++));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console_putc('\n');
|
||||
kernaux_console_putc('\n');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue