Commit graph

54 commits

Author SHA1 Message Date
Sahan Fernando 2845c6753e Kernel: Clean up VirtIOGPU class interfaces 2021-07-18 19:58:17 +04:30
Sahan Fernando d9330c42fa Kernel: Replace VirtIOGPU reinterpret casts with AK::BinaryBufferWriter 2021-07-18 19:58:17 +04:30
Sahan Fernando 04226f0c0a Kernel: Improve debug prints for VirtIOGPU device config events 2021-07-18 19:58:17 +04:30
Sahan Fernando 4dddc56ad9 Kernel: Rename VirtIOGPU/VirtIOGPU.cpp to VirtIOGPU/GPU.cpp 2021-07-18 19:58:17 +04:30
Sahan Fernando 1c77f80676 Kernel: Put VirtIOGPU related types into a namespace 2021-07-18 19:58:17 +04:30
Andreas Kling 9457d83986 Kernel: Rename Locker => MutexLocker 2021-07-18 01:53:04 +02:00
Andreas Kling cee9528168 Kernel: Rename Lock to Mutex
Let's be explicit about what kind of lock this is meant to be.
2021-07-17 21:10:32 +02:00
Liav A 9e36158ece Kernel: Remove stale forward declaration of BochsFramebufferDevice 2021-07-16 18:50:16 +02:00
Luke 2df4d977e2 Kernel: Return ENOMEM on allocation failures in FramebufferDevice::mmap 2021-07-16 11:15:30 +02:00
Liav A 2a1bf53435 Kernel/Graphics: Move Bochs graphics related code into a separate folder 2021-07-12 22:53:08 +02:00
Liav A 3fee1cbe66 Kernel/Graphics: Remove unnecessary Bochs.h file
Nobody excepts BochsGraphicsAdapter code uses these definitions, so
let's put them back into the BochsGraphicsAdapter.cpp file.
2021-07-12 22:53:08 +02:00
Brian Gianforcaro abe72ede7a Kernel: Remove unused header includes in Graphics subtree 2021-07-11 21:37:38 +02:00
Liav A a8c35b6a93 Kernel: Fix condition on whether to initialize a display adapter or not 2021-07-11 21:16:33 +02:00
Liav A b882e5ff6b Kernel/Graphics: Move Intel graphics related code to a separate folder 2021-07-11 21:16:33 +02:00
Andreas Kling f244a25f71 Kernel: Rename VMObject::clone() => try_clone()
And fix an unsafe dereference in SharedInodeVMObject::try_clone()
to make it OOM-safe.
2021-07-11 19:09:02 +02:00
Andreas Kling 88d490566f Kernel: Rename various *VMObject::create*() => try_create()
try_*() implies that it can fail (and they all return RefPtr with
nullptr signalling failure.)
2021-07-11 17:55:29 +02:00
Andreas Kling 846685fca2 Kernel: Remove bogus VMObject resizing in VirtIOGPU
It is not legal to resize a VMObject after it has been created.
As far as I can tell, this code would never actually run since the
object was already populated with physical pages due to using
AllocationStrategy::AllocateNow.
2021-07-11 17:42:31 +02:00
Andreas Kling c9f6786e8b Kernel: Make various T::class_name() and similar return StringView
Instead of returning char const*, we can also give you a StringView.
2021-07-11 01:46:59 +02:00
Tom 02651f8dc6 Kernel: Make VirtIO GPU buffer flipping more spec compliant
The spec requires a flush after setting the new buffer resource id,
which is required by QEMUs SDL backend but not the GTK backend. This
brings us in line with the spec and makes it work for the SDL backend.
2021-07-10 21:24:52 +02:00
Daniel Bertalan 949ea9cb4a Kernel: Use range-for wherever possible 2021-07-08 10:11:00 +02:00
Daniel Bertalan 5f7f063919 Everywhere: Mark debug-only functions [[maybe_unused]]
These functions are only used from within `dbgln_if` calls, so in
certain build configurations, they go unused. Similarly to variables, we
now signal to the compiler that we understand that these are not always
in use.
2021-07-08 10:11:00 +02:00
Andreas Kling 7e4bc04057 Kernel: Don't remap BochsGraphicsAdapter MMIO registers on every access
We were creating a new memory mapping every time WindowServer performed
a buffer flip. This was very visible in whole-system profiles, as the
mapping and unmapping of MMIO registers caused quite a bit of kmalloc()
and kfree() churn.

