mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 09:04:30 +00:00
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.
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Bus/PCI/Device.h>
|
|
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
|
#include <Kernel/Graphics/VMWare/Definitions.h>
|
|
#include <Kernel/IOWindow.h>
|
|
#include <Kernel/Locking/Spinlock.h>
|
|
#include <Kernel/Memory/TypedMapping.h>
|
|
#include <Kernel/PhysicalAddress.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class GraphicsManagement;
|
|
|
|
class VMWareDisplayConnector;
|
|
class VMWareGraphicsAdapter final
|
|
: public GenericGraphicsAdapter
|
|
, public PCI::Device {
|
|
friend class GraphicsManagement;
|
|
|
|
public:
|
|
static LockRefPtr<VMWareGraphicsAdapter> try_initialize(PCI::DeviceIdentifier const&);
|
|
virtual ~VMWareGraphicsAdapter() = default;
|
|
|
|
ErrorOr<void> modeset_primary_screen_resolution(Badge<VMWareDisplayConnector>, size_t width, size_t height);
|
|
size_t primary_screen_width(Badge<VMWareDisplayConnector>) const;
|
|
size_t primary_screen_height(Badge<VMWareDisplayConnector>) const;
|
|
size_t primary_screen_pitch(Badge<VMWareDisplayConnector>) const;
|
|
void primary_screen_flush(Badge<VMWareDisplayConnector>, size_t current_width, size_t current_height);
|
|
|
|
private:
|
|
ErrorOr<void> initialize_adapter();
|
|
ErrorOr<void> initialize_fifo_registers();
|
|
ErrorOr<void> negotiate_device_version();
|
|
|
|
u32 read_io_register(VMWareDisplayRegistersOffset) const;
|
|
void write_io_register(VMWareDisplayRegistersOffset, u32 value);
|
|
|
|
void print_svga_capabilities() const;
|
|
void modeset_primary_screen_resolution(size_t width, size_t height);
|
|
|
|
VMWareGraphicsAdapter(PCI::DeviceIdentifier const&, NonnullOwnPtr<IOWindow> registers_io_window);
|
|
|
|
Memory::TypedMapping<VMWareDisplayFIFORegisters volatile> m_fifo_registers;
|
|
LockRefPtr<VMWareDisplayConnector> m_display_connector;
|
|
mutable NonnullOwnPtr<IOWindow> m_registers_io_window;
|
|
mutable Spinlock<LockRank::None> m_io_access_lock {};
|
|
mutable RecursiveSpinlock<LockRank::None> m_operation_lock {};
|
|
};
|
|
|
|
}
|