mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
Add basic PTY support.
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123] Use this in the Terminal to open a pty pair and spawn a shell.
This commit is contained in:
parent
ecb4ab0943
commit
2f74c2f430
21 changed files with 287 additions and 10 deletions
|
@ -22,6 +22,8 @@
|
|||
#include "VirtualConsole.h"
|
||||
#include "Scheduler.h"
|
||||
#include "PS2MouseDevice.h"
|
||||
#include "MasterPTY.h"
|
||||
#include "SlavePTY.h"
|
||||
|
||||
#define SPAWN_GUI_TEST_APP
|
||||
//#define SPAWN_MULTIPLE_SHELLS
|
||||
|
@ -36,6 +38,14 @@ VirtualConsole* tty3;
|
|||
Keyboard* keyboard;
|
||||
PS2MouseDevice* ps2mouse;
|
||||
GUIEventDevice* gui_event_device;
|
||||
MasterPTY* ptm0;
|
||||
MasterPTY* ptm1;
|
||||
MasterPTY* ptm2;
|
||||
MasterPTY* ptm3;
|
||||
SlavePTY* pts0;
|
||||
SlavePTY* pts1;
|
||||
SlavePTY* pts2;
|
||||
SlavePTY* pts3;
|
||||
|
||||
#ifdef STRESS_TEST_SPAWNING
|
||||
static void spawn_stress() NORETURN;
|
||||
|
@ -56,6 +66,16 @@ static void spawn_stress()
|
|||
}
|
||||
#endif
|
||||
|
||||
static void make_pty_pair(unsigned index)
|
||||
{
|
||||
auto* master = new MasterPTY(index);
|
||||
auto* slave = new SlavePTY(index);
|
||||
master->set_slave(*slave);
|
||||
slave->set_master(*master);
|
||||
VFS::the().register_character_device(*master);
|
||||
VFS::the().register_character_device(*slave);
|
||||
}
|
||||
|
||||
static void init_stage2() NORETURN;
|
||||
static void init_stage2()
|
||||
{
|
||||
|
@ -75,6 +95,11 @@ static void init_stage2()
|
|||
auto dev_random = make<RandomDevice>();
|
||||
vfs->register_character_device(*dev_random);
|
||||
|
||||
make_pty_pair(0);
|
||||
make_pty_pair(1);
|
||||
make_pty_pair(2);
|
||||
make_pty_pair(3);
|
||||
|
||||
vfs->register_character_device(*keyboard);
|
||||
vfs->register_character_device(*ps2mouse);
|
||||
vfs->register_character_device(*gui_event_device);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue