mirror of
https://github.com/tailix/drivers.git
synced 2024-11-20 11:06:32 -05:00
Implement console printf
This commit is contained in:
parent
64e324efb3
commit
3bf16b63e0
2 changed files with 26 additions and 0 deletions
|
@ -13,6 +13,9 @@ void drivers_console_print(const char *s);
|
||||||
void drivers_console_puts(const char *s);
|
void drivers_console_puts(const char *s);
|
||||||
void drivers_console_write(const char *data, size_t size);
|
void drivers_console_write(const char *data, size_t size);
|
||||||
|
|
||||||
|
__attribute__((format(printf, 1, 2)))
|
||||||
|
void drivers_console_printf(const char *format, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,8 +4,18 @@
|
||||||
|
|
||||||
#include <drivers/console.h>
|
#include <drivers/console.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int kernaux_vfprintf(
|
||||||
|
void (*out)(char, void*),
|
||||||
|
void *data,
|
||||||
|
const char* format,
|
||||||
|
va_list va
|
||||||
|
);
|
||||||
|
|
||||||
|
static void file_putc(char c, void *arg);
|
||||||
|
|
||||||
void drivers_console_putc(const char c)
|
void drivers_console_putc(const char c)
|
||||||
{
|
{
|
||||||
#if defined(ASM_X86)
|
#if defined(ASM_X86)
|
||||||
|
@ -22,6 +32,14 @@ void drivers_console_print(const char *const s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drivers_console_printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
kernaux_vfprintf(file_putc, NULL, format, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
void drivers_console_puts(const char *const s)
|
void drivers_console_puts(const char *const s)
|
||||||
{
|
{
|
||||||
drivers_console_print(s);
|
drivers_console_print(s);
|
||||||
|
@ -34,3 +52,8 @@ void drivers_console_write(const char *const data, const size_t size)
|
||||||
drivers_console_putc(data[i]);
|
drivers_console_putc(data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void file_putc(char c, void *arg __attribute__((unused)))
|
||||||
|
{
|
||||||
|
drivers_console_putc(c);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue