21 #include "ConsoleDefines.h" 22 #include "modules/system/vfs/File.h" 23 #include "pedigree/kernel/processor/types.h" 24 #include "pedigree/kernel/utilities/Buffer.h" 25 #include "pedigree/kernel/utilities/String.h" 26 #include "pedigree/kernel/utilities/utility.h" 30 ConsolePhysicalFile::ConsolePhysicalFile(
32 :
ConsoleFile(~0U, consoleName, pFs), m_pTerminal(pTerminal),
33 m_ProcessedInput(PTY_BUFFER_SIZE), m_TerminalNumber(nth)
38 uint64_t location, uint64_t size, uintptr_t buffer,
bool bCanBlock)
47 if (!m_ProcessedInput.canRead(
false))
49 char *temp =
new char[size];
50 size_t nRead = m_pTerminal->read(
51 location, size, reinterpret_cast<uintptr_t>(temp), bCanBlock);
63 char *buff =
new char[512];
64 size_t nTransfer = m_Buffer.
read(buff, 512);
65 write(0, nTransfer, reinterpret_cast<uintptr_t>(buff),
true);
70 if (m_ProcessedInput.canRead(
false))
72 return m_ProcessedInput.read(
73 reinterpret_cast<char *>(buffer), size, bCanBlock);
83 uint64_t location, uint64_t size, uintptr_t buffer,
bool bCanBlock)
87 char *outputBuffer =
new char[size * 2];
88 ByteSet(outputBuffer, 0, size * 2);
89 StringCopyN(outputBuffer, reinterpret_cast<char *>(buffer), size);
90 size_t disciplineSize =
96 location, disciplineSize, reinterpret_cast<uintptr_t>(outputBuffer),
98 delete[] outputBuffer;
104 m_ProcessedInput.write(buf, len, canBlock);
113 return m_pTerminal->select(
true, timeout);
117 if (m_ProcessedInput.canRead(
false))
123 return m_pTerminal->select(
false, timeout);
virtual uint64_t writeBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
static size_t outputLineDiscipline(char *buf, size_t len, size_t maxSz, size_t flags=0)
Output line discipline.
size_t read(T *buffer, size_t count, bool block=true)
virtual int select(bool bWriting, int timeout)
select - check and optionally for a particular state.
void inputLineDiscipline(char *buf, size_t len, size_t flags=~0U, const char *controlChars=0)
Input line discipline.
virtual uint64_t readBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
virtual void performInject(char *buf, size_t len, bool canBlock)
virtual uint64_t write(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final