Console.cpp 671 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "Console.h"
  2. #include "VGA.h"
  3. static Console* s_the;
  4. Console& Console::the()
  5. {
  6. return *s_the;
  7. }
  8. Console::Console()
  9. {
  10. s_the = this;
  11. }
  12. Console::~Console()
  13. {
  14. }
  15. ssize_t Console::read(byte* buffer, size_t bufferSize)
  16. {
  17. // FIXME: Implement reading from the console.
  18. // Maybe we could use a ring buffer for this device?
  19. // A generalized ring buffer would probably be useful.
  20. return 0;
  21. }
  22. void Console::putChar(char ch)
  23. {
  24. vga_putch(nullptr, ch);
  25. }
  26. ssize_t Console::write(const byte* data, size_t size)
  27. {
  28. if (!size)
  29. return 0;
  30. for (size_t i = 0; i < size; ++i)
  31. putChar(data[i]);
  32. return 0;
  33. }