Commit Graph

6080 Commits

Author SHA1 Message Date
Jelle Raaijmakers
86a1ff5204 Kernel: Drain I8042 PS/2 keyboard output after enabling
As soon as we enable the first PS/2 port on the I8042 controller, the
output buffer may become full. We need to drain it before attempting
any new commands with the controller (such as enabling the second PS/2
port).

Fixes #10872.
2021-11-12 07:35:18 +01:00
Andreas Kling
80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
ad5d217e76 Kernel/Ext2FS: Propagate HashMap errors instead of panicking 2021-11-11 01:27:46 +01:00
Andreas Kling
9d1f238450 AK: Make HashTable and HashMap try_* functions return ErrorOr<T>
This allows us to use TRY() and MUST() with them.
2021-11-11 01:27:46 +01:00
Andreas Kling
f86ee71f65 Kernel/Ext2FS: Propagate errors from block list computation functions 2021-11-10 21:58:58 +01:00
Andreas Kling
4661ca5f15 Kernel: Propagate Vector append errors in two places in Ext2FS
There are a bunch more of these, just taking care of some simple ones.
2021-11-10 21:58:58 +01:00
Andreas Kling
5ce753b74d Kernel: Make Inode::traverse_as_directory() callback return ErrorOr
This allows us to propagate errors from inside the callback with TRY().
2021-11-10 21:58:58 +01:00
Andreas Kling
88b6428c25 AK: Make Vector::try_* functions return ErrorOr<void>
Instead of signalling allocation failure with a bool return value
(false), we now use ErrorOr<void> and return ENOMEM as appropriate.
This allows us to use TRY() and MUST() with Vector. :^)
2021-11-10 21:58:58 +01:00
Andreas Kling
5f7d008791 AK+Everywhere: Stop including Vector.h from StringView.h
Preparation for using Error.h from Vector.h. This required moving some
things out of line.
2021-11-10 21:58:58 +01:00
Ben Wiederhake
ad5061bb7a Kernel: Make (f)statvfs report filesystem ID correctly 2021-11-10 16:13:10 +01:00
Ben Wiederhake
631447da57 Kernel: Fix TOCTOU in fstatvfs
In particular, fstatvfs used to assume that a file that was earlier
opened using some path will forever be at that path. This is wrong, and
in the meantime new mounts and new filesystems could take up the
filename or directories, leading to a completely inaccurate result.
This commit improves the situation:
- All filesystem information is now always accurate.
- The mount flags *might* be erroneously zero, if the custody for the
  open file is not available. I don't know when that might happen, but
  it is definitely not the typical case.
2021-11-10 16:13:10 +01:00
Ben Wiederhake
bf7a2ff941 AK+Kernel: Make BitmapView read-only 2021-11-10 14:39:42 +01:00
Ben Wiederhake
850db15d66 Everywhere: Remove unused AK/Bitmap includes 2021-11-10 14:39:42 +01:00
Andreas Kling
79fa9765ca Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace!
This was a slightly tedious refactoring that took a long time, so it's
not unlikely that some bugs crept in.

Nevertheless, it does pass basic functionality testing, and it's just
real nice to finally see the same pattern in all contexts. :^)
2021-11-08 01:10:53 +01:00
Ben Wiederhake
3582184d8c Kernel: Expose inode information in /proc/pid/fds 2021-11-08 00:34:58 +01:00
AMACB
60362ef401 Kernel: Initialize regs.fs in Processor::init_context
Commit f285241c replaced the line that sets regs.fs with a line that
sets regs.gs, but not vice versa.
2021-11-06 11:54:28 +01:00
Liav A
066b1183cd Kernel: Return ENOTIMPL when trying to read from SysFS inodes
Instead of asserting, just return reasonable error back to userland.
2021-11-05 16:26:45 +02:00
Jelle Raaijmakers
a4b1c0fd0c Kernel: Process available VMWare mouse events immediately
The Qemu I8042 controller does not send one IRQ per event, it sends
over four since it will not stop trying to emulate the PS/2 mouse.

