2018-10-22 11:20:35 +00:00
|
|
|
#include "kprintf.h"
|
|
|
|
#include "Console.h"
|
2018-10-29 20:54:11 +00:00
|
|
|
#include "IO.h"
|
2019-01-23 05:53:01 +00:00
|
|
|
#include <LibC/stdarg.h>
|
2019-01-15 23:20:38 +00:00
|
|
|
#include "Process.h"
|
2018-10-22 11:20:35 +00:00
|
|
|
#include <AK/Types.h>
|
2018-10-27 14:43:03 +00:00
|
|
|
#include <AK/printf.cpp>
|
2018-10-22 11:20:35 +00:00
|
|
|
|
2018-10-29 20:54:11 +00:00
|
|
|
static void console_putch(char*&, char ch)
|
2018-10-22 11:20:35 +00:00
|
|
|
{
|
2019-01-15 23:20:38 +00:00
|
|
|
Console::the().write(*current, (byte*)&ch, 1);
|
2018-10-22 11:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int kprintf(const char* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2019-01-31 16:31:23 +00:00
|
|
|
int ret = printf_internal(console_putch, nullptr, fmt, ap);
|
2018-10-22 11:20:35 +00:00
|
|
|
va_end(ap);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void buffer_putch(char*& bufptr, char ch)
|
|
|
|
{
|
|
|
|
*bufptr++ = ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ksprintf(char* buffer, const char* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2019-01-31 16:31:23 +00:00
|
|
|
int ret = printf_internal(buffer_putch, buffer, fmt, ap);
|
2018-10-22 11:20:35 +00:00
|
|
|
buffer[ret] = '\0';
|
|
|
|
va_end(ap);
|
|
|
|
return ret;
|
|
|
|
}
|
2018-10-29 20:54:11 +00:00
|
|
|
|
|
|
|
static void debugger_putch(char*&, char ch)
|
|
|
|
{
|
|
|
|
IO::out8(0xe9, ch);
|
|
|
|
}
|
|
|
|
|
2019-01-14 19:00:42 +00:00
|
|
|
extern "C" int dbgprintf(const char* fmt, ...)
|
2018-10-29 20:54:11 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2019-01-31 16:31:23 +00:00
|
|
|
int ret = printf_internal(debugger_putch, nullptr, fmt, ap);
|
2018-10-29 20:54:11 +00:00
|
|
|
va_end(ap);
|
|
|
|
return ret;
|
|
|
|
}
|