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 void activate(size_t n);
54
56 void reportPermission(SwitchPermission perm);
57
59 size_t openInactive();
60
62 void lockSwitching(bool locked);
63
64 size_t getCurrentTerminalNumber() const;
65 TextIO* getCurrentTerminal() const;
66 File* getCurrentTerminalFile() const;
67
68 struct vt_mode getTerminalMode(size_t n) const;
69 void setTerminalMode(size_t n, struct vt_mode mode);
70
71 struct vt_stat getState() const;
72
73 void setSystemMode(SystemMode mode);
74 SystemMode getSystemMode() const;
75
76 void setInputMode(size_t n, TextIO::InputMode newMode);
77 TextIO::InputMode getInputMode(size_t n) const;
78
79 private:
80 void sendSignal(size_t n, bool acq);
81
83 TextIO* textio;
84 File* file;
85 struct vt_mode mode;
86
87#if THREADS
88 Process* owner;
89#endif
90 };
91
92 VirtualTerminal m_Terminals[MAX_VT];
93
94 TextIO* m_pTty;
95
96 TextIO* m_pTtys[MAX_VT];
97 File* m_pTtyFiles[MAX_VT];
98 struct vt_mode m_Modes[MAX_VT];
99
100 size_t m_CurrentTty;
101 size_t m_WantedTty;
102 size_t m_NumTtys;
103
104 DevFsDirectory* m_ParentDir;
105
106 bool m_bSwitchingLocked;
107
108 SystemMode m_SystemMode;
109};
110
111#endif
Definition File.h:74
void reportPermission(SwitchPermission perm)
void lockSwitching(bool locked)
void setTerminalMode(size_t n, struct vt_mode mode)
struct vt_mode getTerminalMode(size_t n) const
void activate(size_t n)
Starts the process of activating the given tty.