summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-18 16:08:52 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-18 16:08:52 +0200
commit3817f5f6191902d2592dab810d074a266d27596e (patch)
tree2280fd86901020de0cd884d10b29bca2d33f78a8 /Kernel
parent3b986da6431bf566fbf75c37e9a040ab3f9d024d (diff)
downloadserenity-3817f5f6191902d2592dab810d074a266d27596e.zip
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. :^)
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Devices/DebugLogDevice.cpp28
-rw-r--r--Kernel/Devices/DebugLogDevice.h17
-rw-r--r--Kernel/Makefile1
-rw-r--r--Kernel/init.cpp3
-rwxr-xr-xKernel/sync.sh1
5 files changed, 50 insertions, 0 deletions
diff --git a/Kernel/Devices/DebugLogDevice.cpp b/Kernel/Devices/DebugLogDevice.cpp
new file mode 100644
index 0000000000..321cd97d35
--- /dev/null
+++ b/Kernel/Devices/DebugLogDevice.cpp
@@ -0,0 +1,28 @@
+#include <Kernel/Devices/DebugLogDevice.h>
+#include <Kernel/IO.h>
+
+static DebugLogDevice* s_the;
+
+DebugLogDevice& DebugLogDevice::the()
+{
+ ASSERT(s_the);
+ return *s_the;
+}
+
+DebugLogDevice::DebugLogDevice()
+ : CharacterDevice(1, 18)
+{
+ s_the = this;
+}
+
+DebugLogDevice::~DebugLogDevice()
+{
+}
+
+ssize_t DebugLogDevice::write(Process&, const byte* data, ssize_t data_size)
+{
+ for (int i = 0; i < data_size; ++i)
+ IO::out8(0xe9, data[i]);
+ return data_size;
+}
+
diff --git a/Kernel/Devices/DebugLogDevice.h b/Kernel/Devices/DebugLogDevice.h
new file mode 100644
index 0000000000..dd6db9f4d2
--- /dev/null
+++ b/Kernel/Devices/DebugLogDevice.h
@@ -0,0 +1,17 @@
+#include <Kernel/Devices/CharacterDevice.h>
+
+class DebugLogDevice final : public CharacterDevice {
+public:
+ DebugLogDevice();
+ virtual ~DebugLogDevice() override;
+
+ static DebugLogDevice& the();
+
+private:
+ // ^CharacterDevice
+ virtual ssize_t read(Process&, byte*, ssize_t) override { return 0; }
+ virtual ssize_t write(Process&, const byte*, ssize_t) override;
+ virtual bool can_write(Process&) const override { return true; }
+ virtual bool can_read(Process&) const override { return true; }
+ virtual const char* class_name() const override { return "DebugLogDevice"; }
+};
diff --git a/Kernel/Makefile b/Kernel/Makefile
index a771e4f068..ebd182da68 100644
--- a/Kernel/Makefile
+++ b/Kernel/Makefile
@@ -57,6 +57,7 @@ VFS_OBJS = \
Devices/FullDevice.o \
Devices/ZeroDevice.o \
Devices/RandomDevice.o \
+ Devices/DebugLogDevice.o \
FileSystem/FileSystem.o \
FileSystem/DiskBackedFileSystem.o \
FileSystem/Ext2FileSystem.o \
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 440aac263a..0081b88ece 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -24,6 +24,7 @@
#include <Kernel/Devices/BXVGADevice.h>
#include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Net/NetworkTask.h>
+#include <Kernel/Devices/DebugLogDevice.h>
#define SPAWN_TERMINAL
//#define SPAWN_LAUNCHER
@@ -42,6 +43,7 @@ VirtualConsole* tty2;
VirtualConsole* tty3;
KeyboardDevice* keyboard;
PS2MouseDevice* ps2mouse;
+DebugLogDevice* dev_debuglog;
NullDevice* dev_null;
VFS* vfs;
@@ -151,6 +153,7 @@ extern "C" [[noreturn]] void init()
init_ksyms();
vfs = new VFS;
+ dev_debuglog = new DebugLogDevice;
auto console = make<Console>();
diff --git a/Kernel/sync.sh b/Kernel/sync.sh
index 3c7dced878..d9c57a0bf7 100755
--- a/Kernel/sync.sh
+++ b/Kernel/sync.sh
@@ -25,6 +25,7 @@ mknod mnt/dev/random c 1 8
mknod mnt/dev/null c 1 3
mknod mnt/dev/zero c 1 5
mknod mnt/dev/full c 1 7
+mknod -m 666 mnt/dev/debuglog c 1 18
mknod mnt/dev/keyboard c 85 1
mknod mnt/dev/psaux c 10 1
mknod -m 666 mnt/dev/ptmx c 5 2