summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
AgeCommit message (Collapse)Author
2023-01-05Kernel: Add dmesgln_pci logging for Kernel::PCIEvan Smal
A virtual method named device_name() was added to Kernel::PCI to support logging the PCI::Device name and address using dmesgln_pci. Previously, PCI::Device did not store the device name. All devices inheriting from PCI::Device now use dmesgln_pci where they previously used dmesgln.
2023-01-02Kernel: Remove unused includes of Kernel/Debug.hBen Wiederhake
These instances were detected by searching for files that include Kernel/Debug.h, but don't match the regex: \\bdbgln_if\(|_DEBUG\\b This regex is pessimistic, so there might be more files that don't check for any real *_DEBUG macro. There seem to be no corner cases anyway. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Kernel: Turn lock ranks into template parameterskleines Filmröllchen
This step would ideally not have been necessary (increases amount of refactoring and templates necessary, which in turn increases build times), but it gives us a couple of nice properties: - SpinlockProtected inside Singleton (a very common combination) can now obtain any lock rank just via the template parameter. It was not previously possible to do this with SingletonInstanceCreator magic. - SpinlockProtected's lock rank is now mandatory; this is the majority of cases and allows us to see where we're still missing proper ranks. - The type already informs us what lock rank a lock has, which aids code readability and (possibly, if gdb cooperates) lock mismatch debugging. - The rank of a lock can no longer be dynamic, which is not something we wanted in the first place (or made use of). Locks randomly changing their rank sounds like a disaster waiting to happen. - In some places, we might be able to statically check that locks are taken in the right order (with the right lock rank checking implementation) as rank information is fully statically known. This refactoring even more exposes the fact that Mutex has no lock rank capabilites, which is not fixed here.
2022-12-31Kernel/Graphics: Restore VirtIO GPU framebuffer console functionalityLiav A
This has been done in multiple ways: - Each time we modeset the resolution via the VirtIOGPU DisplayConnector we ensure that the framebuffer is updated with the new resolution. - Each time the cursor is updated we ensure that the framebuffer console is marked dirty so the IO Work Queue task which is scheduled to check if it is dirty, will flush the surface. - We only initialize a framebuffer console after we ensure that at the very least a DisplayConnector has being set with a known resolution. - We only call GenericFramebufferConsole::enable() when enabling the console after the important variables of the console (m_width, m_pitch and m_height) have been set.
2022-12-28Kernel: Reorganize Arch/x86 directory to Arch/x86_64 after i686 removalLiav A
No functional change.
2022-12-28Kernel: Remove i686 supportLiav A
2022-12-26Kernel/Graphics: Increase VirtIO GPU transfer buffer size to 4MiBStephan Unverwerth
This is necessary to allow transferring frame buffers larger than ~500x500 pixels back to user space. Until the buffer management is improved this allows us to at least test the existing game ports.
2022-12-22AK+Everywhere: Replace all Bitmap::must_create() uses with ::create()Sam Atkins
Well, *someone* has to add some more FIXMEs to keep FIXME Roulette going. :^)
2022-12-19Kernel/Graphics: Propagate errors properly around in the VirtIO driverLiav A
This happens to be a sad truth for the VirtIOGPU driver - it lacked any error propagation measures and generally relied on clunky assumptions that most operations with the GPU device are infallible, although in reality much of them could fail, so we do need to handle errors. To fix this, synchronous GPU commands no longer rely on the wait queue mechanism anymore, so instead we introduce a timeout-based mechanism, similar to how other Kernel drivers use a polling based mechanism with the assumption that hardware could get stuck in an error state and we could abort gracefully. Then, we change most of the VirtIOGraphicsAdapter methods to propagate errors properly to the original callers, to ensure that if a synchronous GPU command failed, either the Kernel or userspace could do something meaningful about this situation.
2022-12-19Kernel/Graphics: Disable double buffering for the VirtIO driverLiav A
The performance that we achieve from this technique is visually worse compared to turning off this feature, so let's not use this until we figure out why it happens.
2022-12-19Kernel: Properly propagate errors in VirtIOGPU 3D device initializationLiav A
2022-12-15Kernel: Allocate VirtIOGPU context IDs from a bitmap, with ErrorOrSam Atkins
As is, we never *deallocate* them, so we will run out eventually. Creating a context, or allocating a context ID, now returns ErrorOr if there are no available free context IDs. `number_of_fixmes--;` :^)
2022-12-15Kernel: Remove unimplemented VirGL adapter's edid_feature_accepted()Sam Atkins
2022-12-15Kernel: Remove Badged `VirtIOGraphicsAdapter::allocate_FOO_id()` methodsSam Atkins
These are unused, so let's remove them. `number_of_fixmes--;` :^)
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-11-03Everywhere: Clean up "the the" comment typosNico Weber
2022-10-26Kernel: Move bar0_space_size declaration out of arch-specific ifdefsTimon Kruiper
This change allows this file to be built for aarch64.
2022-10-23Kernel/Graphics: Handle correctly unknown ioctls on a DisplayConnectorLiav A
In such case, we should not assert but instead just return EINVAL.
2022-10-01Kernel/aarch64: Get framebuffer data from BootFramebufferConsoleTimon Kruiper
The BootFramebufferConsole class maps the framebuffer using the MemoryManager, so to be able to draw the logo, we need to get this mapped framebuffer. This commit adds a unsafe API for that.
2022-10-01Kernel/aarch64: Remove specific aarch64 code in BootFramebufferConsoleTimon Kruiper
The MemoryManager now works, so we can use the same code as on x86 to map the framebuffer. Since it uses the MemoryManager, the initialization of the BootFramebufferConsole has to happen after the MemoryManager is working.
2022-09-24Kernel+Userland: Provide bytes count for a DisplayConnector framebufferLiav A
This value will be used later on by WindowServer to reject resolutions that will request a mapping that will overflow the hardware framebuffer max length.
2022-09-23Kernel: Introduce the IOWindow classLiav A
This class is intended to replace all IOAddress usages in the Kernel codebase altogether. The idea is to ensure IO can be done in arch-specific manner that is determined mostly in compile-time, but to still be able to use most of the Kernel code in non-x86 builds. Specific devices that rely on x86-specific IO instructions are already placed in the Arch/x86 directory and are omitted for non-x86 builds. The reason this works so well is the fact that x86 IO space acts in a similar fashion to the traditional memory space being available in most CPU architectures - the x86 IO space is essentially just an array of bytes like the physical memory address space, but requires x86 IO instructions to load and store data. Therefore, many devices allow host software to interact with the hardware registers in both ways, with a noticeable trend even in the modern x86 hardware to move away from the old x86 IO space to exclusively using memory-mapped IO. Therefore, the IOWindow class encapsulates both methods for x86 builds. The idea is to allow PCI devices to be used in either way in x86 builds, so when trying to map an IOWindow on a PCI BAR, the Kernel will try to find the proper method being declared with the PCI BAR flags. For old PCI hardware on non-x86 builds this might turn into a problem as we can't use port mapped IO, so the Kernel will gracefully fail with ENOTSUP error code if that's the case, as there's really nothing we can do within such case. For general IO, the read{8,16,32} and write{8,16,32} methods are available as a convenient API for other places in the Kernel. There are simply no direct 64-bit IO API methods yet, as it's not needed right now and is not considered to be Arch-agnostic too - the x86 IO space doesn't support generating 64 bit cycle on IO bus and instead requires two 2 32-bit accesses. If for whatever reason it appears to be necessary to do IO in such manner, it could probably be added with some neat tricks to do so. It is recommended to use Memory::TypedMapping struct if direct 64 bit IO is actually needed.
2022-09-23Kernel/Graphics: Move x86-specific support for VGA to Arch/x86 directoryLiav A
The new VGAIOArbiter class is now responsible to conduct x86-specific instructions to control VGA hardware from the old ISA ports. This allows us to ensure the GraphicsManagement code doesn't use x86-specific code, thus allowing it to be compiled within non-x86 kernel builds.
2022-09-20Kernel: Ensure proper locking when mutating boot console cursorLiav A
The BootFramebufferConsole highly depends on using the m_lock spinlock, therefore setting and changing the cursor state should be done under that spinlock too to avoid crashing.
2022-09-20Kernel: Mark Console::{hide,show}_cursor methods protectedLiav A
Only the Console code in the Graphics directory should be able to call on these methods. The set_cursor method stays public as VirtualConsole uses that method to change the cursor position.
2022-09-20Kernel/Graphics: Introduce support for QEMU isa-vga deviceLiav A
This device is supposed to be used in microvm and ISA-PC machine types, and we assume that if we are able to probe for the QEMU BGA version of 0xB0C5, then we have an existing ISA Bochs VGA adapter to utilize. To ensure we don't instantiate the driver for non isa-vga devices, we try to ensure that PCI is disabled because hardware IO test probe failed so we can be sure that we use this special handling code only in the QEMU microvm and ISA-PC machine types. Unfortunately, this means that if for some reason the isa-vga device is attached for the i440FX or Q35 machine types, we simply are not able to drive the device in such setups at all. To determine the amount of VRAM being available, we read VBE register at offset 0xA. That register holds the amount of VRAM divided by 64K, so we need to multiply the value in our code to use the actual VRAM size value again. The isa-vga device requires us to hardcode the framebuffer physical address to 0xE0000000, and that address is not expected to change in the future as many other projects rely on the isa-vga framebuffer to be present at that physical memory address.
2022-09-20Kernel/Graphics: Always ensure a console is set when initialization endsLiav A
We use a ScopeGuard to ensure we always set a console of some sort if we exit early from the initialization sequence in the GraphicsManagement code. We do so to ensure we can boot into text mode console in an ISA-PC machine type, because earlier we failed with an assertion due to not setting any console for VirtualConsole to use.
2022-09-20Kernel: Move x86 Bochs VBE code to the Arch/x86 directoryLiav A
To do this, we make the QEMUDisplayConnector class more standalone so it does not need to inherit from the BochsDisplayConnector class.
2022-09-20Kernel/PCI: Convert PCI BAR number to a strong typed enum classLiav A
2022-09-20Kernel: Remove stale includes of x86 IO header fileLiav A
The AHCI code doesn't rely on x86 IO at all as it only uses memory mapped IO so we can simply remove the header. We also simply don't use x86 IO in the Intel graphics driver, so we can simply remove the include of the x86 IO header there too. Everything else was a bunch of stale includes to the x86 IO header and are actually not necessary, so let's remove them to make it easier to compile non-x86 Kernel builds.
2022-09-20Kernel: Move IO delay code to x86 architecture subdirectoryLiav A
Many code patterns and hardware procedures rely on reliable delay in the microseconds granularity, and since they are using such delays which are valid cases, but should not rely on x86 specific code, we allow to determine in compile time the proper platform-specific code to use to invoke such delays.
2022-08-24Kernel: Simplify the File memory-mapping APIAndreas Kling
Before this change, we had File::mmap() which did all the work of setting up a VMObject, and then creating a Region in the current process's address space. This patch simplifies the interface by removing the region part. Files now only have to return a suitable VMObject from vmobject_for_mmap(), and then sys$mmap() itself will take care of actually mapping it into the address space. This fixes an issue where we'd try to block on I/O (for inode metadata lookup) while holding the address space spinlock. It also reduces time spent holding the address space lock.
2022-08-24Kernel: Wrap process address spaces in SpinlockProtectedAndreas Kling
This forces anyone who wants to look into and/or manipulate an address space to lock it. And this replaces the previous, more flimsy, manual spinlock use. Note that pointers *into* the address space are not safe to use after you unlock the space. We've got many issues like this, and we'll have to track those down as wlel.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
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-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-08-19Kernel: Require lock rank for Spinlock constructionkleines Filmröllchen
All users which relied on the default constructor use a None lock rank for now. This will make it easier to in the future remove LockRank and actually annotate the ranks by searching for None.
2022-08-14Kernel: Move TrapFrame into its own header on aarch64Filiph Sandström
2022-07-24Kernel/SysFS: Fix parent directory hierarchy with symbolic linksLiav A
We should actually start counting from the parent directory and not from the symbolic link as it will represent a wrong count of hops from the actual mountpoint. The symlinks in /sys/dev/block and /sys/dev/char worked only by luck, because I have set it to the wrong parent directory which is the /sys/dev directory, so with the symlink it was 3 hops to /sys, together with the root directory, therefore, everything seemed to work. Now that the device symlinks in /sys/dev/block and /sys/dev/char are set to the right parent directory and we start measure hops from root directory with the parent directory of a symlink, everything seem to work correctly now.
2022-07-23Kernel+Userland: Add ioctl to set process ownership of DisplayConnectorLiav A
Now that the infrastructure of the Graphics subsystem is quite stable, it is time to try to fix a long-standing problem, which is the lack of locking on display connector devices. Reading and writing from multiple processes to a framebuffer controlled by the display connector is not a huge problem - it could be solved with POSIX locking. The real problem is some program that will try to do ioctl operations on a display connector without the WindowServer being aware of that which can lead to very bad situations, for example - assuming a framebuffer is encoded at a known resolution and certain display timings, but another process changed the ModeSetting of the display connector, leading to inconsistency on the properties of the current ModeSetting. To solve this, there's a new "master" ioctl to take "ownership" and another one to release that ownership of a display connector device. To ensure we will not hold a Process object forever just because it has an ownership over a display connector, we hold it with a weak reference, and if the process is gone, someone else can take an ownership.
2022-07-23Kernel/Graphics: Remove out-of-context comment noteLiav A
2022-07-22Everywhere: Prefix 'TYPEDEF_DISTINCT_ORDERED_ID' with 'AK_'Linus Groh
2022-07-19Kernel+Userland: Remove GRAPHICS_IOCTL_GET_HEAD_EDID ioctlLiav A
We are able to read the EDID from SysFS, therefore there's no need to provide this ioctl on a DisplayConnector anymore. Also, now we can simply require the video pledge to be set before doing any ioctl on a DisplayConnector.
2022-07-19Kernel/Devices: Abstract SysFS Device add/remove methods more properlyLiav A
It is starting to get a little messy with how each device can try to add or remove itself to either /sys/dev/block or /sys/dev/char directories. To better do this, we introduce 4 virtual methods to take care of that, so until we ensure all nodes in /sys/dev/block and /sys/dev/char are actual symlinks, we allow the Device base class to call virtual methods upon insertion or before being destroying, so it add itself elegantly to either of these directories or remove itself when needed. For special cases where we need to create symlinks, we have two virtual methods to be called otherwise to do almost the same thing mentioned before, but to use symlinks instead.
2022-07-19Kernel/SysFS: Add exposing interface for DisplayConnectorsLiav A
Under normal conditions (when mounting SysFS in /sys), there will be a new directory in the /sys/devices directory called "graphics". For now, under that directory there will be only a sub-directory called "connectors" which will contain all DisplayConnectors' details, each in its own sub-directory too, distinguished in naming with its minor number. Therefore, /sys/devices/graphics/connectors/MINOR_NUMBER/ will contain: - General device attributes such as mutable_mode_setting_capable, double_buffering_capable, flush_support, partial_flush_support and refresh_rate_support. These values are exposed in the ioctl interface of the DisplayConnector class too, but these can be useful later on for command line utilities that want/need to expose these basic settings. - The EDID blob, simply named "edid". This will help userspace to fetch the edid without the need of using the ioctl interface later on.
2022-07-15Kernel/Graphics: Remove GenericGraphicsAdapter::vga_compatible methodLiav A
There's no point in keeping this method as we don't really care if a graphics adapter is VGA compatible or not because we don't use this method anymore.
2022-07-13Kernel/Graphics: Allocate VGA window region according to the usual rulesLiav A
We should not allocate a kernel region inside the constructor of the VGATextModeConsole class. We do use MUST() because allocation cannot fail at this point, but that happens in the static factory method instead.
2022-07-13Kernel/Graphics: Rename m_vga_region => m_vga_window_regionLiav A
2022-07-13Kernel/Graphics: Rename TextModeConsole => VGATextModeConsoleLiav A
This change represents well the fact that the text mode console is based on VGA text mode.
2022-07-13Kernel/Graphics: Remove unnecessary VGAConsole class abstractionLiav A
The original intention was to support other types of consoles based on standard VGA modes, but it never came to an implementation, nor we need such feature at all. Therefore, this class is not needed and can be removed.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.