diff options
-rw-r--r-- | Kernel/API/Syscall.h | 1 | ||||
-rw-r--r-- | Kernel/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Kernel/Devices/HID/HIDManagement.cpp | 5 | ||||
-rw-r--r-- | Kernel/Devices/HID/HIDManagement.h | 1 | ||||
-rw-r--r-- | Kernel/Devices/HID/KeyboardDevice.h | 2 | ||||
-rw-r--r-- | Kernel/Process.h | 1 | ||||
-rw-r--r-- | Kernel/Syscalls/num_lock.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibC/serenity.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibC/serenity.h | 2 | ||||
-rw-r--r-- | Userland/Services/KeyboardPreferenceLoader/main.cpp | 23 |
10 files changed, 21 insertions, 38 deletions
diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index b28f7f0804..36c28c2611 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -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) \ diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index b3cbf61c74..f09f0f6e9b 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -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 diff --git a/Kernel/Devices/HID/HIDManagement.cpp b/Kernel/Devices/HID/HIDManagement.cpp index 2eaa7e2f01..67c2073007 100644 --- a/Kernel/Devices/HID/HIDManagement.cpp +++ b/Kernel/Devices/HID/HIDManagement.cpp @@ -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 diff --git a/Kernel/Devices/HID/HIDManagement.h b/Kernel/Devices/HID/HIDManagement.h index 0249ab94e7..954e0d1af6 100644 --- a/Kernel/Devices/HID/HIDManagement.h +++ b/Kernel/Devices/HID/HIDManagement.h @@ -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(); diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h index ea6057978c..23964f6908 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -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; diff --git a/Kernel/Process.h b/Kernel/Process.h index 7bf21c630e..7caca888bd 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -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); diff --git a/Kernel/Syscalls/num_lock.cpp b/Kernel/Syscalls/num_lock.cpp deleted file mode 100644 index aff6d60ff1..0000000000 --- a/Kernel/Syscalls/num_lock.cpp +++ /dev/null @@ -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; -} - -} diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp index e819b20d62..0f112ca0ae 100644 --- a/Userland/Libraries/LibC/serenity.cpp +++ b/Userland/Libraries/LibC/serenity.cpp @@ -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; diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index f375afcd86..c1d8f573b0 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -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 diff --git a/Userland/Services/KeyboardPreferenceLoader/main.cpp b/Userland/Services/KeyboardPreferenceLoader/main.cpp index acebe25edf..63d2f1036e 100644 --- a/Userland/Services/KeyboardPreferenceLoader/main.cpp +++ b/Userland/Services/KeyboardPreferenceLoader/main.cpp @@ -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; + } } |