Commit Graph

13 Commits

Author SHA1 Message Date
Andreas Kling
11eee67b85 Kernel: Make self-contained locking smart pointers their own classes
Until now, our kernel has reimplemented a number of AK classes to
provide automatic internal locking:

- RefPtr
- NonnullRefPtr
- WeakPtr
- Weakable

This patch renames the Kernel classes so that they can coexist with
the original AK classes:

- RefPtr => LockRefPtr
- NonnullRefPtr => NonnullLockRefPtr
- WeakPtr => LockWeakPtr
- Weakable => LockWeakable

The goal here is to eventually get rid of the Lock* classes in favor of
using external locking.
2022-08-20 17:20:43 +02:00
Liav A
1462211ccf Kernel: Allow WorkQueue items allocation failures propagation
In most cases it's safe to abort the requested operation and go forward,
however, in some places it's not clear yet how to handle these failures,
therefore, we use the MUST() wrapper to force a kernel panic for now.
2022-04-20 19:47:18 +02:00
Sviatoslav Peleshko
073f472c51 Kernel: Init receive buffer for dynamically created VirtIO console port
We already init receive buffer if we have singleport console, but if
we have multiport console that dynamically allocates ports we never
initted their receive buffers.
2022-02-20 20:32:22 -08:00
Idan Horowitz
d65347d39d Kernel: Make Memory::RingBuffer construction fallible 2022-01-21 16:27:21 +01:00
Idan Horowitz
618f123463 Kernel: Use StringView instead of String in RingBuffer's constructor
This String was being copied into a KString internally anyways.
2022-01-13 00:20:08 -08:00
Hendiadyoin1
9be409585c Kernel: Some clang-tidy fixes in Bus/VirtIO 2021-12-09 22:53:42 -08:00
Jelle Raaijmakers
e187207610 Kernel: Register Virtio console ports with device management
Previously, Virtio console ports would not show up in `/sys/dev/char/`.
Also adds support to `SystemServer` to create more than one console
port device in `/dev/` in the multiport case.
2021-11-30 10:53:41 +01:00
Liav A
057f5a12c2 Kernel/PCI: Propagate usage of DeviceIdentifier everywhere
This allows us to remove a bunch of PCI API functions, and instead to
leverage the cached data from DeviceIdentifier object in many places.
2021-09-29 11:24:33 +02:00
Liav A
009feefee0 Kernel/Devices: Ensure appropriate locking on the Device map singleton
Devices might be removed and inserted at anytime, so let's ensure we
always do these kind of operations with a good known state of the
HashMap.

The VirtIO code was modified to create devices outside the IRQ handler,
so now it works with the new locking of the devices singleton, but a
better approach might be needed later on.
2021-09-08 00:42:20 +02:00
Liav A
ed6c1f53af Kernel/VirtIO: Defer initialization of device out of the constructor
This ensures we safely handle interrupts (which can call virtual
functions), so they don't happen in the constructor - this pattern can
lead to a crash, if we are still in the constructor context because
not all methods are available for usage (some are pure virtual,
so it's possible to call __cxa_pure_virtual).

Also, under some conditions like adding a PCI device via PCI-passthrough
mechanism in QEMU, it became exposed to the eye that the code asserts on
RNG::handle_device_config_change(). That device has no configuration but
if the hypervisor still misbehaves and tries to configure it, we should
simply return false to indicate nothing happened.
2021-09-04 16:36:02 +02:00
Andreas Kling
8a89698ea4 Kernel/VirtIO: Stop leaking VirtIO::ConsolePort objects 2021-09-03 02:36:09 +02:00
Liav A
8e90a4fd1c Kernel/VirtIO: Don't expose constructors as public method
This leads to a bad pattern where anyone could create an RNG or a
Console object. Instead, let's just use the common pattern of a static
method to instantiate a new object and return it wrapped by a
NonnullRefPtr.
2021-08-31 16:51:13 +02:00
Liav A
01ae614727 Kernel/VirtIO: Remove redundant VirtIO word from filenames
Now that all related VirtIO classes are in the VirtIO namespace, let's
just remove the redundant VirtIO word from filenames.
2021-08-31 16:51:13 +02:00