1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:27:35 +00:00

Kernel+LibC: Add a dbgputstr() syscall for sending strings to debug output.

This is very handy for the DebugLogStream implementation, among others. :^)
This commit is contained in:
Andreas Kling 2019-07-21 21:43:37 +02:00
parent 0ef13e60b0
commit af81645a2a
10 changed files with 33 additions and 4 deletions

View file

@ -2722,3 +2722,12 @@ int Process::sys$dbgputch(u8 ch)
IO::out8(0xe9, ch);
return 0;
}
int Process::sys$dbgputstr(const u8* characters, int length)
{
if (!validate_read(characters, length))
return -EFAULT;
for (int i = 0; i < length; ++i)
IO::out8(0xe9, characters[i]);
return 0;
}

View file

@ -105,6 +105,7 @@ public:
void finalize();
int sys$dbgputch(u8);
int sys$dbgputstr(const u8*, int length);
int sys$dump_backtrace();
int sys$gettid();
int sys$donate(int tid);

View file

@ -72,6 +72,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
break;
case Syscall::SC_dbgputch:
return current->process().sys$dbgputch((u8)arg1);
case Syscall::SC_dbgputstr:
return current->process().sys$dbgputstr((const u8*)arg1, (int)arg2);
case Syscall::SC_sleep:
return current->process().sys$sleep((unsigned)arg1);
case Syscall::SC_usleep:

View file

@ -117,7 +117,8 @@ struct timeval;
__ENUMERATE_SYSCALL(halt) \
__ENUMERATE_SYSCALL(reboot) \
__ENUMERATE_SYSCALL(dump_backtrace) \
__ENUMERATE_SYSCALL(dbgputch)
__ENUMERATE_SYSCALL(dbgputch) \
__ENUMERATE_SYSCALL(dbgputstr)
namespace Syscall {

View file

@ -57,12 +57,18 @@ int ksprintf(char* buffer, const char* fmt, ...)
return ret;
}
extern "C" int dbgputstr(const char* characters, int length)
{
for (int i = 0; i < length; ++i)
IO::out8(0xe9, characters[i]);
return 0;
}
static void debugger_putch(char*&, char ch)
{
IO::out8(0xe9, ch);
}
extern "C" int dbgprintf(const char* fmt, ...)
{
color_on();

View file

@ -1,7 +1,10 @@
#pragma once
#include <AK/Types.h>
extern "C" {
int dbgprintf(const char* fmt, ...);
int dbgputstr(const char*, int);
int kprintf(const char* fmt, ...);
int ksprintf(char* buf, const char* fmt, ...);
}