summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
AgeCommit message (Collapse)Author
2022-06-11Kernel/Console: Fix gaps between background glyph colorMacDue
2022-06-10Kernel/Graphics: Ensure VMWare and VirtualBox EDIDs have manufacturer IDLiav A
2022-06-10Kernel/Graphics: Ensure generic EDID always has correct checksumLiav A
2022-06-10Kernel/Graphics: Re-organize the DisplayConnector class a bitLiav A
Move methods that are overriding the virtual methods in the File class, to a private access scope in the DisplayConnector class because nobody tries to access them in any derived class of this class.
2022-06-09Kernel/Console: Tidy up code a littleMacDue
- Remove some magic numbers - Remove some duplicate branches - Reduce the amount of casting between u8* and u32* - Some renaming of confusing variables
2022-06-09Kernel/Console: Factor out framebuffer offset and support glyph_spacingMacDue
This allows the 9px width of Cathode to be preserved without increasing the bitmap size.
2022-06-09Kernel/Console: Replace QEMU bitmap font with CathodeMacDue
This has very similar look, but was invented here :^)
2022-06-06Kernel/Graphics: Drop support for the DisplayConnector write interfaceLiav A
The WindowServer doesn't use this interface anymore and therefore it's not used by any userspace application, so let's remove this stale method to ensure we don't have to bother with it anymore.
2022-06-06Kernel/Graphics: Bring back the mmap interface for DisplayConnectorsLiav A
The mmap interface was removed when we introduced the DisplayConnector class, as it was quite unsafe to use and didn't handle switching between graphical and text modes safely. By using the SharedFramebufferVMObject, we are able to elegantly coordinate the switch by remapping the attached mmap'ed-Memory::Region(s) with different mappings, therefore, keeping WindowServer to think that the mappings it has are still valid, while they are going to a different physical range until we are back to the graphical mode (after a switch from text mode). Most drivers take advantage of the fact that we know where is the actual framebuffer in physical memory space, the SharedFramebufferVMObject is created with that information. However, the VirtIO driver is different in that aspect, because it relies on DMA transactions to show graphics on the framebuffer, so the SharedFramebufferVMObject is created with that mindset to support the arbitrary framebuffer location in physical memory space.
2022-06-06Kernel/Graphics: Flush the entire buffer if using VirtIO consoleLiav A
Keeping the exact details of a dirty rectangle doesn't make any sense when we just flush the entire screen, so just keep a simple boolean value to know if the screen needs to be flushed or not.
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.