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 
23 #include "modules/subsys/posix/console-syscalls.h"
24 #include "modules/system/console/TextIO.h"
25 #include "modules/system/vfs/File.h"
26 
27 #define MAX_VT 64
28 
29 class DevFsDirectory;
30 class Process;
31 
33 {
34  public:
36  virtual ~VirtualTerminalManager();
37 
38  enum SwitchPermission
39  {
40  Allowed,
41  Disallowed
42  };
43 
44  enum SystemMode
45  {
46  Text,
47  Graphics
48  };
49 
50  bool initialise();
51 
61  void activate(size_t n);
62 
64  void reportPermission(SwitchPermission perm);
65 
67  size_t openInactive();
68 
70  void lockSwitching(bool locked);
71 
72  size_t getCurrentTerminalNumber() const;
73  TextIO *getCurrentTerminal() const;
74  File *getCurrentTerminalFile() const;
75 
76  struct vt_mode getTerminalMode(size_t n) const;
77  void setTerminalMode(size_t n, struct vt_mode mode);
78 
79  struct vt_stat getState() const;
80 
81  void setSystemMode(SystemMode mode);
82  SystemMode getSystemMode() const;
83 
84  void setInputMode(size_t n, TextIO::InputMode newMode);
85  TextIO::InputMode getInputMode(size_t n) const;
86 
87  private:
88  void sendSignal(size_t n, bool acq);
89 
91  {
92  TextIO *textio;
93  File *file;
94  struct vt_mode mode;
95 
96 #ifdef THREADS
97  Process *owner;
98 #endif
99  };
100 
101  VirtualTerminal m_Terminals[MAX_VT];
102 
103  TextIO *m_pTty;
104 
105  TextIO *m_pTtys[MAX_VT];
106  File *m_pTtyFiles[MAX_VT];
107  struct vt_mode m_Modes[MAX_VT];
108 
109  size_t m_CurrentTty;
110  size_t m_WantedTty;
111  size_t m_NumTtys;
112 
113  DevFsDirectory *m_ParentDir;
114 
115  bool m_bSwitchingLocked;
116 
117  SystemMode m_SystemMode;
118 };
119 
120 #endif
void activate(size_t n)
Starts the process of activating the given tty.
void reportPermission(SwitchPermission perm)
void lockSwitching(bool locked)
Definition: TextIO.h:48
void setTerminalMode(size_t n, struct vt_mode mode)
Definition: File.h:66