printf spinlock + remove DEPRECATED stuff + begin separating x86 stuff

This commit is contained in:
2026-03-20 09:01:57 +01:00
parent 424b4c4632
commit 3607a7179c
12 changed files with 77 additions and 138 deletions

View File

@@ -30,19 +30,10 @@ extern struct flanterm_context* ft_ctx;
extern struct init_status init;
struct spinlock_t term_lock = {0};
struct spinlock_t printf_lock = {0};
extern int panic_count;
/*
* _putchar - Writes a character to terminal (DEPRECATED)
* @character: character to write
*/
void _putchar(char character)
{
// TODO: Spinlock here (terminal access)
flanterm_write(ft_ctx, &character, 1);
}
/*
* internal_putc - Internal putchar function
* @c: char to print
@@ -83,14 +74,26 @@ void internal_putc(int c, void *_)
*
* Return:
* <ret> - number of characters sent to the callback
* %-1 - error
*/
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;
if (panic_count == 0) {
spinlock_acquire(&printf_lock);
va_list args;
va_start(args, fmt);
int ret = npf_vpprintf(internal_putc, NULL, fmt, args);
va_end(args);
spinlock_release(&printf_lock);
return ret;
} else {
va_list args;
va_start(args, fmt);
int ret = npf_vpprintf(internal_putc, NULL, fmt, args);
va_end(args);
return ret;
}
return -1;
}
/*
@@ -103,30 +106,14 @@ void kputs(const char* str)
{
size_t i=0;
while (str[i] != 0) {
_putchar(str[i]);
internal_putc(str[i], NULL);
i++;
}
_putchar('\r');
}
extern struct flanterm_context* ft_ctx;
extern struct boot_context boot_ctx;
/*
* flanterm_free_wrapper - free() wrapper for Flanterm (DEPRECATED)
* @ptr: pointer to free
* @size: amount of bytes to free
*
* This function exists solely because the Flanterm initialization
* function only accepts a free() function with a size parameter,
* and the default one doesn't have it.
*/
void flanterm_free_wrapper(void* ptr, size_t size)
{
(void)size;
kfree(ptr);
}
/*
* term_init - Video output/terminal initialization
*