1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

Kernel+KeyboardSettings: Remove numlock syscall and implement ioctl

This commit is contained in:
Edwin Hoksberg 2021-07-05 21:51:54 +02:00 committed by Gunnar Beutner
parent 385e2ccb66
commit 99328e1038
10 changed files with 21 additions and 38 deletions

View file

@ -142,7 +142,6 @@ namespace Kernel {
S(getrandom) \
S(getkeymap) \
S(setkeymap) \
S(set_num_lock) \
S(clock_gettime) \
S(clock_settime) \
S(clock_nanosleep) \

View file

@ -191,7 +191,6 @@ set(KERNEL_SOURCES
Syscalls/mmap.cpp
Syscalls/module.cpp
Syscalls/mount.cpp
Syscalls/num_lock.cpp
Syscalls/open.cpp
Syscalls/perf_event.cpp
Syscalls/pipe.cpp

View file

@ -98,11 +98,6 @@ void HIDManagement::set_maps(const Keyboard::CharacterMapData& character_map_dat
dbgln("New Character map '{}' passed in by client.", character_map_name);
}
void HIDManagement::set_num_lock(bool on)
{
m_i8042_controller->keyboard()->set_num_lock(on);
}
UNMAP_AFTER_INIT void HIDManagement::enumerate()
{
// FIXME: When we have USB HID support, we should ensure that we disable

View file

@ -45,7 +45,6 @@ public:
const Keyboard::CharacterMap& character_map() const { return m_character_map; }
void set_client(KeyboardClient* client) { m_client = client; }
void set_maps(const Keyboard::CharacterMapData& character_map, const String& character_map_name);
void set_num_lock(bool on);
private:
size_t generate_minor_device_number_for_mouse();

View file

@ -49,8 +49,6 @@ public:
m_modifiers &= ~modifier;
}
void set_num_lock(bool on) { m_num_lock_on = on; }
protected:
KeyboardDevice();
mutable SpinLock<u8> m_queue_lock;

View file

@ -290,7 +290,6 @@ public:
KResultOr<FlatPtr> sys$getresuid(Userspace<uid_t*>, Userspace<uid_t*>, Userspace<uid_t*>);
KResultOr<FlatPtr> sys$getresgid(Userspace<gid_t*>, Userspace<gid_t*>, Userspace<gid_t*>);
KResultOr<FlatPtr> sys$umask(mode_t);
KResultOr<FlatPtr> sys$set_num_lock(bool);
KResultOr<FlatPtr> sys$open(Userspace<const Syscall::SC_open_params*>);
KResultOr<FlatPtr> sys$close(int fd);
KResultOr<FlatPtr> sys$read(int fd, Userspace<u8*>, size_t);

View file

@ -1,18 +0,0 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Devices/HID/HIDManagement.h>
#include <Kernel/Process.h>
namespace Kernel {
KResultOr<FlatPtr> Process::sys$set_num_lock(bool on)
{
HIDManagement::the().set_num_lock(on);
return 0;
}
}

View file

@ -137,11 +137,6 @@ int getkeymap(char* name_buffer, size_t name_buffer_size, u32* map, u32* shift_m
__RETURN_WITH_ERRNO(rc, rc, -1);
}
void set_num_lock(bool on)
{
syscall(SC_set_num_lock, on);
}
u16 internet_checksum(const void* ptr, size_t count)
{
u32 checksum = 0;

View file

@ -127,8 +127,6 @@ int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t
int getkeymap(char* name_buffer, size_t name_buffer_size, uint32_t* map, uint32_t* shift_map, uint32_t* alt_map, uint32_t* altgr_map, uint32_t* shift_altgr_map);
int setkeymap(const char* name, const uint32_t* map, uint32_t* const shift_map, const uint32_t* alt_map, const uint32_t* altgr_map, const uint32_t* shift_altgr_map);
void set_num_lock(bool on);
uint16_t internet_checksum(const void* ptr, size_t count);
__END_DECLS

View file

@ -5,10 +5,12 @@
*/
#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
#include <errno.h>
#include <serenity.h>
#include <spawn.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
int main()
@ -30,6 +32,11 @@ int main()
return 1;
}
if (unveil("/dev/keyboard0", "r") < 0) {
perror("unveil /dev/keyboard0");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
@ -45,6 +52,18 @@ int main()
exit(1);
}
bool enable_num_lock = keyboard_settings_config->read_bool_entry("StartupEnable", "NumLock", true);
set_num_lock(enable_num_lock);
bool enable_num_lock = keyboard_settings_config->read_bool_entry("StartupEnable", "NumLock", false);
auto keyboard_device_or_error = Core::File::open("/dev/keyboard0", Core::OpenMode::ReadOnly);
if (keyboard_device_or_error.is_error()) {
warnln("Failed to open /dev/keyboard0: {}", keyboard_device_or_error.error());
VERIFY_NOT_REACHED();
}
auto keyboard_device = keyboard_device_or_error.release_value();
int rc = ioctl(keyboard_device->fd(), KEYBOARD_IOCTL_SET_NUM_LOCK, enable_num_lock);
if (rc < 0) {
perror("ioctl(KEYBOARD_IOCTL_SET_NUM_LOCK)");
return 1;
}
}