If the VMWare backdoor is active, a fake I8042 mouse event will be sent
that we can then use to check if there are VMWare mouse events present.
However, we were only processing one mouse event at a time, even though
multiple events could have been queued up. Luckily this does not often
lead to issues, since after the first IRQ we would still get three
additional interrupts that would then empty the queue.

This change makes sure we always empty the event queue immediately,
instead of waiting on the next interrupt to happen. Functionally this
changes nothing - it could merely improve latency by not waiting for
new interrupts to come in.

Coincidently, this brings our implementation closer to how Linux deals
with the VMMouse.
2021-11-04 18:53:37 +01:00
Jelle Raaijmakers
8a65a9c30f Kernel: Clean up VMWareMouseDevice and VMWareBackdoor
No functional changes.
2021-11-04 18:53:37 +01:00
Andreas Kling
652042e680 Revert "Kernel: Prevent VMWareMouseDevice from handling invalid mouse packets"
This reverts commit 4131b35851.

We're swallowing way too many mouse events from QEMU with this code
enabled. Something is not right, so let's revert it for now.
2021-11-03 16:48:42 +01:00
Brian Gianforcaro
9f6eabd73a Kernel: Move TTY subsystem to use KString instead of AK::String
This is minor progress on removing the `AK::String` API from the Kernel
in the interest of improving OOM safety.
2021-11-02 11:34:31 +01:00
Brian Gianforcaro
71f05c70b4 Kernel: Remove duplicate constructor from TTY/VirtualConsole
This removes some code dupe from the constructors.

By removing this duplicate constructor we can utilize the main
VirtualConsole::create factory implementation and call that from the
VirtualConsole::create_with_preset_log factory method.
2021-11-02 11:34:31 +01:00
Brian Gianforcaro
2c85f65519 Kernel: Switch BIOSSysFSComponent constructor to AK::StringView
These are constants, they don't need to be dynamically allocated.
Another minor step towards removing `AK::String` from the Kernel
and improving OOM safety.
2021-11-02 11:34:31 +01:00
SeekingBlues
b9da877941 Kernel: Do not try opening the same file when dumping perfcore
Dumping perfcore would always fail with EEXIST. This regressed in #10707
because of an incorrect indentation in the for loop.
2021-10-31 21:10:17 +01:00
Ben Wiederhake
e3b7c305bc Kernel: Don't crash on writes to ProcFS 2021-10-31 18:44:12 +01:00
Marcin Undak
588ba72fe7 Kernel: Draw picture on screen when booting Raspberry Pi 2021-10-31 12:35:53 +01:00
Marcin Undak
e7141c4230 Kernel: Add very simple PPM parser for Aarch64
This is much simpler and more embeddable version than libGFX one.
Solely purpose is to draw initial boot logo on screen before kernel
is even booted.
2021-10-31 12:35:53 +01:00
Marcin Undak
dbb61620be Kernel: Add Framebuffer class for Raspberry Pi
It initializes framebuffer and exposes access to its properties.
2021-10-31 12:35:53 +01:00
Marcin Undak
3cc5752a69 Kernel: Refactor Aarch64 MailBox class
The goal was to reduce common setup of messages. Changes:
* MailBox turned into singleton to follow existing patterns
* Removed device specific messages from MailBox requiring
  clients to know the details instead
* Created base Message class which clients should deriver from

It really simplify the usage for more complicated message queues
like framebuffer setup - see followup commits.
2021-10-31 12:35:53 +01:00
Marcin Undak
82a73b8499 Kernel: Add temporary debug printing utilities for Aarch64
Added dbgln() and warnln() debug functions to help bootstraping.
Eventually they are going to be replaced by AK/Format.h implementation.
2021-10-31 12:35:53 +01:00
Ben Wiederhake
9a4e125468 Kernel: Remove misleading FIXME in DevTmpFS
This FIXME does not seem to apply anymore. Yes, symbolic links in all
filesystems appear to be slightly broken, but that has nothing to do
with File::absolute_path. Let's remove the wrong FIXME instead of adding
to the confusion.
2021-10-31 12:06:28 +01:00
Ben Wiederhake
c05c5a7ff4 Kernel: Clarify ambiguous {File,Description}::absolute_path
Found due to smelly code in InodeFile::absolute_path.

