Kernel: Add bareboness possibility to set termios
This commit is contained in:
@@ -59,6 +59,8 @@ namespace Kernel
|
||||
BAN::ErrorOr<BAN::String> working_directory() const;
|
||||
BAN::ErrorOr<void> set_working_directory(BAN::StringView);
|
||||
|
||||
TTY& tty() { ASSERT(m_tty); return *m_tty; }
|
||||
|
||||
BAN::ErrorOr<void*> allocate(size_t);
|
||||
void free(void*);
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#define SYS_FREE 8
|
||||
#define SYS_SEEK 9
|
||||
#define SYS_TELL 10
|
||||
#define SYS_GET_TERMIOS 11
|
||||
#define SYS_SET_TERMIOS 12
|
||||
|
||||
#include <kernel/Attributes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <kernel/Terminal/termios.h>
|
||||
#include <kernel/Semaphore.h>
|
||||
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
@@ -17,7 +16,8 @@ namespace Kernel
|
||||
public:
|
||||
TTY(TerminalDriver*);
|
||||
|
||||
void set_termios(const termios& termios) { m_termios = termios; }
|
||||
void set_termios(const termios& termios) { m_termios = termios; }
|
||||
termios get_termios() const { return m_termios; }
|
||||
void set_font(const Kernel::Font&);
|
||||
|
||||
uint32_t height() const { return m_height; }
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <kernel/Process.h>
|
||||
#include <kernel/Syscall.h>
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
@@ -76,6 +78,26 @@ namespace Kernel
|
||||
return res.value();
|
||||
}
|
||||
|
||||
long sys_get_termios(::termios* termios)
|
||||
{
|
||||
auto current = Process::current().tty().get_termios();
|
||||
memset(termios, 0, sizeof(::termios));
|
||||
if (current.canonical)
|
||||
termios->c_lflag |= ICANON;
|
||||
if (current.echo)
|
||||
termios->c_lflag |= ECHO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long sys_set_termios(const ::termios* termios)
|
||||
{
|
||||
Kernel::termios new_termios;
|
||||
new_termios.canonical = termios->c_lflag & ICANON;
|
||||
new_termios.echo = termios->c_lflag & ECHO;
|
||||
Process::current().tty().set_termios(new_termios);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
|
||||
{
|
||||
Thread::current().set_in_syscall(true);
|
||||
@@ -121,6 +143,12 @@ namespace Kernel
|
||||
case SYS_TELL:
|
||||
ret = sys_tell((int)arg1);
|
||||
break;
|
||||
case SYS_GET_TERMIOS:
|
||||
ret = sys_get_termios((::termios*)arg1);
|
||||
break;
|
||||
case SYS_SET_TERMIOS:
|
||||
ret = sys_set_termios((const ::termios*)arg1);
|
||||
break;
|
||||
default:
|
||||
Kernel::panic("Unknown syscall {}", syscall);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user