21 #include "modules/Module.h" 22 #include "pedigree/kernel/LockGuard.h" 23 #include "pedigree/kernel/process/Thread.h" 24 #include "pedigree/kernel/processor/Processor.h" 25 #include "pedigree/kernel/processor/ProcessorInformation.h" 38 char a =
'a' + (i % 10);
42 char master[] = {
'p',
't',
'y', c, a, 0};
43 char slave[] = {
't',
't',
'y', c, a, 0};
45 String masterName(master), slaveName(slave);
50 pMaster->setOther(pSlave);
51 pSlave->setOther(pMaster);
60 ConsoleManager::ConsoleManager() : m_Consoles(), m_Lock()
65 for (
size_t i = 0; i < 16; ++i)
67 for (
char c =
'p'; c <=
'z'; ++c)
71 for (
char c =
'a'; c <=
'e'; ++c)
78 ConsoleManager::~ConsoleManager()
80 for (
auto it : m_Consoles)
91 File *ConsoleManager::getConsole(
String consoleName)
94 for (
size_t i = 0; i < m_Consoles.
count(); i++)
97 if (pC->m_Name == consoleName)
113 if (!isConsole(file))
117 if (!pConsole->isMaster())
133 if (!isConsole(file))
137 if (!pConsole->isMaster())
144 if (pConsole->
pLocker != pProcess)
149 bool ConsoleManager::isConsole(
File *file)
153 return (file->getInode() == 0xdeadbeef);
156 bool ConsoleManager::isMasterConsole(
File *file)
158 if (!isConsole(file))
162 return pFile->isMaster();
165 void ConsoleManager::setAttributes(
File *file,
size_t flags)
171 pFile->m_Flags = flags;
174 void ConsoleManager::getAttributes(
File *file,
size_t *flags)
179 *flags = pFile->m_Flags;
182 void ConsoleManager::setControlChars(
File *file,
void *p)
187 MemoryCopy(pFile->m_ControlChars, p, MAX_CONTROL_CHAR);
190 void ConsoleManager::getControlChars(
File *file,
void *p)
195 MemoryCopy(p, pFile->m_ControlChars, MAX_CONTROL_CHAR);
198 int ConsoleManager::getWindowSize(
199 File *file,
unsigned short *rows,
unsigned short *cols)
204 if (!pFile->isMaster())
212 *rows = pFile->m_Rows;
213 *cols = pFile->m_Cols;
217 int ConsoleManager::setWindowSize(
218 File *file,
unsigned short rows,
unsigned short cols)
223 if ((!pFile->isMaster()) && pFile->
m_pOther)
228 pFile->m_Rows = rows;
229 pFile->m_Cols = cols;
233 bool ConsoleManager::hasDataAvailable(
File *file)
238 return pFile->
select(
false, 0);
241 void ConsoleManager::flush(
File *file)
245 File *ConsoleManager::getOther(
File *file)
257 static bool initConsole()
262 static void destroyConsole()
266 MODULE_INFO(
"console", &initConsole, &destroyConsole,
"vfs");
void unlockConsole(File *file)
Release a console master locked as above.
void pushBack(const T &value)
bool lockConsole(File *file)
void newConsole(char c, size_t i)
static ProcessorInformation & information()
ConsoleFile * m_pOther
Other side of the console.
virtual int select(bool bWriting, int timeout)
select - check and optionally for a particular state.
bool bLocked
Is this master locked (ie, already opened)?