提交 e0824a1c 创建 作者: Austin Clements's avatar Austin Clements 提交者: Silas Boyd-Wickizer

Add a console output stream and a separate stream for user errors

The user errors stream is disabled by default.
上级 8c2334c1
#pragma once
#include "pstream.hh"
class console_stream : public print_stream
{
public:
constexpr console_stream(bool enabled = true)
: print_stream(enabled) { }
protected:
void write(char c);
void write(sbuf buf);
};
extern console_stream console;
// Errors caused by user processes (page faults, failed system calls,
// etc.)
extern console_stream uerr;
......@@ -57,6 +57,7 @@ OBJS = \
zalloc.o \
incbin.o \
sysvectors.o \
pstream.o
ifeq ($(EXCEPTIONS),y)
OBJS += \
......
......@@ -19,6 +19,7 @@
#include "sperf.hh"
#include "wq.hh"
#include "major.h"
#include "kstream.hh"
#define BACKSPACE 0x100
......@@ -336,6 +337,24 @@ consoleread(struct inode *ip, char *dst, u32 off, u32 n)
return target - n;
}
// Console stream support
void
console_stream::write(char c)
{
consputc(c);
}
void
console_stream::write(sbuf buf)
{
for (size_t i = 0; i < buf.len; i++)
consputc(buf.base[i]);
}
console_stream console;
console_stream uerr(false);
void
initconsole(void)
{
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论