summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
AgeCommit message (Collapse)Author
2022-05-06Kernel: Force y offset 0 when switching between console & graphics modesLiav A
This fixes a weird bug that when sometimes a user tried to switch to console mode, the screen was frozen on graphics mode. After a hour of debugging this, it became apparent that the problem was that we left the y offset of the bochs graphics device in an invalid state, so it was not zero because the WindowServer changed it, and the framebuffer console code is not aware of horizontal and vertical offsets of the framebuffer screen, leading to the problem that the framebuffer console updates the first framebuffer (y offset = 0), but hardware was indicated to show the second framebuffer (y offset = first framebuffer height). Therefore, when doing a switch between these modes, always set the y offset to be zero.
2022-05-06Kernel/Graphics: Protect the list of display connectors with a SpinlockLiav A
This list could be updated in runtime if an hotplug event occurs, so we must protect it with a spin lock to avoid corruption of the list.
2022-05-06Kernel/Graphics: Implement basic support for VMWare SVGA adapterLiav A
2022-05-06Kernel/Graphics: Use boot console if the subsystem is disabledLiav A
This lets us actually to initialize VirtualConsoles later on.
2022-05-06Kernel/Graphics: Implement basic cursor for FramebufferConsoleLiav A
2022-05-05Kernel/Console: Use 8x16 character font bitmap instead of old 8x8 bitmapLiav A
This in turn makes the built-in kernel console much more nicer to look into, so let's remove the support for 8x8 bitmap and instead add 8x16 font bitmap.
2022-05-05Kernel/Graphics: Simplify the GenericGraphicsAdapter classLiav A
The old methods are already can be considered deprecated, and now after we removed framebuffer devices entirely, we can safely remove these methods too, which simplfies the GenericGraphicsAdapter class a lot.
2022-05-05Kernel/Graphics: Simplify the feature level of the Graphics subsystemLiav A
Instead of letting the user to determine whether framebuffer devices will be created (which is useless because they are gone by now), let's simplify the flow by allowing the user to choose between full, limited or disabled functionality. The determination happens only once, so, if the user decided to disable graphics support, the initialize method exits immediately. If limited functionality is chosen, then a generic DisplayConnector is initialized with the preset framebuffer resolution, if present, and then the initialize method exits. As a default, the code proceeds to initialize all drivers as usual.
2022-05-05Everywhere: Purge all support and usage of framebuffer devicesLiav A
Long live the DisplayConnector object!
2022-05-05Everywhere: Rename FB prefix structure names => GraphicsLiav A
2022-05-05Everywhere: Rename FB prefix name ioctls => GRAPHICSLiav A
2022-05-05Kernel/Graphics: Use DisplayConnector design with generic framebuffersLiav A
2022-05-05Kernel/Graphics: Apply DisplayConnector design on the VirtIO driverLiav A
2022-05-05Kernel/Graphics: Use VirtIO GPU3DDevice constructor indirectlyLiav A
We shouldn't expose the VirtIO GPU3DDevice constructor as public method, so instead, let's use the usual pattern of a static construction method that uses the constructor within the method.
2022-05-05Kernel/Graphics: Migrate Intel driver to use the DisplayConnector designLiav A
2022-05-05Kernel/Graphics: Use DisplayConnector design for the Bochs driverLiav A
2022-05-05Kernel/Graphics: Export Bochs definitions to a header fileLiav A
These definitions will be used later when applying the DisplayConnector design on the Bochs driver.
2022-05-05Kernel/Graphics: Introduce the DisplayConnector classLiav A
The DisplayConnector class is meant to replace the FramebufferDevice class. The advantage of this class over the FramebufferDevice class is: 1. It removes the mmap interface entirely. This interface is unsafe, as multiple processes could try to use it, and when switching to and from text console mode, there's no "good" way to revoke a memory mapping from this interface, let alone when there are multiple processes that call this interface. Therefore, in the DisplayConnector class there's no implementation for this method at all. 2. The class uses a new real-world structure called ModeSetting, which takes into account the fact that real hardware requires more than width, height and pitch settings to mode-set the display resolution. 3. The class assumes all instances should supply some sort of EDID, so it facilitates such mechanism to do so. Even if a given driver does not know what is the actual EDID, it will ask to create default-generic EDID blob. 3. This class shifts the responsibilies of switching between console mode and graphical mode from a GraphicsAdapter to the DisplayConnector class, so when doing the switch, the GraphicsManagement code actually asks each DisplayConnector object to do the switch and doesn't rely on the GraphicsAdapter objects at all.
2022-05-05Kernel/Graphics: Declare BochsGraphicsAdapter::get_edid private methodLiav A
2022-04-20Kernel: Allow WorkQueue items allocation failures propagationLiav A
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-01Everywhere: Run clang-formatIdan Horowitz
2022-03-19Kernel: Use original Console m_x and m_y in Text based implementationsLiav A
2022-03-18Kernel/Graphics: Don't declare VGA changing-state methods as constLiav A
2022-03-18Kernel: Fix crash when opening GPU3DDevice without creating a contextSahan Fernando
2022-03-18Kernel/Graphics: Move all VGA related methods to GraphicsManagementLiav A
This helps solving an issue when we boot with text mode screen so the Kernel initializes an early text mode console, but even after disabling it, that console can still access VGA ports. This wouldn't be a problem for emulated hardware but bare metal hardware might have a "conflict", especially if the native driver explicitly request to disable the VGA emulation.
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-14Kernel/PCI: Don't hold spinlocks when doing fast device enumerationLiav A
Instead, hold the lock while we copy the contents to a stack-based Vector then iterate on it without any locking. Because we rely on heap allocations, we need to propagate errors back in case of OOM condition, therefore, both PCI::enumerate API function and PCI::Access::add_host_controller_and_enumerate_attached_devices use now a ErrorOr<void> return value to propagate errors. OOM Error can only occur when enumerating the m_device_identifiers vector under a spinlock and trying to expand the temporary Vector which will be used locklessly to actually iterate over the PCI::DeviceIdentifiers objects.
2022-03-14Kernel: Fix buffer overflow in VirtIOGPU create_3d_resource(..)Brian Gianforcaro
This code attempts to copy the `Protocol::Resource3DSpecification` struct into request, starting at `Protocol::ResourceCreate3D::target` member of the `Protocol::ResourceCreate3D` struct. The problem is that the `Protocol::Resource3DSpecification` struct does not having the trailing `u32 padding` that the `ResourceCreate3D` struct has. Leading to memcopy overrunning the struct and corrupting 32 bits of data trailing the struct. Found by SonarCloud: - Memory copy function overflows the destination buffer.
2022-03-14Kernel: Sandbox each GPU3DDevice file description into own host contextSahan Fernando
2022-03-12Revert "Kernel: Don't override FramebufferDevice's memory regions on mmap"Brian Gianforcaro
This reverts commit 85ba70d86f69b2535586a2adcd873f85238b8491.
2022-03-09Kernel: Disable GPU fencing for VirtIOGPU operationsSahan Fernando
These fences should not be needed, since we force the use of synchronous operations through synchronous_virtio_gpu_command. The use of these fences also causes severe lag when SERENITY_GL is enabled.
2022-03-09Kernel: Implement basic VirGL deviceSahan Fernando
This commit flips VirtIOGPU back to using a Mutex for its operation lock (instead of a spinlock). This is necessary for avoiding a few system hangs when queuing actions on the driver from multiple processes, which becomes much more of an issue when using VirGL from multiple userspace process. This does result in a few code paths where we inevitably have to grab a mutex from inside a spinlock, the only way to fix both issues is to move to issuing asynchronous virtio gpu commands.
2022-03-09Kernel: Use AK::to_underlying instead of static_cast in VirtIOGPUSahan Fernando
2022-03-08Kernel: Don't override FramebufferDevice's memory regions on mmapHendiadyoin1
This additionally refactors FramebufferDevice::try_to_initialize to not leave the FramebufferDevice in an invalid state on errors. This also unifies the logic between FramebufferDevice::mmap and FramebufferDevice::try_to_initialize. This comes with the drawback of removing the UNMAP_AFTER_INIT attribute from this function, which wasn't honoured by IntelNativeGraphicsAdapter anyway.
2022-03-08Kernel/Graphics: Override first byte of the EDID in Intel Native driverLiav A
2022-03-08Kernel/Graphics: Print contents of offending EDID in Intel Native driverLiav A
2022-03-02Kernel/Graphics: Don't try to enumerate PCI adapters if PCI is disabledLiav A
If there's no PCI bus, then it's safe to assume that the x86 machine we run on supports VGA text mode console output with an ISA VGA adapter. If this is the case, we just instantiate a ISAVGAAdapter object that assumes this situation and allows us to boot into VGA text mode console.
2022-03-01Kernel: Respect actual framebuffer pitchAndreas Kling
Instead of winging it with "width * 4", use the actual pitch since it may be different. This makes the kernel text console show up in native 1368x768 on my ThinkPad X250. :^)
2022-02-24Kernel: Use IO init method for Bochs emulated VGA adapterPeter Ross
In short: QEMU supports both Memory-Mapped-IO and classic IO methods for controlling the emulated VGA device. Bochs and VirtualBox only support the classic IO method. An excellent write up on the history of these interfaces can be found here: https://www.kraxel.org/blog/2018/10/qemu-vga-emulation-and-bochs-display The IO method was how things were done originally in SerenityOS. Commit 6a728e2d761601a9d21f2269e2febbfde55b3646 introduced the MMIO method for all devices, breaking Bochs and VirtualBox compatibility. Later in commit 6a9dc5562db9e6b0c519f9e7439e6964b326c419 the classic IO method was restored for VirtualBox graphics adapters. QEMU and Bochs use the same PCI VID/DID (0x1234/0x1111) for the emulated VGA adapter. To distinguish betwen QEMU and Bochs we use the PCI revision ID field (0=Bochs, 2=QEMU).
2022-02-18Kernel: Don't enable write-combine for the Bochs framebuffer deviceTom
While write-combine greatly improves performance on bare metal, QEMU appears to perform significantly worse when enabling it.
2022-02-13Kernel: Fix deadlock when setting VirtIOGPU resolutionSahan Fernando
2022-02-09Kernel: Instantiate a TextModeConsole early on if there's no framebufferLiav A
If the bootloader that loaded us is providing a framebuffer details from the Multiboot protocol then we can instantiate a framebuffer console. Otherwise, we should use a text mode console, assuming that the BIOS and the bootloader didn't try to modeset the screen resolution so we have is a VGA 80x25 text mode being displayed on screen. Since "boot_framebuffer_console" is no longer a good representative as a global variable name, it's changed to g_boot_console to match the fact that it can be assigned with a text mode console and not framebuffer console if needed.
2022-02-09Kernel/Graphics: Don't assert when disabling TextModeConsoleLiav A
Not sure how it's useful to do so, let's not assert if something tries to disable it. If we will use TextModeConsole as a boot console, that console will be disabled after loading an appropriate console to replace it.
2022-02-09Kernel/Graphics: Untie Text mode console from VGACompatibleAdapter classLiav A
Instead, we can construct this type of object without having to instantiate a VGACompatibleAdapter object first. This can help instantiate such console very early on boot to aid debug issues on bare metal hardware.
2022-02-09Kernel: Change static constexpr variables to constexpr where possibleLenny Maiorani
Function-local `static constexpr` variables can be `constexpr`. This can reduce memory consumption, binary size, and offer additional compiler optimizations. These changes result in a stripped x86_64 kernel binary size reduction of 592 bytes.
2022-02-04Kernel: Disable BootFramebufferConsole when drivers create a new oneTom
When GraphicsManagement initializes the drivers we can disable the bootloader framebuffer console. Right now we don't yet fully destroy the no longer needed console as it may be in use by another CPU.
2022-02-04Kernel: Set up an initial boot framebuffer consoleTom
Instead of seeing a black screen until GraphicsManagement was fully initialized, this allows us to see the console output much earlier. So, if the bootloader provided us with a framebuffer, set up a console as early as possible.
2022-02-04Kernel: Separate GenericFramebufferConsole implementationTom
The GenericFramebufferConsoleImpl class implements the logic without taking into account any other details such as synchronization. The GenericFramebufferConsole class then is a simple wrapper around GenericFramebufferConsoleImpl that takes care of synchronization. This allows us to re-use this implementation with e.g. different synchronization schemes.
2022-02-03Kernel: Turn VirtIOGPU operation lock from mutex into spinlockAndreas Kling
2022-02-03Kernel: Protect FramebufferDevice with spinlock instead of mutexAndreas Kling