summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
AgeCommit message (Collapse)Author
2022-01-13Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOrIdan Horowitz
This mostly just moved the problem, as a lot of the callers are not capable of propagating the errors themselves, but it's a step in the right direction.
2022-01-13Kernel: Use KString::formatted in FramebufferDevice::create_framebufferIdan Horowitz
This allows us to avoid the infallible String::formatted.
2022-01-07Everywhere: Fix spelling mistakesmjz19910
2022-01-06Kernel: Only use multiboot framebuffer details if presentTom
We should only look at the framebuffer structure members if the MULTIBOOT_INFO_FRAMEBUFFER_INFO bit is set in the flags field. Also add some logging if we ignored the fbdev command line argument due to either not having a framebuffer provided by the bootloader, or because we don't support the framebuffer format.
2022-01-06Kernel: Add option to force using only the bootloader framebufferTom
This allows forcing the use of only the framebuffer set up by the bootloader and skips instantiating devices for any other graphics cards that may be present.
2022-01-05Kernel: Use MUST + Vector::try_append instead of Vector::appendBrian Gianforcaro
In preparation for making Vector::append unavailable during compilation of the Kernel.
2021-12-29Kernel: Handle promise violations in the syscall handlerBrian Gianforcaro
Previously we would crash the process immediately when a promise violation was found during a syscall. This is error prone, as we don't unwind the stack. This means that in certain cases we can leak resources, like an OwnPtr / RefPtr tracked on the stack. Or even leak a lock acquired in a ScopeLockLocker. To remedy this situation we move the promise violation handling to the syscall handler, right before we return to user space. This allows the code to follow the normal unwind path, and grantees there is no longer any cleanup that needs to occur. The Process::require_promise() and Process::require_no_promises() functions were modified to return ErrorOr<void> so we enforce that the errors are always propagated by the caller.
2021-12-29Kernel: Use Process::require_promise() instead of REQUIRE_PROMISE()Brian Gianforcaro
This change lays the foundation for making the require_promise return an error hand handling the process abort outside of the syscall implementations, to avoid cases where we would leak resources. It also has the advantage that it makes removes a gs pointer read to look up the current thread, then process for every syscall. We can instead go through the Process this pointer in most cases.
2021-12-29Kernel: Fix info leak from padding in GenericFramebufferDevice::ioctlBrian Gianforcaro
In FB_IOCTL_GET_PROPERTIES we were not initializing the padding of the struct, leading to the potential of an kernel information leak if the caller looked back at it's contents. Lets just be extra paranoid and zero initialize all these structs in we store on the stack while handling ioctls(..).
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
2021-12-28Kernel: Remove the kmalloc_eternal heap :^)Andreas Kling
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-18Kernel: Use copy_typed_from_user() in more places :^)Andreas Kling
2021-12-16Kernel+LibC: Move errno definitions to Kernel/API/POSIXsin-ack
This fixes at least half of our LibC includes in the kernel. The source of truth for errno codes and their description strings now lives in Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-11-21Everywhere: Fix spelling of "offsetted"Andreas Kling
This word is actually pretty awkward in context, but this patch merely fixes the spelling instead of finding a better word.
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-10-27Kernel + WindowServer: Re-define the interface to framebuffer devicesLiav A
We create a base class called GenericFramebufferDevice, which defines all the virtual functions that must be implemented by a FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other FramebufferDevice implementations inherit from it. The most important consequence of rearranging the classes is that we now have one IOCTL method, so all drivers should be committed to not override the IOCTL method or make their own IOCTLs of FramebufferDevice. All graphical IOCTLs are known to all FramebufferDevices, and it's up to the specific implementation whether to support them or discard them (so we require extensive usage of KResult and KResultOr, together with virtual characteristic functions). As a result, the interface is much cleaner and understandable to read.
2021-10-27Kernel/Graphics: Rename GraphicsDevice => GenericGraphicsAdapterLiav A
We already use the term adapter for instances of this class, so let's better represent this class by changing its name to what it really is.
2021-10-27Kernel/Graphics: Re-order parameters in VirtIO GraphicsAdapter methodsLiav A
As suggested by @ccapitalK, it makes the interface more neat and clean. The proper order is to get ScanoutID first, then ResourceID and after it everything else that is needed to complete the operation successfully.
2021-10-27Kernel/Graphics: Merge VirtIO GraphicsAdapter and VirtIO GPU codeLiav A
A VirtIO graphics adapter is really the VirtIO GPU, so the virtualized hardware has no distinction between both components so there's no need to put such distinction in software. We might need to split things in the future, but when we do so, we must take proper care to ensure that the interface between the components is correct and use the usual codebase patterns.
2021-10-27Kernel/Graphics: Convert type method => bool vga compatible methodLiav A
We never used that type method except in initialization in GraphicsManagement, and we used it there to query whether the device is VGA compatible or not.
2021-10-27Kernel/Graphics: Force VirtIO Framebuffer to inherit FramebufferDeviceLiav A
The distinction is not justified because a VirtIO Framebuffer device acts much more like a regular FramebufferDevice than a pure BlockDevice.
2021-10-27Kernel/Graphics: Rename VirtIO FrameBufferDevice => FramebufferDeviceLiav A
2021-10-25Kernel: Separate framebuffers from bootmodeBen Wiederhake
Bootmode used to control framebuffers, panic behavior, and SystemServer. This patch factors framebuffer control into a separate flag. Note that the combination 'bootmode=self-test fbdev=on' leads to unexpected behavior, which can only be fixed in a later commit.
2021-10-22Kernel: Make FrameBufferDevice::try_to_set_resolution() return KResultAndreas Kling
2021-10-03Kernel: Use `operator ""sv` in all class_name() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-10-01Kernel: Remove IO.h include from a bunch of placesLiav A
2021-09-29Kernel/PCI: Remove Address from enumeration callbackLiav A
If we need that address, we can always get it from the DeviceIdentifier.
2021-09-29Kernel/PCI: Propagate usage of DeviceIdentifier everywhereLiav A
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-29Kernel: Rename two PCI componentsLiav A
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
2021-09-29Kernel/PCI: Cache more details about PCI devices when enumerating themLiav A
There's no good reason to fetch these values each time we need them.
2021-09-28AK: Add missing AK/Types.h include to VirtIO/Protocol.hHendiadyoin1
How did this even work?
2021-09-27Kernel/Graphics: Modernize somewhat the code of BochsGraphicsAdapterLiav A
Reduce the amount of macros in favor to enum classes.
2021-09-27Kernel/Graphics: Ensure we set BGR format of bochs-display if supportedLiav A
Instead of blindly forcing BGR format on the bochs-display device, let's ensure we do that only on QEMU bochs-display and not on VirtualBox graphics adapter too.
2021-09-27Kernel/Graphics: Force BGR format when modesetting the bochs-displayLiav A
By default bochs-display uses the BGR format, but for future-proof solution, let's force it explicitly to use that format.
2021-09-17Kernel: Introduce the DeviceManagement singletonLiav A
This singleton simplifies many aspects that we struggled with before: 1. There's no need to make derived classes of Device expose the constructor as public anymore. The singleton is a friend of them, so he can call the constructor. This solves the issue with try_create_device helper neatly, hopefully for good. 2. Getting a reference of the NullDevice is now being done from this singleton, which means that NullDevice no longer needs to use its own singleton, and we can apply the try_create_device helper on it too :) 3. We can now defer registration completely after the Device constructor which means the Device constructor is merely assigning the major and minor numbers of the Device, and the try_create_device helper ensures it calls the after_inserting method immediately after construction. This creates a great opportunity to make registration more OOM-safe.
2021-09-11Kernel/Devices: Defer creation of SysFS component after the constructorLiav A
Instead of doing so in the constructor, let's do immediately after the constructor, so we can safely pass a reference of a Device, so the SysFSDeviceComponent constructor can use that object to identify whether it's a block device or a character device. This allows to us to not hold a device in SysFSDeviceComponent with a RefPtr. Also, we also call the before_removing method in both SlavePTY::unref and File::unref, so because Device has that method being overrided, it can ensure the device is removed always cleanly.
2021-09-08Kernel: Make TextModeConsole store VGA window base as VirtualAddressAndreas Kling
2021-09-08Kernel: Remove some unused code in Graphics::TextModeConsoleAndreas Kling
2021-09-08Kernel/Devices: Remove required_mode and device_name methodsLiav A
These methods are no longer needed because SystemServer is able to populate the DevFS on its own. Device absolute_path no longer assume a path to the /dev location, because it really should not assume any path to a Device node. Because StorageManagement still needs to know the storage name, we declare a virtual method only for StorageDevices to override, but this technique should really be removed later on.
2021-09-07Kernel: Rename FileDescription => OpenFileDescriptionAndreas Kling
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
2021-09-07Kernel/PCI: Simplify the entire subsystemLiav A
A couple of things were changed: 1. Semantic changes - PCI segments are now called PCI domains, to better match what they are really. It's also the name that Linux gave, and it seems that Wikipedia also uses this name. We also remove PCI::ChangeableAddress, because it was used in the past but now it's no longer being used. 2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as they made a bunch of unnecessary complexity. Instead, Windowed access is removed entirely (this was tested, but never was benchmarked), so we are left with IO access and memory access options. The memory access option is essentially mapping the PCI bus (from the chosen PCI domain), to virtual memory as-is. This means that unless needed, at any time, there is only one PCI bus being mapped, and this is changed if access to another PCI bus in the same PCI domain is needed. For now, we don't support mapping of different PCI buses from different PCI domains at the same time, because basically it's still a non-issue for most machines out there. 2. OOM-safety is increased, especially when constructing the Access object. It means that we pre-allocating any needed resources, and we try to find PCI domains (if requested to initialize memory access) after we attempt to construct the Access object, so it's possible to fail at this point "gracefully". 3. All PCI API functions are now separated into a different header file, which means only "clients" of the PCI subsystem API will need to include that header file. 4. Functional changes - we only allow now to enumerate the bus after a hardware scan. This means that the old method "enumerate_hardware" is removed, so, when initializing an Access object, the initializing function must call rescan on it to force it to find devices. This makes it possible to fail rescan, and also to defer it after construction from both OOM-safety terms and hotplug capabilities.
2021-09-06Kernel: Use TRY() in Graphics::VirtIOGPU::FrameBufferDeviceAndreas Kling
2021-09-06Kernel: Use TRY() in FramebufferDeviceAndreas Kling
2021-09-06Kernel: Make kernel region allocators return KResultOr<NOP<Region>>Andreas Kling
This expands the reach of error propagation greatly throughout the kernel. Sadly, it also exposes the fact that we're allocating (and doing other fallible things) in constructors all over the place. This patch doesn't attempt to address that of course. That's work for our future selves.
2021-09-05Kernel: Make all Spinlocks use u8 for storage, remove templateBrian Gianforcaro
The default template argument is only used in one place, and it looks like it was probably just an oversight. The rest of the Kernel code all uses u8 as the type. So lets make that the default and remove the unused template argument, as there doesn't seem to be a reason to allow the size to be customizable.
2021-09-05Kernel: Switch static_asserts of a type size to AK::AssertSizeBrian Gianforcaro
This will provide better debug ability when the size comparison fails.
2021-09-05Kernel: Make copy_{from,to}_user() return KResult and use TRY()Andreas Kling
This makes EFAULT propagation flow much more naturally. :^)