Kernel: Add load_keymap syscall and load Finnish keymap in init

This commit is contained in:
Bananymous 2024-01-10 14:46:29 +02:00
parent 8f89519bcf
commit 51214ea1bf
8 changed files with 29 additions and 0 deletions

Binary file not shown.

View File

@ -146,6 +146,8 @@ namespace Kernel
BAN::ErrorOr<long> sys_clock_gettime(clockid_t, timespec*);
BAN::ErrorOr<long> sys_load_keymap(const char* path);
TTY& tty() { ASSERT(m_controlling_terminal); return *m_controlling_terminal; }
static Process& current() { return Thread::current().process(); }

View File

@ -5,6 +5,7 @@
#include <kernel/FS/ProcFS/FileSystem.h>
#include <kernel/FS/VirtualFileSystem.h>
#include <kernel/IDT.h>
#include <kernel/Input/KeyboardLayout.h>
#include <kernel/InterruptController.h>
#include <kernel/LockGuard.h>
#include <kernel/Memory/FileBackedRegion.h>
@ -1253,6 +1254,17 @@ namespace Kernel
return 0;
}
BAN::ErrorOr<long> Process::sys_load_keymap(const char* path)
{
LockGuard _(m_lock);
TRY(validate_string_access(path));
auto absolute_path = TRY(absolute_path_of(path));
TRY(Input::KeyboardLayout::get().load_from_file(absolute_path));
return 0;
}
BAN::ErrorOr<long> Process::sys_signal(int signal, void (*handler)(int))
{
if (signal < _SIGMIN || signal > _SIGMAX)

View File

@ -210,6 +210,9 @@ namespace Kernel
case SYS_CHOWN:
ret = Process::current().sys_chown((const char*)arg1, (uid_t)arg2, (gid_t)arg3);
break;
case SYS_LOAD_KEYMAP:
ret = Process::current().sys_load_keymap((const char*)arg1);
break;
default:
dwarnln("Unknown syscall {}", syscall);
break;

View File

@ -34,6 +34,8 @@ return value: 0 on success, -1 on failure and errno set to the error
int tty_ctrl(int fildes, int command, int flags);
int poweroff(int command);
int load_keymap(const char* path);
__END_DECLS
#endif

View File

@ -62,6 +62,7 @@ __BEGIN_DECLS
#define SYS_MSYNC 61
#define SYS_PREAD 62
#define SYS_CHOWN 63
#define SYS_LOAD_KEYMAP 64
__END_DECLS

View File

@ -11,3 +11,8 @@ int poweroff(int command)
{
return syscall(SYS_POWEROFF, command);
}
int load_keymap(const char* path)
{
return syscall(SYS_LOAD_KEYMAP, path);
}

View File

@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/banan-os.h>
#include <termios.h>
void initialize_stdio()
@ -25,6 +26,9 @@ int main()
if (signal(SIGINT, [](int) {}) == SIG_ERR)
perror("signal");
if (load_keymap("/usr/share/keymaps/fi.keymap") == -1)
perror("load_keymap");
bool first = true;
termios termios;