summaryrefslogtreecommitdiff
path: root/Kernel/TTY
AgeCommit message (Collapse)Author
2021-09-05Kernel: Declare type aliases with "using" instead of "typedef"Brian Gianforcaro
This is the idiomatic way to declare type aliases in modern C++. Flagged by Sonar Cloud as a "Code Smell", but I happen to agree with this particular one. :^)
2021-09-01Kernel: Convert UserOrKernelBuffer callbacks to use AK::BytesBrian Gianforcaro
2021-08-29Kernel: Rename FileDescription::create() => try_create()Andreas Kling
2021-08-23Kernel: Rename Thread::BlockCondition to BlockerSetAndreas Kling
This class represents a set of Thread::Blocker objects attached to something that those blockers are waiting on.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-22Kernel: Rename SpinLockProtectedValue<T> => SpinLockProtected<T>Andreas Kling
2021-08-22Kernel: Rename ProtectedValue<T> => MutexProtected<T>Andreas Kling
Let's make it obvious what we're protecting it with.
2021-08-19Kernel: Make Process::current() return a Process& instead of Process*Idan Horowitz
This has several benefits: 1) We no longer just blindly derefence a null pointer in various places 2) We will get nicer runtime error messages if the current process does turn out to be null in the call location 3) GCC no longer complains about possible nullptr dereferences when compiling without KUBSAN
2021-08-17Kernel: Convert SlavePTY all-instances HashTable to an IntrusiveListAndreas Kling
This simplifies the DevPtsFS implementation somewhat, as it no longer requires SlavePTY to register itself with it, since it can now simply use the list of SlavePTY instances.
2021-08-09Kernel: Fix logic typo in ConsoleManagement::is_initialized()Andreas Kling
Regressed in 2ff3c54153b66e71f2917afe525d64fe63305245.
2021-08-08Kernel: Remove unnecessary churn in ConsoleManagementAndreas Kling
The maximum number of virtual consoles is determined at compile time, so we can pre-allocate that many slots, dodging some heap allocations. Furthermore, virtual consoles are never destroyed, so it's fine to simply store a raw pointer to the currently active one.
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-07Kernel: Port PTYMultiplexer to ProtectedValueAndreas Kling
2021-08-07Kernel: Increase maximum PTY count from 8 to 64Andreas Kling
Let's allow users to allocate more pseudo-terminals if they want.
2021-08-07Kernel/TTY: Remove redundant SpinLock from VirtualConsoleAndreas Kling
VirtualConsole::m_lock was only used in a single place: on_tty_write() That function is already protected by a global lock, so this second lock served no purpose whatsoever.
2021-08-07Kernel: Move Mutex into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Fix handful of remaining "return -EFOO" mistakesAndreas Kling
Now that all KResult and KResultOr are used consistently throughout the kernel, it's no longer necessary to return negative error codes. However, we were still doing that in some places, so let's fix all those (bugs) by removing the minuses. :^)
2021-08-03Kernel: Convert MasterPTY creation to use DoubleBuffer factoryBrian Gianforcaro
In order to remove the public DoubleBuffer constructor, we need to convert the callers to the factory instead, allowing the caller to observe OOM.
2021-07-27Kernel: Modify the IOCTL API to return KResultBrian Gianforcaro
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
2021-07-27Kernel+LibC: Use argument for TIOCGPGRP ioctl valueBrian Gianforcaro
In preparation for modifying the Kernel IOCTL API to return KResult instead of int, we need to fix this ioctl to an argument to receive it's return value, instead of using the actual function return value.
2021-07-27Kernel: Utilize AK::Userspace<T> in the ioctl interfaceBrian Gianforcaro
It's easy to forget the responsibility of validating and safely copying kernel parameters in code that is far away from syscalls. ioctl's are one such example, and bugs there are just as dangerous as at the root syscall level. To avoid this case, utilize the AK::Userspace<T> template in the ioctl kernel interface so that implementors have no choice but to properly validate and copy ioctl pointer arguments.
2021-07-18Kernel: Rename Locker => MutexLockerAndreas Kling
2021-07-17Kernel: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
2021-07-11Kernel: Standardize the header include style to 'include <Kernel/...>'Brian Gianforcaro
This is the overwhelming standard in the project, but there were some cases in the kernel which were not following it, lets fix those cases!
2021-07-11Kernel: Remove unused header includes in TTY subtreeBrian Gianforcaro
2021-07-11Kernel: Make various T::class_name() and similar return StringViewAndreas Kling
Instead of returning char const*, we can also give you a StringView.
2021-07-03Kernel: Fix miscellaneous warnings when building with ClangDaniel Bertalan
These small changes fix the remaining warnings that come up during kernel compilation with Clang. These specific fixes were for benign things: unused lambda captures and braces around scalar initializers.
2021-06-25Kernel: Don't clear VirtualConsoles when initializingSahan Fernando
Instead of calling clear() for each virtual console we initialize, we only call clear() when activating it from ConsoleManagement.
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24Kernel: Pull apart CPU.hHendiadyoin1
This does not add any functional changes
2021-06-21Kernel: Fix assertion failure on large TTY writesDaniel Bertalan
The `File::can_write` mechanism lets us check that writes won't block, meaning some bytes can be immediately written to the underlying device. This means calling `File::write` in a situation where no data could be written is a logic error, which we `VERIFY()` in `Process::do_write()`. TTY, in particular, processes the write in 256-byte buffered chunks. Previously, we would assert that none of these sub-writes returned zero. This was a logic error, as this rejected some successful writes. For example, if there was exactly enough free space in `SlavePty`'s internal buffer for the previous sub-write to complete fully. This made it impossible to perform writes larger than `SlavePty`'s internal buffer. Note that it's not an issue if `on_tty_write` returns zero, as partial writes are handled correctly by the `buffer.read_buffered` helper. We won't spin in a loop trying to write to a full buffer. Fixes #8090
2021-06-18Kernel: Fix crash when changing screen resolutionGunnar Beutner
Steps to reproduce: 1. Change resolution to 640x480. 2. Change resolution to 1280x1024. 3. Observe the following kernel panic: Kernel::__panic(char const*, unsigned int, char const*) +0x55 Kernel::handle_crash(Kernel::RegisterState&, char const*, ...) +0x112 page_fault_handler +0x1130 page_fault_asm_entry +0x26 Kernel::VirtualConsole::refresh_after_resolution_change() +0x35e4 Kernel::ConsoleManagement::resolution_was_changed() +0x38b Kernel::Graphics::FramebufferConsole::set_resolution(...) +0x3e1 Kernel::BochsGraphicsAdapter::try_to_set_resolution(...) +0x319 .L4213 +0x40a Kernel::Process::sys$ioctl(int, unsigned int, unsigned int) +0x2fa Kernel::Syscall::handle(Kernel::RegisterState&, ...) +0xfdc syscall_handler +0x19c0 Kernel::syscall_asm_entry_dummy() +0x31
2021-06-17Kernel: Remove obsolete size_t castsGunnar Beutner
2021-06-16Kernel: Use KResultOr<size_t> throughout the TTY subsystemGunnar Beutner
Previously the VirtualConsole::on_tty_write() method would return an incorrect value when an error had occurred. This prompted me to update the TTY subsystem to use KResultOr<size_t> everywhere.
2021-06-11Kernel: Add missing BrightWhite color to VirtualConsoleDaniel Bertalan
Because of the 'default' label, the compiler did not warn about the missing field. The `VERIFY_NOT_REACHED` was moved out of the switch to fix this.
2021-06-10Kernel: Re-render console after echoing charactersDaniel Bertalan
If we do not flush the dirty lines, characters typed in canonical mode only appear after the virtual console has been switched away from, or the application has been killed. Instead, we now immediately perform the flush.
2021-06-10Kernel+LibVT: Fix selection with scrollback wrap-aroundDaniel Bertalan
If lines are removed from the tail of the scrollback buffer, the previous line indices will refer to different lines; therefore we need to offset them.
2021-06-10Kernel+LibVT: Implement left-right scrollingDaniel Bertalan
This commit implements the left/right scrolling used in the `ICH`/`DCH` escape sequences for `VirtualConsole`. This brings us one step closer to VT420/xterm compatibility. We can now finally remove the last escape sequence related `ifdef`s.
2021-06-10Kernel+LibVT: Add function for deleting a range of charactersDaniel Bertalan
Previously, this was done by telling the client to put a space at each character in the range. This was inefficient, because a large number of function calls took place and incorrect, as the ANSI standard dictates that character attributes should be cleared as well. The newly added `clear_in_line` function solves this issue. It performs just one bounds check when it's called and can be implemented as a pretty tight loop.
2021-06-10LibVT+Kernel: Support clearing the scrollback bufferDaniel Bertalan
As per the `xterm ctlseqs` documentation, `\e3J` should clear the scrollback buffer, and leave the visible lines unchanged. This commit fixes a FIXME.
2021-06-10LibVT+Kernel: Clean up scroll APIDaniel Bertalan
This commit cleans up some of the `#ifdef`-ed code smell in `Terminal`, by extending the scroll APIs to take a range of lines as a parameter. This makes it possible to use the same code for `IL`/`DL` as for scrolling. Note that the current scrolling implementation is very naive, and does many insertions/deletions in the middle of arrays, whereas swaps should be enough. This optimization will come in a later commit. The `linefeed` override was removed from `VirtualConsole`. Previously, it exhibited incorrect behavior by moving to column 0. Now that we use the method defined in `Terminal`, code which relied on this behavior stopped working. We go instead go through the TTY layer which handles the various output flags. Passing the input character-by-character seems a bit excessive, so a fix for it will come in another PR.
2021-06-05Kernel: Perform output processing on echoDaniel Bertalan
Previously, we would echo characters back just as they were passed to us, even in canonical mode. This caused newlines to not work correctly in some programs. Fixes #7802
2021-06-04LibVT+Kernel: Create `Color` classDaniel Bertalan
Previously, we converted colors to their RGB values immediately when they were set. This meant that their semantic meaning was lost, we could not tell a precise RGB value apart from a named/indexed color. The new way of storing colors will allow us to retain this information, so we can change a color scheme on the fly, and previously emitted text will also be affected.
2021-05-31Kernel: Fix crash when switching to console 5 & 6Sebastian Zaha
The changes in commit 20743e8 removed the s_max_virtual_consoles constant and hardcoded the number of consoles to 4. But in PS2KeyboardDevice the keyboard shortcuts for switching to consoles were hardcoded to 6. I reintroduced the constant and added it in both places.
2021-05-24LibVT: Add Alternate Screen Buffer supportDaniel Bertalan
The Alternate Screen Buffer is used by full-screen terminal applications (like `vim` and `nano`). Its data is stored separately from the normal buffer, therefore after applications using it exit, everything looks like it was before, the bottom of their interfaces isn't visible. An interesting feature is that it does not support scrollback, so it consumes less memory by not having to allocate lines for history. Because of the need to save and restore state between the switches, some correctness issues relating to it were also fixed in this commit.
2021-05-24LibVT+Kernel: Add support for setting cursor stylesDaniel Bertalan
This commit introduces support for 3 new escape sequences: 1. Stop blinking cursor mode 2. `DECTCEM` mode (enable/disable cursor) 3. `DECSCUSR` (set cursor style) `TerminalWidget` now supports the following cursor types: block, underline and vertical bar. Each of these can blink or be steady. `VirtualConsole` ignores these (just as we were doing before).