Switch to nanoprintf + good spinlock (rflags) = no more FLANTERM ISSUES???
This commit is contained in:
@@ -19,10 +19,20 @@ because this shitty implementation will be replaced one day by Flanterm
|
||||
#include "flanterm_backends/fb.h"
|
||||
#include "mem/heap/kheap.h"
|
||||
#include "limine.h"
|
||||
#include <stdarg.h>
|
||||
#include "sched/spinlock.h"
|
||||
#include "io/serial/serial.h"
|
||||
|
||||
#define NANOPRINTF_IMPLEMENTATION
|
||||
#include "nanoprintf.h"
|
||||
|
||||
extern struct flanterm_context* ft_ctx;
|
||||
extern struct init_status init;
|
||||
|
||||
struct spinlock_t term_lock = {0};
|
||||
|
||||
extern int panic_count;
|
||||
|
||||
/*
|
||||
* _putchar - Writes a character to terminal
|
||||
* @character: character to write
|
||||
@@ -33,6 +43,39 @@ void _putchar(char character)
|
||||
flanterm_write(ft_ctx, &character, 1);
|
||||
}
|
||||
|
||||
void internal_putc(int c, void *_)
|
||||
{
|
||||
(void)_;
|
||||
char ch = (char)c;
|
||||
|
||||
if (init.terminal) {
|
||||
if (panic_count == 0) {
|
||||
spinlock_acquire(&term_lock);
|
||||
flanterm_write(ft_ctx, &ch, 1);
|
||||
spinlock_release(&term_lock);
|
||||
} else {
|
||||
flanterm_write(ft_ctx, &ch, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (init.serial) {
|
||||
if (ch == '\n') {
|
||||
skputc('\r');
|
||||
}
|
||||
skputc(ch);
|
||||
}
|
||||
}
|
||||
|
||||
int printf(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int ret = npf_vpprintf(internal_putc, NULL, fmt, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* kputs - Kernel puts
|
||||
* @str: String to write
|
||||
|
||||
Reference in New Issue
Block a user