mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:42:44 +00:00 
			
		
		
		
	 72b144e9e9
			
		
	
	
		72b144e9e9
		
	
	
	
	
		
			
			Instead of using a clunky switch-case paradigm, we now have all drivers being declaring two methods for their adapter class - create and probe. These methods are linked in each PCIGraphicsDriverInitializer structure, in a new s_initializers static list of them. Then, when we probe for a PCI device, we use each probe method and if there's a match, then the corresponding create method is called. As a result of this change, it's much more easy to add more drivers and the initialization code is more readable.
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			2.1 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 ErrorOr<bool> probe(PCI::DeviceIdentifier const&);
 | |
|     static ErrorOr<NonnullLockRefPtr<GenericGraphicsAdapter>> create(PCI::DeviceIdentifier const&);
 | |
|     virtual ~VMWareGraphicsAdapter() = default;
 | |
| 
 | |
|     virtual StringView device_name() const override { return "VMWareGraphicsAdapter"sv; }
 | |
| 
 | |
|     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 {};
 | |
| };
 | |
| 
 | |
| }
 |