mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +00:00
Kernel+LibC: Add a DebugLogDevice that forwards everything to I/O port 0xe9.
This is then used to implement the userspace dbgprintf() in a far more efficient way than what we had before. :^)
This commit is contained in:
parent
3b986da643
commit
3817f5f619
7 changed files with 61 additions and 7 deletions
|
@ -13,10 +13,11 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
static FILE __default_streams[3];
|
||||
static FILE __default_streams[4];
|
||||
FILE* stdin;
|
||||
FILE* stdout;
|
||||
FILE* stderr;
|
||||
FILE* stddbg;
|
||||
|
||||
void init_FILE(FILE& fp, int fd, int mode)
|
||||
{
|
||||
|
@ -39,9 +40,16 @@ void __stdio_init()
|
|||
stdin = &__default_streams[0];
|
||||
stdout = &__default_streams[1];
|
||||
stderr = &__default_streams[2];
|
||||
stddbg = &__default_streams[3];
|
||||
init_FILE(*stdin, 0, isatty(0) ? _IOLBF : _IOFBF);
|
||||
init_FILE(*stdout, 1, isatty(1) ? _IOLBF : _IOFBF);
|
||||
init_FILE(*stderr, 2, _IONBF);
|
||||
int fd = open("/dev/debuglog", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("open /dev/debuglog");
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
init_FILE(*stddbg, fd, _IOLBF);
|
||||
}
|
||||
|
||||
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
|
||||
|
@ -263,16 +271,11 @@ void rewind(FILE* stream)
|
|||
fseek(stream, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
static void sys_putch(char*&, char ch)
|
||||
{
|
||||
syscall(SC_putch, ch);
|
||||
}
|
||||
|
||||
int dbgprintf(const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = printf_internal(sys_putch, nullptr, fmt, ap);
|
||||
int ret = vfprintf(stddbg, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue