The Pedigree Project 0.1
VirtualTerminal.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef POSIX_VIRTUALTERMINAL_H
21#define POSIX_VIRTUALTERMINAL_H
22#include <config.h>
23
24#include "modules/subsys/posix/console-syscalls.h"
25#include "modules/system/console/TextIO.h"
26#include "modules/system/vfs/File.h"
27
28#define MAX_VT 64
29
30class DevFsDirectory;
31class Process;
32
34 public:
37
38 enum SwitchPermission { Allowed, Disallowed };
39
40 enum SystemMode { Text, Graphics };
41
42 bool initialise();
43
53 bool activate(size_t n);
54
56 bool reportPermission(size_t n, SwitchPermission perm);
57 bool acknowledgeAcquire(size_t n);
58
60 size_t openInactive();
61
63 void lockSwitching(bool locked);
64
65 size_t getCurrentTerminalNumber() const;
66 TextIO* getCurrentTerminal() const;
67 File* getCurrentTerminalFile() const;
68
69 struct vt_mode getTerminalMode(size_t n) const;
70 bool setTerminalMode(size_t n, struct vt_mode mode);
71 bool isTerminal(size_t n) const;
72
73 struct vt_stat getState() const;
74
75 void setSystemMode(size_t n, SystemMode mode);
76 SystemMode getSystemMode(size_t n) const;
77
78 void setInputMode(size_t n, TextIO::InputMode newMode);
79 TextIO::InputMode getInputMode(size_t n) const;
80
81 private:
82 bool sendSignal(size_t n, bool acq);
83 void switchTerminal(size_t n);
84
86 TextIO* textio;
87 File* file;
88 struct vt_mode mode;
89 SystemMode systemMode;
90
91#if THREADS
92 size_t owner;
93 size_t ownerThread;
94#endif
95 };
96
97 VirtualTerminal m_Terminals[MAX_VT];
98
99 TextIO* m_pTty;
100
101 TextIO* m_pTtys[MAX_VT];
102 File* m_pTtyFiles[MAX_VT];
103 struct vt_mode m_Modes[MAX_VT];
104
105 size_t m_CurrentTty;
106 size_t m_WantedTty;
107 size_t m_NumTtys;
108
109 DevFsDirectory* m_ParentDir;
110
111 bool m_bSwitchingLocked;
112
113 mutable Mutex m_Lock;
114};
115
116#endif
Definition File.h:75
Definition Mutex.h:56
void lockSwitching(bool locked)
bool reportPermission(size_t n, SwitchPermission perm)
bool activate(size_t n)
Starts the process of activating the given tty.