Avoid this problem by simply keeping the MMIO registers mapped.
2021-07-06 12:24:51 +02:00
Tom 7fdf902e4a Kernel: Implement buffer flipping for VirtIOGPU framebuffers
This solves tearing issues and improves performance when updating the
VirtIOGPU framebuffers.
2021-07-04 23:59:17 +02:00
Tom fdae117600 WindowServer: Implement support for combined buffer flipping + flushing
Some devices may require DMA transfers to flush the updated buffer
areas prior to flipping. For those devices we track the areas that
require flushing prior to the next flip. For devices that do not
support flipping, but require flushing, we'll simply flush after
updating the front buffer.

This also adds a small optimization that skips these steps entirely for
a screen that doesn't have any updates that need to be rendered.
2021-07-04 23:59:17 +02:00
Liav A 00e4cc23cb Kernel/Graphics: Unblank the screen when initializing bochs display 2021-07-03 16:28:49 +02:00
Liav A 3fae7ca113 Kernel: Clarify and make it easy to not use raw numbers
Let's put the PCI IDs as enums in the PCI namespace so they're free to
pollute that namespace, but it's also more easier to use them.
2021-07-03 16:28:49 +02:00
Liav A b4e230a7bb Kernel/Graphics: Assert if trying to initialize with the wrong driver 2021-07-03 16:28:49 +02:00
Liav A 053a832fac Kernel: Simplify graphics initialization somewhat
We use a switch-case statements to ensure we try to find the best
suitable driver for a specific graphics card. In case we don't find
such, we use the default statement to initialize the graphics card as a
generic VGA adapter, if the adapter is VGA compatible.

If we couldn't initialize the driver, we don't touch this adapter
anymore.

Also, GraphicsDevice should not be tied to a PCI::Address member, as it
can be theortically be used with other buses (e.g. ISA cards).
2021-07-03 16:28:49 +02:00
Daniel Bertalan 42d197cde7 Kernel: Fix miscellaneous warnings when building with Clang
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-07-03 01:56:31 +04:30
Liav A 6568bb47cb Kernel/PCI: Move the PCI components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Tom 38af4c29e6 WindowServer: Coalesce flushing buffers into one ioctl() call
We regularily need to flush many rectangles, so instead of making many
expensive ioctl() calls to the framebuffer driver, collect the
rectangles and only make one call. And if we have too many rectangles
then it may be cheaper to just update the entire region, in which case
we simply convert them all into a union and just flush that one
rectangle instead.
2021-06-27 09:46:27 +02:00
Tom 56cd0f929e Kernel: Enable additional VirtIO displays only on first resolution set
Also, only allocate the amount of memory we actually need for the given
resolution.
2021-06-27 09:46:27 +02:00
Tom 8749235046 Kernel: Add support for multiple VirtIO GPU outputs
This creates /dev/fbX devices for each physical output, owned by the
parent VirtIOGPU instance. This allows mapping and setting resolutions
independently for each output.
2021-06-27 09:46:27 +02:00
Sahan Fernando b9ad6058aa Kernel: Add VirtIOGPU graphics device 2021-06-25 19:26:30 +02:00
Sahan Fernando 34e9fa4d3b Kernel: Abstract FramebufferConsole away from contiguous physical range
Currently, Kernel::Graphics::FramebufferConsole is written assuming that
the underlying framebuffer memory exists in physically contiguous
memory. There are a bunch of framebuffer devices that would need to use
the components of FramebufferConsole (in particular access to the kernel
bitmap font rendering logic). To reduce code duplication, framebuffer
console has been split into two parts, the abstract
GenericFramebufferConsole class which does the rendering, and the
ContiguousFramebufferConsole class which contains all logic related to
managing the underling vm object.

Also, a new flush method has been added to the class, to support devices
that require an extra flush step to render.
2021-06-25 19:26:30 +02:00
Hendiadyoin1 62f9377656 Kernel: Move special sections into Sections.h
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24 00:38:23 +02:00
Tom fb488e2b27 Kernel: Allow VGA-capable graphics adapters to exist with legacy VGA
If we have a VGA-capable graphics adapter that we support, we should
prefer it over any legacy VGA because we wouldn't use it in legacy VGA
mode in this case.

This solves the problem where we would only use the legacy VGA card
when both a legacy VGA card as well as a VGA-mode capable adapter is
present.
2021-06-20 12:07:06 +02:00
Liav A 6a9dc5562d Kernel: Use IO ports instad of MMIO with Bochs graphics in VirtualBox
This is needed for VirtualBox, because it doesn't support controlling
the device with MMIO.

Fixes #7558.
2021-06-04 13:02:32 +02:00
Liav A d18d91dedc Kernel/Graphics: Add a proper method to check if Intel GPU is supported 2021-06-04 13:02:32 +02:00
Liav A 47c1a31f89 Kernel: Support new lines when doing critical printing
If we are printing strings in the critical path, handling new lines
require us to break abstraction a bit to print new lines.

Fixes #7562.
2021-06-03 16:16:22 +01:00
Liav A e8d85b0694 Kernel/Graphics: Remove unused overloaded write methods of Console
If we happen to print a string, we could use a StringView instead. For
now, let's remove them entirely.
2021-06-03 16:16:22 +01:00
Liav A c1a4dfeffb Kernel/Graphics: Remove unnecessary derived FramebufferDevice classes
It seems like overly-specific classes were written for no good reason.
Instead of making each adapter to have its own unique FramebufferDevice
class, let's generalize everything to keep implementation more
consistent.
2021-05-27 22:39:13 +02:00
Liav A c6ffee7f18 Kernel/Graphics: Indicate initialization failed if no device was found 2021-05-21 17:58:53 +01:00
Liav A 09d09b79b6 Kernel: Fix type, dectivate_writes => deactivate_writes 2021-05-21 08:08:33 +02:00
Liav A db268efa69 Kernel/Graphics: Choose VMObject considering enabled state when mmaping
When mmaping a Framebuffer from userspace, we need to check whether the
framebuffer device is actually enabled (e.g. graphical mode is being
used) or a textual VirtualConsole is active.

Considering the above state, we mmap the right VMObject to ensure we
don't have graphical artifacts if we change the resolution from
DisplaySettings, changed to textual mode and after the resolution change
was reverted, we will see the Desktop reappearing even though we are
still in textual mode.
2021-05-21 08:08:33 +02:00
Liav A 87f8f892d8 Kernel: Fix framebuffer resolution modesetting after boot
If we tried to change the resolution before of this patch, we triggered
a kernel crash due to mmaping the framebuffer device again.
Therefore, on mmaping of the framebuffer device, we create an entire new
set of VMObjects and Regions for the new settings.

Then, when we change the resolution, the framebuffersconsole needs to be
updated with the new resolution and also to be refreshed with the new
settings. To ensure we handle both shrinking of the resolution and
growth of it, we only copy the right amount of available data from the
cells Region.
2021-05-21 08:08:33 +02:00
Linus Groh 0aab774343 Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
Liav A 02b73cb93d Kernel/Graphics: Be more consistent about arguments passing
This fixes a bug that was reported on this discord server by
@ElectrodeYT - due to the confusion of passing arguments in different
orders, we messed up and triggered a page fault due to faulty sizes.
2021-05-17 00:30:40 +01:00
Liav A 7995e115b8 Kernel/Graphics: Round size value when mapping real framebuffer 2021-05-16 21:59:10 +01:00
Liav A 7f3080c8f2 Kernel/Graphics: Assign console to be from VGACompatibleAdapter always
If we create a VGACompatibleAdapter object with a preset framebuffer,
Always assign the console so we can use it.

This is useful for modesetting done by a Multiboot loader, like GRUB.
2021-05-16 21:59:10 +01:00