forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel+LibC: Add a DebugLogDevice that forwards everything to I/O por…
…t 0xe9. This is then used to implement the userspace dbgprintf() in a far more efficient way than what we had before. :^)
- Loading branch information
1 parent
3b986da
commit 3817f5f
Showing
7 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters