summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
AgeCommit message (Collapse)Author
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. :^)
2021-09-04Kernel/VirtIO: Defer initialization of device out of the constructorLiav A
This ensures we safely handle interrupts (which can call virtual functions), so they don't happen in the constructor - this pattern can lead to a crash, if we are still in the constructor context because not all methods are available for usage (some are pure virtual, so it's possible to call __cxa_pure_virtual). Also, under some conditions like adding a PCI device via PCI-passthrough mechanism in QEMU, it became exposed to the eye that the code asserts on RNG::handle_device_config_change(). That device has no configuration but if the hypervisor still misbehaves and tries to configure it, we should simply return false to indicate nothing happened.
2021-09-03Everywhere: Prevent risky implicit casts of (Nonnull)RefPtrDaniel Bertalan
Our existing implementation did not check the element type of the other pointer in the constructors and move assignment operators. This meant that some operations that would require explicit casting on raw pointers were done implicitly, such as: - downcasting a base class to a derived class (e.g. `Kernel::Inode` => `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp), - casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>` in LibIMAP/Client.cpp) This, of course, allows gross violations of the type system, and makes the need to type-check less obvious before downcasting. Luckily, while adding the `static_ptr_cast`s, only two truly incorrect usages were found; in the other instances, our casts just needed to be made explicit.
2021-08-31Kernel/VirtIO: Remove redundant VirtIO word from filenamesLiav A
Now that all related VirtIO classes are in the VirtIO namespace, let's just remove the redundant VirtIO word from filenames.
2021-08-31Kernel/VirtIO: Move everything into the VirtIO namespaceLiav A
Before of this change, many specific classes to VirtIO were in the Kernel namespace, which polluted it. Everything should be more organized now, but there's still room for improvement later.
2021-08-31Kernel/VirtIO: Remove the m_class_name memberLiav A
This class member was used only to determine the device type when printing messages to the debug log. Instead, remove this class member, and add a quick way to find the device type according to how the VirtIO specification says to do that. This simplifies construction of VirtIODevices a bit, because now the constructor doesn't need to ask for a String identified with the device type.
2021-08-23Kernel: Rename PCI::DeviceController => PCI::DeviceLiav A
Now that the old PCI::Device was removed, we can complete the PCI changes by making the PCI::DeviceController to be named PCI::Device. Really the entire purpose and the distinction between the two was about interrupts, but since this is no longer a problem, just rename it to simplify things further.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-15Kernel: Make Kernel::VMObject allocation functions return KResultOrsin-ack
This makes for nicer handling of errors compared to checking whether a RefPtr is null. Additionally, this will give way to return different types of errors in the future.
2021-08-13Kernel: Move VirtIO code into the Bus source folderLiav A
The VirtIO code handles functionality related to the VirtIO bus, so it really should be in the Bus folder.
2021-08-08Kernel: Remove unused "VGA font" memory region in GraphicsManagementAndreas Kling
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-07Kernel: Move SpinLock.h into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Rename Range => VirtualRangeAndreas Kling
...and also RangeAllocator => VirtualRangeAllocator. This clarifies that the ranges we're dealing with are *virtual* memory ranges and not anything else.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling