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