In particular, this replaces the following misleading methods:

File::absolute_path
This method *never* returns an actual path, and if called on an
InodeFile (which is impossible), it would VERIFY_NOT_REACHED().

OpenFileDescription::try_serialize_absolute_path
OpenFileDescription::absolute_path
These methods do not guarantee to return an actual path (just like the
other method), and just like Custody::absolute_path they do not
guarantee accuracy. In particular, just renaming the method made a
TOCTOU bug obvious.

The new method signatures use KResultOr, just like
try_serialize_absolute_path() already did.
2021-10-31 12:06:28 +01:00
Ben Wiederhake
88ca12f037 Kernel: Enable early-returns from VFS::for_each_mount 2021-10-31 12:06:28 +01:00
Ben Wiederhake
735da58d44 Kernel: Avoid OpenFileDescription::absolute_path 2021-10-31 12:06:28 +01:00
Ben Wiederhake
fa018d3ba1 Kernel: Fix common misuse of KString in debug messages 2021-10-30 17:35:18 +02:00
Idan Horowitz
a8bd78e634 LibC: Include sys/uio.h in sys/socket.h for struct iovec 2021-10-28 11:24:36 +02:00
Idan Horowitz
2882a90dec Kernel: Add the IFF_* SIOCGIFFLAGS flag macros 2021-10-28 11:24:36 +02:00
Idan Horowitz
adc9939a7b Kernel+LibC: Add support for the IPv4 TOS field via the IP_TOS sockopt 2021-10-28 11:24:36 +02:00
Idan Horowitz
20c7fcfedf Kernel: Fix accidental memory over-read in getsockopt(IP_TTL)
We were accidentally casting the pointer to m_ttl from an u8* to an int*
which resulted in copying of 3 extra unrelated bytes (which turned out
to be padding in this case).
2021-10-28 11:24:36 +02:00
Idan Horowitz
c45b1e1983 LibC: Add IPPROTO_ICMPV6 macro 2021-10-28 11:24:36 +02:00
Filiph Sandström
c6247fe414 Everywhere: Rename back-click to backward-click
This matches the current forward-click terminology.
2021-10-27 22:05:58 +03:00
Liav A
8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Liav A
78e724a899 Kernel/Graphics: Rename GraphicsDevice => GenericGraphicsAdapter
We already use the term adapter for instances of this class, so let's
better represent this class by changing its name to what it really is.
2021-10-27 07:57:44 +03:00
Liav A
c7eb761b7f Kernel/Graphics: Re-order parameters in VirtIO GraphicsAdapter methods
As suggested by @ccapitalK, it makes the interface more neat and clean.
The proper order is to get ScanoutID first, then ResourceID and after it
everything else that is needed to complete the operation successfully.
2021-10-27 07:57:44 +03:00
Liav A
f476b49fd8 Kernel/Graphics: Merge VirtIO GraphicsAdapter and VirtIO GPU code
A VirtIO graphics adapter is really the VirtIO GPU, so the virtualized
hardware has no distinction between both components so there's no
need to put such distinction in software.

We might need to split things in the future, but when we do so, we must
take proper care to ensure that the interface between the components
is correct and use the usual codebase patterns.
2021-10-27 07:57:44 +03:00
Liav A
a9538b5879 Kernel/Graphics: Convert type method => bool vga compatible method
We never used that type method except in initialization in
GraphicsManagement, and we used it there to query whether the device is
VGA compatible or not.
2021-10-27 07:57:44 +03:00
Liav A
fb0ed2ae46 Kernel/Graphics: Force VirtIO Framebuffer to inherit FramebufferDevice
The distinction is not justified because a VirtIO Framebuffer device
acts much more like a regular FramebufferDevice than a pure BlockDevice.
2021-10-27 07:57:44 +03:00
Liav A
4815282a5f Kernel/Graphics: Rename VirtIO FrameBufferDevice => FramebufferDevice 2021-10-27 07:57:44 +03:00
Andreas Kling
e0f0b6379a Kernel: Make WorkQueue::WorkItem slab allocated 2021-10-26 10:50:44 +02:00